1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/sctp/datachannel/DataChannelProtocol.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_ 1.11 +#define NETWERK_SCTP_DATACHANNEL_DATACHANNELPROTOCOL_H_ 1.12 + 1.13 +#if defined(__GNUC__) 1.14 +#define SCTP_PACKED __attribute__((packed)) 1.15 +#elif defined(_MSC_VER) 1.16 +#pragma pack (push, 1) 1.17 +#define SCTP_PACKED 1.18 +#else 1.19 +#error "Unsupported compiler" 1.20 +#endif 1.21 + 1.22 +// Duplicated in fsm.def 1.23 +#define WEBRTC_DATACHANNEL_STREAMS_DEFAULT 256 1.24 + 1.25 +#define DATA_CHANNEL_PPID_CONTROL 50 1.26 +#define DATA_CHANNEL_PPID_BINARY 52 1.27 +#define DATA_CHANNEL_PPID_BINARY_LAST 53 1.28 +#define DATA_CHANNEL_PPID_DOMSTRING 54 1.29 +#define DATA_CHANNEL_PPID_DOMSTRING_LAST 51 1.30 + 1.31 +#define DATA_CHANNEL_MAX_BINARY_FRAGMENT 0x4000 1.32 + 1.33 +#define DATA_CHANNEL_FLAGS_SEND_REQ 0x00000001 1.34 +#define DATA_CHANNEL_FLAGS_SEND_RSP 0x00000002 1.35 +#define DATA_CHANNEL_FLAGS_SEND_ACK 0x00000004 1.36 +#define DATA_CHANNEL_FLAGS_OUT_OF_ORDER_ALLOWED 0x00000008 1.37 +#define DATA_CHANNEL_FLAGS_SEND_DATA 0x00000010 1.38 +#define DATA_CHANNEL_FLAGS_FINISH_OPEN 0x00000020 1.39 +#define DATA_CHANNEL_FLAGS_FINISH_RSP 0x00000040 1.40 +#define DATA_CHANNEL_FLAGS_EXTERNAL_NEGOTIATED 0x00000080 1.41 +#define DATA_CHANNEL_FLAGS_WAITING_ACK 0x00000100 1.42 + 1.43 +#define INVALID_STREAM (0xFFFF) 1.44 +// max is 0xFFFF: Streams 0 to 0xFFFE = 0xFFFF streams 1.45 +#define MAX_NUM_STREAMS (2048) 1.46 + 1.47 +struct rtcweb_datachannel_open_request { 1.48 + uint8_t msg_type; // DATA_CHANNEL_OPEN 1.49 + uint8_t channel_type; 1.50 + int16_t priority; 1.51 + uint32_t reliability_param; 1.52 + uint16_t label_length; 1.53 + uint16_t protocol_length; 1.54 + char label[1]; // (and protocol) keep VC++ happy... 1.55 +} SCTP_PACKED; 1.56 + 1.57 +struct rtcweb_datachannel_ack { 1.58 + uint8_t msg_type; // DATA_CHANNEL_ACK 1.59 +} SCTP_PACKED; 1.60 + 1.61 +/* msg_type values: */ 1.62 +/* 0-1 were used in an early version of the protocol with 3-way handshakes */ 1.63 +#define DATA_CHANNEL_ACK 2 1.64 +#define DATA_CHANNEL_OPEN_REQUEST 3 1.65 + 1.66 +/* channel_type values: */ 1.67 +#define DATA_CHANNEL_RELIABLE 0x00 1.68 +#define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT 0x01 1.69 +#define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED 0x02 1.70 + 1.71 +#define DATA_CHANNEL_RELIABLE_UNORDERED 0x80 1.72 +#define DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT_UNORDERED 0x81 1.73 +#define DATA_CHANNEL_PARTIAL_RELIABLE_TIMED_UNORDERED 0x82 1.74 + 1.75 +#define ERR_DATA_CHANNEL_ALREADY_OPEN 1 1.76 +#define ERR_DATA_CHANNEL_NONE_AVAILABLE 2 1.77 + 1.78 +#if defined(_MSC_VER) 1.79 +#pragma pack (pop) 1.80 +#undef SCTP_PACKED 1.81 +#endif 1.82 + 1.83 +#endif