Answer the question
In order to leave comments, you need to log in
In what byte order is the MAC address written in the ethernet packet?
Hello! I am interested in the question, is it worth translating the MAC address extracted from the ethernet packet from network order to local byte order? Or is it written as 6 separate single byte numbers?
Thanks for answers. I am using pcap. The code is something like this
typedef unsigned short u16;
u16 extract_16bits(const void *p)
{
return ((u16)ntohs(*(const u16 *)(p)));
}
void callback(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char* packet)
{
int data_offset = 12; //DMAC + SMAC
u16 etype = extract_16bits(packet + data_offset);
....
}
void main(void)
{
...
pcap_loop(descr, -1, callback, NULL);
...
}
Answer the question
In order to leave comments, you need to log in
Or is it written as 6 separate single byte numbers?
a) Each address field shall be 48 bits in length.
...
d) Each octet of each address field shall be transmitted least significant bit first.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question