No empty .Rs/.Re
[netbsd-mini2440.git] / sys / netatalk / at_rmx.c
blobdf2415cde5298062e75ec20c040c07743fc0d347
1 /* $NetBSD: at_rmx.c,v 1.5 2005/12/11 12:24:54 christos Exp $ */
3 /*
4 * Copyright 1994, 1995 Massachusetts Institute of Technology
6 * Permission to use, copy, modify, and distribute this software and
7 * its documentation for any purpose and without fee is hereby
8 * granted, provided that both the above copyright notice and this
9 * permission notice appear in all copies, that both the above
10 * copyright notice and this permission notice appear in all
11 * supporting documentation, and that the name of M.I.T. not be used
12 * in advertising or publicity pertaining to distribution of the
13 * software without specific, written prior permission. M.I.T. makes
14 * no representations about the suitability of this software for any
15 * purpose. It is provided "as is" without express or implied
16 * warranty.
18 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
19 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
22 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 * at_rmx.c,v 1.13 1995/05/30 08:09:31 rgrimes Exp
34 /* This code generates debugging traces to the radix code */
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: at_rmx.c,v 1.5 2005/12/11 12:24:54 christos Exp $");
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/queue.h>
43 #include <sys/socket.h>
44 #include <sys/socketvar.h>
45 #include <sys/mbuf.h>
46 #include <sys/syslog.h>
48 #include <net/if.h>
49 #include <net/route.h>
51 #include <netatalk/at.h>
52 #include <netatalk/at_extern.h>
54 static char hexbuf[256];
56 char *
57 prsockaddr(const void *v)
59 char *bp = &hexbuf[0];
60 u_char *cp = __UNCONST(v);
62 if (v) {
63 int len = *cp;
64 u_char *cplim = cp + len;
66 /* return: "(len) hexdump" */
68 bp += snprintf(bp, sizeof(hexbuf), "(%d)", len);
69 for (cp++; cp < cplim && bp < hexbuf + 252; cp++) {
70 *bp++ = hexdigits[*cp / 16];
71 *bp++ = hexdigits[*cp % 16];
73 } else {
74 bp += snprintf(bp, sizeof(hexbuf), "null");
76 *bp = '\0';
78 return &hexbuf[0];
81 static struct radix_node *
82 at_addroute(const void *v_arg, const void *n_arg, struct radix_node_head * head,
83 struct radix_node * treenodes)
85 struct radix_node *rn;
87 printf("at_addroute: v=%s\n", prsockaddr(v_arg));
88 printf("at_addroute: n=%s\n", prsockaddr(n_arg));
89 printf("at_addroute: head=%p treenodes=%p\n", head, treenodes);
91 rn = rn_addroute(v_arg, n_arg, head, treenodes);
93 printf("at_addroute: returns rn=%p\n", rn);
95 return rn;
98 static struct radix_node *
99 at_matroute(const void *v_arg, struct radix_node_head * head)
101 struct radix_node *rn;
103 printf("at_matroute: v=%s\n", prsockaddr(v_arg));
104 printf("at_matroute: head=%p\n", head);
106 rn = rn_match(v_arg, head);
108 printf("at_matroute: returns rn=%p\n", rn);
110 return rn;
113 static struct radix_node *
114 at_lookup(const void *v_arg, const void *m_arg, struct radix_node_head * head)
116 struct radix_node *rn;
118 printf("at_lookup: v=%s\n", prsockaddr(v_arg));
119 printf("at_lookup: n=%s\n", prsockaddr(m_arg));
120 printf("at_lookup: head=%p\n", head);
122 rn = rn_lookup(v_arg, m_arg, head);
124 printf("at_lookup: returns rn=%p\n", rn);
126 return rn;
129 static struct radix_node *
130 at_delroute(const void *v_arg, const void *netmask_arg, struct radix_node_head * head)
132 struct radix_node *rn;
134 printf("at_delroute: v=%s\n", prsockaddr(v_arg));
135 printf("at_delroute: n=%s\n", prsockaddr(netmask_arg));
136 printf("at_delroute: head=%p\n", head);
138 rn = rn_delete(v_arg, netmask_arg, head);
140 printf("at_delroute: returns rn=%p\n", rn);
142 return rn;
146 * Initialize our routing tree with debugging hooks.
149 at_inithead(void **head, int off)
151 struct radix_node_head *rnh;
153 if (!rn_inithead(head, off))
154 return 0;
156 rnh = *head;
157 rnh->rnh_addaddr = at_addroute;
158 rnh->rnh_deladdr = at_delroute;
159 rnh->rnh_matchaddr = at_matroute;
160 rnh->rnh_lookup = at_lookup;
161 return 1;