Commit 29945cbc authored by François Grisez's avatar François Grisez

Prevent belle-sip version from being automatically added to User-agent header

(cherry picked from commit 5230527b)
parent 8d7cac3b
......@@ -18,6 +18,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <sstream>
#include "linphone/api/c-content.h"
#include "linphone/core_utils.h"
#include "linphone/core.h"
......@@ -3074,11 +3076,11 @@ static char _ua_name[64]="Linphone";
static char _ua_version[64]=LIBLINPHONE_VERSION;
void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char *ver){
char ua_string[256];
snprintf(ua_string, sizeof(ua_string) - 1, "%s/%s", name?name:"", ver?ver:"");
ostringstream ua_string;
ua_string << (name ? name : "");
if (ver) ua_string << "/" << ver;
if (lc->sal) {
lc->sal->setUserAgent(ua_string);
lc->sal->appendStackStringToUserAgent();
lc->sal->setUserAgent(ua_string.str());
}
}
const char *linphone_core_get_user_agent(LinphoneCore *lc){
......
......@@ -1123,10 +1123,15 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneC
LINPHONE_PUBLIC void linphone_core_remove_callbacks(LinphoneCore *lc, const LinphoneCoreCbs *cbs);
/**
* Sets the user agent string used in SIP messages, ideally called just after linphone_core_new() or linphone_core_init().
* @param[in] lc #LinphoneCore object
* @param[in] ua_name The user agent name
* @param[in] version The user agent version
* @brief Set the user agent string used in SIP messages.
*
* Set the user agent string used in SIP messages as "[ua_name]/[version]". No slash character will be printed if NULL is given to "version".
* If NULL is given to "ua_name" and "version" both, the User-agent header will be empty.
*
* This function should be called just after linphone_factory_create_core() ideally.
* @param[in] lc The core.
* @param[in] ua_name Name of the user agent.
* @param[in] version Version of the user agent.
* @ingroup misc
**/
LINPHONE_PUBLIC void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const char *version);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment