diff options
author | Liong Sauw Ming <ming@teluu.com> | 2012-06-20 10:39:05 +0000 |
---|---|---|
committer | Liong Sauw Ming <ming@teluu.com> | 2012-06-20 10:39:05 +0000 |
commit | 8f176cf7c8af5c681b7b616500b6eb32adb28887 (patch) | |
tree | b4aba22b23c9d59115b0f190e161933c05f6d667 /pjsip/include | |
parent | 253bf3c598087e7d4b11d0c0cb3940551becfcdc (diff) |
Fixed #1537: Via rewrite: putting the right IP address in Via sent-by for outgoing requests
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4173 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include')
-rw-r--r-- | pjsip/include/pjsip-simple/publish.h | 16 | ||||
-rw-r--r-- | pjsip/include/pjsip-ua/sip_regc.h | 15 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_dialog.h | 26 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport.h | 8 | ||||
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 10 | ||||
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua_internal.h | 3 |
6 files changed, 77 insertions, 1 deletions
diff --git a/pjsip/include/pjsip-simple/publish.h b/pjsip/include/pjsip-simple/publish.h index c1a97fb5..59a58706 100644 --- a/pjsip/include/pjsip-simple/publish.h +++ b/pjsip/include/pjsip-simple/publish.h @@ -237,6 +237,22 @@ PJ_DECL(pj_status_t) pjsip_publishc_set_headers(pjsip_publishc *pubc, const pjsip_hdr *hdr_list); /** + * Set the "sent-by" field of the Via header for outgoing requests. + * + * @param pubc The client publication structure. + * @param via_addr Set via_addr to use for the Via header or NULL to use + * the transport's published name. + * @param via_tp via_addr will only be used if we are using via_tp + * transport. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_publishc_set_via_sent_by(pjsip_publishc *pubc, + pjsip_host_port *via_addr, + pjsip_transport *via_tp); + + +/** * Create PUBLISH request for the specified client publication structure. * Application can use this function to both create initial publication * or to modify existing publication. diff --git a/pjsip/include/pjsip-ua/sip_regc.h b/pjsip/include/pjsip-ua/sip_regc.h index c2aec0c8..9e393813 100644 --- a/pjsip/include/pjsip-ua/sip_regc.h +++ b/pjsip/include/pjsip-ua/sip_regc.h @@ -191,6 +191,21 @@ PJ_DECL(pj_status_t) pjsip_regc_init(pjsip_regc *regc, pj_uint32_t expires); /** + * Set the "sent-by" field of the Via header for outgoing requests. + * + * @param regc The client registration structure. + * @param via_addr Set via_addr to use for the Via header or NULL to use + * the transport's published name. + * @param via_tp via_addr will only be used if we are using via_tp + * transport. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_regc_set_via_sent_by(pjsip_regc *regc, + pjsip_host_port *via_addr, + pjsip_transport *via_tp); + +/** * Set the number of seconds to refresh the client registration before * the registration expires. * diff --git a/pjsip/include/pjsip/sip_dialog.h b/pjsip/include/pjsip/sip_dialog.h index a9922d57..9f37c32f 100644 --- a/pjsip/include/pjsip/sip_dialog.h +++ b/pjsip/include/pjsip/sip_dialog.h @@ -173,6 +173,14 @@ struct pjsip_dialog /** Module specific data. */ void *mod_data[PJSIP_MAX_MODULE]; /**< Module data. */ + + /** + * If via_addr is set, it will be used as the "sent-by" field of the + * Via header for outgoing requests as long as the request uses via_tp + * transport. Normally application should not use or access these fields. + */ + pjsip_host_port via_addr; /**< Via address. */ + const void *via_tp; /**< Via transport. */ }; @@ -298,6 +306,22 @@ PJ_DECL(pj_status_t) pjsip_dlg_set_transport(pjsip_dialog *dlg, /** + * Set the "sent-by" field of the Via header for outgoing requests. + * + * @param dlg The dialog instance. + * @param via_addr Set via_addr to use for the Via header or NULL to use + * the transport's published name. + * @param via_tp via_addr will only be used if we are using via_tp + * transport. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_dlg_set_via_sent_by(pjsip_dialog *dlg, + pjsip_host_port *via_addr, + pjsip_transport *via_tp); + + +/** * Create a new (forked) dialog on receipt on forked response in rdata. * The new dialog will be created from original_dlg, except that it will have * new remote tag as copied from the To header in the response. Upon return, @@ -402,7 +426,7 @@ PJ_DECL(pj_status_t) pjsip_dlg_add_usage( pjsip_dialog *dlg, * registered as a usage to the dialog. */ PJ_DECL(pj_bool_t) pjsip_dlg_has_usage(pjsip_dialog *dlg, - pjsip_module *module); + pjsip_module *module); /** * Attach module specific data to the dialog. Application can also set diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h index 99f006a6..20ddcc5e 100644 --- a/pjsip/include/pjsip/sip_transport.h +++ b/pjsip/include/pjsip/sip_transport.h @@ -584,6 +584,14 @@ struct pjsip_tx_data * Arbitrary data attached by PJSIP modules. */ void *mod_data[PJSIP_MAX_MODULE]; + + /** + * If via_addr is set, it will be used as the "sent-by" field of the + * Via header for outgoing requests as long as the request uses via_tp + * transport. Normally application should not use or access these fields. + */ + pjsip_host_port via_addr; /**< Via address. */ + const void *via_tp; /**< Via transport. */ }; diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 8bf935aa..a964815f 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -2818,6 +2818,16 @@ typedef struct pjsua_acc_config int contact_rewrite_method; /** + * This option is used to overwrite the "sent-by" field of the Via header + * for outgoing messages with the same interface address as the one in + * the REGISTER request, as long as the request uses the same transport + * instance as the previous REGISTER request. + * + * Default: 1 (yes) + */ + pj_bool_t allow_via_rewrite; + + /** * Control the use of SIP outbound feature. SIP outbound is described in * RFC 5626 to enable proxies or registrar to send inbound requests back * to UA using the same connection initiated by the UA for its diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h index 911cad10..326f916d 100644 --- a/pjsip/include/pjsua-lib/pjsua_internal.h +++ b/pjsip/include/pjsua-lib/pjsua_internal.h @@ -212,6 +212,9 @@ typedef struct pjsua_acc pj_str_t reg_contact; /**< Contact header for REGISTER. It may be different than acc contact if outbound is used */ + pjsip_host_port via_addr; /**< Address for Via header */ + pjsip_transport *via_tp; /**< Transport associated with + the Via address */ pj_str_t srv_domain; /**< Host part of reg server. */ int srv_port; /**< Port number of reg server. */ |