Annotation of kernel/bsd/netat/ddp_brt.c, revision 1.1.1.1

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) 1988, 1989 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: 
                     36: 
                     37: /*
                     38:  * Title:      ddp_brt.c
                     39:  *
                     40:  * Facility:   Best Router Caching.
                     41:  *
                     42:  * Author:     Kumar Vora, Creation Date: June-15-1989
                     43:  *
                     44:  */
                     45: 
                     46: #include <sysglue.h>
                     47: #include <at/appletalk.h>
                     48: #include <at/ddp.h>
                     49: #include <at/elap.h>
                     50: #include <at/at_lap.h>
                     51: #include <at_ddp.h>
                     52: #include <at_ddp_brt.h>
                     53: #include <atlog.h>
                     54: 
                     55: 
                     56: extern void *atalk_timeout();
                     57: extern void atalk_untimeout();
                     58: static void *sweep_tmo;
                     59: 
                     60: /* Best Router Cache */
                     61: ddp_brt_t      at_ddp_brt[BRTSIZE];
                     62: static u_long  ddp_brt_sweep_timer;
                     63: 
                     64: void
                     65: ddp_glean(mp, ifID, src_addr)
                     66: register gbuf_t          *mp;
                     67: register at_if_t  *ifID;
                     68: struct etalk_addr  *src_addr;
                     69: {
                     70:        register at_net_al           src_net;
                     71: 
                     72:        /* NOT assuming that the incoming packet is in one contiguous
                     73:         * buffer.
                     74:         */
                     75: 
                     76:        {
                     77:                /* The interface is ethertalk, so the message is
                     78:                 * of the form {802.3, 802.2, ddp.... }. Extract the
                     79:                 * 802.3 source address if necessary.  Assuming, 
                     80:                 * however, that 802.3 and 802.2 headers are in
                     81:                 * one contiguous piece.
                     82:                 */
                     83:                {       register at_ddp_t    *dgp;
                     84: 
                     85:                        dgp = (at_ddp_t *)(gbuf_rptr(mp));
                     86:                        src_net = NET_VALUE(dgp->src_net);
                     87:                }
                     88:                if (src_net >= ifID->ifThisCableStart && src_net <= ifID->ifThisCableEnd) 
                     89:                        /* the packet has come from a net on this cable,
                     90:                         * no need to glean router info.
                     91:                         */
                     92:                        return;
                     93: 
                     94:                if (src_addr != NULL)
                     95:                {       register ddp_brt_t   *brt;
                     96: 
                     97:                        BRT_LOOK (brt, src_net);
                     98:                        if (brt == NULL) {
                     99:                                /* There's no BRT entry corresponding to this 
                    100:                                 * net. Allocate a new entry.
                    101:                                 */
                    102:                                NEW_BRT(brt, src_net);
                    103:                                if (brt == NULL)
                    104:                                        /* No space available in the BRT; 
                    105:                                         * can't glean info.
                    106:                                         */
                    107:                                        return;
                    108:                                brt->net = src_net;
                    109:                        }
                    110:                        /*
                    111:                         * update the router info in either case
                    112:                         */
                    113:                        brt->et_addr = *src_addr;
                    114:                        brt->age_flag = BRT_VALID;
                    115:                        brt->ifID = ifID;
                    116:                }
                    117:        }
                    118: }
                    119: 
                    120: 
                    121: static void    ddp_brt_sweep();
                    122: 
                    123: void
                    124: ddp_brt_init()
                    125: {
                    126:        bzero(at_ddp_brt, sizeof(at_ddp_brt));
                    127:        ddp_brt_sweep_timer = 1;
                    128:        sweep_tmo = atalk_timeout(ddp_brt_sweep, (long)0, BRT_SWEEP_INT * SYS_HZ);
                    129: }
                    130: 
                    131: void
                    132: ddp_brt_shutdown()
                    133: {
                    134:        bzero(at_ddp_brt, sizeof(at_ddp_brt));
                    135:        if (ddp_brt_sweep_timer)
                    136:                atalk_untimeout(ddp_brt_sweep, 0, sweep_tmo);
                    137:        ddp_brt_sweep_timer = 0;
                    138: }
                    139: 
                    140: StaticProc void
                    141: ddp_brt_sweep ()
                    142: {
                    143:         register ddp_brt_t      *brt;
                    144:        register int            i;
                    145: 
                    146:        brt = at_ddp_brt;
                    147:        for (i = 0; i < BRTSIZE; i++, brt++) {
                    148:                switch (brt->age_flag) {
                    149:                case BRT_EMPTY :
                    150:                        break;
                    151:                case BRT_VALID :
                    152:                        brt->age_flag = BRT_GETTING_OLD;
                    153:                        break;
                    154:                case BRT_GETTING_OLD :
                    155:                        bzero(brt, sizeof(ddp_brt_t));
                    156:                        break;
                    157:                default :
                    158:                        ATTRACE(AT_MID_DDP,AT_SID_RESOURCE, AT_LV_ERROR, FALSE,
                    159:                                "ddp_brt_sweep : corrupt age flag %d", 
                    160:                                brt->age_flag, 0,0);
                    161:                        break;
                    162:                }
                    163:        }
                    164:        
                    165:        /* set up the next sweep... */
                    166:        sweep_tmo = atalk_timeout(ddp_brt_sweep, (long)0, BRT_SWEEP_INT * SYS_HZ);
                    167: }
                    168: 
                    169: 
                    170: 
                    171: 

unix.superglobalmegacorp.com

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