[asterisk-commits] oej: trunk r49092 - in /trunk: channels/
include/asterisk/ main/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Jan 1 12:20:46 MST 2007
Author: oej
Date: Mon Jan 1 13:20:46 2007
New Revision: 49092
URL: http://svn.digium.com/view/asterisk?view=rev&rev=49092
Log:
- Implement error handling in ast_append_ha
- Use this in chan_sip
- Document ha functions in acl.c
Modified:
trunk/channels/chan_h323.c
trunk/channels/chan_iax2.c
trunk/channels/chan_mgcp.c
trunk/channels/chan_sip.c
trunk/channels/chan_skinny.c
trunk/include/asterisk/acl.h
trunk/main/acl.c
Modified: trunk/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_h323.c?view=diff&rev=49092&r1=49091&r2=49092
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Mon Jan 1 13:20:46 2007
@@ -1425,7 +1425,7 @@
}
} else if (!strcasecmp(v->name, "permit") ||
!strcasecmp(v->name, "deny")) {
- user->ha = ast_append_ha(v->name, v->value, user->ha);
+ user->ha = ast_append_ha(v->name, v->value, user->ha, NULL);
}
}
if (!user->options.dtmfmode)
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=49092&r1=49091&r2=49092
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Mon Jan 1 13:20:46 2007
@@ -8450,7 +8450,7 @@
peer_set_srcaddr(peer, v->value);
} else if (!strcasecmp(v->name, "permit") ||
!strcasecmp(v->name, "deny")) {
- peer->ha = ast_append_ha(v->name, v->value, peer->ha);
+ peer->ha = ast_append_ha(v->name, v->value, peer->ha, NULL);
} else if (!strcasecmp(v->name, "mask")) {
maskfound++;
inet_aton(v->value, &peer->mask);
@@ -8610,7 +8610,7 @@
}
} else if (!strcasecmp(v->name, "permit") ||
!strcasecmp(v->name, "deny")) {
- user->ha = ast_append_ha(v->name, v->value, user->ha);
+ user->ha = ast_append_ha(v->name, v->value, user->ha, NULL);
} else if (!strcasecmp(v->name, "setvar")) {
varname = ast_strdupa(v->value);
if (varname && (varval = strchr(varname,'='))) {
Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?view=diff&rev=49092&r1=49091&r2=49092
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Mon Jan 1 13:20:46 2007
@@ -3638,7 +3638,7 @@
}
} else if (!strcasecmp(v->name, "permit") ||
!strcasecmp(v->name, "deny")) {
- gw->ha = ast_append_ha(v->name, v->value, gw->ha);
+ gw->ha = ast_append_ha(v->name, v->value, gw->ha, NULL);
} else if (!strcasecmp(v->name, "port")) {
gw->addr.sin_port = htons(atoi(v->value));
} else if (!strcasecmp(v->name, "context")) {
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=49092&r1=49091&r2=49092
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Jan 1 13:20:46 2007
@@ -15765,7 +15765,11 @@
user->chanvars = add_var(v->value, user->chanvars);
} else if (!strcasecmp(v->name, "permit") ||
!strcasecmp(v->name, "deny")) {
- user->ha = ast_append_ha(v->name, v->value, user->ha);
+ int ha_error = 0;
+
+ user->ha = ast_append_ha(v->name, v->value, user->ha, &ha_error);
+ if (ha_error)
+ ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
} else if (!strcasecmp(v->name, "allowtransfer")) {
user->allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;
} else if (!strcasecmp(v->name, "secret")) {
@@ -16023,7 +16027,11 @@
return NULL;
}
} else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
- peer->ha = ast_append_ha(v->name, v->value, peer->ha);
+ int ha_error = 0;
+
+ peer->ha = ast_append_ha(v->name, v->value, peer->ha, &ha_error);
+ if (ha_error)
+ ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
} else if (!strcasecmp(v->name, "port")) {
if (!realtime && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC))
peer->defaddr.sin_port = htons(atoi(v->value));
@@ -16405,10 +16413,14 @@
}
} else if (!strcasecmp(v->name, "localnet")) {
struct ast_ha *na;
- if (!(na = ast_append_ha("d", v->value, localaddr)))
+ int ha_error;
+
+ if (!(na = ast_append_ha("d", v->value, localaddr, &ha_error)))
ast_log(LOG_WARNING, "Invalid localnet value: %s\n", v->value);
else
localaddr = na;
+ if (ha_error)
+ ast_log(LOG_ERROR, "Bad localnet configuration value line %d : %s\n", v->lineno, v->value);
} else if (!strcasecmp(v->name, "externip")) {
if (!(hp = ast_gethostbyname(v->value, &ahp)))
ast_log(LOG_WARNING, "Invalid address for externip keyword: %s\n", v->value);
Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=49092&r1=49091&r2=49092
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Mon Jan 1 13:20:46 2007
@@ -2027,7 +2027,7 @@
} else if (!strcasecmp(v->name, "device")) {
ast_copy_string(d->id, v->value, sizeof(d->id));
} else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
- d->ha = ast_append_ha(v->name, v->value, d->ha);
+ d->ha = ast_append_ha(v->name, v->value, d->ha, NULL);
} else if (!strcasecmp(v->name, "context")) {
ast_copy_string(context, v->value, sizeof(context));
} else if (!strcasecmp(v->name, "allow")) {
Modified: trunk/include/asterisk/acl.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/acl.h?view=diff&rev=49092&r1=49091&r2=49092
==============================================================================
--- trunk/include/asterisk/acl.h (original)
+++ trunk/include/asterisk/acl.h Mon Jan 1 13:20:46 2007
@@ -38,13 +38,24 @@
struct ast_ha;
+/*! \brief Free host access list */
void ast_free_ha(struct ast_ha *ha);
-struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path);
+
+/*! \brief Append ACL entry to host access list. */
+struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int *error);
+
+/*! \brief Check IP address with host access list */
int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin);
+
+/*! \brief Copy host access list */
+struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original);
+
int ast_get_ip(struct sockaddr_in *sin, const char *value);
+
int ast_get_ip_or_srv(struct sockaddr_in *sin, const char *value, const char *service);
+
int ast_ouraddrfor(struct in_addr *them, struct in_addr *us);
-struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original);
+
int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr);
int ast_str2tos(const char *value, unsigned int *tos);
const char *ast_tos2str(unsigned int tos);
Modified: trunk/main/acl.c
URL: http://svn.digium.com/view/asterisk/trunk/main/acl.c?view=diff&rev=49092&r1=49091&r2=49092
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Mon Jan 1 13:20:46 2007
@@ -137,7 +137,7 @@
return ret; /* Return start of list */
}
-struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
+struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int *error)
{
struct ast_ha *ha;
char *nm = "255.255.255.255";
@@ -172,11 +172,15 @@
}
} else if (!inet_aton(nm, &ha->netmask)) {
ast_log(LOG_WARNING, "%s is not a valid netmask\n", nm);
+ if (error)
+ *error = 1;
free(ha);
return ret;
}
if (!inet_aton(tmp, &ha->netaddr)) {
ast_log(LOG_WARNING, "%s is not a valid IP\n", tmp);
+ if (error)
+ *error = 1;
free(ha);
return ret;
}
@@ -193,7 +197,8 @@
ret = ha;
}
}
- ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm);
return ret;
}
More information about the asterisk-commits
mailing list