[asterisk-commits] kmoore: branch kmoore/pjsip_path_support r403068 - /team/kmoore/pjsip_path_su...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Nov 22 13:16:57 CST 2013
Author: kmoore
Date: Fri Nov 22 13:16:55 2013
New Revision: 403068
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403068
Log:
Add path to Supported header for outbound registration
Modified:
team/kmoore/pjsip_path_support/res/res_pjsip_outbound_registration.c
Modified: team/kmoore/pjsip_path_support/res/res_pjsip_outbound_registration.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_outbound_registration.c?view=diff&rev=403068&r1=403067&r2=403068
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_outbound_registration.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_outbound_registration.c Fri Nov 22 13:16:55 2013
@@ -115,6 +115,14 @@
<configOption name="type">
<synopsis>Must be of type 'registration'.</synopsis>
</configOption>
+ <configOption name="support_path">
+ <synopsis>Enables Path support for outbound REGISTER requests.</synopsis>
+ <description><para>
+ When this option is enabled, outbound REGISTER requests will advertise
+ support for Path headers so that intervening proxies can add to the Path
+ header as necessary.
+ </para></description>
+ </configOption>
</configObject>
</configFile>
</configInfo>
@@ -174,6 +182,8 @@
unsigned int forbidden_retry_interval;
/*! \brief Treat authentication challenges that we cannot handle as permanent failures */
unsigned int auth_rejection_permanent;
+ /*! \brief Determines whether SIP Path support should be advertised */
+ unsigned int support_path;
/*! \brief Serializer for stuff and things */
struct ast_taskprocessor *serializer;
/*! \brief Configured authentication credentials */
@@ -223,6 +233,8 @@
struct ast_sip_auth_array outbound_auths;
/*! \brief Number of configured auths */
size_t num_outbound_auths;
+ /*! \brief Whether Path support is enabled */
+ unsigned int support_path;
};
/*! \brief Helper function which cancels the timer on a client */
@@ -254,6 +266,25 @@
ast_copy_pj_str(client_uri, &info.client_uri, sizeof(client_uri));
ast_debug(3, "REGISTER attempt %d to '%s' with client '%s'\n",
client_state->retries + 1, server_uri, client_uri);
+
+ if (client_state->support_path) {
+ pj_str_t path_name = { "path", 4 };
+ pjsip_supported_hdr *hdr;
+
+ hdr = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL);
+ if (!hdr) {
+ /* insert a new Supported header */
+ hdr = pjsip_supported_hdr_create(tdata->pool);
+ if (!hdr) {
+ return -1;
+ }
+
+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)hdr);
+ }
+
+ /* add on to the existing Supported header */
+ pj_strdup(tdata->pool, &hdr->values[hdr->count++], &path_name);
+ }
/* Due to the registration the callback may now get called, so bump the ref count */
ao2_ref(client_state, +1);
@@ -760,6 +791,7 @@
registration->state->client_state->forbidden_retry_interval = registration->forbidden_retry_interval;
registration->state->client_state->max_retries = registration->max_retries;
registration->state->client_state->retries = 0;
+ registration->state->client_state->support_path = registration->support_path;
pjsip_regc_update_expires(registration->state->client_state->client, registration->expiration);
@@ -957,6 +989,7 @@
ast_sorcery_object_field_register(ast_sip_get_sorcery(), "registration", "max_retries", "10", OPT_UINT_T, 0, FLDSET(struct sip_outbound_registration, max_retries));
ast_sorcery_object_field_register(ast_sip_get_sorcery(), "registration", "auth_rejection_permanent", "yes", OPT_BOOL_T, 1, FLDSET(struct sip_outbound_registration, auth_rejection_permanent));
ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "registration", "outbound_auth", "", outbound_auth_handler, NULL, 0, 0);
+ ast_sorcery_object_field_register(ast_sip_get_sorcery(), "registration", "support_path", "no", OPT_BOOL_T, 1, FLDSET(struct sip_outbound_registration, support_path));
ast_sorcery_reload_object(ast_sip_get_sorcery(), "registration");
sip_outbound_registration_perform_all();
More information about the asterisk-commits
mailing list