4 #include <linux/netlink.h>
5 #include <linux/refcount.h>
7 extern const struct nla_policy rtm_dn_policy[];
11 struct dn_fib_info *fi;
12 unsigned char prefixlen;
19 struct net_device *nh_dev;
20 unsigned int nh_flags;
21 unsigned char nh_scope;
29 struct dn_fib_info *fib_next;
30 struct dn_fib_info *fib_prev;
32 refcount_t fib_clntref;
34 unsigned int fib_flags;
38 __u32 fib_metrics[RTAX_MAX];
41 struct dn_fib_nh fib_nh[0];
42 #define dn_fib_dev fib_nh[0].nh_dev
46 #define DN_FIB_RES_RESET(res) ((res).nh_sel = 0)
47 #define DN_FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel])
49 #define DN_FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __dn_fib_res_prefsrc(&res))
50 #define DN_FIB_RES_GW(res) (DN_FIB_RES_NH(res).nh_gw)
51 #define DN_FIB_RES_DEV(res) (DN_FIB_RES_NH(res).nh_dev)
52 #define DN_FIB_RES_OIF(res) (DN_FIB_RES_NH(res).nh_oif)
67 struct dn_fib_node *fn_next;
68 struct dn_fib_info *fn_info;
69 #define DN_FIB_INFO(f) ((f)->fn_info)
78 struct hlist_node hlist;
81 int (*insert)(struct dn_fib_table *t, struct rtmsg *r,
82 struct nlattr *attrs[], struct nlmsghdr *n,
83 struct netlink_skb_parms *req);
84 int (*delete)(struct dn_fib_table *t, struct rtmsg *r,
85 struct nlattr *attrs[], struct nlmsghdr *n,
86 struct netlink_skb_parms *req);
87 int (*lookup)(struct dn_fib_table *t, const struct flowidn *fld,
88 struct dn_fib_res *res);
89 int (*flush)(struct dn_fib_table *t);
90 int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
92 unsigned char data[0];
95 #ifdef CONFIG_DECNET_ROUTER
99 void dn_fib_init(void);
100 void dn_fib_cleanup(void);
102 int dn_fib_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
103 struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r,
104 struct nlattr *attrs[],
105 const struct nlmsghdr *nlh, int *errp);
106 int dn_fib_semantic_match(int type, struct dn_fib_info *fi,
107 const struct flowidn *fld, struct dn_fib_res *res);
108 void dn_fib_release_info(struct dn_fib_info *fi);
109 void dn_fib_flush(void);
110 void dn_fib_select_multipath(const struct flowidn *fld, struct dn_fib_res *res);
115 struct dn_fib_table *dn_fib_get_table(u32 n, int creat);
116 struct dn_fib_table *dn_fib_empty_table(void);
117 void dn_fib_table_init(void);
118 void dn_fib_table_cleanup(void);
123 void dn_fib_rules_init(void);
124 void dn_fib_rules_cleanup(void);
125 unsigned int dnet_addr_type(__le16 addr);
126 int dn_fib_lookup(struct flowidn *fld, struct dn_fib_res *res);
128 int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
130 void dn_fib_free_info(struct dn_fib_info *fi);
132 static inline void dn_fib_info_put(struct dn_fib_info *fi)
134 if (refcount_dec_and_test(&fi->fib_clntref))
135 dn_fib_free_info(fi);
138 static inline void dn_fib_res_put(struct dn_fib_res *res)
141 dn_fib_info_put(res->fi);
143 fib_rule_put(res->r);
148 #define dn_fib_init() do { } while(0)
149 #define dn_fib_cleanup() do { } while(0)
151 #define dn_fib_lookup(fl, res) (-ESRCH)
152 #define dn_fib_info_put(fi) do { } while(0)
153 #define dn_fib_select_multipath(fl, res) do { } while(0)
154 #define dn_fib_rules_policy(saddr,res,flags) (0)
155 #define dn_fib_res_put(res) do { } while(0)
157 #endif /* CONFIG_DECNET_ROUTER */
159 static inline __le16 dnet_make_mask(int n)
162 return cpu_to_le16(~((1 << (16 - n)) - 1));
163 return cpu_to_le16(0);
166 #endif /* _NET_DN_FIB_H */