No more ick tabs.
[reactos.git] / reactos / lib / iphlpapi / ipstats_reactos.c
index 4f5e6da..1651d0a 100644 (file)
@@ -68,18 +68,18 @@ BOOL isIpEntity( HANDLE tcpFile, TDIEntityID *ent ) {
     req.ID.toi_entity = *ent;
 
     status = 
-       DeviceIoControl
-       ( tcpFile,
-         IOCTL_TCP_QUERY_INFORMATION_EX,
-         &req,
-         sizeof(req),
-         &entityType,
-         sizeof(entityType),
-         &returnedLen,
-         NULL );
+        DeviceIoControl
+        ( tcpFile,
+          IOCTL_TCP_QUERY_INFORMATION_EX,
+          &req,
+          sizeof(req),
+          &entityType,
+          sizeof(entityType),
+          &returnedLen,
+          NULL );
 
     DPRINT("Ent: %04x:d -> %04x\n", 
-          ent->tei_entity, ent->tei_instance, entityType );
+           ent->tei_entity, ent->tei_instance, entityType );
 
     return NT_SUCCESS(status) && entityType == CL_NL_IP;
 }
@@ -92,25 +92,25 @@ NTSTATUS getNthIpEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent ) {
     int i;
 
     if( !NT_SUCCESS(status) )
-       return status;
+        return status;
 
     for( i = 0; i < numEntities; i++ ) {
-       if( isIpEntity( tcpFile, &entitySet[i] ) ) {
-           DPRINT("Entity %d is an IP Entity\n", i);
-           if( numRoutes == index ) break;
-           else numRoutes++;
-       }
+        if( isIpEntity( tcpFile, &entitySet[i] ) ) {
+            DPRINT("Entity %d is an IP Entity\n", i);
+            if( numRoutes == index ) break;
+            else numRoutes++;
+        }
     }
 
     if( numRoutes == index && i < numEntities ) {
-       DPRINT("Index %d is entity #%d - %04x:%08x\n", index, i, 
-              entitySet[i].tei_entity, entitySet[i].tei_instance );
-       memcpy( ent, &entitySet[i], sizeof(*ent) );
-       tdiFreeThingSet( entitySet );
-       return STATUS_SUCCESS;
+        DPRINT("Index %d is entity #%d - %04x:%08x\n", index, i, 
+               entitySet[i].tei_entity, entitySet[i].tei_instance );
+        memcpy( ent, &entitySet[i], sizeof(*ent) );
+        tdiFreeThingSet( entitySet );
+        return STATUS_SUCCESS;
     } else {
-       tdiFreeThingSet( entitySet );
-       return STATUS_UNSUCCESSFUL;
+        tdiFreeThingSet( entitySet );
+        return STATUS_UNSUCCESSFUL;
     }
 }
 
@@ -123,7 +123,7 @@ NTSTATUS tdiGetMibForIpEntity
     memset( entry, 0, sizeof( *entry ) );
 
     DPRINT("TdiGetMibForIpEntity(tcpFile %x,entityId %x)\n",
-          (DWORD)tcpFile, ent->tei_instance);
+           (DWORD)tcpFile, ent->tei_instance);
 
     req.ID.toi_class                = INFO_CLASS_PROTOCOL;
     req.ID.toi_type                 = INFO_TYPE_PROVIDER;
@@ -131,40 +131,40 @@ NTSTATUS tdiGetMibForIpEntity
     req.ID.toi_entity               = *ent;
 
     status = DeviceIoControl( tcpFile,
-                             IOCTL_TCP_QUERY_INFORMATION_EX,
-                             &req,
-                             sizeof(req),
-                             entry,
-                             sizeof(*entry),
-                             &returnSize,
-                             NULL );
+                              IOCTL_TCP_QUERY_INFORMATION_EX,
+                              &req,
+                              sizeof(req),
+                              entry,
+                              sizeof(*entry),
+                              &returnSize,
+                              NULL );
 
     DPRINT("TdiGetMibForIpEntity() => {\n"
-          "  ipsi_forwarding ............ %d\n"
-          "  ipsi_defaultttl ............ %d\n"
-          "  ipsi_inreceives ............ %d\n"
-          "  ipsi_indelivers ............ %d\n"
-          "  ipsi_outrequests ........... %d\n"
-          "  ipsi_routingdiscards ....... %d\n"
-          "  ipsi_outdiscards ........... %d\n"
-          "  ipsi_outnoroutes ........... %d\n"
-          "  ipsi_numif ................. %d\n"
-          "  ipsi_numaddr ............... %d\n"
-          "  ipsi_numroutes ............. %d\n"
-          "} status %08x\n",
-          entry->ipsi_forwarding,
-          entry->ipsi_defaultttl,
-          entry->ipsi_inreceives,
-          entry->ipsi_indelivers,
-          entry->ipsi_outrequests,
-          entry->ipsi_routingdiscards,
-          entry->ipsi_outdiscards,
-          entry->ipsi_outnoroutes,
-          entry->ipsi_numif,
-          entry->ipsi_numaddr,
-          entry->ipsi_numroutes,
-          status);
-       
+           "  ipsi_forwarding ............ %d\n"
+           "  ipsi_defaultttl ............ %d\n"
+           "  ipsi_inreceives ............ %d\n"
+           "  ipsi_indelivers ............ %d\n"
+           "  ipsi_outrequests ........... %d\n"
+           "  ipsi_routingdiscards ....... %d\n"
+           "  ipsi_outdiscards ........... %d\n"
+           "  ipsi_outnoroutes ........... %d\n"
+           "  ipsi_numif ................. %d\n"
+           "  ipsi_numaddr ............... %d\n"
+           "  ipsi_numroutes ............. %d\n"
+           "} status %08x\n",
+           entry->ipsi_forwarding,
+           entry->ipsi_defaultttl,
+           entry->ipsi_inreceives,
+           entry->ipsi_indelivers,
+           entry->ipsi_outrequests,
+           entry->ipsi_routingdiscards,
+           entry->ipsi_outdiscards,
+           entry->ipsi_outnoroutes,
+           entry->ipsi_numif,
+           entry->ipsi_numaddr,
+           entry->ipsi_numroutes,
+           status);
+        
     return status;    
 }
 
@@ -173,17 +173,17 @@ NTSTATUS tdiGetRoutesForIpEntity
     NTSTATUS status = STATUS_SUCCESS;
 
     DPRINT("TdiGetRoutesForIpEntity(tcpFile %x,entityId %x)\n",
-          (DWORD)tcpFile, ent->tei_instance);
+           (DWORD)tcpFile, ent->tei_instance);
 
     status = tdiGetSetOfThings( tcpFile,
-                               INFO_CLASS_PROTOCOL,
-                               INFO_TYPE_PROVIDER,
-                               IP_MIB_ROUTETABLE_ENTRY_ID,
-                               ent->tei_entity,
-                               0,
-                               sizeof(IPRouteEntry),
-                               (PVOID *)routes,
-                               numRoutes);
+                                INFO_CLASS_PROTOCOL,
+                                INFO_TYPE_PROVIDER,
+                                IP_MIB_ROUTETABLE_ENTRY_ID,
+                                ent->tei_entity,
+                                0,
+                                sizeof(IPRouteEntry),
+                                (PVOID *)routes,
+                                numRoutes);
 
     return status;    
 }
@@ -193,17 +193,17 @@ NTSTATUS tdiGetIpAddrsForIpEntity
     NTSTATUS status;
 
     DPRINT("TdiGetIpAddrsForIpEntity(tcpFile %x,entityId %x)\n",
-          (DWORD)tcpFile, ent->tei_instance);
+           (DWORD)tcpFile, ent->tei_instance);
 
     status = tdiGetSetOfThings( tcpFile, 
-                               INFO_CLASS_PROTOCOL, 
-                               INFO_TYPE_PROVIDER,
-                               IP_MIB_ADDRTABLE_ENTRY_ID,
-                               ent->tei_entity,
-                               0,
-                               sizeof(IPAddrEntry),
-                               (PVOID *)addrs,
-                               numAddrs );
+                                INFO_CLASS_PROTOCOL, 
+                                INFO_TYPE_PROVIDER,
+                                IP_MIB_ADDRTABLE_ENTRY_ID,
+                                ent->tei_entity,
+                                0,
+                                sizeof(IPAddrEntry),
+                                (PVOID *)addrs,
+                                numAddrs );
 
     return status;    
 }
@@ -389,28 +389,28 @@ DWORD getNumRoutes(void)
     status = openTcpFile( &tcpFile );
 
     if( !NT_SUCCESS(status) ) {
-       TRACE("failure: %08x\n", (int)status );
-       return 0;
+        TRACE("failure: %08x\n", (int)status );
+        return 0;
     }
 
     status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities );
 
     if( !NT_SUCCESS(status) ) {
-       TRACE("failure: %08x\n", (int)status );
-       return 0;
+        TRACE("failure: %08x\n", (int)status );
+        return 0;
     }
 
     for( i = 0; i < numEntities; i++ ) {
-       if( isIpEntity( tcpFile, &entitySet[i] ) ) {
-           IPSNMPInfo isnmp;
-           memset( &isnmp, 0, sizeof( isnmp ) );
-           status = tdiGetMibForIpEntity( tcpFile, &entitySet[i], &isnmp );
-           if( !NT_SUCCESS(status) ) {
-               tdiFreeThingSet( entitySet );
-               return status;
-           }
-           numRoutes += isnmp.ipsi_numroutes;
-       }
+        if( isIpEntity( tcpFile, &entitySet[i] ) ) {
+            IPSNMPInfo isnmp;
+            memset( &isnmp, 0, sizeof( isnmp ) );
+            status = tdiGetMibForIpEntity( tcpFile, &entitySet[i], &isnmp );
+            if( !NT_SUCCESS(status) ) {
+                tdiFreeThingSet( entitySet );
+                return status;
+            }
+            numRoutes += isnmp.ipsi_numroutes;
+        }
     }
 
     TRACE("numRoutes: %d\n", (int)numRoutes);
@@ -424,11 +424,11 @@ VOID HexDump( PCHAR Data, DWORD Len ) {
     int i;
 
     for( i = 0; i < Len; i++ ) {
-       if( !(i & 0xf) ) {
-           if( i ) fprintf(stderr,"\n");
-           fprintf(stderr,"%08x:", i);
-       }
-       fprintf( stderr, " %02x", Data[i] & 0xff );
+        if( !(i & 0xf) ) {
+            if( i ) fprintf(stderr,"\n");
+            fprintf(stderr,"%08x:", i);
+        }
+        fprintf( stderr, " %02x", Data[i] & 0xff );
     }
     fprintf(stderr,"\n");
 }
@@ -444,55 +444,55 @@ RouteTable *getRouteTable(void)
     int i;
 
     if( !NT_SUCCESS(status) )
-       return 0;
+        return 0;
 
     out_route_table = HeapAlloc( GetProcessHeap(), 0, 
-                                sizeof(RouteTable) + 
-                                (sizeof(RouteEntry) * (numRoutes - 1)) );
+                                 sizeof(RouteTable) + 
+                                 (sizeof(RouteEntry) * (numRoutes - 1)) );
     
     out_route_table->numRoutes = numRoutes;
 
     for( i = 0; routesAdded < numRoutes; i++ ) {
-       int j;
-       IPRouteEntry *route_set;
+        int j;
+        IPRouteEntry *route_set;
 
-       getNthIpEntity( tcpFile, i, &ent );
-       tdiGetMibForIpEntity( tcpFile, &ent, &snmpInfo );
+        getNthIpEntity( tcpFile, i, &ent );
+        tdiGetMibForIpEntity( tcpFile, &ent, &snmpInfo );
 
-       DPRINT( "%d routes in instance %d\n", snmpInfo.ipsi_numroutes, i );
+        DPRINT( "%d routes in instance %d\n", snmpInfo.ipsi_numroutes, i );
 
-       if( !route_set ) {
-           closeTcpFile( tcpFile );
-           HeapFree( GetProcessHeap(), 0, out_route_table );
-           return 0;
-       }
+        if( !route_set ) {
+            closeTcpFile( tcpFile );
+            HeapFree( GetProcessHeap(), 0, out_route_table );
+            return 0;
+        }
 
-       tdiGetRoutesForIpEntity( tcpFile, &ent, &route_set, &numRoutes );
+        tdiGetRoutesForIpEntity( tcpFile, &ent, &route_set, &numRoutes );
 
-       DPRINT("Route set returned\n");
+        DPRINT("Route set returned\n");
 #if 0
-       HexDump( route_set, 
-                sizeof( IPRouteEntry ) * 
-                snmpInfo.ipsi_numroutes );
+        HexDump( route_set, 
+                 sizeof( IPRouteEntry ) * 
+                 snmpInfo.ipsi_numroutes );
 #endif
 
-       for( j = 0; j < snmpInfo.ipsi_numroutes; j++ ) {
-           int routeNum = j + routesAdded;
-           out_route_table->routes[routeNum].dest = 
-               route_set[j].ire_dest;
-           out_route_table->routes[routeNum].mask =
-               route_set[j].ire_mask;
-           out_route_table->routes[routeNum].gateway =
-               route_set[j].ire_gw;
-           out_route_table->routes[routeNum].ifIndex =
-               route_set[j].ire_index;
-           out_route_table->routes[routeNum].metric =
-               route_set[j].ire_metric;
-       }
-
-       if( route_set ) tdiFreeThingSet( route_set );
-
-       routesAdded += snmpInfo.ipsi_numroutes;
+        for( j = 0; j < snmpInfo.ipsi_numroutes; j++ ) {
+            int routeNum = j + routesAdded;
+            out_route_table->routes[routeNum].dest = 
+                route_set[j].ire_dest;
+            out_route_table->routes[routeNum].mask =
+                route_set[j].ire_mask;
+            out_route_table->routes[routeNum].gateway =
+                route_set[j].ire_gw;
+            out_route_table->routes[routeNum].ifIndex =
+                route_set[j].ire_index;
+            out_route_table->routes[routeNum].metric =
+                route_set[j].ire_metric;
+        }
+
+        if( route_set ) tdiFreeThingSet( route_set );
+
+        routesAdded += snmpInfo.ipsi_numroutes;
     }
 
     return out_route_table;