Parent document is top of "comp.sys.hp.hpux FAQ"
Previous document is "7.41 How to get an MS-DOS floppy formatted using HP-UX?"
Next document is "7.43 Is there a Transport Level Interface (TLI) interface to TCP on HP-UX?"

7.42 How to get the MAC (station) address programmatically?

Here's some sample LLA code to do this. Note that you can use DLPI to do
the same, and LLA in not supported in HP-UX 10.0. Sample DLPI code
can be found on HPSL, the document id is CWA940907000.

/*
Here's some sample code that you can use to get your own
station address (otherwise known as MAC address or LAN card address).
Be sure to compile this with the -ln option, since the net_ntoa(3N)
call is found in /usr/lib/libn.a.

This program was compiled by doing: cc get.c -o get -g -ln

*/

#include <stdio.h>
#include <netio.h>
#include <fcntl.h>

main(argc, argv)
int    argc;
char   *argv[];
{
   struct fis s_fis;
   struct fis s_fis;
   int lanic;
   char *ascii[6];

   if (argc < 2) {
      printf ("Usage: %s <device file>\n", argv[0]);
      exit (1);
      }

   lanic = open(argv[1], O_RDWR);
   if (lanic < 0) {
      perror("Error in opening %s", argv[1]);
      printf("Error = %d\n", lanic);
      exit(1);
   } else {
      s_fis.reqtype = LOCAL_ADDRESS;
      s_fis.vtype = INTEGERTYPE;

      ioctl(lanic, NETSTAT, &s_fis);
      net_ntoa(ascii, s_fis.value.s, 6);
      printf("Station address of %s is %s\n", argv[1], ascii);

      s_fis.reqtype = PERMANENT_ADDRESS;
      s_fis.vtype = INTEGERTYPE;
      ioctl(lanic, NETSTAT, &s_fis);
      net_ntoa(ascii, s_fis.value.s, 6);
      printf("Permanent Station address of %s is %s\n", argv[1], ascii);
      close(lanic);
      }
}

(Thanks to Colin Wynd <colin@col.hp.com>)

Parent document is top of "comp.sys.hp.hpux FAQ"
Previous document is "7.41 How to get an MS-DOS floppy formatted using HP-UX?"
Next document is "7.43 Is there a Transport Level Interface (TLI) interface to TCP on HP-UX?"