Browse Source

TT#91151 negotiate DTLS role and SDES for publish

Change-Id: I246415c416a5d4f8126511d6a867109048810bf6
pull/1346/head
Richard Fuchs 4 years ago
parent
commit
fbcddaca49
1 changed files with 10 additions and 7 deletions
  1. +10
    -7
      daemon/call.c

+ 10
- 7
daemon/call.c View File

@ -1488,12 +1488,13 @@ static void __sdes_flags(struct crypto_params_sdes *cps, const struct sdp_ng_fla
} }
/* generates SDES parameters for outgoing SDP, which is our media "out" direction */ /* generates SDES parameters for outgoing SDP, which is our media "out" direction */
// `other` can be NULL
static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_media *this, static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_media *this,
struct call_media *other) struct call_media *other)
{ {
GQueue *cpq = &this->sdes_out; GQueue *cpq = &this->sdes_out;
GQueue *cpq_in = &this->sdes_in; GQueue *cpq_in = &this->sdes_in;
const GQueue *offered_cpq = &other->sdes_in;
const GQueue *offered_cpq = other ? &other->sdes_in : NULL;
if (!flags) if (!flags)
return; return;
@ -1508,7 +1509,7 @@ static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_medi
MEDIA_CLEAR(this, SETUP_PASSIVE); MEDIA_CLEAR(this, SETUP_PASSIVE);
MEDIA_CLEAR(this, SETUP_ACTIVE); MEDIA_CLEAR(this, SETUP_ACTIVE);
if (MEDIA_ISSET(this, PASSTHRU)) {
if (MEDIA_ISSET(this, PASSTHRU) && other) {
/* clear crypto for the other leg as well b/c passthrough only /* clear crypto for the other leg as well b/c passthrough only
* works if it is done for both legs */ * works if it is done for both legs */
MEDIA_CLEAR(other, DTLS); MEDIA_CLEAR(other, DTLS);
@ -1526,7 +1527,7 @@ static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_medi
MEDIA_SET(this, SETUP_ACTIVE); MEDIA_SET(this, SETUP_ACTIVE);
} }
else { else {
if (flags->dtls_passive && MEDIA_ISSET(this, SETUP_PASSIVE))
if (flags && flags->dtls_passive && MEDIA_ISSET(this, SETUP_PASSIVE))
MEDIA_CLEAR(this, SETUP_ACTIVE); MEDIA_CLEAR(this, SETUP_ACTIVE);
/* if we can be active, we will, otherwise we'll be passive */ /* if we can be active, we will, otherwise we'll be passive */
if (MEDIA_ISSET(this, SETUP_ACTIVE)) if (MEDIA_ISSET(this, SETUP_ACTIVE))
@ -1647,7 +1648,8 @@ static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_medi
// we pick the first supported crypto suite // we pick the first supported crypto suite
struct crypto_params_sdes *cps = cpq->head ? cpq->head->data : NULL; struct crypto_params_sdes *cps = cpq->head ? cpq->head->data : NULL;
struct crypto_params_sdes *cps_in = cpq_in->head ? cpq_in->head->data : NULL; struct crypto_params_sdes *cps_in = cpq_in->head ? cpq_in->head->data : NULL;
struct crypto_params_sdes *offered_cps = offered_cpq->head ? offered_cpq->head->data : NULL;
struct crypto_params_sdes *offered_cps = (offered_cpq && offered_cpq->head)
? offered_cpq->head->data : NULL;
if (flags && flags->sdes_static && cps) { if (flags && flags->sdes_static && cps) {
// reverse logic: instead of looking for a matching crypto suite to put in // reverse logic: instead of looking for a matching crypto suite to put in
@ -1969,12 +1971,13 @@ static void __dtls_logic(const struct sdp_ng_flags *flags,
/* Special case: if this is an offer and actpass is being offered (as it should), /* Special case: if this is an offer and actpass is being offered (as it should),
* we would normally choose to be active. However, if this is a reinvite and we * we would normally choose to be active. However, if this is a reinvite and we
* were passive previously, we should retain this role. */ * were passive previously, we should retain this role. */
if (flags && flags->opmode == OP_OFFER && MEDIA_ARESET2(other_media, SETUP_ACTIVE, SETUP_PASSIVE)
if ((flags->opmode == OP_OFFER || flags->opmode == OP_PUBLISH)
&& MEDIA_ARESET2(other_media, SETUP_ACTIVE, SETUP_PASSIVE)
&& (tmp & (MEDIA_FLAG_SETUP_ACTIVE | MEDIA_FLAG_SETUP_PASSIVE)) && (tmp & (MEDIA_FLAG_SETUP_ACTIVE | MEDIA_FLAG_SETUP_PASSIVE))
== MEDIA_FLAG_SETUP_PASSIVE) == MEDIA_FLAG_SETUP_PASSIVE)
MEDIA_CLEAR(other_media, SETUP_ACTIVE); MEDIA_CLEAR(other_media, SETUP_ACTIVE);
/* if passive mode is requested, honour it if we can */ /* if passive mode is requested, honour it if we can */
if (flags && flags->dtls_reverse_passive && MEDIA_ISSET(other_media, SETUP_PASSIVE))
if (flags->dtls_reverse_passive && MEDIA_ISSET(other_media, SETUP_PASSIVE))
MEDIA_CLEAR(other_media, SETUP_ACTIVE); MEDIA_CLEAR(other_media, SETUP_ACTIVE);
} }
@ -2763,8 +2766,8 @@ int monologue_publish(struct call_monologue *ml, GQueue *streams, struct sdp_ng_
bf_copy(&media->media_flags, MEDIA_FLAG_RECV, &sp->sp_flags, SP_FLAG_SEND); bf_copy(&media->media_flags, MEDIA_FLAG_RECV, &sp->sp_flags, SP_FLAG_SEND);
if (sp->rtp_endpoint.port) { if (sp->rtp_endpoint.port) {
/* DTLS stuff */
__dtls_logic(flags, media, sp); __dtls_logic(flags, media, sp);
__generate_crypto(flags, media, NULL);
} }
/* local interface selection */ /* local interface selection */


Loading…
Cancel
Save