hardiman@bcstec.boeing.com (Paul Hardiman) (06/03/91)
How does one programmaticcaly ascertain the machine address (the 6 byte code of the communications card) of a connected peer. Ciao 4 now.
scotta@hpcuhe.cup.hp.com (Scott Anderson) (06/08/91)
I don't really know what I'm talking about, but LaserROM (HP's CD-ROM based documentation searcher) tells me that you should check out the lan(7) man page (specifically the FRAME_HEADER stuff). net_aton(3N) might be useful to you as well. Scott Anderson An RTEsian and proud of it... Hewlett-Packard Data Systems Operation scotta@cup.hp.com 11000 Wolfe Rd. MS 42UN 408-447-5219 Cupertino, CA 95014
jeff@hpfcmgw.HP.COM (Jeff Taylor) (06/11/91)
> How does one programmaticcaly ascertain the machine address > (the 6 byte code of the communications card) of a connected peer. I think this will help. No promises. Jeff Taylor #include <std_disclaimers.h> -------------------------------------------------------------------------- /* * Example code to show the use of an ioctl to fetch the ethernet address * of a workstation. The 48 bit address of the local Ethernet/IEEE802 * device is returned in arg.value.s. */ #include <netio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> static char *hex="0123456789ABCDEF"; main() { int fildes,request; struct fis arg; int i; char addr[15]; fildes=open("/dev/lan", O_RDWR); request = NETSTAT; arg.reqtype = LOCAL_ADDRESS; if (ioctl(fildes,request,&arg)<0) { printf("netstat failed\n"); exit(-1); } /* convert the address into a string of hex characters and print. */ addr[0]='0'; addr[1]='x'; for (i=0; i<6; i++) { addr[i*2+2] = hex[arg.value.s[i] >> 4]; /* high nibble of i'th byte */ addr[i*2+3] = hex[arg.value.s[i] & 0x0f]; /* low nibble of i'th byte */ } addr[14]='\000'; printf("ethernet address is %s\n",addr); }
mike@hpwin052.HP.COM (Mike Croom) (06/11/91)
HP's OpenView Network Node Manager and 8.0 ( I believe) both have programs for dumping out the contents of the arp cache (mapping of Ip address to Physical address. For a particular TCP connection you have a lot dirty grubbing through OS structures which I beieve has been done in the past but would need a rewrite if/when those structures change. Mike croom HP LONDON