[BACK]Return to at_rmx.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / netatalk

Annotation of src/sys/netatalk/at_rmx.c, Revision 1.6

1.6     ! christos    1: /*     $NetBSD: at_rmx.c,v 1.5 2005/12/11 12:24:54 christos Exp $      */
1.1       christos    2:
                      3: /*
                      4:  * Copyright 1994, 1995 Massachusetts Institute of Technology
                      5:  *
                      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.
                     17:  *
                     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.
                     30:  *
                     31:  * at_rmx.c,v 1.13 1995/05/30 08:09:31 rgrimes Exp
                     32:  */
                     33:
                     34: /* This code generates debugging traces to the radix code */
1.2       lukem      35:
                     36: #include <sys/cdefs.h>
1.6     ! christos   37: __KERNEL_RCSID(0, "$NetBSD: at_rmx.c,v 1.5 2005/12/11 12:24:54 christos Exp $");
1.1       christos   38:
                     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>
                     47:
                     48: #include <net/if.h>
                     49: #include <net/route.h>
                     50:
                     51: #include <netatalk/at.h>
                     52: #include <netatalk/at_extern.h>
                     53:
                     54: static char     hexbuf[256];
                     55:
                     56: char           *
1.6     ! christos   57: prsockaddr(const void *v)
1.1       christos   58: {
                     59:        char           *bp = &hexbuf[0];
1.6     ! christos   60:        u_char         *cp = __UNCONST(v);
1.1       christos   61:
                     62:        if (v) {
                     63:                int             len = *cp;
                     64:                u_char         *cplim = cp + len;
                     65:
                     66:                /* return: "(len) hexdump" */
                     67:
1.3       itojun     68:                bp += snprintf(bp, sizeof(hexbuf), "(%d)", len);
1.1       christos   69:                for (cp++; cp < cplim && bp < hexbuf + 252; cp++) {
1.4       christos   70:                        *bp++ = hexdigits[*cp / 16];
                     71:                        *bp++ = hexdigits[*cp % 16];
1.1       christos   72:                }
                     73:        } else {
1.3       itojun     74:                bp += snprintf(bp, sizeof(hexbuf), "null");
1.1       christos   75:        }
                     76:        *bp = '\0';
                     77:
                     78:        return &hexbuf[0];
                     79: }
                     80:
                     81: static struct radix_node *
1.6     ! christos   82: at_addroute(const void *v_arg, const void *n_arg, struct radix_node_head * head,
1.1       christos   83:            struct radix_node * treenodes)
                     84: {
                     85:        struct radix_node *rn;
                     86:
                     87:        printf("at_addroute: v=%s\n", prsockaddr(v_arg));
                     88:        printf("at_addroute: n=%s\n", prsockaddr(n_arg));
1.6     ! christos   89:        printf("at_addroute: head=%p treenodes=%p\n", head, treenodes);
1.1       christos   90:
                     91:        rn = rn_addroute(v_arg, n_arg, head, treenodes);
                     92:
1.6     ! christos   93:        printf("at_addroute: returns rn=%p\n", rn);
1.1       christos   94:
                     95:        return rn;
                     96: }
                     97:
                     98: static struct radix_node *
1.6     ! christos   99: at_matroute(const void *v_arg, struct radix_node_head * head)
1.1       christos  100: {
                    101:        struct radix_node *rn;
                    102:
                    103:        printf("at_matroute: v=%s\n", prsockaddr(v_arg));
1.6     ! christos  104:        printf("at_matroute: head=%p\n", head);
1.1       christos  105:
                    106:        rn = rn_match(v_arg, head);
                    107:
1.6     ! christos  108:        printf("at_matroute: returns rn=%p\n", rn);
1.1       christos  109:
                    110:        return rn;
                    111: }
                    112:
                    113: static struct radix_node *
1.6     ! christos  114: at_lookup(const void *v_arg, const void *m_arg, struct radix_node_head * head)
1.1       christos  115: {
                    116:        struct radix_node *rn;
                    117:
                    118:        printf("at_lookup: v=%s\n", prsockaddr(v_arg));
                    119:        printf("at_lookup: n=%s\n", prsockaddr(m_arg));
1.6     ! christos  120:        printf("at_lookup: head=%p\n", head);
1.1       christos  121:
                    122:        rn = rn_lookup(v_arg, m_arg, head);
                    123:
1.6     ! christos  124:        printf("at_lookup: returns rn=%p\n", rn);
1.1       christos  125:
                    126:        return rn;
                    127: }
                    128:
                    129: static struct radix_node *
1.6     ! christos  130: at_delroute(const void *v_arg, const void *netmask_arg, struct radix_node_head * head)
1.1       christos  131: {
                    132:        struct radix_node *rn;
                    133:
                    134:        printf("at_delroute: v=%s\n", prsockaddr(v_arg));
                    135:        printf("at_delroute: n=%s\n", prsockaddr(netmask_arg));
1.6     ! christos  136:        printf("at_delroute: head=%p\n", head);
1.1       christos  137:
                    138:        rn = rn_delete(v_arg, netmask_arg, head);
                    139:
1.6     ! christos  140:        printf("at_delroute: returns rn=%p\n", rn);
1.1       christos  141:
                    142:        return rn;
                    143: }
                    144:
                    145: /*
                    146:  * Initialize our routing tree with debugging hooks.
                    147:  */
                    148: int
                    149: at_inithead(void **head, int off)
                    150: {
                    151:        struct radix_node_head *rnh;
                    152:
                    153:        if (!rn_inithead(head, off))
                    154:                return 0;
                    155:
                    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;
                    162: }

CVSweb <webmaster@jp.NetBSD.org>