Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_MROUTE_H |
| 2 | #define __LINUX_MROUTE_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/in.h> |
David S. Miller | 7c19a3d | 2008-08-29 14:37:23 -0700 | [diff] [blame] | 5 | #include <linux/pim.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | #include <net/sock.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 7 | #include <uapi/linux/mroute.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Pavel Emelyanov | 6a9fb94 | 2007-11-05 21:32:31 -0800 | [diff] [blame] | 9 | #ifdef CONFIG_IP_MROUTE |
| 10 | static inline int ip_mroute_opt(int opt) |
| 11 | { |
Nicolas Dichtel | bbb923a | 2013-01-21 06:00:25 +0000 | [diff] [blame] | 12 | return (opt >= MRT_BASE) && (opt <= MRT_MAX); |
Pavel Emelyanov | 6a9fb94 | 2007-11-05 21:32:31 -0800 | [diff] [blame] | 13 | } |
| 14 | #else |
| 15 | static inline int ip_mroute_opt(int opt) |
| 16 | { |
| 17 | return 0; |
| 18 | } |
| 19 | #endif |
| 20 | |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 21 | #ifdef CONFIG_IP_MROUTE |
David S. Miller | b705884 | 2009-09-30 16:12:20 -0700 | [diff] [blame] | 22 | extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); |
| 24 | extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); |
Eric W. Biederman | 709b46e | 2011-01-29 16:15:56 +0000 | [diff] [blame] | 25 | extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); |
Wang Chen | 03d2f89 | 2008-07-03 12:13:36 +0800 | [diff] [blame] | 26 | extern int ip_mr_init(void); |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 27 | #else |
| 28 | static inline |
| 29 | int ip_mroute_setsockopt(struct sock *sock, |
David S. Miller | b705884 | 2009-09-30 16:12:20 -0700 | [diff] [blame] | 30 | int optname, char __user *optval, unsigned int optlen) |
YOSHIFUJI Hideaki | e0835f8 | 2008-07-03 16:51:22 +0900 | [diff] [blame] | 31 | { |
| 32 | return -ENOPROTOOPT; |
| 33 | } |
| 34 | |
| 35 | static inline |
| 36 | int ip_mroute_getsockopt(struct sock *sock, |
| 37 | int optname, char __user *optval, int __user *optlen) |
| 38 | { |
| 39 | return -ENOPROTOOPT; |
| 40 | } |
| 41 | |
| 42 | static inline |
| 43 | int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) |
| 44 | { |
| 45 | return -ENOIOCTLCMD; |
| 46 | } |
| 47 | |
| 48 | static inline int ip_mr_init(void) |
| 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 54 | struct vif_device { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | struct net_device *dev; /* Device we are using */ |
| 56 | unsigned long bytes_in,bytes_out; |
| 57 | unsigned long pkt_in,pkt_out; /* Statistics */ |
| 58 | unsigned long rate_limit; /* Traffic shaping (NI) */ |
| 59 | unsigned char threshold; /* TTL threshold */ |
| 60 | unsigned short flags; /* Control flags */ |
Al Viro | 114c784 | 2006-09-27 18:39:29 -0700 | [diff] [blame] | 61 | __be32 local,remote; /* Addresses(remote for tunnels)*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | int link; /* Physical interface index */ |
| 63 | }; |
| 64 | |
| 65 | #define VIFF_STATIC 0x8000 |
| 66 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 67 | struct mfc_cache { |
Patrick McHardy | 862465f | 2010-04-13 05:03:21 +0000 | [diff] [blame] | 68 | struct list_head list; |
Al Viro | 114c784 | 2006-09-27 18:39:29 -0700 | [diff] [blame] | 69 | __be32 mfc_mcastgrp; /* Group the entry belongs to */ |
| 70 | __be32 mfc_origin; /* Source of packet */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | vifi_t mfc_parent; /* Source interface */ |
| 72 | int mfc_flags; /* Flags on line */ |
| 73 | |
| 74 | union { |
| 75 | struct { |
| 76 | unsigned long expires; |
| 77 | struct sk_buff_head unresolved; /* Unresolved buffers */ |
| 78 | } unres; |
| 79 | struct { |
| 80 | unsigned long last_assert; |
| 81 | int minvif; |
| 82 | int maxvif; |
| 83 | unsigned long bytes; |
| 84 | unsigned long pkt; |
| 85 | unsigned long wrong_if; |
| 86 | unsigned char ttls[MAXVIFS]; /* TTL thresholds */ |
| 87 | } res; |
| 88 | } mfc_un; |
Eric Dumazet | a8c9486 | 2010-10-01 16:15:08 +0000 | [diff] [blame] | 89 | struct rcu_head rcu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | #define MFC_STATIC 1 |
| 93 | #define MFC_NOTIFY 2 |
| 94 | |
| 95 | #define MFC_LINES 64 |
| 96 | |
| 97 | #ifdef __BIG_ENDIAN |
Al Viro | 114c784 | 2006-09-27 18:39:29 -0700 | [diff] [blame] | 98 | #define MFC_HASH(a,b) (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | #else |
Al Viro | 114c784 | 2006-09-27 18:39:29 -0700 | [diff] [blame] | 100 | #define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | #endif |
| 102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | struct rtmsg; |
Benjamin Thery | 4feb88e | 2009-01-22 04:56:23 +0000 | [diff] [blame] | 104 | extern int ipmr_get_route(struct net *net, struct sk_buff *skb, |
David S. Miller | 9a1b949 | 2011-05-04 12:18:54 -0700 | [diff] [blame] | 105 | __be32 saddr, __be32 daddr, |
Benjamin Thery | 4feb88e | 2009-01-22 04:56:23 +0000 | [diff] [blame] | 106 | struct rtmsg *rtm, int nowait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | #endif |