|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* ! 26: * Copyright (c) 1996 Apple Computer, Inc. ! 27: * ! 28: * The information contained herein is subject to change without ! 29: * notice and should not be construed as a commitment by Apple ! 30: * Computer, Inc. Apple Computer, Inc. assumes no responsibility ! 31: * for any errors that may appear. ! 32: * ! 33: * Confidential and Proprietary to Apple Computer, Inc. ! 34: * ! 35: * File: tx.c ! 36: */ ! 37: #include <sysglue.h> ! 38: #include <at/appletalk.h> ! 39: #include <lap.h> ! 40: #include <routing_tables.h> ! 41: #define _AURP ! 42: #define _KERNSYS ! 43: #include <at/aurp.h> ! 44: #include <at_aurp.h> ! 45: ! 46: /* ! 47: * Any AURP protocol or appletalk data (ddp) packets flowing through ! 48: * are inserted into the kernel aurpd process's (atalk) input queue. ! 49: * Assume here that we deal with single packets, i.e., someone earlier ! 50: * in the food chain has broken up packet chains. ! 51: */ ! 52: void AURPsend(mdata, type, node) ! 53: gbuf_t *mdata; ! 54: int type, node; ! 55: { ! 56: struct domain *domain; ! 57: aurp_hdr_t *hdr; ! 58: gbuf_t *m; ! 59: int msize = AT_WR_OFFSET+32+IP_DOMAINSIZE; ! 60: ! 61: /* Add the domain header */ ! 62: if ((m = gbuf_alloc(msize, PRI_MED)) == 0) { ! 63: gbuf_freem(mdata); ! 64: return; ! 65: } ! 66: gbuf_wset(m,msize); ! 67: gbuf_rinc(m,AT_WR_OFFSET+32); ! 68: gbuf_cont(m) = mdata; ! 69: domain = (struct domain *)gbuf_rptr(m); ! 70: domain->dst_length = IP_LENGTH; ! 71: domain->dst_authority = IP_AUTHORITY; ! 72: domain->dst_distinguisher = IP_DISTINGUISHER; ! 73: domain->src_length = IP_LENGTH; ! 74: domain->src_authority = IP_AUTHORITY; ! 75: domain->src_distinguisher = IP_DISTINGUISHER; ! 76: domain->src_address = aurp_global.src_addr; ! 77: domain->version = AUD_Version; ! 78: domain->reserved = 0; ! 79: domain->type = type; ! 80: domain->dst_address = aurp_global.dst_addr[node]; ! 81: atalk_to_ip(m); ! 82: } ! 83: ! 84: /* ! 85: * Called from within ddp (via ddp_AURPsendx) to handle data (DDP) packets ! 86: * sent from the AppleTalk stack, routing updates, and routing info ! 87: * initialization. ! 88: */ ! 89: void AURPcmdx(code, mdata, param) ! 90: int code; ! 91: gbuf_t *mdata; ! 92: int param; ! 93: { ! 94: unsigned char node; ! 95: gbuf_t *mdata_next; ! 96: aurp_rtinfo_t *rtinfo; ! 97: ! 98: if (mdata == 0) ! 99: return; ! 100: if (aurp_gref == 0) { ! 101: if ((code != AURPCODE_RTINFO) && (code != AURPCODE_DEBUGINFO)) ! 102: AURPfreemsg(mdata); ! 103: return; ! 104: } ! 105: ! 106: switch (code) { ! 107: case AURPCODE_DATAPKT: /* data packet */ ! 108: node = (unsigned char)param; ! 109: if (gbuf_next(mdata)) { ! 110: mdata_next = gbuf_next(mdata); ! 111: gbuf_next(mdata) = 0; ! 112: AURPsend(mdata, AUD_Atalk, node); ! 113: do { ! 114: mdata = mdata_next; ! 115: mdata_next = gbuf_next(mdata); ! 116: gbuf_next(mdata) = 0; ! 117: /* Indicate non-AURP packet, node id of peer */ ! 118: AURPsend(mdata, AUD_Atalk, node); ! 119: } while (mdata_next); ! 120: } else ! 121: AURPsend(mdata, AUD_Atalk, node); ! 122: break; ! 123: ! 124: case AURPCODE_RTUPDATE: ! 125: AURPrtupdate(mdata, param); ! 126: break; ! 127: ! 128: case AURPCODE_RTINFO: /* routing info */ ! 129: rtinfo = (aurp_rtinfo_t *)mdata; ! 130: RT_table = (RT_entry *)rtinfo->RT_table; ! 131: ZT_table = (ZT_entry *)rtinfo->ZT_table; ! 132: RT_maxentry = rtinfo->RT_maxentry; ! 133: ZT_maxentry = rtinfo->ZT_maxentry; ! 134: RT_lock = rtinfo->rt_lock; ! 135: RT_insert = (RT_entry *(*)())rtinfo->rt_insert; ! 136: RT_delete = (RT_entry *(*)())rtinfo->rt_delete; ! 137: RT_lookup = (RT_entry *(*)())rtinfo->rt_lookup; ! 138: ZT_add_zname = (int (*)())rtinfo->zt_add_zname; ! 139: ZT_set_zmap = (void (*)())rtinfo->zt_set_zmap; ! 140: ZT_get_zindex = (int (*)())rtinfo->zt_get_zindex; ! 141: ZT_remove_zones = (void (*)())rtinfo->zt_remove_zones; ! 142: break; ! 143: ! 144: case AURPCODE_DEBUGINFO: /* debug info */ ! 145: dbgBits = *(dbgBits_t *)mdata; ! 146: net_port = param; ! 147: break; ! 148: ! 149: default: ! 150: dPrintf(D_M_AURP, D_L_ERROR, ("AURPcmdx: bad code, %d\n", code)); ! 151: } ! 152: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.