22static void copy_attr_value(
const char *
line,
const char *prefix,
char *
dst,
size_t cap) {
49 if (
n >=
sizeof(
line))
54 while (pos < len && (
sdp[pos] ==
'\r' ||
sdp[pos] ==
'\n'))
58 copy_attr_value(
line,
"a=ice-ufrag:",
info->ice_ufrag,
sizeof(
info->ice_ufrag));
60 copy_attr_value(
line,
"a=ice-pwd:",
info->ice_pwd,
sizeof(
info->ice_pwd));
62 copy_attr_value(
line,
"a=fingerprint:sha-256 ",
info->fingerprint,
63 sizeof(
info->fingerprint));
65 copy_attr_value(
line,
"a=setup:",
info->setup,
sizeof(
info->setup));
67 copy_attr_value(
line,
"a=mid:",
info->mid,
sizeof(
info->mid));
71 if (
info->ice_ufrag[0] ==
'\0' ||
info->ice_pwd[0] ==
'\0')
89static int write_session(
char *out,
size_t cap,
const char *fingerprint,
const char *
ufrag,
90 const char *
pwd,
const char *mid,
const char *setup,
int with_lite,
94 "o=- %lld 2 IN IP4 127.0.0.1\r\n"
97 "a=group:BUNDLE %s\r\n"
98 "m=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n"
99 "c=IN IP4 0.0.0.0\r\n"
104 "a=fingerprint:sha-256 %s\r\n"
106 "a=sctp-port:5000\r\n"
107 "a=max-message-size:262144\r\n",
110 if (
n < 0 || (
size_t)
n >=
cap)
130 const char *
pwd,
const char *mid,
const char *host,
uint16_t port) {
134 "o=- 872978578 2 IN IP4 127.0.0.1\r\n"
137 "a=group:BUNDLE %s\r\n"
138 "m=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n"
139 "c=IN IP4 0.0.0.0\r\n"
144 "a=fingerprint:sha-256 %s\r\n"
145 "a=setup:passive\r\n"
146 "a=candidate:1 1 UDP 2122260223 %s %u typ host\r\n"
147 "a=end-of-candidates\r\n"
148 "a=sctp-port:5000\r\n"
149 "a=max-message-size:262144\r\n",
150 mid, mid,
ufrag,
pwd, fingerprint, host, (
unsigned)port);
151 if (
n < 0 || (
size_t)
n >=
cap)
169 const char *
pwd,
const char *mid) {
171 return write_session(out,
cap, fingerprint,
ufrag,
pwd, mid,
"active", 0, 337018573);
int cwist_sdp_write_offer(char *out, size_t cap, const char *fingerprint, const char *ufrag, const char *pwd, const char *mid)
Generate an SDP offer for a full (non-lite) DataChannel endpoint.
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)
Generate an SDP answer for an ICE-lite DataChannel endpoint.
int cwist_sdp_parse(const char *sdp, size_t len, cwist_sdp_info *info)
Parse an SDP blob into a cwist_sdp_info structure.
Fields the ICE-lite agent needs from an SDP description.
Internal types and cross-file helpers for the WebRTC DataChannel module (ICE-lite + DTLS + SCTP over ...