I often see such representation of MAC address in C code:
struct mac_addr {
unsigned char bytes[6];
}
Why necessary put an array in a structure, why not just have an array? What benefit does this provide?
Thanks.
A MAC address consists of 48 bits, usually represented as a string of 12 hexadecimal digits (0 to 9, a to f, or A to F); these are often grouped into pairs separated by colons or dashes. For example, the MAC address 001B638445E6 may be given as 00:1b:63:84:45:e6 or as 00-1B-63-84-45-E6.
A MAC address is a 48-bit hexadecimal address. It's usually six sets of two digits or characters, separated by colons. An example MAC address would be 00:00:5e:00:53:af. Many network card and other hardware manufacturers use a unique sequence at the beginning of their products' MAC addresses.
The Block ID is the first six characters of a MAC address. The Device ID is the remaining six characters. The Block ID is unique to the manufacturer. The Device ID is based on the device's model and manufacturer date.
A valid MAC address must satisfy the following conditions: It must contain 12 hexadecimal digits. One way to represent them is to form six pairs of the characters separated with a hyphen (-) or colon(:). For example, 01-23-45-67-89-AB is a valid MAC address.
You can't assign an array in C. But you can assign a struct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With