xref: /openbsd/usr.sbin/tcpdump/decnet.h (revision 2068f686)
1 /*	$OpenBSD: decnet.h,v 1.7 2007/10/07 16:41:05 deraadt Exp $	*/
2 
3 /*
4  * Copyright (c) 1992, 1994, 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  * @(#) $Id: decnet.h,v 1.7 2007/10/07 16:41:05 deraadt Exp $ (LBL)
24  */
25 
26 typedef unsigned char byte[1];		/* single byte field */
27 typedef unsigned char word[2];		/* 2 byte field */
28 typedef unsigned char longword[4];	/* 4 bytes field */
29 
30 /*
31  * Definitions for DECNET Phase IV protocol headers
32  */
33 union etheraddress {
34 	unsigned char   dne_addr[6];		/* full ethernet address */
35 	struct {
36 		unsigned char dne_hiord[4];	/* DECnet HIORD prefix */
37 		unsigned char dne_nodeaddr[2];	/* DECnet node address */
38 	} dne_remote;
39 };
40 
41 typedef union etheraddress etheraddr;	/* Ethernet address */
42 
43 #define HIORD 0x000400aa		/* high 32-bits of address (swapped) */
44 
45 #define AREAMASK	0176000		/* mask for area field */
46 #define	AREASHIFT	10		/* bit-offset for area field */
47 #define NODEMASK	01777		/* mask for node address field */
48 
49 #define DN_MAXADDL	20		/* max size of DECnet address */
50 struct dn_naddr {
51 	unsigned short	a_len;		/* length of address */
52 	unsigned char a_addr[DN_MAXADDL]; /* address as bytes */
53 };
54 
55 /*
56  * Define long and short header formats.
57  */
58 struct shorthdr
59   {
60     byte	sh_flags;		/* route flags */
61     word	sh_dst;			/* destination node address */
62     word	sh_src;			/* source node address */
63     byte	sh_visits;		/* visit count */
64   };
65 
66 struct longhdr
67   {
68     byte	lg_flags;		/* route flags */
69     byte	lg_darea;		/* destination area (reserved) */
70     byte	lg_dsarea;		/* destination subarea (reserved) */
71     etheraddr	lg_dst;			/* destination id */
72     byte	lg_sarea;		/* source area (reserved) */
73     byte	lg_ssarea;		/* source subarea (reserved) */
74     etheraddr	lg_src;			/* source id */
75     byte	lg_nextl2;		/* next level 2 router (reserved) */
76     byte	lg_visits;		/* visit count */
77     byte	lg_service;		/* service class (reserved) */
78     byte	lg_pt;			/* protocol type (reserved) */
79   };
80 
81 union routehdr
82   {
83     struct shorthdr rh_short;		/* short route header */
84     struct longhdr rh_long;		/* long route header */
85   };
86 
87 /*
88  * Define the values of various fields in the protocol messages.
89  *
90  * 1. Data packet formats.
91  */
92 #define RMF_MASK	7		/* mask for message type */
93 #define RMF_SHORT	2		/* short message format */
94 #define RMF_LONG	6		/* long message format */
95 #ifndef RMF_RQR
96 #define RMF_RQR		010		/* request return to sender */
97 #define RMF_RTS		020		/* returning to sender */
98 #define RMF_IE		040		/* intra-ethernet packet */
99 #endif /* RMR_RQR */
100 #define RMF_FVER	0100		/* future version flag */
101 #define RMF_PAD		0200		/* pad field */
102 #define RMF_PADMASK	0177		/* pad field mask */
103 
104 #define VIS_MASK	077		/* visit field mask */
105 
106 /*
107  * 2. Control packet formats.
108  */
109 #define RMF_CTLMASK	017		/* mask for message type */
110 #define RMF_CTLMSG	01		/* control message indicator */
111 #define RMF_INIT	01		/* initialization message */
112 #define RMF_VER		03		/* verification message */
113 #define RMF_TEST	05		/* hello and test message */
114 #define RMF_L1ROUT	07		/* level 1 routing message */
115 #define RMF_L2ROUT	011		/* level 2 routing message */
116 #define RMF_RHELLO	013		/* router hello message */
117 #define RMF_EHELLO	015		/* endnode hello message */
118 
119 #define TI_L2ROUT	01		/* level 2 router */
120 #define TI_L1ROUT	02		/* level 1 router */
121 #define TI_ENDNODE	03		/* endnode */
122 #define TI_VERIF	04		/* verification required */
123 #define TI_BLOCK	010		/* blocking requested */
124 
125 #define VE_VERS		2		/* version number (2) */
126 #define VE_ECO		0		/* ECO number */
127 #define VE_UECO		0		/* user ECO number (0) */
128 
129 #define P3_VERS		1		/* phase III version number (1) */
130 #define P3_ECO		3		/* ECO number (3) */
131 #define P3_UECO		0		/* user ECO number (0) */
132 
133 #define II_L2ROUT	01		/* level 2 router */
134 #define II_L1ROUT	02		/* level 1 router */
135 #define II_ENDNODE	03		/* endnode */
136 #define II_VERIF	04		/* verification required */
137 #define II_NOMCAST	040		/* no multicast traffic accepted */
138 #define II_BLOCK	0100		/* blocking requested */
139 #define II_TYPEMASK	03		/* mask for node type */
140 
141 #define TESTDATA	0252		/* test data bytes */
142 #define TESTLEN		1		/* length of transmitted test data */
143 
144 /*
145  * Define control message formats.
146  */
147 struct initmsgIII			/* phase III initialization message */
148   {
149     byte	inIII_flags;		/* route flags */
150     word	inIII_src;		/* source node address */
151     byte	inIII_info;		/* routing layer information */
152     word	inIII_blksize;		/* maximum data link block size */
153     byte	inIII_vers;		/* version number */
154     byte	inIII_eco;		/* ECO number */
155     byte	inIII_ueco;		/* user ECO number */
156     byte	inIII_rsvd;		/* reserved image field */
157   };
158 
159 struct initmsg				/* initialization message */
160   {
161     byte	in_flags;		/* route flags */
162     word	in_src;			/* source node address */
163     byte	in_info;		/* routing layer information */
164     word	in_blksize;		/* maximum data link block size */
165     byte	in_vers;		/* version number */
166     byte	in_eco;			/* ECO number */
167     byte	in_ueco;		/* user ECO number */
168     word	in_hello;		/* hello timer */
169     byte	in_rsvd;		/* reserved image field */
170   };
171 
172 struct verifmsg				/* verification message */
173   {
174     byte	ve_flags;		/* route flags */
175     word	ve_src;			/* source node address */
176     byte	ve_fcnval;		/* function value image field */
177   };
178 
179 struct testmsg				/* hello and test message */
180   {
181     byte	te_flags;		/* route flags */
182     word	te_src;			/* source node address */
183     byte	te_data;		/* test data image field */
184   };
185 
186 struct l1rout				/* level 1 routing message */
187   {
188     byte	r1_flags;		/* route flags */
189     word	r1_src;			/* source node address */
190     byte	r1_rsvd;		/* reserved field */
191   };
192 
193 struct l2rout				/* level 2 routing message */
194   {
195     byte	r2_flags;		/* route flags */
196     word	r2_src;			/* source node address */
197     byte	r2_rsvd;		/* reserved field */
198   };
199 
200 struct rhellomsg			/* router hello message */
201   {
202     byte	rh_flags;		/* route flags */
203     byte	rh_vers;		/* version number */
204     byte	rh_eco;			/* ECO number */
205     byte	rh_ueco;		/* user ECO number */
206     etheraddr	rh_src;			/* source id */
207     byte	rh_info;		/* routing layer information */
208     word	rh_blksize;		/* maximum data link block size */
209     byte	rh_priority;		/* router's priority */
210     byte	rh_area;		/* reserved */
211     word	rh_hello;		/* hello timer */
212     byte	rh_mpd;			/* reserved */
213   };
214 
215 struct ehellomsg			/* endnode hello message */
216   {
217     byte	eh_flags;		/* route flags */
218     byte	eh_vers;		/* version number */
219     byte	eh_eco;			/* ECO number */
220     byte	eh_ueco;		/* user ECO number */
221     etheraddr	eh_src;			/* source id */
222     byte	eh_info;		/* routing layer information */
223     word	eh_blksize;		/* maximum data link block size */
224     byte	eh_area;		/* area (reserved) */
225     byte	eh_seed[8];		/* verification seed */
226     etheraddr	eh_router;		/* designated router */
227     word	eh_hello;		/* hello timer */
228     byte	eh_mpd;			/* (reserved) */
229     byte	eh_data;		/* test data image field */
230   };
231 
232 union controlmsg
233   {
234     struct initmsg	cm_init;	/* initialization message */
235     struct verifmsg	cm_ver;		/* verification message */
236     struct testmsg	cm_test;	/* hello and test message */
237     struct l1rout	cm_l1rou;	/* level 1 routing message */
238     struct l2rout	cm_l2rout;	/* level 2 routing message */
239     struct rhellomsg	cm_rhello;	/* router hello message */
240     struct ehellomsg	cm_ehello;	/* endnode hello message */
241   };
242 
243 /* Macros for decoding routing-info fields */
244 #define	RI_COST(x)	((x)&0777)
245 #define	RI_HOPS(x)	(((x)>>10)&037)
246 
247 /*
248  * NSP protocol fields and values.
249  */
250 
251 #define NSP_TYPEMASK 014		/* mask to isolate type code */
252 #define NSP_SUBMASK 0160		/* mask to isolate subtype code */
253 #define NSP_SUBSHFT 4			/* shift to move subtype code */
254 
255 #define MFT_DATA 0			/* data message */
256 #define MFT_ACK  04			/* acknowledgement message */
257 #define MFT_CTL  010			/* control message */
258 
259 #define MFS_ILS  020			/* data or I/LS indicator */
260 #define MFS_BOM  040			/* beginning of message (data) */
261 #define MFS_MOM  0			/* middle of message (data) */
262 #define MFS_EOM  0100			/* end of message (data) */
263 #define MFS_INT  040			/* interrupt message */
264 
265 #define MFS_DACK 0			/* data acknowledgement */
266 #define MFS_IACK 020			/* I/LS acknowledgement */
267 #define MFS_CACK 040			/* connect acknowledgement */
268 
269 #define MFS_NOP  0			/* no operation */
270 #define MFS_CI   020			/* connect initiate */
271 #define MFS_CC   040			/* connect confirm */
272 #define MFS_DI   060			/* disconnect initiate */
273 #define MFS_DC   0100			/* disconnect confirm */
274 #define MFS_RCI  0140			/* retransmitted connect initiate */
275 
276 #define SGQ_ACK  0100000		/* ack */
277 #define SGQ_NAK  0110000		/* negative ack */
278 #define SGQ_OACK 0120000		/* other channel ack */
279 #define SGQ_ONAK 0130000		/* other channel negative ack */
280 #define SGQ_MASK 07777			/* mask to isolate seq # */
281 #define SGQ_OTHER 020000		/* other channel qualifier */
282 #define SGQ_DELAY 010000		/* ack delay flag */
283 
284 #define SGQ_EOM  0100000		/* pseudo flag for end-of-message */
285 
286 #define LSM_MASK 03			/* mask for modifier field */
287 #define LSM_NOCHANGE 0			/* no change */
288 #define LSM_DONOTSEND 1			/* do not send data */
289 #define LSM_SEND 2			/* send data */
290 
291 #define LSI_MASK 014			/* mask for interpretation field */
292 #define LSI_DATA 0			/* data segment or message count */
293 #define LSI_INTR 4			/* interrupt request count */
294 #define LSI_INTM 0377			/* funny marker for int. message */
295 
296 #define COS_MASK 014			/* mask for flow control field */
297 #define COS_NONE 0			/* no flow control */
298 #define COS_SEGMENT 04			/* segment flow control */
299 #define COS_MESSAGE 010			/* message flow control */
300 #define COS_CRYPTSER 020		/* cryptographic services requested */
301 #define COS_DEFAULT 1			/* default value for field */
302 
303 #define COI_MASK 3			/* mask for version field */
304 #define COI_32 0			/* version 3.2 */
305 #define COI_31 1			/* version 3.1 */
306 #define COI_40 2			/* version 4.0 */
307 #define COI_41 3			/* version 4.1 */
308 
309 #define MNU_MASK 140			/* mask for session control version */
310 #define MNU_10 000				/* session V1.0 */
311 #define MNU_20 040				/* session V2.0 */
312 #define MNU_ACCESS 1			/* access control present */
313 #define MNU_USRDATA 2			/* user data field present */
314 #define MNU_INVKPROXY 4			/* invoke proxy field present */
315 #define MNU_UICPROXY 8			/* use uic-based proxy */
316 
317 #define DC_NORESOURCES 1		/* no resource reason code */
318 #define DC_NOLINK 41			/* no link terminate reason code */
319 #define DC_COMPLETE 42			/* disconnect complete reason code */
320 
321 #define DI_NOERROR 0			/* user disconnect */
322 #define DI_SHUT 3			/* node is shutting down */
323 #define DI_NOUSER 4			/* destination end user does not exist */
324 #define DI_INVDEST 5			/* invalid end user destination */
325 #define DI_REMRESRC 6			/* insufficient remote resources */
326 #define DI_TPA 8			/* third party abort */
327 #define DI_PROTOCOL 7			/* protocol error discovered */
328 #define DI_ABORT 9			/* user abort */
329 #define DI_LOCALRESRC 32		/* insufficient local resources */
330 #define DI_REMUSERRESRC 33		/* insufficient remote user resources */
331 #define DI_BADACCESS 34			/* bad access control information */
332 #define DI_BADACCNT 36			/* bad ACCOUNT information */
333 #define DI_CONNECTABORT 38		/* connect request cancelled */
334 #define DI_TIMEDOUT 38			/* remote node or user crashed */
335 #define DI_UNREACHABLE 39		/* local timers expired due to ... */
336 #define DI_BADIMAGE 43			/* bad image data in connect */
337 #define DI_SERVMISMATCH 54		/* cryptographic service mismatch */
338 
339 #define UC_OBJREJECT 0			/* object rejected connect */
340 #define UC_USERDISCONNECT 0		/* user disconnect */
341 #define UC_RESOURCES 1			/* insufficient resources (local or remote) */
342 #define UC_NOSUCHNODE 2			/* unrecognized node name */
343 #define UC_REMOTESHUT 3			/* remote node shutting down */
344 #define UC_NOSUCHOBJ 4			/* unrecognized object */
345 #define UC_INVOBJFORMAT 5		/* invalid object name format */
346 #define UC_OBJTOOBUSY 6			/* object too busy */
347 #define UC_NETWORKABORT 8		/* network abort */
348 #define UC_USERABORT 9			/* user abort */
349 #define UC_INVNODEFORMAT 10		/* invalid node name format */
350 #define UC_LOCALSHUT 11			/* local node shutting down */
351 #define UC_ACCESSREJECT 34		/* invalid access control information */
352 #define UC_NORESPONSE 38		/* no response from object */
353 #define UC_UNREACHABLE 39		/* node unreachable */
354 
355 /*
356  * NSP message formats.
357  */
358 struct nsphdr				/* general nsp header */
359   {
360     byte	nh_flags;		/* message flags */
361     word	nh_dst;			/* destination link address */
362     word	nh_src;			/* source link address */
363   };
364 
365 struct seghdr				/* data segment header */
366   {
367     byte	sh_flags;		/* message flags */
368     word	sh_dst;			/* destination link address */
369     word	sh_src;			/* source link address */
370     word	sh_seq[3];		/* sequence numbers */
371   };
372 
373 struct minseghdr			/* minimum data segment header */
374   {
375     byte	ms_flags;		/* message flags */
376     word	ms_dst;			/* destination link address */
377     word	ms_src;			/* source link address */
378     word	ms_seq;			/* sequence number */
379   };
380 
381 struct lsmsg				/* link service message (after hdr) */
382   {
383     byte	ls_lsflags;		/* link service flags */
384     byte	ls_fcval;		/* flow control value */
385   };
386 
387 struct ackmsg				/* acknowledgement message */
388   {
389     byte	ak_flags;		/* message flags */
390     word	ak_dst;			/* destination link address */
391     word	ak_src;			/* source link address */
392     word	ak_acknum[2];		/* acknowledgement numbers */
393   };
394 
395 struct minackmsg			/* minimum acknowledgement message */
396   {
397     byte	mk_flags;		/* message flags */
398     word	mk_dst;			/* destination link address */
399     word	mk_src;			/* source link address */
400     word	mk_acknum;		/* acknowledgement number */
401   };
402 
403 struct ciackmsg				/* connect acknowledgement message */
404   {
405     byte	ck_flags;		/* message flags */
406     word	ck_dst;			/* destination link address */
407   };
408 
409 struct cimsg				/* connect initiate message */
410   {
411     byte	ci_flags;		/* message flags */
412     word	ci_dst;			/* destination link address (0) */
413     word	ci_src;			/* source link address */
414     byte	ci_services;		/* requested services */
415     byte	ci_info;		/* information */
416     word	ci_segsize;		/* maximum segment size */
417   };
418 
419 struct ccmsg				/* connect confirm message */
420   {
421     byte	cc_flags;		/* message flags */
422     word	cc_dst;			/* destination link address */
423     word	cc_src;			/* source link address */
424     byte	cc_services;		/* requested services */
425     byte	cc_info;		/* information */
426     word	cc_segsize;		/* maximum segment size */
427     byte	cc_optlen;		/* optional data length */
428   };
429 
430 struct cnmsg				/* generic connect message */
431   {
432     byte	cn_flags;		/* message flags */
433     word	cn_dst;			/* destination link address */
434     word	cn_src;			/* source link address */
435     byte	cn_services;		/* requested services */
436     byte	cn_info;		/* information */
437     word	cn_segsize;		/* maximum segment size */
438   };
439 
440 struct dimsg				/* disconnect initiate message */
441   {
442     byte	di_flags;		/* message flags */
443     word	di_dst;			/* destination link address */
444     word	di_src;			/* source link address */
445     word	di_reason;		/* reason code */
446     byte	di_optlen;		/* optional data length */
447   };
448 
449 struct dcmsg				/* disconnect confirm message */
450   {
451     byte	dc_flags;		/* message flags */
452     word	dc_dst;			/* destination link address */
453     word	dc_src;			/* source link address */
454     word	dc_reason;		/* reason code */
455   };
456