diff options
author | Joshua Colp <jcolp@digium.com> | 2008-04-30 20:51:17 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2008-04-30 20:51:17 +0000 |
commit | f4237076bfa5ff91a47496fddb1a00fe17595a1d (patch) | |
tree | 8e78102947dd11c948e05595fb1eb83706b265c5 /channels/chan_sip.c | |
parent | e37dafdd3a451ed78c6664a55a7797102b2c1e7a (diff) |
Add support for specifying the registration expiry on a per registration basis in the register line. This comes from a Switchvox patch. (issue AST-24)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114912 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index c9275b804..68fb035b9 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -6294,7 +6294,7 @@ static int sip_register(const char *value, int lineno) enum sip_transport transport = SIP_TRANSPORT_UDP; char buf[256] = ""; char *username = NULL; - char *hostname=NULL, *secret=NULL, *authuser=NULL; + char *hostname=NULL, *secret=NULL, *authuser=NULL, *expiry=NULL; char *porta=NULL; char *callback=NULL; char *trans=NULL; @@ -6330,7 +6330,7 @@ static int sip_register(const char *value, int lineno) if (hostname) *hostname++ = '\0'; if (ast_strlen_zero(username) || ast_strlen_zero(hostname)) { - ast_log(LOG_WARNING, "Format for registration is user[:secret[:authuser]]@host[:port][/contact] at line %d\n", lineno); + ast_log(LOG_WARNING, "Format for registration is user[:secret[:authuser]]@host[:port][/contact][~expiry] at line %d\n", lineno); return -1; } /* split user[:secret[:authuser]] */ @@ -6342,6 +6342,9 @@ static int sip_register(const char *value, int lineno) *authuser++ = '\0'; } /* split host[:port][/contact] */ + expiry = strchr(hostname, '~'); + if (expiry) + *expiry++ = '\0'; callback = strchr(hostname, '/'); if (callback) *callback++ = '\0'; @@ -6380,9 +6383,9 @@ static int sip_register(const char *value, int lineno) ast_string_field_set(reg, secret, secret); reg->transport = transport; reg->expire = -1; - reg->expiry = default_expiry; + reg->expiry = (expiry ? atoi(expiry) : default_expiry); reg->timeout = -1; - reg->refresh = default_expiry; + reg->refresh = reg->expiry; reg->portno = portnum; reg->callid_valid = FALSE; reg->ocseq = INITIAL_CSEQ; |