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