4 #include <linux/config.h>
6 #ifdef CONFIG_DECNET_ROUTER
8 #include <linux/rtnetlink.h>
19 struct rtattr
*rta_mx
;
20 struct rtattr
*rta_mp
;
21 unsigned char *rta_protoinfo
;
22 unsigned char *rta_flow
;
23 struct rta_cacheinfo
*rta_ci
;
36 struct dn_fib_rule
*r
;
37 struct dn_fib_info
*fi
;
38 unsigned char prefixlen
;
45 struct net_device
*nh_dev
;
47 unsigned char nh_scope
;
55 struct dn_fib_info
*fib_next
;
56 struct dn_fib_info
*fib_prev
;
62 dn_address fib_prefsrc
;
66 struct dn_fib_nh fib_nh
[0];
67 #define fib_dev fib_nh[0].nh_dev
71 #define DN_FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel])
72 #define DN_FIB_RES_RESET(res) ((res).nh_sel = 0)
73 #define DN_FIB_RES_GW(res) (DN_FIB_RES_NH(res).nh_gw)
74 #define DN_FIB_RES_DEV(res) (DN_FIB_RES_NH(res).nh_dev)
75 #define DN_FIB_RES_OIF(res) (DN_FIB_RES_NH(res).nh_oif)
90 struct dn_fib_node
*fn_next
;
91 struct dn_fib_info
*fn_info
;
92 #define DN_FIB_INFO(f) ((f)->fn_info)
100 struct dn_fib_table
{
103 int (*insert
)(struct dn_fib_table
*t
, struct rtmsg
*r
,
104 struct dn_kern_rta
*rta
, struct nlmsghdr
*n
,
105 struct netlink_skb_parms
*req
);
106 int (*delete)(struct dn_fib_table
*t
, struct rtmsg
*r
,
107 struct dn_kern_rta
*rta
, struct nlmsghdr
*n
,
108 struct netlink_skb_parms
*req
);
109 int (*lookup
)(struct dn_fib_table
*t
, const struct dn_fib_key
*key
,
110 struct dn_fib_res
*res
);
111 int (*flush
)(struct dn_fib_table
*t
);
112 #ifdef CONFIG_PROC_FS
113 int (*get_info
)(struct dn_fib_table
*table
, char *buf
,
114 int first
, int count
);
115 #endif /* CONFIG_PROC_FS */
116 #ifdef CONFIG_RTNETLINK
117 int (*dump
)(struct dn_fib_table
*t
, struct sk_buff
*skb
, struct netlink_callback
*cb
);
118 #endif /* CONFIG_RTNETLINK */
120 unsigned char data
[0];
127 extern void dn_fib_init(void);
128 extern void dn_fib_cleanup(void);
130 extern int dn_fib_rt_message(struct sk_buff
*skb
);
131 extern int dn_fib_ioctl(struct socket
*sock
, unsigned int cmd
,
133 extern struct dn_fib_info
*dn_fib_create_info(const struct rtmsg
*r
,
134 struct dn_kern_rta
*rta
,
135 const struct nlmsghdr
*nlh
, int *errp
);
136 extern int dn_fib_semantic_match(int type
, struct dn_fib_info
*fi
,
137 const struct dn_fib_key
*key
, struct dn_fib_res
*res
);
138 extern void dn_fib_release_info(struct dn_fib_info
*fi
);
139 extern u16
dn_fib_get_attr16(struct rtattr
*attr
, int attrlen
, int type
);
140 extern void dn_fib_flush(void);
141 extern void dn_fib_select_multipath(const struct dn_fib_key
*key
,
142 struct dn_fib_res
*res
);
143 extern int dn_fib_sync_down(dn_address local
, struct net_device
*dev
,
145 extern int dn_fib_sync_up(struct net_device
*dev
);
150 extern struct dn_fib_table
*dn_fib_get_table(int n
, int creat
);
151 extern struct dn_fib_table
*dn_fib_empty_table(void);
152 extern void dn_fib_table_init(void);
153 extern void dn_fib_table_cleanup(void);
158 extern void dn_fib_rules_init(void);
159 extern void dn_fib_rules_cleanup(void);
160 extern void dn_fib_rule_put(struct dn_fib_rule
*);
161 extern int dn_fib_lookup(struct dn_fib_key
*key
, struct dn_fib_res
*res
);
164 * rtnetlink interface
166 #ifdef CONFIG_RTNETLINK
167 extern int dn_fib_rtm_delroute(struct sk_buff
*skb
, struct nlmsghdr
*nlh
, void *arg
);
168 extern int dn_fib_rtm_newroute(struct sk_buff
*skb
, struct nlmsghdr
*nlh
, void *arg
);
169 extern int dn_fib_dump(struct sk_buff
*skb
, struct netlink_callback
*cb
);
171 extern int dn_fib_rtm_delrule(struct sk_buff
*skb
, struct nlmsghdr
*nlh
, void *arg
);
172 extern int dn_fib_rtm_newrule(struct sk_buff
*skb
, struct nlmsghdr
*nlh
, void *arg
);
173 extern int dn_fib_dump_rules(struct sk_buff
*skb
, struct netlink_callback
*cb
);
174 #endif /* CONFIG_RTNETLINK */
176 #define DN_NUM_TABLES 255
177 #define DN_MIN_TABLE 1
178 #define DN_DEFAULT_TABLE 1
179 #define DN_L1_TABLE 1
180 #define DN_L2_TABLE 2
182 extern void dn_fib_free_info(struct dn_fib_info
*fi
);
184 static __inline__
void dn_fib_info_put(struct dn_fib_info
*fi
)
186 if (atomic_dec_and_test(&fi
->fib_clntref
))
187 dn_fib_free_info(fi
);
190 static __inline__
void dn_fib_res_put(struct dn_fib_res
*res
)
193 dn_fib_info_put(res
->fi
);
195 dn_fib_rule_put(res
->r
);
198 static __inline__ u16
dnet_make_mask(int n
)
201 return htons(~((1<<(16-n
))-1));
205 #endif /* CONFIG_DECNET_ROUTER */
207 #endif /* _NET_DN_FIB_H */