save via_string when sent to nh so we can use it in session timer re-invites to fix double nat issue

This commit is contained in:
Anthony Minessale 2011-08-22 10:58:33 -05:00
parent 71964f61ac
commit cd8ccebbf4
8 changed files with 60 additions and 0 deletions

View File

@ -837,6 +837,9 @@ int nua_client_request_sendmsg(nua_client_request_t *cr)
if (!sip->sip_user_agent && NH_PGET(nh, user_agent))
sip_add_make(msg, sip, sip_user_agent_class, NH_PGET(nh, user_agent));
if (!sip->sip_via && NH_PGET(nh, via))
sip_add_make(msg, sip, sip_via_class, NH_PGET(nh, via));
/** Any node implementing one or more event packages SHOULD include an
* appropriate @AllowEvents header indicating all supported events in
* all methods which initiate dialogs and their responses (such as

View File

@ -154,6 +154,7 @@ void nua_dialog_store_peer_info(nua_owner_t *own,
sip = NULL; /* Redirected */
if (sip == NULL) {
nr->nr_via = NULL, su_free(own, old->nr_via);
nr->nr_allow = NULL, su_free(own, old->nr_allow);
nr->nr_accept = NULL, su_free(own, old->nr_accept);
nr->nr_require = NULL, su_free(own, old->nr_require);
@ -182,6 +183,11 @@ void nua_dialog_store_peer_info(nua_owner_t *own,
su_free(own, old->nr_supported);
}
if (sip->sip_via) {
nr->nr_via = sip_via_dup(own, sip->sip_via);
su_free(own, old->nr_via);
}
if (sip->sip_user_agent) {
nr->nr_user_agent = sip_user_agent_dup(own, sip->sip_user_agent);
su_free(own, old->nr_user_agent);

View File

@ -83,6 +83,7 @@ struct nua_dialog_state
*/
struct nua_dialog_peer_info {
sip_via_t *nr_via;
sip_allow_t *nr_allow;
sip_accept_t *nr_accept;
sip_require_t *nr_require;

View File

@ -957,6 +957,16 @@ static int nhp_set_tags(su_home_t *home,
value = 0;
NHP_SET_STR(nhp, organization, value);
}
/* SIPTAG_VIA(via) */
else if (tag == siptag_via) {
NHP_SET_STR_BY_HEADER(nhp, via, value);
}
/* SIPTAG_VIA_STR(via_str) */
else if (tag == siptag_via_str) {
if (value == -1)
value = 0;
NHP_SET_STR(nhp, via, value);
}
/* NUTAG_REGISTRAR(registrar) */
else if (tag == nutag_registrar) {
NHP_SET_STR_BY_URL(nhp, char, registrar, value);
@ -1134,6 +1144,7 @@ int nhp_save_params(nua_handle_t *nh,
NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, allow_events);
NHP_ZAP_OVERRIDEN(old, dst, su_free, user_agent);
NHP_ZAP_OVERRIDEN(old, dst, su_free, organization);
NHP_ZAP_OVERRIDEN(old, dst, su_free, via);
NHP_ZAP_OVERRIDEN(old, dst, su_free, m_display);
NHP_ZAP_OVERRIDEN(old, dst, su_free, m_username);
NHP_ZAP_OVERRIDEN(old, dst, su_free, m_params);
@ -1673,6 +1684,9 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
TIF_SIP(SIPTAG_ORGANIZATION, organization),
TIF(SIPTAG_ORGANIZATION_STR, organization),
TIF_SIP(SIPTAG_VIA, via),
TIF(SIPTAG_VIA_STR, via),
TIF(NUTAG_INITIAL_ROUTE, initial_route),
TIF_STR(NUTAG_INITIAL_ROUTE_STR, initial_route),

View File

@ -127,6 +127,7 @@ struct nua_handle_preferences
sip_allow_events_t *nhp_allow_events;
char const *nhp_user_agent;
char const *nhp_organization;
char const *nhp_via;
char const *nhp_m_display;
char const *nhp_m_username;
@ -195,6 +196,7 @@ struct nua_handle_preferences
unsigned nhb_allow_events:1;
unsigned nhb_user_agent:1;
unsigned nhb_organization:1;
unsigned nhb_via:1;
unsigned nhb_m_display:1;
unsigned nhb_m_username:1;

View File

@ -537,6 +537,10 @@ int nua_server_respond(nua_server_request_t *sr, tagi_t const *tags)
sip_add_make(msg, sip, sip_organization_class,
NH_PGET(nh, organization)) < 0)
;
else if (!sip->sip_via && NH_PGET(nh, via) &&
sip_add_make(msg, sip, sip_via_class,
NH_PGET(nh, via)) < 0)
;
else if (!sip->sip_allow && NH_PGET(nh, allow) &&
sip_add_dup(msg, sip, (void *)NH_PGET(nh, allow)) < 0)
;

View File

@ -2458,6 +2458,31 @@ tag_typedef_t nutag_user_agent = STRTAG_TYPEDEF(user_agent);
*/
/**@def NUTAG_VIA()
*
* Via string.
*
* Indicate the Via header used by the stack.
*
* @par Used with
* nua_set_params(), nua_set_hparams() \n
* nua_get_params(), nua_get_hparams(), #nua_r_get_params \n
* any handle-specific nua call
*
* @par Parameter type
* char const *
*
* @par Values
* See @RFC3261 \n
*
* Corresponding tag taking reference parameter is NUTAG_VIA_REF().
*/
tag_typedef_t nutag_via = STRTAG_TYPEDEF(via);
/**@def NUTAG_VIA_REF(x)
* Reference tag for NUTAG_VIA().
*/
/**@def NUTAG_ALLOW()
*
* Allow a method (or methods).

View File

@ -437,6 +437,11 @@ SOFIAPUBVAR tag_typedef_t nutag_user_agent;
#define NUTAG_USER_AGENT_REF(x) nutag_user_agent_ref, tag_str_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_user_agent_ref;
#define NUTAG_VIA(x) nutag_via, tag_str_v(x)
SOFIAPUBVAR tag_typedef_t nutag_via;
#define NUTAG_VIA_REF(x) nutag_via_ref, tag_str_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_via_ref;
#define NUTAG_ALLOW(x) nutag_allow, tag_str_v(x)
SOFIAPUBVAR tag_typedef_t nutag_allow;
#define NUTAG_ALLOW_REF(x) nutag_allow_ref, tag_str_vr(&(x))