1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __LINUX_MROUTE_H
3#define __LINUX_MROUTE_H
4
5#include <linux/in.h>
6#include <linux/pim.h>
7#include <net/fib_rules.h>
8#include <net/fib_notifier.h>
9#include <uapi/linux/mroute.h>
10#include <linux/mroute_base.h>
11
12#ifdef CONFIG_IP_MROUTE
13static inline int ip_mroute_opt(int opt)
14{
15 return opt >= MRT_BASE && opt <= MRT_MAX;
16}
17
18int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
19int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
20int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
21int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
22int ip_mr_init(void);
23bool ipmr_rule_default(const struct fib_rule *rule);
24#else
25static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
26 char __user *optval, unsigned int optlen)
27{
28 return -ENOPROTOOPT;
29}
30
31static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
32 char __user *optval, int __user *optlen)
33{
34 return -ENOPROTOOPT;
35}
36
37static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
38{
39 return -ENOIOCTLCMD;
40}
41
42static inline int ip_mr_init(void)
43{
44 return 0;
45}
46
47static inline int ip_mroute_opt(int opt)
48{
49 return 0;
50}
51
52static inline bool ipmr_rule_default(const struct fib_rule *rule)
53{
54 return true;
55}
56#endif
57
58#define VIFF_STATIC 0x8000
59
60struct mfc_cache_cmp_arg {
61 __be32 mfc_mcastgrp;
62 __be32 mfc_origin;
63};
64
65/**
66 * struct mfc_cache - multicast routing entries
67 * @_c: Common multicast routing information; has to be first [for casting]
68 * @mfc_mcastgrp: destination multicast group address
69 * @mfc_origin: source address
70 * @cmparg: used for rhashtable comparisons
71 */
72struct mfc_cache {
73 struct mr_mfc _c;
74 union {
75 struct {
76 __be32 mfc_mcastgrp;
77 __be32 mfc_origin;
78 };
79 struct mfc_cache_cmp_arg cmparg;
80 };
81};
82
83struct rtmsg;
84int ipmr_get_route(struct net *net, struct sk_buff *skb,
85 __be32 saddr, __be32 daddr,
86 struct rtmsg *rtm, u32 portid);
87#endif
88