xref: /OK3568_Linux_fs/kernel/include/linux/ip.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * INET		An implementation of the TCP/IP protocol suite for the LINUX
4*4882a593Smuzhiyun  *		operating system.  INET is implemented using the  BSD Socket
5*4882a593Smuzhiyun  *		interface as the means of communication with the user level.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  *		Definitions for the IP protocol.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * Version:	@(#)ip.h	1.0.2	04/28/93
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * Authors:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12*4882a593Smuzhiyun  */
13*4882a593Smuzhiyun #ifndef _LINUX_IP_H
14*4882a593Smuzhiyun #define _LINUX_IP_H
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #include <linux/skbuff.h>
17*4882a593Smuzhiyun #include <uapi/linux/ip.h>
18*4882a593Smuzhiyun 
ip_hdr(const struct sk_buff * skb)19*4882a593Smuzhiyun static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
20*4882a593Smuzhiyun {
21*4882a593Smuzhiyun 	return (struct iphdr *)skb_network_header(skb);
22*4882a593Smuzhiyun }
23*4882a593Smuzhiyun 
inner_ip_hdr(const struct sk_buff * skb)24*4882a593Smuzhiyun static inline struct iphdr *inner_ip_hdr(const struct sk_buff *skb)
25*4882a593Smuzhiyun {
26*4882a593Smuzhiyun 	return (struct iphdr *)skb_inner_network_header(skb);
27*4882a593Smuzhiyun }
28*4882a593Smuzhiyun 
ipip_hdr(const struct sk_buff * skb)29*4882a593Smuzhiyun static inline struct iphdr *ipip_hdr(const struct sk_buff *skb)
30*4882a593Smuzhiyun {
31*4882a593Smuzhiyun 	return (struct iphdr *)skb_transport_header(skb);
32*4882a593Smuzhiyun }
33*4882a593Smuzhiyun 
ip_transport_len(const struct sk_buff * skb)34*4882a593Smuzhiyun static inline unsigned int ip_transport_len(const struct sk_buff *skb)
35*4882a593Smuzhiyun {
36*4882a593Smuzhiyun 	return ntohs(ip_hdr(skb)->tot_len) - skb_network_header_len(skb);
37*4882a593Smuzhiyun }
38*4882a593Smuzhiyun #endif	/* _LINUX_IP_H */
39