]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/net/dn_fib.h
Merge branch 'acpi-ec' into acpi-pm
[mirror_ubuntu-artful-kernel.git] / include / net / dn_fib.h
1 #ifndef _NET_DN_FIB_H
2 #define _NET_DN_FIB_H
3
4 #include <linux/netlink.h>
5 #include <linux/refcount.h>
6
7 extern const struct nla_policy rtm_dn_policy[];
8
9 struct dn_fib_res {
10 struct fib_rule *r;
11 struct dn_fib_info *fi;
12 unsigned char prefixlen;
13 unsigned char nh_sel;
14 unsigned char type;
15 unsigned char scope;
16 };
17
18 struct dn_fib_nh {
19 struct net_device *nh_dev;
20 unsigned int nh_flags;
21 unsigned char nh_scope;
22 int nh_weight;
23 int nh_power;
24 int nh_oif;
25 __le16 nh_gw;
26 };
27
28 struct dn_fib_info {
29 struct dn_fib_info *fib_next;
30 struct dn_fib_info *fib_prev;
31 int fib_treeref;
32 refcount_t fib_clntref;
33 int fib_dead;
34 unsigned int fib_flags;
35 int fib_protocol;
36 __le16 fib_prefsrc;
37 __u32 fib_priority;
38 __u32 fib_metrics[RTAX_MAX];
39 int fib_nhs;
40 int fib_power;
41 struct dn_fib_nh fib_nh[0];
42 #define dn_fib_dev fib_nh[0].nh_dev
43 };
44
45
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])
48
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)
53
54 typedef struct {
55 __le16 datum;
56 } dn_fib_key_t;
57
58 typedef struct {
59 __le16 datum;
60 } dn_fib_hash_t;
61
62 typedef struct {
63 __u16 datum;
64 } dn_fib_idx_t;
65
66 struct dn_fib_node {
67 struct dn_fib_node *fn_next;
68 struct dn_fib_info *fn_info;
69 #define DN_FIB_INFO(f) ((f)->fn_info)
70 dn_fib_key_t fn_key;
71 u8 fn_type;
72 u8 fn_scope;
73 u8 fn_state;
74 };
75
76
77 struct dn_fib_table {
78 struct hlist_node hlist;
79 u32 n;
80
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);
91
92 unsigned char data[0];
93 };
94
95 #ifdef CONFIG_DECNET_ROUTER
96 /*
97 * dn_fib.c
98 */
99 void dn_fib_init(void);
100 void dn_fib_cleanup(void);
101
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);
111
112 /*
113 * dn_tables.c
114 */
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);
119
120 /*
121 * dn_rules.c
122 */
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);
127
128 int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
129
130 void dn_fib_free_info(struct dn_fib_info *fi);
131
132 static inline void dn_fib_info_put(struct dn_fib_info *fi)
133 {
134 if (refcount_dec_and_test(&fi->fib_clntref))
135 dn_fib_free_info(fi);
136 }
137
138 static inline void dn_fib_res_put(struct dn_fib_res *res)
139 {
140 if (res->fi)
141 dn_fib_info_put(res->fi);
142 if (res->r)
143 fib_rule_put(res->r);
144 }
145
146 #else /* Endnode */
147
148 #define dn_fib_init() do { } while(0)
149 #define dn_fib_cleanup() do { } while(0)
150
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)
156
157 #endif /* CONFIG_DECNET_ROUTER */
158
159 static inline __le16 dnet_make_mask(int n)
160 {
161 if (n)
162 return cpu_to_le16(~((1 << (16 - n)) - 1));
163 return cpu_to_le16(0);
164 }
165
166 #endif /* _NET_DN_FIB_H */