mardi 1 avril 2014

How does the mac related functions work in linux kernel, in skbuff.h?


Vote count:

0




I read the source code, but it did confuse me. For example the function sib_mac_header function, which is the third function in the code below, the sib -> head is the pointer to head of allocated buffer, and sib -> mac_header is the pointer to mac_header address in that buffer. Why the result of two address added together is the pointer to MAC ether structure??


Source code in skbuff.h is listed below:



1609 static inline void skb_reset_network_header(struct sk_buff *skb)
1610 {
1611 skb->network_header = skb->data - skb->head;
1612 }
1613
1614 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
1615 {
1616 skb_reset_network_header(skb);
1617 skb->network_header += offset;
1618 }
1619
1620 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
1621 {
1622 return skb->head + skb->mac_header;
1623 }


asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire