summaryrefslogtreecommitdiff
path: root/res/res_pjsip.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2016-02-11 10:01:05 -0700
committerGeorge Joseph <george.joseph@fairview5.com>2016-02-19 17:56:27 -0700
commitd2a1457e0b4ecdd512fe58fdb55ecc07fd141bea (patch)
treedb97ca4b365f3bd4bad2110c69a0e4ff9fe268a7 /res/res_pjsip.c
parentb4fdf93d06753c580b4ef7e34fe07670a8e4aff4 (diff)
res_pjsip/config_transport: Allow reloading transports.
The 'reload' mechanism actually involves closing the underlying socket and calling the appropriate udp, tcp or tls start functions again. Only outbound_registration, pubsub and session needed work to reset the transport before sending requests to insure that the pjsip transport didn't get pulled out from under them. In my testing, no calls were dropped when a transport was changed for any of the 3 transport types even if ip addresses or ports were changed. To be on the safe side however, a new transport option was added (allow_reload) which defaults to 'no'. Unless it's explicitly set to 'yes' for a transport, changes to that transport will be ignored on a reload of res_pjsip. This should preserve the current behavior. Change-Id: I5e759850e25958117d4c02f62ceb7244d7ec9edf
Diffstat (limited to 'res/res_pjsip.c')
-rw-r--r--res/res_pjsip.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 625016191..e0af0b084 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -1026,6 +1026,14 @@
Value is in milliseconds; default is 100 ms.</para>
</description>
</configOption>
+ <configOption name="allow_reload" default="no">
+ <synopsis>Allow this transport to be reloaded.</synopsis>
+ <description>
+ <para>Allow this transport to be reloaded when res_pjsip is reloaded.
+ This option defaults to "no" because reloading a transport may disrupt
+ in-progress calls.</para>
+ </description>
+ </configOption>
</configObject>
<configObject name="contact">
<synopsis>A way of creating an aliased name to a SIP URI</synopsis>
@@ -2483,22 +2491,14 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u
return 0;
}
-static int sip_get_tpselector_from_endpoint(const struct ast_sip_endpoint *endpoint, pjsip_tpselector *selector)
+int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector)
{
- RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
RAII_VAR(struct ast_sip_transport_state *, transport_state, NULL, ao2_cleanup);
- const char *transport_name = endpoint->transport;
-
- if (ast_strlen_zero(transport_name)) {
- return 0;
- }
-
- transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_name);
- transport_state = ast_sip_get_transport_state(transport_name);
- if (!transport || !transport_state) {
- ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport '%s' for endpoint '%s'\n",
- transport_name, ast_sorcery_object_get_id(endpoint));
+ transport_state = ast_sip_get_transport_state(ast_sorcery_object_get_id(transport));
+ if (!transport_state) {
+ ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport state for '%s'\n",
+ ast_sorcery_object_get_id(transport));
return -1;
}
@@ -2521,6 +2521,35 @@ static int sip_get_tpselector_from_endpoint(const struct ast_sip_endpoint *endpo
return 0;
}
+int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector)
+{
+ RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
+
+ if (ast_strlen_zero(transport_name)) {
+ return 0;
+ }
+
+ transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_name);
+ if (!transport) {
+ ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport '%s'\n",
+ transport_name);
+ return -1;
+ }
+
+ return ast_sip_set_tpselector_from_transport(transport, selector);
+}
+
+static int sip_get_tpselector_from_endpoint(const struct ast_sip_endpoint *endpoint, pjsip_tpselector *selector)
+{
+ const char *transport_name = endpoint->transport;
+
+ if (ast_strlen_zero(transport_name)) {
+ return 0;
+ }
+
+ return ast_sip_set_tpselector_from_transport_name(endpoint->transport, selector);
+}
+
void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
{
pjsip_sip_uri *sip_uri;