|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25:
26: /*
27: * Copyright (c) 1988, 1989 Apple Computer, Inc.
28: *
29: * The information contained herein is subject to change without
30: * notice and should not be construed as a commitment by Apple
31: * Computer, Inc. Apple Computer, Inc. assumes no responsibility
32: * for any errors that may appear.
33: *
34: * Confidential and Proprietary to Apple Computer, Inc.
35: */
36:
37: /* "@(#)at_aarp.h: 2.0, 1.6; 10/4/93; Copyright 1988-89, Apple Computer, Inc." */
38:
39: /* This is a header file for AARP.
40: *
41: * Author: R. C. Venkatraman
42: * Date : 3/2/88
43: *
44: */
45:
46: /* AARP packet */
47:
48: typedef struct {
49: u_short hardware_type;
50: u_short stack_type; /* indicates appletalk or xns*/
51: u_char hw_addr_len; /* len of hardware addr, e.g
52: * ethernet addr len, in bytes
53: */
54: u_char stack_addr_len; /* protocol stack addr len,
55: * e.g., appletalk addr len
56: * in bytes
57: */
58: u_short aarp_cmd;
59: struct etalk_addr src_addr;
60: struct atalk_addr src_at_addr;
61: struct etalk_addr dest_addr;
62: struct atalk_addr dest_at_addr; /* desired or dest. at addr */
63: } aarp_pkt_t;
64:
65:
66: /* Constants currently defined in AARP */
67:
68: #define AARP_AT_TYPE 0x80F3 /* indicates aarp packet */
69: #define AARP_ETHER_HW_TYPE 0x1
70: #define AARP_AT_PROTO 0x809B /* indicates stack type */
71: #define AARP_ETHER_ADDR_LEN 6 /* in bytes */
72: #define AARP_AT_ADDR_LEN 4 /* in bytes */
73:
74: /* AARP cmd definitions */
75:
76: #define AARP_REQ_CMD 0x1 /* address lookup request */
77: #define AARP_RESP_CMD 0x2 /* address match response */
78: #define AARP_PROBE_CMD 0x3 /* new kid probing... */
79:
80: /* AARP timer and retry counts */
81:
82: #define AARP_MAX_PROBE_RETRIES 20
83: #define AARP_PROBE_TIMER_INT HZ/30 /* HZ defines in param.h */
84: #define AARP_MAX_REQ_RETRIES 10
85: #define AARP_REQ_TIMER_INT HZ/30
86: #define AARP_MAX_NODES_TRIED 200 /* max no. of addresses tried */
87: /* on the same net before */
88: /* giving up on the net# */
89: #define AARP_MAX_NETS_TRIED 10 /* max no. of net nos tried */
90: /* before giving up on startup*/
91:
92: /* Probe states */
93:
94: #define PROBE_IDLE 0x1 /* There is no node addr */
95: #define PROBE_TENTATIVE 0x2 /* probing */
96: #define PROBE_DONE 0x3 /* an appletalk addr has been */
97: /* assigned for the given node*/
98: /* Errors returned by AARP routines */
99: #define AARP_ERR_NOT_OURS 1 /* not our appletalk address */
100:
101: /*************************************************/
102: /* Declarations for AARP Address Map Table (AMT) */
103: /*************************************************/
104:
105: typedef 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: elap_specifics_t *elapp;
116: int error;
117: void *tmo;
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:
124: #define AMT_HASH(a) \
125: ((NET_VALUE(((struct atalk_addr *)&a)->atalk_net) + ((struct atalk_addr *)&a)->atalk_node) % AMT_NB)
126:
127: #define AMT_LOOK(at, at_addr, elapp) { \
128: register n; \
129: at = &et_aarp_amt[elapp->pat_id][AMT_HASH(at_addr) * AMT_BSIZ]; \
130: for (n = 0 ; ; at++) { \
131: if (ATALK_EQUAL(at->dest_at_addr, at_addr)) \
132: break; \
133: if (++n >= AMT_BSIZ) { \
134: at = NULL; \
135: break; \
136: } \
137: } \
138: }
139:
140: #define NEW_AMT(at, at_addr, elapp) { \
141: register n; \
142: register aarp_amt_t *myat; \
143: myat = at = &et_aarp_amt[elapp->pat_id][AMT_HASH(at_addr) * AMT_BSIZ]; \
144: for (n = 0 ; ; at++) { \
145: if (at->last_time == 0) \
146: break; \
147: if (++n >= AMT_BSIZ) { \
148: at = aarp_lru_entry(myat); \
149: break; \
150: } \
151: } \
152: }
153:
154: #define AARP_NET_MCAST(p, elapp) \
155: (NET_EQUAL((p)->dst_net, elapp->elap_if.ifThisNode.atalk_net) \
156: ) /* network-wide broadcast */
157:
158: #define AARP_CABLE_MCAST(p) \
159: (NET_VALUE((p)->dst_net) == 0x0000 \
160: )
161:
162: #define AARP_BROADCAST(p, elapp) \
163: (((p)->dst_node == 0xff) && \
164: ( \
165: (NET_VALUE((p)->dst_net) == 0x0000) || \
166: (NET_EQUAL((p)->dst_net, elapp->elap_if.ifThisNode.atalk_net))) \
167: ) /* is this some kind of a broadcast address (?) */
168:
169:
170: #define ETHER_ADDR_EQUAL(addr1p, addr2p) \
171: (( \
172: ((addr1p)->etalk_addr_octet[0]==(addr2p)->etalk_addr_octet[0]) && \
173: ((addr1p)->etalk_addr_octet[1]==(addr2p)->etalk_addr_octet[1]) && \
174: ((addr1p)->etalk_addr_octet[2]==(addr2p)->etalk_addr_octet[2]) && \
175: ((addr1p)->etalk_addr_octet[3]==(addr2p)->etalk_addr_octet[3]) && \
176: ((addr1p)->etalk_addr_octet[4]==(addr2p)->etalk_addr_octet[4]) && \
177: ((addr1p)->etalk_addr_octet[5]==(addr2p)->etalk_addr_octet[5]) \
178: ) ? 1 : 0 \
179: )
180:
181: #ifdef _AIX
182: extern time_t lbolt;
183: #endif
184:
185: extern struct etalk_addr etalk_multicast_addr;
186: extern struct etalk_addr ttalk_multicast_addr;
187: extern struct etalk_addr zone_multicast_addr;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.