- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to get Mac address via DLPI API
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2009 02:38 AM
01-05-2009 02:38 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2009 02:55 AM
01-05-2009 02:55 AM
Re: How to get Mac address via DLPI API
or putmsg a DL_ATTACH_REQ
then a
DL_INFO_REQ message after attaching to a ppa.
then get the DL_INFO_ACK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2009 05:03 AM
01-05-2009 05:03 AM
Solution#include
#include
#include
#include
main(c,v)
int c;
char **v;
{
int f;
dl_attach_req_t dar;
dl_info_req_t dir;
struct strbuf ctl;
struct strbuf data;
unsigned char buf[4096];
dl_ok_ack_t *doa=(dl_ok_ack_t*)buf;
dl_info_ack_t *dia=(dl_info_ack_t*)buf;
dl_error_ack_t *dea=(dl_info_ack_t*)buf;
int r;
int fl=0;
int prim;
f=open("/dev/dlpi",O_RDWR);
dar.dl_primitive=DL_ATTACH_REQ;
dar.dl_ppa=atoi(v[1]);;
ctl.buf=(char*)&dar;
ctl.maxlen=ctl.len=sizeof(dar);
putmsg(f,&ctl,0,0);
ctl.buf=(char*)&buf;
ctl.maxlen=ctl.len=sizeof(buf);
data.len=0;
data.maxlen=sizeof(buf);
data.buf=&buf;
fl=RS_HIPRI;
r=getmsg(f,&ctl,&data,&fl);
if(r<0) perror("getmsg");
if((prim=doa->dl_primitive)!=DL_OK_ACK)
{
if (dea->dl_primitive==DL_ERROR_ACK)
printf("erreur: ppa=%d dl_error=%d dl_unix_errno=%d\n",atoi(v[1]),dea->dl_errno,dea->dl_unix_errno);
else
printf("erreur: ppa=%d primitive=%x\n",atoi(v[1]),dea->dl_primitive);
exit(1);
}
dir.dl_primitive=DL_INFO_REQ;
ctl.buf=(char*)&dir;
ctl.maxlen=ctl.len=sizeof(dir);
putmsg(f,&ctl,0,0);
ctl.buf=(char*)&buf;
ctl.maxlen=ctl.len=sizeof(buf);
data.len=data.maxlen=0;
data.buf=0;
fl=0;
r=getmsg(f,&ctl,&data,&fl);
if(r<0) perror("getmsg");
dia=buf;
if(dia->dl_primitive==DL_INFO_ACK)
{
int i;
int l;
int o;
char sep='=';
unsigned char*c;
l=dia->dl_addr_length;
o=dia->dl_addr_offset;
printf("interface %d mac addr",atoi(v[1]));
c=buf+o;
for(i=0;i
printf("%c%02x",sep,c[i]);
sep=':';
}
printf("\n");
}
else
printf("error! primitive=%d\n",dia->dl_primitive);
}
# cc m.c
# ./a.out 1
interface 1 mac addr=00:17:a4:51:4b:d1
# lanscan |grep lan1
0/1/2/1 0x0017A4514BD1 1 UP lan1 snap1 2 ETHER Yes 119
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2009 06:56 PM
01-05-2009 06:56 PM
Re: How to get Mac address via DLPI API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2009 10:54 PM
01-05-2009 10:54 PM
Re: How to get Mac address via DLPI API
Laurent already provided you with
almost everything.
HP documentation on DLPI programming
discusses various primitives including:
DL_HP_PPA_REQ
This primitive is used to obtain a list of
all the valid PPAs currently installed in
the system.
This message consists of one M_PCPROTO
message block which contains the following
structure.
Format
typedef struct {
u_long dl_primitive;
} dl_hp_ppa_req_t;
...
If your C programming is not efficient,
as a simple workaround you could use
Laurent's program and write a Shell
wrapper for it by using nwmgr(1M) or
lanscan(1m).
An example for lanscan(1m) (I cannot remember the layout for command nwmgr as
I am not at work and do not have HP-UX
11.31 server in front of me:
for PPA in `lanscan -i | awk '{print $1}' | sed -e 's/^lan//g'`
do
./a.out $PPA
done
Cheers,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2009 12:09 AM
01-06-2009 12:09 AM
Re: How to get Mac address via DLPI API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2009 03:51 AM
01-06-2009 03:51 AM
Re: How to get Mac address via DLPI API
u_long ctrl_area[LONG_AREA_SIZE];
u_long data_area[LONG_AREA_SIZE];
u_long i ;
int fd;
int ppa;
dl_hp_ppa_req_t *ppa_req = (dl_hp_ppa_req_t *)ctrl_area;
dl_hp_ppa_ack_t *ppa_ack = (dl_hp_ppa_ack_t *)ctrl_area;
dl_hp_ppa_info_t *ppa_info;
dl_error_ack_t *err_ack;
int flags = 0;
struct strbuf ctrl_buf;
struct strbuf data_buf;
ctrl_buf.maxlen = AREA_SIZE;
ctrl_buf.len = 0;
ctrl_buf.buf = (char*)ctrl_area;
data_buf.maxlen = AREA_SIZE;
data_buf.len = 0;
data_buf.buf = (char*)data_area;
/* open the device file */
if((fd = open("/dev/dlpi", O_RDWR)) == -1)
{
bRet = AL_false;
goto _exit;
}
ppa_req->dl_primitive = DL_HP_PPA_REQ;
ctrl_buf.len = sizeof(dl_hp_ppa_req_t);
if(putmsg(fd, &ctrl_buf, 0, 0) < 0)
{
bRet = AL_false;
goto _exit;
}
ctrl_area[0] = 0;
if(getmsg(fd, &ctrl_buf, &data_buf, &flags) < 0)
{
bRet = AL_false;
goto _exit;
}
err_ack = (dl_error_ack_t *)ctrl_area;
if(err_ack->dl_primitive != DL_HP_PPA_ACK)
{
bRet = AL_false;
goto _exit;
}
if(ppa_ack->dl_length == 0)
{
bRet = AL_false;
goto _exit;
}
nicinfoex->count = 0;
for ( i = 0; i < ppa_ack->dl_count; ++i )
{
if ( i == 0 )
{
ppa_info = (dl_hp_ppa_info_t *)((u_char *)ctrl_area + ppa_ack->dl_offset);
}
else
{
ppa_info = (dl_hp_ppa_info_t *)((u_char *)ctrl_area + ppa_ack->dl_offset + ppa_info->dl_next_offset);
}
ppa = ppa_info->dl_ppa;
if (ppa_info->dl_mac_type == DL_ETHER)
{
// Todo:
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2009 04:11 AM
01-06-2009 04:11 AM
Re: How to get Mac address via DLPI API
You can get the DL_HP_PPA_ACK
with 2 getmsg()
the you call the first one to only get the dl_hppa_ack_t setting max_len to sizeof(dl_hppa_ack_t) on the first call
getmsg will return 1 which means MORECTL
then you can read infos/infos or all the info_acks. mallocing ppa_ack->dl_length bytes before the 2nd getmsg()setting max_len to ppa_ack->dl_length.
it will contains all the rest of the DL_HP_PPA_ACK which contains the ppa infos.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2009 03:09 AM
01-16-2009 03:09 AM
Re: How to get Mac address via DLPI API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2009 04:14 AM
01-16-2009 04:14 AM
Re: How to get Mac address via DLPI API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2009 04:21 AM
01-16-2009 04:21 AM