aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ipv6.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ipv6.h')
-rw-r--r--include/linux/ipv6.h52
1 files changed, 49 insertions, 3 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 6fcd6a0ade24..98fa32316e40 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -308,6 +308,41 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to,
308 308
309#define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only) 309#define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only)
310#define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk)) 310#define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk))
311
312#include <linux/tcp.h>
313
314struct tcp6_timewait_sock {
315 struct tcp_timewait_sock tw_v6_sk;
316 struct in6_addr tw_v6_daddr;
317 struct in6_addr tw_v6_rcv_saddr;
318};
319
320static inline struct tcp6_timewait_sock *tcp6_twsk(const struct sock *sk)
321{
322 return (struct tcp6_timewait_sock *)sk;
323}
324
325static inline struct in6_addr *__tcp_v6_rcv_saddr(const struct sock *sk)
326{
327 return likely(sk->sk_state != TCP_TIME_WAIT) ?
328 &inet6_sk(sk)->rcv_saddr : &tcp6_twsk(sk)->tw_v6_rcv_saddr;
329}
330
331static inline struct in6_addr *tcp_v6_rcv_saddr(const struct sock *sk)
332{
333 return sk->sk_family == AF_INET6 ? __tcp_v6_rcv_saddr(sk) : NULL;
334}
335
336static inline int tcp_twsk_ipv6only(const struct sock *sk)
337{
338 return inet_twsk(sk)->tw_ipv6only;
339}
340
341static inline int tcp_v6_ipv6only(const struct sock *sk)
342{
343 return likely(sk->sk_state != TCP_TIME_WAIT) ?
344 ipv6_only_sock(sk) : tcp_twsk_ipv6only(sk);
345}
311#else 346#else
312#define __ipv6_only_sock(sk) 0 347#define __ipv6_only_sock(sk) 0
313#define ipv6_only_sock(sk) 0 348#define ipv6_only_sock(sk) 0
@@ -322,8 +357,19 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
322 return NULL; 357 return NULL;
323} 358}
324 359
325#endif 360#define __tcp_v6_rcv_saddr(__sk) NULL
361#define tcp_v6_rcv_saddr(__sk) NULL
362#define tcp_twsk_ipv6only(__sk) 0
363#define tcp_v6_ipv6only(__sk) 0
364#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
326 365
327#endif 366#define INET6_MATCH(__sk, __saddr, __daddr, __ports, __dif) \
367 (((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \
368 ((__sk)->sk_family == AF_INET6) && \
369 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \
370 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \
371 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
328 372
329#endif 373#endif /* __KERNEL__ */
374
375#endif /* _IPV6_H */