diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-12-10 16:54:16 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-12-10 16:54:16 +0000 |
commit | eb5756d2c401568e24c448776cc1a914b57b80b0 (patch) | |
tree | 227210f2e0d329cf7c785b2f7934e05b05f36912 | |
parent | 51ea10ee4adb41c3e8ddcfdee5fb165faffa432e (diff) |
Ticket #672: Option to add custom parameters in the account Contact URI
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2373 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjsip-apps/src/pjsua/pjsua_app.c | 15 | ||||
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 12 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_acc.c | 18 |
3 files changed, 39 insertions, 6 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c index b3b5a98d..13f948fa 100644 --- a/pjsip-apps/src/pjsua/pjsua_app.c +++ b/pjsip-apps/src/pjsua/pjsua_app.c @@ -177,6 +177,7 @@ 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 (" --proxy=url Optional URL of proxy server to visit"); puts (" May be specified multiple times"); puts (" --reg-timeout=SEC Optional registration interval (default 55)"); @@ -462,6 +463,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_CONTACT_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, @@ -517,6 +519,7 @@ static pj_status_t parse_args(int argc, char *argv[], { "use-ims", 0, 0, OPT_USE_IMS}, { "id", 1, 0, OPT_ID}, { "contact", 1, 0, OPT_CONTACT}, + { "contact-params",1,0, OPT_CONTACT_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}, @@ -826,6 +829,10 @@ static pj_status_t parse_args(int argc, char *argv[], cur_acc->force_contact = pj_str(pj_optarg); break; + case OPT_CONTACT_PARAMS: + cur_acc->contact_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; @@ -1370,6 +1377,14 @@ static void write_account_settings(int acc_index, pj_str_t *result) pj_strcat2(result, line); } + /* Contact parameters */ + if (acc_cfg->contact_params.slen) { + pj_ansi_sprintf(line, "--contact-params %.*s\n", + (int)acc_cfg->contact_params.slen, + acc_cfg->contact_params.ptr); + pj_strcat2(result, line); + } + /* */ if (acc_cfg->allow_contact_rewrite!=1) { diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 74cbffec..c8073e70 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -2131,6 +2131,18 @@ typedef struct pjsua_acc_config pj_str_t force_contact; /** + * Additional URI 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. + * + * 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_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 7faec4e4..12d7af4f 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -681,14 +681,16 @@ 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:%d;transport=%s>", + "<sip:%.*s%s%.*s:%d;transport=%s%.*s>", (int)acc->user_part.slen, acc->user_part.ptr, (acc->user_part.slen? "@" : ""), (int)via_addr->slen, via_addr->ptr, rport, - tp->type_name); + tp->type_name, + (int)acc->cfg.contact_params.slen, + acc->cfg.contact_params.ptr); if (len < 1) { PJ_LOG(1,(THIS_FILE, "URI too long")); pj_pool_release(pool); @@ -1663,7 +1665,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:%d%s%.*s>", (int)acc->display.slen, acc->display.ptr, (acc->display.slen?" " : ""), @@ -1676,7 +1678,9 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, local_addr.ptr, endquote, local_port, - transport_param); + transport_param, + (int)acc->cfg.contact_params.slen, + acc->cfg.contact_params.ptr); return PJ_SUCCESS; } @@ -1813,7 +1817,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:%d%s%.*s>", (int)acc->display.slen, acc->display.ptr, (acc->display.slen?" " : ""), @@ -1826,7 +1830,9 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, local_addr.ptr, endquote, local_port, - transport_param); + transport_param, + (int)acc->cfg.contact_params.slen, + acc->cfg.contact_params.ptr); return PJ_SUCCESS; } |