Re: getting link-layer addr of unknown interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 12 Dec 2001, Bernd Eckenfels wrote:

> In article <Pine.LNX.4.33.0112111355310.3218-100000@havoc.ittc.ku.edu> you wrote:
> > I should be able to get the link-layer address of an interface by 
> > specifying the interface name ie. eth0, eth1 etc.
> > (mac address for ethernet)
> 
> Do it like ifconfig is doing it:
> 
> lib/interface.c
>   strcpy(ifr.ifr_name, ifname);
>   if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
>           memset(ife->hwaddr, 0, 32);
>   else
>           memcpy(ife->hwaddr, ifr.ifr_hwaddr.sa_data, 8);

Thanks everybody for the solution. Now to hack some code!

ciao,
Amit

-- 
The statement below is true.
The statement above is false.
^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^
                  Amit Kucheria
          EECS Grad. Research Assistant
         University of Kansas @ Lawrence
   (R)+1-(785)-830 8521 ||| (O)+1-(785)-864 7774
____________________________________________________

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux