Amazon Kinesis Webrtc C SDK
 
Loading...
Searching...
No Matches
Include_i.h
Go to the documentation of this file.
1/*******************************************
2Main internal include file
3*******************************************/
4#ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_INCLUDE_I__
5#define __KINESIS_VIDEO_WEBRTC_CLIENT_INCLUDE_I__
6
7#pragma once
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#ifdef _WIN32
14#include <winsock2.h>
15#include <iphlpapi.h>
16#include <ws2tcpip.h>
17
18#ifndef MSG_NOSIGNAL
19#define MSG_NOSIGNAL 0
20#endif
21
22#endif
23
25// Project include files
28
29#ifdef KVS_USE_OPENSSL
30#include <openssl/bio.h>
31#include <openssl/err.h>
32#include <openssl/hmac.h>
33#include <openssl/md5.h>
34#include <openssl/rand.h>
35#include <openssl/sha.h>
36#include <openssl/ssl.h>
37#elif KVS_USE_MBEDTLS
38/* mbedTLS 4 moved legacy entropy/CTR-DRBG/hash/RSA/ECP/bignum headers under
39 * mbedtls/private/ and gates their prototypes behind
40 * MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS. The symbols still ship in libmbedcrypto,
41 * so we declare the macro before mbedtls/ssl.h to re-expose them across all
42 * includes below. Note: mbedtls/private/* is explicitly unsupported upstream
43 * and may break across v4.x point releases. TODO: migrate to PSA Crypto APIs
44 * (psa_crypto_init + psa_generate_random + psa_hash_compute + psa_mac_compute)
45 * in a follow-up so we can drop this opt-out. */
46/* Nested guard: a bare __has_include(...) in an #if is a syntax error on
47 * pre-C23 / older compilers (e.g. GCC < 5) — the && does not stop the parse.
48 * #ifdef __has_include is safe everywhere; only use the operator when present. */
49#ifdef __has_include
50#if __has_include(<mbedtls/build_info.h>)
51#include <mbedtls/build_info.h>
52#else
53#include <mbedtls/version.h>
54#endif
55#else
56#include <mbedtls/version.h>
57#endif
58#if defined(MBEDTLS_VERSION_NUMBER) && MBEDTLS_VERSION_MAJOR >= 4
59#define MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS
60#endif
61#include <mbedtls/ssl.h>
62#include <mbedtls/error.h>
63#if defined(MBEDTLS_VERSION_NUMBER) && MBEDTLS_VERSION_MAJOR >= 4
64#include <mbedtls/private/entropy.h>
65#include <mbedtls/private/ctr_drbg.h>
66#include <mbedtls/private/sha256.h>
67#include <mbedtls/private/md5.h>
68#include <mbedtls/md.h>
69#include <mbedtls/pk.h>
70#include <mbedtls/private/rsa.h>
71#include <mbedtls/private/ecp.h>
72#include <mbedtls/private/bignum.h>
73#else
74#include <mbedtls/entropy.h>
75#include <mbedtls/ctr_drbg.h>
76#if MBEDTLS_VERSION_NUMBER < 0x03000000
77#include <mbedtls/certs.h>
78#endif
79#include <mbedtls/sha256.h>
80#include <mbedtls/md5.h>
81#endif
82#endif
83
84#ifdef USE_LIBSRTP3
85#include <srtp3/srtp.h>
86#else
87#include <srtp2/srtp.h>
88#endif
89
90// INET/INET6 MUST be defined before usrsctp
91// If removed will cause corruption that is hard to determine at runtime
92#define INET 1
93#define INET6 1
94#include <usrsctp.h>
95
96#if !defined __WINDOWS_BUILD__
97#include <signal.h>
98#include <sys/types.h>
99#ifdef HAVE_IFADDRS_H
100#include <ifaddrs.h>
101#endif
102#include <sys/types.h>
103#include <sys/socket.h>
104#include <netdb.h>
105#include <net/if.h>
106#include <arpa/inet.h>
107#include <fcntl.h>
108#include <netinet/tcp.h>
109#ifdef HAVE_POLL_H
110#include <poll.h>
111#endif
112#endif
113
114// Max uFrag and uPwd length as documented in https://tools.ietf.org/html/rfc5245#section-15.4
115#define ICE_MAX_UFRAG_LEN 256
116#define ICE_MAX_UPWD_LEN 256
117
118// Max stun username attribute len: https://tools.ietf.org/html/rfc5389#section-15.3
119#define STUN_MAX_USERNAME_LEN (UINT16) 512
120
121// https://tools.ietf.org/html/rfc5389#section-15.7
122#define STUN_MAX_REALM_LEN (UINT16) 128
123
124// https://tools.ietf.org/html/rfc5389#section-15.8
125#define STUN_MAX_NONCE_LEN (UINT16) 128
126
127// https://tools.ietf.org/html/rfc5389#section-15.6
128#define STUN_MAX_ERROR_PHRASE_LEN (UINT16) 128
129
130// Byte sizes of the IP addresses
131#define IPV6_ADDRESS_LENGTH (UINT16) 16
132#define IPV4_ADDRESS_LENGTH (UINT16) 4
133
134#define CERTIFICATE_FINGERPRINT_LENGTH 160
135
136#define MAX_UDP_PACKET_SIZE 65507
137
138typedef enum {
139 KVS_IP_FAMILY_TYPE_NOT_SET = (UINT16) 0x0000, // Sentinel value for not yet set IP address.
140 KVS_IP_FAMILY_TYPE_IPV4 = (UINT16) 0x0001,
141 KVS_IP_FAMILY_TYPE_IPV6 = (UINT16) 0x0002,
143
144typedef struct {
145 UINT16 family;
146 UINT16 port; // port is stored in network byte order
147 BYTE address[IPV6_ADDRESS_LENGTH]; // address is stored in network byte order
150
151// This structure stores both an IPv4 and IPv6 address (if applicable).
156
157static inline BOOL IS_IPV4_ADDR(const PKvsIpAddress pAddress)
158{
159 return pAddress != NULL && pAddress->family == KVS_IP_FAMILY_TYPE_IPV4;
160}
161
162static inline BOOL IS_IPV6_ADDR(const PKvsIpAddress pAddress)
163{
164 return pAddress != NULL && pAddress->family == KVS_IP_FAMILY_TYPE_IPV6;
165}
166
167// Used for ensuring alignment
168#define ALIGN_UP_TO_MACHINE_WORD(x) ROUND_UP((x), SIZEOF(SIZE_T))
169
170typedef STATUS (*IceServerSetIpFunc)(UINT64, PCHAR, PDualKvsIpAddresses);
171STATUS getIpAddrStr(PKvsIpAddress pKvsIpAddress, PCHAR pBuffer, UINT32 bufferLen);
172
174// Project forward declarations
176struct __TurnConnection;
177struct __SocketConnection;
178STATUS generateJSONSafeString(PCHAR, UINT32);
179
181// Project internal includes
184#include "Crypto/IOBuffer.h"
185#include "Crypto/Crypto.h"
186#include "Crypto/Dtls.h"
187#include "Crypto/Tls.h"
188#include "Ice/Network.h"
189#include "Ice/SocketConnection.h"
191#include "Stun/Stun.h"
192#include "Ice/IceUtils.h"
193#include "Sdp/Sdp.h"
194#include "Ice/IceAgent.h"
195#include "Ice/TurnConnection.h"
199#include "Srtp/SrtpSession.h"
200#include "Sctp/Sctp.h"
201#include "Signaling/FileCache.h"
202#include "Signaling/Signaling.h"
206#include "Rtp/RtpPacket.h"
207#include "Rtcp/RtcpPacket.h"
208#include "Rtcp/RollingBuffer.h"
214#include "PeerConnection/Rtp.h"
215#include "PeerConnection/Rtcp.h"
222#include "Metrics/Metrics.h"
223
225// Project internal defines
227
229// Project internal functions
231
232#define KVS_CONVERT_TIMESCALE(pts, from_timescale, to_timescale) (pts * to_timescale / from_timescale)
233
234#ifdef __cplusplus
235}
236#endif
237#endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_INCLUDE_I__ */
KVS_IP_FAMILY_TYPE
Definition Include_i.h:138
@ KVS_IP_FAMILY_TYPE_IPV4
Definition Include_i.h:140
@ KVS_IP_FAMILY_TYPE_NOT_SET
Definition Include_i.h:139
@ KVS_IP_FAMILY_TYPE_IPV6
Definition Include_i.h:141
#define IPV6_ADDRESS_LENGTH
Definition Include_i.h:131
STATUS generateJSONSafeString(PCHAR, UINT32)
Definition PeerConnection.c:711
struct DualKvsIpAddresses * PDualKvsIpAddresses
struct KvsIpAddress * PKvsIpAddress
STATUS getIpAddrStr(PKvsIpAddress pKvsIpAddress, PCHAR pBuffer, UINT32 bufferLen)
Definition Network.c:636
STATUS(* IceServerSetIpFunc)(UINT64, PCHAR, PDualKvsIpAddresses)
Definition Include_i.h:170
Definition Include_i.h:152
KvsIpAddress ipv4Address
Definition Include_i.h:153
KvsIpAddress ipv6Address
Definition Include_i.h:154
Definition Include_i.h:144
UINT16 port
Definition Include_i.h:146
BOOL isPointToPoint
Definition Include_i.h:148
UINT16 family
Definition Include_i.h:145
Definition SocketConnection.h:25
Definition TurnConnection.h:119