25 #include <linux/types.h>
40 #define IPSKB_FORWARDED 1
41 #define IPSKB_XFRM_TUNNEL_SIZE 2
42 #define IPSKB_XFRM_TRANSFORMED 4
43 #define IPSKB_FRAG_COMPLETE 8
44 #define IPSKB_REROUTED 16
49 static inline unsigned int ip_hdrlen(
const struct sk_buff *
skb)
51 return ip_hdr(skb)->ihl * 4;
61 #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
79 #define IP_OFFSET 0x1FFF
81 #define IP_FRAG_TIME (30 * HZ)
112 int getfrag(
void *
from,
char *to,
int offset,
int len,
114 void *from,
int len,
int protolen,
132 void *from,
int length,
int transhdrlen,
156 #define IP_REPLY_ARG_NOSRCCHECK 1
173 #define IP_INC_STATS(net, field) SNMP_INC_STATS64((net)->mib.ip_statistics, field)
174 #define IP_INC_STATS_BH(net, field) SNMP_INC_STATS64_BH((net)->mib.ip_statistics, field)
175 #define IP_ADD_STATS(net, field, val) SNMP_ADD_STATS64((net)->mib.ip_statistics, field, val)
176 #define IP_ADD_STATS_BH(net, field, val) SNMP_ADD_STATS64_BH((net)->mib.ip_statistics, field, val)
177 #define IP_UPD_PO_STATS(net, field, val) SNMP_UPD_PO_STATS64((net)->mib.ip_statistics, field, val)
178 #define IP_UPD_PO_STATS_BH(net, field, val) SNMP_UPD_PO_STATS64_BH((net)->mib.ip_statistics, field, val)
179 #define NET_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.net_statistics, field)
180 #define NET_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.net_statistics, field)
181 #define NET_INC_STATS_USER(net, field) SNMP_INC_STATS_USER((net)->mib.net_statistics, field)
182 #define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
183 #define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
186 #if BITS_PER_LONG==32
187 extern u64 snmp_fold_field64(
void __percpu *mib[],
int offt,
size_t sync_off);
189 static inline u64 snmp_fold_field64(
void __percpu *mib[],
int offt,
size_t syncp_off)
204 static inline int inet_is_reserved_local_port(
int port)
206 return test_bit(port, sysctl_local_reserved_ports);
226 static inline bool ip_is_fragment(
const struct iphdr *iph)
237 int ip_decrease_ttl(
struct iphdr *iph)
250 !(dst_metric_locked(dst,
RTAX_MTU)));
263 iph->
id = (sk && inet_sk(sk)->inet_daddr) ?
264 htons(inet_sk(sk)->inet_id++) : 0;
269 static inline void ip_select_ident_more(
struct iphdr *iph,
struct dst_entry *dst,
struct sock *sk,
int more)
273 iph->
id =
htons(inet_sk(sk)->inet_id);
274 inet_sk(sk)->inet_id += 1 + more;
285 static inline void ip_eth_mc_map(
__be32 naddr,
char *
buf)
303 static inline void ip_ib_mc_map(
__be32 naddr,
const unsigned char *broadcast,
char *
buf)
306 unsigned char scope = broadcast[5] & 0xF;
314 buf[5] = 0x10 |
scope;
317 buf[8] = broadcast[8];
318 buf[9] = broadcast[9];
325 buf[19] = addr & 0xff;
327 buf[18] = addr & 0xff;
329 buf[17] = addr & 0xff;
331 buf[16] = addr & 0x0f;
334 static inline void ip_ipgre_mc_map(
__be32 naddr,
const unsigned char *broadcast,
char *
buf)
336 if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0)
337 memcpy(buf, broadcast, 4);
339 memcpy(buf, &naddr,
sizeof(naddr));
342 #if IS_ENABLED(CONFIG_IPV6)
343 #include <linux/ipv6.h>
348 inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0;
349 #if IS_ENABLED(CONFIG_IPV6)
361 static inline int sk_mc_loop(
struct sock *sk)
365 switch (sk->sk_family) {
367 return inet_sk(sk)->mc_loop;
368 #if IS_ENABLED(CONFIG_IPV6)
370 return inet6_sk(sk)->mc_loop;
428 unsigned char *
data,
int optlen);
430 unsigned char __user *
data,
int optlen);
443 extern int ip_setsockopt(
struct sock *sk,
int level,
int optname,
char __user *optval,
unsigned int optlen);
444 extern int ip_getsockopt(
struct sock *sk,
int level,
int optname,
char __user *optval,
int __user *optlen);
446 int optname,
char __user *optval,
unsigned int optlen);
448 int optname,
char __user *optval,
int __user *optlen);
457 #ifdef CONFIG_PROC_FS