blob: 7c567a2679ceb740867f33b2a3a4003cc96d0b59 [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{
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +010012 return opt >= MRT_BASE && opt <= MRT_MAX;
Pavel Emelyanov6a9fb942007-11-05 21:32:31 -080013}
Pavel Emelyanov6a9fb942007-11-05 21:32:31 -080014
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +010015int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
16int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
17int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
18int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
19int ip_mr_init(void);
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090020#else
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +010021static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
22 char __user *optval, unsigned int optlen)
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090023{
24 return -ENOPROTOOPT;
25}
26
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +010027static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
28 char __user *optval, int __user *optlen)
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090029{
30 return -ENOPROTOOPT;
31}
32
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +010033static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090034{
35 return -ENOIOCTLCMD;
36}
37
38static inline int ip_mr_init(void)
39{
40 return 0;
41}
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +010042
43static inline int ip_mroute_opt(int opt)
44{
45 return 0;
46}
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090047#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080049struct vif_device {
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 struct net_device *dev; /* Device we are using */
51 unsigned long bytes_in,bytes_out;
52 unsigned long pkt_in,pkt_out; /* Statistics */
53 unsigned long rate_limit; /* Traffic shaping (NI) */
54 unsigned char threshold; /* TTL threshold */
55 unsigned short flags; /* Control flags */
Al Viro114c7842006-09-27 18:39:29 -070056 __be32 local,remote; /* Addresses(remote for tunnels)*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 int link; /* Physical interface index */
58};
59
60#define VIFF_STATIC 0x8000
61
Nikolay Aleksandrov06bd6c02015-11-26 15:23:45 +010062/* mfc_flags:
63 * MFC_STATIC - the entry was added statically (not by a routing daemon)
64 */
65enum {
66 MFC_STATIC = BIT(0),
67};
68
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080069struct mfc_cache {
Patrick McHardy862465f2010-04-13 05:03:21 +000070 struct list_head list;
Al Viro114c7842006-09-27 18:39:29 -070071 __be32 mfc_mcastgrp; /* Group the entry belongs to */
72 __be32 mfc_origin; /* Source of packet */
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 vifi_t mfc_parent; /* Source interface */
74 int mfc_flags; /* Flags on line */
75
76 union {
77 struct {
78 unsigned long expires;
79 struct sk_buff_head unresolved; /* Unresolved buffers */
80 } unres;
81 struct {
82 unsigned long last_assert;
83 int minvif;
84 int maxvif;
85 unsigned long bytes;
86 unsigned long pkt;
87 unsigned long wrong_if;
88 unsigned char ttls[MAXVIFS]; /* TTL thresholds */
89 } res;
90 } mfc_un;
Eric Dumazeta8c94862010-10-01 16:15:08 +000091 struct rcu_head rcu;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092};
93
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +010094#define MFC_LINES 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96#ifdef __BIG_ENDIAN
Al Viro114c7842006-09-27 18:39:29 -070097#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 -070098#else
Al Viro114c7842006-09-27 18:39:29 -070099#define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +0100100#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102struct rtmsg;
Nikolay Aleksandrov520191b2015-11-26 15:23:46 +0100103int ipmr_get_route(struct net *net, struct sk_buff *skb,
104 __be32 saddr, __be32 daddr,
105 struct rtmsg *rtm, int nowait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#endif