|
|
|
@ -91,12 +91,10 @@ static void ast_copy_ha(struct ast_ha *from, struct ast_ha *to)
|
|
|
|
|
static struct ast_ha *ast_duplicate_ha(struct ast_ha *original)
|
|
|
|
|
{
|
|
|
|
|
struct ast_ha *new_ha = malloc(sizeof(struct ast_ha));
|
|
|
|
|
|
|
|
|
|
/* Copy from original to new object */
|
|
|
|
|
ast_copy_ha(original, new_ha);
|
|
|
|
|
|
|
|
|
|
return(new_ha);
|
|
|
|
|
|
|
|
|
|
return new_ha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create duplicate HA link list */
|
|
|
|
@ -118,7 +116,7 @@ struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original)
|
|
|
|
|
start = start->next; /* Go to next object */
|
|
|
|
|
prev = link; /* Save pointer to this object */
|
|
|
|
|
}
|
|
|
|
|
return (ret); /* Return start of list */
|
|
|
|
|
return ret; /* Return start of list */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
|
|
|
|
@ -138,9 +136,9 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
|
|
|
|
|
if (ha) {
|
|
|
|
|
ast_copy_string(tmp, stuff, sizeof(tmp));
|
|
|
|
|
nm = strchr(tmp, '/');
|
|
|
|
|
if (!nm)
|
|
|
|
|
if (!nm) {
|
|
|
|
|
nm = "255.255.255.255";
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
*nm = '\0';
|
|
|
|
|
nm++;
|
|
|
|
|
}
|
|
|
|
@ -170,11 +168,12 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
|
|
|
|
|
ha->sense = AST_SENSE_DENY;
|
|
|
|
|
}
|
|
|
|
|
ha->next = NULL;
|
|
|
|
|
if (prev)
|
|
|
|
|
if (prev) {
|
|
|
|
|
prev->next = ha;
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
ret = ha;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
@ -193,7 +192,7 @@ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin)
|
|
|
|
|
ast_inet_ntoa(iabuf2, sizeof(iabuf2), ha->netaddr));
|
|
|
|
|
/* For each rule, if this address and the netmask = the net address
|
|
|
|
|
apply the current rule */
|
|
|
|
|
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == (ha->netaddr.s_addr))
|
|
|
|
|
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr)
|
|
|
|
|
res = ha->sense;
|
|
|
|
|
ha = ha->next;
|
|
|
|
|
}
|
|
|
|
|