[comp.sys.novell] Determining Network status

abrams@cs.columbia.edu (Steven Abrams) (12/28/90)

Lots of people (including myself) have been posting messages inquiring
as to how we can check the status of the network from software. 

The August '90 Dr. Dobbs Journal discusses the NetWare environment and
the API.  To summarize, the NetWare API is mostly an extension of the
regular DOS Interrupt (0x21), but they strongly recommend use of the C
Interface (which is possibly the worst documented piece of software
I've ever seen). 

In any case, the article concludes that there is NO WAY of ACCURATELY
determining if the network shell is loaded or not, using the API.  The
author, Al Stevens, gives a method he discovered a while back that
uses the int 21 interface.  I'll include the listing below (it's short
enough).  

As for determining if the network is there, first one should make sure
the shell is there.  Then, attempt to get the userid, or the
connection information using the GetConnectionInformation() call in
the API.  Alternatively, one could use the int 21 interface here too.
I'll include this code as well.

Maybe someday Novell will learn how to document all this stuff!

Disclaimer:
I never compiled this code.  I just typed it in here directly from Dr.
Dobbs Journal to make people happy.  Sometime this week I'll be trying
this out, and I'll go over the NetWare API for real to see if I can
find another way.  If you like this code, use it.  If it works for
you, enjoy it. If it doesn't, don't flame. 


~~~Steve
 

---------------------------[Cut Here]---------------------------------
/* These listings are taken from Dr. Dobb's Journal, August, 1990, 
 * and are probably copyrighted.  They are posted without permission.
 * I suggest that if you use these, you document their source!
 */

/* getusr1.c */
static struct {
	int rlen;	/* Packet length -2 */
	char func;	/* NW function */
	char station;	/* Station number */
} rqpacket = {2, 22};	

static struct {
	int rlen;      
	long id;
	int type;
	char userid[48];
	char time[8];
} rqbuffer = {62};

char *GetUserid()
{
	union REGS regs;       
	struct SREGS sregs;    
	
	segread(&segs);
	segs.es = segs.ds;
	/* Get connection number */
	regs.h.ah = 0xdc;
	intdosx(&regs, &regs, &segs);
	rqpacket.station = regs.h.al;
	regs.x.si = (unsigned) &rqpacket;
	regs.x.di = (unsigned) &rsbuffer;
	regs.h.ah = 0xe3;
	intdosx(&regs, &regs, &segs);
	return(rsbuffer.userid);
}
--
/*************************************************
 *
 *Steven Abrams             abrams@cs.columbia.edu
 *
 **************************************************/
#include <std/dumquote.h>
#include <std/disclaimer.h>