1 #ifndef __LINUX_MROUTE_H
2 #define __LINUX_MROUTE_H
4 #include <linux/sockios.h>
9 * Based on the MROUTING 3.5 defines primarily to keep
10 * source compatibility with BSD.
12 * See the mrouted code for the original history.
14 * Protocol Independent Multicast (PIM) data structures included
15 * Carlos Picoto (cap@di.fc.ul.pt)
20 #define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */
21 #define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */
22 #define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */
23 #define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */
24 #define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */
25 #define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
26 #define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
27 #define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
28 #define MRT_PIM (MRT_BASE+8) /* enable PIM code */
30 #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
31 #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
32 #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
35 typedef unsigned long vifbitmap_t; /* User mode code depends on this lot */
36 typedef unsigned short vifi_t;
37 #define ALL_VIFS ((vifi_t)(-1))
43 #define VIFM_SET(n,m) ((m)|=(1<<(n)))
44 #define VIFM_CLR(n,m) ((m)&=~(1<<(n)))
45 #define VIFM_ISSET(n,m) ((m)&(1<<(n)))
46 #define VIFM_CLRALL(m) ((m)=0)
47 #define VIFM_COPY(mfrom,mto) ((mto)=(mfrom))
48 #define VIFM_SAME(m1,m2) ((m1)==(m2))
51 * Passed by mrouted for an MRT_ADD_VIF - again we use the
52 * mrouted 3.6 structures for compatibility
56 vifi_t vifc_vifi; /* Index of VIF */
57 unsigned char vifc_flags; /* VIFF_ flags */
58 unsigned char vifc_threshold; /* ttl limit */
59 unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
60 struct in_addr vifc_lcl_addr; /* Our address */
61 struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
64 #define VIFF_TUNNEL 0x1 /* IPIP tunnel */
65 #define VIFF_SRCRT 0x2 /* NI */
66 #define VIFF_REGISTER 0x4 /* register vif */
69 * Cache manipulation structures for mrouted and PIMd
74 struct in_addr mfcc_origin; /* Origin of mcast */
75 struct in_addr mfcc_mcastgrp; /* Group in question */
76 vifi_t mfcc_parent; /* Where it arrived */
77 unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
78 unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
79 unsigned int mfcc_byte_cnt;
80 unsigned int mfcc_wrong_if;
85 * Group count retrieval for mrouted
93 unsigned long bytecnt;
94 unsigned long wrong_if;
98 * To get vif packet counts
103 vifi_t vifi; /* Which iface */
104 unsigned long icount; /* In packets */
105 unsigned long ocount; /* Out packets */
106 unsigned long ibytes; /* In bytes */
107 unsigned long obytes; /* Out bytes */
111 * This is the format the mroute daemon expects to see IGMP control
112 * data. Magically happens to be like an IP packet as per the original
117 __u32 unused1,unused2;
118 unsigned char im_msgtype; /* What is this */
119 unsigned char im_mbz; /* Must be zero */
120 unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */
121 unsigned char unused3;
122 struct in_addr im_src,im_dst;
126 * That's all usermode folks
130 #include <net/sock.h>
132 #ifdef CONFIG_IP_MROUTE
133 static inline int ip_mroute_opt(int opt)
135 return (opt >= MRT_BASE) && (opt <= MRT_BASE + 10);
138 static inline int ip_mroute_opt(int opt)
144 extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int);
145 extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
146 extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
147 extern void ip_mr_init(void);
152 struct net_device *dev; /* Device we are using */
153 unsigned long bytes_in,bytes_out;
154 unsigned long pkt_in,pkt_out; /* Statistics */
155 unsigned long rate_limit; /* Traffic shaping (NI) */
156 unsigned char threshold; /* TTL threshold */
157 unsigned short flags; /* Control flags */
158 __be32 local,remote; /* Addresses(remote for tunnels)*/
159 int link; /* Physical interface index */
162 #define VIFF_STATIC 0x8000
166 struct mfc_cache *next; /* Next entry on cache line */
167 __be32 mfc_mcastgrp; /* Group the entry belongs to */
168 __be32 mfc_origin; /* Source of packet */
169 vifi_t mfc_parent; /* Source interface */
170 int mfc_flags; /* Flags on line */
174 unsigned long expires;
175 struct sk_buff_head unresolved; /* Unresolved buffers */
178 unsigned long last_assert;
183 unsigned long wrong_if;
184 unsigned char ttls[MAXVIFS]; /* TTL thresholds */
195 #define MFC_HASH(a,b) (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
197 #define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
203 #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
206 * Pseudo messages used by mrouted
209 #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
210 #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
211 #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
215 extern int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait);