xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/snoop/at.h (revision 0fb96ba1f1ce26ff8b286f8f928769a6afcb00a6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  *
26  */
27 
28 #ifndef _AT_H
29 #define	_AT_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * There is a lot of alignment problems in AppleTalk packets.
37  * This is the reason some of the headers use uint8_t arrays instead of the
38  * natural datatype.
39  */
40 
41 /* AARP */
42 
43 #define	AARP_REQ		1
44 #define	AARP_RESP		2
45 #define	AARP_PROBE		3
46 
47 
48 /* DDP */
49 
50 struct ddp_hdr {
51 	uint8_t		ddp_hop_len;
52 	uint8_t		ddp_len_lo;
53 	uint16_t	ddp_cksum;
54 	uint16_t	ddp_dest_net;
55 	uint16_t	ddp_src_net;
56 	uint8_t		ddp_dest_id;
57 	uint8_t		ddp_src_id;
58 	uint8_t		ddp_dest_sock;
59 	uint8_t		ddp_src_sock;
60 	uint8_t		ddp_type;
61 };
62 
63 #define	ddp_pad(x)	((x)->ddp_hop_len & 0xc0)
64 #define	ddp_hop(x)	(((x)->ddp_hop_len >> 2) & 0xf)
65 #define	ddp_len(x)	((((x)->ddp_hop_len & 0x3) << 8) + (x)->ddp_len_lo)
66 
67 #define	DDPHDR_SIZE 13
68 
69 #define	DDP_TYPE_RTMPRQ		5
70 #define	DDP_TYPE_RTMPRESP	1
71 #define	DDP_TYPE_NBP		2
72 #define	DDP_TYPE_ATP		3
73 #define	DDP_TYPE_AEP		4
74 #define	DDP_TYPE_ZIP		6
75 #define	DDP_TYPE_ADSP		7
76 
77 
78 /* AECHO */
79 
80 #define	AEP_REQ			1
81 #define	AEP_REPLY		2
82 
83 /* NBP */
84 
85 struct nbp_hdr {
86 	uint8_t		ddphdr[DDPHDR_SIZE];
87 	uint8_t		nbp_fun_cnt;
88 	uint8_t		nbp_id;
89 };
90 
91 #define	NBP_BRRQ		1
92 #define	NBP_LKUP		2
93 #define	NBP_LKUP_REPLY		3
94 #define	NBP_FWDREQ		4
95 
96 
97 /* ZIP */
98 
99 struct zip_hdr {
100 	uint8_t		ddphdr[DDPHDR_SIZE];
101 	uint8_t		zip_func;
102 	uint8_t		zip_netcnt;
103 };
104 
105 #define	ZIP_QUERY		1
106 #define	ZIP_REPLY		2
107 #define	ZIP_GET_NET_INFO	5
108 #define	ZIP_GET_NET_INFO_REPLY	6
109 #define	ZIP_NOTIFY		7
110 #define	ZIP_EXT_REPLY		8
111 
112 #define	ZIP_ATP_GETMYZONE	7
113 #define	ZIP_ATP_GETZONELIST	8
114 #define	ZIP_ATP_GETLOCALZONES	9
115 
116 #define	ZIP_FLG_ONEZ		0x20
117 #define	ZIP_FLG_USEBRC		0x40
118 #define	ZIP_FLG_ZINV		0x80
119 
120 
121 /* ATP */
122 
123 struct atp_hdr {
124 	uint8_t		ddphdr[DDPHDR_SIZE];
125 	uint8_t		atp_ctrl;
126 	uint8_t		atp_seq;
127 	uint8_t		atp_tid[2];
128 	uint8_t		atp_user[4];
129 };
130 
131 #define	ATPHDR_SIZE	8
132 
133 #define	atp_fun(x)	(((x) >> 6) & 0x3)
134 #define	atp_tmo(x)	((x) & 0x7)
135 
136 #define	ATP_TREQ		1
137 #define	ATP_TRESP		2
138 #define	ATP_TREL		3
139 #define	ATP_FLG_STS		0x08
140 #define	ATP_FLG_EOM		0x10
141 #define	ATP_FLG_XO		0x20
142 
143 
144 #define	NODE_ID_BROADCAST	0xff
145 
146 struct ddp_adsphdr {
147 	uint8_t	ddphdr[DDPHDR_SIZE];
148 	uint8_t	ad_connid[2];		/* short */
149 	uint8_t	ad_fbseq[4];		/* long */
150 	uint8_t	ad_nrseq[4];		/* long */
151 	uint8_t	ad_rcvwin[2];		/* short */
152 	uint8_t	ad_desc;
153 };
154 
155 #define	AD_CTRL		0x80
156 #define	AD_ACKREQ	0x40
157 #define	AD_EOM		0x20
158 #define	AD_ATT		0x10
159 #define	AD_CTRL_MASK	0x0f
160 
161 #define	AD_CREQ		0x81		/* Open Conn Request */
162 #define	AD_CACK		0x82		/* Open Conn Ack */
163 #define	AD_CREQ_ACK	0x83		/* Open Conn Req+Ack */
164 #define	AD_CDENY	0x84		/* Open Conn Denial */
165 
166 struct ddp_adsp_att {
167 	struct ddp_adsphdr	ad;
168 	uint8_t		ad_att_code[2];	/* short */
169 };
170 
171 struct ddp_adsp_open {
172 	struct ddp_adsphdr	ad;
173 	uint8_t		ad_version[2];	/* short */
174 	uint8_t		ad_dconnid[2];	/* short */
175 	uint8_t		ad_attseq[4];	/* long */
176 };
177 
178 #define	RTMP_REQ	1
179 #define	RTMP_RDR_SH	2	/* Route Data Request, split horizon */
180 #define	RTMP_RDR_NSH	3	/* Route Data Request, no split horizon */
181 
182 #define	RTMP_DIST_MASK	0x1f
183 #define	RTMP_EXTEND	0x80
184 #define	RTMP_FILLER	0x82
185 
186 
187 uint16_t get_short(uint8_t *);
188 uint32_t get_long(uint8_t *);
189 
190 extern void interpret_aarp(int, char *, int);
191 extern void interpret_at(int, struct ddp_hdr *, int);
192 extern void interpret_nbp(int, struct nbp_hdr *, int);
193 extern void interpret_rtmp(int, struct ddp_hdr *, int);
194 extern void interpret_aecho(int, struct ddp_hdr *, int);
195 extern void interpret_atp(int, struct ddp_hdr *, int);
196 extern void interpret_adsp(int, struct ddp_adsphdr *, int);
197 extern void interpret_ddp_zip(int, struct zip_hdr *, int);
198 extern void interpret_atp_zip(int, struct atp_hdr *, int);
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* _AT_H */
205