radix.h (59529) | radix.h (92725) |
---|---|
1/* 2 * Copyright (c) 1988, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)radix.h 8.2 (Berkeley) 10/31/94 | 1/* 2 * Copyright (c) 1988, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)radix.h 8.2 (Berkeley) 10/31/94 |
34 * $FreeBSD: head/sys/net/radix.h 59529 2000-04-23 04:00:00Z wollman $ | 34 * $FreeBSD: head/sys/net/radix.h 92725 2002-03-19 21:54:18Z alfred $ |
35 */ 36 37#ifndef _RADIX_H_ 38#define _RADIX_H_ 39 40#ifdef MALLOC_DECLARE 41MALLOC_DECLARE(M_RTABLE); 42#endif --- 60 unchanged lines hidden (view full) --- 103 if (rn_mkfreelist) {\ 104 m = rn_mkfreelist; \ 105 rn_mkfreelist = (m)->rm_mklist; \ 106 } else \ 107 R_Malloc(m, struct radix_mask *, sizeof (*(m))); }\ 108 109#define MKFree(m) { (m)->rm_mklist = rn_mkfreelist; rn_mkfreelist = (m);} 110 | 35 */ 36 37#ifndef _RADIX_H_ 38#define _RADIX_H_ 39 40#ifdef MALLOC_DECLARE 41MALLOC_DECLARE(M_RTABLE); 42#endif --- 60 unchanged lines hidden (view full) --- 103 if (rn_mkfreelist) {\ 104 m = rn_mkfreelist; \ 105 rn_mkfreelist = (m)->rm_mklist; \ 106 } else \ 107 R_Malloc(m, struct radix_mask *, sizeof (*(m))); }\ 108 109#define MKFree(m) { (m)->rm_mklist = rn_mkfreelist; rn_mkfreelist = (m);} 110 |
111typedef int walktree_f_t __P((struct radix_node *, void *)); | 111typedef int walktree_f_t(struct radix_node *, void *); |
112 113struct radix_node_head { 114 struct radix_node *rnh_treetop; 115 int rnh_addrsize; /* permit, but not require fixed keys */ 116 int rnh_pktsize; /* permit, but not require fixed keys */ 117 struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ | 112 113struct radix_node_head { 114 struct radix_node *rnh_treetop; 115 int rnh_addrsize; /* permit, but not require fixed keys */ 116 int rnh_pktsize; /* permit, but not require fixed keys */ 117 struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ |
118 __P((void *v, void *mask, 119 struct radix_node_head *head, struct radix_node nodes[])); | 118 (void *v, void *mask, 119 struct radix_node_head *head, struct radix_node nodes[]); |
120 struct radix_node *(*rnh_addpkt) /* add based on packet hdr */ | 120 struct radix_node *(*rnh_addpkt) /* add based on packet hdr */ |
121 __P((void *v, void *mask, 122 struct radix_node_head *head, struct radix_node nodes[])); | 121 (void *v, void *mask, 122 struct radix_node_head *head, struct radix_node nodes[]); |
123 struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */ | 123 struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */ |
124 __P((void *v, void *mask, struct radix_node_head *head)); | 124 (void *v, void *mask, struct radix_node_head *head); |
125 struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */ | 125 struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */ |
126 __P((void *v, void *mask, struct radix_node_head *head)); | 126 (void *v, void *mask, struct radix_node_head *head); |
127 struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */ | 127 struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */ |
128 __P((void *v, struct radix_node_head *head)); | 128 (void *v, struct radix_node_head *head); |
129 struct radix_node *(*rnh_lookup) /* locate based on sockaddr */ | 129 struct radix_node *(*rnh_lookup) /* locate based on sockaddr */ |
130 __P((void *v, void *mask, struct radix_node_head *head)); | 130 (void *v, void *mask, struct radix_node_head *head); |
131 struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */ | 131 struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */ |
132 __P((void *v, struct radix_node_head *head)); | 132 (void *v, struct radix_node_head *head); |
133 int (*rnh_walktree) /* traverse tree */ | 133 int (*rnh_walktree) /* traverse tree */ |
134 __P((struct radix_node_head *head, walktree_f_t *f, void *w)); | 134 (struct radix_node_head *head, walktree_f_t *f, void *w); |
135 int (*rnh_walktree_from) /* traverse tree below a */ | 135 int (*rnh_walktree_from) /* traverse tree below a */ |
136 __P((struct radix_node_head *head, void *a, void *m, 137 walktree_f_t *f, void *w)); | 136 (struct radix_node_head *head, void *a, void *m, 137 walktree_f_t *f, void *w); |
138 void (*rnh_close) /* do something when the last ref drops */ | 138 void (*rnh_close) /* do something when the last ref drops */ |
139 __P((struct radix_node *rn, struct radix_node_head *head)); | 139 (struct radix_node *rn, struct radix_node_head *head); |
140 struct radix_node rnh_nodes[3]; /* empty tree for common case */ 141}; 142 143#ifndef _KERNEL 144#define Bcmp(a, b, n) bcmp(((char *)(a)), ((char *)(b)), (n)) 145#define Bcopy(a, b, n) bcopy(((char *)(a)), ((char *)(b)), (unsigned)(n)) 146#define Bzero(p, n) bzero((char *)(p), (int)(n)); 147#define R_Malloc(p, t, n) (p = (t) malloc((unsigned int)(n))) 148#define Free(p) free((char *)p); 149#else 150#define Bcmp(a, b, n) bcmp(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) 151#define Bcopy(a, b, n) bcopy(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) 152#define Bzero(p, n) bzero((caddr_t)(p), (unsigned)(n)); 153#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_DONTWAIT)) 154#define Free(p) free((caddr_t)p, M_RTABLE); 155#endif /* _KERNEL */ 156 | 140 struct radix_node rnh_nodes[3]; /* empty tree for common case */ 141}; 142 143#ifndef _KERNEL 144#define Bcmp(a, b, n) bcmp(((char *)(a)), ((char *)(b)), (n)) 145#define Bcopy(a, b, n) bcopy(((char *)(a)), ((char *)(b)), (unsigned)(n)) 146#define Bzero(p, n) bzero((char *)(p), (int)(n)); 147#define R_Malloc(p, t, n) (p = (t) malloc((unsigned int)(n))) 148#define Free(p) free((char *)p); 149#else 150#define Bcmp(a, b, n) bcmp(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) 151#define Bcopy(a, b, n) bcopy(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) 152#define Bzero(p, n) bzero((caddr_t)(p), (unsigned)(n)); 153#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_DONTWAIT)) 154#define Free(p) free((caddr_t)p, M_RTABLE); 155#endif /* _KERNEL */ 156 |
157void rn_init __P((void)); 158int rn_inithead __P((void **, int)); 159int rn_refines __P((void *, void *)); | 157void rn_init(void); 158int rn_inithead(void **, int); 159int rn_refines(void *, void *); |
160struct radix_node | 160struct radix_node |
161 *rn_addmask __P((void *, int, int)), 162 *rn_addroute __P((void *, void *, struct radix_node_head *, 163 struct radix_node [2])), 164 *rn_delete __P((void *, void *, struct radix_node_head *)), 165 *rn_lookup __P((void *v_arg, void *m_arg, 166 struct radix_node_head *head)), 167 *rn_match __P((void *, struct radix_node_head *)); | 161 *rn_addmask(void *, int, int), 162 *rn_addroute (void *, void *, struct radix_node_head *, 163 struct radix_node [2]), 164 *rn_delete(void *, void *, struct radix_node_head *), 165 *rn_lookup (void *v_arg, void *m_arg, 166 struct radix_node_head *head), 167 *rn_match(void *, struct radix_node_head *); |
168 169 170#endif /* _RADIX_H_ */ | 168 169 170#endif /* _RADIX_H_ */ |