Blame view

include/linux/mroute.h 6.51 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
  #ifndef __LINUX_MROUTE_H
  #define __LINUX_MROUTE_H
  
  #include <linux/sockios.h>
80a9492a3   YOSHIFUJI Hideaki   [IPV4] MROUTE: Ad...
5
6
  #include <linux/types.h>
  #ifdef __KERNEL__
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
  #include <linux/in.h>
80a9492a3   YOSHIFUJI Hideaki   [IPV4] MROUTE: Ad...
8
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  
  /*
   *	Based on the MROUTING 3.5 defines primarily to keep
   *	source compatibility with BSD.
   *
   *	See the mrouted code for the original history.
   *
   *      Protocol Independent Multicast (PIM) data structures included
   *      Carlos Picoto (cap@di.fc.ul.pt)
   *
   */
  
  #define MRT_BASE	200
  #define MRT_INIT	(MRT_BASE)	/* Activate the kernel mroute code 	*/
  #define MRT_DONE	(MRT_BASE+1)	/* Shutdown the kernel mroute		*/
  #define MRT_ADD_VIF	(MRT_BASE+2)	/* Add a virtual interface		*/
  #define MRT_DEL_VIF	(MRT_BASE+3)	/* Delete a virtual interface		*/
  #define MRT_ADD_MFC	(MRT_BASE+4)	/* Add a multicast forwarding entry	*/
  #define MRT_DEL_MFC	(MRT_BASE+5)	/* Delete a multicast forwarding entry	*/
  #define MRT_VERSION	(MRT_BASE+6)	/* Get the kernel multicast version	*/
  #define MRT_ASSERT	(MRT_BASE+7)	/* Activate PIM assert mode		*/
f0ad0860d   Patrick McHardy   ipv4: ipmr: suppo...
30
31
  #define MRT_PIM		(MRT_BASE+8)	/* enable PIM code			*/
  #define MRT_TABLE	(MRT_BASE+9)	/* Specify mroute table ID		*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
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
  
  #define SIOCGETVIFCNT	SIOCPROTOPRIVATE	/* IP protocol privates */
  #define SIOCGETSGCNT	(SIOCPROTOPRIVATE+1)
  #define SIOCGETRPF	(SIOCPROTOPRIVATE+2)
  
  #define MAXVIFS		32	
  typedef unsigned long vifbitmap_t;	/* User mode code depends on this lot */
  typedef unsigned short vifi_t;
  #define ALL_VIFS	((vifi_t)(-1))
  
  /*
   *	Same idea as select
   */
   
  #define VIFM_SET(n,m)	((m)|=(1<<(n)))
  #define VIFM_CLR(n,m)	((m)&=~(1<<(n)))
  #define VIFM_ISSET(n,m)	((m)&(1<<(n)))
  #define VIFM_CLRALL(m)	((m)=0)
  #define VIFM_COPY(mfrom,mto)	((mto)=(mfrom))
  #define VIFM_SAME(m1,m2)	((m1)==(m2))
  
  /*
   *	Passed by mrouted for an MRT_ADD_VIF - again we use the
   *	mrouted 3.6 structures for compatibility
   */
   
  struct vifctl {
  	vifi_t	vifc_vifi;		/* Index of VIF */
  	unsigned char vifc_flags;	/* VIFF_ flags */
  	unsigned char vifc_threshold;	/* ttl limit */
  	unsigned int vifc_rate_limit;	/* Rate limiter values (NI) */
ee5e81f00   Ilia K   add vif using loc...
63
64
65
66
  	union {
  		struct in_addr vifc_lcl_addr;     /* Local interface address */
  		int            vifc_lcl_ifindex;  /* Local interface index   */
  	};
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
68
  	struct in_addr vifc_rmt_addr;	/* IPIP tunnel addr */
  };
ee5e81f00   Ilia K   add vif using loc...
69
70
71
72
73
  #define VIFF_TUNNEL		0x1	/* IPIP tunnel */
  #define VIFF_SRCRT		0x2	/* NI */
  #define VIFF_REGISTER		0x4	/* register vif	*/
  #define VIFF_USE_IFINDEX	0x8	/* use vifc_lcl_ifindex instead of
  					   vifc_lcl_addr to find an interface */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74
75
76
77
78
  
  /*
   *	Cache manipulation structures for mrouted and PIMd
   */
   
d94d9fee9   Eric Dumazet   net: cleanup incl...
79
  struct mfcctl {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  	struct in_addr mfcc_origin;		/* Origin of mcast	*/
  	struct in_addr mfcc_mcastgrp;		/* Group in question	*/
  	vifi_t	mfcc_parent;			/* Where it arrived	*/
  	unsigned char mfcc_ttls[MAXVIFS];	/* Where it is going	*/
  	unsigned int mfcc_pkt_cnt;		/* pkt count for src-grp */
  	unsigned int mfcc_byte_cnt;
  	unsigned int mfcc_wrong_if;
  	int	     mfcc_expire;
  };
  
  /* 
   *	Group count retrieval for mrouted
   */
   
d94d9fee9   Eric Dumazet   net: cleanup incl...
94
  struct sioc_sg_req {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
98
99
100
101
102
103
104
  	struct in_addr src;
  	struct in_addr grp;
  	unsigned long pktcnt;
  	unsigned long bytecnt;
  	unsigned long wrong_if;
  };
  
  /*
   *	To get vif packet counts
   */
d94d9fee9   Eric Dumazet   net: cleanup incl...
105
  struct sioc_vif_req {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
107
108
109
110
111
112
113
114
115
116
117
  	vifi_t	vifi;		/* Which iface */
  	unsigned long icount;	/* In packets */
  	unsigned long ocount;	/* Out packets */
  	unsigned long ibytes;	/* In bytes */
  	unsigned long obytes;	/* Out bytes */
  };
  
  /*
   *	This is the format the mroute daemon expects to see IGMP control
   *	data. Magically happens to be like an IP packet as per the original
   */
   
d94d9fee9   Eric Dumazet   net: cleanup incl...
118
  struct igmpmsg {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
120
121
122
123
124
125
126
127
128
129
130
131
  	__u32 unused1,unused2;
  	unsigned char im_msgtype;		/* What is this */
  	unsigned char im_mbz;			/* Must be zero */
  	unsigned char im_vif;			/* Interface (this ought to be a vifi_t!) */
  	unsigned char unused3;
  	struct in_addr im_src,im_dst;
  };
  
  /*
   *	That's all usermode folks
   */
  
  #ifdef __KERNEL__
7c19a3d28   David S. Miller   net: Unbreak user...
132
  #include <linux/pim.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
133
  #include <net/sock.h>
6a9fb9479   Pavel Emelyanov   [IPV4]: Clean the...
134
135
136
137
138
139
140
141
142
143
144
  #ifdef CONFIG_IP_MROUTE
  static inline int ip_mroute_opt(int opt)
  {
  	return (opt >= MRT_BASE) && (opt <= MRT_BASE + 10);
  }
  #else
  static inline int ip_mroute_opt(int opt)
  {
  	return 0;
  }
  #endif
e0835f8fa   YOSHIFUJI Hideaki   ipv4,ipv6 mroute:...
145
  #ifdef CONFIG_IP_MROUTE
b7058842c   David S. Miller   net: Make setsock...
146
  extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147
148
  extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
  extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
709b46e8d   Eric W. Biederman   net: Add compat i...
149
  extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
03d2f897e   Wang Chen   ipv4: Do cleanup ...
150
  extern int ip_mr_init(void);
e0835f8fa   YOSHIFUJI Hideaki   ipv4,ipv6 mroute:...
151
152
153
  #else
  static inline
  int ip_mroute_setsockopt(struct sock *sock,
b7058842c   David S. Miller   net: Make setsock...
154
  			 int optname, char __user *optval, unsigned int optlen)
e0835f8fa   YOSHIFUJI Hideaki   ipv4,ipv6 mroute:...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  {
  	return -ENOPROTOOPT;
  }
  
  static inline
  int ip_mroute_getsockopt(struct sock *sock,
  			 int optname, char __user *optval, int __user *optlen)
  {
  	return -ENOPROTOOPT;
  }
  
  static inline
  int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
  {
  	return -ENOIOCTLCMD;
  }
  
  static inline int ip_mr_init(void)
  {
  	return 0;
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
177

d94d9fee9   Eric Dumazet   net: cleanup incl...
178
  struct vif_device {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
179
180
181
182
183
184
  	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 		*/
114c7844f   Al Viro   [IPV4]: mroute an...
185
  	__be32		local,remote;		/* Addresses(remote for tunnels)*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
186
187
188
189
  	int		link;			/* Physical interface index	*/
  };
  
  #define VIFF_STATIC 0x8000
d94d9fee9   Eric Dumazet   net: cleanup incl...
190
  struct mfc_cache {
862465f2e   Patrick McHardy   ipv4: ipmr: conve...
191
  	struct list_head list;
114c7844f   Al Viro   [IPV4]: mroute an...
192
193
  	__be32 mfc_mcastgrp;			/* Group the entry belongs to 	*/
  	__be32 mfc_origin;			/* Source of packet 		*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
  	vifi_t mfc_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[MAXVIFS];	/* TTL thresholds		*/
  		} res;
  	} mfc_un;
a8c9486b8   Eric Dumazet   ipmr: RCU protect...
212
  	struct rcu_head	rcu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
213
214
215
216
217
218
219
220
  };
  
  #define MFC_STATIC		1
  #define MFC_NOTIFY		2
  
  #define MFC_LINES		64
  
  #ifdef __BIG_ENDIAN
114c7844f   Al Viro   [IPV4]: mroute an...
221
  #define MFC_HASH(a,b)	(((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
222
  #else
114c7844f   Al Viro   [IPV4]: mroute an...
223
  #define MFC_HASH(a,b)	((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
  #endif		
  
  #endif
  
  
  #define MFC_ASSERT_THRESH (3*HZ)		/* Maximal freq. of asserts */
  
  /*
   *	Pseudo messages used by mrouted
   */
  
  #define IGMPMSG_NOCACHE		1		/* Kern cache fill request to mrouted */
  #define IGMPMSG_WRONGVIF	2		/* For PIM assert processing (unused) */
  #define IGMPMSG_WHOLEPKT	3		/* For PIM Register processing */
  
  #ifdef __KERNEL__
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240
  struct rtmsg;
4feb88e5c   Benjamin Thery   netns: ipmr: enab...
241
  extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
9a1b9496c   David S. Miller   ipv4: Pass explic...
242
  			  __be32 saddr, __be32 daddr,
4feb88e5c   Benjamin Thery   netns: ipmr: enab...
243
  			  struct rtmsg *rtm, int nowait);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
244
245
246
  #endif
  
  #endif