Category : Network Files
Archive   : NBSTATUS.ZIP
Filename : NBSTATUS.C

 
Output of file : NBSTATUS.C contained in archive : NBSTATUS.ZIP
/* NBSTATUS.C - program checks the status of the current NetBIOS */
/* session. Uses the alternate NetBIOS interrupt (INT 2Ah). */
/* Programmer: Paul McGinnis, AST Research, Data Comm Support Dept. */
/* September 29, 1988. */
/* Compilation information: */
/* Compiler: Borland Turbo C v1.5 */
/* Memory model: small */
/* Floating point support: none */


#include
#include
#include
#include


typedef unsigned char byte;
typedef unsigned int word;

/* Structure of Network Control Block (NCB) */
typedef struct
{
byte NCB_COMMAND; /* command */
byte NCB_RETCODE; /* function return code */
byte NCB_LSN; /* local session number */
byte NCB_NUM; /* number of network name */
word NCB_BUFFER_OFFSET; /* offset of message buffer */
word NCB_BUFFER_SEGMENT; /* segment of message buffer */
word NCB_LENGTH; /* length of message buffer */
byte NCB_CALLNAME[16]; /* name of session user is talking to */
byte NCB_NAME[16]; /* user's network name */
byte NCB_RTO; /* receive time-out in 500 ms. incrs. */
byte NCB_STO; /* send time-out - 500 ms. increments */
word NCB_POST_OFFSET; /* offset of "no-wait" interrupt call */
word NCB_POST_SEGMENT; /* segment of "no-wait" interrupt */
byte NCB_LANA_NUM; /* adapter number (must be 0 or 1) */
byte NCB_CMD_CPLT; /* command completion status */
byte NCB_RESERVE[14]; /* Reserved area for Token-Ring */
} NCB;

/* Define session status block */
typedef struct
{
byte num_sessions; /* Number of possible sessions */
byte same_name; /* Number of sessions with this name */
byte datagrams; /* Number of datagram cmds. pending */
byte receive_any; /* Number of RECEIVE ANY cmds. pending*/
byte lsn; /* Local session number */
byte session_state; /* Current state of session */
byte local_name[16]; /* User's name */
byte remote_name[16]; /* Name of session on other PC */
byte receives; /* Number of pending receive commands */
byte sends; /* Number of pending send commands */
} STATUS_BLOCK;

#define SESSION_STATUS_WAIT 0x34


main()
{
byte iflag, ret_code, net_name[18];
NCB * net_block;
STATUS_BLOCK * session;
char *PRGMR = "Programmer: Paul McGinnis - v1.02";
net_block = (NCB *) malloc(sizeof(NCB));
session = (STATUS_BLOCK *) malloc(40);
cprintf("NetBIOS session status test. Version 1.02\n\n");
_AH = 0;
geninterrupt(0x2a);
iflag = _AH;
if (!iflag)
{
cprintf("%c *** ERROR - NetBIOS not installed. ***\n", 7);
return;
}
cprintf("Enter network name to check. = current session name.\n");
cprintf("(this is case-sensitive) ===> ");
net_name[0] = 16;
cgets(net_name);
cprintf("\n\n");
net_block -> NCB_COMMAND = SESSION_STATUS_WAIT;
net_block -> NCB_LENGTH = 40;
net_block -> NCB_BUFFER_OFFSET = session;
net_block -> NCB_BUFFER_SEGMENT = _DS;
net_block -> NCB_LANA_NUM = 0; /* Use primary adapter */
if (!net_name[1])
strncpy(net_block -> NCB_NAME, "*", 16); /* Check all local names */
else
strncpy(net_block -> NCB_NAME, net_name + 2, 16);
_ES = _DS;
_BX = net_block;
_AX = 0x401; /* Use alternate NetBIOS interface, w/o error-retry */
geninterrupt(0x2a);
ret_code = _AH;
if (ret_code)
{
if (net_block -> NCB_RETCODE == 0x15)
cprintf("%c You aren't using \042%s\042 !!\n\n", 7, net_name + 2);
else
cprintf("%c Bad return code = %02Xh\n\n", 7, net_block -> NCB_RETCODE);
return;
}
if (session -> same_name)
{
cprintf("Local session number: %02Xh\n", (byte) session -> lsn);
cprintf("Local name: %s\n", session -> local_name);
cprintf("# of sessions with this name: %d\n", session -> same_name);
cprintf("Session state: ");
switch (session -> session_state)
{
case 1 : cprintf("LISTEN pending\n");
break;
case 2 : cprintf("CALL pending\n");
break;
case 3 : cprintf("Session established\n");
break;
case 4 : cprintf("HANG UP pending\n");
break;
case 5 : cprintf("HANG UP complete\n");
break;
case 6 : cprintf("Session aborted\n");
break;
}
cprintf("Session name on other PC: %s\n\n", session -> remote_name);
cprintf("# of pending RECEIVE ANY commands: %d\n", session -> receive_any);
cprintf("# of pending RECEIVE commands: %d\n", session -> receives);
cprintf("# of pending SEND/CHAIN SEND commands: %d\n", session -> sends);
}
else
cprintf("No sessions currently in use.\n\n");
cprintf("# of pending datagram commands: %d\n\n", session -> datagrams);
}

  3 Responses to “Category : Network Files
Archive   : NBSTATUS.ZIP
Filename : NBSTATUS.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/