diff --git a/coreapi/sal_eXosip2_sdp.c b/coreapi/sal_eXosip2_sdp.c index a85b5ef5a..8c9279aa1 100644 --- a/coreapi/sal_eXosip2_sdp.c +++ b/coreapi/sal_eXosip2_sdp.c @@ -227,9 +227,21 @@ static void add_payload(sdp_message_t *msg, int line, const PayloadType *pt, boo static void add_candidate_attribute(sdp_message_t *msg, int lineno, const IceCandidate *candidate) { char buffer[1024]; + int nb; - snprintf(buffer, sizeof(buffer), "%s %d UDP %d %s %d typ %s", + nb = snprintf(buffer, sizeof(buffer), "%s %d UDP %d %s %d typ %s", candidate->foundation, candidate->componentID, candidate->priority, candidate->taddr.ip, candidate->taddr.port, ice_candidate_type(candidate)); + if (nb < 0) { + ms_error("Cannot add ICE candidate attribute!"); + return; + } + if (candidate->type != ICT_HostCandidate) { + nb = snprintf(buffer + nb, sizeof(buffer) - nb, " raddr %s rport %d", candidate->base->taddr.ip, candidate->base->taddr.port); + if (nb < 0) { + ms_error("Cannot add ICE candidate attribute!"); + return; + } + } sdp_message_a_attribute_add(msg, lineno, osip_strdup("candidate"), osip_strdup(buffer)); }