xref: /titanic_44/usr/src/cmd/cmd-inet/usr.sbin/snoop/at.h (revision 4bff34e37def8a90f9194d81bc345c52ba20086a)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * There is a lot of alignment problems in AppleTalk packets.
39  * This is the reason some of the headers use uint8_t arrays instead of the
40  * natural datatype.
41  */
42 
43 /* AARP */
44 
45 #define	AARP_REQ		1
46 #define	AARP_RESP		2
47 #define	AARP_PROBE		3
48 
49 
50 /* DDP */
51 
52 struct ddp_hdr {
53 	uint8_t		ddp_hop_len;
54 	uint8_t		ddp_len_lo;
55 	uint16_t	ddp_cksum;
56 	uint16_t	ddp_dest_net;
57 	uint16_t	ddp_src_net;
58 	uint8_t		ddp_dest_id;
59 	uint8_t		ddp_src_id;
60 	uint8_t		ddp_dest_sock;
61 	uint8_t		ddp_src_sock;
62 	uint8_t		ddp_type;
63 };
64 
65 #define	ddp_pad(x)	((x)->ddp_hop_len & 0xc0)
66 #define	ddp_hop(x)	(((x)->ddp_hop_len >> 2) & 0xf)
67 #define	ddp_len(x)	((((x)->ddp_hop_len & 0x3) << 8) + (x)->ddp_len_lo)
68 
69 #define	DDPHDR_SIZE 13
70 
71 #define	DDP_TYPE_RTMPRQ		5
72 #define	DDP_TYPE_RTMPRESP	1
73 #define	DDP_TYPE_NBP		2
74 #define	DDP_TYPE_ATP		3
75 #define	DDP_TYPE_AEP		4
76 #define	DDP_TYPE_ZIP		6
77 #define	DDP_TYPE_ADSP		7
78 
79 
80 /* AECHO */
81 
82 #define	AEP_REQ			1
83 #define	AEP_REPLY		2
84 
85 /* NBP */
86 
87 struct nbp_hdr {
88 	uint8_t		ddphdr[DDPHDR_SIZE];
89 	uint8_t		nbp_fun_cnt;
90 	uint8_t		nbp_id;
91 };
92 
93 #define	NBP_BRRQ		1
94 #define	NBP_LKUP		2
95 #define	NBP_LKUP_REPLY		3
96 #define	NBP_FWDREQ		4
97 
98 
99 /* ZIP */
100 
101 struct zip_hdr {
102 	uint8_t		ddphdr[DDPHDR_SIZE];
103 	uint8_t		zip_func;
104 	uint8_t		zip_netcnt;
105 };
106 
107 #define	ZIP_QUERY		1
108 #define	ZIP_REPLY		2
109 #define	ZIP_GET_NET_INFO	5
110 #define	ZIP_GET_NET_INFO_REPLY	6
111 #define	ZIP_NOTIFY		7
112 #define	ZIP_EXT_REPLY		8
113 
114 #define	ZIP_ATP_GETMYZONE	7
115 #define	ZIP_ATP_GETZONELIST	8
116 #define	ZIP_ATP_GETLOCALZONES	9
117 
118 #define	ZIP_FLG_ONEZ		0x20
119 #define	ZIP_FLG_USEBRC		0x40
120 #define	ZIP_FLG_ZINV		0x80
121 
122 
123 /* ATP */
124 
125 struct atp_hdr {
126 	uint8_t		ddphdr[DDPHDR_SIZE];
127 	uint8_t		atp_ctrl;
128 	uint8_t		atp_seq;
129 	uint8_t		atp_tid[2];
130 	uint8_t		atp_user[4];
131 };
132 
133 #define	ATPHDR_SIZE	8
134 
135 #define	atp_fun(x)	(((x) >> 6) & 0x3)
136 #define	atp_tmo(x)	((x) & 0x7)
137 
138 #define	ATP_TREQ		1
139 #define	ATP_TRESP		2
140 #define	ATP_TREL		3
141 #define	ATP_FLG_STS		0x08
142 #define	ATP_FLG_EOM		0x10
143 #define	ATP_FLG_XO		0x20
144 
145 
146 #define	NODE_ID_BROADCAST	0xff
147 
148 struct ddp_adsphdr {
149 	uint8_t	ddphdr[DDPHDR_SIZE];
150 	uint8_t	ad_connid[2];		/* short */
151 	uint8_t	ad_fbseq[4];		/* long */
152 	uint8_t	ad_nrseq[4];		/* long */
153 	uint8_t	ad_rcvwin[2];		/* short */
154 	uint8_t	ad_desc;
155 };
156 
157 #define	AD_CTRL		0x80
158 #define	AD_ACKREQ	0x40
159 #define	AD_EOM		0x20
160 #define	AD_ATT		0x10
161 #define	AD_CTRL_MASK	0x0f
162 
163 #define	AD_CREQ		0x81		/* Open Conn Request */
164 #define	AD_CACK		0x82		/* Open Conn Ack */
165 #define	AD_CREQ_ACK	0x83		/* Open Conn Req+Ack */
166 #define	AD_CDENY	0x84		/* Open Conn Denial */
167 
168 struct ddp_adsp_att {
169 	struct ddp_adsphdr	ad;
170 	uint8_t		ad_att_code[2];	/* short */
171 };
172 
173 struct ddp_adsp_open {
174 	struct ddp_adsphdr	ad;
175 	uint8_t		ad_version[2];	/* short */
176 	uint8_t		ad_dconnid[2];	/* short */
177 	uint8_t		ad_attseq[4];	/* long */
178 };
179 
180 #define	RTMP_REQ	1
181 #define	RTMP_RDR_SH	2	/* Route Data Request, split horizon */
182 #define	RTMP_RDR_NSH	3	/* Route Data Request, no split horizon */
183 
184 #define	RTMP_DIST_MASK	0x1f
185 #define	RTMP_EXTEND	0x80
186 #define	RTMP_FILLER	0x82
187 
188 
189 uint16_t get_short(uint8_t *);
190 uint32_t get_long(uint8_t *);
191 
192 extern void interpret_aarp(int, char *, int);
193 extern void interpret_at(int, struct ddp_hdr *, int);
194 extern void interpret_nbp(int, struct nbp_hdr *, int);
195 extern void interpret_rtmp(int, struct ddp_hdr *, int);
196 extern void interpret_aecho(int, struct ddp_hdr *, int);
197 extern void interpret_atp(int, struct ddp_hdr *, int);
198 extern void interpret_adsp(int, struct ddp_adsphdr *, int);
199 extern void interpret_ddp_zip(int, struct zip_hdr *, int);
200 extern void interpret_atp_zip(int, struct atp_hdr *, int);
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* _AT_H */
207