diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-10-01 00:24:23 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-10-01 00:24:23 +0000 |
commit | c9b181750958386e9b5f2b21e486b214e0c5906d (patch) | |
tree | 47ea20912d51b8e61a0ae1c0cffc10e525d7c870 /pjsip | |
parent | 2263a30d5a775d8ffd73484f73c6d13e93dab77e (diff) |
Closed #1141: Compile and run-time setting to allow printing of port number in URI in To and From header (thanks Marcus Froeschl for the suggestion)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3329 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsip/sip_config.h | 24 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_config.c | 5 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_uri.c | 14 |
3 files changed, 37 insertions, 6 deletions
diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h index 5788de6c..934d6969 100644 --- a/pjsip/include/pjsip/sip_config.h +++ b/pjsip/include/pjsip/sip_config.h @@ -68,6 +68,17 @@ PJ_BEGIN_DECL */ typedef struct pjsip_cfg_t { + /** Global settings. */ + struct { + /** + * Specify port number should be allowed to appear in To and From + * header. Note that RFC 3261 disallow this, see Table 1 in section + * 19.1.1 of the RFC. Default is PJSIP_ALLOW_PORT_IN_FROMTO_HDR. + */ + pj_bool_t allow_port_in_fromto_hdr; + + } endpt; + /** Transaction layer settings. */ struct { @@ -361,6 +372,19 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void) /** + * Specify port number should be allowed to appear in To and From + * header. Note that RFC 3261 disallow this, see Table 1 in section + * 19.1.1 of the RFC. This setting can also be altered at run-time + * via pjsip_cfg setting, see pjsip_cfg_t.allow_port_in_fromto_hdr + * field. + * + * Default: 0 + */ +#ifndef PJSIP_ALLOW_PORT_IN_FROMTO_HDR +# define PJSIP_ALLOW_PORT_IN_FROMTO_HDR 0 +#endif + +/** * This macro controls maximum numbers of ioqueue events to be processed * in a single pjsip_endpt_handle_events() poll. When PJSIP detects that * there are probably more events available from the network and total diff --git a/pjsip/src/pjsip/sip_config.c b/pjsip/src/pjsip/sip_config.c index 85466d4e..87eba3f0 100644 --- a/pjsip/src/pjsip/sip_config.c +++ b/pjsip/src/pjsip/sip_config.c @@ -23,6 +23,11 @@ /* pjsip configuration instance, initialized with default values */ pjsip_cfg_t pjsip_sip_cfg_var = { + /* Global settings */ + { + PJSIP_ALLOW_PORT_IN_FROMTO_HDR + }, + /* Transaction settings */ { PJSIP_MAX_TSX_COUNT, diff --git a/pjsip/src/pjsip/sip_uri.c b/pjsip/src/pjsip/sip_uri.c index d4054573..d2b31d9f 100644 --- a/pjsip/src/pjsip/sip_uri.c +++ b/pjsip/src/pjsip/sip_uri.c @@ -288,14 +288,16 @@ static pj_ssize_t pjsip_url_print( pjsip_uri_context_e context, } /* Only print port if it is explicitly specified. - * Port is not allowed in To and From header. + * Port is not allowed in To and From header, see Table 1 in + * RFC 3261 Section 19.1.1 */ - /* Unfortunately some UA requires us to send back the port - * number exactly as it was sent. We don't remember whether an - * UA has sent us port, so we'll just send the port indiscrimately + /* Note: ticket #1141 adds run-time setting to allow port number to + * appear in From/To header. Default is still false. */ - //PJ_TODO(SHOULD_DISALLOW_URI_PORT_IN_FROM_TO_HEADER) - if (url->port && context != PJSIP_URI_IN_FROMTO_HDR) { + if (url->port && + (context != PJSIP_URI_IN_FROMTO_HDR || + pjsip_cfg()->endpt.allow_port_in_fromto_hdr)) + { if (endbuf - buf < 10) return -1; |