Article Source: http://hi.baidu.com/xootus/item/2e2fb06f57afe22268105b13
Find the location defined by net_skbuff_data_uses_offset. The File Include/Linux/skbuff. h
# If bits_per_long> 32
# Define net_skbuff_data_uses_offset 1
# Endif
Where net_skbuff_data_uses_offset is used, for example:
# Ifdef net_skbuff_data_uses_offset
// If offset is used to indicate the offset, It is a relative offset:
Static inline unsigned char * skb_transport_header (const struct sk_buff * SKB)
{
Return SKB-> head + SKB-> transport_header;
}
......
# Else/* net_skbuff_data_uses_offset */
// If relative offset is not used
Static inline unsigned char * skb_transport_header (const struct sk_buff * SKB)
{
Return SKB-> transport_header;
}
......
# Endif/* net_skbuff_data_uses_offset */
The preceding figure shows the implementation of the * skb_network_header function,Back to the implementation of the network layer protocol header for 32-bit and 64-bit systems,
The skb_network_header function has different implementations. Therefore, it is better to directly call the * skb_network_header function in programming.
It can be said that these functions provide great convenience for us to write kernel programs, instead of spending more energy on calculating pointer offsets at each layer,
You can focus more on strategic design.