<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to get Mac address via DLPI API in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331625#M56230</link>
    <description>I developed my project on HPUX ia64 11.v3, how can I get NIC's count and MAC address of each using DLPI API or other method? Thanks!!!!</description>
    <pubDate>Mon, 05 Jan 2009 10:38:57 GMT</pubDate>
    <dc:creator>hgjsj</dc:creator>
    <dc:date>2009-01-05T10:38:57Z</dc:date>
    <item>
      <title>How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331625#M56230</link>
      <description>I developed my project on HPUX ia64 11.v3, how can I get NIC's count and MAC address of each using DLPI API or other method? Thanks!!!!</description>
      <pubDate>Mon, 05 Jan 2009 10:38:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331625#M56230</guid>
      <dc:creator>hgjsj</dc:creator>
      <dc:date>2009-01-05T10:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331626#M56231</link>
      <description>system("lanscan");&lt;BR /&gt;&lt;BR /&gt;or putmsg a DL_ATTACH_REQ&lt;BR /&gt;then a&lt;BR /&gt;DL_INFO_REQ message after attaching to a ppa.&lt;BR /&gt;then get the DL_INFO_ACK.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jan 2009 10:55:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331626#M56231</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-01-05T10:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331627#M56232</link>
      <description>I took 10min to make an example:&lt;BR /&gt;#include&lt;SYS&gt;&lt;BR /&gt;#include&lt;SYS&gt;&lt;BR /&gt;#include &lt;STROPTS.H&gt;&lt;BR /&gt;#include &lt;FCNTL.H&gt;&lt;BR /&gt;&lt;BR /&gt;main(c,v)&lt;BR /&gt;int c;&lt;BR /&gt;char **v;&lt;BR /&gt;{&lt;BR /&gt;   int f;&lt;BR /&gt;   dl_attach_req_t dar;&lt;BR /&gt;   dl_info_req_t dir;&lt;BR /&gt;   struct strbuf ctl;&lt;BR /&gt;   struct strbuf data;&lt;BR /&gt;   unsigned char buf[4096];&lt;BR /&gt;   dl_ok_ack_t *doa=(dl_ok_ack_t*)buf;&lt;BR /&gt;   dl_info_ack_t *dia=(dl_info_ack_t*)buf;&lt;BR /&gt;   dl_error_ack_t *dea=(dl_info_ack_t*)buf;&lt;BR /&gt;   int r;&lt;BR /&gt;   int fl=0;&lt;BR /&gt;   int prim;&lt;BR /&gt;&lt;BR /&gt;   f=open("/dev/dlpi",O_RDWR);&lt;BR /&gt;   dar.dl_primitive=DL_ATTACH_REQ;&lt;BR /&gt;   dar.dl_ppa=atoi(v[1]);;&lt;BR /&gt;   ctl.buf=(char*)&amp;amp;dar;&lt;BR /&gt;   ctl.maxlen=ctl.len=sizeof(dar);&lt;BR /&gt;   putmsg(f,&amp;amp;ctl,0,0);&lt;BR /&gt;&lt;BR /&gt;   ctl.buf=(char*)&amp;amp;buf;&lt;BR /&gt;   ctl.maxlen=ctl.len=sizeof(buf);&lt;BR /&gt;   data.len=0;&lt;BR /&gt;   data.maxlen=sizeof(buf);&lt;BR /&gt;   data.buf=&amp;amp;buf;&lt;BR /&gt;   fl=RS_HIPRI;&lt;BR /&gt;   r=getmsg(f,&amp;amp;ctl,&amp;amp;data,&amp;amp;fl);&lt;BR /&gt;   if(r&amp;lt;0) perror("getmsg");&lt;BR /&gt;   if((prim=doa-&amp;gt;dl_primitive)!=DL_OK_ACK)&lt;BR /&gt;   {&lt;BR /&gt;       if (dea-&amp;gt;dl_primitive==DL_ERROR_ACK)&lt;BR /&gt;          printf("erreur: ppa=%d dl_error=%d dl_unix_errno=%d\n",atoi(v[1]),dea-&amp;gt;dl_errno,dea-&amp;gt;dl_unix_errno);&lt;BR /&gt;       else&lt;BR /&gt;          printf("erreur: ppa=%d primitive=%x\n",atoi(v[1]),dea-&amp;gt;dl_primitive);&lt;BR /&gt;       exit(1);&lt;BR /&gt;   }&lt;BR /&gt;   dir.dl_primitive=DL_INFO_REQ;&lt;BR /&gt;   ctl.buf=(char*)&amp;amp;dir;&lt;BR /&gt;   ctl.maxlen=ctl.len=sizeof(dir);&lt;BR /&gt;   putmsg(f,&amp;amp;ctl,0,0);&lt;BR /&gt;   ctl.buf=(char*)&amp;amp;buf;&lt;BR /&gt;   ctl.maxlen=ctl.len=sizeof(buf);&lt;BR /&gt;   data.len=data.maxlen=0;&lt;BR /&gt;   data.buf=0;&lt;BR /&gt;   fl=0;&lt;BR /&gt;   r=getmsg(f,&amp;amp;ctl,&amp;amp;data,&amp;amp;fl);&lt;BR /&gt;   if(r&amp;lt;0) perror("getmsg");&lt;BR /&gt;   dia=buf;&lt;BR /&gt;   if(dia-&amp;gt;dl_primitive==DL_INFO_ACK)&lt;BR /&gt;   {&lt;BR /&gt;      int i;&lt;BR /&gt;      int l;&lt;BR /&gt;      int o;&lt;BR /&gt;      char sep='=';&lt;BR /&gt;      unsigned char*c;&lt;BR /&gt;      l=dia-&amp;gt;dl_addr_length;&lt;BR /&gt;      o=dia-&amp;gt;dl_addr_offset;&lt;BR /&gt;      printf("interface %d mac addr",atoi(v[1]));&lt;BR /&gt;      c=buf+o;&lt;BR /&gt;      for(i=0;i&lt;L&gt;&lt;/L&gt;      {&lt;BR /&gt;          printf("%c%02x",sep,c[i]);&lt;BR /&gt;          sep=':';&lt;BR /&gt;      }&lt;BR /&gt;      printf("\n");&lt;BR /&gt;   }&lt;BR /&gt;   else&lt;BR /&gt;      printf("error! primitive=%d\n",dia-&amp;gt;dl_primitive);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# cc m.c&lt;BR /&gt;# ./a.out 1&lt;BR /&gt;interface 1 mac addr=00:17:a4:51:4b:d1&lt;BR /&gt;# lanscan |grep lan1&lt;BR /&gt;0/1/2/1  0x0017A4514BD1 1   UP    lan1 snap1     2   ETHER     Yes     119&lt;BR /&gt;&lt;BR /&gt;&lt;/FCNTL.H&gt;&lt;/STROPTS.H&gt;&lt;/SYS&gt;&lt;/SYS&gt;</description>
      <pubDate>Mon, 05 Jan 2009 13:03:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331627#M56232</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-01-05T13:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331628#M56233</link>
      <description>Thanks for your reply! according to the code above, it only get MAC address of lan1, could you tell me how many ethernet interface system installed, I need get all the MAC address of them.</description>
      <pubDate>Tue, 06 Jan 2009 02:56:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331628#M56233</guid>
      <dc:creator>hgjsj</dc:creator>
      <dc:date>2009-01-06T02:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331629#M56234</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Laurent already provided you with&lt;BR /&gt;almost everything.&lt;BR /&gt;&lt;BR /&gt;HP documentation on DLPI programming&lt;BR /&gt;discusses various primitives including:&lt;BR /&gt;&lt;BR /&gt;DL_HP_PPA_REQ&lt;BR /&gt;This primitive is used to obtain a list of&lt;BR /&gt;all the valid PPAs currently installed in&lt;BR /&gt;the system.&lt;BR /&gt;&lt;BR /&gt;This message consists of one M_PCPROTO&lt;BR /&gt;message block which contains the following&lt;BR /&gt;structure.&lt;BR /&gt;&lt;BR /&gt;Format&lt;BR /&gt;&lt;BR /&gt;typedef struct {&lt;BR /&gt;u_long     dl_primitive;&lt;BR /&gt;} dl_hp_ppa_req_t;&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;If your C programming is not efficient,&lt;BR /&gt;as a simple workaround you could use&lt;BR /&gt;Laurent's program and write a Shell&lt;BR /&gt;wrapper for it by using nwmgr(1M) or&lt;BR /&gt;lanscan(1m).&lt;BR /&gt;&lt;BR /&gt;An example for lanscan(1m) (I cannot remember the layout for command nwmgr as&lt;BR /&gt;I am not at work and do not have HP-UX&lt;BR /&gt;11.31 server in front of me:&lt;BR /&gt;&lt;BR /&gt;for PPA in `lanscan -i | awk '{print $1}' | sed -e 's/^lan//g'`&lt;BR /&gt;do&lt;BR /&gt;   ./a.out $PPA&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
      <pubDate>Tue, 06 Jan 2009 06:54:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331629#M56234</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2009-01-06T06:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331630#M56235</link>
      <description>Thanks both of you, I know Laurent code is right, it is also a good workaroud way using shell scrip to wrapper, but i must use C programming to get PPAs list and get all of the MAC address. Could you give me a sample? many thanks.</description>
      <pubDate>Tue, 06 Jan 2009 08:09:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331630#M56235</guid>
      <dc:creator>hgjsj</dc:creator>
      <dc:date>2009-01-06T08:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331631#M56236</link>
      <description>Thanks, I had fixed this issue.&lt;BR /&gt;&lt;BR /&gt;    u_long ctrl_area[LONG_AREA_SIZE];&lt;BR /&gt;    u_long data_area[LONG_AREA_SIZE];&lt;BR /&gt;    u_long i ;&lt;BR /&gt;    int fd;  &lt;BR /&gt;    int ppa;  &lt;BR /&gt;    dl_hp_ppa_req_t *ppa_req = (dl_hp_ppa_req_t *)ctrl_area;&lt;BR /&gt;    dl_hp_ppa_ack_t *ppa_ack = (dl_hp_ppa_ack_t *)ctrl_area;&lt;BR /&gt;    dl_hp_ppa_info_t *ppa_info;&lt;BR /&gt;    dl_error_ack_t *err_ack;&lt;BR /&gt;    int flags = 0;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    struct strbuf ctrl_buf;  &lt;BR /&gt;    struct strbuf data_buf; &lt;BR /&gt;&lt;BR /&gt;    ctrl_buf.maxlen = AREA_SIZE;&lt;BR /&gt;    ctrl_buf.len = 0;&lt;BR /&gt;    ctrl_buf.buf = (char*)ctrl_area;&lt;BR /&gt;&lt;BR /&gt;    data_buf.maxlen = AREA_SIZE;&lt;BR /&gt;    data_buf.len = 0;&lt;BR /&gt;    data_buf.buf = (char*)data_area;&lt;BR /&gt;&lt;BR /&gt;    /* open the device file */&lt;BR /&gt;    if((fd = open("/dev/dlpi", O_RDWR)) == -1) &lt;BR /&gt;    {&lt;BR /&gt;        bRet = AL_false;&lt;BR /&gt;        goto _exit;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;    ppa_req-&amp;gt;dl_primitive = DL_HP_PPA_REQ;&lt;BR /&gt;&lt;BR /&gt;    ctrl_buf.len = sizeof(dl_hp_ppa_req_t);&lt;BR /&gt;&lt;BR /&gt;    if(putmsg(fd, &amp;amp;ctrl_buf, 0, 0) &amp;lt; 0) &lt;BR /&gt;    {&lt;BR /&gt;        bRet = AL_false;&lt;BR /&gt;        goto _exit;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;    ctrl_area[0] = 0;&lt;BR /&gt;&lt;BR /&gt;    if(getmsg(fd, &amp;amp;ctrl_buf, &amp;amp;data_buf, &amp;amp;flags) &amp;lt; 0)&lt;BR /&gt;    {&lt;BR /&gt;        bRet = AL_false;&lt;BR /&gt;        goto _exit;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;    err_ack = (dl_error_ack_t *)ctrl_area;&lt;BR /&gt;&lt;BR /&gt;    if(err_ack-&amp;gt;dl_primitive != DL_HP_PPA_ACK)&lt;BR /&gt;    {&lt;BR /&gt;        bRet = AL_false;&lt;BR /&gt;        goto _exit;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;    if(ppa_ack-&amp;gt;dl_length == 0) &lt;BR /&gt;    {&lt;BR /&gt;        bRet = AL_false;&lt;BR /&gt;        goto _exit;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;    nicinfoex-&amp;gt;count = 0;&lt;BR /&gt;    for ( i = 0; i &amp;lt; ppa_ack-&amp;gt;dl_count; ++i )&lt;BR /&gt;    {&lt;BR /&gt;        if ( i == 0 )&lt;BR /&gt;        {&lt;BR /&gt;            ppa_info = (dl_hp_ppa_info_t *)((u_char *)ctrl_area + ppa_ack-&amp;gt;dl_offset);&lt;BR /&gt;        }&lt;BR /&gt;        else&lt;BR /&gt;        {&lt;BR /&gt;            ppa_info = (dl_hp_ppa_info_t *)((u_char *)ctrl_area + ppa_ack-&amp;gt;dl_offset + ppa_info-&amp;gt;dl_next_offset);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        ppa = ppa_info-&amp;gt;dl_ppa;&lt;BR /&gt;&lt;BR /&gt;        if (ppa_info-&amp;gt;dl_mac_type == DL_ETHER)&lt;BR /&gt;        {&lt;BR /&gt;           // Todo: &lt;BR /&gt;        }&lt;BR /&gt;    }</description>
      <pubDate>Tue, 06 Jan 2009 11:51:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331631#M56236</guid>
      <dc:creator>hgjsj</dc:creator>
      <dc:date>2009-01-06T11:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331632#M56237</link>
      <description>Just 1 remark,&lt;BR /&gt;&lt;BR /&gt;You can get the DL_HP_PPA_ACK&lt;BR /&gt;with 2 getmsg()&lt;BR /&gt;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&lt;BR /&gt;getmsg will return 1 which means MORECTL&lt;BR /&gt;then you can read infos/infos or all the info_acks. mallocing ppa_ack-&amp;gt;dl_length  bytes before the 2nd getmsg()setting max_len to ppa_ack-&amp;gt;dl_length.&lt;BR /&gt; it will contains all the rest of the DL_HP_PPA_ACK which contains the ppa infos.&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Jan 2009 12:11:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331632#M56237</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-01-06T12:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331633#M56238</link>
      <description>Is there other way to get by using the ioctl call with proper request?</description>
      <pubDate>Fri, 16 Jan 2009 11:09:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331633#M56238</guid>
      <dc:creator>jgobbur</dc:creator>
      <dc:date>2009-01-16T11:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331634#M56239</link>
      <description>with ioctl you can only get plumb interfaces - the same as netstat -ni output with a ioctl over a  AF_INET/SOCK_RAW</description>
      <pubDate>Fri, 16 Jan 2009 12:14:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331634#M56239</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-01-16T12:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Mac address via DLPI API</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331635#M56240</link>
      <description>do you know have any sample code. pls share with me.</description>
      <pubDate>Fri, 16 Jan 2009 12:21:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-mac-address-via-dlpi-api/m-p/4331635#M56240</guid>
      <dc:creator>jgobbur</dc:creator>
      <dc:date>2009-01-16T12:21:34Z</dc:date>
    </item>
  </channel>
</rss>

