This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Need hostid or enet addr from cygwin32


----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 27


I need to be able to find a uniq identifier for a host.  Usually, I use 
gethostid() on "secure" unix boxes, but under OSF 3.2 for example, I use the
ethernet address instead, using the ioctl function. (OSF allows root to actually
change the hostid from what I remember).

Someone sent me a piece of code that can get the ethernet address from a pc,
but it uses the Netbios() call.  

When this code is compiled, I get undefined references to NCBRESET and NCBASTAT
and even if I hack these values in, the linker cannot find the Netbios()
function, even if I use -lnetapi32

I've checked the library for "strings" and also tried nm (and there are a few
similar calls), but alas, still can't get the thing to compile.

Have any of you already accomplished this?  

I'm still using b18 for now, but am waiting for 19.2, and I am running on win95B
if it matters.

I've attached the code with the two #defines mentioned above.  I've no idea what
the values really are, i just wanted to get a complete compile first...

thanks!

Craig Nelson, Cameo Systems
----------
X-Sun-Data-Type: c-file
X-Sun-Data-Description: c-file
X-Sun-Data-Name: jj.c
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 49

#include <windows.h>
#include <wincon.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
 
typedef struct _ASTAT_ {
	ADAPTER_STATUS adapt;
	NAME_BUFFER    NameBuff [30];
} ASTAT, * PASTAT;
 
ASTAT Adapter;

#define NCBRESET 0
#define NCBASTAT 1 

int main (void)
{
	NCB Ncb;
	UCHAR uRetCode;
	char NetName[50];
 
	memset( &Ncb, 0, sizeof(Ncb) );
	Ncb.ncb_command = NCBRESET;
	Ncb.ncb_lana_num = 0;
 
	uRetCode = Netbios( &Ncb );
	printf( "The NCBRESET return code is: 0x%x \n", uRetCode );
 
	memset( &Ncb, 0, sizeof (Ncb) );
	Ncb.ncb_command = NCBASTAT;
	Ncb.ncb_lana_num = 0;
 
	strcpy( Ncb.ncb_callname,  "*               " );
	Ncb.ncb_buffer = (char *) &Adapter;
	Ncb.ncb_length = sizeof(Adapter);
 
	uRetCode = Netbios( &Ncb );
	printf( "The NCBASTAT return code is: 0x%x \n", uRetCode );
	if ( uRetCode == 0 ) {
		printf( "The Ethernet Number is: %02x.%02x.%02x.%02x.%02x.%02x\n",
		Adapter.adapt.adapter_address[0],
		Adapter.adapt.adapter_address[1],
		Adapter.adapt.adapter_address[2],
		Adapter.adapt.adapter_address[3],
		Adapter.adapt.adapter_address[4],
		Adapter.adapt.adapter_address[5] );
	}
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]