blob: ce44e3e96d2763cf766058c88680a15215a37084 [file] [log] [blame]
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +09001#ifndef __LINUX_MROUTE6_H
2#define __LINUX_MROUTE6_H
3
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +09004
David S. Miller7c19a3d2008-08-29 14:37:23 -07005#include <linux/pim.h>
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +09006#include <linux/skbuff.h> /* for struct sk_buff_head */
Benjamin Therybd91b8b2008-12-10 16:07:08 -08007#include <net/net_namespace.h>
David Howells607ca462012-10-13 10:46:48 +01008#include <uapi/linux/mroute6.h>
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +09009
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090010#ifdef CONFIG_IPV6_MROUTE
11static inline int ip6_mroute_opt(int opt)
12{
Nicolas Dichtelbbb923a2013-01-21 06:00:25 +000013 return (opt >= MRT6_BASE) && (opt <= MRT6_MAX);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090014}
15#else
16static inline int ip6_mroute_opt(int opt)
17{
18 return 0;
19}
20#endif
21
22struct sock;
23
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090024#ifdef CONFIG_IPV6_MROUTE
David S. Millerb7058842009-09-30 16:12:20 -070025extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090026extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
27extern int ip6_mr_input(struct sk_buff *skb);
28extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
David S. Millere2d57762011-02-03 17:59:32 -080029extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
Wang Chen623d1a12008-07-03 12:13:30 +080030extern int ip6_mr_init(void);
31extern void ip6_mr_cleanup(void);
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090032#else
33static inline
34int ip6_mroute_setsockopt(struct sock *sock,
David S. Millerb7058842009-09-30 16:12:20 -070035 int optname, char __user *optval, unsigned int optlen)
YOSHIFUJI Hideakie0835f82008-07-03 16:51:22 +090036{
37 return -ENOPROTOOPT;
38}
39
40static inline
41int ip6_mroute_getsockopt(struct sock *sock,
42 int optname, char __user *optval, int __user *optlen)
43{
44 return -ENOPROTOOPT;
45}
46
47static inline
48int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
49{
50 return -ENOIOCTLCMD;
51}
52
53static inline int ip6_mr_init(void)
54{
55 return 0;
56}
57
58static inline void ip6_mr_cleanup(void)
59{
60 return;
61}
62#endif
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090063
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080064struct mif_device {
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090065 struct net_device *dev; /* Device we are using */
66 unsigned long bytes_in,bytes_out;
67 unsigned long pkt_in,pkt_out; /* Statistics */
68 unsigned long rate_limit; /* Traffic shaping (NI) */
69 unsigned char threshold; /* TTL threshold */
70 unsigned short flags; /* Control flags */
71 int link; /* Physical interface index */
72};
73
74#define VIFF_STATIC 0x8000
75
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080076struct mfc6_cache {
Patrick McHardyf30a77842010-05-11 14:40:51 +020077 struct list_head list;
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090078 struct in6_addr mf6c_mcastgrp; /* Group the entry belongs to */
79 struct in6_addr mf6c_origin; /* Source of packet */
80 mifi_t mf6c_parent; /* Source interface */
81 int mfc_flags; /* Flags on line */
82
83 union {
84 struct {
85 unsigned long expires;
86 struct sk_buff_head unresolved; /* Unresolved buffers */
87 } unres;
88 struct {
89 unsigned long last_assert;
90 int minvif;
91 int maxvif;
92 unsigned long bytes;
93 unsigned long pkt;
94 unsigned long wrong_if;
Nikolay Aleksandrov43b9e122016-07-14 19:28:27 +030095 unsigned long lastuse;
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +090096 unsigned char ttls[MAXMIFS]; /* TTL thresholds */
97 } res;
98 } mfc_un;
99};
100
101#define MFC_STATIC 1
102#define MFC_NOTIFY 2
103
104#define MFC6_LINES 64
105
106#define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \
107 (__force u32)(a)->s6_addr32[1] ^ \
108 (__force u32)(a)->s6_addr32[2] ^ \
109 (__force u32)(a)->s6_addr32[3] ^ \
110 (__force u32)(g)->s6_addr32[0] ^ \
111 (__force u32)(g)->s6_addr32[1] ^ \
112 (__force u32)(g)->s6_addr32[2] ^ \
113 (__force u32)(g)->s6_addr32[3]) % MFC6_LINES)
114
115#define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
116
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +0900117struct rtmsg;
Benjamin Thery8229efd2008-12-10 16:30:15 -0800118extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
David Ahernfd61c6b2017-01-17 15:51:07 -0800119 struct rtmsg *rtm, u32 portid);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +0900120
121#ifdef CONFIG_IPV6_MROUTE
Patrick McHardyd1db2752010-05-11 14:40:55 +0200122extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb);
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +0900123extern int ip6mr_sk_done(struct sock *sk);
124#else
Patrick McHardyd1db2752010-05-11 14:40:55 +0200125static inline struct sock *mroute6_socket(struct net *net, struct sk_buff *skb)
126{
127 return NULL;
128}
129static inline int ip6mr_sk_done(struct sock *sk)
130{
131 return 0;
132}
YOSHIFUJI Hideaki7bc570c2008-04-03 09:22:53 +0900133#endif
134#endif