4 /* WARNING: The ordering of these elements must match ordering
5 * of RTA_* rtnetlink attribute numbers.
16 struct rtattr *rta_mx;
17 struct rtattr *rta_mp;
18 unsigned char *rta_protoinfo;
20 struct rta_cacheinfo *rta_ci;
21 struct rta_session *rta_sess;
25 struct dn_fib_rule *r;
26 struct dn_fib_info *fi;
27 unsigned char prefixlen;
34 struct net_device *nh_dev;
36 unsigned char nh_scope;
44 struct dn_fib_info *fib_next;
45 struct dn_fib_info *fib_prev;
51 dn_address fib_prefsrc;
53 __u32 fib_metrics[RTAX_MAX];
54 #define dn_fib_mtu fib_metrics[RTAX_MTU-1]
55 #define dn_fib_window fib_metrics[RTAX_WINDOW-1]
56 #define dn_fib_rtt fib_metrics[RTAX_RTT-1]
57 #define dn_fib_advmss fib_metrics[RTAX_ADVMSS-1]
60 struct dn_fib_nh fib_nh[0];
61 #define dn_fib_dev fib_nh[0].nh_dev
65 #define DN_FIB_RES_RESET(res) ((res).nh_sel = 0)
66 #define DN_FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel])
68 #define DN_FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __dn_fib_res_prefsrc(&res))
69 #define DN_FIB_RES_GW(res) (DN_FIB_RES_NH(res).nh_gw)
70 #define DN_FIB_RES_DEV(res) (DN_FIB_RES_NH(res).nh_dev)
71 #define DN_FIB_RES_OIF(res) (DN_FIB_RES_NH(res).nh_oif)
86 struct dn_fib_node *fn_next;
87 struct dn_fib_info *fn_info;
88 #define DN_FIB_INFO(f) ((f)->fn_info)
99 int (*insert)(struct dn_fib_table *t, struct rtmsg *r,
100 struct dn_kern_rta *rta, struct nlmsghdr *n,
101 struct netlink_skb_parms *req);
102 int (*delete)(struct dn_fib_table *t, struct rtmsg *r,
103 struct dn_kern_rta *rta, struct nlmsghdr *n,
104 struct netlink_skb_parms *req);
105 int (*lookup)(struct dn_fib_table *t, const struct flowi *fl,
106 struct dn_fib_res *res);
107 int (*flush)(struct dn_fib_table *t);
108 int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
110 unsigned char data[0];
113 #ifdef CONFIG_DECNET_ROUTER
117 extern void dn_fib_init(void);
118 extern void dn_fib_cleanup(void);
120 extern int dn_fib_rt_message(struct sk_buff *skb);
121 extern int dn_fib_ioctl(struct socket *sock, unsigned int cmd,
123 extern struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r,
124 struct dn_kern_rta *rta,
125 const struct nlmsghdr *nlh, int *errp);
126 extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi,
127 const struct flowi *fl,
128 struct dn_fib_res *res);
129 extern void dn_fib_release_info(struct dn_fib_info *fi);
130 extern u16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type);
131 extern void dn_fib_flush(void);
132 extern void dn_fib_select_multipath(const struct flowi *fl,
133 struct dn_fib_res *res);
134 extern int dn_fib_sync_down(dn_address local, struct net_device *dev,
136 extern int dn_fib_sync_up(struct net_device *dev);
141 extern struct dn_fib_table *dn_fib_get_table(int n, int creat);
142 extern struct dn_fib_table *dn_fib_empty_table(void);
143 extern void dn_fib_table_init(void);
144 extern void dn_fib_table_cleanup(void);
149 extern void dn_fib_rules_init(void);
150 extern void dn_fib_rules_cleanup(void);
151 extern void dn_fib_rule_put(struct dn_fib_rule *);
152 extern __u16 dn_fib_rules_policy(__u16 saddr, struct dn_fib_res *res, unsigned *flags);
153 extern unsigned dnet_addr_type(__u16 addr);
154 extern int dn_fib_lookup(const struct flowi *fl, struct dn_fib_res *res);
157 * rtnetlink interface
159 extern int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
160 extern int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
161 extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
163 extern int dn_fib_rtm_delrule(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
164 extern int dn_fib_rtm_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
165 extern int dn_fib_dump_rules(struct sk_buff *skb, struct netlink_callback *cb);
167 extern void dn_fib_free_info(struct dn_fib_info *fi);
169 static inline void dn_fib_info_put(struct dn_fib_info *fi)
171 if (atomic_dec_and_test(&fi->fib_clntref))
172 dn_fib_free_info(fi);
175 static inline void dn_fib_res_put(struct dn_fib_res *res)
178 dn_fib_info_put(res->fi);
180 dn_fib_rule_put(res->r);
183 extern struct dn_fib_table *dn_fib_tables[];
187 #define dn_fib_init() do { } while(0)
188 #define dn_fib_cleanup() do { } while(0)
190 #define dn_fib_lookup(fl, res) (-ESRCH)
191 #define dn_fib_info_put(fi) do { } while(0)
192 #define dn_fib_select_multipath(fl, res) do { } while(0)
193 #define dn_fib_rules_policy(saddr,res,flags) (0)
194 #define dn_fib_res_put(res) do { } while(0)
196 #endif /* CONFIG_DECNET_ROUTER */
198 static inline u16 dnet_make_mask(int n)
201 return htons(~((1<<(16-n))-1));
205 #endif /* _NET_DN_FIB_H */