setting source hardware address (mac addr) - TCP-IP

This is a discussion on setting source hardware address (mac addr) - TCP-IP ; I understand that in unix you can use ioctl to change your mac address and you can use ifconfig. This will change the source address of the ethernet frames that go out. My question is how does this new address ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: setting source hardware address (mac addr)

  1. setting source hardware address (mac addr)

    I understand that in unix you can use ioctl to change your mac address
    and you can use ifconfig. This will change the source address of the
    ethernet frames that go out. My question is how does this new address
    actually get set? Is it set into the hardware or is is set in software
    and the address is copied into each frame that goes out? I would tend to
    think it is usually done by writing to a register of the ethernet
    controller or nic hardware and the hardware places the source address
    into the frame.

    The reason I ask is because I am working with a small embedded linux
    system that currently hardcodes the mac address in the ethernet driver.
    But I have yet to find how that address string gets into the outgoing
    packets. It does not seem to be used anywhere in linux and the driver
    itself does not write it to a ethernet controller chip register. All I
    see in the driver is the string copied to "dev->dev_addr". Yet when I
    change the hardcoded mac address and recompile the driver, the source
    address on each packet sent is then changed to the new hardcoded value.

    Anyone know?

    -gene

  2. Re: setting source hardware address (mac addr)

    In article ,
    Gene Smith wrote:
    >I understand that in unix you can use ioctl to change your mac address


    Your understanding is incorrect. The ability to change MAC address
    is not part of any Unix or POSIX standard. It is, though,
    offered as an -extension- in some systems.

    >The reason I ask is because I am working with a small embedded linux
    >system that currently hardcodes the mac address in the ethernet driver.


    Then yours is a -linux- question, not a TCP or Unix question; I
    suggest you check in a linux newsgroup.


  3. Re: setting source hardware address (mac addr)

    Walter Roberson wrote, On 07/24/2008 12:03 AM:
    > In article ,
    > Gene Smith wrote:
    >> I understand that in unix you can use ioctl to change your mac address

    >
    > Your understanding is incorrect. The ability to change MAC address
    > is not part of any Unix or POSIX standard. It is, though,
    > offered as an -extension- in some systems.


    OK, its not a standard. But it is often possible.

    >
    >> The reason I ask is because I am working with a small embedded linux
    >> system that currently hardcodes the mac address in the ethernet driver.

    >
    > Then yours is a -linux- question, not a TCP or Unix question; I
    > suggest you check in a linux newsgroup.
    >


    My actual system was just an example. The general question is whether
    the ethernet address (or source hardware address in the transmitted
    frame) is always pre-set into the hardware ethernet controller. Probably
    more of a low level/general ethernet question rather than tcp/ip (as
    this group is called). Just thought I would ask here.

  4. Re: setting source hardware address (mac addr)

    On Jul 23, 10:14*pm, Gene Smith wrote:
    > I understand that in unix you can use ioctl to change your mac address
    > and you can use ifconfig. This will change the source address of the
    > ethernet frames that go out. My question is how does this new address
    > actually get set? Is it set into the hardware or is is set in software
    > and the address is copied into each frame that goes out? I would tend to
    > think it is usually done by writing to a register of the ethernet
    > controller or nic hardware and the hardware places the source address
    > into the frame.


    That's generally how it's done.

    > The reason I ask is because I am working with a small embedded linux
    > system that currently hardcodes the mac address in the ethernet driver.
    > But I have yet to find how that address string gets into the outgoing
    > packets. It does not seem to be used anywhere in linux and the driver
    > itself does not write it to a ethernet controller chip register. All I
    > see in the driver is the string copied to "dev->dev_addr". Yet when I
    > change the hardcoded mac address and recompile the driver, the source
    > address on each packet sent is then changed to the new hardcoded value.


    Might be using memory-mapped I/O, where bytes that seem like they are
    being written to a memory address are actually going to registers on
    the device. As you undoubtedly already know, the device reponds to
    memory bus-control signals in the same way that memory chip does. Then
    in C:

    unsigned long int RegisterSet_memory_mapped_IO_address = 0xFEED0000UL;

    RegisterSet *dev = reinterpret_cast *>(RegisterSet_memory_mapped_IO_address);

    dev->dev_addr[0] = 0xF1; // puts F1 in low-oder byte of 6-byte
    Ethernet address in register set of device;

    -Le Chaud Lapin-

  5. Re: setting source hardware address (mac addr)

    In article ,
    Gene Smith wrote:

    > The general question is whether
    >the ethernet address (or source hardware address in the transmitted
    >frame) is always pre-set into the hardware ethernet controller.


    The answer to a question of the form "Is X *always done by hardware or
    sometimes by software?" is likely to be "No." For any reasonable mixture
    of hardware and software, you can often find a system that used it. An
    additional complication is that the distinction between "hardware" and
    "software" is fuzzy. For example, is "firmware" "software," "hardware,"
    neither, or both? If the CPU running the "driver" delegates as much
    as possible everything about MAC addresses to the "interface card", is
    the MAC address work done in "hardware" or "software"? What if the
    "interface card" has a CPU and the code for that CPU must be loaded
    into the card by the driver along with the MAC address and any other
    parameters? (I've worked on systems that did that.)

    The question "Is X always done by hardware?" is also likely to be
    uninteresting. You might care about the answer for implementations you
    are considering buying, or you might worry about the implementation you
    are designing. Unless you are writing some inter-advertising filler
    for a trade rag, some advertising, a text book, or some netnews Cliff
    Claven know-it-all fluff, why would you care about all possible
    past and future implementations?

    My experience in writing link layer drivers has been that both the
    software and the hardware often need to know the station's 48-bit MAC
    address and other relevant MAC addresses. The driver or software often
    creates entire outgoing packets including the link layer header with
    the MAC address but usually excluding the RCS or CRC. The driver often
    relies on the hardware to do at least some filtering based on destination
    MAC addresses of incoming packets. That filtering is often imperfect,
    for example, for multicast addresses or when the driver is in promiscuous
    mode.


    Vernon Schryver vjs@rhyolite.com

+ Reply to Thread