summaryrefslogtreecommitdiffstats
path: root/include/net/ip.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/ip.h')
-rw-r--r--include/net/ip.h189
1 files changed, 99 insertions, 90 deletions
diff --git a/include/net/ip.h b/include/net/ip.h
index 5e5268807a1c..5a25f36fe3a7 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -28,6 +28,7 @@
28#include <linux/skbuff.h> 28#include <linux/skbuff.h>
29 29
30#include <net/inet_sock.h> 30#include <net/inet_sock.h>
31#include <net/route.h>
31#include <net/snmp.h> 32#include <net/snmp.h>
32#include <net/flow.h> 33#include <net/flow.h>
33 34
@@ -56,6 +57,9 @@ struct ipcm_cookie {
56 int oif; 57 int oif;
57 struct ip_options_rcu *opt; 58 struct ip_options_rcu *opt;
58 __u8 tx_flags; 59 __u8 tx_flags;
60 __u8 ttl;
61 __s16 tos;
62 char priority;
59}; 63};
60 64
61#define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb)) 65#define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
@@ -86,64 +90,71 @@ struct packet_type;
86struct rtable; 90struct rtable;
87struct sockaddr; 91struct sockaddr;
88 92
89extern int igmp_mc_proc_init(void); 93int igmp_mc_proc_init(void);
90 94
91/* 95/*
92 * Functions provided by ip.c 96 * Functions provided by ip.c
93 */ 97 */
94 98
95extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, 99int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
96 __be32 saddr, __be32 daddr, 100 __be32 saddr, __be32 daddr,
97 struct ip_options_rcu *opt); 101 struct ip_options_rcu *opt);
98extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, 102int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
99 struct packet_type *pt, struct net_device *orig_dev); 103 struct net_device *orig_dev);
100extern int ip_local_deliver(struct sk_buff *skb); 104int ip_local_deliver(struct sk_buff *skb);
101extern int ip_mr_input(struct sk_buff *skb); 105int ip_mr_input(struct sk_buff *skb);
102extern int ip_output(struct sk_buff *skb); 106int ip_output(struct sk_buff *skb);
103extern int ip_mc_output(struct sk_buff *skb); 107int ip_mc_output(struct sk_buff *skb);
104extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); 108int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
105extern int ip_do_nat(struct sk_buff *skb); 109int ip_do_nat(struct sk_buff *skb);
106extern void ip_send_check(struct iphdr *ip); 110void ip_send_check(struct iphdr *ip);
107extern int __ip_local_out(struct sk_buff *skb); 111int __ip_local_out(struct sk_buff *skb);
108extern int ip_local_out(struct sk_buff *skb); 112int ip_local_out(struct sk_buff *skb);
109extern int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl); 113int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl);
110extern void ip_init(void); 114void ip_init(void);
111extern int ip_append_data(struct sock *sk, struct flowi4 *fl4, 115int ip_append_data(struct sock *sk, struct flowi4 *fl4,
112 int getfrag(void *from, char *to, int offset, int len, 116 int getfrag(void *from, char *to, int offset, int len,
113 int odd, struct sk_buff *skb), 117 int odd, struct sk_buff *skb),
114 void *from, int len, int protolen, 118 void *from, int len, int protolen,
115 struct ipcm_cookie *ipc, 119 struct ipcm_cookie *ipc,
116 struct rtable **rt, 120 struct rtable **rt,
117 unsigned int flags); 121 unsigned int flags);
118extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb); 122int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd,
119extern ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, 123 struct sk_buff *skb);
120 int offset, size_t size, int flags); 124ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
121extern struct sk_buff *__ip_make_skb(struct sock *sk, 125 int offset, size_t size, int flags);
122 struct flowi4 *fl4, 126struct sk_buff *__ip_make_skb(struct sock *sk, struct flowi4 *fl4,
123 struct sk_buff_head *queue, 127 struct sk_buff_head *queue,
124 struct inet_cork *cork); 128 struct inet_cork *cork);
125extern int ip_send_skb(struct net *net, struct sk_buff *skb); 129int ip_send_skb(struct net *net, struct sk_buff *skb);
126extern int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4); 130int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4);
127extern void ip_flush_pending_frames(struct sock *sk); 131void ip_flush_pending_frames(struct sock *sk);
128extern struct sk_buff *ip_make_skb(struct sock *sk, 132struct sk_buff *ip_make_skb(struct sock *sk, struct flowi4 *fl4,
129 struct flowi4 *fl4, 133 int getfrag(void *from, char *to, int offset,
130 int getfrag(void *from, char *to, int offset, int len, 134 int len, int odd, struct sk_buff *skb),
131 int odd, struct sk_buff *skb), 135 void *from, int length, int transhdrlen,
132 void *from, int length, int transhdrlen, 136 struct ipcm_cookie *ipc, struct rtable **rtp,
133 struct ipcm_cookie *ipc, 137 unsigned int flags);
134 struct rtable **rtp,
135 unsigned int flags);
136 138
137static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4) 139static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4)
138{ 140{
139 return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork.base); 141 return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork.base);
140} 142}
141 143
144static inline __u8 get_rttos(struct ipcm_cookie* ipc, struct inet_sock *inet)
145{
146 return (ipc->tos != -1) ? RT_TOS(ipc->tos) : RT_TOS(inet->tos);
147}
148
149static inline __u8 get_rtconn_flags(struct ipcm_cookie* ipc, struct sock* sk)
150{
151 return (ipc->tos != -1) ? RT_CONN_FLAGS_TOS(sk, ipc->tos) : RT_CONN_FLAGS(sk);
152}
153
142/* datagram.c */ 154/* datagram.c */
143extern int ip4_datagram_connect(struct sock *sk, 155int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
144 struct sockaddr *uaddr, int addr_len);
145 156
146extern void ip4_datagram_release_cb(struct sock *sk); 157void ip4_datagram_release_cb(struct sock *sk);
147 158
148struct ip_reply_arg { 159struct ip_reply_arg {
149 struct kvec iov[1]; 160 struct kvec iov[1];
@@ -184,16 +195,16 @@ extern struct ipv4_config ipv4_config;
184#define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd) 195#define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
185#define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd) 196#define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
186 197
187extern unsigned long snmp_fold_field(void __percpu *mib[], int offt); 198unsigned long snmp_fold_field(void __percpu *mib[], int offt);
188#if BITS_PER_LONG==32 199#if BITS_PER_LONG==32
189extern u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t sync_off); 200u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t sync_off);
190#else 201#else
191static inline u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_off) 202static inline u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_off)
192{ 203{
193 return snmp_fold_field(mib, offt); 204 return snmp_fold_field(mib, offt);
194} 205}
195#endif 206#endif
196extern int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align); 207int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align);
197 208
198static inline void snmp_mib_free(void __percpu *ptr[SNMP_ARRAY_SZ]) 209static inline void snmp_mib_free(void __percpu *ptr[SNMP_ARRAY_SZ])
199{ 210{
@@ -206,11 +217,7 @@ static inline void snmp_mib_free(void __percpu *ptr[SNMP_ARRAY_SZ])
206 } 217 }
207} 218}
208 219
209extern struct local_ports { 220void inet_get_local_port_range(struct net *net, int *low, int *high);
210 seqlock_t lock;
211 int range[2];
212} sysctl_local_ports;
213extern void inet_get_local_port_range(int *low, int *high);
214 221
215extern unsigned long *sysctl_local_reserved_ports; 222extern unsigned long *sysctl_local_reserved_ports;
216static inline int inet_is_reserved_local_port(int port) 223static inline int inet_is_reserved_local_port(int port)
@@ -231,9 +238,9 @@ extern int sysctl_ip_early_demux;
231/* From ip_output.c */ 238/* From ip_output.c */
232extern int sysctl_ip_dynaddr; 239extern int sysctl_ip_dynaddr;
233 240
234extern void ipfrag_init(void); 241void ipfrag_init(void);
235 242
236extern void ip_static_sysctl_init(void); 243void ip_static_sysctl_init(void);
237 244
238static inline bool ip_is_fragment(const struct iphdr *iph) 245static inline bool ip_is_fragment(const struct iphdr *iph)
239{ 246{
@@ -262,7 +269,7 @@ int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
262 !(dst_metric_locked(dst, RTAX_MTU))); 269 !(dst_metric_locked(dst, RTAX_MTU)));
263} 270}
264 271
265extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); 272void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
266 273
267static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk) 274static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk)
268{ 275{
@@ -367,7 +374,7 @@ static __inline__ void inet_reset_saddr(struct sock *sk)
367 struct ipv6_pinfo *np = inet6_sk(sk); 374 struct ipv6_pinfo *np = inet6_sk(sk);
368 375
369 memset(&np->saddr, 0, sizeof(np->saddr)); 376 memset(&np->saddr, 0, sizeof(np->saddr));
370 memset(&np->rcv_saddr, 0, sizeof(np->rcv_saddr)); 377 memset(&sk->sk_v6_rcv_saddr, 0, sizeof(sk->sk_v6_rcv_saddr));
371 } 378 }
372#endif 379#endif
373} 380}
@@ -390,7 +397,7 @@ static inline int sk_mc_loop(struct sock *sk)
390 return 1; 397 return 1;
391} 398}
392 399
393extern bool ip_call_ra_chain(struct sk_buff *skb); 400bool ip_call_ra_chain(struct sk_buff *skb);
394 401
395/* 402/*
396 * Functions provided by ip_fragment.c 403 * Functions provided by ip_fragment.c
@@ -428,50 +435,52 @@ int ip_frag_nqueues(struct net *net);
428 * Functions provided by ip_forward.c 435 * Functions provided by ip_forward.c
429 */ 436 */
430 437
431extern int ip_forward(struct sk_buff *skb); 438int ip_forward(struct sk_buff *skb);
432 439
433/* 440/*
434 * Functions provided by ip_options.c 441 * Functions provided by ip_options.c
435 */ 442 */
436 443
437extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, 444void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
438 __be32 daddr, struct rtable *rt, int is_frag); 445 __be32 daddr, struct rtable *rt, int is_frag);
439extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); 446int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb);
440extern void ip_options_fragment(struct sk_buff *skb); 447void ip_options_fragment(struct sk_buff *skb);
441extern int ip_options_compile(struct net *net, 448int ip_options_compile(struct net *net, struct ip_options *opt,
442 struct ip_options *opt, struct sk_buff *skb); 449 struct sk_buff *skb);
443extern int ip_options_get(struct net *net, struct ip_options_rcu **optp, 450int ip_options_get(struct net *net, struct ip_options_rcu **optp,
444 unsigned char *data, int optlen); 451 unsigned char *data, int optlen);
445extern int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, 452int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp,
446 unsigned char __user *data, int optlen); 453 unsigned char __user *data, int optlen);
447extern void ip_options_undo(struct ip_options * opt); 454void ip_options_undo(struct ip_options *opt);
448extern void ip_forward_options(struct sk_buff *skb); 455void ip_forward_options(struct sk_buff *skb);
449extern int ip_options_rcv_srr(struct sk_buff *skb); 456int ip_options_rcv_srr(struct sk_buff *skb);
450 457
451/* 458/*
452 * Functions provided by ip_sockglue.c 459 * Functions provided by ip_sockglue.c
453 */ 460 */
454 461
455extern void ipv4_pktinfo_prepare(struct sk_buff *skb); 462void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb);
456extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); 463void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb);
457extern int ip_cmsg_send(struct net *net, 464int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc);
458 struct msghdr *msg, struct ipcm_cookie *ipc); 465int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
459extern int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); 466 unsigned int optlen);
460extern int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); 467int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
461extern int compat_ip_setsockopt(struct sock *sk, int level, 468 int __user *optlen);
462 int optname, char __user *optval, unsigned int optlen); 469int compat_ip_setsockopt(struct sock *sk, int level, int optname,
463extern int compat_ip_getsockopt(struct sock *sk, int level, 470 char __user *optval, unsigned int optlen);
464 int optname, char __user *optval, int __user *optlen); 471int compat_ip_getsockopt(struct sock *sk, int level, int optname,
465extern int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *)); 472 char __user *optval, int __user *optlen);
466 473int ip_ra_control(struct sock *sk, unsigned char on,
467extern int ip_recv_error(struct sock *sk, struct msghdr *msg, int len); 474 void (*destructor)(struct sock *));
468extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, 475
469 __be16 port, u32 info, u8 *payload); 476int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len);
470extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, 477void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,
471 u32 info); 478 u32 info, u8 *payload);
479void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
480 u32 info);
472 481
473#ifdef CONFIG_PROC_FS 482#ifdef CONFIG_PROC_FS
474extern int ip_misc_proc_init(void); 483int ip_misc_proc_init(void);
475#endif 484#endif
476 485
477#endif /* _IP_H */ 486#endif /* _IP_H */