blob: 79aaa9fc1a15d6ed7caac2b147ae030b18da060a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_MROUTE_H
2#define __LINUX_MROUTE_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/in.h>
David S. Miller7c19a3d2008-08-29 14:37:23 -07005#include <linux/pim.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <net/sock.h>
David Howells607ca462012-10-13 10:46:48 +01007#include <uapi/linux/mroute.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Pavel Emelyanov6a9fb942007-11-05 21:32:31 -08009#ifdef CONFIG_IP_MROUTE
10static inline int ip_mroute_opt(int opt)
11{
Nicolas Dichtelbbb923a2013-01-21 06:00:25 +000012 return (opt >= MRT_BASE) && (opt <= MRT_MAX);
Pavel Emelyanov6a9fb942007-11-05 21:32:31 -080013}
14#else
15static inline int ip_mroute_opt(int opt)
16{
17 return 0;
18}
19#endif
20
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090021#ifdef CONFIG_IP_MROUTE
David S. Millerb7058842009-09-30 16:12:20 -070022extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070023extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
24extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
Eric W. Biederman709b46e2011-01-29 16:15:56 +000025extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
Wang Chen03d2f892008-07-03 12:13:36 +080026extern int ip_mr_init(void);
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090027#else
28static inline
29int ip_mroute_setsockopt(struct sock *sock,
David S. Millerb7058842009-09-30 16:12:20 -070030 int optname, char __user *optval, unsigned int optlen)
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090031{
32 return -ENOPROTOOPT;
33}
34
35static inline
36int ip_mroute_getsockopt(struct sock *sock,
37 int optname, char __user *optval, int __user *optlen)
38{
39 return -ENOPROTOOPT;
40}
41
42static inline
43int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
44{
45 return -ENOIOCTLCMD;
46}
47
48static inline int ip_mr_init(void)
49{
50 return 0;
51}
52#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080054struct vif_device {
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 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 Viro114c7842006-09-27 18:39:29 -070061 __be32 local,remote; /* Addresses(remote for tunnels)*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 int link; /* Physical interface index */
63};
64
65#define VIFF_STATIC 0x8000
66
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080067struct mfc_cache {
Patrick McHardy862465f2010-04-13 05:03:21 +000068 struct list_head list;
Al Viro114c7842006-09-27 18:39:29 -070069 __be32 mfc_mcastgrp; /* Group the entry belongs to */
70 __be32 mfc_origin; /* Source of packet */
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 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 Dumazeta8c94862010-10-01 16:15:08 +000089 struct rcu_head rcu;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090};
91
92#define MFC_STATIC 1
93#define MFC_NOTIFY 2
94
95#define MFC_LINES 64
96
97#ifdef __BIG_ENDIAN
Al Viro114c7842006-09-27 18:39:29 -070098#define MFC_HASH(a,b) (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#else
Al Viro114c7842006-09-27 18:39:29 -0700100#define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#endif
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103struct rtmsg;
Benjamin Thery4feb88e2009-01-22 04:56:23 +0000104extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
David S. Miller9a1b9492011-05-04 12:18:54 -0700105 __be32 saddr, __be32 daddr,
Benjamin Thery4feb88e2009-01-22 04:56:23 +0000106 struct rtmsg *rtm, int nowait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107#endif