/*++ Copyright (c) 1991 Microsoft Corporation Module Name: tnetcall.c Abstract: This module contains code which exercises the NetBIOS dll and driver. Author: Colin Watson (ColinW) 13-Mar-1991 Environment: Application mode Revision History: Dave Beaver (DBeaver) 10 August 1991 Modify to support multiple LAN numbers Jerome Nantel (w-jeromn) 23 August 1991 Add Event Signaling testing --*/ #include #include #include #define WIN32_CONSOLE_APP #include #include #include // 1234567890123456 #define SPACES " " #define TIMEOUT 60000 // Time out for wait, set at 1 minute #define Hi "Come here Dave, I need you" #define SEND 1 #define RCV 0 NCB myncb[2]; CHAR Buffer[16384+1024]; CHAR Buffer2[16384+1024]; ULONG lanNumber=0; UCHAR lsn; HANDLE twoEvent[2]; int count; // frame count BOOLEAN verbose=FALSE; BOOLEAN rxany=FALSE; BOOLEAN rxanyany=FALSE; BOOLEAN input=TRUE; BOOLEAN output=TRUE; int QuietCount = 50; UCHAR name_number; VOID usage ( VOID ) { printf("usage: tsrnetb -c|l [-[a|r]] [-[i|o]] [-n:lan number][-h] \n"); printf(" -c specifies calling, -l specifies listener\n"); printf(" -a specifies rx any, any, -r specifies rx any\n"); printf(" -i specifies rx only, -o specifies tx only\n"); printf(" -d specifies delay with alerts on each tx/rx\n"); printf(" -n specifies the lan number (0 is the default)\n"); printf(" -h specifies that addresses are hexadecimal numbers \n"); printf(" rather than strings.\n"); printf(" -g use group name for the connection\n"); printf(" -v verbose\n"); printf(" -s silent\n"); printf(" -t token ring, lan status alert (names ignored)\n"); printf(" -q quiet (print r every 50 receives\n"); printf(" final two arguments are the remote and local computer names.\n"); } VOID ClearNcb( PNCB pncb ) { RtlZeroMemory( pncb , sizeof (NCB) ); RtlMoveMemory( pncb->ncb_name, SPACES, sizeof(SPACES)-1 ); RtlMoveMemory( pncb->ncb_callname, SPACES, sizeof(SPACES)-1 ); } VOID StartSend() { ClearNcb( &(myncb[0]) ); if ( output == FALSE ) { ResetEvent(twoEvent[SEND]); return; } myncb[0].ncb_command = NCBSEND | ASYNCH; myncb[0].ncb_lana_num = (UCHAR)lanNumber; myncb[0].ncb_buffer = Buffer; myncb[0].ncb_lsn = lsn; myncb[0].ncb_event = twoEvent[SEND]; RtlMoveMemory( Buffer, Hi, sizeof( Hi )); sprintf( Buffer, "%s %d\n", Hi, count ); if ( verbose == TRUE ) { printf( "Tx: %s", Buffer ); } count++; myncb[0].ncb_length = (WORD)sizeof(Buffer); Netbios( &(myncb[0]) ); } VOID StartRcv() { ClearNcb( &(myncb[1]) ); if ( input == FALSE ) { ResetEvent(twoEvent[RCV]); return; } if ((rxany == FALSE) && (rxanyany == FALSE)) { myncb[1].ncb_command = NCBRECV | ASYNCH; } else { myncb[1].ncb_command = NCBRECVANY | ASYNCH; } myncb[1].ncb_lana_num = (UCHAR)lanNumber; myncb[1].ncb_length = sizeof( Buffer2 ); myncb[1].ncb_buffer = Buffer2; if ( rxany == FALSE ) { if ( rxanyany == FALSE ) { myncb[1].ncb_lsn = lsn; } else { myncb[1].ncb_num = 0xff; } } else{ myncb[1].ncb_num = name_number; } myncb[1].ncb_lsn = lsn; myncb[1].ncb_event = twoEvent[RCV]; Netbios( &(myncb[1]) ); } int _cdecl main (argc, argv) int argc; char *argv[]; { int i,j; int rcvCount=0; CHAR localName[17]; CHAR remoteName[17]; CHAR localTemp[32]; CHAR remoteTemp[32]; BOOLEAN gotFirst=FALSE; BOOLEAN asHex=FALSE; BOOLEAN listen=FALSE; BOOLEAN quiet=FALSE; BOOLEAN delay=FALSE; BOOLEAN group=FALSE; BOOLEAN silent=FALSE; BOOLEAN lanalert=FALSE; DWORD tevent; BOOLEAN ttwo=FALSE; if ( argc < 4 || argc > 9) { usage (); return 1; } // // dbeaver: added switch to allow 32 byte hex string as name to facilitate // testing under unusual circumstances // for (j=1;j<16;j++ ) { localTemp[j] = ' '; remoteTemp[j] = ' '; } // // parse the switches // for (i=1;i