Blame view

include/linux/mroute6.h 7.14 KB
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  #ifndef __LINUX_MROUTE6_H
  #define __LINUX_MROUTE6_H
  
  #include <linux/types.h>
  #include <linux/sockios.h>
  
  /*
   *	Based on the MROUTING 3.5 defines primarily to keep
   *	source compatibility with BSD.
   *
   *	See the pim6sd code for the original history.
   *
   *      Protocol Independent Multicast (PIM) data structures included
   *      Carlos Picoto (cap@di.fc.ul.pt)
   *
   */
  
  #define MRT6_BASE	200
  #define MRT6_INIT	(MRT6_BASE)	/* Activate the kernel mroute code 	*/
  #define MRT6_DONE	(MRT6_BASE+1)	/* Shutdown the kernel mroute		*/
  #define MRT6_ADD_MIF	(MRT6_BASE+2)	/* Add a virtual interface		*/
  #define MRT6_DEL_MIF	(MRT6_BASE+3)	/* Delete a virtual interface		*/
  #define MRT6_ADD_MFC	(MRT6_BASE+4)	/* Add a multicast forwarding entry	*/
  #define MRT6_DEL_MFC	(MRT6_BASE+5)	/* Delete a multicast forwarding entry	*/
  #define MRT6_VERSION	(MRT6_BASE+6)	/* Get the kernel multicast version	*/
14fb64e1f   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
26
  #define MRT6_ASSERT	(MRT6_BASE+7)	/* Activate PIM assert mode		*/
d1db275dd   Patrick McHardy   ipv6: ip6mr: supp...
27
28
  #define MRT6_PIM	(MRT6_BASE+8)	/* enable PIM code			*/
  #define MRT6_TABLE	(MRT6_BASE+9)	/* Specify mroute table ID		*/
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  
  #define SIOCGETMIFCNT_IN6	SIOCPROTOPRIVATE	/* IP protocol privates */
  #define SIOCGETSGCNT_IN6	(SIOCPROTOPRIVATE+1)
  #define SIOCGETRPF	(SIOCPROTOPRIVATE+2)
  
  #define MAXMIFS		32
  typedef unsigned long mifbitmap_t;	/* User mode code depends on this lot */
  typedef unsigned short mifi_t;
  #define ALL_MIFS	((mifi_t)(-1))
  
  #ifndef IF_SETSIZE
  #define IF_SETSIZE	256
  #endif
  
  typedef	__u32		if_mask;
  #define NIFBITS (sizeof(if_mask) * 8)        /* bits per mask */
  
  #if !defined(__KERNEL__) && !defined(DIV_ROUND_UP)
  #define	DIV_ROUND_UP(x,y)	(((x) + ((y) - 1)) / (y))
  #endif
  
  typedef struct if_set {
  	if_mask ifs_bits[DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
  } if_set;
  
  #define IF_SET(n, p)    ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
  #define IF_CLR(n, p)    ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
  #define IF_ISSET(n, p)  ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
  #define IF_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
  #define IF_ZERO(p)      bzero(p, sizeof(*(p)))
  
  /*
   *	Passed by mrouted for an MRT_ADD_MIF - again we use the
   *	mrouted 3.6 structures for compatibility
   */
  
  struct mif6ctl {
  	mifi_t	mif6c_mifi;		/* Index of MIF */
  	unsigned char mif6c_flags;	/* MIFF_ flags */
  	unsigned char vifc_threshold;	/* ttl limit */
85efde6f4   Arnd Bergmann   make exported hea...
69
  	__u16	 mif6c_pifi;		/* the index of the physical IF */
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
70
71
72
73
74
75
76
77
  	unsigned int vifc_rate_limit;	/* Rate limiter values (NI) */
  };
  
  #define MIFF_REGISTER	0x1	/* register vif	*/
  
  /*
   *	Cache manipulation structures for mrouted and PIMd
   */
d94d9fee9   Eric Dumazet   net: cleanup incl...
78
  struct mf6cctl {
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
79
80
81
82
83
84
85
86
87
  	struct sockaddr_in6 mf6cc_origin;		/* Origin of mcast	*/
  	struct sockaddr_in6 mf6cc_mcastgrp;		/* Group in question	*/
  	mifi_t	mf6cc_parent;			/* Where it arrived	*/
  	struct if_set mf6cc_ifset;		/* Where it is going */
  };
  
  /*
   *	Group count retrieval for pim6sd
   */
d94d9fee9   Eric Dumazet   net: cleanup incl...
88
  struct sioc_sg_req6 {
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
89
90
91
92
93
94
95
96
97
98
  	struct sockaddr_in6 src;
  	struct sockaddr_in6 grp;
  	unsigned long pktcnt;
  	unsigned long bytecnt;
  	unsigned long wrong_if;
  };
  
  /*
   *	To get vif packet counts
   */
d94d9fee9   Eric Dumazet   net: cleanup incl...
99
  struct sioc_mif_req6 {
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
100
101
102
103
104
105
106
107
108
109
110
111
  	mifi_t	mifi;		/* Which iface */
  	unsigned long icount;	/* In packets */
  	unsigned long ocount;	/* Out packets */
  	unsigned long ibytes;	/* In bytes */
  	unsigned long obytes;	/* Out bytes */
  };
  
  /*
   *	That's all usermode folks
   */
  
  #ifdef __KERNEL__
7c19a3d28   David S. Miller   net: Unbreak user...
112
  #include <linux/pim.h>
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
113
  #include <linux/skbuff.h>	/* for struct sk_buff_head */
bd91b8bf3   Benjamin Thery   netns: ip6mr: all...
114
  #include <net/net_namespace.h>
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
115

7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
116
117
118
119
120
121
122
123
124
125
126
127
128
  #ifdef CONFIG_IPV6_MROUTE
  static inline int ip6_mroute_opt(int opt)
  {
  	return (opt >= MRT6_BASE) && (opt <= MRT6_BASE + 10);
  }
  #else
  static inline int ip6_mroute_opt(int opt)
  {
  	return 0;
  }
  #endif
  
  struct sock;
e0835f8fa   YOSHIFUJI Hideaki   ipv4,ipv6 mroute:...
129
  #ifdef CONFIG_IPV6_MROUTE
b7058842c   David S. Miller   net: Make setsock...
130
  extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
131
132
133
  extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
  extern int ip6_mr_input(struct sk_buff *skb);
  extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
e2d57766e   David S. Miller   net: Provide comp...
134
  extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
623d1a1af   Wang Chen   ipv6: Do cleanup ...
135
136
  extern int ip6_mr_init(void);
  extern void ip6_mr_cleanup(void);
e0835f8fa   YOSHIFUJI Hideaki   ipv4,ipv6 mroute:...
137
138
139
  #else
  static inline
  int ip6_mroute_setsockopt(struct sock *sock,
b7058842c   David S. Miller   net: Make setsock...
140
  			  int optname, char __user *optval, unsigned int optlen)
e0835f8fa   YOSHIFUJI Hideaki   ipv4,ipv6 mroute:...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
  {
  	return -ENOPROTOOPT;
  }
  
  static inline
  int ip6_mroute_getsockopt(struct sock *sock,
  			  int optname, char __user *optval, int __user *optlen)
  {
  	return -ENOPROTOOPT;
  }
  
  static inline
  int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
  {
  	return -ENOIOCTLCMD;
  }
  
  static inline int ip6_mr_init(void)
  {
  	return 0;
  }
  
  static inline void ip6_mr_cleanup(void)
  {
  	return;
  }
  #endif
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
168

d94d9fee9   Eric Dumazet   net: cleanup incl...
169
  struct mif_device {
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
170
171
172
173
174
175
176
177
178
179
  	struct net_device 	*dev;			/* Device we are using */
  	unsigned long	bytes_in,bytes_out;
  	unsigned long	pkt_in,pkt_out;		/* Statistics 			*/
  	unsigned long	rate_limit;		/* Traffic shaping (NI) 	*/
  	unsigned char	threshold;		/* TTL threshold 		*/
  	unsigned short	flags;			/* Control flags 		*/
  	int		link;			/* Physical interface index	*/
  };
  
  #define VIFF_STATIC 0x8000
d94d9fee9   Eric Dumazet   net: cleanup incl...
180
  struct mfc6_cache {
f30a77842   Patrick McHardy   ipv6: ip6mr: conv...
181
  	struct list_head list;
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
  	struct in6_addr mf6c_mcastgrp;			/* Group the entry belongs to 	*/
  	struct in6_addr mf6c_origin;			/* Source of packet 		*/
  	mifi_t mf6c_parent;			/* Source interface		*/
  	int mfc_flags;				/* Flags on line		*/
  
  	union {
  		struct {
  			unsigned long expires;
  			struct sk_buff_head unresolved;	/* Unresolved buffers		*/
  		} unres;
  		struct {
  			unsigned long last_assert;
  			int minvif;
  			int maxvif;
  			unsigned long bytes;
  			unsigned long pkt;
  			unsigned long wrong_if;
  			unsigned char ttls[MAXMIFS];	/* TTL thresholds		*/
  		} res;
  	} mfc_un;
  };
  
  #define MFC_STATIC		1
  #define MFC_NOTIFY		2
  
  #define MFC6_LINES		64
  
  #define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \
  			  (__force u32)(a)->s6_addr32[1] ^ \
  			  (__force u32)(a)->s6_addr32[2] ^ \
  			  (__force u32)(a)->s6_addr32[3] ^ \
  			  (__force u32)(g)->s6_addr32[0] ^ \
  			  (__force u32)(g)->s6_addr32[1] ^ \
  			  (__force u32)(g)->s6_addr32[2] ^ \
  			  (__force u32)(g)->s6_addr32[3]) % MFC6_LINES)
  
  #define MFC_ASSERT_THRESH (3*HZ)		/* Maximal freq. of asserts */
  
  #endif
  
  #ifdef __KERNEL__
  struct rtmsg;
8229efdae   Benjamin Thery   netns: ip6mr: ena...
224
225
  extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
  			   struct rtmsg *rtm, int nowait);
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
226
227
  
  #ifdef CONFIG_IPV6_MROUTE
d1db275dd   Patrick McHardy   ipv6: ip6mr: supp...
228
  extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb);
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
229
230
  extern int ip6mr_sk_done(struct sock *sk);
  #else
d1db275dd   Patrick McHardy   ipv6: ip6mr: supp...
231
232
233
234
235
236
237
238
  static inline struct sock *mroute6_socket(struct net *net, struct sk_buff *skb)
  {
  	return NULL;
  }
  static inline int ip6mr_sk_done(struct sock *sk)
  {
  	return 0;
  }
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
239
240
241
242
243
244
245
  #endif
  #endif
  
  /*
   * Structure used to communicate from kernel to multicast router.
   * We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{}
   * used for IPv4 implementation). This is because this structure will be passed via an
25985edce   Lucas De Marchi   Fix common misspe...
246
   * IPv6 raw socket, on which an application will only receiver the payload i.e the data after
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
247
248
249
250
251
   * the IPv6 header and all the extension headers. (See section 3 of RFC 3542)
   */
  
  struct mrt6msg {
  #define MRT6MSG_NOCACHE		1
14fb64e1f   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
252
253
  #define MRT6MSG_WRONGMIF	2
  #define MRT6MSG_WHOLEPKT	3		/* used for use level encap */
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
254
255
256
257
258
259
260
261
  	__u8		im6_mbz;		/* must be zero		   */
  	__u8		im6_msgtype;		/* what type of message    */
  	__u16		im6_mif;		/* mif rec'd on		   */
  	__u32		im6_pad;		/* padding for 64 bit arch */
  	struct in6_addr	im6_src, im6_dst;
  };
  
  #endif