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