From b748d7af7ea4bb9baf5517cc53756f8d4d7be1ca Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 13 Aug 2017 17:51:52 +0200 Subject: [PATCH] ipv6_scope: support unique local addresses Fixes #1764 Closes #1773 Reported-by: James Slaughter --- lib/if2ip.c | 4 +++- lib/if2ip.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/if2ip.c b/lib/if2ip.c index 3e74cc687..a91b6d2ab 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -71,6 +71,8 @@ unsigned int Curl_ipv6_scope(const struct sockaddr *sa) const unsigned char *b = sa6->sin6_addr.s6_addr; unsigned short w = (unsigned short) ((b[0] << 8) | b[1]); + if((b[0] & 0xFE) == 0xFC) /* Handle ULAs */ + return IPV6_SCOPE_UNIQUELOCAL; switch(w & 0xFFC0) { case 0xFE80: return IPV6_SCOPE_LINKLOCAL; diff --git a/lib/if2ip.h b/lib/if2ip.h index f3a7ff0b2..a90e66216 100644 --- a/lib/if2ip.h +++ b/lib/if2ip.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,7 +27,8 @@ #define IPV6_SCOPE_GLOBAL 0 /* Global scope. */ #define IPV6_SCOPE_LINKLOCAL 1 /* Link-local scope. */ #define IPV6_SCOPE_SITELOCAL 2 /* Site-local scope (deprecated). */ -#define IPV6_SCOPE_NODELOCAL 3 /* Loopback. */ +#define IPV6_SCOPE_UNIQUELOCAL 3 /* Unique local */ +#define IPV6_SCOPE_NODELOCAL 4 /* Loopback. */ unsigned int Curl_ipv6_scope(const struct sockaddr *sa);