diff options
Diffstat (limited to 'private/ntos/tdi/isnp/nb/nbcount')
-rw-r--r-- | private/ntos/tdi/isnp/nb/nbcount/makefile | 6 | ||||
-rw-r--r-- | private/ntos/tdi/isnp/nb/nbcount/nbcount.c | 177 | ||||
-rw-r--r-- | private/ntos/tdi/isnp/nb/nbcount/nbcount.rc | 11 | ||||
-rw-r--r-- | private/ntos/tdi/isnp/nb/nbcount/sources | 29 |
4 files changed, 223 insertions, 0 deletions
diff --git a/private/ntos/tdi/isnp/nb/nbcount/makefile b/private/ntos/tdi/isnp/nb/nbcount/makefile new file mode 100644 index 000000000..6ee4f43fa --- /dev/null +++ b/private/ntos/tdi/isnp/nb/nbcount/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/isnp/nb/nbcount/nbcount.c b/private/ntos/tdi/isnp/nb/nbcount/nbcount.c new file mode 100644 index 000000000..74a656f16 --- /dev/null +++ b/private/ntos/tdi/isnp/nb/nbcount/nbcount.c @@ -0,0 +1,177 @@ +/**************************************************************************** +* (c) Copyright 1990, 1993 Micro Computer Systems, Inc. All rights reserved. +***************************************************************************** +* +* Title: IPX/SPX Compatible Source Routing Daemon for Windows NT +* +* Module: ipx/route/ipxroute.c +* +* Version: 1.00.00 +* +* Date: 04-08-93 +* +* Author: Brian Walker +* +***************************************************************************** +* +* Change Log: +* +* Date DevSFC Comment +* -------- ------ ------------------------------------------------------- +***************************************************************************** +* +* Functional Description: +* +* +****************************************************************************/ +#include <nt.h> +#include <ntrtl.h> +#include <nturtl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <process.h> +#include <ntstapi.h> +#include <sys/stropts.h> +#include <windows.h> +#include "errno.h" +#include "tdi.h" +#include "isnkrnl.h" + + +typedef struct _NB_ACTION_GET_COUNTS { + USHORT MaximumNicId; // returns maximum NIC ID + USHORT NicIdCounts[32]; // session counts for first 32 NIC IDs +} NB_ACTION_GET_COUNTS, *PNB_ACTION_GET_COUNTS; + +HANDLE isnnbfd; +wchar_t isnnbname[] = L"\\Device\\NwlnkNb"; +char pgmname[] = "NBCOUNT"; + +/** **/ + +#define INVALID_HANDLE (HANDLE)(-1) + +int do_isnnbioctl(HANDLE fd, int cmd, char *datap, int dlen); + +/*page************************************************************* + m a i n + + This is the main routine that gets executed when a NET START + happens. + + Arguments - None + + Returns - Nothing +********************************************************************/ +void _CRTAPI1 main(int argc, char **argv) +{ + UNICODE_STRING FileString; + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + NTSTATUS Status; + NB_ACTION_GET_COUNTS GetCounts; + int rc; + int i; + + /** Open the nwlnknb driver **/ + + RtlInitUnicodeString (&FileString, isnnbname); + + InitializeObjectAttributes( + &ObjectAttributes, + &FileString, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + Status = NtOpenFile( + &isnnbfd, + SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA, + &ObjectAttributes, + &IoStatusBlock, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_SYNCHRONOUS_IO_ALERT); + + if (!NT_SUCCESS(Status)) { + isnnbfd = INVALID_HANDLE; + printf("Could not open transport\n"); + } + + if (isnnbfd == INVALID_HANDLE) { + exit(1); + } + + rc = do_isnnbioctl(isnnbfd, (I_MIPX | 351), (char *)&GetCounts, sizeof(NB_ACTION_GET_COUNTS)); + if (rc == 0) { + + printf("NB NIC count: %d\n", GetCounts.MaximumNicId); + for (i = 1; i <= GetCounts.MaximumNicId; i++) { + printf("NIC %d: %d sessions\n", i, GetCounts.NicIdCounts[i]); + } + } +} + + +/*page*************************************************************** + d o _ i s n i p x i o c t l + + Do the equivalent of a stream ioctl to isnnb + + Arguments - fd = Handle to put on + cmd = Command to send + datap = Ptr to ctrl buffer + dlen = Ptr to len of data buffer + + Returns - 0 = OK + else = Error +********************************************************************/ +int do_isnnbioctl(HANDLE fd, int cmd, char *datap, int dlen) +{ + NTSTATUS Status; + UCHAR buffer[300]; + PNWLINK_ACTION action; + IO_STATUS_BLOCK IoStatusBlock; + int rc; + + /** Fill out the structure **/ + + action = (PNWLINK_ACTION)buffer; + + action->Header.TransportId = ISN_ACTION_TRANSPORT_ID; + action->OptionType = NWLINK_OPTION_CONTROL; + action->BufferLength = sizeof(ULONG) + dlen; + action->Option = cmd; + RtlMoveMemory(action->Data, datap, dlen); + + /** Issue the ioctl **/ + + Status = NtDeviceIoControlFile( + fd, + NULL, + NULL, + NULL, + &IoStatusBlock, + IOCTL_TDI_ACTION, + NULL, + 0, + action, + FIELD_OFFSET(NWLINK_ACTION,Data) + dlen); + + if (Status != STATUS_SUCCESS) { + if (Status == STATUS_INVALID_PARAMETER) { + rc = ERANGE; + } else { + rc = EINVAL; + } + } else { + if (dlen > 0) { + RtlMoveMemory (datap, action->Data, dlen); + } + rc = 0; + } + + return rc; + +} + diff --git a/private/ntos/tdi/isnp/nb/nbcount/nbcount.rc b/private/ntos/tdi/isnp/nb/nbcount/nbcount.rc new file mode 100644 index 000000000..ada219b24 --- /dev/null +++ b/private/ntos/tdi/isnp/nb/nbcount/nbcount.rc @@ -0,0 +1,11 @@ +#include <windows.h> + +#include <ntverp.h> + +#define VER_FILETYPE VFT_APP +#define VER_FILESUBTYPE VFT2_UNKNOWN +#define VER_FILEDESCRIPTION_STR "NWLink Netbios Session Count Application" +#define VER_INTERNALNAME_STR "nbcount.exe" +#define VER_ORIGINALFILENAME_STR "nbcount.exe" + +#include "common.ver" diff --git a/private/ntos/tdi/isnp/nb/nbcount/sources b/private/ntos/tdi/isnp/nb/nbcount/sources new file mode 100644 index 000000000..f9dfe3561 --- /dev/null +++ b/private/ntos/tdi/isnp/nb/nbcount/sources @@ -0,0 +1,29 @@ +!IF 0 + +Copyright (c) 1993 Micro Computer Systems, Inc. + +!ENDIF + +MAJORCOMP=nwlink +MINORCOMP=nbcount + +TARGETNAME=nbcount +TARGETPATH=$(BASEDIR)\public\sdk\lib +TARGETTYPE=UMAPPL_NOLIB + +USE_CRTDLL=1 + +C_DEFINES=$(C_DEFINES) + +!IF 0 +INCLUDES=..\h;..\..\..\..\..\inc;..\..\..\..\inc;..\..\..\inc +!ELSE +INCLUDES=..\h;$(BASEDIR)\private\inc;$(BASEDIR)\private\ntos\inc;$(BASEDIR)\private\ntos\streams\inc +!ENDIF + +SOURCES= nbcount.c nbcount.rc + +UMTYPE=console +UMAPPL=$(TARGETNAME) +UMLIBS=$(BASEDIR)\public\sdk\lib\*\ntdll.lib \ + |