|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1988, 1989 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)radix.h 7.4 (Berkeley) 6/28/90 ! 21: */ ! 22: ! 23: /* ! 24: * Radix search tree node layout. ! 25: */ ! 26: ! 27: struct radix_node { ! 28: struct radix_mask *rn_mklist; /* list of masks contained in subtree */ ! 29: struct radix_node *rn_p; /* parent */ ! 30: short rn_b; /* bit offset; -1-index(netmask) */ ! 31: char rn_bmask; /* node: mask for bit test*/ ! 32: u_char rn_flags; /* enumerated next */ ! 33: #define RNF_NORMAL 1 /* leaf contains normal route */ ! 34: #define RNF_ROOT 2 /* leaf is root leaf for tree */ ! 35: #define RNF_ACTIVE 4 /* This node is alive (for rtfree) */ ! 36: union { ! 37: struct { /* leaf only data: */ ! 38: caddr_t rn_Key; /* object of search */ ! 39: caddr_t rn_Mask; /* netmask, if present */ ! 40: struct radix_node *rn_Dupedkey; ! 41: } rn_leaf; ! 42: struct { /* node only data: */ ! 43: int rn_Off; /* where to start compare */ ! 44: struct radix_node *rn_L;/* progeny */ ! 45: struct radix_node *rn_R;/* progeny */ ! 46: }rn_node; ! 47: } rn_u; ! 48: #ifdef RN_DEBUG ! 49: int rn_info; ! 50: struct radix_node *rn_twin; ! 51: struct radix_node *rn_ybro; ! 52: #endif ! 53: }; ! 54: ! 55: #define MAXKEYLEN 32 ! 56: ! 57: #define rn_dupedkey rn_u.rn_leaf.rn_Dupedkey ! 58: #define rn_key rn_u.rn_leaf.rn_Key ! 59: #define rn_mask rn_u.rn_leaf.rn_Mask ! 60: #define rn_off rn_u.rn_node.rn_Off ! 61: #define rn_l rn_u.rn_node.rn_L ! 62: #define rn_r rn_u.rn_node.rn_R ! 63: ! 64: /* ! 65: * Annotations to tree concerning potential routes applying to subtrees. ! 66: */ ! 67: ! 68: extern struct radix_mask { ! 69: short rm_b; /* bit offset; -1-index(netmask) */ ! 70: char rm_unused; /* cf. rn_bmask */ ! 71: u_char rm_flags; /* cf. rn_flags */ ! 72: struct radix_mask *rm_mklist; /* more masks to try */ ! 73: caddr_t rm_mask; /* the mask */ ! 74: int rm_refs; /* # of references to this struct */ ! 75: } *rn_mkfreelist; ! 76: ! 77: #define MKGet(m) {\ ! 78: if (rn_mkfreelist) {\ ! 79: m = rn_mkfreelist; \ ! 80: rn_mkfreelist = (m)->rm_mklist; \ ! 81: } else \ ! 82: R_Malloc(m, struct radix_mask *, sizeof (*(m))); }\ ! 83: ! 84: #define MKFree(m) { (m)->rm_mklist = rn_mkfreelist; rn_mkfreelist = (m);} ! 85: ! 86: extern struct radix_node_head { ! 87: struct radix_node_head *rnh_next; ! 88: struct radix_node *rnh_treetop; ! 89: int rnh_af; ! 90: struct radix_node rnh_nodes[3]; ! 91: } *radix_node_head; ! 92: ! 93: ! 94: #ifndef KERNEL ! 95: #define Bcmp(a, b, n) bcmp(((char *)(a)), ((char *)(b)), (n)) ! 96: #define Bzero(p, n) bzero((char *)(p), (int)(n)); ! 97: #define R_Malloc(p, t, n) (p = (t) malloc((unsigned int)(n))) ! 98: #define Free(p) free((char *)p); ! 99: #else ! 100: #define Bcmp(a, b, n) bcmp(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) ! 101: #define Bcopy(a, b, n) bcopy(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) ! 102: #define Bzero(p, n) bzero((caddr_t)(p), (unsigned)(n)); ! 103: #define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_DONTWAIT)) ! 104: #define Free(p) free((caddr_t)p, M_RTABLE); ! 105: #endif /*KERNEL*/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.