xref: /freebsd/sys/netinet/dccp.h (revision 37c8ee8847faa53432809cae2ecc11b80c4eab2f)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2019 Tom Jones <thj@freebsd.org>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29 
30 #ifndef _NETINET_DCCP_H_
31 #define _NETINET_DCCP_H_
32 
33 /* DCCP protocol header as per RFC4340 */
34 struct dccphdr {
35 	uint16_t	d_sport;
36 	uint16_t	d_dport;
37 	uint8_t		d_doff;
38 #if BYTE_ORDER == LITTLE_ENDIAN
39 	uint8_t		d_cscov:4,
40 			d_ccval:4;
41 #endif
42 #if BYTE_ORDER == BIG_ENDIAN
43 	uint8_t		d_ccval:4,
44 			d_cscov:4;
45 #endif
46 	uint8_t		d_cksum[2];
47 #if BYTE_ORDER == LITTLE_ENDIAN
48 	uint8_t		d_res:3,
49 			d_type:4,
50 			d_x:1;
51 #endif
52 #if BYTE_ORDER == BIG_ENDIAN
53 	uint8_t		d_x:1,
54 			d_type:4,
55 			d_res:3;
56 #endif
57        /*
58         * Provide enough space for both the short (24 bit) sequence number and
59         * the long (48 bit) sequene number and a leading reserved byte in
60         * front of the long sequence number.
61         */
62        union dccp_seqno {
63                uint8_t shortseq[3];
64                struct dccp_long_seqno {
65                        uint8_t res;
66                        uint8_t seq[6];
67                } longseq;
68        } d_seqno;
69 };
70 
71 #define d_seqno_short d_seqno.shortseq;
72 #define d_seqno_long d_seqno.longseq.seq;
73 
74 #define DCCP_SHORTHDR	12
75 #define DCCP_LONGHDR	16
76 #define DCCP_EXTHDR	0x80
77 
78 #endif /* _NETINET_DCCP_H */
79