home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / netat / at_ddp_brt.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  2.6 KB  |  83 lines

  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. /*
  24.  *    Copyright (c) 1988, 1989 Apple Computer, Inc. 
  25.  */
  26.  
  27. #ifndef _NETAT_AT_DDP_BRT_H_
  28. #define _NETAT_AT_DDP_BRT_H_
  29.  
  30. typedef struct {
  31.     int                 age_flag;
  32.     at_ifaddr_t            *ifID;
  33.     struct    etalk_addr        et_addr;
  34.     at_net_al            net;
  35. } ddp_brt_t;
  36.  
  37. #define BRT_SWEEP_INT        (10 * PR_SLOWHZ)
  38. #define    BRT_BSIZ         4    /* bucket size */
  39. #define    BRT_NB            16    /* number of buckets */
  40. #define    BRTSIZE            (BRT_BSIZ * BRT_NB)
  41.  
  42. /* age_flag values */
  43. #define    BRT_EMPTY        0    /* the BRT entry is empty     */
  44.                     /* (or aged out).             */
  45. #define    BRT_VALID        1    /* BRT entry contains valid   */
  46.                     /* tuple               */
  47. #define    BRT_GETTING_OLD        2    /* BRT entry is a candidate   */
  48.                     /* for aging              */
  49.  
  50. #define    BRT_HASH(a)   ((a) % BRT_NB)
  51.  
  52. #define    BRT_LOOK(brt, dst_net) {                \
  53.     register n;                         \
  54.     brt = &at_ddp_brt[BRT_HASH(dst_net) * BRT_BSIZ];    \
  55.     for (n = 0 ; ; brt++) {                                \
  56.         if (brt->net == dst_net)             \
  57.             break;                     \
  58.         if (++n >= BRT_BSIZ) {                          \
  59.                 brt = NULL;                             \
  60.             break;                                  \
  61.         }                                               \
  62.     }                                                       \
  63.     }
  64.  
  65. #define    NEW_BRT(brt, net) {                    \
  66.     register n;                         \
  67.     brt = &at_ddp_brt[BRT_HASH(net) * BRT_BSIZ];         \
  68.     for (n = 0 ; ; brt++) {                         \
  69.         if (brt->age_flag == BRT_EMPTY)            \
  70.             break;                     \
  71.         if (++n >= BRT_BSIZ) {                \
  72.                 brt = NULL;                \
  73.             break;                                  \
  74.         }                                               \
  75.         }                                                       \
  76.     }
  77.  
  78. /* Best Router Cache */
  79. extern    ddp_brt_t    at_ddp_brt[BRTSIZE];
  80.  
  81. #endif /* _NETAT_AT_DDP_BRT_H_ */
  82.  
  83.