4 #include <linux/netlink.h>
6 extern const struct nla_policy rtm_dn_policy
[];
10 struct dn_fib_info
*fi
;
11 unsigned char prefixlen
;
18 struct net_device
*nh_dev
;
19 unsigned int nh_flags
;
20 unsigned char nh_scope
;
28 struct dn_fib_info
*fib_next
;
29 struct dn_fib_info
*fib_prev
;
33 unsigned int fib_flags
;
37 __u32 fib_metrics
[RTAX_MAX
];
40 struct dn_fib_nh fib_nh
[0];
41 #define dn_fib_dev fib_nh[0].nh_dev
45 #define DN_FIB_RES_RESET(res) ((res).nh_sel = 0)
46 #define DN_FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel])
48 #define DN_FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __dn_fib_res_prefsrc(&res))
49 #define DN_FIB_RES_GW(res) (DN_FIB_RES_NH(res).nh_gw)
50 #define DN_FIB_RES_DEV(res) (DN_FIB_RES_NH(res).nh_dev)
51 #define DN_FIB_RES_OIF(res) (DN_FIB_RES_NH(res).nh_oif)
66 struct dn_fib_node
*fn_next
;
67 struct dn_fib_info
*fn_info
;
68 #define DN_FIB_INFO(f) ((f)->fn_info)
77 struct hlist_node hlist
;
80 int (*insert
)(struct dn_fib_table
*t
, struct rtmsg
*r
,
81 struct nlattr
*attrs
[], struct nlmsghdr
*n
,
82 struct netlink_skb_parms
*req
);
83 int (*delete)(struct dn_fib_table
*t
, struct rtmsg
*r
,
84 struct nlattr
*attrs
[], struct nlmsghdr
*n
,
85 struct netlink_skb_parms
*req
);
86 int (*lookup
)(struct dn_fib_table
*t
, const struct flowidn
*fld
,
87 struct dn_fib_res
*res
);
88 int (*flush
)(struct dn_fib_table
*t
);
89 int (*dump
)(struct dn_fib_table
*t
, struct sk_buff
*skb
, struct netlink_callback
*cb
);
91 unsigned char data
[0];
94 #ifdef CONFIG_DECNET_ROUTER
98 extern void dn_fib_init(void);
99 extern void dn_fib_cleanup(void);
101 extern int dn_fib_ioctl(struct socket
*sock
, unsigned int cmd
,
103 extern struct dn_fib_info
*dn_fib_create_info(const struct rtmsg
*r
,
104 struct nlattr
*attrs
[],
105 const struct nlmsghdr
*nlh
, int *errp
);
106 extern int dn_fib_semantic_match(int type
, struct dn_fib_info
*fi
,
107 const struct flowidn
*fld
,
108 struct dn_fib_res
*res
);
109 extern void dn_fib_release_info(struct dn_fib_info
*fi
);
110 extern void dn_fib_flush(void);
111 extern void dn_fib_select_multipath(const struct flowidn
*fld
,
112 struct dn_fib_res
*res
);
117 extern struct dn_fib_table
*dn_fib_get_table(u32 n
, int creat
);
118 extern struct dn_fib_table
*dn_fib_empty_table(void);
119 extern void dn_fib_table_init(void);
120 extern void dn_fib_table_cleanup(void);
125 extern void dn_fib_rules_init(void);
126 extern void dn_fib_rules_cleanup(void);
127 extern unsigned int dnet_addr_type(__le16 addr
);
128 extern int dn_fib_lookup(struct flowidn
*fld
, struct dn_fib_res
*res
);
130 extern int dn_fib_dump(struct sk_buff
*skb
, struct netlink_callback
*cb
);
132 extern void dn_fib_free_info(struct dn_fib_info
*fi
);
134 static inline void dn_fib_info_put(struct dn_fib_info
*fi
)
136 if (atomic_dec_and_test(&fi
->fib_clntref
))
137 dn_fib_free_info(fi
);
140 static inline void dn_fib_res_put(struct dn_fib_res
*res
)
143 dn_fib_info_put(res
->fi
);
145 fib_rule_put(res
->r
);
150 #define dn_fib_init() do { } while(0)
151 #define dn_fib_cleanup() do { } while(0)
153 #define dn_fib_lookup(fl, res) (-ESRCH)
154 #define dn_fib_info_put(fi) do { } while(0)
155 #define dn_fib_select_multipath(fl, res) do { } while(0)
156 #define dn_fib_rules_policy(saddr,res,flags) (0)
157 #define dn_fib_res_put(res) do { } while(0)
159 #endif /* CONFIG_DECNET_ROUTER */
161 static inline __le16
dnet_make_mask(int n
)
164 return cpu_to_le16(~((1 << (16 - n
)) - 1));
165 return cpu_to_le16(0);
168 #endif /* _NET_DN_FIB_H */