ip.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*
  2. * INET An implementation of the TCP/IP protocol suite for the LINUX
  3. * operating system. INET is implemented using the BSD Socket
  4. * interface as the means of communication with the user level.
  5. *
  6. * Definitions for the IP module.
  7. *
  8. * Version: @(#)ip.h 1.0.2 05/07/93
  9. *
  10. * Authors: Ross Biro
  11. * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12. * Alan Cox, <gw4pts@gw4pts.ampr.org>
  13. *
  14. * Changes:
  15. * Mike McLagan : Routing by source
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License
  19. * as published by the Free Software Foundation; either version
  20. * 2 of the License, or (at your option) any later version.
  21. */
  22. #ifndef _IP_H
  23. #define _IP_H
  24. #include <linux/types.h>
  25. #include <linux/ip.h>
  26. #include <linux/in.h>
  27. #include <linux/skbuff.h>
  28. #include <net/inet_sock.h>
  29. #include <net/route.h>
  30. #include <net/snmp.h>
  31. #include <net/flow.h>
  32. #include <net/flow_dissector.h>
  33. struct sock;
  34. struct inet_skb_parm {
  35. struct ip_options opt; /* Compiled IP options */
  36. unsigned char flags;
  37. #define IPSKB_FORWARDED BIT(0)
  38. #define IPSKB_XFRM_TUNNEL_SIZE BIT(1)
  39. #define IPSKB_XFRM_TRANSFORMED BIT(2)
  40. #define IPSKB_FRAG_COMPLETE BIT(3)
  41. #define IPSKB_REROUTED BIT(4)
  42. #define IPSKB_DOREDIRECT BIT(5)
  43. #define IPSKB_FRAG_PMTU BIT(6)
  44. u16 frag_max_size;
  45. };
  46. static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
  47. {
  48. return ip_hdr(skb)->ihl * 4;
  49. }
  50. struct ipcm_cookie {
  51. __be32 addr;
  52. int oif;
  53. struct ip_options_rcu *opt;
  54. __u8 tx_flags;
  55. __u8 ttl;
  56. __s16 tos;
  57. char priority;
  58. };
  59. #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
  60. #define PKTINFO_SKB_CB(skb) ((struct in_pktinfo *)((skb)->cb))
  61. struct ip_ra_chain {
  62. struct ip_ra_chain __rcu *next;
  63. struct sock *sk;
  64. union {
  65. void (*destructor)(struct sock *);
  66. struct sock *saved_sk;
  67. };
  68. struct rcu_head rcu;
  69. };
  70. extern struct ip_ra_chain __rcu *ip_ra_chain;
  71. /* IP flags. */
  72. #define IP_CE 0x8000 /* Flag: "Congestion" */
  73. #define IP_DF 0x4000 /* Flag: "Don't Fragment" */
  74. #define IP_MF 0x2000 /* Flag: "More Fragments" */
  75. #define IP_OFFSET 0x1FFF /* "Fragment Offset" part */
  76. #define IP_FRAG_TIME (30 * HZ) /* fragment lifetime */
  77. struct msghdr;
  78. struct net_device;
  79. struct packet_type;
  80. struct rtable;
  81. struct sockaddr;
  82. int igmp_mc_init(void);
  83. /*
  84. * Functions provided by ip.c
  85. */
  86. int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
  87. __be32 saddr, __be32 daddr,
  88. struct ip_options_rcu *opt);
  89. int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
  90. struct net_device *orig_dev);
  91. int ip_local_deliver(struct sk_buff *skb);
  92. int ip_mr_input(struct sk_buff *skb);
  93. int ip_output(struct sock *sk, struct sk_buff *skb);
  94. int ip_mc_output(struct sock *sk, struct sk_buff *skb);
  95. int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
  96. int (*output)(struct sock *, struct sk_buff *));
  97. void ip_send_check(struct iphdr *ip);
  98. int __ip_local_out(struct sk_buff *skb);
  99. int ip_local_out_sk(struct sock *sk, struct sk_buff *skb);
  100. static inline int ip_local_out(struct sk_buff *skb)
  101. {
  102. return ip_local_out_sk(skb->sk, skb);
  103. }
  104. int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
  105. void ip_init(void);
  106. int ip_append_data(struct sock *sk, struct flowi4 *fl4,
  107. int getfrag(void *from, char *to, int offset, int len,
  108. int odd, struct sk_buff *skb),
  109. void *from, int len, int protolen,
  110. struct ipcm_cookie *ipc,
  111. struct rtable **rt,
  112. unsigned int flags);
  113. int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd,
  114. struct sk_buff *skb);
  115. ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
  116. int offset, size_t size, int flags);
  117. struct sk_buff *__ip_make_skb(struct sock *sk, struct flowi4 *fl4,
  118. struct sk_buff_head *queue,
  119. struct inet_cork *cork);
  120. int ip_send_skb(struct net *net, struct sk_buff *skb);
  121. int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4);
  122. void ip_flush_pending_frames(struct sock *sk);
  123. struct sk_buff *ip_make_skb(struct sock *sk, struct flowi4 *fl4,
  124. int getfrag(void *from, char *to, int offset,
  125. int len, int odd, struct sk_buff *skb),
  126. void *from, int length, int transhdrlen,
  127. struct ipcm_cookie *ipc, struct rtable **rtp,
  128. unsigned int flags);
  129. static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4)
  130. {
  131. return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork.base);
  132. }
  133. static inline __u8 get_rttos(struct ipcm_cookie* ipc, struct inet_sock *inet)
  134. {
  135. return (ipc->tos != -1) ? RT_TOS(ipc->tos) : RT_TOS(inet->tos);
  136. }
  137. static inline __u8 get_rtconn_flags(struct ipcm_cookie* ipc, struct sock* sk)
  138. {
  139. return (ipc->tos != -1) ? RT_CONN_FLAGS_TOS(sk, ipc->tos) : RT_CONN_FLAGS(sk);
  140. }
  141. /* datagram.c */
  142. int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
  143. int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
  144. void ip4_datagram_release_cb(struct sock *sk);
  145. struct ip_reply_arg {
  146. struct kvec iov[1];
  147. int flags;
  148. __wsum csum;
  149. int csumoffset; /* u16 offset of csum in iov[0].iov_base */
  150. /* -1 if not needed */
  151. int bound_dev_if;
  152. u8 tos;
  153. };
  154. #define IP_REPLY_ARG_NOSRCCHECK 1
  155. static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg)
  156. {
  157. return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0;
  158. }
  159. void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
  160. const struct ip_options *sopt,
  161. __be32 daddr, __be32 saddr,
  162. const struct ip_reply_arg *arg,
  163. unsigned int len);
  164. #define IP_INC_STATS(net, field) SNMP_INC_STATS64((net)->mib.ip_statistics, field)
  165. #define IP_INC_STATS_BH(net, field) SNMP_INC_STATS64_BH((net)->mib.ip_statistics, field)
  166. #define IP_ADD_STATS(net, field, val) SNMP_ADD_STATS64((net)->mib.ip_statistics, field, val)
  167. #define IP_ADD_STATS_BH(net, field, val) SNMP_ADD_STATS64_BH((net)->mib.ip_statistics, field, val)
  168. #define IP_UPD_PO_STATS(net, field, val) SNMP_UPD_PO_STATS64((net)->mib.ip_statistics, field, val)
  169. #define IP_UPD_PO_STATS_BH(net, field, val) SNMP_UPD_PO_STATS64_BH((net)->mib.ip_statistics, field, val)
  170. #define NET_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.net_statistics, field)
  171. #define NET_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.net_statistics, field)
  172. #define NET_INC_STATS_USER(net, field) SNMP_INC_STATS_USER((net)->mib.net_statistics, field)
  173. #define NET_ADD_STATS(net, field, adnd) SNMP_ADD_STATS((net)->mib.net_statistics, field, adnd)
  174. #define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
  175. #define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
  176. u64 snmp_get_cpu_field(void __percpu *mib, int cpu, int offct);
  177. unsigned long snmp_fold_field(void __percpu *mib, int offt);
  178. #if BITS_PER_LONG==32
  179. u64 snmp_get_cpu_field64(void __percpu *mib, int cpu, int offct,
  180. size_t syncp_offset);
  181. u64 snmp_fold_field64(void __percpu *mib, int offt, size_t sync_off);
  182. #else
  183. static inline u64 snmp_get_cpu_field64(void __percpu *mib, int cpu, int offct,
  184. size_t syncp_offset)
  185. {
  186. return snmp_get_cpu_field(mib, cpu, offct);
  187. }
  188. static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_off)
  189. {
  190. return snmp_fold_field(mib, offt);
  191. }
  192. #endif
  193. void inet_get_local_port_range(struct net *net, int *low, int *high);
  194. #ifdef CONFIG_SYSCTL
  195. static inline int inet_is_local_reserved_port(struct net *net, int port)
  196. {
  197. if (!net->ipv4.sysctl_local_reserved_ports)
  198. return 0;
  199. return test_bit(port, net->ipv4.sysctl_local_reserved_ports);
  200. }
  201. static inline bool sysctl_dev_name_is_allowed(const char *name)
  202. {
  203. return strcmp(name, "default") != 0 && strcmp(name, "all") != 0;
  204. }
  205. #else
  206. static inline int inet_is_local_reserved_port(struct net *net, int port)
  207. {
  208. return 0;
  209. }
  210. #endif
  211. /* From inetpeer.c */
  212. extern int inet_peer_threshold;
  213. extern int inet_peer_minttl;
  214. extern int inet_peer_maxttl;
  215. /* From ip_input.c */
  216. extern int sysctl_ip_early_demux;
  217. /* From ip_output.c */
  218. extern int sysctl_ip_dynaddr;
  219. void ipfrag_init(void);
  220. void ip_static_sysctl_init(void);
  221. #define IP4_REPLY_MARK(net, mark) \
  222. ((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0)
  223. static inline bool ip_is_fragment(const struct iphdr *iph)
  224. {
  225. return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0;
  226. }
  227. #ifdef CONFIG_INET
  228. #include <net/dst.h>
  229. /* The function in 2.2 was invalid, producing wrong result for
  230. * check=0xFEFF. It was noticed by Arthur Skawina _year_ ago. --ANK(000625) */
  231. static inline
  232. int ip_decrease_ttl(struct iphdr *iph)
  233. {
  234. u32 check = (__force u32)iph->check;
  235. check += (__force u32)htons(0x0100);
  236. iph->check = (__force __sum16)(check + (check>=0xFFFF));
  237. return --iph->ttl;
  238. }
  239. static inline
  240. int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
  241. {
  242. return inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO ||
  243. (inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT &&
  244. !(dst_metric_locked(dst, RTAX_MTU)));
  245. }
  246. static inline bool ip_sk_accept_pmtu(const struct sock *sk)
  247. {
  248. return inet_sk(sk)->pmtudisc != IP_PMTUDISC_INTERFACE &&
  249. inet_sk(sk)->pmtudisc != IP_PMTUDISC_OMIT;
  250. }
  251. static inline bool ip_sk_use_pmtu(const struct sock *sk)
  252. {
  253. return inet_sk(sk)->pmtudisc < IP_PMTUDISC_PROBE;
  254. }
  255. static inline bool ip_sk_ignore_df(const struct sock *sk)
  256. {
  257. return inet_sk(sk)->pmtudisc < IP_PMTUDISC_DO ||
  258. inet_sk(sk)->pmtudisc == IP_PMTUDISC_OMIT;
  259. }
  260. static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
  261. bool forwarding)
  262. {
  263. struct net *net = dev_net(dst->dev);
  264. if (net->ipv4.sysctl_ip_fwd_use_pmtu ||
  265. dst_metric_locked(dst, RTAX_MTU) ||
  266. !forwarding)
  267. return dst_mtu(dst);
  268. return min(dst->dev->mtu, IP_MAX_MTU);
  269. }
  270. static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
  271. {
  272. if (!skb->sk || ip_sk_use_pmtu(skb->sk)) {
  273. bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED;
  274. return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding);
  275. } else {
  276. return min(skb_dst(skb)->dev->mtu, IP_MAX_MTU);
  277. }
  278. }
  279. u32 ip_idents_reserve(u32 hash, int segs);
  280. void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
  281. static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
  282. struct sock *sk, int segs)
  283. {
  284. struct iphdr *iph = ip_hdr(skb);
  285. if ((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) {
  286. /* This is only to work around buggy Windows95/2000
  287. * VJ compression implementations. If the ID field
  288. * does not change, they drop every other packet in
  289. * a TCP stream using header compression.
  290. */
  291. if (sk && inet_sk(sk)->inet_daddr) {
  292. iph->id = htons(inet_sk(sk)->inet_id);
  293. inet_sk(sk)->inet_id += segs;
  294. } else {
  295. iph->id = 0;
  296. }
  297. } else {
  298. __ip_select_ident(net, iph, segs);
  299. }
  300. }
  301. static inline void ip_select_ident(struct net *net, struct sk_buff *skb,
  302. struct sock *sk)
  303. {
  304. ip_select_ident_segs(net, skb, sk, 1);
  305. }
  306. static inline __wsum inet_compute_pseudo(struct sk_buff *skb, int proto)
  307. {
  308. return csum_tcpudp_nofold(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
  309. skb->len, proto, 0);
  310. }
  311. /* copy IPv4 saddr & daddr to flow_keys, possibly using 64bit load/store
  312. * Equivalent to : flow->v4addrs.src = iph->saddr;
  313. * flow->v4addrs.dst = iph->daddr;
  314. */
  315. static inline void iph_to_flow_copy_v4addrs(struct flow_keys *flow,
  316. const struct iphdr *iph)
  317. {
  318. BUILD_BUG_ON(offsetof(typeof(flow->addrs), v4addrs.dst) !=
  319. offsetof(typeof(flow->addrs), v4addrs.src) +
  320. sizeof(flow->addrs.v4addrs.src));
  321. memcpy(&flow->addrs.v4addrs, &iph->saddr, sizeof(flow->addrs.v4addrs));
  322. flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
  323. }
  324. static inline __wsum inet_gro_compute_pseudo(struct sk_buff *skb, int proto)
  325. {
  326. const struct iphdr *iph = skb_gro_network_header(skb);
  327. return csum_tcpudp_nofold(iph->saddr, iph->daddr,
  328. skb_gro_len(skb), proto, 0);
  329. }
  330. /*
  331. * Map a multicast IP onto multicast MAC for type ethernet.
  332. */
  333. static inline void ip_eth_mc_map(__be32 naddr, char *buf)
  334. {
  335. __u32 addr=ntohl(naddr);
  336. buf[0]=0x01;
  337. buf[1]=0x00;
  338. buf[2]=0x5e;
  339. buf[5]=addr&0xFF;
  340. addr>>=8;
  341. buf[4]=addr&0xFF;
  342. addr>>=8;
  343. buf[3]=addr&0x7F;
  344. }
  345. /*
  346. * Map a multicast IP onto multicast MAC for type IP-over-InfiniBand.
  347. * Leave P_Key as 0 to be filled in by driver.
  348. */
  349. static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
  350. {
  351. __u32 addr;
  352. unsigned char scope = broadcast[5] & 0xF;
  353. buf[0] = 0; /* Reserved */
  354. buf[1] = 0xff; /* Multicast QPN */
  355. buf[2] = 0xff;
  356. buf[3] = 0xff;
  357. addr = ntohl(naddr);
  358. buf[4] = 0xff;
  359. buf[5] = 0x10 | scope; /* scope from broadcast address */
  360. buf[6] = 0x40; /* IPv4 signature */
  361. buf[7] = 0x1b;
  362. buf[8] = broadcast[8]; /* P_Key */
  363. buf[9] = broadcast[9];
  364. buf[10] = 0;
  365. buf[11] = 0;
  366. buf[12] = 0;
  367. buf[13] = 0;
  368. buf[14] = 0;
  369. buf[15] = 0;
  370. buf[19] = addr & 0xff;
  371. addr >>= 8;
  372. buf[18] = addr & 0xff;
  373. addr >>= 8;
  374. buf[17] = addr & 0xff;
  375. addr >>= 8;
  376. buf[16] = addr & 0x0f;
  377. }
  378. static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
  379. {
  380. if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0)
  381. memcpy(buf, broadcast, 4);
  382. else
  383. memcpy(buf, &naddr, sizeof(naddr));
  384. }
  385. #if IS_ENABLED(CONFIG_IPV6)
  386. #include <linux/ipv6.h>
  387. #endif
  388. static __inline__ void inet_reset_saddr(struct sock *sk)
  389. {
  390. inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0;
  391. #if IS_ENABLED(CONFIG_IPV6)
  392. if (sk->sk_family == PF_INET6) {
  393. struct ipv6_pinfo *np = inet6_sk(sk);
  394. memset(&np->saddr, 0, sizeof(np->saddr));
  395. memset(&sk->sk_v6_rcv_saddr, 0, sizeof(sk->sk_v6_rcv_saddr));
  396. }
  397. #endif
  398. }
  399. #endif
  400. static inline unsigned int ipv4_addr_hash(__be32 ip)
  401. {
  402. return (__force unsigned int) ip;
  403. }
  404. bool ip_call_ra_chain(struct sk_buff *skb);
  405. /*
  406. * Functions provided by ip_fragment.c
  407. */
  408. enum ip_defrag_users {
  409. IP_DEFRAG_LOCAL_DELIVER,
  410. IP_DEFRAG_CALL_RA_CHAIN,
  411. IP_DEFRAG_CONNTRACK_IN,
  412. __IP_DEFRAG_CONNTRACK_IN_END = IP_DEFRAG_CONNTRACK_IN + USHRT_MAX,
  413. IP_DEFRAG_CONNTRACK_OUT,
  414. __IP_DEFRAG_CONNTRACK_OUT_END = IP_DEFRAG_CONNTRACK_OUT + USHRT_MAX,
  415. IP_DEFRAG_CONNTRACK_BRIDGE_IN,
  416. __IP_DEFRAG_CONNTRACK_BRIDGE_IN = IP_DEFRAG_CONNTRACK_BRIDGE_IN + USHRT_MAX,
  417. IP_DEFRAG_VS_IN,
  418. IP_DEFRAG_VS_OUT,
  419. IP_DEFRAG_VS_FWD,
  420. IP_DEFRAG_AF_PACKET,
  421. IP_DEFRAG_MACVLAN,
  422. };
  423. /* Return true if the value of 'user' is between 'lower_bond'
  424. * and 'upper_bond' inclusively.
  425. */
  426. static inline bool ip_defrag_user_in_between(u32 user,
  427. enum ip_defrag_users lower_bond,
  428. enum ip_defrag_users upper_bond)
  429. {
  430. return user >= lower_bond && user <= upper_bond;
  431. }
  432. int ip_defrag(struct sk_buff *skb, u32 user);
  433. #ifdef CONFIG_INET
  434. struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user);
  435. #else
  436. static inline struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user)
  437. {
  438. return skb;
  439. }
  440. #endif
  441. int ip_frag_mem(struct net *net);
  442. /*
  443. * Functions provided by ip_forward.c
  444. */
  445. int ip_forward(struct sk_buff *skb);
  446. /*
  447. * Functions provided by ip_options.c
  448. */
  449. void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
  450. __be32 daddr, struct rtable *rt, int is_frag);
  451. int __ip_options_echo(struct ip_options *dopt, struct sk_buff *skb,
  452. const struct ip_options *sopt);
  453. static inline int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb)
  454. {
  455. return __ip_options_echo(dopt, skb, &IPCB(skb)->opt);
  456. }
  457. void ip_options_fragment(struct sk_buff *skb);
  458. int ip_options_compile(struct net *net, struct ip_options *opt,
  459. struct sk_buff *skb);
  460. int ip_options_get(struct net *net, struct ip_options_rcu **optp,
  461. unsigned char *data, int optlen);
  462. int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp,
  463. unsigned char __user *data, int optlen);
  464. void ip_options_undo(struct ip_options *opt);
  465. void ip_forward_options(struct sk_buff *skb);
  466. int ip_options_rcv_srr(struct sk_buff *skb);
  467. /*
  468. * Functions provided by ip_sockglue.c
  469. */
  470. void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb);
  471. void ip_cmsg_recv_offset(struct msghdr *msg, struct sk_buff *skb, int offset);
  472. int ip_cmsg_send(struct net *net, struct msghdr *msg,
  473. struct ipcm_cookie *ipc, bool allow_ipv6);
  474. int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
  475. unsigned int optlen);
  476. int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
  477. int __user *optlen);
  478. int compat_ip_setsockopt(struct sock *sk, int level, int optname,
  479. char __user *optval, unsigned int optlen);
  480. int compat_ip_getsockopt(struct sock *sk, int level, int optname,
  481. char __user *optval, int __user *optlen);
  482. int ip_ra_control(struct sock *sk, unsigned char on,
  483. void (*destructor)(struct sock *));
  484. int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len);
  485. void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,
  486. u32 info, u8 *payload);
  487. void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
  488. u32 info);
  489. static inline void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb)
  490. {
  491. ip_cmsg_recv_offset(msg, skb, 0);
  492. }
  493. bool icmp_global_allow(void);
  494. extern int sysctl_icmp_msgs_per_sec;
  495. extern int sysctl_icmp_msgs_burst;
  496. #ifdef CONFIG_PROC_FS
  497. int ip_misc_proc_init(void);
  498. #endif
  499. #endif /* _IP_H */