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:
parent
0cd9e10d2d
commit
861ed9a339
17
acl.c
17
acl.c
|
@ -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));
|
struct ast_ha *ha = malloc(sizeof(struct ast_ha));
|
||||||
char *nm;
|
char *nm;
|
||||||
|
char tmp[256] = "";
|
||||||
struct ast_ha *prev = NULL;
|
struct ast_ha *prev = NULL;
|
||||||
struct ast_ha *ret;
|
struct ast_ha *ret;
|
||||||
ret = path;
|
ret = path;
|
||||||
|
@ -77,21 +78,23 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
|
||||||
path = path->next;
|
path = path->next;
|
||||||
}
|
}
|
||||||
if (ha) {
|
if (ha) {
|
||||||
char *stringp=NULL;
|
strncpy(tmp, stuff, sizeof(tmp) - 1);
|
||||||
stringp=stuff;
|
nm = strchr(tmp, '/');
|
||||||
strsep(&stringp, "/");
|
|
||||||
nm = strsep(&stringp, "/");
|
|
||||||
if (!nm)
|
if (!nm)
|
||||||
nm = "255.255.255.255";
|
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);
|
ast_log(LOG_WARNING, "%s not a valid IP\n", stuff);
|
||||||
free(ha);
|
free(ha);
|
||||||
return NULL;
|
return path;
|
||||||
}
|
}
|
||||||
if (!inet_aton(nm, &ha->netmask)) {
|
if (!inet_aton(nm, &ha->netmask)) {
|
||||||
ast_log(LOG_WARNING, "%s not a valid netmask\n", nm);
|
ast_log(LOG_WARNING, "%s not a valid netmask\n", nm);
|
||||||
free(ha);
|
free(ha);
|
||||||
return NULL;
|
return path;
|
||||||
}
|
}
|
||||||
ha->netaddr.s_addr &= ha->netmask.s_addr;
|
ha->netaddr.s_addr &= ha->netmask.s_addr;
|
||||||
if (!strncasecmp(sense, "p", 1)) {
|
if (!strncasecmp(sense, "p", 1)) {
|
||||||
|
|
|
@ -5791,11 +5791,13 @@ static struct sip_user *build_user(char *name, struct ast_variable *v)
|
||||||
{
|
{
|
||||||
struct sip_user *user;
|
struct sip_user *user;
|
||||||
int format;
|
int format;
|
||||||
|
struct ast_ha *oldha = NULL;
|
||||||
user = (struct sip_user *)malloc(sizeof(struct sip_user));
|
user = (struct sip_user *)malloc(sizeof(struct sip_user));
|
||||||
if (user) {
|
if (user) {
|
||||||
memset(user, 0, sizeof(struct sip_user));
|
memset(user, 0, sizeof(struct sip_user));
|
||||||
strncpy(user->name, name, sizeof(user->name)-1);
|
strncpy(user->name, name, sizeof(user->name)-1);
|
||||||
|
oldha = user->ha;
|
||||||
|
user->ha = NULL;
|
||||||
/* set the usage flag to a sane staring value*/
|
/* set the usage flag to a sane staring value*/
|
||||||
user->inUse = 0;
|
user->inUse = 0;
|
||||||
user->outUse = 0;
|
user->outUse = 0;
|
||||||
|
@ -5888,6 +5890,8 @@ static struct sip_user *build_user(char *name, struct ast_variable *v)
|
||||||
else if (strlen(user->md5secret))
|
else if (strlen(user->md5secret))
|
||||||
strncpy(user->methods, "md5", sizeof(user->methods) - 1);
|
strncpy(user->methods, "md5", sizeof(user->methods) - 1);
|
||||||
}
|
}
|
||||||
|
if (oldha)
|
||||||
|
ast_free_ha(oldha);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5918,6 +5922,7 @@ static struct sip_peer *build_peer(char *name, struct ast_variable *v)
|
||||||
{
|
{
|
||||||
struct sip_peer *peer;
|
struct sip_peer *peer;
|
||||||
struct sip_peer *prev;
|
struct sip_peer *prev;
|
||||||
|
struct ast_ha *oldha = NULL;
|
||||||
int maskfound=0;
|
int maskfound=0;
|
||||||
int format;
|
int format;
|
||||||
int found=0;
|
int found=0;
|
||||||
|
@ -5955,6 +5960,8 @@ static struct sip_peer *build_peer(char *name, struct ast_variable *v)
|
||||||
peer->addr.sin_port = htons(DEFAULT_SIP_PORT);
|
peer->addr.sin_port = htons(DEFAULT_SIP_PORT);
|
||||||
peer->expiry = expiry;
|
peer->expiry = expiry;
|
||||||
}
|
}
|
||||||
|
oldha = peer->ha;
|
||||||
|
peer->ha = NULL;
|
||||||
peer->capability = capability;
|
peer->capability = capability;
|
||||||
/* Assume can reinvite */
|
/* Assume can reinvite */
|
||||||
peer->canreinvite = REINVITE_INVITE;
|
peer->canreinvite = REINVITE_INVITE;
|
||||||
|
@ -6075,6 +6082,8 @@ static struct sip_peer *build_peer(char *name, struct ast_variable *v)
|
||||||
reg_source_db(peer);
|
reg_source_db(peer);
|
||||||
peer->delme = 0;
|
peer->delme = 0;
|
||||||
}
|
}
|
||||||
|
if (oldha)
|
||||||
|
ast_free_ha(oldha);
|
||||||
return peer;
|
return peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue