2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS packet driver interface list utility
4 * FILE: apps/net/niclist/niclist.c
5 * PURPOSE: Network information utility
6 * PROGRAMMERS: Robert Dickenson (robert_dickenson@users.sourceforge.net)
8 * RDD 10/07/2002 Created from bochs sources
11 For this program and for win32 ethernet, the winpcap library is required.
12 Download it from http://netgroup-serv.polito.it/winpcap.
15 #define WIN32_LEAN_AND_MEAN
21 #define MAX_ADAPTERS 10
22 #define NIC_BUFFER_SIZE 2048
25 // structure to hold the adapter name and description
31 // array of structures to hold information for our adapters
32 NIC_INFO_NT nic_info
[MAX_ADAPTERS
];
34 // pointer to exported function in winpcap library
35 BOOLEAN (*PacketGetAdapterNames
)(PTSTR
, PULONG
) = NULL
;
36 PCHAR (*PacketGetVersion
)(VOID
) = NULL
;
39 int main(int argc
, char **argv
)
41 char AdapterInfo
[NIC_BUFFER_SIZE
] = { '\0','\0' };
42 unsigned long AdapterLength
= NIC_BUFFER_SIZE
;
48 char* PacketLibraryVersion
;
51 // Attemp to load the WinPCap dynamic link library
52 HINSTANCE hPacket
= LoadLibrary("PACKET.DLL");
54 PacketGetAdapterNames
= (BOOLEAN (*)(PTSTR
, PULONG
))GetProcAddress(hPacket
, "PacketGetAdapterNames");
55 PacketGetVersion
= (PCHAR (*)(VOID
))GetProcAddress(hPacket
, "PacketGetVersion");
57 printf("Could not load WinPCap driver! for more information goto:\n");
58 printf ("http://netgroup-serv.polito.it/winpcap\n");
61 if (!(PacketLibraryVersion
= PacketGetVersion())) {
62 printf("ERROR: Could not get Packet DLL Version string.\n");
65 printf("Packet Library Version: %s\n", PacketLibraryVersion
);
67 if (!PacketGetAdapterNames(AdapterInfo
, &AdapterLength
)) {
68 printf("ERROR: Could not get Packet Adaptor Names.\n");
71 wstrName
= (LPWSTR
)AdapterInfo
;
73 // Enumerate all the adapters names found...
76 nic_info
[nAdapterCount
].wstrName
= wstrName
;
77 wstrName
+= lstrlenW(wstrName
) + 1;
79 if (nAdapterCount
> 9) break;
81 strDesc
= (LPSTR
)++wstrName
;
84 printf("No Packet Adaptors found (%lu)\n", AdapterLength
);
86 printf("Adaptor count: %d\n", nAdapterCount
);
89 // And obtain the adapter description strings....
90 for (i
= 0; i
< nAdapterCount
; i
++) {
91 nic_info
[i
].strDesc
= strDesc
;
92 strDesc
+= lstrlen(strDesc
) + 1;
94 // display adapter info
95 printf("%d: %s\n", i
+ 1, nic_info
[i
].strDesc
);
96 wprintf(L
" Device: %s\n", nic_info
[i
].wstrName
);