fix 'sip debug' vs. reload properly

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-08-25 02:12:49 +00:00
parent e979e32374
commit fa4b3f8416

View File

@@ -358,6 +358,8 @@ static struct in_addr __ourip;
static struct sockaddr_in outboundproxyip; static struct sockaddr_in outboundproxyip;
static int ourport; static int ourport;
#define SIP_DEBUG_CONFIG 1 << 0
#define SIP_DEBUG_CONSOLE 1 << 1
static int sipdebug = 0; static int sipdebug = 0;
static struct sockaddr_in debugaddr; static struct sockaddr_in debugaddr;
@@ -7944,7 +7946,7 @@ static int sip_do_debug_ip(int fd, int argc, char *argv[])
ast_cli(fd, "SIP Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr)); ast_cli(fd, "SIP Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr));
else else
ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), port); ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), port);
sipdebug = 1; sipdebug |= SIP_DEBUG_CONSOLE;
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@@ -7962,7 +7964,7 @@ static int sip_do_debug_peer(int fd, int argc, char *argv[])
memcpy(&debugaddr.sin_addr, &peer->addr.sin_addr, sizeof(debugaddr.sin_addr)); memcpy(&debugaddr.sin_addr, &peer->addr.sin_addr, sizeof(debugaddr.sin_addr));
debugaddr.sin_port = peer->addr.sin_port; debugaddr.sin_port = peer->addr.sin_port;
ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), ntohs(debugaddr.sin_port)); ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), ntohs(debugaddr.sin_port));
sipdebug = 1; sipdebug |= SIP_DEBUG_CONSOLE;
} else } else
ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[3]); ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[3]);
ASTOBJ_UNREF(peer,sip_destroy_peer); ASTOBJ_UNREF(peer,sip_destroy_peer);
@@ -7974,7 +7976,7 @@ static int sip_do_debug_peer(int fd, int argc, char *argv[])
/*--- sip_do_debug: Turn on SIP debugging (CLI command) */ /*--- sip_do_debug: Turn on SIP debugging (CLI command) */
static int sip_do_debug(int fd, int argc, char *argv[]) static int sip_do_debug(int fd, int argc, char *argv[])
{ {
int oldsipdebug = sipdebug; int oldsipdebug = sipdebug & SIP_DEBUG_CONSOLE;
if (argc != 2) { if (argc != 2) {
if (argc != 4) if (argc != 4)
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
@@ -7984,7 +7986,7 @@ static int sip_do_debug(int fd, int argc, char *argv[])
return sip_do_debug_peer(fd, argc, argv); return sip_do_debug_peer(fd, argc, argv);
else return RESULT_SHOWUSAGE; else return RESULT_SHOWUSAGE;
} }
sipdebug = 1; sipdebug |= SIP_DEBUG_CONSOLE;
memset(&debugaddr, 0, sizeof(debugaddr)); memset(&debugaddr, 0, sizeof(debugaddr));
if (oldsipdebug) if (oldsipdebug)
ast_cli(fd, "SIP Debugging re-enabled\n"); ast_cli(fd, "SIP Debugging re-enabled\n");
@@ -8078,7 +8080,7 @@ static int sip_no_debug(int fd, int argc, char *argv[])
{ {
if (argc != 3) if (argc != 3)
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
sipdebug = 0; sipdebug &= ~SIP_DEBUG_CONSOLE;
ast_cli(fd, "SIP Debugging Disabled\n"); ast_cli(fd, "SIP Debugging Disabled\n");
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@@ -11128,6 +11130,7 @@ static int reload_config(void)
memset(&localaddr, 0, sizeof(localaddr)); memset(&localaddr, 0, sizeof(localaddr));
memset(&externip, 0, sizeof(externip)); memset(&externip, 0, sizeof(externip));
memset(&prefs, 0 , sizeof(prefs)); memset(&prefs, 0 , sizeof(prefs));
sipdebug &= ~SIP_DEBUG_CONFIG;
/* Initialize some reasonable defaults at SIP reload */ /* Initialize some reasonable defaults at SIP reload */
ast_copy_string(default_context, DEFAULT_CONTEXT, sizeof(default_context)); ast_copy_string(default_context, DEFAULT_CONTEXT, sizeof(default_context));
@@ -11268,7 +11271,8 @@ static int reload_config(void)
if (default_expiry < 1) if (default_expiry < 1)
default_expiry = DEFAULT_DEFAULT_EXPIRY; default_expiry = DEFAULT_DEFAULT_EXPIRY;
} else if (!strcasecmp(v->name, "sipdebug")) { } else if (!strcasecmp(v->name, "sipdebug")) {
sipdebug = ast_true(v->value); if (ast_true(v->value))
sipdebug |= SIP_DEBUG_CONFIG;
} else if (!strcasecmp(v->name, "dumphistory")) { } else if (!strcasecmp(v->name, "dumphistory")) {
dumphistory = ast_true(v->value); dumphistory = ast_true(v->value);
} else if (!strcasecmp(v->name, "recordhistory")) { } else if (!strcasecmp(v->name, "recordhistory")) {