Annotation of XNU/bsd/netat/aurp_tx.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  *     Copyright (c) 1996 Apple Computer, Inc. 
        !            24:  *
        !            25:  *             Created April 8, 1996 by Tuyen Nguyen
        !            26:  *   Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
        !            27:  *
        !            28:  *     File: tx.c
        !            29:  */
        !            30: #include <sys/errno.h>
        !            31: #include <sys/types.h>
        !            32: #include <sys/param.h>
        !            33: #include <machine/spl.h>
        !            34: #include <sys/systm.h>
        !            35: #include <sys/kernel.h>
        !            36: #include <sys/proc.h>
        !            37: #include <sys/filedesc.h>
        !            38: #include <sys/fcntl.h>
        !            39: #include <sys/mbuf.h>
        !            40: #include <sys/socket.h>
        !            41: #include <sys/socketvar.h>
        !            42: #include <net/if.h>
        !            43: 
        !            44: #include <netat/sysglue.h>
        !            45: #include <netat/appletalk.h>
        !            46: #include <netat/at_var.h>
        !            47: #include <netat/routing_tables.h>
        !            48: #include <netat/at_pcb.h>
        !            49: #include <netat/aurp.h>
        !            50: #include <netat/debug.h>
        !            51: 
        !            52: /*
        !            53:  * Any AURP protocol or appletalk data (ddp) packets flowing through
        !            54:  *  are inserted into the kernel aurpd process's (atalk) input queue.
        !            55:  * Assume here that we deal with single packets, i.e., someone earlier
        !            56:  *  in the food chain has broken up packet chains.
        !            57:  */
        !            58: void AURPsend(mdata, type, node)
        !            59:        gbuf_t *mdata;
        !            60:        int type, node;
        !            61: {
        !            62:        struct aurp_domain *domain;
        !            63:        gbuf_t *m;
        !            64:        int msize = AT_WR_OFFSET+32+IP_DOMAINSIZE;
        !            65: 
        !            66:        /* Add the domain header */
        !            67:        if ((m = gbuf_alloc(msize, PRI_MED)) == 0) {
        !            68:                gbuf_freem(mdata);
        !            69:                dPrintf(D_M_AURP, D_L_WARNING, ("AURPsend: gbuf_alloc failed\n"));
        !            70:                return;
        !            71:        }
        !            72:        gbuf_wset(m,msize);
        !            73:        gbuf_rinc(m,AT_WR_OFFSET+32);
        !            74:        gbuf_cont(m) = mdata;
        !            75:        domain = (struct aurp_domain *)gbuf_rptr(m);
        !            76:        domain->dst_length = IP_LENGTH;
        !            77:        domain->dst_authority = IP_AUTHORITY;
        !            78:        domain->dst_distinguisher = IP_DISTINGUISHER;
        !            79:        domain->src_length = IP_LENGTH;
        !            80:        domain->src_authority = IP_AUTHORITY;
        !            81:        domain->src_distinguisher = IP_DISTINGUISHER;
        !            82:        domain->src_address = aurp_global.src_addr;
        !            83:        domain->version = AUD_Version;
        !            84:        domain->reserved = 0;
        !            85:        domain->type = type;
        !            86:        domain->dst_address = aurp_global.dst_addr[node];
        !            87:        atalk_to_ip(m);
        !            88: }
        !            89: 
        !            90: /*
        !            91:  * Called from within ddp (via ddp_AURPsendx) to handle data (DDP) packets
        !            92:  *  sent from the AppleTalk stack, routing updates, and routing info
        !            93:  *  initialization.
        !            94:  */
        !            95: void AURPcmdx(code, mdata, param)
        !            96:        int code;
        !            97:        gbuf_t *mdata;
        !            98:        int param;
        !            99: {
        !           100:        unsigned char node;
        !           101:        gbuf_t *mdata_next;
        !           102: 
        !           103:        if (mdata == 0)
        !           104:                return;
        !           105:        if (aurp_gref == 0) {
        !           106:                if (code != AURPCODE_DEBUGINFO)
        !           107:                        AURPfreemsg(mdata);
        !           108:                return;
        !           109:        }
        !           110: 
        !           111:        switch (code) {
        !           112:        case AURPCODE_DATAPKT: /* data packet */
        !           113:                node = (unsigned char)param;
        !           114:                if (gbuf_next(mdata)) {
        !           115:                        mdata_next = gbuf_next(mdata);
        !           116:                        gbuf_next(mdata) = 0;
        !           117:                        AURPsend(mdata, AUD_Atalk, node);
        !           118:                        do {
        !           119:                                mdata = mdata_next;
        !           120:                                mdata_next = gbuf_next(mdata);
        !           121:                                gbuf_next(mdata) = 0;
        !           122:                                /* Indicate non-AURP packet, node id of peer */
        !           123:                                AURPsend(mdata, AUD_Atalk, node);
        !           124:                        } while (mdata_next);
        !           125:                } else
        !           126:                        AURPsend(mdata, AUD_Atalk, node);
        !           127:                break;
        !           128: 
        !           129:        case AURPCODE_RTUPDATE:
        !           130:                AURPrtupdate((RT_entry *)mdata, param);
        !           131:                break;
        !           132: 
        !           133:        case AURPCODE_DEBUGINFO: /* debug info */
        !           134:                dbgBits = *(dbgBits_t *)mdata;
        !           135:                net_port = param;
        !           136:                break;
        !           137: 
        !           138:        default:
        !           139:                dPrintf(D_M_AURP, D_L_ERROR, ("AURPcmdx: bad code, %d\n", code));
        !           140:        }
        !           141: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.