]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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 | #ifndef _NETAT_AT_AARP_H_ | |
23 | #define _NETAT_AT_AARP_H_ | |
24 | /* | |
25 | * Copyright (c) 1988, 1989 Apple Computer, Inc. | |
26 | */ | |
27 | ||
28 | /* "@(#)at_aarp.h: 2.0, 1.6; 10/4/93; Copyright 1988-89, Apple Computer, Inc." */ | |
29 | ||
30 | /* This is a header file for AARP. | |
31 | * | |
32 | * Author: R. C. Venkatraman | |
33 | * Date : 3/2/88 | |
34 | * | |
35 | */ | |
36 | ||
37 | /* AARP packet */ | |
38 | ||
39 | typedef struct { | |
40 | u_short hardware_type; | |
41 | u_short stack_type; /* indicates appletalk or xns*/ | |
42 | u_char hw_addr_len; /* len of hardware addr, e.g | |
43 | * ethernet addr len, in bytes | |
44 | */ | |
45 | u_char stack_addr_len; /* protocol stack addr len, | |
46 | * e.g., appletalk addr len | |
47 | * in bytes | |
48 | */ | |
49 | u_short aarp_cmd; | |
50 | struct etalk_addr src_addr; | |
51 | struct atalk_addr src_at_addr; | |
52 | struct etalk_addr dest_addr; | |
53 | struct atalk_addr dest_at_addr; /* desired or dest. at addr */ | |
54 | } aarp_pkt_t; | |
55 | ||
56 | ||
57 | /* Constants currently defined in AARP */ | |
58 | ||
59 | #define AARP_AT_TYPE 0x80F3 /* indicates aarp packet */ | |
60 | #define AARP_ETHER_HW_TYPE 0x1 | |
61 | #define AARP_AT_PROTO 0x809B /* indicates stack type */ | |
62 | #define AARP_ETHER_ADDR_LEN 6 /* in bytes */ | |
63 | #define AARP_AT_ADDR_LEN 4 /* in bytes */ | |
64 | ||
65 | /* AARP cmd definitions */ | |
66 | ||
67 | #define AARP_REQ_CMD 0x1 /* address lookup request */ | |
68 | #define AARP_RESP_CMD 0x2 /* address match response */ | |
69 | #define AARP_PROBE_CMD 0x3 /* new kid probing... */ | |
70 | ||
71 | /* AARP timer and retry counts */ | |
72 | ||
73 | #define AARP_MAX_PROBE_RETRIES 20 | |
74 | #define AARP_PROBE_TIMER_INT HZ/30 /* HZ defines in param.h */ | |
75 | #define AARP_MAX_REQ_RETRIES 10 | |
76 | #define AARP_REQ_TIMER_INT HZ/30 | |
77 | #define AARP_MAX_NODES_TRIED 200 /* max no. of addresses tried */ | |
78 | /* on the same net before */ | |
79 | /* giving up on the net# */ | |
80 | #define AARP_MAX_NETS_TRIED 10 /* max no. of net nos tried */ | |
81 | /* before giving up on startup*/ | |
82 | ||
83 | /* Probe states */ | |
84 | ||
85 | #define PROBE_IDLE 0x1 /* There is no node addr */ | |
86 | #define PROBE_TENTATIVE 0x2 /* probing */ | |
87 | #define PROBE_DONE 0x3 /* an appletalk addr has been */ | |
88 | /* assigned for the given node*/ | |
89 | /* Errors returned by AARP routines */ | |
90 | #define AARP_ERR_NOT_OURS 1 /* not our appletalk address */ | |
91 | ||
92 | /*************************************************/ | |
93 | /* Declarations for AARP Address Map Table (AMT) */ | |
94 | /*************************************************/ | |
95 | ||
96 | typedef struct { | |
97 | struct atalk_addr dest_at_addr; | |
98 | struct etalk_addr dest_addr; | |
99 | char dummy[2]; /* pad out to struct size of 32 */ | |
100 | time_t last_time; /* the last time that this addr | |
101 | * was used. Read in lbolt | |
102 | * whenever the addr is used. | |
103 | */ | |
104 | int no_of_retries; /* number of times we've xmitted */ | |
105 | gbuf_t *m; /* ptr to msg blk to be sent out */ | |
106 | at_ifaddr_t *elapp; | |
107 | int error; | |
108 | void *tmo; | |
109 | } aarp_amt_t; | |
110 | ||
111 | #define AMT_BSIZ 4 /* bucket size */ | |
112 | #define AMT_NB 64 /* number of buckets */ | |
113 | #define AMTSIZE (AMT_BSIZ * AMT_NB) | |
114 | ||
115 | typedef struct { | |
116 | aarp_amt_t et_aarp_amt[AMTSIZE]; | |
117 | } aarp_amt_array; | |
118 | ||
119 | #define AMT_HASH(a) \ | |
120 | ((NET_VALUE(((struct atalk_addr *)&a)->atalk_net) + ((struct atalk_addr *)&a)->atalk_node) % AMT_NB) | |
121 | ||
122 | #define AMT_LOOK(at, at_addr, elapp) { \ | |
123 | register n; \ | |
124 | at = &aarp_table[elapp->ifPort]->et_aarp_amt[AMT_HASH(at_addr) * AMT_BSIZ]; \ | |
125 | for (n = 0 ; ; at++) { \ | |
126 | if (ATALK_EQUAL(at->dest_at_addr, at_addr)) \ | |
127 | break; \ | |
128 | if (++n >= AMT_BSIZ) { \ | |
129 | at = NULL; \ | |
130 | break; \ | |
131 | } \ | |
132 | } \ | |
133 | } | |
134 | ||
135 | #define NEW_AMT(at, at_addr, elapp) { \ | |
136 | register n; \ | |
137 | register aarp_amt_t *myat; \ | |
138 | myat = at = &aarp_table[elapp->ifPort]->et_aarp_amt[AMT_HASH(at_addr) * AMT_BSIZ]; \ | |
139 | for (n = 0 ; ; at++) { \ | |
140 | if (at->last_time == 0) \ | |
141 | break; \ | |
142 | if (++n >= AMT_BSIZ) { \ | |
143 | at = aarp_lru_entry(myat); \ | |
144 | break; \ | |
145 | } \ | |
146 | } \ | |
147 | } | |
148 | ||
149 | #define AARP_NET_MCAST(p, elapp) \ | |
150 | (NET_VALUE((p)->dst_net) == elapp->ifThisNode.s_net) \ | |
151 | ) /* network-wide broadcast */ | |
152 | ||
153 | #define AARP_CABLE_MCAST(p) \ | |
154 | (NET_VALUE((p)->dst_net) == 0x0000 \ | |
155 | ) | |
156 | ||
157 | #define AARP_BROADCAST(p, elapp) \ | |
158 | (((p)->dst_node == 0xff) && \ | |
159 | ( \ | |
160 | (NET_VALUE((p)->dst_net) == 0x0000) || \ | |
161 | (NET_VALUE((p)->dst_net) == elapp->ifThisNode.s_net)) \ | |
162 | ) /* is this some kind of a broadcast address (?) */ | |
163 | ||
164 | ||
165 | #define ETHER_ADDR_EQUAL(addr1p, addr2p) \ | |
166 | (( \ | |
167 | ((addr1p)->etalk_addr_octet[0]==(addr2p)->etalk_addr_octet[0]) && \ | |
168 | ((addr1p)->etalk_addr_octet[1]==(addr2p)->etalk_addr_octet[1]) && \ | |
169 | ((addr1p)->etalk_addr_octet[2]==(addr2p)->etalk_addr_octet[2]) && \ | |
170 | ((addr1p)->etalk_addr_octet[3]==(addr2p)->etalk_addr_octet[3]) && \ | |
171 | ((addr1p)->etalk_addr_octet[4]==(addr2p)->etalk_addr_octet[4]) && \ | |
172 | ((addr1p)->etalk_addr_octet[5]==(addr2p)->etalk_addr_octet[5]) \ | |
173 | ) ? 1 : 0 \ | |
174 | ) | |
175 | ||
176 | #ifdef KERNEL | |
177 | ||
178 | int aarp_chk_addr(at_ddp_t *, at_ifaddr_t *); | |
179 | int aarp_rcv_pkt(aarp_pkt_t *, at_ifaddr_t *); | |
180 | ||
181 | #endif /* KERNEL */ | |
182 | ||
183 | #endif /* _NETAT_AT_AARP_H_ */ |