Description of the net_skbuff_data_uses_offset macro in the skbuff. h file

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.