summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c20
-rw-r--r--pjsip-apps/src/python/_pjsua.h22
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h14
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c12
4 files changed, 61 insertions, 7 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 4f534f90..41630132 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -180,7 +180,8 @@ static void usage(void)
puts (" --registrar=url Set the URL of registrar server");
puts (" --id=url Set the URL of local ID (used in From header)");
puts (" --contact=url Optionally override the Contact information");
- puts (" --contact-params=S Append the specified parameters S in Contact URI");
+ puts (" --contact-params=S Append the specified parameters S in Contact header");
+ puts (" --contact-uri-params=S Append the specified parameters S in Contact URI");
puts (" --proxy=url Optional URL of proxy server to visit");
puts (" May be specified multiple times");
puts (" --reg-timeout=SEC Optional registration interval (default 55)");
@@ -471,7 +472,7 @@ static pj_status_t parse_args(int argc, char *argv[],
OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, OPT_SND_AUTO_CLOSE,
OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY,
OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT,
- OPT_BOUND_ADDR, OPT_CONTACT_PARAMS,
+ OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS,
OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
OPT_NAMESERVER, OPT_STUN_DOMAIN, OPT_STUN_SRV,
OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE,
@@ -529,6 +530,7 @@ static pj_status_t parse_args(int argc, char *argv[],
{ "id", 1, 0, OPT_ID},
{ "contact", 1, 0, OPT_CONTACT},
{ "contact-params",1,0, OPT_CONTACT_PARAMS},
+ { "contact-uri-params",1,0, OPT_CONTACT_URI_PARAMS},
{ "auto-update-nat", 1, 0, OPT_AUTO_UPDATE_NAT},
{ "use-compact-form", 0, 0, OPT_USE_COMPACT_FORM},
{ "accept-redirect", 1, 0, OPT_ACCEPT_REDIRECT},
@@ -851,6 +853,10 @@ static pj_status_t parse_args(int argc, char *argv[],
cur_acc->contact_params = pj_str(pj_optarg);
break;
+ case OPT_CONTACT_URI_PARAMS:
+ cur_acc->contact_uri_params = pj_str(pj_optarg);
+ break;
+
case OPT_AUTO_UPDATE_NAT: /* OPT_AUTO_UPDATE_NAT */
cur_acc->allow_contact_rewrite = pj_strtoul(pj_cstr(&tmp, pj_optarg));
break;
@@ -1405,7 +1411,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
pj_strcat2(result, line);
}
- /* Contact parameters */
+ /* Contact header parameters */
if (acc_cfg->contact_params.slen) {
pj_ansi_sprintf(line, "--contact-params %.*s\n",
(int)acc_cfg->contact_params.slen,
@@ -1413,6 +1419,14 @@ static void write_account_settings(int acc_index, pj_str_t *result)
pj_strcat2(result, line);
}
+ /* Contact URI parameters */
+ if (acc_cfg->contact_uri_params.slen) {
+ pj_ansi_sprintf(line, "--contact-uri-params %.*s\n",
+ (int)acc_cfg->contact_uri_params.slen,
+ acc_cfg->contact_uri_params.ptr);
+ pj_strcat2(result, line);
+ }
+
/* */
if (acc_cfg->allow_contact_rewrite!=1)
{
diff --git a/pjsip-apps/src/python/_pjsua.h b/pjsip-apps/src/python/_pjsua.h
index e277c7d0..d3958d76 100644
--- a/pjsip-apps/src/python/_pjsua.h
+++ b/pjsip-apps/src/python/_pjsua.h
@@ -1653,6 +1653,8 @@ typedef struct
int auth_initial_send;
PyObject *auth_initial_algorithm;
PyObject *pidf_tuple_id;
+ PyObject *contact_params;
+ PyObject *contact_uri_params;
int require_100rel;
int allow_contact_rewrite;
int ka_interval;
@@ -1675,6 +1677,8 @@ static void PyObj_pjsua_acc_config_delete(PyObj_pjsua_acc_config* self)
Py_XDECREF(self->cred_info);
Py_XDECREF(self->auth_initial_algorithm);
Py_XDECREF(self->pidf_tuple_id);
+ Py_XDECREF(self->contact_params);
+ Py_XDECREF(self->contact_uri_params);
Py_XDECREF(self->ka_data);
self->ob_type->tp_free((PyObject*)self);
}
@@ -1721,6 +1725,10 @@ static void PyObj_pjsua_acc_config_import(PyObj_pjsua_acc_config *obj,
obj->auth_initial_algorithm = PyString_FromPJ(&cfg->auth_pref.algorithm);
Py_XDECREF(obj->pidf_tuple_id);
obj->pidf_tuple_id = PyString_FromPJ(&cfg->pidf_tuple_id);
+ Py_XDECREF(obj->contact_params);
+ obj->contact_params = PyString_FromPJ(&cfg->contact_params);
+ Py_XDECREF(obj->contact_uri_params);
+ obj->contact_uri_params = PyString_FromPJ(&cfg->contact_uri_params);
obj->require_100rel = cfg->require_100rel;
obj->allow_contact_rewrite = cfg->allow_contact_rewrite;
obj->ka_interval = cfg->ka_interval;
@@ -1765,6 +1773,8 @@ static void PyObj_pjsua_acc_config_export(pjsua_acc_config *cfg,
cfg->auth_pref.initial_auth = obj->auth_initial_send;
cfg->auth_pref.algorithm = PyString_ToPJ(obj->auth_initial_algorithm);
cfg->pidf_tuple_id = PyString_ToPJ(obj->pidf_tuple_id);
+ cfg->contact_params = PyString_ToPJ(obj->contact_params);
+ cfg->contact_uri_params = PyString_ToPJ(obj->contact_uri_params);
cfg->require_100rel = obj->require_100rel;
cfg->allow_contact_rewrite = obj->allow_contact_rewrite;
cfg->ka_interval = obj->ka_interval;
@@ -1796,6 +1806,8 @@ static PyObject * PyObj_pjsua_acc_config_new(PyTypeObject *type,
self->cred_info = (PyListObject *)PyList_New(0);
self->auth_initial_algorithm = PyString_FromString("");
self->pidf_tuple_id = PyString_FromString("");
+ self->contact_params = PyString_FromString("");
+ self->contact_uri_params = PyString_FromString("");
self->ka_data = PyString_FromString("");
}
@@ -1894,6 +1906,16 @@ static PyMemberDef PyObj_pjsua_acc_config_members[] =
"PIDF tuple id."
},
{
+ "contact_params", T_OBJECT_EX,
+ offsetof(PyObj_pjsua_acc_config, contact_params), 0,
+ "Additional parameters for Contact header."
+ },
+ {
+ "contact_uri_params", T_OBJECT_EX,
+ offsetof(PyObj_pjsua_acc_config, contact_uri_params), 0,
+ "Additional parameters for Contact URI."
+ },
+ {
"require_100rel", T_INT,
offsetof(PyObj_pjsua_acc_config, require_100rel), 0,
"Require reliable provisional response."
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 1ea6f9e4..023acb6b 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1666,7 +1666,7 @@ typedef struct pjsua_acc_config
pj_str_t force_contact;
/**
- * Additional URI parameters that will be appended in the Contact header
+ * Additional parameters that will be appended in the Contact header
* for this account. This will affect the Contact header in all SIP
* messages sent on behalf of this account, including but not limited to
* REGISTER, INVITE, and SUBCRIBE requests or responses.
@@ -1678,6 +1678,18 @@ typedef struct pjsua_acc_config
pj_str_t contact_params;
/**
+ * Additional URI parameters that will be appended in the Contact URI
+ * for this account. This will affect the Contact URI in all SIP
+ * messages sent on behalf of this account, including but not limited to
+ * REGISTER, INVITE, and SUBCRIBE requests or responses.
+ *
+ * The parameters should be preceeded by semicolon, and all strings must
+ * be properly escaped. Example:
+ * ";my-param=X;another-param=Hi%20there"
+ */
+ pj_str_t contact_uri_params;
+
+ /**
* Specify whether support for reliable provisional response (100rel and
* PRACK) should be required for all sessions of this account.
*
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index 5bfa5f04..05cedf49 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -712,7 +712,7 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc,
tmp = (char*) pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
len = pj_ansi_snprintf(tmp, PJSIP_MAX_URL_SIZE,
- "<sip:%.*s%s%s%.*s%s:%d;transport=%s%.*s>",
+ "<sip:%.*s%s%s%.*s%s:%d;transport=%s%.*s>%.*s",
(int)acc->user_part.slen,
acc->user_part.ptr,
(acc->user_part.slen? "@" : ""),
@@ -722,6 +722,8 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc,
endquote,
rport,
tp->type_name,
+ (int)acc->cfg.contact_uri_params.slen,
+ acc->cfg.contact_uri_params.ptr,
(int)acc->cfg.contact_params.slen,
acc->cfg.contact_params.ptr);
if (len < 1) {
@@ -1698,7 +1700,7 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
/* Create the contact header */
contact->ptr = (char*)pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
contact->slen = pj_ansi_snprintf(contact->ptr, PJSIP_MAX_URL_SIZE,
- "%.*s%s<%s:%.*s%s%s%.*s%s:%d%s%.*s>",
+ "%.*s%s<%s:%.*s%s%s%.*s%s:%d%s%.*s>%.*s",
(int)acc->display.slen,
acc->display.ptr,
(acc->display.slen?" " : ""),
@@ -1712,6 +1714,8 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
endquote,
local_port,
transport_param,
+ (int)acc->cfg.contact_uri_params.slen,
+ acc->cfg.contact_uri_params.ptr,
(int)acc->cfg.contact_params.slen,
acc->cfg.contact_params.ptr);
@@ -1850,7 +1854,7 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
/* Create the contact header */
contact->ptr = (char*) pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
contact->slen = pj_ansi_snprintf(contact->ptr, PJSIP_MAX_URL_SIZE,
- "%.*s%s<%s:%.*s%s%s%.*s%s:%d%s%.*s>",
+ "%.*s%s<%s:%.*s%s%s%.*s%s:%d%s%.*s>%.*s",
(int)acc->display.slen,
acc->display.ptr,
(acc->display.slen?" " : ""),
@@ -1864,6 +1868,8 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
endquote,
local_port,
transport_param,
+ (int)acc->cfg.contact_uri_params.slen,
+ acc->cfg.contact_uri_params.ptr,
(int)acc->cfg.contact_params.slen,
acc->cfg.contact_params.ptr);