summaryrefslogtreecommitdiff
path: root/res/res_pjsip_endpoint_identifier_ip.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-12-31 22:21:07 +0000
committerJoshua Colp <jcolp@digium.com>2013-12-31 22:21:07 +0000
commite583dca9dd7823489067a67311d30583ba1ad3c6 (patch)
tree8ab6a88db373027479c556c8dc033e3d450b565f /res/res_pjsip_endpoint_identifier_ip.c
parentbb30b224195c77fcae0c91037c8e9d551fc034f6 (diff)
res_pjsip_endpoint_identifier_ip: Accept hostnames in the 'match' field.
Hostnames specified in the 'match' field will be resolved and all addresses returned. Each address will be added to the endpoint identifier for the matching process. Reported by: Rob Thomas ........ Merged revisions 404613 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404620 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_endpoint_identifier_ip.c')
-rw-r--r--res/res_pjsip_endpoint_identifier_ip.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/res/res_pjsip_endpoint_identifier_ip.c b/res/res_pjsip_endpoint_identifier_ip.c
index 34c8f2c39..d71345b19 100644
--- a/res/res_pjsip_endpoint_identifier_ip.c
+++ b/res/res_pjsip_endpoint_identifier_ip.c
@@ -156,13 +156,30 @@ static struct ast_sip_endpoint_identifier ip_identifier = {
static int ip_identify_match_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
{
struct ip_identify_match *identify = obj;
- int error = 0;
+ int num_addrs = 0, error = 0, i;
+ struct ast_sockaddr *addrs;
- /* We deny what we actually want to match because there is an implicit permit all rule for ACLs */
- if (!(identify->matches = ast_append_ha("d", var->value, identify->matches, &error))) {
+ num_addrs = ast_sockaddr_resolve(&addrs, var->value, PARSE_PORT_FORBID, AST_AF_UNSPEC);
+ if (!num_addrs) {
+ ast_log(LOG_ERROR, "Address '%s' provided on ip endpoint identifier '%s' did not resolve to any address\n",
+ var->value, ast_sorcery_object_get_id(obj));
return -1;
}
+ for (i = 0; i < num_addrs; ++i) {
+ /* We deny what we actually want to match because there is an implicit permit all rule for ACLs */
+ identify->matches = ast_append_ha("d", ast_sockaddr_stringify_addr(&addrs[i]), identify->matches, &error);
+
+ if (!identify->matches || error) {
+ ast_log(LOG_ERROR, "Failed to add address '%s' to ip endpoint identifier '%s'\n",
+ ast_sockaddr_stringify_addr(&addrs[i]), ast_sorcery_object_get_id(obj));
+ error = -1;
+ break;
+ }
+ }
+
+ ast_free(addrs);
+
return error;
}