1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
$NetBSD: patch-ac,v 1.2 2009/02/21 14:43:03 adrianp Exp $
--- lib/lwres/getaddrinfo.c.orig 2007-09-12 21:45:18.000000000 -0700
+++ lib/lwres/getaddrinfo.c
@@ -142,6 +142,10 @@
#include <lwres/netdb.h>
#include <lwres/stdlib.h>
+#ifdef __KAME__
+#include <net/if.h>
+#endif
+
#define SA(addr) ((struct sockaddr *)(addr))
#define SIN(addr) ((struct sockaddr_in *)(addr))
#define SIN6(addr) ((struct sockaddr_in6 *)(addr))
@@ -366,14 +370,22 @@ lwres_getaddrinfo(const char *hostname,
p = strchr(ntmp, '%');
ep = NULL;
+#ifdef __KAME__
+ if (p != NULL) {
+ scopeid = if_nametoindex(p + 1);
+ if (scopeid)
+ p = NULL;
+ }
+#endif
/*
* Vendors may want to support non-numeric
* scopeid around here.
*/
- if (p != NULL)
+ if (p != NULL) {
scopeid = (lwres_uint32_t)strtoul(p + 1,
&ep, 10);
+ }
if (p != NULL && ep != NULL && ep[0] == '\0')
*p = '\0';
else {
@@ -709,17 +721,17 @@ lwres_freeaddrinfo(struct addrinfo *ai)
static int
get_local(const char *name, int socktype, struct addrinfo **res) {
struct addrinfo *ai;
- struct sockaddr_un *sun;
+ struct sockaddr_un *un;
if (socktype == 0)
return (EAI_SOCKTYPE);
- ai = ai_alloc(AF_LOCAL, sizeof(*sun));
+ ai = ai_alloc(AF_LOCAL, sizeof(*un));
if (ai == NULL)
return (EAI_MEMORY);
- sun = SUN(ai->ai_addr);
- strncpy(sun->sun_path, name, sizeof(sun->sun_path));
+ un = SUN(ai->ai_addr);
+ strncpy(un->sun_path, name, sizeof(un->sun_path));
ai->ai_socktype = socktype;
/*
|