Created new network utility niclist for displaying list of packet capture devices.
authorRobert Dickenson <robd@reactos.org>
Tue, 9 Jul 2002 19:34:41 +0000 (19:34 +0000)
committerRobert Dickenson <robd@reactos.org>
Tue, 9 Jul 2002 19:34:41 +0000 (19:34 +0000)
svn path=/trunk/; revision=3194

rosapps/net/niclist/makefile [new file with mode: 0644]
rosapps/net/niclist/niclist.c [new file with mode: 0644]
rosapps/net/niclist/niclist.rc [new file with mode: 0644]

diff --git a/rosapps/net/niclist/makefile b/rosapps/net/niclist/makefile
new file mode 100644 (file)
index 0000000..f119bd8
--- /dev/null
@@ -0,0 +1,20 @@
+
+PATH_TO_TOP=../../../reactos
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = niclist
+
+TARGET_SDKLIBS = ws2_32.a
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+TARGET_GCCLIBS = iberty
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF
diff --git a/rosapps/net/niclist/niclist.c b/rosapps/net/niclist/niclist.c
new file mode 100644 (file)
index 0000000..40e11f6
--- /dev/null
@@ -0,0 +1,80 @@
+/* $Id: niclist.c,v 1.1 2002/07/09 19:34:41 robd Exp $
+ *
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS packet driver interface list utility
+ * FILE:        apps/net/niclist/niclist.c
+ * PURPOSE:     Network information utility
+ * PROGRAMMERS: Robert Dickenson (robert_dickenson@users.sourceforge.net)
+ * REVISIONS:
+ *   RDD  10/07/2002 Created from bochs sources
+ */
+/*
+ For this program and for win32 ethernet, the winpcap library is required.
+ Download it from http://netgroup-serv.polito.it/winpcap.
+ */
+#ifdef MSC_VER
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MAX_ADAPTERS 10
+#define NIC_BUFFER_SIZE 2048
+
+
+// structure to hold the adapter name and description
+typedef struct {
+    LPWSTR wstrName;
+    LPSTR strDesc;
+} NIC_INFO_NT;
+
+// array of structures to hold information for our adapters
+NIC_INFO_NT nic_info[MAX_ADAPTERS];
+
+// pointer to exported function in winpcap library
+BOOLEAN (*PacketGetAdapterNames)(PTSTR, PULONG) = NULL;
+
+
+int main(int argc, char **argv)
+{
+    char AdapterInfo[NIC_BUFFER_SIZE] = { '\0','\0' };
+    unsigned long AdapterLength = NIC_BUFFER_SIZE;
+    LPWSTR wstrName;
+    LPSTR strDesc;
+    int nAdapterCount;
+    int i;
+
+
+    // Attemp to load the WinPCap dynamic link library
+    HINSTANCE hPacket = LoadLibrary("PACKET.DLL");
+    if (hPacket) {
+        PacketGetAdapterNames = (BOOLEAN (*)(PTSTR, PULONG))GetProcAddress(hPacket, "PacketGetAdapterNames");
+    } else {
+        printf("Could not load WinPCap driver! for more information goto:\n");
+        printf ("http://netgroup-serv.polito.it/winpcap\n");
+        return 1;
+    }
+    PacketGetAdapterNames(AdapterInfo, &AdapterLength);
+    wstrName = (LPWSTR)AdapterInfo;
+
+    // Enumerate all the adapters names found...
+    nAdapterCount = 0;
+    while ((*wstrName)) {
+        nic_info[nAdapterCount].wstrName = wstrName;
+        wstrName += lstrlenW(wstrName) + 1;
+        nAdapterCount++;
+    }
+    strDesc = (LPSTR)++wstrName;
+
+    // And obtain the adapter description strings....
+    for (i = 0; i < nAdapterCount; i++) {
+        nic_info[i].strDesc = strDesc;
+        strDesc += lstrlen(strDesc) + 1;
+
+        // display adapter info
+        printf("%d: %s\n", i + 1, nic_info[i].strDesc);
+        wprintf(L"     Device: %s\n", nic_info[i].wstrName);
+    }
+    return 0;
+}
diff --git a/rosapps/net/niclist/niclist.rc b/rosapps/net/niclist/niclist.rc
new file mode 100644 (file)
index 0000000..0568e32
--- /dev/null
@@ -0,0 +1,39 @@
+#include <defines.h>
+#include <reactos/resource.h>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+       FILEVERSION     RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+       PRODUCTVERSION  RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD      
+       FILEFLAGSMASK   0x3fL
+#ifdef _DEBUG
+       FILEFLAGS       0x1L
+#else
+       FILEFLAGS       0x0L
+#endif
+       FILEOS          0x40004L
+       FILETYPE        0x2L
+       FILESUBTYPE     0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName",       RES_STR_COMPANY_NAME
+            VALUE "FileDescription",   "ReactOS packet driver niclist\0"
+            VALUE "FileVersion",       RES_STR_FILE_VERSION
+            VALUE "InternalName",      "niclist\0"
+            VALUE "LegalCopyright",    RES_STR_LEGAL_COPYRIGHT
+            VALUE "OriginalCopyright", "Robert Dickenson (robd@reactos.org)\0"
+            VALUE "OriginalFilename",  "niclist.exe\0"
+            VALUE "ProductName",       RES_STR_PRODUCT_NAME
+            VALUE "ProductVersion",    RES_STR_PRODUCT_VERSION
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+