Original address: http://blog.csdn.net/skyflying2012/article/details/40322563
Some time ago in the work of network card driver, now product mass production, the use of ifconfig eth hw ether When configuring the MAC address to find a problem,
Random configuration of a MAC address, found that some will be reported cannot assign requested address.
The error code is eaddrnotavail.
Driver implemented a special SET_MAC_ADDR function, look at the function, found that the original will verify the validity of the MAC address.
[CPP]View PlainCopy
- <span style=< Span class= "string" style= "Border:none; Color: #0000ff ">" FONT-SIZE:14PX; " > Static inline int is_valid_ether_addr (const u8 *addr" &NBSP;&NBSP;
- {
- / * FF:FF:FF:FF:FF:FF is a multicast address so we don ' t need to
- * Explicitly check for it here. */
- return !is_multicast_ether_addr (addr) &&!is_zero_ether_addr (addr);
- }
- </span>
The check is not a multicast address or a full 0 address.
The multicast address is the first byte with the lowest bit 1, the problem is here.
A eaddrnotavail error code is returned when the function returns the SET_MAC_ADDR in the first byte with the lowest bit of 1 o'clock.
Strictly speaking MAC address for each NIC is fixed, each NIC is produced, there will be a global unique number to identify themselves, will not repeat,
This number is the MAC address, which is the physical address of the NIC. The MAC address consists of a 48-bit binary number, which is 6 bytes. In the communication is expressed in 16 binary.
The first 24 bits are the factory code that is applied by the manufacturer to the IEEE Standards organization, which is fixed, but the lowest bit of a byte must be 0, because the physical address of the NIC must be a unicast address
In the IPV4 environment, the distinction between unicast and multicast addresses is the binary number of the lowest digit of the school check, 0 for the unicast address and 1 for the multicast address.
In other words, the second number must be 0, 2, 4, 6, 8, A, C, e one of them.
So MAC address Although can be modified, but do not change, to follow the manufacturer's regulations to modify, so as not to repeat.
Ethernet MAC Address specification