[svn-commits] dvossel: trunk r244924 - in /trunk/channels: ./ sip/ sip/include/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Feb 5 10:59:12 CST 2010
Author: dvossel
Date: Fri Feb 5 10:59:06 2010
New Revision: 244924
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244924
Log:
fixes issue with sip registry not having correct default expiry
default expiry was not being set correctly for a registry object.
Thanks to ebroad for reporting the issue and testing the patch.
Modified:
trunk/channels/chan_sip.c
trunk/channels/sip/config_parser.c
trunk/channels/sip/include/config_parser.h
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=244924&r1=244923&r2=244924
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Feb 5 10:59:06 2010
@@ -6268,7 +6268,7 @@
ast_atomic_fetchadd_int(®objs, 1);
ASTOBJ_INIT(reg);
- if (sip_parse_register_line(reg, value, lineno)) {
+ if (sip_parse_register_line(reg, default_expiry, value, lineno)) {
registry_unref(reg, "failure to parse, unref the reg pointer");
return -1;
}
Modified: trunk/channels/sip/config_parser.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/config_parser.c?view=diff&rev=244924&r1=244923&r2=244924
==============================================================================
--- trunk/channels/sip/config_parser.c (original)
+++ trunk/channels/sip/config_parser.c Fri Feb 5 10:59:06 2010
@@ -32,7 +32,7 @@
* \retval 0 on success
* \retval -1 on failure
*/
-int sip_parse_register_line(struct sip_registry *reg, const char *value, int lineno)
+int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const char *value, int lineno)
{
int portnum = 0;
enum sip_transport transport = SIP_TRANSPORT_UDP;
@@ -208,9 +208,7 @@
reg->portno = portnum;
reg->callid_valid = FALSE;
reg->ocseq = INITIAL_CSEQ;
- if (!ast_strlen_zero(host1.expiry)) {
- reg->refresh = reg->expiry = reg->configured_expiry = atoi(ast_strip_quoted(host1.expiry, "\"", "\""));
- }
+ reg->refresh = reg->expiry = reg->configured_expiry = (host1.expiry ? atoi(ast_strip_quoted(host1.expiry, "\"", "\"")) : default_expiry);
return 0;
}
@@ -219,6 +217,7 @@
{
int res = AST_TEST_PASS;
struct sip_registry *reg;
+ int default_expiry = 120;
const char *reg1 = "name at domain";
const char *reg2 = "name:pass at domain";
const char *reg3 = "name at namedomain:pass:authuser at domain";
@@ -247,7 +246,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg1, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg1, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name") ||
strcmp(reg->hostname, "domain") ||
@@ -257,9 +256,9 @@
reg->transport != SIP_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
- reg->refresh ||
- reg->expiry ||
- reg->configured_expiry ||
+ reg->refresh != default_expiry ||
+ reg->expiry != default_expiry ||
+ reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
@@ -274,7 +273,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg2, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg2, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name") ||
strcmp(reg->hostname, "domain") ||
@@ -284,9 +283,9 @@
reg->transport != SIP_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
- reg->refresh ||
- reg->expiry ||
- reg->configured_expiry ||
+ reg->refresh != default_expiry ||
+ reg->expiry != default_expiry ||
+ reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
@@ -301,7 +300,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg3, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg3, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name at namedomain") ||
strcmp(reg->hostname, "domain") ||
@@ -311,9 +310,9 @@
reg->transport != SIP_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
- reg->refresh ||
- reg->expiry ||
- reg->configured_expiry ||
+ reg->refresh != default_expiry ||
+ reg->expiry != default_expiry ||
+ reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
@@ -328,7 +327,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg4, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg4, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name at namedomain") ||
strcmp(reg->hostname, "domain") ||
@@ -338,9 +337,9 @@
reg->transport != SIP_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
- reg->refresh ||
- reg->expiry ||
- reg->configured_expiry ||
+ reg->refresh != default_expiry ||
+ reg->expiry != default_expiry ||
+ reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
@@ -355,7 +354,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg5, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg5, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name at namedomain") ||
strcmp(reg->hostname, "domain") ||
@@ -365,9 +364,9 @@
reg->transport != SIP_TRANSPORT_TCP ||
reg->timeout != -1 ||
reg->expire != -1 ||
- reg->refresh ||
- reg->expiry ||
- reg->configured_expiry ||
+ reg->refresh != default_expiry ||
+ reg->expiry != default_expiry ||
+ reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
@@ -382,7 +381,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg6, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg6, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name at namedomain") ||
strcmp(reg->hostname, "domain") ||
@@ -409,7 +408,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg7, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg7, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name at namedomain") ||
strcmp(reg->hostname, "domain") ||
@@ -436,7 +435,7 @@
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
- sip_parse_register_line(reg, reg8, 1) ||
+ sip_parse_register_line(reg, default_expiry, reg8, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name at namedomain") ||
strcmp(reg->hostname, "domain") ||
@@ -462,7 +461,7 @@
/* ---Test reg 9, missing domain, expected to fail --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
- } else if (!sip_parse_register_line(reg, reg9, 1)) {
+ } else if (!sip_parse_register_line(reg, default_expiry, reg9, 1)) {
ast_str_append(&args->ast_test_error_str, 0, "Test 9, missing domain, expected to fail but did not.\n");
res = AST_TEST_FAIL;
@@ -473,7 +472,7 @@
/* ---Test reg 10, missing user, expected to fail --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
- } else if (!sip_parse_register_line(reg, reg10, 1)) {
+ } else if (!sip_parse_register_line(reg, default_expiry, reg10, 1)) {
ast_str_append(&args->ast_test_error_str, 0, "Test 10, missing user expected to fail but did not\n");
res = AST_TEST_FAIL;
@@ -482,7 +481,7 @@
ast_free(reg);
/* ---Test reg 11, no registry object, expected to fail--- */
- if (!sip_parse_register_line(NULL, reg1, 1)) {
+ if (!sip_parse_register_line(NULL, default_expiry, reg1, 1)) {
ast_str_append(&args->ast_test_error_str, 0, "Test 11, no registery object, expected to fail but did not.\n");
res = AST_TEST_FAIL;
@@ -491,7 +490,7 @@
/* ---Test reg 11, no registry line, expected to fail --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
- } else if (!sip_parse_register_line(reg, NULL, 1)) {
+ } else if (!sip_parse_register_line(reg, default_expiry, NULL, 1)) {
ast_str_append(&args->ast_test_error_str, 0, "Test 11, NULL register line expected to fail but did not.\n");
res = AST_TEST_FAIL;
Modified: trunk/channels/sip/include/config_parser.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/config_parser.h?view=diff&rev=244924&r1=244923&r2=244924
==============================================================================
--- trunk/channels/sip/include/config_parser.h (original)
+++ trunk/channels/sip/include/config_parser.h Fri Feb 5 10:59:06 2010
@@ -30,7 +30,7 @@
* \retval 0 on success
* \retval -1 on failure
*/
-int sip_parse_register_line(struct sip_registry *reg, const char *value, int lineno);
+int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const char *value, int lineno);
/*!
* \brief parses a config line for a host with a transport
More information about the svn-commits
mailing list