summaryrefslogtreecommitdiffstats
path: root/include/net/dn_fib.h
blob: d8118449c8ffee4e71a668e9db09335a08a074a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef _NET_DN_FIB_H
#define _NET_DN_FIB_H

#include <linux/config.h>

#ifdef CONFIG_DECNET_ROUTER


struct dn_fib_res {
	dn_address res_addr;
	dn_address res_mask;
	int res_ifindex;
	int res_proto;
	int res_cost;
	int res_type;
	struct dn_fib_node *res_fn;
	struct dn_fib_action *res_fa;
};

struct dn_fib_action {
	struct dn_fib_action *fa_next;
	dn_address fa_key;
	dn_address fa_mask;
	int fa_ifindex;
	int fa_proto;
	int fa_cost;
	int fa_type;
	union {
		struct neighbour *fau_neigh;	/* Normal route */
		int fau_error;			/* Reject       */
		int fau_table;			/* Throw        */
	} fa_u;
#define fa_neigh fa_u.fau_neigh
#define fa_error fa_u.fau_error
#define fa_table fa_u.fau_table
};

struct dn_fib_node {
	struct dn_fib_node *fn_up;
	dn_address fn_cmpmask;
	dn_address fn_key;
	int fn_shift;
	struct dn_fib_action *fn_action;
	struct dn_fib_node *fn_children[2];
};

#define DN_FIB_NEXT(fibnode, key) ((fibnode)->fn_children[((key) ^ (fibnode)->fn_cmpmask) >> (fibnode)->fn_shift]) 

struct dn_fib_walker_t;

struct dn_fib_table {
	int n;
	unsigned long count;
	struct dn_fib_node *root;

	int (*insert)(struct dn_fib_table *t, struct dn_fib_action *fa);
	int (*delete)(struct dn_fib_table *t, struct dn_fib_action *fa);
	int (*lookup)(struct dn_fib_table *t, struct dn_fib_res *res);
	int (*walk)(struct dn_fib_walker_t *fwt);
#ifdef CONFIG_RTNETLINK
	int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
#endif /* CONFIG_RTNETLINK */
};

struct dn_fib_walker_t {
	struct dn_fib_table *table;
	void *arg;
	int (*fxn)(struct dn_fib_walker_t *fwt, struct dn_fib_node *n);
};

extern void dn_fib_init(void);
extern void dn_fib_cleanup(void);

extern int dn_fib_rt_message(struct sk_buff *skb);
extern int dn_fib_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);

#ifdef CONFIG_RTNETLINK
extern int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
extern int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
extern int dn_fib_rtm_getroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
#endif /* CONFIG_RTNETLINK */
#endif /* CONFIG_DECNET_ROUTER */

#endif /* _NET_DN_FIB_H */