]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Implement ipv6%interface notation for scope_id usage.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 19 Oct 2011 14:34:11 +0000 (14:34 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 19 Oct 2011 14:34:11 +0000 (14:34 +0000)
git-svn-id: file:///svn/unbound/trunk@2519 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/net_help.c

index 092fecdb0f3a500ed274be7906e749e3d6f1871f..5a243913054c0ce3516447d4bc4af35ab437daf8 100644 (file)
@@ -2,6 +2,7 @@
        - fix unbound-anchor for broken strptime on OSX lion, detected
          in configure.
        - Detect if GOST really works, openssl1.0 on OSX fails.
+       - Implement ipv6%interface notation for scope_id usage.
 
 17 October 2011: Wouter
        - better documentation for inform_super (Thanks Yang Zhe).
index 95f300df4c85d86409f150544fe3288162c5d2f9..3df2cc11df2094df09a0fea5f7232af9b7f7f57e 100644 (file)
@@ -188,11 +188,21 @@ ipstrtoaddr(const char* ip, int port, struct sockaddr_storage* addr,
        if(!ip) return 0;
        p = (uint16_t) port;
        if(str_is_ip6(ip)) {
+               char buf[MAX_ADDR_STRLEN];
+               char* s;
                struct sockaddr_in6* sa = (struct sockaddr_in6*)addr;
                *addrlen = (socklen_t)sizeof(struct sockaddr_in6);
                memset(sa, 0, *addrlen);
                sa->sin6_family = AF_INET6;
                sa->sin6_port = (in_port_t)htons(p);
+               if((s=strchr(ip, '%'))) { /* ip6%interface, rfc 4007 */
+                       if(s-ip >= MAX_ADDR_STRLEN)
+                               return 0;
+                       strncpy(buf, ip, MAX_ADDR_STRLEN);
+                       buf[s-ip]=0;
+                       sa->sin6_scope_id = atoi(s+1);
+                       ip = buf;
+               }
                if(inet_pton((int)sa->sin6_family, ip, &sa->sin6_addr) <= 0) {
                        return 0;
                }