Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

representation of MAC address in C code

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.

like image 945
Mark Avatar asked Oct 20 '13 20:10

Mark


People also ask

How do you represent a MAC address?

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.

How are MAC addresses usually presented?

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.

What are the first 6 characters of a MAC address?

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.

What is a valid MAC address format?

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.


1 Answers

You can't assign an array in C. But you can assign a struct.

like image 163
Oliver Charlesworth Avatar answered Oct 18 '22 07:10

Oliver Charlesworth