etc/services - sync with NetBSD-8
[minix.git] / minix / net / lwip / rttree.h
blobb2a24d8c7215a3eb8bfaae7441bed01981479a33
1 #ifndef MINIX_NET_LWIP_RTTREE_H
2 #define MINIX_NET_LWIP_RTTREE_H
4 /* Routing table node structure. */
5 struct rttree_node {
6 struct rttree_node *rtn_child[2]; /* left child node */
7 struct rttree_node *rtn_parent; /* parent node */
8 uint8_t rtn_type; /* node type (RNT_) */
9 uint8_t rtn_bits; /* prefix bit count */
10 uint8_t rtn_byte; /* bits-derived byte index */
11 uint8_t rtn_shift; /* bits-derived shift count */
14 #define RTNT_DATA 0 /* data node (entry) */
15 #define RTNT_LINK 1 /* link node, in use */
16 #define RTNT_FREE 2 /* link node, free */
18 /* Routing table entry structure. */
19 struct rttree_entry {
20 struct rttree_node rte_data; /* data node - MUST be first */
21 struct rttree_node rte_link; /* link node */
22 const void *rte_addr; /* pointer to address */
23 const void *rte_mask; /* pointer to mask */
26 /* Routing table structure. */
27 struct rttree {
28 struct rttree_node *rtt_root; /* root of the route tree */
29 struct rttree_node *rtt_free; /* free internal nodes list */
30 uint8_t rtt_bits; /* number of bits in address */
33 #define rttree_get_addr(entry) ((entry)->rte_addr)
34 #define rttree_get_mask(entry) ((entry)->rte_mask)
35 #define rttree_get_prefix(entry) ((entry)->rte_data.rtn_bits)
37 void rttree_init(struct rttree * tree, unsigned int bits);
38 struct rttree_entry *rttree_lookup_match(struct rttree * tree,
39 const void * addr);
40 struct rttree_entry *rttree_lookup_host(struct rttree * tree,
41 const void * addr);
42 struct rttree_entry *rttree_lookup_exact(struct rttree * tree,
43 const void * addr, unsigned int prefix);
44 struct rttree_entry *rttree_enum(struct rttree * tree,
45 struct rttree_entry * entry);
46 int rttree_add(struct rttree * tree, struct rttree_entry * entry,
47 const void * addr, const void * mask, unsigned int prefix);
48 void rttree_delete(struct rttree * tree, struct rttree_entry * entry);
50 #endif /* !MINIX_NET_LWIP_RTTREE_H */