ReactOS 0.4.15-dev-5669-g09dde2c
niclist.c
Go to the documentation of this file.
1/*
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)
7 * REVISIONS:
8 * RDD 10/07/2002 Created from bochs sources
9 */
10/*
11 For this program and for win32 ethernet, the winpcap library is required.
12 Download it from http://netgroup-serv.polito.it/winpcap.
13 */
14#ifdef MSC_VER
15#define WIN32_LEAN_AND_MEAN
16#endif
17#include <windows.h>
18#include <stdio.h>
19#include <stdlib.h>
20
21#define MAX_ADAPTERS 10
22#define NIC_BUFFER_SIZE 2048
23
24
25// structure to hold the adapter name and description
26typedef struct {
30
31// array of structures to hold information for our adapters
33
34// pointer to exported function in winpcap library
37
38
39int main(int argc, char **argv)
40{
41 char AdapterInfo[NIC_BUFFER_SIZE] = { '\0','\0' };
42 unsigned long AdapterLength = NIC_BUFFER_SIZE;
43 LPWSTR wstrName;
44 LPSTR strDesc;
45 int nAdapterCount;
46 int i;
47
48 char* PacketLibraryVersion;
49
50
51 // Attemp to load the WinPCap dynamic link library
52 HINSTANCE hPacket = LoadLibrary("PACKET.DLL");
53 if (hPacket) {
54 PacketGetAdapterNames = (BOOLEAN (*)(PTSTR, PULONG))GetProcAddress(hPacket, "PacketGetAdapterNames");
55 PacketGetVersion = (PCHAR (*)(VOID))GetProcAddress(hPacket, "PacketGetVersion");
56 } else {
57 printf("Could not load WinPCap driver! for more information goto:\n");
58 printf ("http://netgroup-serv.polito.it/winpcap\n");
59 return 1;
60 }
61 if (!(PacketLibraryVersion = PacketGetVersion())) {
62 printf("ERROR: Could not get Packet DLL Version string.\n");
63 return 2;
64 }
65 printf("Packet Library Version: %s\n", PacketLibraryVersion);
66
67 if (!PacketGetAdapterNames(AdapterInfo, &AdapterLength)) {
68 printf("ERROR: Could not get Packet Adaptor Names.\n");
69 return 2;
70 }
71 wstrName = (LPWSTR)AdapterInfo;
72
73 // Enumerate all the adapters names found...
74 nAdapterCount = 0;
75 while ((*wstrName)) {
76 nic_info[nAdapterCount].wstrName = wstrName;
77 wstrName += lstrlenW(wstrName) + 1;
78 nAdapterCount++;
79 if (nAdapterCount > 9) break;
80 }
81 strDesc = (LPSTR)++wstrName;
82
83 if (!nAdapterCount) {
84 printf("No Packet Adaptors found (%lu)\n", AdapterLength);
85 } else {
86 printf("Adaptor count: %d\n", nAdapterCount);
87 }
88
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;
93
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);
97 }
98 return 0;
99}
static int argc
Definition: ServiceArgs.c:12
#define VOID
Definition: acefi.h:82
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define lstrlenW
Definition: compat.h:750
int main()
Definition: test.c:6
#define printf
Definition: freeldr.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PCHAR
Definition: match.c:90
#define argv
Definition: mplay32.c:18
BOOLEAN(* PacketGetAdapterNames)(PTSTR, PULONG)
Definition: niclist.c:35
NIC_INFO_NT nic_info[MAX_ADAPTERS]
Definition: niclist.c:32
PCHAR(* PacketGetVersion)(VOID)
Definition: niclist.c:36
#define MAX_ADAPTERS
Definition: niclist.c:21
#define NIC_BUFFER_SIZE
Definition: niclist.c:22
#define L(x)
Definition: ntvdm.h:50
#define BOOLEAN
Definition: pedump.c:73
LPWSTR wstrName
Definition: niclist.c:27
LPSTR strDesc
Definition: niclist.c:28
uint32_t * PULONG
Definition: typedefs.h:59
#define wprintf(...)
Definition: whoami.c:18
#define LoadLibrary
Definition: winbase.h:3733
#define lstrlen
Definition: winbase.h:3747
char * LPSTR
Definition: xmlstorage.h:182
CHAR * PTSTR
Definition: xmlstorage.h:191
WCHAR * LPWSTR
Definition: xmlstorage.h:184