summaryrefslogtreecommitdiffstats
path: root/debian/patches/0014-Support-to-build-on-kFreeBSD-n-GNU-Hurd-platform.patch
blob: 34df3d30ebbc742721bafd89b27bb9a9b2ad7b36 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
From: Roger Shimizu <rogershimizu@gmail.com>
Date: Thu, 24 Dec 2015 01:16:58 +0900
Subject: Support to build on kFreeBSD & GNU/Hurd platform

Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
---
 cftoken.c            |  4 ++--
 cftoken.l            |  4 ++--
 common.c             | 38 +++++++++++++++++++-------------------
 config.c             |  8 ++++----
 configure            |  2 +-
 configure.in         |  2 +-
 dhcp6_ctl.c          |  2 +-
 dhcp6_ctlclient.c    |  2 +-
 dhcp6c.c             |  6 +++---
 dhcp6relay.c         |  6 +++---
 dhcp6s.c             |  4 ++--
 if.c                 |  2 +-
 missing/getifaddrs.c |  2 +-
 13 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/cftoken.c b/cftoken.c
index 079f274..6d43200 100644
--- a/cftoken.c
+++ b/cftoken.c
@@ -2539,7 +2539,7 @@ cfswitch_buffer(incl)
 	incstack[incstackp].state = YY_CURRENT_BUFFER;
 	incstack[incstackp].lineno = lineno;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	fp = fopen(path, "re");
 #else
 	fp = fopen(path, "r");
@@ -2566,7 +2566,7 @@ cfparse(conf)
 	char *conf;
 {
 	configfilename = conf;
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	if ((yyin = fopen(configfilename, "re")) == NULL) {
 #else
 	if ((yyin = fopen(configfilename, "r")) == NULL) {
diff --git a/cftoken.l b/cftoken.l
index e307357..f35b59f 100644
--- a/cftoken.l
+++ b/cftoken.l
@@ -418,7 +418,7 @@ cfswitch_buffer(incl)
 	incstack[incstackp].state = YY_CURRENT_BUFFER;
 	incstack[incstackp].lineno = lineno;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	fp = fopen(path, "re");
 #else
 	fp = fopen(path, "r");
@@ -445,7 +445,7 @@ cfparse(conf)
 	char *conf;
 {
 	configfilename = conf;
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	if ((yyin = fopen(configfilename, "re")) == NULL) {
 #else
 	if ((yyin = fopen(configfilename, "r")) == NULL) {
diff --git a/common.c b/common.c
index b5c09c3..10d905f 100644
--- a/common.c
+++ b/common.c
@@ -45,9 +45,9 @@
 #endif
 #include <net/if.h>
 #include <netinet/in.h>
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 #include <net/if_types.h>
-#ifdef __FreeBSD__
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
 #include <net/if_var.h>
 #endif
 #include <net/if_dl.h>
@@ -64,7 +64,7 @@
 #include <libdevinfo.h>
 #endif
 
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 #include <netinet6/in6_var.h>
 #endif
 
@@ -86,7 +86,7 @@
 #include <common.h>
 #include <timer.h>
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 /* from /usr/include/linux/ipv6.h */
 
 struct in6_ifreq {
@@ -716,7 +716,7 @@ getifaddr(addr, ifnam, prefix, plen, strong, ignoreflags)
 			continue;
 
 		memcpy(&sin6, ifa->ifa_addr, sysdep_sa_len(ifa->ifa_addr));
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 		if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr)) {
 			sin6.sin6_addr.s6_addr[2] = 0;
 			sin6.sin6_addr.s6_addr[3] = 0;
@@ -742,7 +742,7 @@ getifaddr(addr, ifnam, prefix, plen, strong, ignoreflags)
 				continue;
 		}
 		memcpy(addr, &sin6.sin6_addr, sizeof(sin6.sin6_addr));
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 		if (IN6_IS_ADDR_LINKLOCAL(addr))
 			addr->s6_addr[2] = addr->s6_addr[3] = 0; 
 #endif
@@ -961,7 +961,7 @@ in6_matchflags(addr, ifnam, flags)
 	char *ifnam;
 	int flags;
 {
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 	int s;
 	struct in6_ifreq ifr6;
 
@@ -1115,7 +1115,7 @@ getifhwaddr(const char *ifname, char *buf, u_int16_t *hwtypep, int ppa)
 		(void) snprintf(fname, sizeof (fname), "/dev/%s", ifname);
 	getctl.maxlen = sizeof (getbuf);
 	getctl.buf = (char *)getbuf;
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	if ((fd = open(fname, O_RDWR | O_CLOEXEC)) == -1) {
 #else
 	if ((fd = open(fname, O_RDWR)) == -1) {
@@ -1135,7 +1135,7 @@ getifhwaddr(const char *ifname, char *buf, u_int16_t *hwtypep, int ppa)
 		cp++;
 		dlar.dl_ppa = atoi(cp);
 		*cp = '\0';
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 		if ((fd = open(fname, O_RDWR | O_CLOEXEC)) == -1)
 #else
 		if ((fd = open(fname, O_RDWR)) == -1)
@@ -1232,7 +1232,7 @@ gethwid(buf, len, ifname, hwtypep)
 	u_int16_t *hwtypep;
 {
 	struct ifaddrs *ifa, *ifap;
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 	struct sockaddr_dl *sdl;
 #endif
 #ifdef __linux__
@@ -1270,7 +1270,7 @@ gethwid(buf, len, ifname, hwtypep)
 			continue;
 		if (ifa->ifa_addr == NULL)
 			continue;
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 		if (ifa->ifa_addr->sa_family != AF_LINK)
 			continue;
 
@@ -3257,10 +3257,10 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
 	int pltime;
 	int vltime;
 {
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 	struct in6_aliasreq req;
 #endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	struct in6_ifreq req;
 	struct ifreq ifr;
 #endif
@@ -3274,10 +3274,10 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
 	switch(cmd) {
 	case IFADDRCONF_ADD:
 		cmdstr = "add";
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 		ioctl_cmd = SIOCAIFADDR_IN6;
 #endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 		ioctl_cmd = SIOCSIFADDR;
 #endif
 #ifdef __sun__
@@ -3286,10 +3286,10 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
 		break;
 	case IFADDRCONF_REMOVE:
 		cmdstr = "remove";
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 		ioctl_cmd = SIOCDIFADDR_IN6;
 #endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 		ioctl_cmd = SIOCDIFADDR;
 #endif
 #ifdef __sun__
@@ -3300,7 +3300,7 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
 		return (-1);
 	}
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 #define SOCKTYPE (SOCK_DGRAM | SOCK_CLOEXEC)
 #else
 #define SOCKTYPE SOCK_DGRAM
@@ -3312,7 +3312,7 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
 	}
 
 	memset(&req, 0, sizeof(req));
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 	req.ifra_addr = *addr;
 	memcpy(req.ifra_name, ifname, sizeof(req.ifra_name));
 	(void)sa6_plen2mask(&req.ifra_prefixmask, plen);
diff --git a/config.c b/config.c
index e04d6a5..2c5ad5d 100644
--- a/config.c
+++ b/config.c
@@ -35,7 +35,7 @@
 
 #include <net/if.h>
 #include <netinet/in.h>
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 #include <net/if_dl.h>
 #endif
 #ifdef __linux__
@@ -48,7 +48,7 @@
 #include <string.h>
 #include <ifaddrs.h>
 #include <errno.h>
-#ifdef __linux__
+#ifdef __GLIBC__
 #define __USE_XOPEN
 #include <time.h>
 #endif
@@ -1227,7 +1227,7 @@ get_default_ifid(pif)
 	struct prefix_ifconf *pif;
 {
 	struct ifaddrs *ifa, *ifap;
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 	struct sockaddr_dl *sdl;
 #endif
 #ifdef __linux__
@@ -1254,7 +1254,7 @@ get_default_ifid(pif)
 		if (ifa->ifa_addr == NULL)
 			continue;
 
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 		if (ifa->ifa_addr->sa_family != AF_LINK)
 			continue;
 
diff --git a/configure b/configure
index 4722b7b..8b67abe 100755
--- a/configure
+++ b/configure
@@ -2994,7 +2994,7 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <netinet/in.h>
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
  yes
 #endif
 _ACEOF
diff --git a/configure.in b/configure.in
index 6da9af5..e320956 100644
--- a/configure.in
+++ b/configure.in
@@ -65,7 +65,7 @@ AC_TRY_COMPILE([#include <sys/queue.h>],
 
 AC_EGREP_CPP(yes,
 [#include <netinet/in.h>
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
  yes
 #endif], [result=kame], [result=regular])
 AC_MSG_CHECKING(for getaddrinfo/getnameinfo library)
diff --git a/dhcp6_ctl.c b/dhcp6_ctl.c
index f1bae0b..dc6c323 100644
--- a/dhcp6_ctl.c
+++ b/dhcp6_ctl.c
@@ -97,7 +97,7 @@ dhcp6_ctl_init(addr, port, max, sockp)
 		    gai_strerror(error));
 		return (-1);
 	}
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	res->ai_socktype |= SOCK_CLOEXEC;
 #endif
 	ctlsock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
diff --git a/dhcp6_ctlclient.c b/dhcp6_ctlclient.c
index 2bec3e7..84ede58 100644
--- a/dhcp6_ctlclient.c
+++ b/dhcp6_ctlclient.c
@@ -169,7 +169,7 @@ main(argc, argv)
 
 	s = -1;
 	for (res = res0; res != NULL; res = res->ai_next) {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 		res->ai_socktype |= SOCK_CLOEXEC;
 #endif
 		s = socket(res->ai_family, res->ai_socktype,
diff --git a/dhcp6c.c b/dhcp6c.c
index 1d10a78..4e1356b 100644
--- a/dhcp6c.c
+++ b/dhcp6c.c
@@ -50,7 +50,7 @@
 #endif
 
 #include <netinet/in.h>
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 #include <net/if_dl.h>
 #include <netinet6/in6_var.h>
 #endif
@@ -290,7 +290,7 @@ client6_init()
 		    gai_strerror(error));
 		exit(1);
 	}
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	/* Force socket to be closed on execve */
 	res->ai_socktype |= SOCK_CLOEXEC;
 #endif
@@ -350,7 +350,7 @@ client6_init()
 	freeaddrinfo(res);
 
 	/* open a routing socket to watch the routing table */
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 #define SOCKTYPE (SOCK_RAW | SOCK_CLOEXEC)
 #else
 #define SOCKTYPE SOCK_RAW
diff --git a/dhcp6relay.c b/dhcp6relay.c
index 200d3cb..ed4aee7 100644
--- a/dhcp6relay.c
+++ b/dhcp6relay.c
@@ -41,7 +41,7 @@
 
 #include <netinet/in.h>
 
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 #include <netinet6/in6_var.h>
 #endif
 
@@ -359,7 +359,7 @@ relay6_init(int ifnum, char *iflist[])
 		    gai_strerror(error));
 		goto failexit;
 	}
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	res->ai_socktype |= SOCK_CLOEXEC;
 #endif
 	csock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -468,7 +468,7 @@ relay6_init(int ifnum, char *iflist[])
 		goto failexit;
 	}
 	memcpy(&sa6_client, res->ai_addr, sizeof (sa6_client));
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 	res->ai_socktype |= SOCK_CLOEXEC;
 #endif
 	ssock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
diff --git a/dhcp6s.c b/dhcp6s.c
index ff8b17d..a230d75 100644
--- a/dhcp6s.c
+++ b/dhcp6s.c
@@ -51,7 +51,7 @@
 #endif
 
 #include <netinet/in.h>
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 #include <netinet6/in6_var.h>
 #endif
 
@@ -532,7 +532,7 @@ server6_init()
 		    strerror(errno));
 		exit(1);
 	}
-#if !defined(__linux__) && !defined(__sun__)
+#if !defined(__linux__) && !defined(__sun__) && !defined(__GNU__)
 	/* make the socket write-only */
 	if (shutdown(outsock, 0)) {
 		debug_printf(LOG_ERR, FNAME, "shutdown(outbound, 0): %s",
diff --git a/if.c b/if.c
index c690671..d69e79a 100644
--- a/if.c
+++ b/if.c
@@ -34,7 +34,7 @@
 
 #include <net/if.h>
 #include <netinet/in.h>
-#ifdef __KAME__
+#if defined (__KAME__) || defined (__FreeBSD_kernel__)
 #include <net/if_dl.h>
 #endif
 
diff --git a/missing/getifaddrs.c b/missing/getifaddrs.c
index 23b3e43..42dba27 100644
--- a/missing/getifaddrs.c
+++ b/missing/getifaddrs.c
@@ -167,7 +167,7 @@ getifaddrs(struct ifaddrs **ifap)
 	struct ifaddrs *ifa = NULL;
 	char *buf;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 #define SOCKTYPE (SOCK_DGRAM | SOCK_CLOEXEC)
 #else
 #define SOCKTYPE SOCK_DGRAM