/*
- * $Id: radix.h,v 1.10 2001/10/08 16:18:31 hno Exp $
+ * $Id: radix.h,v 1.11 2001/10/17 17:55:23 hno Exp $
*/
#ifndef SQUID_RADIX_H
*/
#undef RN_DEBUG
-#ifndef __P
-#define __P(x) x
-#endif
/*
* Radix search tree node layout.
*/
int rnh_addrsize; /* permit, but not require fixed keys */
int rnh_pktsize; /* permit, but not require fixed keys */
struct radix_node *(*rnh_addaddr) /* add based on sockaddr */
- __P((void *v, void *mask,
- struct radix_node_head * head, struct radix_node nodes[]));
+ (void *v, void *mask,
+ struct radix_node_head * head, struct radix_node nodes[]);
struct radix_node *(*rnh_addpkt) /* add based on packet hdr */
- __P((void *v, void *mask,
- struct radix_node_head * head, struct radix_node nodes[]));
+ (void *v, void *mask,
+ struct radix_node_head * head, struct radix_node nodes[]);
struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */
- __P((void *v, void *mask, struct radix_node_head * head));
+ (void *v, void *mask, struct radix_node_head * head);
struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */
- __P((void *v, void *mask, struct radix_node_head * head));
+ (void *v, void *mask, struct radix_node_head * head);
struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */
- __P((void *v, struct radix_node_head * head));
+ (void *v, struct radix_node_head * head);
struct radix_node *(*rnh_lookup) /* locate based on sockaddr */
- __P((void *v, void *mask, struct radix_node_head * head));
+ (void *v, void *mask, struct radix_node_head * head);
struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */
- __P((void *v, struct radix_node_head * head));
+ (void *v, struct radix_node_head * head);
int (*rnh_walktree) /* traverse tree */
- __P((struct radix_node_head * head, int (*f) (), void *w));
+ (struct radix_node_head * head, int (*f) (struct radix_node *, void *), void *w);
struct radix_node rnh_nodes[3]; /* empty tree for common case */
};
#define Bcmp(a, b, n) memcmp(((char *)(a)), ((char *)(b)), (n))
#define Bcopy(a, b, n) memcpy(((char *)(b)), ((char *)(a)), (unsigned)(n))
-#define Bzero(p, n) memset((char *)(p),'\0', (int)(n));
+#define Bzero(p, n) memset((char *)(p),'\0', (int)(n))
#define R_Malloc(p, t, n) (p = (t) xmalloc((unsigned int)(n)))
-#define Free(p) xfree((char *)p);
+#define Free(p) xfree((char *)p)
-void rn_init __P((void));
-int rn_inithead __P((void **, int));
-int rn_refines __P((void *, void *));
-int rn_walktree __P((struct radix_node_head *, int (*)(), void *));
-struct radix_node
- *rn_addmask __P((void *, int, int)), *rn_addroute __P((void *, void *, struct radix_node_head *,
- struct radix_node[2])), *rn_delete __P((void *, void *, struct radix_node_head *)),
- *rn_insert __P((void *, struct radix_node_head *, int *,
- struct radix_node[2])), *rn_match __P((void *, struct radix_node_head *)),
- *rn_newpair __P((void *, int, struct radix_node[2])), *rn_search __P((void *, struct radix_node *)),
- *rn_search_m __P((void *, struct radix_node *, void *));
+extern void rn_init (void);
+extern int rn_inithead(void **, int);
+extern int rn_refines(void *, void *);
+extern int rn_walktree(struct radix_node_head *, int (*)(struct radix_node *, void *), void *);
+extern struct radix_node *rn_addmask(void *, int, int);
+extern struct radix_node *rn_addroute(void *, void *, struct radix_node_head *, struct radix_node[2]);
+extern struct radix_node *rn_delete(void *, void *, struct radix_node_head *);
+extern struct radix_node *rn_insert(void *, struct radix_node_head *, int *, struct radix_node[2]);
+extern struct radix_node *rn_match(void *, struct radix_node_head *);
+extern struct radix_node *rn_newpair(void *, int, struct radix_node[2]);
+extern struct radix_node *rn_search(void *, struct radix_node *);
+extern struct radix_node *rn_search_m(void *, struct radix_node *, void *);
extern struct radix_node *rn_lookup(void *, void *, struct radix_node_head *);
#define min(x,y) ((x)<(y)? (x) : (y))
/*
- * $Id: radix.c,v 1.14 2001/08/03 16:55:21 wessels Exp $
+ * $Id: radix.c,v 1.15 2001/10/17 17:55:23 hno Exp $
*
* DEBUG: section 53 Radix tree data structure implementation
* AUTHOR: NetBSD Derived
*/
struct radix_node *
-rn_search(v_arg, head)
- void *v_arg;
- struct radix_node *head;
+rn_search(void *v_arg, struct radix_node *head)
{
register struct radix_node *x;
register caddr_t v;
}
struct radix_node *
-rn_search_m(v_arg, head, m_arg)
- struct radix_node *head;
- void *v_arg, *m_arg;
+rn_search_m(void *v_arg, struct radix_node *head, void *m_arg)
{
register struct radix_node *x;
register caddr_t v = v_arg, m = m_arg;
}
int
-rn_refines(m_arg, n_arg)
- void *m_arg, *n_arg;
+rn_refines(void *m_arg, void *n_arg)
{
register caddr_t m = m_arg, n = n_arg;
register caddr_t lim, lim2 = lim = n + *(u_char *) n;
}
struct radix_node *
-rn_lookup(v_arg, m_arg, head)
- void *v_arg, *m_arg;
- struct radix_node_head *head;
+rn_lookup(void *v_arg, void *m_arg, struct radix_node_head *head)
{
register struct radix_node *x;
caddr_t netmask = 0;
return x;
}
-static
-int
-rn_satsifies_leaf(trial, leaf, skip)
- char *trial;
- register struct radix_node *leaf;
- int skip;
+static int
+rn_satsifies_leaf (char *trial, register struct radix_node *leaf, int skip)
{
register char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask;
char *cplim;
}
struct radix_node *
-rn_match(v_arg, head)
- void *v_arg;
- struct radix_node_head *head;
+rn_match(void *v_arg, struct radix_node_head *head)
{
caddr_t v = v_arg;
register struct radix_node *t = head->rnh_treetop, *x;
#endif
struct radix_node *
-rn_newpair(v, b, nodes)
- void *v;
- int b;
- struct radix_node nodes[2];
+rn_newpair(void *v, int b, struct radix_node nodes[2])
{
register struct radix_node *tt = nodes, *t = tt + 1;
t->rn_b = b;
}
struct radix_node *
-rn_insert(v_arg, head, dupentry, nodes)
- void *v_arg;
- struct radix_node_head *head;
- int *dupentry;
- struct radix_node nodes[2];
+rn_insert(void *v_arg, struct radix_node_head *head, int *dupentry, struct radix_node nodes[2])
{
caddr_t v = v_arg;
struct radix_node *top = head->rnh_treetop;
}
struct radix_node *
-rn_addmask(n_arg, search, skip)
- int search, skip;
- void *n_arg;
+rn_addmask(void *n_arg, int search, int skip)
{
caddr_t netmask = (caddr_t) n_arg;
register struct radix_node *x;
}
static int /* XXX: arbitrary ordering for non-contiguous masks */
-rn_lexobetter(m_arg, n_arg)
- void *m_arg, *n_arg;
+rn_lexobetter(void *m_arg, void *n_arg)
{
register u_char *mp = m_arg, *np = n_arg, *lim;
}
static struct radix_mask *
-rn_new_radix_mask(tt, next)
- register struct radix_node *tt;
- register struct radix_mask *next;
+rn_new_radix_mask(struct radix_node *tt, struct radix_mask *next)
{
register struct radix_mask *m;
}
struct radix_node *
-rn_addroute(v_arg, n_arg, head, treenodes)
- void *v_arg, *n_arg;
- struct radix_node_head *head;
- struct radix_node treenodes[2];
+rn_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, struct radix_node treenodes[2])
{
caddr_t v = (caddr_t) v_arg, netmask = (caddr_t) n_arg;
register struct radix_node *t, *x = NULL, *tt;
}
struct radix_node *
-rn_delete(v_arg, netmask_arg, head)
- void *v_arg, *netmask_arg;
- struct radix_node_head *head;
+rn_delete(void *v_arg, void *netmask_arg, struct radix_node_head *head)
{
register struct radix_node *t, *p, *x, *tt;
struct radix_mask *m, *saved_m, **mp;
}
int
-rn_walktree(h, f, w)
- struct radix_node_head *h;
- int (*f) ();
- void *w;
+rn_walktree(struct radix_node_head *h, int (*f)(struct radix_node *, void *), void *w)
{
int error;
struct radix_node *base, *next;
}
int
-rn_inithead(head, off)
- void **head;
- int off;
+rn_inithead(void **head, int off)
{
register struct radix_node_head *rnh;
register struct radix_node *t, *tt, *ttt;
}
void
-rn_init()
+rn_init(void)
{
char *cp, *cplim;
#ifdef KERNEL