1 /*	$KAME: dccp.h,v 1.10 2005/10/26 18:46:33 nishida Exp $	*/
2 /* $NetBSD: dccp.h,v 1.1 2015/02/10 19:11:52 rjs Exp $ */
3 
4 /*
5  * Copyright (c) 2003 Joacim H�ggmark, Magnus Erixzon, Nils-Erik Mattsson
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Id: dccp.h,v 1.13 2003/07/31 11:14:41 joahag-9 Exp
32  */
33 
34 #ifndef _NETINET_DCCP_H_
35 #define _NETINET_DCCP_H_
36 
37 /*
38  * DCCP protocol header
39  * draft-ietf-dccp-spec-01.txt
40  */
41 struct dccphdr {
42 	u_short		dh_sport;	/* source port */
43 	u_short		dh_dport;	/* destination port */
44 
45 	u_int8_t	dh_off;		/* Data offset */
46 #if BYTE_ORDER == LITTLE_ENDIAN
47 	u_int8_t	dh_cscov:4,	/* Checksum Length */
48 				dh_ccval:4;	/* Number of non data packets */
49 #else
50 	u_int8_t	dh_ccval:4,
51 				dh_cscov:4;
52 #endif
53 	u_short		dh_sum;		/* Checksum */
54 
55 #if BYTE_ORDER == LITTLE_ENDIAN
56 	u_int32_t	dh_x:1,		/* long/short sequence number */
57 				dh_type:4,
58 				dh_res:3,
59 				dh_seq:24;	/* Sequence number */
60 #else
61 	u_int32_t	dh_res:3,	/* Reserved */
62 				dh_type:4,	/* Type of message */
63 				dh_x:1,		/* long/short sequence number */
64 				dh_seq:24;
65 #endif
66 };
67 
68 struct dccplhdr {
69 	u_short		dh_sport;	/* source port */
70 	u_short		dh_dport;	/* destination port */
71 
72 	u_int8_t	dh_off;		/* Data offset */
73 #if BYTE_ORDER == LITTLE_ENDIAN
74 	u_int8_t	dh_cscov:4,	/* Checksum Length */
75 				dh_ccval:4;	/* Number of non data packets */
76 #else
77 	u_int8_t	dh_ccval:4,
78 				dh_cscov:4;
79 #endif
80 	u_short		dh_sum;		/* Checksum */
81 
82 #if BYTE_ORDER == LITTLE_ENDIAN
83 	u_int8_t	dh_x:1,		/* long/short sequence number */
84 				dh_type:4,
85 				dh_res:3;
86 #else
87 	u_int8_t	dh_res:3,	/* Reserved */
88 				dh_type:4,	/* Type of message */
89 				dh_x:1;		/* long/short sequence number */
90 #endif
91 	u_int8_t	dh_res2;
92 	u_int16_t	dh_seq;
93 	u_int32_t	dh_seq2;	/* long sequence number */
94 };
95 
96 struct dccp_nathdr {
97 	u_int16_t	dh_sport;	/* source port */
98 	u_int16_t	dh_dport;	/* destination port */
99 	u_int8_t	dh_off;
100 #if BYTE_ORDER == LITTLE_ENDIAN
101 	u_int8_t	dh_cscov:4,	/* Checksum Length */
102 				dh_ccval:4;	/* Number of non data packets */
103 #else
104 	u_int8_t	dh_ccval:4,
105 				dh_cscov:4;
106 #endif
107 
108 	u_int16_t	dh_seq;
109 	u_int32_t	dh_seq2;
110 };
111 
112 
113 struct dccp_requesthdr {
114 	u_int32_t	drqh_scode;	/* Service Code */
115 };
116 
117 struct dccp_acksubhdr {
118 #if BYTE_ORDER == LITTLE_ENDIAN
119 	u_int32_t	dah_res:8,  /* Reserved */
120 				dah_ack:24; /* Acknowledgement number */
121 #else
122 	u_int32_t	dah_ack:24,
123 				dah_res:8;
124 #endif
125 };
126 
127 struct dccp_acksublhdr {
128 	u_int16_t	dah_res; /* Reserved */
129 	u_int16_t	dah_ack; /* Acknowledgement number */
130 	u_int32_t   dah_ack2;
131 };
132 
133 struct dccp_ackhdr {
134 	struct dccp_acksubhdr   dash;
135 };
136 
137 struct dccp_acklhdr {
138 	struct dccp_acksublhdr  dash;
139 };
140 
141 struct dccp_resethdr {
142 	struct dccp_acksublhdr  drth_dash;
143 	u_int8_t	drth_reason;	/* Reason */
144 	u_int8_t	drth_data1;	/* Data 1 */
145 	u_int8_t	drth_data2;	/* Data 2 */
146 	u_int8_t	drth_data3;	/* Data 3 */
147 };
148 
149 #define DCCP_TYPE_REQUEST	0
150 #define DCCP_TYPE_RESPONSE	1
151 #define DCCP_TYPE_DATA		2
152 #define DCCP_TYPE_ACK		3
153 #define DCCP_TYPE_DATAACK	4
154 #define DCCP_TYPE_CLOSEREQ	5
155 #define DCCP_TYPE_CLOSE		6
156 #define DCCP_TYPE_RESET		7
157 #define DCCP_TYPE_MOVE		8
158 
159 #define DCCP_FEATURE_CC		1
160 #define DCCP_FEATURE_ECN	2
161 #define DCCP_FEATURE_ACKRATIO	3
162 #define DCCP_FEATURE_ACKVECTOR	4
163 #define DCCP_FEATURE_MOBILITY	5
164 #define DCCP_FEATURE_LOSSWINDOW	6
165 #define DCCP_FEATURE_CONN_NONCE	8
166 #define DCCP_FEATURE_IDENTREG	7
167 
168 #define DCCP_OPT_PADDING		0
169 #define DCCP_OPT_DATA_DISCARD	1
170 #define DCCP_OPT_SLOW_RECV		2
171 #define DCCP_OPT_BUF_CLOSED		3
172 #define DCCP_OPT_CHANGE_L		32
173 #define DCCP_OPT_CONFIRM_L		33
174 #define DCCP_OPT_CHANGE_R		34
175 #define DCCP_OPT_CONFIRM_R		35
176 #define DCCP_OPT_INIT_COOKIE	36
177 #define DCCP_OPT_NDP_COUNT		37
178 #define DCCP_OPT_ACK_VECTOR0	38
179 #define DCCP_OPT_ACK_VECTOR1	39
180 #define DCCP_OPT_RECV_BUF_DROPS 40
181 #define DCCP_OPT_TIMESTAMP		41
182 #define DCCP_OPT_TIMESTAMP_ECHO 42
183 #define DCCP_OPT_ELAPSEDTIME	43
184 #define DCCP_OPT_DATACHECKSUM	44
185 
186 #define DCCP_REASON_UNSPEC	0
187 #define DCCP_REASON_CLOSED	1
188 #define DCCP_REASON_INVALID	2
189 #define DCCP_REASON_OPTION_ERR	3
190 #define DCCP_REASON_FEA_ERR	4
191 #define DCCP_REASON_CONN_REF	5
192 #define DCCP_REASON_BAD_SNAME	6
193 #define DCCP_REASON_BAD_COOKIE	7
194 #define DCCP_REASON_INV_MOVE	8
195 #define DCCP_REASON_UNANSW_CH	10
196 #define DCCP_REASON_FRUITLESS_NEG	11
197 
198 #define DCCP_CCID		0x01
199 #define DCCP_CSLEN		0x02
200 #define DCCP_MAXSEG		0x04
201 #define DCCP_SERVICE	0x08
202 
203 #define DCCP_NDP_LIMIT          16
204 #define DCCP_SEQ_NUM_LIMIT      16777216
205 #define DCCP_MAX_OPTIONS	32
206 #define DCCP_CONNECT_TIMER	(75 * hz)
207 #define DCCP_CLOSE_TIMER	(75 * hz)
208 #define DCCP_TIMEWAIT_TIMER	(60 * hz)
209 #define DCCP_MAX_PKTS		100
210 #endif
211