diff options
Diffstat (limited to 'include/net/ip.h')
-rw-r--r-- | include/net/ip.h | 189 |
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; | |||
86 | struct rtable; | 90 | struct rtable; |
87 | struct sockaddr; | 91 | struct sockaddr; |
88 | 92 | ||
89 | extern int igmp_mc_proc_init(void); | 93 | int 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 | ||
95 | extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, | 99 | int 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); |
98 | extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, | 102 | int 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); |
100 | extern int ip_local_deliver(struct sk_buff *skb); | 104 | int ip_local_deliver(struct sk_buff *skb); |
101 | extern int ip_mr_input(struct sk_buff *skb); | 105 | int ip_mr_input(struct sk_buff *skb); |
102 | extern int ip_output(struct sk_buff *skb); | 106 | int ip_output(struct sk_buff *skb); |
103 | extern int ip_mc_output(struct sk_buff *skb); | 107 | int ip_mc_output(struct sk_buff *skb); |
104 | extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); | 108 | int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); |
105 | extern int ip_do_nat(struct sk_buff *skb); | 109 | int ip_do_nat(struct sk_buff *skb); |
106 | extern void ip_send_check(struct iphdr *ip); | 110 | void ip_send_check(struct iphdr *ip); |
107 | extern int __ip_local_out(struct sk_buff *skb); | 111 | int __ip_local_out(struct sk_buff *skb); |
108 | extern int ip_local_out(struct sk_buff *skb); | 112 | int ip_local_out(struct sk_buff *skb); |
109 | extern int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl); | 113 | int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl); |
110 | extern void ip_init(void); | 114 | void ip_init(void); |
111 | extern int ip_append_data(struct sock *sk, struct flowi4 *fl4, | 115 | int 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); |
118 | extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb); | 122 | int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, |
119 | extern 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); | 124 | ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, |
121 | extern struct sk_buff *__ip_make_skb(struct sock *sk, | 125 | int offset, size_t size, int flags); |
122 | struct flowi4 *fl4, | 126 | struct 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); |
125 | extern int ip_send_skb(struct net *net, struct sk_buff *skb); | 129 | int ip_send_skb(struct net *net, struct sk_buff *skb); |
126 | extern int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4); | 130 | int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4); |
127 | extern void ip_flush_pending_frames(struct sock *sk); | 131 | void ip_flush_pending_frames(struct sock *sk); |
128 | extern struct sk_buff *ip_make_skb(struct sock *sk, | 132 | struct 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 | ||
137 | static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4) | 139 | static 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 | ||
144 | static 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 | |||
149 | static 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 */ |
143 | extern int ip4_datagram_connect(struct sock *sk, | 155 | int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len); |
144 | struct sockaddr *uaddr, int addr_len); | ||
145 | 156 | ||
146 | extern void ip4_datagram_release_cb(struct sock *sk); | 157 | void ip4_datagram_release_cb(struct sock *sk); |
147 | 158 | ||
148 | struct ip_reply_arg { | 159 | struct 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 | ||
187 | extern unsigned long snmp_fold_field(void __percpu *mib[], int offt); | 198 | unsigned long snmp_fold_field(void __percpu *mib[], int offt); |
188 | #if BITS_PER_LONG==32 | 199 | #if BITS_PER_LONG==32 |
189 | extern u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t sync_off); | 200 | u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t sync_off); |
190 | #else | 201 | #else |
191 | static inline u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_off) | 202 | static 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 |
196 | extern int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align); | 207 | int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align); |
197 | 208 | ||
198 | static inline void snmp_mib_free(void __percpu *ptr[SNMP_ARRAY_SZ]) | 209 | static 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 | ||
209 | extern struct local_ports { | 220 | void inet_get_local_port_range(struct net *net, int *low, int *high); |
210 | seqlock_t lock; | ||
211 | int range[2]; | ||
212 | } sysctl_local_ports; | ||
213 | extern void inet_get_local_port_range(int *low, int *high); | ||
214 | 221 | ||
215 | extern unsigned long *sysctl_local_reserved_ports; | 222 | extern unsigned long *sysctl_local_reserved_ports; |
216 | static inline int inet_is_reserved_local_port(int port) | 223 | static 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 */ |
232 | extern int sysctl_ip_dynaddr; | 239 | extern int sysctl_ip_dynaddr; |
233 | 240 | ||
234 | extern void ipfrag_init(void); | 241 | void ipfrag_init(void); |
235 | 242 | ||
236 | extern void ip_static_sysctl_init(void); | 243 | void ip_static_sysctl_init(void); |
237 | 244 | ||
238 | static inline bool ip_is_fragment(const struct iphdr *iph) | 245 | static 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 | ||
265 | extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); | 272 | void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); |
266 | 273 | ||
267 | static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk) | 274 | static 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 | ||
393 | extern bool ip_call_ra_chain(struct sk_buff *skb); | 400 | bool 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 | ||
431 | extern int ip_forward(struct sk_buff *skb); | 438 | int 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 | ||
437 | extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, | 444 | void 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); |
439 | extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); | 446 | int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); |
440 | extern void ip_options_fragment(struct sk_buff *skb); | 447 | void ip_options_fragment(struct sk_buff *skb); |
441 | extern int ip_options_compile(struct net *net, | 448 | int ip_options_compile(struct net *net, struct ip_options *opt, |
442 | struct ip_options *opt, struct sk_buff *skb); | 449 | struct sk_buff *skb); |
443 | extern int ip_options_get(struct net *net, struct ip_options_rcu **optp, | 450 | int ip_options_get(struct net *net, struct ip_options_rcu **optp, |
444 | unsigned char *data, int optlen); | 451 | unsigned char *data, int optlen); |
445 | extern int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, | 452 | int 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); |
447 | extern void ip_options_undo(struct ip_options * opt); | 454 | void ip_options_undo(struct ip_options *opt); |
448 | extern void ip_forward_options(struct sk_buff *skb); | 455 | void ip_forward_options(struct sk_buff *skb); |
449 | extern int ip_options_rcv_srr(struct sk_buff *skb); | 456 | int 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 | ||
455 | extern void ipv4_pktinfo_prepare(struct sk_buff *skb); | 462 | void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb); |
456 | extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); | 463 | void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); |
457 | extern int ip_cmsg_send(struct net *net, | 464 | int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc); |
458 | struct msghdr *msg, struct ipcm_cookie *ipc); | 465 | int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, |
459 | extern int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); | 466 | unsigned int optlen); |
460 | extern int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); | 467 | int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, |
461 | extern int compat_ip_setsockopt(struct sock *sk, int level, | 468 | int __user *optlen); |
462 | int optname, char __user *optval, unsigned int optlen); | 469 | int compat_ip_setsockopt(struct sock *sk, int level, int optname, |
463 | extern 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); | 471 | int compat_ip_getsockopt(struct sock *sk, int level, int optname, |
465 | extern int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *)); | 472 | char __user *optval, int __user *optlen); |
466 | 473 | int ip_ra_control(struct sock *sk, unsigned char on, | |
467 | extern int ip_recv_error(struct sock *sk, struct msghdr *msg, int len); | 474 | void (*destructor)(struct sock *)); |
468 | extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, | 475 | |
469 | __be16 port, u32 info, u8 *payload); | 476 | int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len); |
470 | extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, | 477 | void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port, |
471 | u32 info); | 478 | u32 info, u8 *payload); |
479 | void 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 |
474 | extern int ip_misc_proc_init(void); | 483 | int ip_misc_proc_init(void); |
475 | #endif | 484 | #endif |
476 | 485 | ||
477 | #endif /* _IP_H */ | 486 | #endif /* _IP_H */ |