More Makefile cleanups, otherwise mainly noticeable are the netfilter fix
[davej-history.git] / include / net / dn_fib.h
blob0bd6357cbc916f6d48df92b24f9897801940b9b9
1 #ifndef _NET_DN_FIB_H
2 #define _NET_DN_FIB_H
4 #include <linux/config.h>
6 #ifdef CONFIG_DECNET_ROUTER
8 #include <linux/rtnetlink.h>
10 struct dn_kern_rta
12 void *rta_dst;
13 void *rta_src;
14 int *rta_iif;
15 int *rta_oif;
16 void *rta_gw;
17 u32 *rta_priority;
18 void *rta_prefsrc;
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;
26 struct dn_fib_key {
27 dn_address src;
28 dn_address dst;
29 int iif;
30 int oif;
31 u32 fwmark;
32 unsigned char scope;
35 struct dn_fib_res {
36 struct dn_fib_rule *r;
37 struct dn_fib_info *fi;
38 unsigned char prefixlen;
39 unsigned char nh_sel;
40 unsigned char type;
41 unsigned char scope;
44 struct dn_fib_nh {
45 struct net_device *nh_dev;
46 unsigned nh_flags;
47 unsigned char nh_scope;
48 int nh_weight;
49 int nh_power;
50 int nh_oif;
51 u32 nh_gw;
54 struct dn_fib_info {
55 struct dn_fib_info *fib_next;
56 struct dn_fib_info *fib_prev;
57 int fib_treeref;
58 atomic_t fib_clntref;
59 int fib_dead;
60 unsigned fib_flags;
61 int fib_protocol;
62 dn_address fib_prefsrc;
63 u32 fib_priority;
64 int fib_nhs;
65 int fib_power;
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)
77 typedef struct {
78 u16 datum;
79 } dn_fib_key_t;
81 typedef struct {
82 u16 datum;
83 } dn_fib_hash_t;
85 typedef struct {
86 u16 datum;
87 } dn_fib_idx_t;
89 struct dn_fib_node {
90 struct dn_fib_node *fn_next;
91 struct dn_fib_info *fn_info;
92 #define DN_FIB_INFO(f) ((f)->fn_info)
93 dn_fib_key_t fn_key;
94 u8 fn_type;
95 u8 fn_scope;
96 u8 fn_state;
100 struct dn_fib_table {
101 int n;
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];
125 * dn_fib.c
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,
132 unsigned long arg);
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,
144 int force);
145 extern int dn_fib_sync_up(struct net_device *dev);
148 * dn_tables.c
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);
156 * dn_rules.c
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)
192 if (res->fi)
193 dn_fib_info_put(res->fi);
194 if (res->r)
195 dn_fib_rule_put(res->r);
198 static __inline__ u16 dnet_make_mask(int n)
200 if (n)
201 return htons(~((1<<(16-n))-1));
202 return 0;
205 #endif /* CONFIG_DECNET_ROUTER */
207 #endif /* _NET_DN_FIB_H */