michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_ michael@0: #define NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_ michael@0: michael@0: #if defined(__GNUC__) michael@0: #define SCTP_PACKED __attribute__((packed)) michael@0: #elif defined(_MSC_VER) michael@0: #pragma pack (push, 1) michael@0: #define SCTP_PACKED michael@0: #else michael@0: #error "Unsupported compiler" michael@0: #endif michael@0: michael@0: // Duplicated in fsm.def michael@0: #define WEBRTC_DATACHANNEL_STREAMS_DEFAULT 256 michael@0: michael@0: #define DATA_CHANNEL_PPID_CONTROL 50 michael@0: #define DATA_CHANNEL_PPID_BINARY 52 michael@0: #define DATA_CHANNEL_PPID_BINARY_LAST 53 michael@0: #define DATA_CHANNEL_PPID_DOMSTRING 54 michael@0: #define DATA_CHANNEL_PPID_DOMSTRING_LAST 51 michael@0: michael@0: #define DATA_CHANNEL_MAX_BINARY_FRAGMENT 0x4000 michael@0: michael@0: #define DATA_CHANNEL_FLAGS_SEND_REQ 0x00000001 michael@0: #define DATA_CHANNEL_FLAGS_SEND_RSP 0x00000002 michael@0: #define DATA_CHANNEL_FLAGS_SEND_ACK 0x00000004 michael@0: #define DATA_CHANNEL_FLAGS_OUT_OF_ORDER_ALLOWED 0x00000008 michael@0: #define DATA_CHANNEL_FLAGS_SEND_DATA 0x00000010 michael@0: #define DATA_CHANNEL_FLAGS_FINISH_OPEN 0x00000020 michael@0: #define DATA_CHANNEL_FLAGS_FINISH_RSP 0x00000040 michael@0: #define DATA_CHANNEL_FLAGS_EXTERNAL_NEGOTIATED 0x00000080 michael@0: #define DATA_CHANNEL_FLAGS_WAITING_ACK 0x00000100 michael@0: michael@0: #define INVALID_STREAM (0xFFFF) michael@0: // max is 0xFFFF: Streams 0 to 0xFFFE = 0xFFFF streams michael@0: #define MAX_NUM_STREAMS (2048) michael@0: michael@0: struct rtcweb_datachannel_open_request { michael@0: uint8_t msg_type; // DATA_CHANNEL_OPEN michael@0: uint8_t channel_type; michael@0: int16_t priority; michael@0: uint32_t reliability_param; michael@0: uint16_t label_length; michael@0: uint16_t protocol_length; michael@0: char label[1]; // (and protocol) keep VC++ happy... michael@0: } SCTP_PACKED; michael@0: michael@0: struct rtcweb_datachannel_ack { michael@0: uint8_t msg_type; // DATA_CHANNEL_ACK michael@0: } SCTP_PACKED; michael@0: michael@0: /* msg_type values: */ michael@0: /* 0-1 were used in an early version of the protocol with 3-way handshakes */ michael@0: #define DATA_CHANNEL_ACK 2 michael@0: #define DATA_CHANNEL_OPEN_REQUEST 3 michael@0: michael@0: /* channel_type values: */ michael@0: #define DATA_CHANNEL_RELIABLE 0x00 michael@0: #define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT 0x01 michael@0: #define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED 0x02 michael@0: michael@0: #define DATA_CHANNEL_RELIABLE_UNORDERED 0x80 michael@0: #define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT_UNORDERED 0x81 michael@0: #define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED_UNORDERED 0x82 michael@0: michael@0: #define ERR_DATA_CHANNEL_ALREADY_OPEN 1 michael@0: #define ERR_DATA_CHANNEL_NONE_AVAILABLE 2 michael@0: michael@0: #if defined(_MSC_VER) michael@0: #pragma pack (pop) michael@0: #undef SCTP_PACKED michael@0: #endif michael@0: michael@0: #endif