|
cwist
Modern C web framework with libttak runtime
|
Internal types and cross-file helpers for the WebRTC DataChannel module (ICE-lite + DTLS + SCTP over UDP). More...
#include <cwist/net/webrtc.h>#include <cwist/sys/io/reactor.h>#include <netinet/in.h>#include <openssl/ssl.h>#include <pthread.h>#include <stdatomic.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <sys/socket.h>#include <sys/types.h>

Go to the source code of this file.
Classes | |
| struct | cwist_webrtc_msg |
| A DataChannel message on its way into SCTP. More... | |
| struct | cwist_webrtc_conn |
| One peer: ICE state, DTLS session, SCTP association. More... | |
| struct | cwist_webrtc_ctx |
| A UDP endpoint bound to one reactor, serving many conns. More... | |
| struct | cwist_sdp_info |
| Fields the ICE-lite agent needs from an SDP description. More... | |
Macros | |
| #define | CWIST_WEBRTC_MAX_MESSAGE 262144 |
| #define | CWIST_WEBRTC_MAX_BUFFERED (4u << 20) |
| #define | CWIST_WEBRTC_DGRAM_MAX 2048 |
| #define | CWIST_WEBRTC_RX_BATCH 32 |
| #define | CWIST_WEBRTC_TX_BATCH 64 |
STUN message types (ice.c) | |
| #define | CWIST_STUN_BINDING_REQUEST 0x0001 |
| #define | CWIST_STUN_BINDING_RESPONSE 0x0101 |
Typedefs | |
| typedef struct cwist_webrtc_msg | cwist_webrtc_msg |
| A DataChannel message on its way into SCTP. | |
Enumerations | |
| enum | cwist_conn_state { CWIST_CONN_STUN = 0 , CWIST_CONN_DTLS = 1 , CWIST_CONN_ESTABLISHED = 2 , CWIST_CONN_CLOSED = 3 } |
Functions | |
ICE-lite STUN (ice.c) | |
| int | cwist_ice_stun_is_message (const uint8_t *buf, size_t len) |
Non-zero if buf looks like a STUN message (magic cookie, length). | |
| bool | cwist_ice_stun_is_binding_request (const uint8_t *buf, size_t len) |
true if buf is a STUN Binding request. | |
| bool | cwist_ice_stun_has_use_candidate (const uint8_t *buf, size_t len) |
| true if the request carries USE-CANDIDATE (nomination). | |
| int | cwist_ice_stun_get_remote_ufrag (const uint8_t *buf, size_t len, char *out, size_t cap) |
| Extract the sender's ufrag from USERNAME ("recipient:sender", RFC 8445 section 7.2.2) – the peer's SDP ice-ufrag. | |
| int | cwist_ice_stun_validate_request (const uint8_t *buf, size_t len, const char *pwd) |
Check MESSAGE-INTEGRITY (HMAC-SHA1 keyed with pwd). | |
| int | cwist_ice_stun_build_response (uint8_t *out, size_t cap, const uint8_t *req, size_t req_len, const struct sockaddr_in *mapped, const char *pwd) |
| Build a signed Binding success response with XOR-MAPPED-ADDRESS. | |
| int | cwist_ice_stun_build_request (uint8_t *out, size_t cap, const uint8_t txid[12], const char *username) |
| Build an unsigned Binding request (USERNAME, USE-CANDIDATE, ...). | |
| int | cwist_ice_stun_sign_request (uint8_t *msg, size_t cap, size_t msg_len, const char *pwd) |
| Append MESSAGE-INTEGRITY and FINGERPRINT to a request. | |
| int | cwist_ice_stun_parse_response (const uint8_t *buf, size_t len, const uint8_t txid[12], const char *pwd, struct sockaddr_in *mapped) |
| Validate a response: cookie, txid match, MI with pwd, return mapped address. | |
| void | cwist_ice_random_creds (char *ufrag, size_t ufrag_cap, char *pwd, size_t pwd_cap) |
| Generate random ICE credentials (ice-chars only). | |
SDP (sdp.c) | |
| int | cwist_sdp_parse (const char *sdp, size_t len, cwist_sdp_info *info) |
| Parse the fields the ICE-lite agent needs from an SDP description. | |
| int | cwist_sdp_write_answer (char *out, size_t cap, const char *fingerprint, const char *ufrag, const char *pwd, const char *mid, const char *host, uint16_t port) |
| Write an ICE-lite, DTLS-passive DataChannel answer. | |
| int | cwist_sdp_write_offer (char *out, size_t cap, const char *fingerprint, const char *ufrag, const char *pwd, const char *mid) |
| Write a DTLS-active DataChannel offer (loopback tests). | |
DTLS (dtls.c) | |
| int | cwist_dtls_generate_cert (X509 **cert, EVP_PKEY **pkey) |
| Generate an ephemeral self-signed P-256 certificate. | |
| int | cwist_dtls_fingerprint (X509 *cert, char *out, size_t cap) |
SHA-256 fingerprint of cert in SDP form ("AB:CD:..."). | |
| SSL_CTX * | cwist_dtls_ctx_new (int is_server, X509 *cert, EVP_PKEY *pkey) |
| DTLS 1.2 SSL_CTX for the server (with cert) or client role. | |
| BIO * | cwist_dtls_bio_new (struct cwist_webrtc_conn *conn) |
Datagram BIO for conn: reads return conn->dtls_in once, writes go to cwist_webrtc_conn_dtls_out() one datagram per call. | |
| unsigned int | cwist_dtls_link_mtu (void) |
| DTLS link MTU (bytes per datagram) used for handshake fragmentation. | |
SCTP (sctp.c) | |
| int | cwist_sctp_global_init (void) |
| One-time usrsctp initialisation (no threads, AF_CONN only). | |
| void | cwist_sctp_tick (void) |
| Advance usrsctp's process-wide timer clock to now. Any thread. | |
| int | cwist_sctp_conn_open (struct cwist_webrtc_conn *conn) |
| Create, bind and listen/connect the conn's SCTP socket. | |
| void | cwist_sctp_conn_close (struct cwist_webrtc_conn *conn) |
| Abort the association and release SCTP state. Idempotent. | |
| void | cwist_sctp_conn_input (struct cwist_webrtc_conn *conn, const uint8_t *data, size_t len) |
| Feed one decrypted SCTP packet to usrsctp. | |
| int | cwist_sctp_conn_drain (struct cwist_webrtc_conn *conn) |
| Accept (server role), then deliver every complete inbound message. | |
| bool | cwist_sctp_assoc_established (struct cwist_webrtc_conn *conn) |
| true once the SCTP association is up. | |
| int | cwist_sctp_send (struct cwist_webrtc_conn *conn, uint16_t channel, const uint8_t *data, size_t len, int is_string) |
| Send one message, announcing the channel with DCEP OPEN first if we are opening it. | |
Cross-file helpers (webrtc.c) | |
| bool | cwist_webrtc_on_owner (const cwist_webrtc_ctx *ctx) |
true when the calling thread is servicing ctx right now. | |
| void | cwist_webrtc_conn_dtls_out (struct cwist_webrtc_conn *conn, const uint8_t *data, size_t len) |
| Queue one datagram to the conn's peer (owner thread). | |
| void | cwist_webrtc_conn_sctp_out (struct cwist_webrtc_conn *conn, const void *buffer, size_t len) |
usrsctp output for conn; marshalled to the owner thread when needed. | |
| void | cwist_webrtc_conn_on_message (struct cwist_webrtc_conn *conn, uint16_t channel, const uint8_t *data, size_t len, int is_string) |
| Deliver a complete inbound message to the message handler. | |
| void | cwist_webrtc_conn_on_channel_open (struct cwist_webrtc_conn *conn, uint16_t channel, const char *label) |
| Report a channel the peer opened to the channel handler. | |
| cwist_webrtc_conn * | cwist_webrtc_connect (cwist_webrtc_ctx *ctx, const struct sockaddr_in *remote, const char *peer_ufrag, const char *peer_pwd) |
Offering-side dialer used by the loopback tests: registers a client conn to remote and starts ICE. | |
Internal types and cross-file helpers for the WebRTC DataChannel module (ICE-lite + DTLS + SCTP over UDP).
Threading model: every ctx is bound to one cwist reactor, and all mutable ctx/conn state is touched only on that reactor's run thread (the "owner"). Other threads reach a ctx or conn through cwist_reactor_post() nodes: cwist_webrtc_conn_send(), cwist_webrtc_conn_close(), cwist_webrtc_handle_offer() and cwist_webrtc_ctx_free() all post when called off the owner thread and act inline when called on it.
Lifetimes are reference counted. A conn holds a reference on its ctx; the ctx's connection table holds a reference on each registered conn; every in-flight post holds a reference on the object it targets. Teardown (closing sockets, freeing SSL/SCTP state) happens on the owner thread and is separate from freeing the memory, which happens on the last release.
Not part of the public API; only the module's .c files and its tests include this header.
Definition in file webrtc_internal.h.
| #define CWIST_STUN_BINDING_REQUEST 0x0001 |
STUN Binding request.
Definition at line 195 of file webrtc_internal.h.
| #define CWIST_STUN_BINDING_RESPONSE 0x0101 |
STUN Binding success response.
Definition at line 196 of file webrtc_internal.h.
| #define CWIST_WEBRTC_DGRAM_MAX 2048 |
Largest UDP datagram handled; bigger ones are dropped.
Definition at line 48 of file webrtc_internal.h.
| #define CWIST_WEBRTC_MAX_BUFFERED (4u << 20) |
Per-conn cap on bytes queued by cwist_webrtc_conn_send() and not yet taken by SCTP. Sends beyond it fail instead of growing the queue.
Definition at line 46 of file webrtc_internal.h.
| #define CWIST_WEBRTC_MAX_MESSAGE 262144 |
Largest DataChannel message accepted either way; advertised in the SDP as a=max-message-size.
Definition at line 43 of file webrtc_internal.h.
| #define CWIST_WEBRTC_RX_BATCH 32 |
Datagrams received per recvmmsg() call.
Definition at line 50 of file webrtc_internal.h.
| #define CWIST_WEBRTC_TX_BATCH 64 |
Datagrams queued before a sendmmsg() flush.
Definition at line 52 of file webrtc_internal.h.
A DataChannel message on its way into SCTP.
Foreign-thread sends travel through the conn's inbox in the same node they wait in on the pending queue, so a queued send costs one allocation.
Connection lifecycle.
Definition at line 55 of file webrtc_internal.h.
| BIO * cwist_dtls_bio_new | ( | struct cwist_webrtc_conn * | conn | ) |
Datagram BIO for conn: reads return conn->dtls_in once, writes go to cwist_webrtc_conn_dtls_out() one datagram per call.
Definition at line 211 of file dtls.c.
References cap.
DTLS 1.2 SSL_CTX for the server (with cert) or client role.
DTLS 1.2 SSL_CTX for the server (with cert) or client role.
| is_server | Non-zero to build a DTLS server context, zero for a DTLS client context. |
| cert | Server certificate; used (with pkey) only when is_server is non-zero. May be NULL for a client. |
| pkey | Private key matching cert; only used for a server. |
Definition at line 120 of file dtls.c.
References cap, SSL_CTX_check_private_key, SSL_CTX_free, SSL_CTX_new, SSL_CTX_set_min_proto_version, SSL_CTX_set_verify, and SSL_VERIFY_NONE.
SHA-256 fingerprint of cert in SDP form ("AB:CD:...").
SHA-256 fingerprint of cert in SDP form ("AB:CD:...").
| cert | Certificate to hash; must be non-NULL. |
| out | Output buffer receiving the fingerprint text. |
| cap | Capacity of out in bytes (including the NUL terminator). |
out. | 0 | Fingerprint written, e.g. "AB:12:...:EF" in uppercase hex. |
| -1 | Encoding, size, or digest error. |
Definition at line 90 of file dtls.c.
References cap, EVP_MAX_MD_SIZE, and EVP_sha256.
Generate an ephemeral self-signed P-256 certificate.
Generate an ephemeral self-signed P-256 certificate.
| cert_out | Receives a new X509 certificate; set to NULL on entry and on failure. |
| pkey_out | Receives the matching EVP_PKEY; set to NULL on entry and on failure. |
Definition at line 36 of file dtls.c.
References cap, and EVP_sha256.
DTLS link MTU (bytes per datagram) used for handshake fragmentation.
DTLS link MTU (bytes per datagram) used for handshake fragmentation.
Definition at line 142 of file dtls.c.
References CWIST_DTLS_MTU.
Generate random ICE credentials (ice-chars only).
Generate random ICE credentials (ice-chars only).
Both strings are drawn from 24 bytes of CSPRNG output encoded with the base64url alphabet (6 bits per character).
| ufrag | Output buffer for the ufrag. |
| ufrag_cap | Capacity of ufrag; up to 8 characters plus NUL are written. |
| pwd | Output buffer for the password. |
| pwd_cap | Capacity of pwd; up to 32 characters plus NUL are written. |
Definition at line 592 of file ice.c.
References cap, and RAND_bytes.
| int cwist_ice_stun_build_request | ( | uint8_t * | out, |
| size_t | cap, | ||
| const uint8_t | txid[12], | ||
| const char * | username | ||
| ) |
Build an unsigned Binding request (USERNAME, USE-CANDIDATE, ...).
cap.Build an unsigned Binding request (USERNAME, USE-CANDIDATE, ...).
The request carries USERNAME (only if username is non-empty), ICE-CONTROLLING, USE-CANDIDATE, and PRIORITY attributes. MESSAGE-INTEGRITY and FINGERPRINT are intentionally not added here; the MI key (the peer's password) is only known at send time, so the caller signs the built request with cwist_ice_stun_sign_request().
| out | Destination buffer. |
| cap | Capacity of out in bytes. |
| txid | 12-byte transaction ID to copy into the header. |
| username | "remoteufrag:localufrag" string for the USERNAME attribute; skipped when empty. |
cap is too small. Definition at line 361 of file ice.c.
References ATTR_ICE_CONTROLLING, ATTR_PRIORITY, ATTR_USE_CANDIDATE, ATTR_USERNAME, cap, CWIST_STUN_BINDING_REQUEST, STUN_HDR_LEN, and STUN_MAGIC.
| int cwist_ice_stun_build_response | ( | uint8_t * | out, |
| size_t | cap, | ||
| const uint8_t * | req, | ||
| size_t | req_len, | ||
| const struct sockaddr_in * | mapped, | ||
| const char * | pwd | ||
| ) |
Build a signed Binding success response with XOR-MAPPED-ADDRESS.
cap.Build a signed Binding success response with XOR-MAPPED-ADDRESS.
Emits a message containing XOR-MAPPED-ADDRESS (IPv4 only), MESSAGE-INTEGRITY (HMAC-SHA1 keyed with pwd), and FINGERPRINT attributes, reusing the request's transaction ID.
| out | Destination buffer. |
| cap | Capacity of out in bytes. |
| req | The received binding request (used for its transaction ID). |
| req_len | Bytes at req; currently unused. |
| mapped | Address/port to report back (XOR-encoded with the magic cookie). |
| pwd | Short-term credential password for the MI HMAC. |
cap is too small or OpenSSL allocation fails. Definition at line 281 of file ice.c.
References ATTR_FINGERPRINT, ATTR_MESSAGE_INTEGRITY, ATTR_XOR_MAPPED_ADDRESS, cap, CWIST_STUN_BINDING_RESPONSE, HMAC_CTX_free, HMAC_CTX_new, HMAC_Final, HMAC_Init_ex, HMAC_Update, STUN_HDR_LEN, and STUN_MAGIC.
Extract the sender's ufrag from USERNAME ("recipient:sender", RFC 8445 section 7.2.2) – the peer's SDP ice-ufrag.
Extract the sender's ufrag from USERNAME ("recipient:sender", RFC 8445 section 7.2.2) – the peer's SDP ice-ufrag.
A Binding request's USERNAME is "<recipient ufrag>:<sender ufrag>" (RFC 8445 section 7.2.2), so for a request we received this returns the part after the first ':' – the remote peer's ufrag, as it appears in the peer's SDP.
| buf | Datagram bytes. |
| len | Number of bytes at buf. |
| out | Output buffer for the NUL-terminated ufrag. |
| cap | Capacity of out; output is truncated to cap - 1 characters. |
| 0 | Ufrag extracted (possibly truncated). |
| -1 | Not a STUN message, or no USERNAME attribute present. |
Definition at line 556 of file ice.c.
References ATTR_USERNAME, cap, cwist_ice_stun_is_message(), and STUN_HDR_LEN.
true if the request carries USE-CANDIDATE (nomination).
true if the request carries USE-CANDIDATE (nomination).
| buf | Datagram bytes. |
| len | Number of bytes at buf. |
Definition at line 197 of file ice.c.
References ATTR_USE_CANDIDATE.
true if buf is a STUN Binding request.
true if buf is a STUN Binding request.
| buf | Datagram bytes. |
| len | Number of bytes at buf. |
buf is a STUN message with type CWIST_STUN_BINDING_REQUEST. Definition at line 119 of file ice.c.
References cwist_ice_stun_is_message(), and CWIST_STUN_BINDING_REQUEST.
Non-zero if buf looks like a STUN message (magic cookie, length).
Non-zero if buf looks like a STUN message (magic cookie, length).
| buf | Datagram bytes. |
| len | Number of bytes at buf. |
buf holds at least a STUN header and the magic cookie matches, 0 otherwise. Definition at line 110 of file ice.c.
References STUN_HDR_LEN, and STUN_MAGIC.
Referenced by cwist_ice_stun_get_remote_ufrag(), cwist_ice_stun_is_binding_request(), cwist_ice_stun_parse_response(), and cwist_ice_stun_validate_request().
| int cwist_ice_stun_parse_response | ( | const uint8_t * | buf, |
| size_t | len, | ||
| const uint8_t | txid[12], | ||
| const char * | pwd, | ||
| struct sockaddr_in * | mapped | ||
| ) |
Validate a response: cookie, txid match, MI with pwd, return mapped address.
| mapped | Filled with the XOR-MAPPED-ADDRESS on success. |
Validate a response: cookie, txid match, MI with pwd, return mapped address.
Checks, in order: well-formed STUN message of type BINDING-RESPONSE, transaction ID match against txid, MESSAGE-INTEGRITY HMAC with pwd (via cwist_ice_stun_validate_request()), and presence of a MESSAGE-INTEGRITY attribute. If mapped is non-NULL, an IPv4 XOR-MAPPED-ADDRESS must also be present and is decoded into it.
| buf | Datagram bytes. |
| len | Number of bytes at buf. |
| txid | Transaction ID the response must carry (the one we sent). |
| pwd | Local password used as the MI HMAC key. |
| mapped | Optional output for the decoded mapped address. |
| 1 | Valid response. |
| 0 | Any check failed or the message is malformed. |
Definition at line 518 of file ice.c.
References cap, cwist_ice_stun_is_message(), cwist_ice_stun_validate_request(), and CWIST_STUN_BINDING_RESPONSE.
Append MESSAGE-INTEGRITY and FINGERPRINT to a request.
cap.Append MESSAGE-INTEGRITY and FINGERPRINT to a request.
| msg | Buffer holding the request; extended in place. |
| cap | Total capacity of msg. |
| msg_len | Current request length. |
| pwd | Peer password used as the MI HMAC key. |
Definition at line 474 of file ice.c.
References cap.
Check MESSAGE-INTEGRITY (HMAC-SHA1 keyed with pwd).
Check MESSAGE-INTEGRITY (HMAC-SHA1 keyed with pwd).
| buf | Datagram bytes (any STUN message type; also used for responses). |
| len | Number of bytes at buf. |
| pwd | Short-term credential password used as the HMAC-SHA1 key. |
| 1 | Also when no MESSAGE-INTEGRITY attribute is present: accepted for MVP interoperability (RFC 8445 requires MI, but the agent stays permissive here). |
Definition at line 241 of file ice.c.
References cap, cwist_ice_stun_is_message(), EVP_MAX_MD_SIZE, HMAC_CTX_free, HMAC_CTX_new, HMAC_Final, HMAC_Init_ex, HMAC_Update, and STUN_HDR_LEN.
Referenced by cwist_ice_stun_parse_response().
| bool cwist_sctp_assoc_established | ( | struct cwist_webrtc_conn * | conn | ) |
true once the SCTP association is up.
Definition at line 399 of file sctp.c.
References cap, cwist_webrtc_conn::is_server_role, cwist_webrtc_conn::sctp_acc, and cwist_webrtc_conn::sctp_sock.
| void cwist_sctp_conn_close | ( | struct cwist_webrtc_conn * | conn | ) |
Abort the association and release SCTP state. Idempotent.
Definition at line 296 of file sctp.c.
References cap, cwist_webrtc_conn::ch_bits, cwist_webrtc_conn::ch_bits_len, cwist_free(), cwist_webrtc_conn::rx_partial, cwist_webrtc_conn::rx_partial_cap, cwist_webrtc_conn::rx_partial_len, cwist_webrtc_conn::sctp_acc, and cwist_webrtc_conn::sctp_sock.
Referenced by cwist_sctp_conn_open().
| int cwist_sctp_conn_drain | ( | struct cwist_webrtc_conn * | conn | ) |
Accept (server role), then deliver every complete inbound message.
Definition at line 343 of file sctp.c.
References cap, cwist_webrtc_conn::close_requested, cwist_webrtc_conn::ctx, CWIST_WEBRTC_MAX_MESSAGE, cwist_webrtc_conn::detached, cwist_webrtc_conn::is_server_role, cwist_webrtc_conn::rx_partial, cwist_webrtc_conn::rx_partial_len, cwist_webrtc_conn::sctp_acc, cwist_webrtc_ctx::sctp_buf, and cwist_webrtc_conn::sctp_sock.
Feed one decrypted SCTP packet to usrsctp.
Definition at line 317 of file sctp.c.
References cap, cwist_webrtc_conn::sctp_acc, and cwist_webrtc_conn::sctp_sock.
| int cwist_sctp_conn_open | ( | struct cwist_webrtc_conn * | conn | ) |
Create, bind and listen/connect the conn's SCTP socket.
Definition at line 265 of file sctp.c.
References cap, cwist_sctp_conn_close(), cwist_sctp_global_init(), CWIST_SCTP_PORT, cwist_webrtc_conn::is_server_role, and cwist_webrtc_conn::sctp_sock.
One-time usrsctp initialisation (no threads, AF_CONN only).
Definition at line 106 of file sctp.c.
References cap.
Referenced by cwist_sctp_conn_open().
| int cwist_sctp_send | ( | struct cwist_webrtc_conn * | conn, |
| uint16_t | channel, | ||
| const uint8_t * | data, | ||
| size_t | len, | ||
| int | is_string | ||
| ) |
Send one message, announcing the channel with DCEP OPEN first if we are opening it.
Definition at line 410 of file sctp.c.
References cap, CWIST_SCTP_STREAMS, DCEP_OPEN, PPID_BINARY, PPID_BINARY_EMPTY, PPID_STRING, PPID_STRING_EMPTY, and cwist_webrtc_conn::sctp_ready.
Referenced by cwist_webrtc_conn_send().
| int cwist_sdp_parse | ( | const char * | sdp, |
| size_t | len, | ||
| cwist_sdp_info * | info | ||
| ) |
Parse the fields the ICE-lite agent needs from an SDP description.
| info | Filled on return; missing fields stay zeroed. |
Parse the fields the ICE-lite agent needs from an SDP description.
| sdp | SDP text (not required to be NUL-terminated). |
| len | Length of sdp in bytes. |
| info | Output structure; zeroed first, then filled from recognized lines. |
Definition at line 43 of file sdp.c.
References cap.
Referenced by cwist_webrtc_handle_offer().
| int cwist_sdp_write_answer | ( | char * | out, |
| size_t | cap, | ||
| const char * | fingerprint, | ||
| const char * | ufrag, | ||
| const char * | pwd, | ||
| const char * | mid, | ||
| const char * | host, | ||
| uint16_t | port | ||
| ) |
Write an ICE-lite, DTLS-passive DataChannel answer.
cap.Write an ICE-lite, DTLS-passive DataChannel answer.
| out | Output buffer, receives CRLF-terminated SDP answer. |
| cap | Capacity of out in bytes. |
| fingerprint | DTLS certificate fingerprint (hex, colon-separated). |
| ufrag | ICE username fragment. |
| pwd | ICE password. |
| mid | Media section ID (also used in the BUNDLE group). |
| host | Local host address for the a=candidate line. |
| port | Local UDP port for the a=candidate line. |
Definition at line 129 of file sdp.c.
References cap.
Referenced by cwist_webrtc_handle_offer().
| int cwist_sdp_write_offer | ( | char * | out, |
| size_t | cap, | ||
| const char * | fingerprint, | ||
| const char * | ufrag, | ||
| const char * | pwd, | ||
| const char * | mid | ||
| ) |
Write a DTLS-active DataChannel offer (loopback tests).
cap.Write a DTLS-active DataChannel offer (loopback tests).
| out | Output buffer, receives CRLF-terminated SDP offer. |
| cap | Capacity of out in bytes. |
| fingerprint | DTLS certificate fingerprint (hex, colon-separated). |
| ufrag | ICE username fragment. |
| pwd | ICE password. |
| mid | Media section ID (also used in the BUNDLE group). |
Definition at line 168 of file sdp.c.
References cap.
| void cwist_webrtc_conn_dtls_out | ( | struct cwist_webrtc_conn * | conn, |
| const uint8_t * | data, | ||
| size_t | len | ||
| ) |
Queue one datagram to the conn's peer (owner thread).
Definition at line 554 of file webrtc.c.
References cwist_webrtc_conn::ctx, and cwist_webrtc_conn::remote.
| void cwist_webrtc_conn_on_channel_open | ( | struct cwist_webrtc_conn * | conn, |
| uint16_t | channel, | ||
| const char * | label | ||
| ) |
Report a channel the peer opened to the channel handler.
Definition at line 548 of file webrtc.c.
References cap, cwist_webrtc_ctx::ch_cb, cwist_webrtc_ctx::ch_user, and cwist_webrtc_conn::ctx.
| void cwist_webrtc_conn_on_message | ( | struct cwist_webrtc_conn * | conn, |
| uint16_t | channel, | ||
| const uint8_t * | data, | ||
| size_t | len, | ||
| int | is_string | ||
| ) |
Deliver a complete inbound message to the message handler.
Definition at line 540 of file webrtc.c.
References cwist_webrtc_conn::ctx, CWIST_WEBRTC_DATA_BINARY, CWIST_WEBRTC_DATA_STRING, cwist_webrtc_ctx::msg_cb, and cwist_webrtc_ctx::msg_user.
| void cwist_webrtc_conn_sctp_out | ( | struct cwist_webrtc_conn * | conn, |
| const void * | buffer, | ||
| size_t | len | ||
| ) |
usrsctp output for conn; marshalled to the owner thread when needed.
Definition at line 577 of file webrtc.c.
References cap, cwist_webrtc_conn::ctx, cwist_alloc(), cwist_webrtc_conn_retain(), cwist_webrtc_on_owner(), cwist_webrtc_ctx::reactor, cwist_webrtc_conn::ssl, and SSL_write.
| cwist_webrtc_conn * cwist_webrtc_connect | ( | cwist_webrtc_ctx * | ctx, |
| const struct sockaddr_in * | remote, | ||
| const char * | peer_ufrag, | ||
| const char * | peer_pwd | ||
| ) |
Offering-side dialer used by the loopback tests: registers a client conn to remote and starts ICE.
Definition at line 1078 of file webrtc.c.
References cap, cwist_reactor_post::cb, cwist_reactor_post::ctx, cwist_webrtc_conn::ctx, cwist_webrtc_conn_retain(), cwist_webrtc_conn::peer_pwd, cwist_webrtc_conn::peer_ufrag, RAND_bytes, cwist_webrtc_ctx::reactor, cwist_webrtc_conn::reg_post, cwist_webrtc_conn::remote, and cwist_webrtc_conn::stun_txid.
| bool cwist_webrtc_on_owner | ( | const cwist_webrtc_ctx * | ctx | ) |
true when the calling thread is servicing ctx right now.
Definition at line 100 of file webrtc.c.
Referenced by cwist_webrtc_conn_close(), cwist_webrtc_conn_sctp_out(), and cwist_webrtc_conn_send().