Re: Automatic MAC address retrieval/access
Eddie Kohler <[email protected]>
| Newsgroups | gmane.network.routing.click |
|---|---|
| Message-ID | <CAF0C5SJLmMQZMmEif9nB1-LVXxx0xAW8+r9-HkG0qGO_dZyA2Q@mail.gmail.com> |
Hi Markku, What OS are you using? On Mon, Nov 14, 2011 at 9:21 AM, Markku Savela <[email protected]> wrote: > I would like to make click configuration that automaticly > retrieves the MAC addresses from the Hardware (non-linux). > > AddressInfo seems to be doing something like that, but I > have hard time understanding how it works when used in > context of elements like APRResponder, which expect > configuration string as parameter. Basically it works like this. ARPResponder uses "EtherAddressArg" (see etheraddress.hh) to parse Ethernet addresses. If EtherAddressArg can't parse a string, it asks AddressInfo to try. The relevant function is AddressInfo::query_ethernet. This function first checks for explicitly defined shorthand strings (e.g., "AddressInfo(foo 00:0a:47:32:33:34)"), then calls query_netdevice as a backup. > AddressInfo, however, appears not to be a simple storage > of a string and return it on request. The AddressInfo seems > to be returning binary data instead. That's right, the binary data is the Ethernet address, 6 bytes of data. > => some documentation pointers to read? > > Anyway, the default retrieval seems support only Linux/BSD. > > Is the correct approach just patch this and add my own > #ifdefs for the specific HW into query_ethernet function? > Instead of "query_netdevice", I would use something of my > own? What you should do is extend AddressInfo::create_deviceinfo if possible. This function should find ALL devices attached to the machine and store their addresses in "deviceinfo". That vector contains pairs of device name and annotated address. The first byte of the annotated address is the address type ("i" for ipv4, "I" for ipv4 net mask, "e" for ethernet). The remaining bytes are the bytes of the address (4 bytes for ipv4, 6 for ethernet). Patches as always are welcome. The current code should work on Linux or on any OS that supports the getifaddrs() function. Eddie > > _______________________________________________ > click mailing list > [email protected] > https://amsterdam.lcs.mit.edu/mailman/listinfo/click >