summaryrefslogtreecommitdiffstats
path: root/private/ntos/tdi/isn/rip/rttest
diff options
context:
space:
mode:
Diffstat (limited to 'private/ntos/tdi/isn/rip/rttest')
-rw-r--r--private/ntos/tdi/isn/rip/rttest/makefile6
-rw-r--r--private/ntos/tdi/isn/rip/rttest/nwsap.h75
-rw-r--r--private/ntos/tdi/isn/rip/rttest/rttest.c426
-rw-r--r--private/ntos/tdi/isn/rip/rttest/sources42
-rw-r--r--private/ntos/tdi/isn/rip/rttest/utils.h55
5 files changed, 604 insertions, 0 deletions
diff --git a/private/ntos/tdi/isn/rip/rttest/makefile b/private/ntos/tdi/isn/rip/rttest/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/ntos/tdi/isn/rip/rttest/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/ntos/tdi/isn/rip/rttest/nwsap.h b/private/ntos/tdi/isn/rip/rttest/nwsap.h
new file mode 100644
index 000000000..c99a84063
--- /dev/null
+++ b/private/ntos/tdi/isn/rip/rttest/nwsap.h
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 1994 Microsoft Corporation
+Copyright (c) 1993 Micro Computer Systems, Inc.
+
+Module Name:
+
+ net\inc\nwsap.h
+
+Abstract:
+
+ This is the public include file for the Nw Sap Agent API.
+
+Author:
+
+ Brian Walker (MCS) 06-30-1993
+
+Revision History:
+
+--*/
+
+#ifndef _NWSAP_
+#define _NWSAP_
+
+/** Return codes for Advertise API and BindLib API **/
+
+#define SAPRETURN_SUCCESS 0
+#define SAPRETURN_NOMEMORY 1
+#define SAPRETURN_EXISTS 2
+#define SAPRETURN_NOTEXIST 3
+#define SAPRETURN_NOTINIT 4
+#define SAPRETURN_INVALIDNAME 5
+
+/** Function Prototypes **/
+
+INT
+SapAddAdvertise(
+ IN PUCHAR ServerName,
+ IN USHORT ServerType,
+ IN PUCHAR ServerAddr);
+
+INT
+SapRemoveAdvertise(
+ IN PUCHAR ServerName,
+ IN USHORT ServerType);
+
+DWORD
+SapLibInit(
+ VOID);
+
+DWORD
+SapLibShutdown(
+ VOID);
+
+INT
+SapGetObjectID(
+ IN PUCHAR ObjectName,
+ IN USHORT ObjectType,
+ IN PULONG ObjectID);
+
+INT
+SapGetObjectName(
+ IN ULONG ObjectID,
+ IN PUCHAR ObjectName,
+ IN PUSHORT ObjectType,
+ IN PUCHAR ObjectAddr);
+
+INT
+SapScanObject(
+ IN PULONG ObjectID,
+ IN PUCHAR ObjectName,
+ IN PUSHORT ObjectType,
+ IN USHORT ScanType);
+
+#endif
diff --git a/private/ntos/tdi/isn/rip/rttest/rttest.c b/private/ntos/tdi/isn/rip/rttest/rttest.c
new file mode 100644
index 000000000..941e93511
--- /dev/null
+++ b/private/ntos/tdi/isn/rip/rttest/rttest.c
@@ -0,0 +1,426 @@
+#include <nt.h>
+#include <ntrtl.h>
+#include <nturtl.h>
+#include <ntddser.h>
+
+#include <windows.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <malloc.h>
+
+#include "..\driver.h"
+#include "utils.h"
+#include "nwsap.h"
+
+typedef struct _IPX_ROUTE_ENTRY {
+ UCHAR Network[4];
+ USHORT NicId;
+ UCHAR NextRouter[6];
+ PVOID NdisBindingContext;
+ USHORT Flags;
+ USHORT Timer;
+ UINT Segment;
+ USHORT TickCount;
+ USHORT HopCount;
+ PVOID AlternateRoute[2];
+ PVOID NicLinkage[2];
+ struct {
+ PVOID Linkage[2];
+ ULONG Reserved[1];
+ } PRIVATE;
+} IPX_ROUTE_ENTRY, * PIPX_ROUTE_ENTRY;
+
+
+
+INT
+IsDigit(UCHAR *string) {
+ if (*string < '0' || *string >'9') {
+ return(0);
+ }
+ return(1);
+}
+
+
+IPX_ROUTE_ENTRY rte;
+
+VOID
+RouterDisplayTable(
+ PHANDLE FileHandle,
+ PIO_STATUS_BLOCK IoStatusBlock) {
+
+ ULONG netnr;
+ NTSTATUS Status;
+
+ printf("<------------ ROUTING TABLE START ------------->\n\n");
+
+ Status = NtDeviceIoControlFile(
+ *FileHandle, // HANDLE to File
+ NULL, // HANDLE to Event
+ NULL, // ApcRoutine
+ NULL, // ApcContext
+ IoStatusBlock, // IO_STATUS_BLOCK
+ IOCTL_IPXROUTER_SNAPROUTES, // IoControlCode
+ NULL, // Input Buffer
+ 0, // Input Buffer Length
+ NULL, // Output Buffer
+ 0); // Output Buffer Length
+
+ if (IoStatusBlock->Status != STATUS_SUCCESS) {
+
+ printf("Ioctl snap routes failed\n");
+ return;
+ }
+
+ while(TRUE) {
+
+ Status = NtDeviceIoControlFile(
+ *FileHandle, // HANDLE to File
+ NULL, // HANDLE to Event
+ NULL, // ApcRoutine
+ NULL, // ApcContext
+ IoStatusBlock, // IO_STATUS_BLOCK
+ IOCTL_IPXROUTER_GETNEXTROUTE, // IoControlCode
+ NULL, // Input Buffer
+ 0, // Input Buffer Length
+ &rte, // Output Buffer
+ sizeof(IPX_ROUTE_ENTRY)); // Output Buffer Length
+
+
+ if(IoStatusBlock->Status == STATUS_NO_MORE_ENTRIES) {
+
+ printf("\n\n<------------ ROUTING TABLE END ------------->\n\n");
+ return;
+ }
+
+
+ if(Status != STATUS_SUCCESS) {
+
+ printf("Ioctl failure\n");
+ return;
+ }
+
+ // get net nr in "on the wire" order
+
+ GETLONG2ULONG(&netnr, rte.Network);
+
+ printf("<-- net=%.8x, nic=%d, hops=%d, ticks=%d, flags=0x%x -->\n",
+ netnr, rte.NicId, rte.HopCount, rte.TickCount, rte.Flags);
+ }
+}
+
+PUCHAR DeviceType[2] = { "LAN", "WAN" };
+PUCHAR NicState[4] = { "CLOSED", "CLOSING", "ACTIVE", "PENDING_OPEN" };
+
+
+VOID
+RouterShowNicInfo(
+ PHANDLE FileHandle,
+ PIO_STATUS_BLOCK IoStatusBlock) {
+
+ SHOW_NIC_INFO nis;
+ USHORT index, i;
+
+ NTSTATUS Status;
+
+ printf("\n");
+ index = 0;
+
+ while(TRUE) {
+
+ Status = NtDeviceIoControlFile(
+ *FileHandle, // HANDLE to File
+ NULL, // HANDLE to Event
+ NULL, // ApcRoutine
+ NULL, // ApcContext
+ IoStatusBlock, // IO_STATUS_BLOCK
+ IOCTL_IPXROUTER_SHOWNICINFO, // IoControlCode
+ &index, // Input Buffer
+ sizeof(USHORT), // Input Buffer Length
+ &nis, // Output Buffer
+ sizeof(nis)); // Output Buffer Length
+
+ index++;
+ printf("\n");
+
+ if(IoStatusBlock->Status == STATUS_NO_MORE_ENTRIES) {
+
+ return;
+ }
+
+
+ if(Status != STATUS_SUCCESS) {
+
+ printf("Ioctl failure\n");
+ return;
+ }
+
+ printf("NicId = %d\n", nis.NicId);
+ printf("DeviceType = %s\n", DeviceType[nis.DeviceType]);
+ printf("NicState = %s\n", NicState[nis.NicState]);
+ printf("Network = ");
+ for(i=0; i<4; i++) {
+
+ printf("%.2x", nis.Network[i]);
+ }
+ printf("\nNode = ");
+ for(i=0; i<6; i++) {
+
+ printf("%.2x", nis.Node[i]);
+ }
+ printf("\nTickCount = %d\n", nis.TickCount);
+
+ printf("RIP Packets Traffic: Received = %d, Sent = %d\n",
+ nis.StatRipReceived, nis.StatRipSent);
+
+ printf("Routed Packets Traffic: Received = %d, Sent = %d\n",
+ nis.StatRoutedReceived, nis.StatRoutedSent);
+
+ printf("Type 20 Packets Traffic: Received = %d, Sent = %d\n",
+ nis.StatType20Received, nis.StatType20Sent);
+
+ printf("Bad Packets Received = %d\n", nis.StatBadReceived);
+
+ }
+}
+
+VOID
+RouterShowMemStat(
+ PHANDLE FileHandle,
+ PIO_STATUS_BLOCK IoStatusBlock) {
+
+ SHOW_MEM_STAT sms;
+
+ NTSTATUS Status;
+
+ Status = NtDeviceIoControlFile(
+ *FileHandle, // HANDLE to File
+ NULL, // HANDLE to Event
+ NULL, // ApcRoutine
+ NULL, // ApcContext
+ IoStatusBlock, // IO_STATUS_BLOCK
+ IOCTL_IPXROUTER_SHOWMEMSTATISTICS, // IoControlCode
+ NULL, // Input Buffer
+ 0, // Input Buffer Length
+ &sms, // Output Buffer
+ sizeof(sms)); // Output Buffer Length
+
+ if(Status != STATUS_SUCCESS) {
+
+ printf("Ioctl failure\n");
+ return;
+ }
+
+ printf("\n\nPeak receive packets allocation: %d pkts\n", sms.PeakPktAllocCount);
+ printf("Current receive packets allocation: %d pkts\n", sms.CurrentPktAllocCount);
+ printf("Current packet pool size (alloc'ed + free) %d pkts , %dk\n",
+ sms.CurrentPktPoolCount, (sms.CurrentPktPoolCount * sms.PacketSize)/1024 + 1);
+ printf("Packet Size %d\n", sms.PacketSize);
+}
+
+
+VOID
+RouterClearStatistics(
+ PHANDLE FileHandle,
+ PIO_STATUS_BLOCK IoStatusBlock) {
+
+ NTSTATUS Status;
+
+ Status = NtDeviceIoControlFile(
+ *FileHandle, // HANDLE to File
+ NULL, // HANDLE to Event
+ NULL, // ApcRoutine
+ NULL, // ApcContext
+ IoStatusBlock, // IO_STATUS_BLOCK
+ IOCTL_IPXROUTER_ZERONICSTATISTICS, // IoControlCode
+ NULL, // Input Buffer
+ 0, // Input Buffer Length
+ NULL, // Output Buffer
+ 0); // Output Buffer Length
+
+ if(Status != STATUS_SUCCESS) {
+
+ printf("Ioctl failure\n");
+ return;
+ }
+}
+
+VOID
+SapShowAllServers()
+{
+ INT rc;
+ ULONG ObjectID = 0xFFFFFFFF;
+ UCHAR ObjectName[100];
+ USHORT ObjectType;
+ USHORT ScanType = 0xFFFF;
+
+ memset(&ObjectName, 0, 100);
+
+ while((rc = SapScanObject(&ObjectID,
+ ObjectName,
+ &ObjectType,
+ ScanType)) == SAPRETURN_SUCCESS) {
+
+ printf("%-48s ServerType=%d\n", &ObjectName, ObjectType);
+ }
+}
+
+VOID
+SapShowFileServers()
+{
+ INT rc;
+ ULONG ObjectID = 0xFFFFFFFF;
+ UCHAR ObjectName[100];
+ USHORT ObjectType;
+ USHORT ScanType = 0x4;
+ UCHAR IpxAddress[12];
+ USHORT i;
+
+ memset(&ObjectName, 0, 100);
+
+ printf("\nServer Name IPX Address\n");
+ printf("-------------------------------------------\n");
+
+ printf("\n");
+ while((rc = SapScanObject(&ObjectID,
+ ObjectName,
+ &ObjectType,
+ ScanType)) == SAPRETURN_SUCCESS) {
+
+ // get object address
+ SapGetObjectName(ObjectID,
+ ObjectName,
+ &ObjectType,
+ IpxAddress);
+
+
+ printf("%-30s", &ObjectName);
+ for(i=0; i<4; i++) {
+
+ printf("%.2x", IpxAddress[i]);
+ }
+ printf(".");
+ for(i=4; i<10; i++) {
+
+ printf("%.2x", IpxAddress[i]);
+ }
+ printf("\n");
+ }
+}
+
+VOID _cdecl
+main(
+ IN WORD argc,
+ IN LPSTR argv[]
+ )
+
+{
+ HANDLE RouterFileHandle;
+ OBJECT_ATTRIBUTES RouterObjectAttributes;
+ IO_STATUS_BLOCK RouterIoStatusBlock;
+ UNICODE_STRING RouterFileString;
+ WCHAR RouterFileName[] = L"\\Device\\Ipxroute";
+ NTSTATUS Status;
+
+ PVOID Memory;
+ int choice;
+
+ RtlInitUnicodeString (&RouterFileString, RouterFileName);
+
+ InitializeObjectAttributes(
+ &RouterObjectAttributes,
+ &RouterFileString,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtOpenFile(
+ &RouterFileHandle, // HANDLE of file
+ SYNCHRONIZE | GENERIC_READ,
+ &RouterObjectAttributes,
+ &RouterIoStatusBlock,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, // Share Access
+ FILE_SYNCHRONOUS_IO_NONALERT); // Open Options
+
+ if (!NT_SUCCESS(Status)) {
+ printf("Open of IPX Router returned %lx\n", Status);
+ return;
+ }
+ else
+ {
+ printf("Open of %Z was successful!\n",&RouterFileString);
+ }
+
+ //
+ // Allocate storage to hold all this.
+ //
+
+ Memory = malloc (200 * sizeof(ULONG));
+ if (Memory == NULL) {
+ printf("Malloc failed.\n");
+ return;
+ }
+
+ SapLibInit();
+
+
+ do {
+ printf("\n");
+ printf("----------- IPX ROUTER TEST MENU -------------\n");
+ printf("\n");
+ printf(" 1. Show Routing Table\n");
+ printf(" 2. Show Network Interfaces Statistics\n");
+ printf(" 3. Show Packet Pool Statistics\n");
+ printf(" 4. Clear Router Statistics\n");
+ printf(" 5. Show All Servers (of all types) in SAP Table\n");
+ printf(" 6. Show NetWare File Servers in SAP Table\n");
+ printf(" 99.Exit\n");
+ printf("\n");
+ printf("Enter your choice -->");
+
+ scanf("%d", &choice);
+
+ switch (choice) {
+ case 1:
+ RouterDisplayTable(&RouterFileHandle, &RouterIoStatusBlock);
+ break;
+ case 2:
+ RouterShowNicInfo(&RouterFileHandle, &RouterIoStatusBlock);
+ break;
+ case 3:
+ RouterShowMemStat(&RouterFileHandle, &RouterIoStatusBlock);
+ break;
+ case 4:
+ RouterClearStatistics(&RouterFileHandle, &RouterIoStatusBlock);
+ break;
+ case 5:
+ SapShowAllServers();
+ break;
+ case 6:
+ SapShowFileServers();
+ break;
+
+
+ case 99:
+ break;
+ default:
+ printf("Bad choice !!\n");
+ }
+
+ } while (choice != 99);
+
+
+ Status = NtClose(RouterFileHandle);
+
+ if (!NT_SUCCESS(Status)) {
+ printf("Router Close returned %lx\n", Status);
+ } else {
+ printf("Router Close successful\n");
+ }
+
+ free (Memory);
+
+}
+
+
diff --git a/private/ntos/tdi/isn/rip/rttest/sources b/private/ntos/tdi/isn/rip/rttest/sources
new file mode 100644
index 000000000..fc42df2d6
--- /dev/null
+++ b/private/ntos/tdi/isn/rip/rttest/sources
@@ -0,0 +1,42 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1990
+
+UMLIBS=obj\*\hubtest.lib \nt\public\sdk\lib\*\setargv.obj
+NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
+
+!ENDIF
+
+MAJORCOMP=ndis
+MINORCOMP=rttest
+
+TARGETNAME=rttest
+TARGETPATH=obj
+TARGETTYPE=PROGRAM
+
+TARGETLIBS=$(BASEDIR)\public\sdk\lib\*\nwsaplib.lib
+
+INCLUDES=
+
+SOURCES=rttest.c
+
+
+UMTYPE=console
+UMLIBS=
+
diff --git a/private/ntos/tdi/isn/rip/rttest/utils.h b/private/ntos/tdi/isn/rip/rttest/utils.h
new file mode 100644
index 000000000..afacd2a35
--- /dev/null
+++ b/private/ntos/tdi/isn/rip/rttest/utils.h
@@ -0,0 +1,55 @@
+/*******************************************************************/
+/* Copyright(c) 1993 Microsoft Corporation */
+/*******************************************************************/
+
+//***
+//
+// Filename: utils.h
+//
+// Description: Contains miscellaneous utilities
+//
+// Author: Stefan Solomon (stefans) October 4, 1993.
+//
+// Revision History:
+//
+//***
+
+#ifndef _UTILS_
+#define _UTILS_
+
+/*
+ * The following macros deal with on-the-wire short and long values
+ *
+ * On the wire format is big-endian i.e. a long value of 0x01020304 is
+ * represented as 01 02 03 04.
+ * Similarly a short value of 0x0102 is represented as 01 02.
+ *
+ * The host format is not assumed since it will vary from processor to
+ * processor.
+ */
+
+// Get a short from on-the-wire format to a USHORT in the host format
+#define GETSHORT2USHORT(DstPtr, SrcPtr) \
+ *(PUSHORT)(DstPtr) = ((*((PUCHAR)(SrcPtr)+0) << 8) + \
+ (*((PUCHAR)(SrcPtr)+1) ))
+
+// Get a long from on-the-wire format to a ULONG in the host format
+#define GETLONG2ULONG(DstPtr, SrcPtr) \
+ *(PULONG)(DstPtr) = ((*((PUCHAR)(SrcPtr)+0) << 24) + \
+ (*((PUCHAR)(SrcPtr)+1) << 16) + \
+ (*((PUCHAR)(SrcPtr)+2) << 8) + \
+ (*((PUCHAR)(SrcPtr)+3) ))
+
+// Put a USHORT from the host format to a short to on-the-wire format
+#define PUTUSHORT2SHORT(DstPtr, Src) \
+ *((PUCHAR)(DstPtr)+0) = (UCHAR) ((USHORT)(Src) >> 8), \
+ *((PUCHAR)(DstPtr)+1) = (UCHAR)(Src)
+
+// Put a ULONG from the host format to an array of 4 UCHARs on-the-wire format
+#define PUTULONG2LONG(DstPtr, Src) \
+ *((PUCHAR)(DstPtr)+0) = (UCHAR) ((ULONG)(Src) >> 24), \
+ *((PUCHAR)(DstPtr)+1) = (UCHAR) ((ULONG)(Src) >> 16), \
+ *((PUCHAR)(DstPtr)+2) = (UCHAR) ((ULONG)(Src) >> 8), \
+ *((PUCHAR)(DstPtr)+3) = (UCHAR) (Src)
+
+#endif // _UTILS_