Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * INET     An implementation of the TCP/IP protocol suite for the LINUX
0004  *      operating system.  INET is implemented using the  BSD Socket
0005  *      interface as the means of communication with the user level.
0006  *
0007  *      Definitions for the IP protocol.
0008  *
0009  * Version: @(#)ip.h    1.0.2   04/28/93
0010  *
0011  * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
0012  */
0013 #ifndef _LINUX_IP_H
0014 #define _LINUX_IP_H
0015 
0016 #include <linux/skbuff.h>
0017 #include <uapi/linux/ip.h>
0018 
0019 static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
0020 {
0021     return (struct iphdr *)skb_network_header(skb);
0022 }
0023 
0024 static inline struct iphdr *inner_ip_hdr(const struct sk_buff *skb)
0025 {
0026     return (struct iphdr *)skb_inner_network_header(skb);
0027 }
0028 
0029 static inline struct iphdr *ipip_hdr(const struct sk_buff *skb)
0030 {
0031     return (struct iphdr *)skb_transport_header(skb);
0032 }
0033 
0034 static inline unsigned int ip_transport_len(const struct sk_buff *skb)
0035 {
0036     return ntohs(ip_hdr(skb)->tot_len) - skb_network_header_len(skb);
0037 }
0038 #endif  /* _LINUX_IP_H */