Compy 0.2.0
A lightweight RTSP 1.0 server library for embedded systems
Loading...
Searching...
No Matches
transport.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <compy/droppable.h>
9#include <compy/io_vec.h>
10#include <compy/writer.h>
11
12#include <interface99.h>
13
14#include <compy/priv/compiler_attrs.h>
15
22#define Compy_Transport_IFACE \
23 \
24 /* \
25 * Transmits a slice of I/O vectors @p bufs. \
26 * \
27 * @return -1 if an I/O error occurred and sets `errno` appropriately, 0 \
28 * on success. \
29 */ \
30 vfunc99(int, transmit, VSelf99, Compy_IoVecSlice bufs) \
31 vfunc99(bool, is_full, VSelf99)
32
36#define Compy_Transport_EXTENDS (Compy_Droppable)
37
44interface99(Compy_Transport);
45
55Compy_Transport compy_transport_tcp(
56 Compy_Writer w, uint8_t channel_id, size_t max_buffer) COMPY_PRIV_MUST_USE;
57
69Compy_Transport compy_transport_udp(int fd) COMPY_PRIV_MUST_USE;
70
88int compy_dgram_socket(int af, const void *restrict addr, uint16_t port)
89 COMPY_PRIV_MUST_USE;
90
102int compy_recv_dgram_socket(int af, uint16_t port) COMPY_PRIV_MUST_USE;
103
112void *
113compy_sockaddr_ip(const struct sockaddr *restrict addr) COMPY_PRIV_MUST_USE;
114
115#ifdef COMPY_HAS_TLS
116
120typedef enum {
121 Compy_SrtpSuite_AES_CM_128_HMAC_SHA1_80,
122 Compy_SrtpSuite_AES_CM_128_HMAC_SHA1_32,
123} Compy_SrtpSuite;
124
128typedef struct {
129 uint8_t master_key[16];
130 uint8_t master_salt[14];
131} Compy_SrtpKeyMaterial;
132
146Compy_Transport compy_transport_srtp(
147 Compy_Transport inner, Compy_SrtpSuite suite,
148 const Compy_SrtpKeyMaterial *key) COMPY_PRIV_MUST_USE;
149
164Compy_Transport compy_transport_srtcp(
165 Compy_Transport inner, Compy_SrtpSuite suite,
166 const Compy_SrtpKeyMaterial *key) COMPY_PRIV_MUST_USE;
167
172
183Compy_SrtpRecvCtx *compy_srtp_recv_new(
184 Compy_SrtpSuite suite,
185 const Compy_SrtpKeyMaterial *key) COMPY_PRIV_MUST_USE;
186
190void compy_srtp_recv_free(Compy_SrtpRecvCtx *ctx);
191
205int compy_srtp_recv_unprotect(
206 Compy_SrtpRecvCtx *ctx, uint8_t *data, size_t *len) COMPY_PRIV_MUST_USE;
207
221int compy_srtcp_recv_unprotect(
222 Compy_SrtpRecvCtx *ctx, uint8_t *data, size_t *len) COMPY_PRIV_MUST_USE;
223
229int compy_srtp_generate_key(Compy_SrtpKeyMaterial *key) COMPY_PRIV_MUST_USE;
230
244int compy_srtp_format_crypto_attr(
245 char *buf, size_t buf_len, int tag, Compy_SrtpSuite suite,
246 const Compy_SrtpKeyMaterial *key) COMPY_PRIV_MUST_USE;
247
257int compy_srtp_parse_crypto_attr(
258 const char *attr_value, Compy_SrtpSuite *suite,
259 Compy_SrtpKeyMaterial *key) COMPY_PRIV_MUST_USE;
260
261#endif /* COMPY_HAS_TLS */
Droppable types support.
Vectored I/O support.
Definition srtp.c:468
int compy_dgram_socket(int af, const void *restrict addr, uint16_t port) COMPY_PRIV_MUST_USE
Creates a new datagram socket suitable for compy_transport_udp.
Definition udp.c:94
Compy_Transport compy_transport_udp(int fd) COMPY_PRIV_MUST_USE
Creates a new UDP transport.
Definition udp.c:25
void * compy_sockaddr_ip(const struct sockaddr *restrict addr) COMPY_PRIV_MUST_USE
Returns a pointer to the IP address of addr.
Definition udp.c:196
Compy_Transport compy_transport_tcp(Compy_Writer w, uint8_t channel_id, size_t max_buffer) COMPY_PRIV_MUST_USE
Creates a new TCP transport.
Definition tcp.c:23
int compy_recv_dgram_socket(int af, uint16_t port) COMPY_PRIV_MUST_USE
Creates a new datagram socket bound to a local port for receiving.
Definition udp.c:152
interface99(Compy_Transport)
Defines the Compy_Transport interface.
The writer interface.