5d7288f6b49cc304ed1ee6bc90ea5831b66ce6e4
[dragonfly.git] / sys / netproto / atalk / ddp.h
1 /*
2  * Copyright (c) 1990,1991 Regents of The University of Michigan.
3  * All Rights Reserved.
4  *
5  * Permission to use, copy, modify, and distribute this software and
6  * its documentation for any purpose and without fee is hereby granted,
7  * provided that the above copyright notice appears in all copies and
8  * that both that copyright notice and this permission notice appear
9  * in supporting documentation, and that the name of The University
10  * of Michigan not be used in advertising or publicity pertaining to
11  * distribution of the software without specific, written prior
12  * permission. This software is supplied as is without expressed or
13  * implied warranties of any kind.
14  *
15  *      Research Systems Unix Group
16  *      The University of Michigan
17  *      c/o Mike Clark
18  *      535 W. William Street
19  *      Ann Arbor, Michigan
20  *      +1-313-763-0525
21  *      netatalk@itd.umich.edu
22  *
23  * $DragonFly: src/sys/netproto/atalk/ddp.h,v 1.2 2006/10/23 21:50:33 dillon Exp $
24  */
25 #ifndef _NETATALK_DDP_H_
26 #define _NETATALK_DDP_H_
27
28 /*
29  * <-1byte(8bits) ->
30  * +---------------+
31  * | 0 | hopc  |len|
32  * +---------------+
33  * | len (cont)    |
34  * +---------------+
35  * |               |
36  * +- DDP csum    -+
37  * |               |
38  * +---------------+
39  * |               |
40  * +- Dest NET    -+
41  * |               |
42  * +---------------+
43  * |               |
44  * +- Src NET     -+
45  * |               |
46  * +---------------+
47  * | Dest NODE     |
48  * +---------------+
49  * | Src NODE      |
50  * +---------------+
51  * | Dest PORT     |
52  * +---------------+
53  * | Src PORT      |
54  * +---------------+
55  *
56  * On Apples, there is also a ddp_type field, after src_port. However,
57  * under this unix implementation, user level processes need to be able
58  * to set the ddp_type. In later revisions, the ddp_type may only be
59  * available in a raw_appletalk interface.
60  */
61
62 struct elaphdr {
63     u_char      el_dnode;
64     u_char      el_snode;
65     u_char      el_type;
66 };
67
68 #define SZ_ELAPHDR      3
69
70 #define ELAP_DDPSHORT   0x01
71 #define ELAP_DDPEXTEND  0x02
72
73 /*
74  * Extended DDP header. Includes sickness for dealing with arbitrary
75  * bitfields on a little-endian arch.
76  */
77 struct ddpehdr {
78     union {
79         struct {
80 #if BYTE_ORDER == BIG_ENDIAN
81     unsigned            dub_pad:2;
82     unsigned            dub_hops:4;
83     unsigned            dub_len:10;
84     unsigned            dub_sum:16;
85 #endif
86 #if BYTE_ORDER == LITTLE_ENDIAN
87     unsigned            dub_sum:16;
88     unsigned            dub_len:10;
89     unsigned            dub_hops:4;
90     unsigned            dub_pad:2;
91 #endif
92         } du_bits;
93         unsigned        du_bytes;
94     } deh_u;
95 #define deh_pad         deh_u.du_bits.dub_pad
96 #define deh_hops        deh_u.du_bits.dub_hops
97 #define deh_len         deh_u.du_bits.dub_len
98 #define deh_sum         deh_u.du_bits.dub_sum
99 #define deh_bytes       deh_u.du_bytes
100     u_short             deh_dnet;
101     u_short             deh_snet;
102     u_char              deh_dnode;
103     u_char              deh_snode;
104     u_char              deh_dport;
105     u_char              deh_sport;
106 };
107
108 #define DDP_MAXHOPS     15
109
110 struct ddpshdr {
111     union {
112         struct {
113 #if BYTE_ORDER == BIG_ENDIAN
114     unsigned            dub_pad:6;
115     unsigned            dub_len:10;
116     unsigned            dub_dport:8;
117     unsigned            dub_sport:8;
118 #endif
119 #if BYTE_ORDER == LITTLE_ENDIAN
120     unsigned            dub_sport:8;
121     unsigned            dub_dport:8;
122     unsigned            dub_len:10;
123     unsigned            dub_pad:6;
124 #endif
125         } du_bits;
126         unsigned        du_bytes;
127     } dsh_u;
128 #define dsh_pad         dsh_u.du_bits.dub_pad
129 #define dsh_len         dsh_u.du_bits.dub_len
130 #define dsh_dport       dsh_u.du_bits.dub_dport
131 #define dsh_sport       dsh_u.du_bits.dub_sport
132 #define dsh_bytes       dsh_u.du_bytes
133 };
134
135 #endif /* _NETATALK_DDP_H_ */