Cleanup ACL parsing, handle properly reload on sip with ACL

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1918 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-01-10 21:19:56 +00:00
parent 0cd9e10d2d
commit 861ed9a339
2 changed files with 20 additions and 8 deletions

17
acl.c
View File

@@ -69,6 +69,7 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
{
struct ast_ha *ha = malloc(sizeof(struct ast_ha));
char *nm;
char tmp[256] = "";
struct ast_ha *prev = NULL;
struct ast_ha *ret;
ret = path;
@@ -77,21 +78,23 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
path = path->next;
}
if (ha) {
char *stringp=NULL;
stringp=stuff;
strsep(&stringp, "/");
nm = strsep(&stringp, "/");
strncpy(tmp, stuff, sizeof(tmp) - 1);
nm = strchr(tmp, '/');
if (!nm)
nm = "255.255.255.255";
if (!inet_aton(stuff, &ha->netaddr)) {
else {
*nm = '\0';
nm++;
}
if (!inet_aton(tmp, &ha->netaddr)) {
ast_log(LOG_WARNING, "%s not a valid IP\n", stuff);
free(ha);
return NULL;
return path;
}
if (!inet_aton(nm, &ha->netmask)) {
ast_log(LOG_WARNING, "%s not a valid netmask\n", nm);
free(ha);
return NULL;
return path;
}
ha->netaddr.s_addr &= ha->netmask.s_addr;
if (!strncasecmp(sense, "p", 1)) {