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