dccp.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  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. #ifndef _NETINET_DCCP_H_
  30. #define _NETINET_DCCP_H_
  31. /* DCCP protocol header as per RFC4340 */
  32. struct dccphdr {
  33. uint16_t d_sport;
  34. uint16_t d_dport;
  35. uint8_t d_doff;
  36. #if BYTE_ORDER == LITTLE_ENDIAN
  37. uint8_t d_cscov:4,
  38. d_ccval:4;
  39. #endif
  40. #if BYTE_ORDER == BIG_ENDIAN
  41. uint8_t d_ccval:4,
  42. d_cscov:4;
  43. #endif
  44. uint8_t d_cksum[2];
  45. #if BYTE_ORDER == LITTLE_ENDIAN
  46. uint8_t d_res:3,
  47. d_type:4,
  48. d_x:1;
  49. #endif
  50. #if BYTE_ORDER == BIG_ENDIAN
  51. uint8_t d_x:1,
  52. d_type:4,
  53. d_res:3;
  54. #endif
  55. /*
  56. * Provide enough space for both the short (24 bit) sequence number and
  57. * the long (48 bit) sequene number and a leading reserved byte in
  58. * front of the long sequence number.
  59. */
  60. union dccp_seqno {
  61. uint8_t shortseq[3];
  62. struct dccp_long_seqno {
  63. uint8_t res;
  64. uint8_t seq[6];
  65. } longseq;
  66. } d_seqno;
  67. };
  68. #define d_seqno_short d_seqno.shortseq;
  69. #define d_seqno_long d_seqno.longseq.seq;
  70. #define DCCP_SHORTHDR 12
  71. #define DCCP_LONGHDR 16
  72. #define DCCP_EXTHDR 0x80
  73. #endif /* _NETINET_DCCP_H */