]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/tcpdump/dccp.h
This commit was generated by cvs2svn to compensate for changes in r167617,
[FreeBSD/FreeBSD.git] / contrib / tcpdump / dccp.h
1 /* @(#) $Header: /tcpdump/master/tcpdump/dccp.h,v 1.1.2.2 2005/09/20 06:25:45 guy Exp $ (LBL) */
2 /*
3  * Copyright (C) Arnaldo Carvalho de Melo 2004
4  * Copyright (C) Ian McDonald 2005 <iam4@cs.waikato.ac.nz>
5  * Copyright (C) Yoshifumi Nishida 2005
6  *
7  * This software may be distributed either under the terms of the
8  * BSD-style license that accompanies tcpdump or the GNU GPL version 2
9  */
10
11 #ifndef __DCCP_HDR__
12 #define __DCCP_HDR__
13
14 /**
15  * struct dccp_hdr - generic part of DCCP packet header
16  *
17  * @dccph_sport - Relevant port on the endpoint that sent this packet
18  * @dccph_dport - Relevant port on the other endpoint
19  * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
20  * @dccph_ccval - Used by the HC-Sender CCID
21  * @dccph_cscov - Parts of the packet that are covered by the Checksum field
22  * @dccph_checksum - Internet checksum, depends on dccph_cscov
23  * @dccph_x - 0 = 24 bit sequence number, 1 = 48
24  * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
25  * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
26  */
27 struct dccp_hdr {
28         u_int16_t       dccph_sport,
29                         dccph_dport;
30         u_int8_t        dccph_doff;
31         u_int8_t        dccph_ccval_cscov;
32         u_int16_t       dccph_checksum;
33         union {
34         u_int8_t        dccph_xtr;
35         u_int32_t       dccph_seq;
36         }               dccph_xtrs;
37 };
38
39 #define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov) & 0x0F)
40 #define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov >> 4) & 0x0F)
41
42 #define DCCPH_X(dh)     ((dh)->dccph_xtrs.dccph_xtr & 1)
43 #define DCCPH_TYPE(dh)  (((dh)->dccph_xtrs.dccph_xtr >> 1) & 0xF)
44 #define DCCPH_SEQ(dh)   (((dh)->dccph_xtrs.dccph_seq) >> 8)
45
46 /**
47  * struct dccp_hdr_ext - the low bits of a 48 bit seq packet
48  *
49  * @dccph_seq_low - low 24 bits of a 48 bit seq packet
50  */
51 struct dccp_hdr_ext {
52         u_int32_t       dccph_seq_low;
53 };
54
55 /**
56  * struct dccp_hdr_request - Conection initiation request header
57  *
58  * @dccph_req_service - Service to which the client app wants to connect
59  */
60 struct dccp_hdr_request {
61         u_int32_t       dccph_req_service;
62 };
63
64 /**
65  * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
66  *
67  * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
68  * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
69  */
70 struct dccp_hdr_ack_bits {
71         u_int32_t       dccph_ra;
72         u_int32_t       dccph_ack_nr_low;
73 };
74
75 #define DCCPH_ACK(dh_ack)   ((dh_ack)->dccph_ra >> 8)
76
77 /**
78  * struct dccp_hdr_response - Conection initiation response header
79  *
80  * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
81  * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
82  * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
83  */
84 struct dccp_hdr_response {
85         struct dccp_hdr_ack_bits        dccph_resp_ack;
86         u_int32_t                       dccph_resp_service;
87 };
88
89 static inline struct dccp_hdr_data *dccp_hdr_data(struct dccp_hdr *hdrg)
90 {
91         const int ext = DCCPH_X(hdrg) ? sizeof(struct dccp_hdr_ext) : 0;
92
93         return (struct dccp_hdr_data *)(((u_char *)hdrg) + sizeof(hdrg) + ext);
94 }
95
96 /**
97  * struct dccp_hdr_reset - Unconditionally shut down a connection
98  *
99  * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
100  */
101 struct dccp_hdr_reset {
102         struct dccp_hdr_ack_bits        dccph_reset_ack;
103         u_int8_t                        dccph_reset_code,
104                                         dccph_reset_data[3];
105 };
106
107 enum dccp_pkt_type {
108         DCCP_PKT_REQUEST = 0,
109         DCCP_PKT_RESPONSE,
110         DCCP_PKT_DATA,
111         DCCP_PKT_ACK,
112         DCCP_PKT_DATAACK,
113         DCCP_PKT_CLOSEREQ,
114         DCCP_PKT_CLOSE,
115         DCCP_PKT_RESET,
116         DCCP_PKT_SYNC,
117         DCCP_PKT_SYNCACK,
118         DCCP_PKT_INVALID,
119 };
120
121 enum dccp_reset_codes {
122         DCCP_RESET_CODE_UNSPECIFIED = 0,
123         DCCP_RESET_CODE_CLOSED,
124         DCCP_RESET_CODE_ABORTED,
125         DCCP_RESET_CODE_NO_CONNECTION,
126         DCCP_RESET_CODE_PACKET_ERROR,
127         DCCP_RESET_CODE_OPTION_ERROR,
128         DCCP_RESET_CODE_MANDATORY_ERROR,
129         DCCP_RESET_CODE_CONNECTION_REFUSED,
130         DCCP_RESET_CODE_BAD_SERVICE_CODE,
131         DCCP_RESET_CODE_TOO_BUSY,
132         DCCP_RESET_CODE_BAD_INIT_COOKIE,
133         DCCP_RESET_CODE_AGGRESSION_PENALTY,
134         __DCCP_RESET_CODE_LAST,
135 };
136
137 #endif /* __DCCP_HDR__ */