summaryrefslogtreecommitdiff
path: root/main/netsock2.c
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2011-06-22 19:12:24 +0000
committerTerry Wilson <twilson@digium.com>2011-06-22 19:12:24 +0000
commit385b8c6f8b9cbc39c1c1667a5de6c84c9a4271f8 (patch)
tree7a6ec853f73b606503c37503da65c5f3c106c647 /main/netsock2.c
parent9000732418a94ad98f1f8c65c76733a04c169da6 (diff)
Merged revisions 324484 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r324484 | twilson | 2011-06-22 13:52:04 -0500 (Wed, 22 Jun 2011) | 20 lines Stop sending IPv6 link-local scope-ids in SIP messages The idea behind the patch listed below was used, but in a more targeted manner. There are now address stringification functions for addresses that are meant to be sent to a remote party. Link-local scope-ids only make sense on the machine from which they originate and so are stripped in the new functions. There is also a host sanitization function added to chan_sip which is used for when peer and dialog tohost fields or sip_registry hostnames are used to craft a SIP message. Also added are some basic unit tests for netsock2 address parsing. (closes issue ASTERISK-17711) Reported by: ch_djalel Patches: asterisk-1.8.3.2-ipv6_ll_scope.patch uploaded by ch_djalel (license 1251) Review: https://reviewboard.asterisk.org/r/1278/ ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@324487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/netsock2.c')
-rw-r--r--main/netsock2.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/main/netsock2.c b/main/netsock2.c
index d6561fba2..4ac1d0ffb 100644
--- a/main/netsock2.c
+++ b/main/netsock2.c
@@ -95,7 +95,14 @@ char *ast_sockaddr_stringify_fmt(const struct ast_sockaddr *sa, int format)
return "";
}
- switch (format) {
+ if ((format & AST_SOCKADDR_STR_REMOTE) == AST_SOCKADDR_STR_REMOTE) {
+ char *p;
+ if (ast_sockaddr_is_ipv6_link_local(sa) && (p = strchr(host, '%'))) {
+ *p = '\0';
+ }
+ }
+
+ switch ((format & AST_SOCKADDR_STR_FORMAT_MASK)) {
case AST_SOCKADDR_STR_DEFAULT:
ast_str_set(&str, 0, sa_tmp->ss.ss_family == AF_INET6 ?
"[%s]:%s" : "%s:%s", host, port);
@@ -397,6 +404,12 @@ int ast_sockaddr_is_ipv4_multicast(const struct ast_sockaddr *addr)
return ((ast_sockaddr_ipv4(addr) & 0xf0000000) == 0xe0000000);
}
+int ast_sockaddr_is_ipv6_link_local(const struct ast_sockaddr *addr)
+{
+ const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&addr->ss;
+ return ast_sockaddr_is_ipv6(addr) && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr);
+}
+
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
{
return addr->ss.ss_family == AF_INET6 &&