]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/at_aarp.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _NETAT_AT_AARP_H_
26 #define _NETAT_AT_AARP_H_
27 #include <sys/appleapiopts.h>
29 * Copyright (c) 1988, 1989 Apple Computer, Inc.
32 /* "@(#)at_aarp.h: 2.0, 1.6; 10/4/93; Copyright 1988-89, Apple Computer, Inc." */
34 /* This is a header file for AARP.
36 * Author: R. C. Venkatraman
44 u_short hardware_type
;
45 u_short stack_type
; /* indicates appletalk or xns*/
46 u_char hw_addr_len
; /* len of hardware addr, e.g
47 * ethernet addr len, in bytes
49 u_char stack_addr_len
; /* protocol stack addr len,
50 * e.g., appletalk addr len
54 struct etalk_addr src_addr
;
55 struct atalk_addr src_at_addr
;
56 struct etalk_addr dest_addr
;
57 struct atalk_addr dest_at_addr
; /* desired or dest. at addr */
61 /* Constants currently defined in AARP */
63 #define AARP_AT_TYPE 0x80F3 /* indicates aarp packet */
64 #define AARP_ETHER_HW_TYPE 0x1
65 #define AARP_AT_PROTO 0x809B /* indicates stack type */
66 #define AARP_ETHER_ADDR_LEN 6 /* in bytes */
67 #define AARP_AT_ADDR_LEN 4 /* in bytes */
69 /* AARP cmd definitions */
71 #define AARP_REQ_CMD 0x1 /* address lookup request */
72 #define AARP_RESP_CMD 0x2 /* address match response */
73 #define AARP_PROBE_CMD 0x3 /* new kid probing... */
75 /* AARP timer and retry counts */
77 #define AARP_MAX_PROBE_RETRIES 20
78 #define AARP_PROBE_TIMER_INT HZ/30 /* HZ defines in param.h */
79 #define AARP_MAX_REQ_RETRIES 10
80 #define AARP_REQ_TIMER_INT HZ/30
81 #define AARP_MAX_NODES_TRIED 200 /* max no. of addresses tried */
82 /* on the same net before */
83 /* giving up on the net# */
84 #define AARP_MAX_NETS_TRIED 10 /* max no. of net nos tried */
85 /* before giving up on startup*/
89 #define PROBE_IDLE 0x1 /* There is no node addr */
90 #define PROBE_TENTATIVE 0x2 /* probing */
91 #define PROBE_DONE 0x3 /* an appletalk addr has been */
92 /* assigned for the given node*/
93 /* Errors returned by AARP routines */
94 #define AARP_ERR_NOT_OURS 1 /* not our appletalk address */
96 /*************************************************/
97 /* Declarations for AARP Address Map Table (AMT) */
98 /*************************************************/
101 struct atalk_addr dest_at_addr
;
102 struct etalk_addr dest_addr
;
103 char dummy
[2]; /* pad out to struct size of 32 */
104 time_t last_time
; /* the last time that this addr
105 * was used. Read in lbolt
106 * whenever the addr is used.
108 int no_of_retries
; /* number of times we've xmitted */
109 gbuf_t
*m
; /* ptr to msg blk to be sent out */
115 #define AMT_BSIZ 4 /* bucket size */
116 #define AMT_NB 64 /* number of buckets */
117 #define AMTSIZE (AMT_BSIZ * AMT_NB)
120 aarp_amt_t et_aarp_amt
[AMTSIZE
];
123 #define AMT_HASH(a) \
124 ((NET_VALUE(((struct atalk_addr *)&a)->atalk_net) + ((struct atalk_addr *)&a)->atalk_node) % AMT_NB)
126 #define AMT_LOOK(at, at_addr, elapp) { \
128 at = &aarp_table[elapp->ifPort]->et_aarp_amt[AMT_HASH(at_addr) * AMT_BSIZ]; \
129 for (n = 0 ; ; at++) { \
130 if (ATALK_EQUAL(at->dest_at_addr, at_addr)) \
132 if (++n >= AMT_BSIZ) { \
139 #define NEW_AMT(at, at_addr, elapp) { \
141 register aarp_amt_t *myat; \
142 myat = at = &aarp_table[elapp->ifPort]->et_aarp_amt[AMT_HASH(at_addr) * AMT_BSIZ]; \
143 for (n = 0 ; ; at++) { \
144 if (at->last_time == 0) \
146 if (++n >= AMT_BSIZ) { \
147 at = aarp_lru_entry(myat); \
153 #define AARP_NET_MCAST(p, elapp) \
154 (NET_VALUE((p)->dst_net) == elapp->ifThisNode.s_net) \
155 ) /* network-wide broadcast */
157 #define AARP_CABLE_MCAST(p) \
158 (NET_VALUE((p)->dst_net) == 0x0000 \
161 #define AARP_BROADCAST(p, elapp) \
162 (((p)->dst_node == 0xff) && \
164 (NET_VALUE((p)->dst_net) == 0x0000) || \
165 (NET_VALUE((p)->dst_net) == elapp->ifThisNode.s_net)) \
166 ) /* is this some kind of a broadcast address (?) */
169 #define ETHER_ADDR_EQUAL(addr1p, addr2p) \
171 ((addr1p)->etalk_addr_octet[0]==(addr2p)->etalk_addr_octet[0]) && \
172 ((addr1p)->etalk_addr_octet[1]==(addr2p)->etalk_addr_octet[1]) && \
173 ((addr1p)->etalk_addr_octet[2]==(addr2p)->etalk_addr_octet[2]) && \
174 ((addr1p)->etalk_addr_octet[3]==(addr2p)->etalk_addr_octet[3]) && \
175 ((addr1p)->etalk_addr_octet[4]==(addr2p)->etalk_addr_octet[4]) && \
176 ((addr1p)->etalk_addr_octet[5]==(addr2p)->etalk_addr_octet[5]) \
181 #ifdef __APPLE_API_PRIVATE
183 int aarp_chk_addr(at_ddp_t
*, at_ifaddr_t
*);
184 int aarp_rcv_pkt(aarp_pkt_t
*, at_ifaddr_t
*);
186 #endif /* __APPLE_API_PRIVATE */
189 #endif /* _NETAT_AT_AARP_H_ */