xref: /openbsd/usr.sbin/tcpdump/appletalk.h (revision 2068f686)
1 /*	$OpenBSD: appletalk.h,v 1.8 2007/10/07 16:41:05 deraadt Exp $	*/
2 
3 /*
4  * Copyright (c) 1988, 1989, 1990, 1993, 1994, 1995, 1996
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that: (1) source code distributions
9  * retain the above copyright notice and this paragraph in its entirety, (2)
10  * distributions including binary code include the above copyright notice and
11  * this paragraph in its entirety in the documentation or other materials
12  * provided with the distribution, and (3) all advertising materials mentioning
13  * features or use of this software display the following acknowledgement:
14  * ``This product includes software developed by the University of California,
15  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16  * the University nor the names of its contributors may be used to endorse
17  * or promote products derived from this software without specific prior
18  * written permission.
19  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22  *
23  * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
24  *
25  * @(#) $Id: appletalk.h,v 1.8 2007/10/07 16:41:05 deraadt Exp $ (LBL)
26  */
27 
28 struct LAP {
29 	u_char	dst;
30 	u_char	src;
31 	u_char	type;
32 };
33 #define lapShortDDP	1	/* short DDP type */
34 #define lapDDP		2	/* DDP type */
35 #define lapKLAP		'K'	/* Kinetics KLAP type */
36 
37 /* Datagram Delivery Protocol */
38 
39 struct atDDP {
40 	u_short	length;
41 	u_short	checksum;
42 	u_short	dstNet;
43 	u_short	srcNet;
44 	u_char	dstNode;
45 	u_char	srcNode;
46 	u_char	dstSkt;
47 	u_char	srcSkt;
48 	u_char	type;
49 };
50 
51 struct atShortDDP {
52 	u_short	length;
53 	u_char	dstSkt;
54 	u_char	srcSkt;
55 	u_char	type;
56 };
57 
58 #define	ddpMaxWKS	0x7F
59 #define	ddpMaxData	586
60 #define	ddpLengthMask	0x3FF
61 #define	ddpHopShift	10
62 #define	ddpSize		13	/* size of DDP header (avoid struct padding) */
63 #define	ddpSSize	5
64 #define	ddpWKS		128	/* boundary of DDP well known sockets */
65 #define	ddpRTMP		1	/* RTMP type */
66 #define	ddpRTMPrequest	5	/* RTMP request type */
67 #define	ddpNBP		2	/* NBP type */
68 #define	ddpATP		3	/* ATP type */
69 #define	ddpECHO		4	/* ECHO type */
70 #define	ddpIP		22	/* IP type */
71 #define	ddpARP		23	/* ARP type */
72 #define	ddpKLAP		0x4b	/* Kinetics KLAP type */
73 
74 
75 /* AppleTalk Transaction Protocol */
76 
77 struct atATP {
78 	u_char	control;
79 	u_char	bitmap;
80 	u_short	transID;
81 	int32_t userData;
82 };
83 
84 #define	atpReqCode	0x40
85 #define	atpRspCode	0x80
86 #define	atpRelCode	0xC0
87 #define	atpXO		0x20
88 #define	atpEOM		0x10
89 #define	atpSTS		0x08
90 #define	atpFlagMask	0x3F
91 #define	atpControlMask	0xF8
92 #define	atpMaxNum	8
93 #define	atpMaxData	578
94 
95 
96 /* AppleTalk Echo Protocol */
97 
98 struct atEcho {
99 	u_char	echoFunction;
100 	u_char	*echoData;
101 };
102 
103 #define echoSkt		4		/* the echoer socket */
104 #define echoSize	1		/* size of echo header */
105 #define echoRequest	1		/* echo request */
106 #define echoReply	2		/* echo request */
107 
108 
109 /* Name Binding Protocol */
110 
111 struct atNBP {
112 	u_char	control;
113 	u_char	id;
114 };
115 
116 struct atNBPtuple {
117 	u_short	net;
118 	u_char	node;
119 	u_char	skt;
120 	u_char	enumerator;
121 };
122 
123 #define	nbpBrRq		0x10
124 #define	nbpLkUp		0x20
125 #define	nbpLkUpReply	0x30
126 #define	nbpFwd		0x40
127 /* The following are not standard, but netatalk uses them. */
128 #define	nbpNATLKrgstr	0xc0
129 #define	nbpNATLKunrgstr	0xd0
130 #define	nbpNATLKok	0xe0
131 #define	nbpNATLKerr	0xf0
132 
133 #define	nbpNIS		2
134 #define	nbpTupleMax	15
135 
136 #define	nbpHeaderSize	2
137 #define nbpTupleSize	5
138 
139 #define nbpSkt		2		/* NIS */
140 
141 
142 /* Routing Table Maint. Protocol */
143 
144 #define	rtmpSkt		1	/* number of RTMP socket */
145 #define	rtmpSize	4	/* minimum size */
146 #define	rtmpTupleSize	3
147 
148 
149 /* Zone Information Protocol */
150 
151 struct zipHeader {
152 	u_char	command;
153 	u_char	netcount;
154 };
155 
156 #define	zipHeaderSize	2
157 #define	zipQuery	1
158 #define	zipReply	2
159 #define	zipTakedown	3
160 #define	zipBringup	4
161 #define	ddpZIP		6
162 #define	zipSkt		6
163 #define	GetMyZone	7
164 #define	GetZoneList	8
165 
166 /*
167  * UDP port range used for ddp-in-udp encapsulation is 16512-16639
168  * for client sockets (128-255) and 200-327 for server sockets
169  * (0-127).  We also try to recognize the pre-April 88 server
170  * socket range of 768-895.
171  */
172 #define atalk_port(p) \
173 	(((unsigned)((p) - 16512) < 128) || \
174 	 ((unsigned)((p) - 200) < 128) || \
175 	 ((unsigned)((p) - 768) < 128))
176