3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS packet driver interface list utility
5 * FILE: apps/net/niclist/niclist.c
6 * PURPOSE: Network information utility
7 * PROGRAMMERS: Robert Dickenson (robert_dickenson@users.sourceforge.net)
9 * RDD 10/07/2002 Created from bochs sources
12 For this program and for win32 ethernet, the winpcap library is required.
13 Download it from http://netgroup-serv.polito.it/winpcap.
16 #define WIN32_LEAN_AND_MEAN
22 #define MAX_ADAPTERS 10
23 #define NIC_BUFFER_SIZE 2048
26 // structure to hold the adapter name and description
32 // array of structures to hold information for our adapters
33 NIC_INFO_NT nic_info
[MAX_ADAPTERS
];
35 // pointer to exported function in winpcap library
36 BOOLEAN (*PacketGetAdapterNames
)(PTSTR
, PULONG
) = NULL
;
37 PCHAR (*PacketGetVersion
)(VOID
) = NULL
;
40 int main(int argc
, char **argv
)
42 char AdapterInfo
[NIC_BUFFER_SIZE
] = { '\0','\0' };
43 unsigned long AdapterLength
= NIC_BUFFER_SIZE
;
49 char* PacketLibraryVersion
;
52 // Attemp to load the WinPCap dynamic link library
53 HINSTANCE hPacket
= LoadLibrary("PACKET.DLL");
55 PacketGetAdapterNames
= (BOOLEAN (*)(PTSTR
, PULONG
))GetProcAddress(hPacket
, "PacketGetAdapterNames");
56 PacketGetVersion
= (PCHAR (*)(VOID
))GetProcAddress(hPacket
, "PacketGetVersion");
58 printf("Could not load WinPCap driver! for more information goto:\n");
59 printf ("http://netgroup-serv.polito.it/winpcap\n");
62 if (!(PacketLibraryVersion
= PacketGetVersion())) {
63 printf("ERROR: Could not get Packet DLL Version string.\n");
66 printf("Packet Library Version: %s\n", PacketLibraryVersion
);
68 if (!PacketGetAdapterNames(AdapterInfo
, &AdapterLength
)) {
69 printf("ERROR: Could not get Packet Adaptor Names.\n");
72 wstrName
= (LPWSTR
)AdapterInfo
;
74 // Enumerate all the adapters names found...
77 nic_info
[nAdapterCount
].wstrName
= wstrName
;
78 wstrName
+= lstrlenW(wstrName
) + 1;
80 if (nAdapterCount
> 9) break;
82 strDesc
= (LPSTR
)++wstrName
;
85 printf("No Packet Adaptors found (%lu)\n", AdapterLength
);
87 printf("Adaptor count: %d\n", nAdapterCount
);
90 // And obtain the adapter description strings....
91 for (i
= 0; i
< nAdapterCount
; i
++) {
92 nic_info
[i
].strDesc
= strDesc
;
93 strDesc
+= lstrlen(strDesc
) + 1;
95 // display adapter info
96 printf("%d: %s\n", i
+ 1, nic_info
[i
].strDesc
);
97 wprintf(L
" Device: %s\n", nic_info
[i
].wstrName
);