DataChannelProtocol.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_
  6. #define NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_
  7. #if defined(__GNUC__)
  8. #define SCTP_PACKED __attribute__((packed))
  9. #elif defined(_MSC_VER)
  10. #pragma pack (push, 1)
  11. #define SCTP_PACKED
  12. #else
  13. #error "Unsupported compiler"
  14. #endif
  15. // Duplicated in fsm.def
  16. #define WEBRTC_DATACHANNEL_STREAMS_DEFAULT 256
  17. #define DATA_CHANNEL_PPID_CONTROL 50
  18. #define DATA_CHANNEL_PPID_BINARY 52
  19. #define DATA_CHANNEL_PPID_BINARY_LAST 53
  20. #define DATA_CHANNEL_PPID_DOMSTRING 54
  21. #define DATA_CHANNEL_PPID_DOMSTRING_LAST 51
  22. #define DATA_CHANNEL_MAX_BINARY_FRAGMENT 0x4000
  23. #define DATA_CHANNEL_FLAGS_SEND_REQ 0x00000001
  24. #define DATA_CHANNEL_FLAGS_SEND_RSP 0x00000002
  25. #define DATA_CHANNEL_FLAGS_SEND_ACK 0x00000004
  26. #define DATA_CHANNEL_FLAGS_OUT_OF_ORDER_ALLOWED 0x00000008
  27. #define DATA_CHANNEL_FLAGS_SEND_DATA 0x00000010
  28. #define DATA_CHANNEL_FLAGS_FINISH_OPEN 0x00000020
  29. #define DATA_CHANNEL_FLAGS_FINISH_RSP 0x00000040
  30. #define DATA_CHANNEL_FLAGS_EXTERNAL_NEGOTIATED 0x00000080
  31. #define DATA_CHANNEL_FLAGS_WAITING_ACK 0x00000100
  32. #define INVALID_STREAM (0xFFFF)
  33. // max is 0xFFFF: Streams 0 to 0xFFFE = 0xFFFF streams
  34. #define MAX_NUM_STREAMS (2048)
  35. struct rtcweb_datachannel_open_request {
  36. uint8_t msg_type; // DATA_CHANNEL_OPEN
  37. uint8_t channel_type;
  38. int16_t priority;
  39. uint32_t reliability_param;
  40. uint16_t label_length;
  41. uint16_t protocol_length;
  42. char label[1]; // (and protocol) keep VC++ happy...
  43. } SCTP_PACKED;
  44. struct rtcweb_datachannel_ack {
  45. uint8_t msg_type; // DATA_CHANNEL_ACK
  46. } SCTP_PACKED;
  47. /* msg_type values: */
  48. /* 0-1 were used in an early version of the protocol with 3-way handshakes */
  49. #define DATA_CHANNEL_ACK 2
  50. #define DATA_CHANNEL_OPEN_REQUEST 3
  51. /* channel_type values: */
  52. #define DATA_CHANNEL_RELIABLE 0x00
  53. #define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT 0x01
  54. #define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED 0x02
  55. #define DATA_CHANNEL_RELIABLE_UNORDERED 0x80
  56. #define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT_UNORDERED 0x81
  57. #define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED_UNORDERED 0x82
  58. #define ERR_DATA_CHANNEL_ALREADY_OPEN 1
  59. #define ERR_DATA_CHANNEL_NONE_AVAILABLE 2
  60. #if defined(_MSC_VER)
  61. #pragma pack (pop)
  62. #undef SCTP_PACKED
  63. #endif
  64. #endif