DataChannelProtocol.h (2872B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_ 8 #define NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_ 9 10 #if defined(__GNUC__) 11 # define SCTP_PACKED __attribute__((packed)) 12 #elif defined(_MSC_VER) 13 # pragma pack(push, 1) 14 # define SCTP_PACKED 15 #else 16 # error "Unsupported compiler" 17 #endif 18 19 #define WEBRTC_DATACHANNEL_STREAMS_DEFAULT 2048 20 // Do not change this value! 21 #define WEBRTC_DATACHANNEL_PORT_DEFAULT 5000 22 // TODO: Bug 1381146, change once we resolve the nsCString limitation 23 #define WEBRTC_DATACHANNEL_MAX_MESSAGE_SIZE_LOCAL 1073741823 24 #define WEBRTC_DATACHANNEL_MAX_MESSAGE_SIZE_REMOTE_DEFAULT 65536 25 // TODO: Bug 1382779, once resolved, can be increased to min(Uint8ArrayMaxSize, 26 // UINT32_MAX) 27 // TODO: Bug 1381146, once resolved, can be increased to whatever we support 28 // then (hopefully SIZE_MAX) or be removed 29 #define WEBRTC_DATACHANNEL_MAX_MESSAGE_SIZE_REMOTE 2147483637 30 31 #define DATA_CHANNEL_PPID_CONTROL 50 32 #define DATA_CHANNEL_PPID_BINARY_PARTIAL 52 33 #define DATA_CHANNEL_PPID_BINARY 53 34 #define DATA_CHANNEL_PPID_DOMSTRING_PARTIAL 54 35 #define DATA_CHANNEL_PPID_DOMSTRING 51 36 #define DATA_CHANNEL_PPID_DOMSTRING_EMPTY 56 37 #define DATA_CHANNEL_PPID_BINARY_EMPTY 57 38 39 #define DATA_CHANNEL_MAX_BINARY_FRAGMENT 0x4000 40 41 #define DATA_CHANNEL_BUFFER_MESSAGE_FLAGS_TOO_LARGE 0x01 42 #define DATA_CHANNEL_BUFFER_MESSAGE_FLAGS_BUFFERED 0x02 43 #define DATA_CHANNEL_BUFFER_MESSAGE_FLAGS_COMPLETE 0x04 44 45 #define INVALID_STREAM (0xFFFF) 46 // max is 0xFFFF: Streams 0 to 0xFFFE = 0xFFFF streams 47 #define MAX_NUM_STREAMS (2048) 48 49 struct rtcweb_datachannel_open_request { 50 uint8_t msg_type; // DATA_CHANNEL_OPEN 51 uint8_t channel_type; 52 int16_t priority; 53 uint32_t reliability_param; 54 uint16_t label_length; 55 uint16_t protocol_length; 56 char label[1]; // (and protocol) keep VC++ happy... 57 } SCTP_PACKED; 58 59 struct rtcweb_datachannel_ack { 60 uint8_t msg_type; // DATA_CHANNEL_ACK 61 } SCTP_PACKED; 62 63 /* msg_type values: */ 64 /* 0-1 were used in an early version of the protocol with 3-way handshakes */ 65 #define DATA_CHANNEL_ACK 2 66 #define DATA_CHANNEL_OPEN_REQUEST 3 67 68 /* channel_type values: */ 69 #define DATA_CHANNEL_RELIABLE 0x00 70 #define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT 0x01 71 #define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED 0x02 72 73 #define DATA_CHANNEL_RELIABLE_UNORDERED 0x80 74 #define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT_UNORDERED 0x81 75 #define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED_UNORDERED 0x82 76 77 #define ERR_DATA_CHANNEL_ALREADY_OPEN 1 78 #define ERR_DATA_CHANNEL_NONE_AVAILABLE 2 79 80 #if defined(_MSC_VER) 81 # pragma pack(pop) 82 # undef SCTP_PACKED 83 #endif 84 85 #endif