asterisk: add contact_fqdn option for transports
This commit is contained in:
parent
f8211e4c28
commit
2606056893
1 changed files with 73 additions and 0 deletions
73
net/asterisk/patches/999-contact_fqdn.patch
Normal file
73
net/asterisk/patches/999-contact_fqdn.patch
Normal file
|
@ -0,0 +1,73 @@
|
|||
--- a/include/asterisk/res_pjsip.h
|
||||
+++ b/include/asterisk/res_pjsip.h
|
||||
@@ -238,6 +238,8 @@ struct ast_sip_transport {
|
||||
AST_STRING_FIELD(external_media_address);
|
||||
/*! Optional domain to use for messages if provided could not be found */
|
||||
AST_STRING_FIELD(domain);
|
||||
+ /*! Contact FQDN */
|
||||
+ AST_STRING_FIELD(contact_fqdn);
|
||||
);
|
||||
/*! Type of transport */
|
||||
enum ast_transport type;
|
||||
--- a/res/res_pjsip/config_transport.c
|
||||
+++ b/res/res_pjsip/config_transport.c
|
||||
@@ -1830,6 +1830,7 @@ int ast_sip_initialize_sorcery_transport
|
||||
ast_sorcery_object_field_register(sorcery, "transport", "external_signaling_port", "0", OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_transport, external_signaling_port), 0, 65535);
|
||||
ast_sorcery_object_field_register(sorcery, "transport", "external_media_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, external_media_address));
|
||||
ast_sorcery_object_field_register(sorcery, "transport", "domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, domain));
|
||||
+ ast_sorcery_object_field_register(sorcery, "transport", "contact_fqdn", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, contact_fqdn));
|
||||
ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_server", "", transport_tls_bool_handler, verify_server_to_str, NULL, 0, 0);
|
||||
ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_client", "", transport_tls_bool_handler, verify_client_to_str, NULL, 0, 0);
|
||||
ast_sorcery_object_field_register_custom(sorcery, "transport", "require_client_cert", "", transport_tls_bool_handler, require_client_cert_to_str, NULL, 0, 0);
|
||||
--- a/res/res_pjsip/pjsip_config.xml
|
||||
+++ b/res/res_pjsip/pjsip_config.xml
|
||||
@@ -1738,6 +1738,9 @@
|
||||
<configOption name="domain">
|
||||
<synopsis>Domain the transport comes from</synopsis>
|
||||
</configOption>
|
||||
+ <configOption name="contact_fqdn">
|
||||
+ <synopsis>FQDN to have in contact header</synopsis>
|
||||
+ </configOption>
|
||||
<configOption name="external_media_address">
|
||||
<synopsis>External IP address to use in RTP handling</synopsis>
|
||||
<description><para>
|
||||
--- a/res/res_pjsip/pjsip_manager.xml
|
||||
+++ b/res/res_pjsip/pjsip_manager.xml
|
||||
@@ -179,6 +179,9 @@
|
||||
<parameter name="Domain">
|
||||
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='domain']/synopsis/node())"/></para>
|
||||
</parameter>
|
||||
+ <parameter name="ContactFQDN">
|
||||
+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='contact_fqdn']/synopsis/node())"/></para>
|
||||
+ </parameter>
|
||||
<parameter name="VerifyServer">
|
||||
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='verify_server']/synopsis/node())"/></para>
|
||||
</parameter>
|
||||
--- a/res/res_pjsip_nat.c
|
||||
+++ b/res/res_pjsip_nat.c
|
||||
@@ -365,7 +365,11 @@ static pj_status_t process_nat(pjsip_tx_
|
||||
pjsip_method_cmp(&cseq->method, &pjsip_register_method)) {
|
||||
/* We can only rewrite the URI when one is present */
|
||||
if (uri || (uri = ast_sip_get_contact_sip_uri(tdata))) {
|
||||
- pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
|
||||
+ if (!ast_strlen_zero(transport->contact_fqdn)) {
|
||||
+ pj_strdup2(tdata->pool, &uri->host, transport->contact_fqdn);
|
||||
+ } else {
|
||||
+ pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
|
||||
+ }
|
||||
if (transport->external_signaling_port) {
|
||||
uri->port = transport->external_signaling_port;
|
||||
ast_debug(4, "Re-wrote Contact URI port to %d\n", uri->port);
|
||||
@@ -375,7 +379,11 @@ static pj_status_t process_nat(pjsip_tx_
|
||||
|
||||
/* Update the via header if relevant */
|
||||
if ((tdata->msg->type == PJSIP_REQUEST_MSG) && (via || (via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL)))) {
|
||||
- pj_strdup2(tdata->pool, &via->sent_by.host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
|
||||
+ if (!ast_strlen_zero(transport->contact_fqdn)) {
|
||||
+ pj_strdup2(tdata->pool, &via->sent_by.host, transport->contact_fqdn);
|
||||
+ } else {
|
||||
+ pj_strdup2(tdata->pool, &via->sent_by.host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
|
||||
+ }
|
||||
if (transport->external_signaling_port) {
|
||||
via->sent_by.port = transport->external_signaling_port;
|
||||
}
|
Loading…
Reference in a new issue