[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

246.0. "Accessing the Ethernet Ctrlr Address" by DVINCI::GREENFIELD () Wed May 21 1986 13:52

	Can anyone help me with this?

	I need a fortran callable subroutine that will execute
 from a non prived process and return to me the unique 48bit Ethernet
 controller address (if one is present on the system).

	Any pointers to examples or documentation that will show how to do this
 will be most appreciated.

	Thanks

	Mike

T.RTitleUserPersonal
Name
DateLines
246.1CLT::COWANKen Cowan, 381-2198Thu May 22 1986 13:309
    I haven't a clue where the ethernet controller address is stored.
    Maybe one of the network hackers could help there.
    
    Once you figured out where the address is stored, write a little
    user-written system service to retrieve it.  The process for doing
    this is in appendix A of the System Service Reference manual.
    
    	KC
    
246.2E/P can do it, so maybe a program?FROST::PIPERbill piperThu May 22 1986 14:5510
On a uVAX2, at the console, >>> E/P/W/N:5 20001920 will show the DEQNA's
physical address.  It appears in the low byte of each of the five words
displayed.  %x20001920 corresponds to the I/O address %o774440.  If you
can go poking at the devices like E/P does, I imagine you could read
this with a program.

In general, you'll have to find the I/O address somehow.  DEUNAs live
at a different place than DEQNAs, etc...

-piper
246.3Network address is 6 bytes, not 5JON::MORONEYPravda ne izvestia, Izvestia ne pravdaFri May 23 1986 10:046
re .2:  Correct except the network address in QNA's is 6 bytes long and
you should read 6 words to get it.  I doubt this will help the author
of .0 since it sounds like he's trying to get DECnet or something to
cough it up and give it to a nonprivilaged process.

-Mike
246.4QIO SENSEMODE to XEA0:8587::S_BINGHAMScott Bingham, CSC/CS TBUSun May 25 1986 00:015
	I don't think it can be done from a non-priv account.  With PHY_IO or
LOG_IO you can do a SENSEMODE to device XEA0: as per I/O User's Guide Vol II.
The hardware and physical addresses are in the extended characteristics.

	_Scott
246.5Use subprocessesJON::MORONEYPravda ne izvestia, Izvestia ne pravdaSun May 25 1986 23:436
If you can use subprocesses, try one that executes the following command:
$ MCR NCP SH LINE UNA-0 CHAR TO <filename>

This will give the network of the UNA

-Mike
246.6RANI::LEICHTERJJerry LeichterSat Jun 14 1986 13:2010
Actually, SENSEMODE's seem to work fine on XE's and XQ's, without any privs.
(Or perhaps when I did this I used SENSECHAR's; they get the same information.)

For some simple code that uses the XE/XQ QIO interface, have a look at the files
in RANI::USER$5:[LEICHTERJ.LINDAIO].

[The above is a limited-time offer; I put the files there for someone who
wanted to look at them, and they will eventually vanish.]

							-- Jerry
246.7extract as deqna.pas, compile & linkCOOKIE::GARDNERTue Nov 04 1986 18:57165
{ Program to read ethernet adaptor hardware address and define it 	}
{ as a DCL symbol.  Invoked as:						}
{ 									}
{ 	$ define/user deqna xqa0:					}
{ 	$ run deqna.exe							}
{ 									}
{ Sets local DCL symbol DEQNA_ADDRESS to the ethernet adaptor		}
{ hardware address.							}
{									}
{ Requires LOG_IO priviledge.						}


program deqna (output);

{ Declarations copied from STARLET.PAS	}
 
[HIDDEN] TYPE	(**** Pre-declared data types ****)
	$UBYTE = [BYTE] 0..255;
	$UWORD = [WORD] 0..65535;
	$UQUAD = [QUAD,UNSAFE] RECORD
		L0,L1:UNSIGNED; END;
 
(*  $ASSIGN                                                                 *)
(*                                                                          *)
(*    Assign I/O Channel                                                    *)
(*                                                                          *)
(*      $ASSIGN  devnam ,chan ,[acmode]  ,[mbxnam]                          *)
(*                                                                          *)
(*      devnam = address  of  device  name  or  logical  name   string      *)
(*               descriptor                                                 *)
(*      chan   = address of word to receive channel number assigned         *)
(*      acmode = access mode associated with channel                        *)
(*      mbxnam = address of mailbox logical name string descriptor, if      *)
(*               mailbox associated with device                             *)
(*                                                                          *)
 
[ASYNCHRONOUS,EXTERNAL(SYS$ASSIGN)] FUNCTION $ASSIGN (
	DEVNAM : [CLASS_S] PACKED ARRAY [$l1..$u1:INTEGER] OF CHAR;
	VAR CHAN : [VOLATILE]$UWORD;
	%IMMED ACMODE : UNSIGNED := %IMMED 0;
	MBXNAM : [CLASS_S] PACKED ARRAY [$l4..$u4:INTEGER] OF CHAR := %IMMED 0) : INTEGER; EXTERNAL; 
 
(*                                                                          *)
(*    Queue I/O Request                                                     *)
(*                                                                          *)
(*     $QIO     [efn] ,chan ,func ,[iosb] ,[astadr] ,[astprm]               *)
(*     ($QIOW)  ,[p1] ,[p2] ,[p3] ,[p4] ,[p5] ,[p6]                         *)
(*                                                                          *)
(*     efn    = number of event flag to set on completion                   *)
(*                                                                          *)
(*     chan   = number of channel on which I/O is directed                  *)
(*                                                                          *)
(*     func   = function code specifying action to be performed             *)
(*                                                                          *)
(*     iosb   = address of quadword I/O status block to receive final       *)
(*              completion status                                           *)
(*                                                                          *)
(*     astadr = address of entry mask of AST routine                        *)
(*                                                                          *)
(*     astprm = value to be passed to AST routine as argument               *)
(*                                                                          *)
(*     p1...  = optional device- and function-specific parameters           *)
(*                                                                          *)
 
[ASYNCHRONOUS,EXTERNAL(SYS$QIO)] FUNCTION $QIO (
	%IMMED EFN : UNSIGNED := %IMMED 0;
	%IMMED CHAN : INTEGER;
	%IMMED FUNC : INTEGER;
	VAR IOSB : [VOLATILE]$UQUAD := %IMMED 0;
	%IMMED [UNBOUND, ASYNCHRONOUS] PROCEDURE ASTADR := %IMMED 0;
	%IMMED ASTPRM : UNSIGNED := %IMMED 0;
	%REF P1 : [UNSAFE] ARRAY [$l7..$u7:INTEGER] OF $UBYTE := %IMMED 0;
	%IMMED P2 : INTEGER := %IMMED 0;
	%IMMED P3 : INTEGER := %IMMED 0;
	%IMMED P4 : INTEGER := %IMMED 0;
	%IMMED P5 : INTEGER := %IMMED 0;
	%IMMED P6 : INTEGER := %IMMED 0) : INTEGER; EXTERNAL;
 
[ASYNCHRONOUS,EXTERNAL(SYS$QIOW)] FUNCTION $QIOW (
	%IMMED EFN : UNSIGNED := %IMMED 0;
	%IMMED CHAN : INTEGER;
	%IMMED FUNC : INTEGER;
	VAR IOSB : [VOLATILE]$UQUAD := %IMMED 0;
	%IMMED [UNBOUND, ASYNCHRONOUS] PROCEDURE ASTADR := %IMMED 0;
	%IMMED ASTPRM : UNSIGNED := %IMMED 0;
	%REF P1 : [UNSAFE] ARRAY [$l7..$u7:INTEGER] OF $UBYTE := %IMMED 0;
	%IMMED P2 : INTEGER := %IMMED 0;
	%IMMED P3 : INTEGER := %IMMED 0;
	%IMMED P4 : INTEGER := %IMMED 0;
	%IMMED P5 : INTEGER := %IMMED 0;
	%IMMED P6 : INTEGER := %IMMED 0) : INTEGER; EXTERNAL; 

[external,asynchronous] procedure lib$stop (
  %immed condition: [unsafe] integer;
  %immed fao_params: [unsafe,list] integer); external;

[external] function lib$set_symbol (
  %stdescr sym: [readonly] packed array [$l1..$u1: integer] of char;
  %stdescr val: [readonly] packed array [$l2..$u2: integer] of char):
  integer; external;


var
  io$_sensechar:	[value, external] integer;
  io$m_ctrl:		[value, external] integer;
  ss$_normal:		[value, external] integer;

const
  nma$c_pcli_hwa = 1160;	{ from sys$library:lib.mlb	}
  devnam = 'DEQNA:' ;
  symnam = 'DEQNA_ADDRESS';
  bufl = 256;

type
  bufb = packed array [1..bufl] of $ubyte;
  bufc = packed array [1..bufl] of char;

var
  chan:	$uword ;
  sts: integer;
  iosb: $uquad;
  buf: bufb;
  lin: packed array [1..17] of char;
  i: integer;
  cd,ln,lc: integer;
  crock: $uword;
  hexdig: packed array [1..16] of char := '0123456789ABCDEF';

begin
  sts := $assign ( devnam, chan );
  if sts <> ss$_normal then lib$stop(sts);
  for i := 1 to bufl do buf[i] := 0;
  sts := $qiow ( chan := chan, iosb := iosb,
    func := io$_sensechar+io$m_ctrl, p2 := %stdescr buf::bufc);
  if sts <> ss$_normal then lib$stop(sts);
  crock := (iosb.L0)::$uword;
  if crock <> ss$_normal then lib$stop(iosb.L0);
  i := 1;
  repeat
    cd := int(buf[i+1]*256 + buf[i]);
    if uand(cd,4096) = 0 then begin
      lc := i + 2;
      ln := 4;
    end else begin
      lc := i + 4;
      ln := int(buf[i+3]*256 + buf[i+2]);
    end;
    i := lc + ln;
  until (uand(cd,4095) = nma$c_pcli_hwa) or (cd = 0);
  if cd <> nma$c_pcli_hwa+4096 then begin
    writeln ( '  Cannot find Ethernet adaptor hardware address.');
    halt;
  end;
  if ln <> 6 then begin
    writeln ( '  Ethernet adaptor hardware address has unexpected format.');
    halt;
  end;
  lin := '00-00-00-00-00-00' ;
  for i := 0 to 5 do begin
    lin[i*3+1] := hexdig[ buf[lc+i] div 16 + 1 ];
    lin[i*3+2] := hexdig[ buf[lc+i] mod 16 + 1 ];
  end;
  sts := lib$set_symbol( symnam, lin );
  if sts <> ss$_normal then lib$stop(sts);
end.