117680Spst/*
217680Spst * Copyright (c) 1992, 1994, 1996
317680Spst *	The Regents of the University of California.  All rights reserved.
417680Spst *
517680Spst * Redistribution and use in source and binary forms, with or without
617680Spst * modification, are permitted provided that: (1) source code distributions
717680Spst * retain the above copyright notice and this paragraph in its entirety, (2)
817680Spst * distributions including binary code include the above copyright notice and
917680Spst * this paragraph in its entirety in the documentation or other materials
1017680Spst * provided with the distribution, and (3) all advertising materials mentioning
1117680Spst * features or use of this software display the following acknowledgement:
1217680Spst * ``This product includes software developed by the University of California,
1317680Spst * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1417680Spst * the University nor the names of its contributors may be used to endorse
1517680Spst * or promote products derived from this software without specific prior
1617680Spst * written permission.
1717680Spst * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1817680Spst * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1917680Spst * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2017680Spst *
21190207Srpaulo * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.11 2002-12-11 07:13:50 guy Exp $ (LBL)
2217680Spst */
2317680Spst
24127668Sbms#ifndef WIN32
2575115Sfennertypedef u_int8_t byte[1];		/* single byte field */
26127668Sbms#else
27127668Sbms/*
28127668Sbms * the keyword 'byte' generates conflicts in Windows
29127668Sbms */
30127668Sbmstypedef unsigned char Byte[1];		/* single byte field */
31127668Sbms#define byte Byte
32127668Sbms#endif /* WIN32 */
3375115Sfennertypedef u_int8_t word[2];		/* 2 byte field */
3475115Sfennertypedef u_int8_t longword[4];		/* 4 bytes field */
3517680Spst
3617680Spst/*
3717680Spst * Definitions for DECNET Phase IV protocol headers
3817680Spst */
3917680Spstunion etheraddress {
4075115Sfenner	u_int8_t   dne_addr[6];		/* full ethernet address */
4117680Spst	struct {
4275115Sfenner		u_int8_t dne_hiord[4];	/* DECnet HIORD prefix */
4375115Sfenner		u_int8_t dne_nodeaddr[2]; /* DECnet node address */
4417680Spst	} dne_remote;
4517680Spst};
4617680Spst
4717680Spsttypedef union etheraddress etheraddr;	/* Ethernet address */
4817680Spst
4917680Spst#define HIORD 0x000400aa		/* high 32-bits of address (swapped) */
5017680Spst
5117680Spst#define AREAMASK	0176000		/* mask for area field */
5217680Spst#define	AREASHIFT	10		/* bit-offset for area field */
5317680Spst#define NODEMASK	01777		/* mask for node address field */
5417680Spst
5517680Spst#define DN_MAXADDL	20		/* max size of DECnet address */
5617680Spststruct dn_naddr {
5775115Sfenner	u_int16_t	a_len;		/* length of address */
5875115Sfenner	u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */
5917680Spst};
6017680Spst
6117680Spst/*
6217680Spst * Define long and short header formats.
6317680Spst */
6417680Spststruct shorthdr
6517680Spst  {
6617680Spst    byte	sh_flags;		/* route flags */
6717680Spst    word	sh_dst;			/* destination node address */
6817680Spst    word	sh_src;			/* source node address */
6917680Spst    byte	sh_visits;		/* visit count */
7017680Spst  };
7117680Spst
7217680Spststruct longhdr
7317680Spst  {
7417680Spst    byte	lg_flags;		/* route flags */
7517680Spst    byte	lg_darea;		/* destination area (reserved) */
7617680Spst    byte	lg_dsarea;		/* destination subarea (reserved) */
7717680Spst    etheraddr	lg_dst;			/* destination id */
7817680Spst    byte	lg_sarea;		/* source area (reserved) */
7917680Spst    byte	lg_ssarea;		/* source subarea (reserved) */
8017680Spst    etheraddr	lg_src;			/* source id */
8117680Spst    byte	lg_nextl2;		/* next level 2 router (reserved) */
8217680Spst    byte	lg_visits;		/* visit count */
8317680Spst    byte	lg_service;		/* service class (reserved) */
8417680Spst    byte	lg_pt;			/* protocol type (reserved) */
8517680Spst  };
8617680Spst
8717680Spstunion routehdr
8817680Spst  {
8917680Spst    struct shorthdr rh_short;		/* short route header */
9017680Spst    struct longhdr rh_long;		/* long route header */
9117680Spst  };
9217680Spst
9317680Spst/*
9417680Spst * Define the values of various fields in the protocol messages.
9517680Spst *
9617680Spst * 1. Data packet formats.
9717680Spst */
9817680Spst#define RMF_MASK	7		/* mask for message type */
9917680Spst#define RMF_SHORT	2		/* short message format */
10017680Spst#define RMF_LONG	6		/* long message format */
10117680Spst#ifndef RMF_RQR
10217680Spst#define RMF_RQR		010		/* request return to sender */
10317680Spst#define RMF_RTS		020		/* returning to sender */
10417680Spst#define RMF_IE		040		/* intra-ethernet packet */
10517680Spst#endif /* RMR_RQR */
10617680Spst#define RMF_FVER	0100		/* future version flag */
10717680Spst#define RMF_PAD		0200		/* pad field */
10817680Spst#define RMF_PADMASK	0177		/* pad field mask */
10917680Spst
11017680Spst#define VIS_MASK	077		/* visit field mask */
11117680Spst
11217680Spst/*
11317680Spst * 2. Control packet formats.
11417680Spst */
11517680Spst#define RMF_CTLMASK	017		/* mask for message type */
11617680Spst#define RMF_CTLMSG	01		/* control message indicator */
11717680Spst#define RMF_INIT	01		/* initialization message */
11817680Spst#define RMF_VER		03		/* verification message */
11917680Spst#define RMF_TEST	05		/* hello and test message */
12017680Spst#define RMF_L1ROUT	07		/* level 1 routing message */
12117680Spst#define RMF_L2ROUT	011		/* level 2 routing message */
12217680Spst#define RMF_RHELLO	013		/* router hello message */
12317680Spst#define RMF_EHELLO	015		/* endnode hello message */
12417680Spst
12517680Spst#define TI_L2ROUT	01		/* level 2 router */
12617680Spst#define TI_L1ROUT	02		/* level 1 router */
12717680Spst#define TI_ENDNODE	03		/* endnode */
12817680Spst#define TI_VERIF	04		/* verification required */
12917680Spst#define TI_BLOCK	010		/* blocking requested */
13017680Spst
13117680Spst#define VE_VERS		2		/* version number (2) */
13217680Spst#define VE_ECO		0		/* ECO number */
13317680Spst#define VE_UECO		0		/* user ECO number (0) */
13417680Spst
13517680Spst#define P3_VERS		1		/* phase III version number (1) */
13617680Spst#define P3_ECO		3		/* ECO number (3) */
13717680Spst#define P3_UECO		0		/* user ECO number (0) */
13817680Spst
13917680Spst#define II_L2ROUT	01		/* level 2 router */
14017680Spst#define II_L1ROUT	02		/* level 1 router */
14117680Spst#define II_ENDNODE	03		/* endnode */
14217680Spst#define II_VERIF	04		/* verification required */
14317680Spst#define II_NOMCAST	040		/* no multicast traffic accepted */
14417680Spst#define II_BLOCK	0100		/* blocking requested */
14517680Spst#define II_TYPEMASK	03		/* mask for node type */
14617680Spst
14717680Spst#define TESTDATA	0252		/* test data bytes */
14817680Spst#define TESTLEN		1		/* length of transmitted test data */
14917680Spst
15017680Spst/*
15117680Spst * Define control message formats.
15217680Spst */
15317680Spststruct initmsgIII			/* phase III initialization message */
15417680Spst  {
15517680Spst    byte	inIII_flags;		/* route flags */
15617680Spst    word	inIII_src;		/* source node address */
15717680Spst    byte	inIII_info;		/* routing layer information */
15817680Spst    word	inIII_blksize;		/* maximum data link block size */
15917680Spst    byte	inIII_vers;		/* version number */
16017680Spst    byte	inIII_eco;		/* ECO number */
16117680Spst    byte	inIII_ueco;		/* user ECO number */
16217680Spst    byte	inIII_rsvd;		/* reserved image field */
16317680Spst  };
16417680Spst
16517680Spststruct initmsg				/* initialization message */
16617680Spst  {
16717680Spst    byte	in_flags;		/* route flags */
16817680Spst    word	in_src;			/* source node address */
16917680Spst    byte	in_info;		/* routing layer information */
17017680Spst    word	in_blksize;		/* maximum data link block size */
17117680Spst    byte	in_vers;		/* version number */
17217680Spst    byte	in_eco;			/* ECO number */
17317680Spst    byte	in_ueco;		/* user ECO number */
17417680Spst    word	in_hello;		/* hello timer */
17517680Spst    byte	in_rsvd;		/* reserved image field */
17617680Spst  };
17717680Spst
17817680Spststruct verifmsg				/* verification message */
17917680Spst  {
18017680Spst    byte	ve_flags;		/* route flags */
18117680Spst    word	ve_src;			/* source node address */
18217680Spst    byte	ve_fcnval;		/* function value image field */
18317680Spst  };
18417680Spst
18517680Spststruct testmsg				/* hello and test message */
18617680Spst  {
18717680Spst    byte	te_flags;		/* route flags */
18817680Spst    word	te_src;			/* source node address */
18917680Spst    byte	te_data;		/* test data image field */
19017680Spst  };
19117680Spst
19217680Spststruct l1rout				/* level 1 routing message */
19317680Spst  {
19417680Spst    byte	r1_flags;		/* route flags */
19517680Spst    word	r1_src;			/* source node address */
19617680Spst    byte	r1_rsvd;		/* reserved field */
19717680Spst  };
19817680Spst
19917680Spststruct l2rout				/* level 2 routing message */
20017680Spst  {
20117680Spst    byte	r2_flags;		/* route flags */
20217680Spst    word	r2_src;			/* source node address */
20317680Spst    byte	r2_rsvd;		/* reserved field */
20417680Spst  };
20517680Spst
20617680Spststruct rhellomsg			/* router hello message */
20717680Spst  {
20817680Spst    byte	rh_flags;		/* route flags */
20917680Spst    byte	rh_vers;		/* version number */
21017680Spst    byte	rh_eco;			/* ECO number */
21117680Spst    byte	rh_ueco;		/* user ECO number */
21217680Spst    etheraddr	rh_src;			/* source id */
21317680Spst    byte	rh_info;		/* routing layer information */
21417680Spst    word	rh_blksize;		/* maximum data link block size */
21517680Spst    byte	rh_priority;		/* router's priority */
21617680Spst    byte	rh_area;		/* reserved */
21717680Spst    word	rh_hello;		/* hello timer */
21817680Spst    byte	rh_mpd;			/* reserved */
21917680Spst  };
22017680Spst
22117680Spststruct ehellomsg			/* endnode hello message */
22217680Spst  {
22317680Spst    byte	eh_flags;		/* route flags */
22417680Spst    byte	eh_vers;		/* version number */
22517680Spst    byte	eh_eco;			/* ECO number */
22617680Spst    byte	eh_ueco;		/* user ECO number */
22717680Spst    etheraddr	eh_src;			/* source id */
22817680Spst    byte	eh_info;		/* routing layer information */
22917680Spst    word	eh_blksize;		/* maximum data link block size */
23017680Spst    byte	eh_area;		/* area (reserved) */
23117680Spst    byte	eh_seed[8];		/* verification seed */
23217680Spst    etheraddr	eh_router;		/* designated router */
23317680Spst    word	eh_hello;		/* hello timer */
23417680Spst    byte	eh_mpd;			/* (reserved) */
23517680Spst    byte	eh_data;		/* test data image field */
23617680Spst  };
23717680Spst
23817680Spstunion controlmsg
23917680Spst  {
24017680Spst    struct initmsg	cm_init;	/* initialization message */
24117680Spst    struct verifmsg	cm_ver;		/* verification message */
24217680Spst    struct testmsg	cm_test;	/* hello and test message */
24317680Spst    struct l1rout	cm_l1rou;	/* level 1 routing message */
24417680Spst    struct l2rout	cm_l2rout;	/* level 2 routing message */
24517680Spst    struct rhellomsg	cm_rhello;	/* router hello message */
24617680Spst    struct ehellomsg	cm_ehello;	/* endnode hello message */
24717680Spst  };
24817680Spst
24917680Spst/* Macros for decoding routing-info fields */
25017680Spst#define	RI_COST(x)	((x)&0777)
25117680Spst#define	RI_HOPS(x)	(((x)>>10)&037)
25217680Spst
25317680Spst/*
25417680Spst * NSP protocol fields and values.
25517680Spst */
25617680Spst
25717680Spst#define NSP_TYPEMASK 014		/* mask to isolate type code */
25817680Spst#define NSP_SUBMASK 0160		/* mask to isolate subtype code */
25917680Spst#define NSP_SUBSHFT 4			/* shift to move subtype code */
26017680Spst
26117680Spst#define MFT_DATA 0			/* data message */
26217680Spst#define MFT_ACK  04			/* acknowledgement message */
26317680Spst#define MFT_CTL  010			/* control message */
26417680Spst
26517680Spst#define MFS_ILS  020			/* data or I/LS indicator */
26617680Spst#define MFS_BOM  040			/* beginning of message (data) */
26717680Spst#define MFS_MOM  0			/* middle of message (data) */
26817680Spst#define MFS_EOM  0100			/* end of message (data) */
26917680Spst#define MFS_INT  040			/* interrupt message */
27017680Spst
27117680Spst#define MFS_DACK 0			/* data acknowledgement */
27217680Spst#define MFS_IACK 020			/* I/LS acknowledgement */
27317680Spst#define MFS_CACK 040			/* connect acknowledgement */
27417680Spst
27517680Spst#define MFS_NOP  0			/* no operation */
27617680Spst#define MFS_CI   020			/* connect initiate */
27717680Spst#define MFS_CC   040			/* connect confirm */
27817680Spst#define MFS_DI   060			/* disconnect initiate */
27917680Spst#define MFS_DC   0100			/* disconnect confirm */
28017680Spst#define MFS_RCI  0140			/* retransmitted connect initiate */
28117680Spst
28217680Spst#define SGQ_ACK  0100000		/* ack */
28317680Spst#define SGQ_NAK  0110000		/* negative ack */
28417680Spst#define SGQ_OACK 0120000		/* other channel ack */
28517680Spst#define SGQ_ONAK 0130000		/* other channel negative ack */
28617680Spst#define SGQ_MASK 07777			/* mask to isolate seq # */
28717680Spst#define SGQ_OTHER 020000		/* other channel qualifier */
28817680Spst#define SGQ_DELAY 010000		/* ack delay flag */
28917680Spst
29017680Spst#define SGQ_EOM  0100000		/* pseudo flag for end-of-message */
29117680Spst
29217680Spst#define LSM_MASK 03			/* mask for modifier field */
29317680Spst#define LSM_NOCHANGE 0			/* no change */
29417680Spst#define LSM_DONOTSEND 1			/* do not send data */
29517680Spst#define LSM_SEND 2			/* send data */
29617680Spst
29717680Spst#define LSI_MASK 014			/* mask for interpretation field */
29817680Spst#define LSI_DATA 0			/* data segment or message count */
29917680Spst#define LSI_INTR 4			/* interrupt request count */
30017680Spst#define LSI_INTM 0377			/* funny marker for int. message */
30117680Spst
30217680Spst#define COS_MASK 014			/* mask for flow control field */
30317680Spst#define COS_NONE 0			/* no flow control */
30417680Spst#define COS_SEGMENT 04			/* segment flow control */
30517680Spst#define COS_MESSAGE 010			/* message flow control */
30617680Spst#define COS_CRYPTSER 020		/* cryptographic services requested */
30717680Spst#define COS_DEFAULT 1			/* default value for field */
30817680Spst
30917680Spst#define COI_MASK 3			/* mask for version field */
31017680Spst#define COI_32 0			/* version 3.2 */
31117680Spst#define COI_31 1			/* version 3.1 */
31217680Spst#define COI_40 2			/* version 4.0 */
31317680Spst#define COI_41 3			/* version 4.1 */
31417680Spst
31517680Spst#define MNU_MASK 140			/* mask for session control version */
31617680Spst#define MNU_10 000				/* session V1.0 */
31717680Spst#define MNU_20 040				/* session V2.0 */
31817680Spst#define MNU_ACCESS 1			/* access control present */
31917680Spst#define MNU_USRDATA 2			/* user data field present */
32017680Spst#define MNU_INVKPROXY 4			/* invoke proxy field present */
32117680Spst#define MNU_UICPROXY 8			/* use uic-based proxy */
32217680Spst
32317680Spst#define DC_NORESOURCES 1		/* no resource reason code */
32417680Spst#define DC_NOLINK 41			/* no link terminate reason code */
32517680Spst#define DC_COMPLETE 42			/* disconnect complete reason code */
32617680Spst
32717680Spst#define DI_NOERROR 0			/* user disconnect */
32817680Spst#define DI_SHUT 3			/* node is shutting down */
32917680Spst#define DI_NOUSER 4			/* destination end user does not exist */
33017680Spst#define DI_INVDEST 5			/* invalid end user destination */
33117680Spst#define DI_REMRESRC 6			/* insufficient remote resources */
33217680Spst#define DI_TPA 8			/* third party abort */
33317680Spst#define DI_PROTOCOL 7			/* protocol error discovered */
33417680Spst#define DI_ABORT 9			/* user abort */
33517680Spst#define DI_LOCALRESRC 32		/* insufficient local resources */
33617680Spst#define DI_REMUSERRESRC 33		/* insufficient remote user resources */
33717680Spst#define DI_BADACCESS 34			/* bad access control information */
33817680Spst#define DI_BADACCNT 36			/* bad ACCOUNT information */
33917680Spst#define DI_CONNECTABORT 38		/* connect request cancelled */
34017680Spst#define DI_TIMEDOUT 38			/* remote node or user crashed */
34117680Spst#define DI_UNREACHABLE 39		/* local timers expired due to ... */
34217680Spst#define DI_BADIMAGE 43			/* bad image data in connect */
34317680Spst#define DI_SERVMISMATCH 54		/* cryptographic service mismatch */
34417680Spst
34517680Spst#define UC_OBJREJECT 0			/* object rejected connect */
34617680Spst#define UC_USERDISCONNECT 0		/* user disconnect */
34717680Spst#define UC_RESOURCES 1			/* insufficient resources (local or remote) */
34817680Spst#define UC_NOSUCHNODE 2			/* unrecognized node name */
34917680Spst#define UC_REMOTESHUT 3			/* remote node shutting down */
35017680Spst#define UC_NOSUCHOBJ 4			/* unrecognized object */
35117680Spst#define UC_INVOBJFORMAT 5		/* invalid object name format */
35217680Spst#define UC_OBJTOOBUSY 6			/* object too busy */
35317680Spst#define UC_NETWORKABORT 8		/* network abort */
35417680Spst#define UC_USERABORT 9			/* user abort */
35517680Spst#define UC_INVNODEFORMAT 10		/* invalid node name format */
35617680Spst#define UC_LOCALSHUT 11			/* local node shutting down */
35717680Spst#define UC_ACCESSREJECT 34		/* invalid access control information */
35817680Spst#define UC_NORESPONSE 38		/* no response from object */
35917680Spst#define UC_UNREACHABLE 39		/* node unreachable */
36017680Spst
36117680Spst/*
36217680Spst * NSP message formats.
36317680Spst */
36417680Spststruct nsphdr				/* general nsp header */
36517680Spst  {
36617680Spst    byte	nh_flags;		/* message flags */
36717680Spst    word	nh_dst;			/* destination link address */
36817680Spst    word	nh_src;			/* source link address */
36917680Spst  };
37017680Spst
37117680Spststruct seghdr				/* data segment header */
37217680Spst  {
37317680Spst    byte	sh_flags;		/* message flags */
37417680Spst    word	sh_dst;			/* destination link address */
37517680Spst    word	sh_src;			/* source link address */
37617680Spst    word	sh_seq[3];		/* sequence numbers */
37717680Spst  };
37817680Spst
37917680Spststruct minseghdr			/* minimum data segment header */
38017680Spst  {
38117680Spst    byte	ms_flags;		/* message flags */
38217680Spst    word	ms_dst;			/* destination link address */
38317680Spst    word	ms_src;			/* source link address */
38417680Spst    word	ms_seq;			/* sequence number */
38517680Spst  };
38617680Spst
38717680Spststruct lsmsg				/* link service message (after hdr) */
38817680Spst  {
38917680Spst    byte	ls_lsflags;		/* link service flags */
39017680Spst    byte	ls_fcval;		/* flow control value */
39117680Spst  };
39217680Spst
39317680Spststruct ackmsg				/* acknowledgement message */
39417680Spst  {
39517680Spst    byte	ak_flags;		/* message flags */
39617680Spst    word	ak_dst;			/* destination link address */
39717680Spst    word	ak_src;			/* source link address */
39817680Spst    word	ak_acknum[2];		/* acknowledgement numbers */
39917680Spst  };
40017680Spst
40117680Spststruct minackmsg			/* minimum acknowledgement message */
40217680Spst  {
40317680Spst    byte	mk_flags;		/* message flags */
40417680Spst    word	mk_dst;			/* destination link address */
40517680Spst    word	mk_src;			/* source link address */
40617680Spst    word	mk_acknum;		/* acknowledgement number */
40717680Spst  };
40817680Spst
40917680Spststruct ciackmsg				/* connect acknowledgement message */
41017680Spst  {
41117680Spst    byte	ck_flags;		/* message flags */
41217680Spst    word	ck_dst;			/* destination link address */
41317680Spst  };
41417680Spst
41517680Spststruct cimsg				/* connect initiate message */
41617680Spst  {
41717680Spst    byte	ci_flags;		/* message flags */
41817680Spst    word	ci_dst;			/* destination link address (0) */
41917680Spst    word	ci_src;			/* source link address */
42017680Spst    byte	ci_services;		/* requested services */
42117680Spst    byte	ci_info;		/* information */
42217680Spst    word	ci_segsize;		/* maximum segment size */
42317680Spst  };
42417680Spst
42517680Spststruct ccmsg				/* connect confirm message */
42617680Spst  {
42717680Spst    byte	cc_flags;		/* message flags */
42817680Spst    word	cc_dst;			/* destination link address */
42917680Spst    word	cc_src;			/* source link address */
43017680Spst    byte	cc_services;		/* requested services */
43117680Spst    byte	cc_info;		/* information */
43217680Spst    word	cc_segsize;		/* maximum segment size */
43317680Spst    byte	cc_optlen;		/* optional data length */
43417680Spst  };
43517680Spst
43617680Spststruct cnmsg				/* generic connect message */
43717680Spst  {
43817680Spst    byte	cn_flags;		/* message flags */
43917680Spst    word	cn_dst;			/* destination link address */
44017680Spst    word	cn_src;			/* source link address */
44117680Spst    byte	cn_services;		/* requested services */
44217680Spst    byte	cn_info;		/* information */
44317680Spst    word	cn_segsize;		/* maximum segment size */
44417680Spst  };
44517680Spst
44617680Spststruct dimsg				/* disconnect initiate message */
44717680Spst  {
44817680Spst    byte	di_flags;		/* message flags */
44917680Spst    word	di_dst;			/* destination link address */
45017680Spst    word	di_src;			/* source link address */
45117680Spst    word	di_reason;		/* reason code */
45217680Spst    byte	di_optlen;		/* optional data length */
45317680Spst  };
45417680Spst
45517680Spststruct dcmsg				/* disconnect confirm message */
45617680Spst  {
45717680Spst    byte	dc_flags;		/* message flags */
45817680Spst    word	dc_dst;			/* destination link address */
45917680Spst    word	dc_src;			/* source link address */
46017680Spst    word	dc_reason;		/* reason code */
46117680Spst  };
462