1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Based on include/net/ip6_route.h
4 * No Authors, no Copyright
5 */
6 #ifndef _NET_NIP_ROUTE_H
7 #define _NET_NIP_ROUTE_H
8
9 #include <net/net_namespace.h>
10 #include "nip_fib.h"
11 #include "nip_addrconf.h"
12
13 #define NIP_RT_PRIO_USER 1024
14
15 struct nip_rt_info *nip_addrconf_dst_alloc(struct ninet_dev *idev,
16 const struct nip_addr *addr);
17
18
19 int nip_route_input(struct sk_buff *skb);
20 struct dst_entry *nip_route_input_lookup(struct net *net,
21 struct net_device *dev,
22 struct flow_nip *fln, int flags, int *tbl_type);
23
24 struct dst_entry *nip_route_output_flags(struct net *net, const struct sock *sk,
25 struct flow_nip *fln, int flags);
26
27
nip_route_output(struct net * net,const struct sock * sk,struct flow_nip * fln)28 static inline struct dst_entry *nip_route_output(struct net *net,
29 const struct sock *sk,
30 struct flow_nip *fln)
31 {
32 return nip_route_output_flags(net, sk, fln, 0);
33 }
34
35 struct nip_rt_info *nip_pol_route(struct net *net, struct nip_fib_table *table,
36 int oif, struct flow_nip *fln, int flags);
37
38 bool nip_bind_addr_check(struct net *net,
39 struct nip_addr *addr);
40
41 int nip_ins_rt(struct nip_rt_info *rt);
42 int nip_del_rt(struct nip_rt_info *rt);
43
nip_route_get_saddr(struct net * net,struct nip_rt_info * rt,const struct nip_addr * daddr,struct nip_addr * saddr)44 static inline int nip_route_get_saddr(struct net *net, struct nip_rt_info *rt,
45 const struct nip_addr *daddr,
46 struct nip_addr *saddr)
47 {
48 struct ninet_dev *idev =
49 rt ? nip_dst_idev((struct dst_entry *)rt) : NULL;
50 int err = 0;
51
52 err = nip_dev_get_saddr(net, idev ? idev->dev : NULL, daddr, saddr);
53
54 return err;
55 }
56
57 void nip_rt_ifdown(struct net *net, struct net_device *dev);
58
59 int nip_route_ioctl(struct net *net, unsigned int cmd, struct nip_rtmsg *rtmsg);
60
61 int nip_route_init(void);
62
63 void nip_route_cleanup(void);
64
65 #endif /* _NET_NIP_ROUTE_H */
66