delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/04/21/01:00:31

From: craig AT reversion DOT ca (Craig Nelson)
Subject: Need hostid or enet addr from cygwin32
21 Apr 1998 01:00:31 -0700 :
Message-ID: <199804201441.IAA06205.cygnus.gnu-win32@tuffy.reversion.ca>
To: gnu-win32 AT cygnus DOT com

----------
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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019