Skip to content
Snippets Groups Projects
Commit d815147b authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2522] Add simple crypto attribute parser in SDP

parent c0ae25bb
Branches
Tags
No related merge requests found
......@@ -125,6 +125,7 @@ void AudioRtpFactory::start (void)
switch (_rtpSessionType) {
case Sdes:
break;
case Symmetric:
_debug ("Starting symmetric rtp thread");
......
......@@ -33,6 +33,7 @@ static const pj_str_t STR_SDP_NAME = { (char*) "sflphone", 8 };
static const pj_str_t STR_SENDRECV = { (char*) "sendrecv", 8 };
static const pj_str_t STR_RTPMAP = { (char*) "rtpmap", 6 };
Sdp::Sdp (pj_pool_t *pool)
: _local_media_cap()
, _session_media (0)
......@@ -130,7 +131,7 @@ void Sdp::set_media_descriptor_line (sdpMedia *media, pjmedia_sdp_media** p_med)
_debug ("No hash specified");
}
// sdp_add_srtp_attribute (med);
sdp_add_sdes_attribute (med);
*p_med = med;
}
......@@ -363,11 +364,12 @@ void Sdp::sdp_add_media_description()
}
void Sdp::sdp_add_srtp_attribute (pjmedia_sdp_media* media)
void Sdp::sdp_add_sdes_attribute (pjmedia_sdp_media* media)
{
char tempbuf[256];
std::string tag = "1";
std::string crypto_suite = "AES_CM_128_HMAC_SHA1_32";
std::string application = "srtp";
std::string key = "inline:16/14/NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj/2^20/1:32";
......@@ -378,8 +380,8 @@ void Sdp::sdp_add_srtp_attribute (pjmedia_sdp_media* media)
int len = pj_ansi_snprintf(tempbuf, sizeof(tempbuf),
"%.*s %.*s %.*s",
(int)tag.size(), tag.c_str(),
(int)crypto_suite.size(), crypto_suite.c_str(),
(int)application.size(), application.c_str(),
(int)key.size(), key.c_str());
attribute->value.slen = len;
......@@ -638,8 +640,12 @@ void Sdp::set_media_transport_info_from_remote_sdp (const pjmedia_sdp_session *r
pjmedia_sdp_media *r_media;
pjmedia_sdp_attr *attribute;
this->get_remote_sdp_media_from_offer (remote_sdp, &r_media);
// this->get_remote_sdp_crypto_from_offer()
if (r_media==NULL) {
_debug ("SDP Failure: no remote sdp media found in the remote offer");
return;
......@@ -665,3 +671,18 @@ void Sdp::get_remote_sdp_media_from_offer (const pjmedia_sdp_session* remote_sdp
}
}
void Sdp::get_remote_sdp_crypto_from_offer (const pjmedia_sdp_session* remote_sdp, pjmedia_sdp_media** r_crypto)
{
int count, i;
count = remote_sdp->media_count;
*r_crypto = NULL;
for (i = 0; i < count; ++i) {
if (pj_stricmp2 (&remote_sdp->media[i]->desc.media, "crypto") == 0) {
*r_crypto = remote_sdp->media[i];
return;
}
}
}
......@@ -336,13 +336,15 @@ class Sdp {
void get_remote_sdp_media_from_offer (const pjmedia_sdp_session* r_sdp, pjmedia_sdp_media** r_media);
void get_remote_sdp_crypto_from_offer (const pjmedia_sdp_session* remote_sdp, pjmedia_sdp_media** r_crypto);
/*
* Adds a srtp attribute to the given media section.
* Adds a sdes attribute to the given media section.
*
* @param media The media to add the srtp attribute to
*/
void sdp_add_srtp_attribute(pjmedia_sdp_media* media);
void sdp_add_sdes_attribute(pjmedia_sdp_media* media);
/*
* Adds a zrtp-hash attribute to
......
......@@ -3419,6 +3419,9 @@ mod_on_rx_request (pjsip_rx_data *rdata)
int end_displayName = temp.rfind ("\"");
// _debug("The display name start at %i, end at %i", begin_displayName, end_displayName);
displayName = temp.substr (begin_displayName, end_displayName - begin_displayName);//display_name);
if(displayName.size() > 25) {
displayName = std::string ("");
}
} else {
displayName = std::string ("");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment