1139827Simp/*-
2165974Srwatson * Copyright (c) 1990, 1991 Regents of The University of Michigan.
315885Sjulian * All Rights Reserved.
415885Sjulian *
515885Sjulian * Permission to use, copy, modify, and distribute this software and
615885Sjulian * its documentation for any purpose and without fee is hereby granted,
715885Sjulian * provided that the above copyright notice appears in all copies and
815885Sjulian * that both that copyright notice and this permission notice appear
915885Sjulian * in supporting documentation, and that the name of The University
1015885Sjulian * of Michigan not be used in advertising or publicity pertaining to
1115885Sjulian * distribution of the software without specific, written prior
1215885Sjulian * permission. This software is supplied as is without expressed or
1315885Sjulian * implied warranties of any kind.
1415885Sjulian *
1515885Sjulian *	Research Systems Unix Group
1615885Sjulian *	The University of Michigan
1715885Sjulian *	c/o Mike Clark
1815885Sjulian *	535 W. William Street
1915885Sjulian *	Ann Arbor, Michigan
2015885Sjulian *	+1-313-763-0525
2115885Sjulian *	netatalk@itd.umich.edu
22139827Simp *
23139827Simp * $FreeBSD$
2415885Sjulian */
25165974Srwatson
2615885Sjulian#ifndef _NETATALK_DDP_H_
27165974Srwatson#define	_NETATALK_DDP_H_
2815885Sjulian
29165974Srwatson/*-
3015885Sjulian * <-1byte(8bits) ->
3115885Sjulian * +---------------+
3215885Sjulian * | 0 | hopc  |len|
3315885Sjulian * +---------------+
3415885Sjulian * | len (cont)    |
3515885Sjulian * +---------------+
3615885Sjulian * |               |
3715885Sjulian * +- DDP csum    -+
3815885Sjulian * |               |
3915885Sjulian * +---------------+
4015885Sjulian * |               |
4115885Sjulian * +- Dest NET    -+
4215885Sjulian * |               |
4315885Sjulian * +---------------+
4415885Sjulian * |               |
4515885Sjulian * +- Src NET     -+
4615885Sjulian * |               |
4715885Sjulian * +---------------+
4815885Sjulian * | Dest NODE     |
4915885Sjulian * +---------------+
5015885Sjulian * | Src NODE      |
5115885Sjulian * +---------------+
5215885Sjulian * | Dest PORT     |
5315885Sjulian * +---------------+
5415885Sjulian * | Src PORT      |
5515885Sjulian * +---------------+
5615885Sjulian *
57165974Srwatson * On Apples, there is also a ddp_type field, after src_port.  However, under
58165974Srwatson * this unix implementation, user level processes need to be able to set the
59165974Srwatson * ddp_type.  In later revisions, the ddp_type may only be available in a
60165974Srwatson * raw_appletalk interface.
6115885Sjulian */
6215885Sjulian
6315885Sjulianstruct elaphdr {
64165974Srwatson	u_char	el_dnode;
65165974Srwatson	u_char	el_snode;
66165974Srwatson	u_char	el_type;
67171078Srwatson} __packed;
6815885Sjulian
6915885Sjulian#define	SZ_ELAPHDR	3
7015885Sjulian
71165974Srwatson#define	ELAP_DDPSHORT	0x01
72165974Srwatson#define	ELAP_DDPEXTEND	0x02
7315885Sjulian
7415885Sjulian/*
7515885Sjulian * Extended DDP header. Includes sickness for dealing with arbitrary
7615885Sjulian * bitfields on a little-endian arch.
7715885Sjulian */
7815885Sjulianstruct ddpehdr {
79165974Srwatson	union {
80165974Srwatson		struct {
8115885Sjulian#if BYTE_ORDER == BIG_ENDIAN
82165974Srwatson			unsigned	dub_pad:2;
83165974Srwatson			unsigned	dub_hops:4;
84165974Srwatson			unsigned	dub_len:10;
85165974Srwatson			unsigned	dub_sum:16;
8615885Sjulian#endif
8715885Sjulian#if BYTE_ORDER == LITTLE_ENDIAN
88165974Srwatson			unsigned	dub_sum:16;
89165974Srwatson			unsigned	dub_len:10;
90165974Srwatson			unsigned	dub_hops:4;
91165974Srwatson			unsigned	dub_pad:2;
9215885Sjulian#endif
93171078Srwatson		} __packed du_bits;
94165974Srwatson		unsigned	du_bytes;
95165974Srwatson	} deh_u;
96165974Srwatson	u_short	deh_dnet;
97165974Srwatson	u_short	deh_snet;
98165974Srwatson	u_char	deh_dnode;
99165974Srwatson	u_char	deh_snode;
100165974Srwatson	u_char	deh_dport;
101165974Srwatson	u_char	deh_sport;
102171078Srwatson} __packed;
103165974Srwatson#define	deh_pad		deh_u.du_bits.dub_pad
104165974Srwatson#define	deh_hops	deh_u.du_bits.dub_hops
105165974Srwatson#define	deh_len		deh_u.du_bits.dub_len
106165974Srwatson#define	deh_sum		deh_u.du_bits.dub_sum
107165974Srwatson#define	deh_bytes	deh_u.du_bytes
10815885Sjulian
109165974Srwatson#define	DDP_MAXHOPS	15
11015885Sjulian
11115885Sjulianstruct ddpshdr {
112165974Srwatson	union {
113165974Srwatson		struct {
11415885Sjulian#if BYTE_ORDER == BIG_ENDIAN
115165974Srwatson			unsigned	dub_pad:6;
116165974Srwatson			unsigned	dub_len:10;
117165974Srwatson			unsigned	dub_dport:8;
118165974Srwatson			unsigned	dub_sport:8;
11915885Sjulian#endif
12015885Sjulian#if BYTE_ORDER == LITTLE_ENDIAN
121165974Srwatson			unsigned	dub_sport:8;
122165974Srwatson			unsigned	dub_dport:8;
123165974Srwatson			unsigned	dub_len:10;
124165974Srwatson			unsigned	dub_pad:6;
12515885Sjulian#endif
126171078Srwatson		} __packed du_bits;
127165974Srwatson		unsigned	du_bytes;
128165974Srwatson	} dsh_u;
129171078Srwatson} __packed;
130171078Srwatson
131165974Srwatson#define	dsh_pad		dsh_u.du_bits.dub_pad
132165974Srwatson#define	dsh_len		dsh_u.du_bits.dub_len
133165974Srwatson#define	dsh_dport	dsh_u.du_bits.dub_dport
134165974Srwatson#define	dsh_sport	dsh_u.du_bits.dub_sport
135165974Srwatson#define	dsh_bytes	dsh_u.du_bytes
13615885Sjulian
13715885Sjulian#endif /* _NETATALK_DDP_H_ */
138