[TCPIP/AFD]

- Use less weird internal structures and more public headers.

svn path=/trunk/; revision=65241
This commit is contained in:
Jérôme Gardou 2014-11-04 10:38:26 +00:00
parent 099910fd83
commit 5e4cc9a9c9
4 changed files with 11 additions and 65 deletions

View file

@ -768,7 +768,7 @@ NTSTATUS TdiQueryAddress(
TDIEntityID *Entities; TDIEntityID *Entities;
ULONG EntityCount; ULONG EntityCount;
ULONG EntityType; ULONG EntityType;
IPSNMP_INFO SnmpInfo; IPSNMPInfo SnmpInfo;
PIPADDR_ENTRY IpAddress; PIPADDR_ENTRY IpAddress;
ULONG BufferSize; ULONG BufferSize;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
@ -832,15 +832,15 @@ NTSTATUS TdiQueryAddress(
IP_MIB_STATS_ID, /* Entity id */ IP_MIB_STATS_ID, /* Entity id */
&SnmpInfo, /* Output buffer */ &SnmpInfo, /* Output buffer */
&BufferSize); /* Output buffer size */ &BufferSize); /* Output buffer size */
if (!NT_SUCCESS(Status) || (SnmpInfo.NumAddr == 0)) { if (!NT_SUCCESS(Status) || (SnmpInfo.ipsi_numaddr == 0)) {
AFD_DbgPrint(MIN_TRACE, ("Unable to get SNMP information or no IP addresses available (Status = 0x%X).\n", Status)); AFD_DbgPrint(MIN_TRACE, ("Unable to get SNMP information or no IP addresses available (Status = 0x%X).\n", Status));
break; break;
} }
/* Query device for all IP addresses */ /* Query device for all IP addresses */
if (SnmpInfo.NumAddr != 0) { if (SnmpInfo.ipsi_numaddr != 0) {
BufferSize = SnmpInfo.NumAddr * sizeof(IPADDR_ENTRY); BufferSize = SnmpInfo.ipsi_numaddr * sizeof(IPADDR_ENTRY);
IpAddress = (PIPADDR_ENTRY)ExAllocatePool(NonPagedPool, BufferSize); IpAddress = (PIPADDR_ENTRY)ExAllocatePool(NonPagedPool, BufferSize);
if (!IpAddress) { if (!IpAddress) {
AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n")); AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
@ -861,7 +861,7 @@ NTSTATUS TdiQueryAddress(
break; break;
} }
if (SnmpInfo.NumAddr != 1) { if (SnmpInfo.ipsi_numaddr != 1) {
/* Skip loopback address */ /* Skip loopback address */
*Address = DN2H(IpAddress[1].Addr); *Address = DN2H(IpAddress[1].Addr);
} else { } else {

View file

@ -14,6 +14,7 @@
#include <ntifs.h> #include <ntifs.h>
#include <ndk/obtypes.h> #include <ndk/obtypes.h>
#include <tdi.h> #include <tdi.h>
#include <tcpioctl.h>
#define _WINBASE_ #define _WINBASE_
#define _WINDOWS_H #define _WINDOWS_H
#define _INC_WINDOWS #define _INC_WINDOWS
@ -30,39 +31,10 @@
#define MIN(x,y) (((x)<(y))?(x):(y)) #define MIN(x,y) (((x)<(y))?(x):(y))
#endif #endif
#define IOCTL_TCP_QUERY_INFORMATION_EX \
CTL_CODE(FILE_DEVICE_NETWORK, 0, METHOD_NEITHER, FILE_ANY_ACCESS)
#define TL_INSTANCE 0 #define TL_INSTANCE 0
#define IP_MIB_STATS_ID 1 #define IP_MIB_STATS_ID 1
#define IP_MIB_ADDRTABLE_ENTRY_ID 0x102 #define IP_MIB_ADDRTABLE_ENTRY_ID 0x102
typedef struct IPSNMP_INFO {
ULONG Forwarding;
ULONG DefaultTTL;
ULONG InReceives;
ULONG InHdrErrors;
ULONG InAddrErrors;
ULONG ForwDatagrams;
ULONG InUnknownProtos;
ULONG InDiscards;
ULONG InDelivers;
ULONG OutRequests;
ULONG RoutingDiscards;
ULONG OutDiscards;
ULONG OutNoRoutes;
ULONG ReasmTimeout;
ULONG ReasmReqds;
ULONG ReasmOks;
ULONG ReasmFails;
ULONG FragOks;
ULONG FragFails;
ULONG FragCreates;
ULONG NumIf;
ULONG NumAddr;
ULONG NumRoutes;
} IPSNMP_INFO, *PIPSNMP_INFO;
typedef struct IPADDR_ENTRY { typedef struct IPADDR_ENTRY {
ULONG Addr; ULONG Addr;
ULONG Index; ULONG Index;

View file

@ -12,32 +12,6 @@
#define MAX_PHYSADDR_LEN 8 #define MAX_PHYSADDR_LEN 8
#define MAX_IFDESCR_LEN 256 #define MAX_IFDESCR_LEN 256
typedef struct IPSNMP_INFO {
ULONG Forwarding;
ULONG DefaultTTL;
ULONG InReceives;
ULONG InHdrErrors;
ULONG InAddrErrors;
ULONG ForwDatagrams;
ULONG InUnknownProtos;
ULONG InDiscards;
ULONG InDelivers;
ULONG OutRequests;
ULONG RoutingDiscards;
ULONG OutDiscards;
ULONG OutNoRoutes;
ULONG ReasmTimeout;
ULONG ReasmReqds;
ULONG ReasmOks;
ULONG ReasmFails;
ULONG FragOks;
ULONG FragFails;
ULONG FragCreates;
ULONG NumIf;
ULONG NumAddr;
ULONG NumRoutes;
} IPSNMP_INFO, *PIPSNMP_INFO;
typedef struct IPADDR_ENTRY { typedef struct IPADDR_ENTRY {
ULONG Addr; ULONG Addr;
ULONG Index; ULONG Index;

View file

@ -156,18 +156,18 @@ TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
PIP_INTERFACE IF, PIP_INTERFACE IF,
PNDIS_BUFFER Buffer, PNDIS_BUFFER Buffer,
PUINT BufferSize ) { PUINT BufferSize ) {
IPSNMP_INFO SnmpInfo; IPSNMPInfo SnmpInfo;
UINT IfCount = CountInterfaces(); UINT IfCount = CountInterfaces();
UINT RouteCount = CountFIBs(IF); UINT RouteCount = CountFIBs(IF);
TDI_STATUS Status = TDI_INVALID_REQUEST; TDI_STATUS Status = TDI_INVALID_REQUEST;
TI_DbgPrint(DEBUG_INFO, ("Called.\n")); TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
RtlZeroMemory(&SnmpInfo, sizeof(IPSNMP_INFO)); RtlZeroMemory(&SnmpInfo, sizeof(SnmpInfo));
SnmpInfo.NumIf = IfCount; SnmpInfo.ipsi_numif = IfCount;
SnmpInfo.NumAddr = 1; SnmpInfo.ipsi_numaddr = 1;
SnmpInfo.NumRoutes = RouteCount; SnmpInfo.ipsi_numroutes = RouteCount;
Status = InfoCopyOut( (PCHAR)&SnmpInfo, sizeof(SnmpInfo), Status = InfoCopyOut( (PCHAR)&SnmpInfo, sizeof(SnmpInfo),
Buffer, BufferSize ); Buffer, BufferSize );