summaryrefslogtreecommitdiff
path: root/res/res_pjsip
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2014-10-17 13:17:58 +0000
committerJoshua Colp <jcolp@digium.com>2014-10-17 13:17:58 +0000
commit0d0e38a0e11d6c2f8b3d678ec2c51ab686babf54 (patch)
tree223257fd40d1e8c00c40ce03ecaf718a948b22a2 /res/res_pjsip
parent86eea19c8f6027b6f8095c531f088c9a523e4744 (diff)
res_pjsip_keepalive: Add runtime configurable keepalive module for connection-oriented transports.
This change adds a module which is configurable using the keep_alive_interval setting in the global section that will send a CRLF keep alive to all active connection-oriented transports at the provided interval. This is useful because it can help keep connections open through NATs. This functionality also exists within PJSIP but can not be controlled at runtime and requires recompiling it. Review: https://reviewboard.asterisk.org/r/4084/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425825 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip')
-rw-r--r--res/res_pjsip/config_global.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/res/res_pjsip/config_global.c b/res/res_pjsip/config_global.c
index 8e2cb2a41..1779c535d 100644
--- a/res/res_pjsip/config_global.c
+++ b/res/res_pjsip/config_global.c
@@ -42,6 +42,8 @@ struct global_config {
);
/* Value to put in Max-Forwards header */
unsigned int max_forwards;
+ /* The interval at which to send keep alive messages to active connection-oriented transports */
+ unsigned int keep_alive_interval;
};
static void global_destructor(void *obj)
@@ -114,6 +116,21 @@ char *ast_sip_get_debug(void)
return res;
}
+unsigned int ast_sip_get_keep_alive_interval(void)
+{
+ unsigned int interval;
+ struct global_config *cfg = get_global_cfg();
+
+ if (!cfg) {
+ return 0;
+ }
+
+ interval = cfg->keep_alive_interval;
+ ao2_ref(cfg, -1);
+
+ return interval;
+}
+
int ast_sip_initialize_sorcery_global(void)
{
struct ast_sorcery *sorcery = ast_sip_get_sorcery();
@@ -135,6 +152,8 @@ int ast_sip_initialize_sorcery_global(void)
OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_outbound_endpoint));
ast_sorcery_object_field_register(sorcery, "global", "debug", "no",
OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, debug));
+ ast_sorcery_object_field_register(sorcery, "global", "keep_alive_interval", "",
+ OPT_UINT_T, 0, FLDSET(struct global_config, keep_alive_interval));
return 0;
}