]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
7bc570c8 YH |
2 | #ifndef __LINUX_MROUTE6_H |
3 | #define __LINUX_MROUTE6_H | |
4 | ||
7bc570c8 | 5 | |
7c19a3d2 | 6 | #include <linux/pim.h> |
7bc570c8 | 7 | #include <linux/skbuff.h> /* for struct sk_buff_head */ |
bd91b8bf | 8 | #include <net/net_namespace.h> |
607ca46e | 9 | #include <uapi/linux/mroute6.h> |
6853f21f | 10 | #include <linux/mroute_base.h> |
7bc570c8 | 11 | |
7bc570c8 YH |
12 | #ifdef CONFIG_IPV6_MROUTE |
13 | static inline int ip6_mroute_opt(int opt) | |
14 | { | |
bbb923a4 | 15 | return (opt >= MRT6_BASE) && (opt <= MRT6_MAX); |
7bc570c8 YH |
16 | } |
17 | #else | |
18 | static inline int ip6_mroute_opt(int opt) | |
19 | { | |
20 | return 0; | |
21 | } | |
22 | #endif | |
23 | ||
24 | struct sock; | |
25 | ||
e0835f8f | 26 | #ifdef CONFIG_IPV6_MROUTE |
b7058842 | 27 | extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); |
7bc570c8 YH |
28 | extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); |
29 | extern int ip6_mr_input(struct sk_buff *skb); | |
30 | extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); | |
e2d57766 | 31 | extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); |
623d1a1a WC |
32 | extern int ip6_mr_init(void); |
33 | extern void ip6_mr_cleanup(void); | |
e0835f8f YH |
34 | #else |
35 | static inline | |
36 | int ip6_mroute_setsockopt(struct sock *sock, | |
b7058842 | 37 | int optname, char __user *optval, unsigned int optlen) |
e0835f8f YH |
38 | { |
39 | return -ENOPROTOOPT; | |
40 | } | |
41 | ||
42 | static inline | |
43 | int ip6_mroute_getsockopt(struct sock *sock, | |
44 | int optname, char __user *optval, int __user *optlen) | |
45 | { | |
46 | return -ENOPROTOOPT; | |
47 | } | |
48 | ||
49 | static inline | |
50 | int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg) | |
51 | { | |
52 | return -ENOIOCTLCMD; | |
53 | } | |
54 | ||
55 | static inline int ip6_mr_init(void) | |
56 | { | |
57 | return 0; | |
58 | } | |
59 | ||
60 | static inline void ip6_mr_cleanup(void) | |
61 | { | |
62 | return; | |
63 | } | |
64 | #endif | |
7bc570c8 | 65 | |
7bc570c8 YH |
66 | #define VIFF_STATIC 0x8000 |
67 | ||
d94d9fee | 68 | struct mfc6_cache { |
f30a7784 | 69 | struct list_head list; |
7bc570c8 YH |
70 | struct in6_addr mf6c_mcastgrp; /* Group the entry belongs to */ |
71 | struct in6_addr mf6c_origin; /* Source of packet */ | |
72 | mifi_t mf6c_parent; /* Source interface */ | |
73 | int mfc_flags; /* Flags on line */ | |
74 | ||
75 | union { | |
76 | struct { | |
77 | unsigned long expires; | |
78 | struct sk_buff_head unresolved; /* Unresolved buffers */ | |
79 | } unres; | |
80 | struct { | |
81 | unsigned long last_assert; | |
82 | int minvif; | |
83 | int maxvif; | |
84 | unsigned long bytes; | |
85 | unsigned long pkt; | |
86 | unsigned long wrong_if; | |
43b9e127 | 87 | unsigned long lastuse; |
7bc570c8 YH |
88 | unsigned char ttls[MAXMIFS]; /* TTL thresholds */ |
89 | } res; | |
90 | } mfc_un; | |
91 | }; | |
92 | ||
93 | #define MFC_STATIC 1 | |
94 | #define MFC_NOTIFY 2 | |
95 | ||
96 | #define MFC6_LINES 64 | |
97 | ||
98 | #define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \ | |
99 | (__force u32)(a)->s6_addr32[1] ^ \ | |
100 | (__force u32)(a)->s6_addr32[2] ^ \ | |
101 | (__force u32)(a)->s6_addr32[3] ^ \ | |
102 | (__force u32)(g)->s6_addr32[0] ^ \ | |
103 | (__force u32)(g)->s6_addr32[1] ^ \ | |
104 | (__force u32)(g)->s6_addr32[2] ^ \ | |
105 | (__force u32)(g)->s6_addr32[3]) % MFC6_LINES) | |
106 | ||
107 | #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */ | |
108 | ||
7bc570c8 | 109 | struct rtmsg; |
8229efda | 110 | extern int ip6mr_get_route(struct net *net, struct sk_buff *skb, |
fd61c6ba | 111 | struct rtmsg *rtm, u32 portid); |
7bc570c8 YH |
112 | |
113 | #ifdef CONFIG_IPV6_MROUTE | |
d1db275d | 114 | extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb); |
7bc570c8 YH |
115 | extern int ip6mr_sk_done(struct sock *sk); |
116 | #else | |
d1db275d PM |
117 | static inline struct sock *mroute6_socket(struct net *net, struct sk_buff *skb) |
118 | { | |
119 | return NULL; | |
120 | } | |
121 | static inline int ip6mr_sk_done(struct sock *sk) | |
122 | { | |
123 | return 0; | |
124 | } | |
7bc570c8 YH |
125 | #endif |
126 | #endif |