diff options
author | Michael L. Young <elgueromexicano@gmail.com> | 2012-04-16 21:20:50 +0000 |
---|---|---|
committer | Michael L. Young <elgueromexicano@gmail.com> | 2012-04-16 21:20:50 +0000 |
commit | abf40d9b28c0fc8339643e2903692e154d32719e (patch) | |
tree | 25974b83968cf1e99f2a60c951df3986fa87661d /main/security_events.c | |
parent | ba7032be5f4ac8c638806fe6d4f683ec7813c82f (diff) |
Add IPv6 address support to security events framework.
The current Security Events Framework API only supports IPv4 when it comes to
generating security events. This patch does the following:
* Changes the Security Events Framework API to support IPV6 and updates
the components that use this API.
* Eliminates an error message that was being generated since the current
implementation was treating an IPv6 socket address as if it was IPv4.
* Some copyright dates were updated on files touched by this patch.
(closes issue ASTERISK-19447)
Reported by: Michael L. Young
Tested by: Michael L. Young
Patches:
security_events_ipv6v3.diff uploaded by Michael L. Young (license 5026)
Review: https://reviewboard.asterisk.org/r/1777/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/security_events.c')
-rw-r--r-- | main/security_events.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/main/security_events.c b/main/security_events.c index ed05ebfa0..6b419237c 100644 --- a/main/security_events.c +++ b/main/security_events.c @@ -1,7 +1,7 @@ /* * Asterisk -- An open source telephony toolkit. * - * Copyright (C) 2009, Digium, Inc. + * Copyright (C) 2012, Digium, Inc. * * Russell Bryant <russell@digium.com> * @@ -32,6 +32,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/strings.h" #include "asterisk/network.h" #include "asterisk/security_events.h" +#include "asterisk/netsock2.h" static const size_t TIMESTAMP_STR_LEN = 32; @@ -502,12 +503,12 @@ static int add_timeval_ie(struct ast_event **event, enum ast_event_ie_type ie_ty return ast_event_append_ie_str(event, ie_type, ast_str_buffer(str)); } -static int add_ipv4_ie(struct ast_event **event, enum ast_event_ie_type ie_type, - const struct ast_security_event_ipv4_addr *addr) +static int add_ip_ie(struct ast_event **event, enum ast_event_ie_type ie_type, + const struct ast_security_event_ip_addr *addr) { struct ast_str *str = ast_str_alloca(64); - ast_str_set(&str, 0, "IPV4/"); + ast_str_set(&str, 0, (ast_sockaddr_is_ipv4(addr->addr) || ast_sockaddr_is_ipv4_mapped(addr->addr)) ? "IPV4/" : "IPV6/"); switch (addr->transport) { case AST_SECURITY_EVENT_TRANSPORT_UDP: @@ -521,9 +522,8 @@ static int add_ipv4_ie(struct ast_event **event, enum ast_event_ie_type ie_type, break; } - ast_str_append(&str, 0, "%s/%hu", - ast_inet_ntoa(addr->sin->sin_addr), - ntohs(addr->sin->sin_port)); + ast_str_append(&str, 0, "%s", ast_sockaddr_stringify_addr(addr->addr)); + ast_str_append(&str, 0, "/%s", ast_sockaddr_stringify_port(addr->addr)); return ast_event_append_ie_str(event, ie_type, ast_str_buffer(str)); } @@ -583,19 +583,19 @@ static int add_ie(struct ast_event **event, const struct ast_security_event_comm case AST_EVENT_IE_REMOTE_ADDR: case AST_EVENT_IE_EXPECTED_ADDR: { - const struct ast_security_event_ipv4_addr *addr; + const struct ast_security_event_ip_addr *addr; - addr = (const struct ast_security_event_ipv4_addr *)(((const char *) sec) + ie_type->offset); + addr = (const struct ast_security_event_ip_addr *)(((const char *) sec) + ie_type->offset); - if (req && !addr->sin) { + if (req && !addr->addr) { ast_log(LOG_WARNING, "Required IE '%d' for security event " "type '%d' not present\n", ie_type->ie_type, sec->event_type); res = -1; } - if (addr->sin) { - res = add_ipv4_ie(event, ie_type->ie_type, addr); + if (addr->addr) { + res = add_ip_ie(event, ie_type->ie_type, addr); } break; } |