dccp.h revision 172683
1235537Sgber/* @(#) $Header: /tcpdump/master/tcpdump/dccp.h,v 1.1.2.4 2006/05/12 01:46:17 guy Exp $ (LBL) */ 2235537Sgber/* 3235537Sgber * Copyright (C) Arnaldo Carvalho de Melo 2004 4235537Sgber * Copyright (C) Ian McDonald 2005 <iam4@cs.waikato.ac.nz> 5235537Sgber * Copyright (C) Yoshifumi Nishida 2005 6235537Sgber * 7235537Sgber * This software may be distributed either under the terms of the 8235537Sgber * BSD-style license that accompanies tcpdump or the GNU GPL version 2 9235537Sgber */ 10235537Sgber 11235537Sgber#ifndef __DCCP_HDR__ 12235537Sgber#define __DCCP_HDR__ 13235537Sgber 14235537Sgber/** 15235537Sgber * struct dccp_hdr - generic part of DCCP packet header 16235537Sgber * 17235537Sgber * @dccph_sport - Relevant port on the endpoint that sent this packet 18235537Sgber * @dccph_dport - Relevant port on the other endpoint 19235537Sgber * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words 20235537Sgber * @dccph_ccval - Used by the HC-Sender CCID 21235537Sgber * @dccph_cscov - Parts of the packet that are covered by the Checksum field 22235537Sgber * @dccph_checksum - Internet checksum, depends on dccph_cscov 23235537Sgber * @dccph_x - 0 = 24 bit sequence number, 1 = 48 24235537Sgber * @dccph_type - packet type, see DCCP_PKT_ prefixed macros 25235537Sgber * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x 26235537Sgber */ 27235537Sgberstruct dccp_hdr { 28235537Sgber u_int16_t dccph_sport, 29235537Sgber dccph_dport; 30235537Sgber u_int8_t dccph_doff; 31235537Sgber u_int8_t dccph_ccval_cscov; 32235537Sgber u_int16_t dccph_checksum; 33235537Sgber union { 34235537Sgber u_int8_t dccph_xtr; 35235537Sgber u_int32_t dccph_seq; 36235537Sgber } dccph_xtrs; 37235537Sgber}; 38235537Sgber 39235537Sgber#define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov) & 0x0F) 40245953Sian#define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov >> 4) & 0x0F) 41245953Sian 42235537Sgber#define DCCPH_X(dh) ((dh)->dccph_xtrs.dccph_xtr & 1) 43235537Sgber#define DCCPH_TYPE(dh) (((dh)->dccph_xtrs.dccph_xtr >> 1) & 0xF) 44235537Sgber#define DCCPH_SEQ(dh) (((dh)->dccph_xtrs.dccph_seq) >> 8) 45235537Sgber 46235537Sgber/** 47235537Sgber * struct dccp_hdr_ext - the low bits of a 48 bit seq packet 48235537Sgber * 49235537Sgber * @dccph_seq_low - low 24 bits of a 48 bit seq packet 50259371Sian */ 51259371Sianstruct dccp_hdr_ext { 52235537Sgber u_int32_t dccph_seq_low; 53235537Sgber}; 54235537Sgber 55235537Sgber/** 56235537Sgber * struct dccp_hdr_request - Conection initiation request header 57235537Sgber * 58235537Sgber * @dccph_req_service - Service to which the client app wants to connect 59235537Sgber */ 60235537Sgberstruct dccp_hdr_request { 61235537Sgber u_int32_t dccph_req_service; 62235537Sgber}; 63235537Sgber 64235537Sgber/** 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 */ 70struct 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 */ 84struct dccp_hdr_response { 85 struct dccp_hdr_ack_bits dccph_resp_ack; 86 u_int32_t dccph_resp_service; 87}; 88 89#if 0 90static inline struct dccp_hdr_data *dccp_hdr_data(struct dccp_hdr *hdrg) 91{ 92 const int ext = DCCPH_X(hdrg) ? sizeof(struct dccp_hdr_ext) : 0; 93 94 return (struct dccp_hdr_data *)(((u_char *)hdrg) + sizeof(hdrg) + ext); 95} 96#endif 97 98/** 99 * struct dccp_hdr_reset - Unconditionally shut down a connection 100 * 101 * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request 102 */ 103struct dccp_hdr_reset { 104 struct dccp_hdr_ack_bits dccph_reset_ack; 105 u_int8_t dccph_reset_code, 106 dccph_reset_data[3]; 107}; 108 109enum dccp_pkt_type { 110 DCCP_PKT_REQUEST = 0, 111 DCCP_PKT_RESPONSE, 112 DCCP_PKT_DATA, 113 DCCP_PKT_ACK, 114 DCCP_PKT_DATAACK, 115 DCCP_PKT_CLOSEREQ, 116 DCCP_PKT_CLOSE, 117 DCCP_PKT_RESET, 118 DCCP_PKT_SYNC, 119 DCCP_PKT_SYNCACK, 120 DCCP_PKT_INVALID 121}; 122 123enum dccp_reset_codes { 124 DCCP_RESET_CODE_UNSPECIFIED = 0, 125 DCCP_RESET_CODE_CLOSED, 126 DCCP_RESET_CODE_ABORTED, 127 DCCP_RESET_CODE_NO_CONNECTION, 128 DCCP_RESET_CODE_PACKET_ERROR, 129 DCCP_RESET_CODE_OPTION_ERROR, 130 DCCP_RESET_CODE_MANDATORY_ERROR, 131 DCCP_RESET_CODE_CONNECTION_REFUSED, 132 DCCP_RESET_CODE_BAD_SERVICE_CODE, 133 DCCP_RESET_CODE_TOO_BUSY, 134 DCCP_RESET_CODE_BAD_INIT_COOKIE, 135 DCCP_RESET_CODE_AGGRESSION_PENALTY, 136 __DCCP_RESET_CODE_LAST 137}; 138 139#endif /* __DCCP_HDR__ */ 140