[svn-commits] file: branch file/pimp_sip_nat r382085 - in /team/file/pimp_sip_nat: include/...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Feb 26 12:14:23 CST 2013
Author: file
Date: Tue Feb 26 12:14:20 2013
New Revision: 382085
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382085
Log:
Make some NAT options configurable on a per-endpoint basis.
Modified:
team/file/pimp_sip_nat/include/asterisk/res_sip.h
team/file/pimp_sip_nat/res/res_sip/sip_configuration.c
team/file/pimp_sip_nat/res/res_sip_nat.c
Modified: team/file/pimp_sip_nat/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/include/asterisk/res_sip.h?view=diff&rev=382085&r1=382084&r2=382085
==============================================================================
--- team/file/pimp_sip_nat/include/asterisk/res_sip.h (original)
+++ team/file/pimp_sip_nat/include/asterisk/res_sip.h Tue Feb 26 12:14:20 2013
@@ -259,6 +259,10 @@
unsigned int ice_support;
/*! Whether to use the "ptime" attribute received from the endpoint or not */
unsigned int use_ptime;
+ /*! Whether to force using the source IP address/port for sending responses */
+ unsigned int force_rport;
+ /*! Whether to rewrite the Contact header with the source IP address/port or not */
+ unsigned int rewrite_contact;
/*! Enabled SIP extensions */
unsigned int extensions;
/*! Minimum session expiration period, in seconds */
Modified: team/file/pimp_sip_nat/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/res/res_sip/sip_configuration.c?view=diff&rev=382085&r1=382084&r2=382085
==============================================================================
--- team/file/pimp_sip_nat/res/res_sip/sip_configuration.c (original)
+++ team/file/pimp_sip_nat/res/res_sip/sip_configuration.c Tue Feb 26 12:14:20 2013
@@ -280,6 +280,8 @@
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_symmetric", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, rtp_symmetric));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ice_support", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, ice_support));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_ptime", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, use_ptime));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_rport", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, force_rport));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rewrite_contact", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, rewrite_contact));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "transport", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, transport));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mohsuggest", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mohsuggest));
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "100rel", "yes", prack_handler, NULL, 0, 0);
Modified: team/file/pimp_sip_nat/res/res_sip_nat.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/res/res_sip_nat.c?view=diff&rev=382085&r1=382084&r2=382085
==============================================================================
--- team/file/pimp_sip_nat/res/res_sip_nat.c (original)
+++ team/file/pimp_sip_nat/res/res_sip_nat.c Tue Feb 26 12:14:20 2013
@@ -33,17 +33,24 @@
static pj_bool_t nat_on_rx_request(pjsip_rx_data *rdata)
{
- pjsip_contact_hdr *contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
- pjsip_sip_uri *uri;
+ RAII_VAR(struct ast_sip_endpoint *, endpoint, ast_sip_identify_endpoint(rdata), ao2_cleanup);
+ pjsip_contact_hdr *contact;
- if (!contact || !(PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
+ if (!endpoint) {
return PJ_FALSE;
}
- uri = pjsip_uri_get_uri(contact->uri);
- pj_cstr(&uri->host, rdata->pkt_info.src_name);
- uri->port = rdata->pkt_info.src_port;
- rdata->msg_info.via->rport_param = 0;
+ if (endpoint->rewrite_contact && (contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL)) &&
+ (PJSIP_URI_SCHEME_IS_SIP(contact->uri) || PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
+ pjsip_sip_uri *uri = pjsip_uri_get_uri(contact->uri);
+
+ pj_cstr(&uri->host, rdata->pkt_info.src_name);
+ uri->port = rdata->pkt_info.src_port;
+ }
+
+ if (endpoint->force_rport) {
+ rdata->msg_info.via->rport_param = 0;
+ }
return PJ_FALSE;
}
More information about the svn-commits
mailing list