Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | /* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _NETAT_AT_AARP_H_ #define _NETAT_AT_AARP_H_ #include <sys/appleapiopts.h> #ifdef KERNEL_PRIVATE #include <netat/at_var.h> #endif KERNEL_PRIVATE #ifdef __APPLE_API_OBSOLETE /* * Copyright (c) 1988, 1989 Apple Computer, Inc. */ /* "@(#)at_aarp.h: 2.0, 1.6; 10/4/93; Copyright 1988-89, Apple Computer, Inc." */ /* This is a header file for AARP. * * Author: R. C. Venkatraman * Date : 3/2/88 * */ /* AARP packet */ typedef struct { u_short hardware_type; u_short stack_type; /* indicates appletalk or xns*/ u_char hw_addr_len; /* len of hardware addr, e.g * ethernet addr len, in bytes */ u_char stack_addr_len; /* protocol stack addr len, * e.g., appletalk addr len * in bytes */ u_short aarp_cmd; struct etalk_addr src_addr; struct atalk_addr src_at_addr; struct etalk_addr dest_addr; struct atalk_addr dest_at_addr; /* desired or dest. at addr */ } aarp_pkt_t; /* Constants currently defined in AARP */ #define AARP_AT_TYPE 0x80F3 /* indicates aarp packet */ #define AARP_ETHER_HW_TYPE 0x1 #define AARP_AT_PROTO 0x809B /* indicates stack type */ #define AARP_ETHER_ADDR_LEN 6 /* in bytes */ #define AARP_AT_ADDR_LEN 4 /* in bytes */ /* AARP cmd definitions */ #define AARP_REQ_CMD 0x1 /* address lookup request */ #define AARP_RESP_CMD 0x2 /* address match response */ #define AARP_PROBE_CMD 0x3 /* new kid probing... */ /* AARP timer and retry counts */ #define AARP_MAX_PROBE_RETRIES 20 #define AARP_PROBE_TIMER_INT HZ/30 /* HZ defines in param.h */ #define AARP_MAX_REQ_RETRIES 10 #define AARP_REQ_TIMER_INT HZ/30 #define AARP_MAX_NODES_TRIED 200 /* max no. of addresses tried */ /* on the same net before */ /* giving up on the net# */ #define AARP_MAX_NETS_TRIED 10 /* max no. of net nos tried */ /* before giving up on startup*/ /* Probe states */ #define PROBE_IDLE 0x1 /* There is no node addr */ #define PROBE_TENTATIVE 0x2 /* probing */ #define PROBE_DONE 0x3 /* an appletalk addr has been */ /* assigned for the given node*/ /* Errors returned by AARP routines */ #define AARP_ERR_NOT_OURS 1 /* not our appletalk address */ #ifdef KERNEL_PRIVATE /*************************************************/ /* Declarations for AARP Address Map Table (AMT) */ /*************************************************/ typedef struct { struct atalk_addr dest_at_addr; /* net# in network byte order */ struct etalk_addr dest_addr; char dummy[2]; /* pad out to struct size of 32 */ time_t last_time; /* the last time that this addr * was used. Read in lbolt * whenever the addr is used. */ int no_of_retries; /* number of times we've xmitted */ gbuf_t *m; /* ptr to msg blk to be sent out */ at_ifaddr_t *elapp; int error; int tmo; } aarp_amt_t; #define AMT_BSIZ 4 /* bucket size */ #define AMT_NB 64 /* number of buckets */ #define AMTSIZE (AMT_BSIZ * AMT_NB) typedef struct { aarp_amt_t et_aarp_amt[AMTSIZE]; } aarp_amt_array; #define AMT_HASH(a) \ ((NET_VALUE(((struct atalk_addr *)&a)->atalk_net) + ((struct atalk_addr *)&a)->atalk_node) % AMT_NB) /* at_addr - net # in network byte order */ #define AMT_LOOK(at, at_addr, elapp) { \ int n; \ at = &aarp_table[elapp->ifPort]->et_aarp_amt[AMT_HASH(at_addr) * AMT_BSIZ]; \ for (n = 0 ; ; at++) { \ if (at->dest_at_addr.atalk_node == (at_addr).atalk_node && \ NET_EQUAL(at->dest_at_addr.atalk_net, (at_addr).atalk_net)) \ break; \ if (++n >= AMT_BSIZ) { \ at = NULL; \ break; \ } \ } \ } /* at_addr - net # in network byte order */ #define NEW_AMT(at, at_addr, elapp) { \ int n; \ aarp_amt_t *myat; \ myat = at = &aarp_table[elapp->ifPort]->et_aarp_amt[AMT_HASH(at_addr) * AMT_BSIZ]; \ for (n = 0 ; ; at++) { \ if (at->last_time == 0) \ break; \ if (++n >= AMT_BSIZ) { \ at = aarp_lru_entry(myat); \ break; \ } \ } \ } #define AARP_NET_MCAST(p, elapp) \ (NET_VALUE((p)->dst_net) == elapp->ifThisNode.s_net) \ ) /* network-wide broadcast */ #define AARP_CABLE_MCAST(p) \ (NET_VALUE((p)->dst_net) == 0x0000 \ ) #define AARP_BROADCAST(p, elapp) \ (((p)->dst_node == 0xff) && \ ( \ (NET_VALUE((p)->dst_net) == 0x0000) || \ (NET_VALUE((p)->dst_net) == elapp->ifThisNode.s_net)) \ ) /* is this some kind of a broadcast address (?) */ #define ETHER_ADDR_EQUAL(addr1p, addr2p) \ (( \ ((addr1p)->etalk_addr_octet[0]==(addr2p)->etalk_addr_octet[0]) && \ ((addr1p)->etalk_addr_octet[1]==(addr2p)->etalk_addr_octet[1]) && \ ((addr1p)->etalk_addr_octet[2]==(addr2p)->etalk_addr_octet[2]) && \ ((addr1p)->etalk_addr_octet[3]==(addr2p)->etalk_addr_octet[3]) && \ ((addr1p)->etalk_addr_octet[4]==(addr2p)->etalk_addr_octet[4]) && \ ((addr1p)->etalk_addr_octet[5]==(addr2p)->etalk_addr_octet[5]) \ ) ? 1 : 0 \ ) int aarp_chk_addr(at_ddp_t *, at_ifaddr_t *); int aarp_rcv_pkt(aarp_pkt_t *, at_ifaddr_t *); void AARPwakeup(aarp_amt_t *); int aarp_send_data(gbuf_t *, at_ifaddr_t *, struct atalk_addr *, int); #endif /* KERNEL_PRIVATE */ #endif /* __APPLE_API_OBSOLETE */ #endif /* _NETAT_AT_AARP_H_ */ |