[TCPIP] Define a enum to select which information to return
authorPierre Schweitzer <pierre@reactos.org>
Tue, 27 Nov 2018 07:27:00 +0000 (08:27 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Tue, 27 Nov 2018 20:36:41 +0000 (21:36 +0100)
drivers/network/tcpip/include/info.h
drivers/network/tcpip/tcpip/info.c
drivers/network/tcpip/tcpip/ninfo.c

index 358a8b0..8866a01 100644 (file)
@@ -80,6 +80,12 @@ typedef union TDI_INFO {
     TDI_PROVIDER_STATISTICS ProviderStats;
 } TDI_INFO, *PTDI_INFO;
 
+typedef enum TDI_TCPUDP_CLASS_INFO {
+    TcpUdpClassBasic,
+    TcpUdpClassOwnerPid,
+    TcpUdpClassOwner
+} TDI_TCPUDP_CLASS_INFO, *PTDI_TCPUDP_CLASS_INFO;
+
 TDI_STATUS InfoCopyOut( PCHAR DataOut, UINT SizeOut,
                        PNDIS_BUFFER ClientBuf, PUINT ClientBufSize );
 
@@ -117,12 +123,12 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF,
 TDI_STATUS InfoTdiQueryGetConnectionTcpTable( PADDRESS_FILE AddrFile,
                                               PNDIS_BUFFER Buffer,
                                               PUINT BufferSize,
-                                              BOOLEAN Extended);
+                                              TDI_TCPUDP_CLASS_INFO Class);
 
 TDI_STATUS InfoTdiQueryGetConnectionUdpTable( PADDRESS_FILE AddrFile,
                                               PNDIS_BUFFER Buffer,
                                               PUINT BufferSize,
-                                              BOOLEAN Extended);
+                                              TDI_TCPUDP_CLASS_INFO Class);
 
 TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF,
                            PVOID Buffer,
index b64e861..674fb96 100644 (file)
@@ -268,12 +268,12 @@ TDI_STATUS InfoTdiQueryInformationEx(
                     return InfoTdiQueryGetAddrTable(ID->toi_entity, Buffer, BufferSize);
                 else if (ID->toi_entity.tei_entity == CO_TL_ENTITY)
                      if ((EntityListContext = GetContext(ID->toi_entity)))
-                         return InfoTdiQueryGetConnectionTcpTable(EntityListContext, Buffer, BufferSize, TRUE);
+                         return InfoTdiQueryGetConnectionTcpTable(EntityListContext, Buffer, BufferSize, TcpUdpClassOwnerPid);
                      else
                          return TDI_INVALID_PARAMETER;
                 else if (ID->toi_entity.tei_entity == CL_TL_ENTITY)
                      if ((EntityListContext = GetContext(ID->toi_entity)))
-                         return InfoTdiQueryGetConnectionUdpTable(EntityListContext, Buffer, BufferSize, TRUE);
+                         return InfoTdiQueryGetConnectionUdpTable(EntityListContext, Buffer, BufferSize, TcpUdpClassOwnerPid);
                      else
                          return TDI_INVALID_PARAMETER;
                 else
@@ -297,12 +297,12 @@ TDI_STATUS InfoTdiQueryInformationEx(
                          return TDI_INVALID_PARAMETER;
                  else if (ID->toi_entity.tei_entity == CO_TL_ENTITY)
                      if ((EntityListContext = GetContext(ID->toi_entity)))
-                         return InfoTdiQueryGetConnectionTcpTable(EntityListContext, Buffer, BufferSize, FALSE);
+                         return InfoTdiQueryGetConnectionTcpTable(EntityListContext, Buffer, BufferSize, TcpUdpClassBasic);
                      else
                          return TDI_INVALID_PARAMETER;
                  else if (ID->toi_entity.tei_entity == CL_TL_ENTITY)
                      if ((EntityListContext = GetContext(ID->toi_entity)))
-                         return InfoTdiQueryGetConnectionUdpTable(EntityListContext, Buffer, BufferSize, FALSE);
+                         return InfoTdiQueryGetConnectionUdpTable(EntityListContext, Buffer, BufferSize, TcpUdpClassBasic);
                      else
                          return TDI_INVALID_PARAMETER;
                  else
index 5b7c706..267c43f 100644 (file)
@@ -182,7 +182,7 @@ TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
 TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
                                    PNDIS_BUFFER Buffer,
                                    PUINT BufferSize,
-                    BOOLEAN Extended)
+                    TDI_TCPUDP_CLASS_INFO Class)
 {
     SIZE_T Size;
     MIB_TCPROW_OWNER_PID TcpRow;
@@ -191,12 +191,13 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
     TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
 
     TcpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
-    if (Extended)
+    if (Class == TcpUdpClassOwnerPid)
     {
         Size = sizeof(MIB_TCPROW_OWNER_PID);
     }
     else
     {
+        ASSERT(Class != TcpUdpClassOwner);
         Size = sizeof(MIB_TCPROW);
     }
 
@@ -255,20 +256,30 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
 TDI_STATUS InfoTdiQueryGetConnectionUdpTable(PADDRESS_FILE AddrFile,
                                    PNDIS_BUFFER Buffer,
                                    PUINT BufferSize,
-                                   BOOLEAN Extended)
+                                   TDI_TCPUDP_CLASS_INFO Class)
 {
+    SIZE_T Size;
     MIB_UDPROW_OWNER_PID UdpRow;
     TDI_STATUS Status = TDI_INVALID_REQUEST;
 
     TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
 
+    if (Class == TcpUdpClassOwnerPid)
+    {
+        Size = sizeof(MIB_UDPROW_OWNER_PID);
+    }
+    else
+    {
+        ASSERT(Class != TcpUdpClassOwner);
+        Size = sizeof(MIB_UDPROW);
+    }
+
     UdpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
     UdpRow.dwLocalPort = AddrFile->Port;
     UdpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
 
     Status = InfoCopyOut( (PCHAR)&UdpRow,
-                         (Extended ? sizeof(MIB_UDPROW_OWNER_PID) : sizeof(MIB_UDPROW)),
-                         Buffer, BufferSize );
+                         Size, Buffer, BufferSize );
 
     TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));