Operating System - HP-UX
1752661 Members
5957 Online
108788 Solutions
New Discussion

How to get Network Adapter MAC Address by calling C's API

 
SOLVED
Go to solution
曾暘展
New Member

How to get Network Adapter MAC Address by calling C's API

I don't know how to get the MAC Address by calling C's API.
I had read the API Document, but I still cannot find the functions that I can use.
Please help me. Thanks a lot.
1 REPLY 1
Solution

Re: How to get Network Adapter MAC Address by calling C's API

Hi,

this code is from the comp.sys.hp.hpux newsgroup FAQ. I haven't tested it (no compiler!) :

#include
#include
#include

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 \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);
}
}



HTH

Duncan

I am an HPE Employee
Accept or Kudo