Operating System - HP-UX
1832869 Members
2903 Online
110048 Solutions
New Discussion

DLPI - can't collect mac addresses in 64-bit

 
maxime1
Visitor

DLPI - can't collect mac addresses in 64-bit

Hello


I try to collect MAC addresses on HP-UX. There are 2 MAC addresses (lan0 and lan1) on my test machine (HP integrity server, HP-UX itanium V2).


I first send attach requests with ppa 0 and 1, and then use the DLPI primitives DL_PHYS_ADDR_REQ and  DL_PHYS_ADDR_ACK to collect the physical addresses.


The program works well when compiled in 32-bit, but both requests (with ppa=0 and ppa=1) return the same physical address when the program is 64-bit.


Any idea why I can't collect the 2 MAC addresses on 64-bit?


Your help will be greatly appreciated.


Thanks

6 REPLIES 6
Steven Schweda
Honored Contributor

Re: DLPI - can't collect mac addresses in 64-bit

> Your help will be greatly appreciated.

 

   You first.  Do you _really_ expect advice on a program when only
_you_ (and some psychics?) can see either the program source or how you
built the executable from it?

> Any idea why I can't collect the 2 MAC addresses on 64-bit?

   I'd guess some kind of programming error, possibly involving 32-bit
versus 64-bit storage.  Without some actual information, that's about
the best I can do.

maxime1
Visitor

Re: DLPI - can't collect mac addresses in 64-bit

Thank you for you reply.

 

I am sorry but I don't have the sources right now. Basically, I followed the examples of DLPI documentation.

http://h10032.www1.hp.com/ctg/Manual/c02011471.pdf (p 188):

/* Attach to the PPA */
dl_attach_req.dl_primitive = DL_ATTACH_REQ;
dl_attach_req.dl_ppa = 0; /* in 64-bit, I get the same phyical address with ppa = 1 */
ctlbuf.len = sizeof (dl_attach_req);
ctlbuf.buf = (char *) &dl_attach_req;
flags = RS_HIPRI;
printf("Sending a DL_ATTACH_REQ primitive\n");
if (putmsg(fd, &ctlbuf, (struct strbuf*) NULL, flags) < 0) {
	perror("main: putmsg");
	ctlbuf.buf = buf_ctl;
	ctlbuf.maxlen = 1000;
}
if (getmsg(fd, &ctlbuf, (struct strbuf*)NULL, &flags) < 0) {
	perror("main: getmsg");
	recv_primitive = *(int *)buf_ctl;
	/* If DL_OK_ACK is received, attach was successful */
	if (recv_primitive != DL_OK_ACK) {
		printf("Could not attach\n");
		exit(1);
	}
}

/* Request phyical Address */
dl_addr_req.dl_primitive = DL_PHYS_ADDR_REQ;
dl_addr_req.dl_addr_type = DL_CURR_PHYS_ADDR;
ctlbuf.len = sizeof (dl_addr_req);
ctlbuf.buf = (char *) &dl_addr_req;
flags = RS_HIPRI;
printf("Sending a DL_PHYS_ADDR_REQ primitive\n");
if (putmsg(fd, &ctlbuf, (struct strbuf*) NULL, flags) < 0) {
	perror("main: putmsg");
	ctlbuf.buf = buf_ctl;
	ctlbuf.maxlen = 1000;
}
if (getmsg(fd, &ctlbuf, (struct strbuf*)NULL, &flags) < 0) {
	perror("main: getmsg");
	recv_primitive = *(int *)buf_ctl;
	if (recv_primitive != DL_OK_ACK) {
		printf("Could not find phyical address\n");
		exit(1);
	}
}

/*show the result : the phyical address is stored in position 3,4 in 32 bit, and 1, 16 in 64 bit. I get different values when I change the ppa in 32-bit. In 64 bit however, the ppa has no effect: I can get only 1 physical address. */
for (i = 0; i < 16, i++) {
	printf("%d : %d", i, (ulong)ctlbuf.buf[i]);
}

/* close & exit */
close(fd);
Dennis Handly
Acclaimed Contributor

Re: DLPI - can't collect MAC addresses in 64-bit

Do you get any warnings when you compile for 64 bit?

maxime1
Visitor

Re: DLPI - can't collect MAC addresses in 64-bit

only one warning:

 

warning: use of C99 long long integer constant

 

but not on the file where containing the code to get the physical address..

maxime1
Visitor

Re: DLPI - can't collect mac addresses in 64-bit

> I'd guess some kind of programming error, possibly involving 32-bit versus 64-bit storage. 

 

Quick hint, but you were right. That was about ulong type which seems to have different size in 64-bit.

The solution was to use:

(u_char *)ctrl_area + addr_ack->dl_addr_offset;

(inspired from the 'Connection Mode Example' example of the DLPI Programmer’s Guide (p 196))

 

Your help is greatly appreciated ;)

Dennis Handly
Acclaimed Contributor

Re: DLPI - can't collect MAC addresses in 64-bit

>That was about ulong type which has a different size in 64-bit.

 

Yes, that would be 32 vs 64.  Not sure how (u_char*) would replace it, unless it didn't really work in 32 bit mode.