diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/fwtcp.c vbox-trunk\src\VBox\NetworkServices/NAT/fwtcp.c
old
|
new
|
|
29 | 29 | #include <arpa/inet.h> |
30 | 30 | #include <stdio.h> |
31 | 31 | #include <poll.h> |
| 32 | #ifdef RT_OS_OS2 |
| 33 | typedef unsigned long socklen_t; |
| 34 | #endif |
32 | 35 | |
33 | 36 | #include <err.h> /* BSD'ism */ |
34 | 37 | #else |
… |
… |
|
214 | 217 | fwtcp_pmgr_listen(struct pollmgr_handler *handler, SOCKET fd, int revents) |
215 | 218 | { |
216 | 219 | struct fwtcp *fwtcp; |
| 220 | #ifdef IPv6 |
217 | 221 | struct sockaddr_storage ss; |
| 222 | #else |
| 223 | struct sockaddr_in ss; |
| 224 | #endif |
218 | 225 | socklen_t sslen; |
219 | 226 | struct pxtcp *pxtcp; |
220 | 227 | SOCKET newsock; |
… |
… |
|
233 | 240 | LWIP_ASSERT1(sys_mbox_valid(&fwtcp->connmbox)); |
234 | 241 | |
235 | 242 | sslen = sizeof(ss); |
236 | | newsock = accept(fwtcp->sock, (struct sockaddr *)&ss, &sslen); |
| 243 | newsock = accept(fwtcp->sock, (struct sockaddr *)&ss, (int *)&sslen); |
237 | 244 | if (newsock == INVALID_SOCKET) { |
238 | 245 | return POLLIN; |
239 | 246 | } |
240 | 247 | |
241 | 248 | |
| 249 | #ifdef IPv6 |
242 | 250 | if (ss.ss_family == PF_INET) { |
| 251 | #else |
| 252 | if (ss.sin_family == PF_INET) { |
| 253 | #endif |
243 | 254 | struct sockaddr_in *peer4 = (struct sockaddr_in *)&ss; |
244 | 255 | DPRINTF(("<--- TCP %RTnaipv4:%d\n", |
245 | 256 | peer4->sin_addr.s_addr, ntohs(peer4->sin_port))); |
246 | 257 | } |
| 258 | #ifdef IPv6 |
247 | 259 | else { /* PF_INET6 */ |
248 | 260 | struct sockaddr_in6 *peer6 = (struct sockaddr_in6 *)&ss; |
249 | 261 | DPRINTF(("<--- TCP %RTnaipv6:%d\n", |
250 | 262 | &peer6->sin6_addr, ntohs(peer6->sin6_port))); |
251 | 263 | } |
| 264 | #endif |
252 | 265 | |
253 | 266 | pxtcp = pxtcp_create_forwarded(newsock); |
254 | 267 | if (pxtcp == NULL) { |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/fwudp.c vbox-trunk\src\VBox\NetworkServices/NAT/fwudp.c
old
|
new
|
|
29 | 29 | #include <stdio.h> |
30 | 30 | #include <string.h> |
31 | 31 | #include <poll.h> |
| 32 | #ifdef RT_OS_OS2 |
| 33 | typedef unsigned long socklen_t; |
| 34 | #endif |
32 | 35 | |
33 | 36 | #include <err.h> /* BSD'ism */ |
34 | 37 | #else |
… |
… |
|
202 | 205 | fwudp->sock = sock; |
203 | 206 | fwudp->fwspec = *fwspec; /* struct copy */ |
204 | 207 | |
| 208 | #ifdef IPv6 |
205 | 209 | /* XXX */ |
206 | 210 | if (fwspec->sdom == PF_INET) { |
| 211 | #endif |
207 | 212 | struct sockaddr_in *dst4 = &fwspec->dst.sin; |
208 | 213 | memcpy(&fwudp->dst_addr.ip4, &dst4->sin_addr, sizeof(ip_addr_t)); |
209 | 214 | fwudp->dst_port = htons(dst4->sin_port); |
| 215 | #ifdef IPv6 |
210 | 216 | } |
211 | 217 | else { /* PF_INET6 */ |
212 | 218 | struct sockaddr_in6 *dst6 = &fwspec->dst.sin6; |
213 | 219 | memcpy(&fwudp->dst_addr.ip6, &dst6->sin6_addr, sizeof(ip6_addr_t)); |
214 | 220 | fwudp->dst_port = htons(dst6->sin6_port); |
215 | 221 | } |
| 222 | #endif |
216 | 223 | |
217 | 224 | fwudp->inbuf.bufsize = 256; /* elements */ |
218 | 225 | fwudp->inbuf.buf |
… |
… |
|
261 | 268 | fwudp_pmgr_pump(struct pollmgr_handler *handler, SOCKET fd, int revents) |
262 | 269 | { |
263 | 270 | struct fwudp *fwudp; |
| 271 | #ifdef IPv6 |
264 | 272 | struct sockaddr_storage ss; |
| 273 | #else |
| 274 | struct sockaddr_in ss; |
| 275 | #endif |
265 | 276 | socklen_t sslen = sizeof(ss); |
266 | 277 | size_t beg, lim; |
267 | 278 | struct fwudp_dgram *dgram; |
… |
… |
|
279 | 290 | LWIP_UNUSED_ARG(revents); |
280 | 291 | |
281 | 292 | nread = recvfrom(fwudp->sock, pollmgr_udpbuf, sizeof(pollmgr_udpbuf), 0, |
282 | | (struct sockaddr *)&ss, &sslen); |
| 293 | (struct sockaddr *)&ss, (int *)&sslen); |
283 | 294 | if (nread < 0) { |
284 | 295 | DPRINTF(("%s: %R[sockerr]\n", __func__, SOCKERRNO())); |
285 | 296 | return POLLIN; |
… |
… |
|
308 | 319 | return POLLIN; |
309 | 320 | } |
310 | 321 | |
| 322 | #ifdef IPv6 |
311 | 323 | if (ss.ss_family == AF_INET) { |
| 324 | #else |
| 325 | if (ss.sin_family == PF_INET) { |
| 326 | #endif |
312 | 327 | const struct sockaddr_in *peer4 = (const struct sockaddr_in *)&ss; |
313 | 328 | dgram->src_port = htons(peer4->sin_port); |
314 | 329 | } |
| 330 | #ifdef IPv6 |
315 | 331 | else { /* PF_INET6 */ |
316 | 332 | const struct sockaddr_in6 *peer6 = (const struct sockaddr_in6 *)&ss; |
317 | 333 | dgram->src_port = htons(peer6->sin6_port); |
318 | 334 | } |
| 335 | #endif |
319 | 336 | |
320 | 337 | p = pbuf_alloc(PBUF_RAW, nread, PBUF_RAM); |
321 | 338 | if (p == NULL) { |
… |
… |
|
476 | 493 | { |
477 | 494 | union { |
478 | 495 | struct sockaddr_in sin; |
| 496 | #ifdef IPv6 |
479 | 497 | struct sockaddr_in6 sin6; |
| 498 | #endif |
480 | 499 | } peer; |
481 | 500 | socklen_t namelen; |
482 | 501 | |
483 | 502 | memset(&peer, 0, sizeof(peer)); /* XXX: shut up valgrind */ |
484 | 503 | |
| 504 | #ifdef IPv6 |
485 | 505 | if (fwudp->fwspec.sdom == PF_INET) { |
| 506 | #endif |
486 | 507 | peer.sin.sin_family = AF_INET; |
487 | 508 | #if HAVE_SA_LEN |
488 | 509 | peer.sin.sin_len = |
… |
… |
|
490 | 511 | namelen = sizeof(peer.sin); |
491 | 512 | pxremap_outbound_ip4((ip_addr_t *)&peer.sin.sin_addr, &pcb->local_ip.ip4); |
492 | 513 | peer.sin.sin_port = htons(pcb->local_port); |
| 514 | #ifdef IPv6 |
493 | 515 | } |
494 | 516 | else { |
495 | 517 | peer.sin6.sin6_family = AF_INET6; |
… |
… |
|
501 | 523 | pxremap_outbound_ip6((ip6_addr_t *)&peer.sin6.sin6_addr, &pcb->local_ip.ip6); |
502 | 524 | peer.sin6.sin6_port = htons(pcb->local_port); |
503 | 525 | } |
| 526 | #endif |
504 | 527 | |
505 | 528 | proxy_sendto(fwudp->sock, p, &peer, namelen); |
506 | 529 | pbuf_free(p); |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/Makefile.kmk vbox-trunk\src\VBox\NetworkServices/NAT/Makefile.kmk
old
|
new
|
|
44 | 44 | VBoxNetLwipNAT_TEMPLATE = |
45 | 45 | VBoxNetLwipNAT_TEMPLATE := VBOXMAIN$(if-expr defined(VBOX_WITH_HARDENING),DLL,CLIENTEXE) |
46 | 46 | VBoxNetLwipNAT_NAME = VBoxNetNAT |
47 | | VBoxNetLwipNAT_DEFS += ${LWIP_DEFS} IPv6 |
| 47 | VBoxNetLwipNAT_DEFS += ${LWIP_DEFS} |
| 48 | ifn1of ($(KBUILD_TARGET), os2) |
| 49 | VBoxNetLwipNAT_DEFS += IPv6 |
| 50 | endif |
48 | 51 | # VBoxNetLwipNAT_DEFS.linux += WITH_VALGRIND # instrument lwip memp.c |
49 | 52 | VBoxNetLwipNAT_DEFS.win += VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP |
50 | 53 | VBoxNetLwipNAT_SOURCES += VBoxNetLwipNAT.cpp \ |
… |
… |
|
58 | 61 | VBoxNetLwipNAT_LIBS = \ |
59 | 62 | $(LIB_RUNTIME) |
60 | 63 | VBoxNetLwipNAT_LIBS.solaris += socket nsl |
| 64 | VBoxNetLwipNAT_LIBS.os2 += socket \ |
| 65 | $(PATH_STAGE_LIB)/VBox-os2-poll$(VBOX_SUFF_LIB) |
| 66 | VBoxNetLwipNAT_INCS.os2 += $(PATH_SUB_CURRENT)/src/libs/poll-os2 |
61 | 67 | VBoxNetLwipNAT_LDFLAGS.win = /SUBSYSTEM:windows |
62 | 68 | |
63 | 69 | # Convince Solaris headers to expose socket stuff we need. |
… |
… |
|
98 | 104 | fwtcp.c \ |
99 | 105 | fwudp.c \ |
100 | 106 | portfwd.c \ |
101 | | proxy_dhcp6ds.c \ |
102 | 107 | proxy_tftpd.c |
103 | 108 | |
| 109 | ifn1of ($(KBUILD_TARGET),os2) |
| 110 | VBoxNetLwipNAT_SOURCES += \ |
| 111 | proxy_dhcp6ds.c |
| 112 | endif |
| 113 | |
104 | 114 | ifeq ($(KBUILD_TARGET),win) |
105 | 115 | # unprivileged Icmp API |
106 | 116 | VBoxNetLwipNAT_SOURCES += pxping_win.c |
… |
… |
|
121 | 131 | VBoxNetLwipNAT_SOURCES.freebsd += rtmon_bsd.c |
122 | 132 | VBoxNetLwipNAT_SOURCES.linux += rtmon_linux.c |
123 | 133 | VBoxNetLwipNAT_SOURCES.solaris += rtmon_bsd.c |
| 134 | VBoxNetLwipNAT_SOURCES.os2 += rtmon_win.c |
124 | 135 | VBoxNetLwipNAT_SOURCES.win += rtmon_win.c |
125 | 136 | |
126 | 137 | VBoxNetLwipNAT_SOURCES.win += \ |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/portfwd.c vbox-trunk\src\VBox\NetworkServices/NAT/portfwd.c
old
|
new
|
|
149 | 149 | const char *src_addr_str, uint16_t src_port, |
150 | 150 | const char *dst_addr_str, uint16_t dst_port) |
151 | 151 | { |
| 152 | #ifdef IPv6 |
152 | 153 | struct addrinfo hints; |
153 | 154 | struct addrinfo *ai; |
| 155 | #endif |
154 | 156 | int status; |
155 | 157 | |
| 158 | #ifdef IPv6 |
156 | 159 | LWIP_ASSERT1(sdom == PF_INET || sdom == PF_INET6); |
| 160 | #else |
| 161 | LWIP_ASSERT1(sdom == PF_INET); |
| 162 | #endif |
157 | 163 | LWIP_ASSERT1(stype == SOCK_STREAM || stype == SOCK_DGRAM); |
158 | 164 | |
159 | 165 | fwspec->sdom = sdom; |
160 | 166 | fwspec->stype = stype; |
161 | 167 | |
| 168 | #ifdef IPv6 |
162 | 169 | memset(&hints, 0, sizeof(hints)); |
163 | 170 | hints.ai_family = (sdom == PF_INET) ? AF_INET : AF_INET6; |
164 | 171 | hints.ai_socktype = stype; |
… |
… |
|
185 | 192 | memcpy(&fwspec->dst, ai->ai_addr, ai->ai_addrlen); |
186 | 193 | freeaddrinfo(ai); |
187 | 194 | ai = NULL; |
| 195 | #else |
| 196 | struct hostent *he = gethostbyname(src_addr_str); |
| 197 | |
| 198 | if (he == NULL) { |
| 199 | LogRel(("\"%s\": %s\n", src_addr_str, hstrerror(h_errno))); |
| 200 | return -1; |
| 201 | } |
| 202 | LWIP_ASSERT1(he != NULL); |
| 203 | LWIP_ASSERT1(he->h_length <= sizeof(fwspec->src)); |
| 204 | memcpy(&fwspec->src, he->h_addr_list, he->h_length); |
| 205 | free(he); |
| 206 | he = NULL; |
| 207 | #endif |
188 | 208 | |
189 | 209 | if (sdom == PF_INET) { |
190 | 210 | fwspec->src.sin.sin_port = htons(src_port); |
191 | 211 | fwspec->dst.sin.sin_port = htons(dst_port); |
192 | 212 | } |
| 213 | #ifdef IPv6 |
193 | 214 | else { /* PF_INET6 */ |
194 | 215 | fwspec->src.sin6.sin6_port = htons(src_port); |
195 | 216 | fwspec->dst.sin6.sin6_port = htons(dst_port); |
196 | 217 | } |
| 218 | #endif |
197 | 219 | |
198 | 220 | return 0; |
199 | 221 | } |
… |
… |
|
215 | 237 | && a->src.sin.sin_addr.s_addr == b->src.sin.sin_addr.s_addr |
216 | 238 | && a->dst.sin.sin_addr.s_addr == b->dst.sin.sin_addr.s_addr; |
217 | 239 | } |
| 240 | #ifdef IPv6 |
218 | 241 | else { /* PF_INET6 */ |
219 | 242 | return a->src.sin6.sin6_port == b->src.sin6.sin6_port |
220 | 243 | && a->dst.sin6.sin6_port == b->dst.sin6.sin6_port |
221 | 244 | && IN6_ARE_ADDR_EQUAL(&a->src.sin6.sin6_addr, &b->src.sin6.sin6_addr) |
222 | 245 | && IN6_ARE_ADDR_EQUAL(&a->dst.sin6.sin6_addr, &b->dst.sin6.sin6_addr); |
223 | 246 | } |
| 247 | #endif |
224 | 248 | } |
225 | 249 | |
226 | 250 | |
… |
… |
|
247 | 271 | peerip4.addr = peer4->sin_addr.s_addr; |
248 | 272 | mapping = pxremap_inbound_ip4(&fwdsrc->ip4, &peerip4); |
249 | 273 | } |
| 274 | #ifdef IPv6 |
250 | 275 | else if (peer->sa_family == AF_INET6) { |
251 | 276 | const struct sockaddr_in6 *peer6 = (const struct sockaddr_in6 *)peer; |
252 | 277 | ip6_addr_t peerip6; |
… |
… |
|
254 | 279 | memcpy(&peerip6, &peer6->sin6_addr, sizeof(ip6_addr_t)); |
255 | 280 | mapping = pxremap_inbound_ip6(&fwdsrc->ip6, &peerip6); |
256 | 281 | } |
| 282 | #endif |
257 | 283 | else { |
258 | 284 | mapping = PXREMAP_FAILED; |
259 | 285 | } |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/portfwd.h vbox-trunk\src\VBox\NetworkServices/NAT/portfwd.h
old
|
new
|
|
35 | 35 | union { |
36 | 36 | struct sockaddr sa; |
37 | 37 | struct sockaddr_in sin; /* sdom == PF_INET */ |
| 38 | #ifdef IPv6 |
38 | 39 | struct sockaddr_in6 sin6; /* sdom == PF_INET6 */ |
| 40 | #endif |
39 | 41 | } src; |
40 | 42 | |
41 | 43 | /* forward to */ |
42 | 44 | union { |
43 | 45 | struct sockaddr sa; |
44 | 46 | struct sockaddr_in sin; /* sdom == PF_INET */ |
| 47 | #ifdef IPv6 |
45 | 48 | struct sockaddr_in6 sin6; /* sdom == PF_INET6 */ |
| 49 | #endif |
46 | 50 | } dst; |
47 | 51 | }; |
48 | 52 | |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/proxy_pollmgr.c vbox-trunk\src\VBox\NetworkServices/NAT/proxy_pollmgr.c
old
|
new
|
|
28 | 28 | #include <err.h> |
29 | 29 | #include <errno.h> |
30 | 30 | #include <poll.h> |
| 31 | #ifdef RT_OS_OS2 |
| 32 | typedef unsigned long nfds_t; |
| 33 | #endif |
31 | 34 | #include <stdio.h> |
32 | 35 | #include <stdlib.h> |
33 | 36 | #include <string.h> |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/proxy.c vbox-trunk\src\VBox\NetworkServices/NAT/proxy.c
old
|
new
|
|
30 | 30 | |
31 | 31 | #ifndef RT_OS_WINDOWS |
32 | 32 | #include <sys/poll.h> |
| 33 | #ifdef RT_OS_OS2 |
| 34 | typedef unsigned long socklen_t; |
| 35 | #endif |
33 | 36 | #include <sys/socket.h> |
34 | 37 | #include <netinet/in.h> |
35 | 38 | #include <arpa/inet.h> |
… |
… |
|
407 | 410 | proxy_connected_socket(int sdom, int stype, |
408 | 411 | ipX_addr_t *dst_addr, u16_t dst_port) |
409 | 412 | { |
| 413 | #ifdef IPv6 |
410 | 414 | struct sockaddr_in6 dst_sin6; |
| 415 | #endif |
411 | 416 | struct sockaddr_in dst_sin; |
412 | 417 | struct sockaddr *pdst_sa; |
413 | 418 | socklen_t dst_sa_len; |
… |
… |
|
422 | 427 | LWIP_ASSERT1(stype == SOCK_STREAM || stype == SOCK_DGRAM); |
423 | 428 | |
424 | 429 | DPRINTF(("---> %s ", stype == SOCK_STREAM ? "TCP" : "UDP")); |
| 430 | #ifdef IPv6 |
425 | 431 | if (sdom == PF_INET6) { |
426 | 432 | pdst_sa = (struct sockaddr *)&dst_sin6; |
427 | 433 | pdst_addr = (void *)&dst_sin6.sin6_addr; |
… |
… |
|
438 | 444 | DPRINTF(("[%RTnaipv6]:%d ", &dst_sin6.sin6_addr, dst_port)); |
439 | 445 | } |
440 | 446 | else { /* sdom = PF_INET */ |
| 447 | #else |
| 448 | { |
| 449 | #endif |
441 | 450 | pdst_sa = (struct sockaddr *)&dst_sin; |
442 | 451 | pdst_addr = (void *)&dst_sin.sin_addr; |
443 | 452 | |
… |
… |
|
460 | 469 | DPRINTF(("socket %d\n", s)); |
461 | 470 | |
462 | 471 | /* TODO: needs locking if dynamic modifyvm is allowed */ |
| 472 | #ifdef IPv6 |
463 | 473 | if (sdom == PF_INET6) { |
464 | 474 | psrc_sa = (const struct sockaddr *)g_proxy_options->src6; |
465 | 475 | src_sa_len = sizeof(struct sockaddr_in6); |
466 | 476 | } |
467 | 477 | else { |
| 478 | #else |
| 479 | { |
| 480 | #endif |
468 | 481 | psrc_sa = (const struct sockaddr *)g_proxy_options->src4; |
469 | 482 | src_sa_len = sizeof(struct sockaddr_in); |
470 | 483 | } |
… |
… |
|
532 | 545 | } |
533 | 546 | |
534 | 547 | status = bind(s, src_addr, |
| 548 | #ifdef IPv6 |
535 | 549 | sdom == PF_INET ? |
536 | 550 | sizeof(struct sockaddr_in) |
537 | 551 | : sizeof(struct sockaddr_in6)); |
| 552 | #else |
| 553 | sizeof(struct sockaddr_in)); |
| 554 | #endif |
538 | 555 | if (status == SOCKET_ERROR) { |
539 | 556 | sockerr = SOCKERRNO(); |
540 | 557 | DPRINTF(("bind: %R[sockerr]\n", sockerr)); |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/pxdns.c vbox-trunk\src\VBox\NetworkServices/NAT/pxdns.c
old
|
new
|
|
49 | 49 | |
50 | 50 | #ifndef RT_OS_WINDOWS |
51 | 51 | #include <sys/poll.h> |
| 52 | #ifdef RT_OS_OS2 |
| 53 | typedef unsigned long socklen_t; |
| 54 | #endif |
52 | 55 | #include <sys/socket.h> |
53 | 56 | #include <netinet/in.h> |
54 | 57 | #include <netdb.h> |
… |
… |
|
63 | 66 | union sockaddr_inet { |
64 | 67 | struct sockaddr sa; |
65 | 68 | struct sockaddr_in sin; |
| 69 | #ifdef IPv6 |
66 | 70 | struct sockaddr_in6 sin6; |
| 71 | #endif |
67 | 72 | }; |
68 | 73 | |
69 | 74 | |
… |
… |
|
312 | 317 | static void |
313 | 318 | pxdns_create_resolver_sockaddrs(struct pxdns *pxdns, const char **nameservers) |
314 | 319 | { |
| 320 | #ifdef IPv6 |
315 | 321 | struct addrinfo hints; |
| 322 | #endif |
316 | 323 | union sockaddr_inet *resolvers; |
317 | 324 | size_t nnames, nresolvers; |
318 | 325 | const char **p; |
… |
… |
|
340 | 347 | goto update_resolvers; |
341 | 348 | } |
342 | 349 | |
| 350 | #ifdef IPv6 |
343 | 351 | memset(&hints, 0, sizeof(hints)); |
344 | 352 | hints.ai_family = AF_UNSPEC; |
345 | 353 | hints.ai_socktype = SOCK_DGRAM; |
… |
… |
|
377 | 385 | ++nresolvers; |
378 | 386 | } |
379 | 387 | |
| 388 | #else |
| 389 | for (p = nameservers; *p; ++p) { |
| 390 | const char *name = *p; |
| 391 | struct hostent *he = gethostbyname(name); |
| 392 | |
| 393 | if (he == NULL) { |
| 394 | /* failed resolution */ |
| 395 | continue; |
| 396 | } |
| 397 | |
| 398 | if (he->h_addrtype != AF_INET) { |
| 399 | /* not AF_INET addr type */ |
| 400 | free(he); |
| 401 | continue; |
| 402 | } |
| 403 | |
| 404 | if (he->h_length > sizeof(struct sockaddr_in)) { |
| 405 | /* IPv6 or other non-IPv4 addr length */ |
| 406 | free(he); |
| 407 | continue; |
| 408 | } |
| 409 | |
| 410 | memcpy(&resolvers[nresolvers], he->h_addr_list, he->h_length); |
| 411 | free(he); |
| 412 | ++nresolvers; |
| 413 | } |
| 414 | #endif |
380 | 415 | if (nresolvers == 0) { |
381 | 416 | if (resolvers != NULL) { |
382 | 417 | free(resolvers); |
… |
… |
|
698 | 733 | &resolver->sa, sizeof(resolver->sin)); |
699 | 734 | |
700 | 735 | } |
| 736 | #ifdef IPv6 |
701 | 737 | else if (resolver->sa.sa_family == AF_INET6) { |
702 | 738 | if (pxdns->sock6 != INVALID_SOCKET) { |
703 | 739 | nsent = sendto(pxdns->sock6, req->data, req->size, 0, |
… |
… |
|
708 | 744 | return 0; |
709 | 745 | } |
710 | 746 | } |
| 747 | #endif |
711 | 748 | else { |
712 | 749 | /* shouldn't happen, we should have weeded out unsupported families */ |
713 | 750 | return 0; |
… |
… |
|
782 | 819 | int status; |
783 | 820 | |
784 | 821 | status = getsockopt(fd, SOL_SOCKET, |
785 | | SO_ERROR, (char *)&sockerr, &optlen); |
| 822 | SO_ERROR, (char *)&sockerr, (int *)&optlen); |
786 | 823 | if (status < 0) { |
787 | 824 | DPRINTF(("%s: sock %d: SO_ERROR failed: %R[sockerr]\n", |
788 | 825 | __func__, fd, SOCKERRNO())); |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/pxping.c vbox-trunk\src\VBox\NetworkServices/NAT/pxping.c
old
|
new
|
|
32 | 32 | #endif |
33 | 33 | #include <netinet/in.h> |
34 | 34 | #include <poll.h> |
| 35 | #ifdef RT_OS_OS2 |
| 36 | typedef unsigned long socklen_t; |
| 37 | #endif |
35 | 38 | #include <stdint.h> |
36 | 39 | #include <stdio.h> |
37 | 40 | #include <stdlib.h> |
… |
… |
|
85 | 88 | struct pxping { |
86 | 89 | SOCKET sock4; |
87 | 90 | |
88 | | #if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) |
| 91 | #if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_OS2) |
89 | 92 | # define DF_WITH_IP_HDRINCL |
90 | 93 | int hdrincl; |
91 | 94 | #else |
… |
… |
|
159 | 162 | |
160 | 163 | union { |
161 | 164 | struct sockaddr_in sin; |
| 165 | #ifdef IPv6 |
162 | 166 | struct sockaddr_in6 sin6; |
| 167 | #endif |
163 | 168 | } peer; |
164 | 169 | }; |
165 | 170 | |
… |
… |
|
197 | 202 | static int pxping_init_windows(struct pxping *pxping); |
198 | 203 | #endif |
199 | 204 | static void pxping_recv4(void *arg, struct pbuf *p); |
| 205 | #ifdef IPv6 |
200 | 206 | static void pxping_recv6(void *arg, struct pbuf *p); |
| 207 | #endif |
201 | 208 | |
202 | 209 | static void pxping_timer(void *arg); |
203 | 210 | static void pxping_timer_needed(struct pxping *pxping); |
… |
… |
|
224 | 231 | u16_t iplen, struct sockaddr_in *peer); |
225 | 232 | static void pxping_pmgr_icmp4_error(struct pxping *pxping, |
226 | 233 | u16_t iplen, struct sockaddr_in *peer); |
| 234 | #ifdef IPv6 |
227 | 235 | static void pxping_pmgr_icmp6(struct pxping *pxping); |
228 | 236 | static void pxping_pmgr_icmp6_echo(struct pxping *pxping, |
229 | 237 | ip6_addr_t *src, ip6_addr_t *dst, |
… |
… |
|
232 | 240 | ip6_addr_t *src, ip6_addr_t *dst, |
233 | 241 | int hopl, int tclass, u16_t icmplen); |
234 | 242 | |
| 243 | #endif |
235 | 244 | static void pxping_pmgr_forward_inbound(struct pxping *pxping, u16_t iplen); |
236 | 245 | static void pxping_pcb_forward_inbound(void *arg); |
237 | 246 | |
| 247 | #ifdef IPv6 |
238 | 248 | static void pxping_pmgr_forward_inbound6(struct pxping *pxping, |
239 | 249 | ip6_addr_t *src, ip6_addr_t *dst, |
240 | 250 | u8_t hopl, u8_t tclass, |
241 | 251 | u16_t icmplen); |
242 | 252 | static void pxping_pcb_forward_inbound6(void *arg); |
243 | 253 | |
| 254 | #endif |
244 | 255 | /* |
245 | 256 | * NB: This is not documented except in RTFS. |
246 | 257 | * |
… |
… |
|
300 | 311 | ping_proxy_accept(pxping_recv4, &g_pxping); |
301 | 312 | } |
302 | 313 | |
| 314 | #ifdef IPv6 |
303 | 315 | g_pxping.sock6 = sock6; |
304 | 316 | #ifdef RT_OS_WINDOWS |
305 | 317 | /* we need recvmsg */ |
… |
… |
|
344 | 356 | |
345 | 357 | ping6_proxy_accept(pxping_recv6, &g_pxping); |
346 | 358 | } |
| 359 | #endif |
347 | 360 | |
348 | 361 | status = RTStrFormatTypeRegister("ping_pcb", pxping_pcb_rtstrfmt, NULL); |
349 | 362 | AssertRC(status); |
… |
… |
|
663 | 676 | } |
664 | 677 | |
665 | 678 | |
| 679 | #ifdef IPv6 |
666 | 680 | /** |
667 | 681 | * ICMPv6 Echo Request in pbuf "p" is to be proxied. |
668 | 682 | */ |
… |
… |
|
768 | 782 | pbuf_free(p); |
769 | 783 | } |
770 | 784 | |
| 785 | #endif |
771 | 786 | |
772 | 787 | /** |
773 | 788 | * Formatter for %R[ping_pcb]. |
… |
… |
|
792 | 807 | return RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL, "(null)"); |
793 | 808 | } |
794 | 809 | |
| 810 | #ifdef IPv6 |
795 | 811 | /* XXX: %RTnaipv4 takes the value, but %RTnaipv6 takes the pointer */ |
796 | 812 | if (pcb->is_ipv6) { |
797 | 813 | cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL, |
… |
… |
|
802 | 818 | } |
803 | 819 | } |
804 | 820 | else { |
| 821 | #else |
| 822 | { |
| 823 | #endif |
805 | 824 | cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL, |
806 | 825 | "%RTnaipv4 -> %RTnaipv4", |
807 | 826 | ip4_addr_get_u32(ipX_2_ip(&pcb->src)), |
… |
… |
|
949 | 968 | pcb->pprev_timeout = NULL; |
950 | 969 | pcb->next_timeout = NULL; |
951 | 970 | |
| 971 | #ifdef IPv6 |
952 | 972 | if (is_ipv6) { |
953 | 973 | pcb->peer.sin6.sin6_family = AF_INET6; |
954 | 974 | #if HAVE_SA_LEN |
… |
… |
|
960 | 980 | ipX_2_ip6(&pcb->dst)); |
961 | 981 | } |
962 | 982 | else { |
| 983 | #else |
| 984 | { |
| 985 | #endif |
963 | 986 | pcb->peer.sin.sin_family = AF_INET; |
964 | 987 | #if HAVE_SA_LEN |
965 | 988 | pcb->peer.sin.sin_len = sizeof(pcb->peer.sin); |
… |
… |
|
1100 | 1123 | int status; |
1101 | 1124 | |
1102 | 1125 | status = getsockopt(fd, SOL_SOCKET, |
1103 | | SO_ERROR, (char *)&sockerr, &optlen); |
| 1126 | SO_ERROR, (char *)&sockerr, (int *)&optlen); |
1104 | 1127 | if (status < 0) { |
1105 | 1128 | DPRINTF(("%s: sock %d: SO_ERROR failed: %R[sockerr]\n", |
1106 | 1129 | __func__, fd, SOCKERRNO())); |
… |
… |
|
1118 | 1141 | if (fd == pxping->sock4) { |
1119 | 1142 | pxping_pmgr_icmp4(pxping); |
1120 | 1143 | } |
| 1144 | #ifdef IPv6 |
1121 | 1145 | else /* fd == pxping->sock6 */ { |
1122 | 1146 | pxping_pmgr_icmp6(pxping); |
1123 | 1147 | } |
1124 | 1148 | |
| 1149 | #endif |
1125 | 1150 | return POLLIN; |
1126 | 1151 | } |
1127 | 1152 | |
… |
… |
|
1493 | 1518 | } |
1494 | 1519 | |
1495 | 1520 | |
| 1521 | #ifdef IPv6 |
1496 | 1522 | /** |
1497 | 1523 | * Process incoming ICMPv6 message for the host. |
1498 | 1524 | * NB: we will get a lot of spam here and have to sift through it. |
… |
… |
|
1858 | 1884 | hopl, tclass, icmplen); |
1859 | 1885 | } |
1860 | 1886 | |
| 1887 | #endif |
1861 | 1888 | |
1862 | 1889 | /** |
1863 | 1890 | * Hand off ICMP datagram to the lwip thread where it will be |
… |
… |
|
1927 | 1954 | } |
1928 | 1955 | |
1929 | 1956 | |
| 1957 | #ifdef IPv6 |
1930 | 1958 | static void |
1931 | 1959 | pxping_pmgr_forward_inbound6(struct pxping *pxping, |
1932 | 1960 | ip6_addr_t *src, ip6_addr_t *dst, |
… |
… |
|
1995 | 2023 | pbuf_free(msg->p); |
1996 | 2024 | free(msg); |
1997 | 2025 | } |
| 2026 | #endif |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/pxtcp.c vbox-trunk\src\VBox\NetworkServices/NAT/pxtcp.c
old
|
new
|
|
38 | 38 | #include <stdio.h> |
39 | 39 | #include <string.h> |
40 | 40 | #include <poll.h> |
| 41 | #ifdef RT_OS_OS2 |
| 42 | # define SHUT_RD SO_RCV_SHUTDOWN |
| 43 | # define SHUT_WR SO_SND_SHUTDOWN |
| 44 | # define SHUT_RDWR (SO_RCV_SHUTDOWN | SO_SND_SHUTDOWN) |
| 45 | typedef unsigned long nfds_t; |
| 46 | typedef unsigned long socklen_t; |
| 47 | #endif |
41 | 48 | |
42 | 49 | #include <err.h> /* BSD'ism */ |
43 | 50 | #else |
… |
… |
|
1133 | 1140 | SOCKET s; |
1134 | 1141 | |
1135 | 1142 | status = getsockopt(pxtcp->sock, SOL_SOCKET, SO_ERROR, |
1136 | | (char *)&pxtcp->sockerr, &optlen); |
| 1143 | (char *)&pxtcp->sockerr, (int *)&optlen); |
1137 | 1144 | if (RT_UNLIKELY(status == SOCKET_ERROR)) { /* should not happen */ |
1138 | 1145 | DPRINTF(("%s: sock %d: SO_ERROR failed: %R[sockerr]\n", |
1139 | 1146 | __func__, fd, SOCKERRNO())); |
… |
… |
|
1245 | 1252 | void |
1246 | 1253 | pxtcp_pcb_connect(struct pxtcp *pxtcp, const struct fwspec *fwspec) |
1247 | 1254 | { |
| 1255 | #ifdef IPv6 |
1248 | 1256 | struct sockaddr_storage ss; |
| 1257 | #else |
| 1258 | struct sockaddr_in ss; |
| 1259 | #endif |
1249 | 1260 | socklen_t sslen; |
1250 | | struct tcp_pcb *pcb; |
| 1261 | struct tcp_pcb *pcb = NULL; |
1251 | 1262 | ipX_addr_t src_addr, dst_addr; |
1252 | 1263 | u16_t src_port, dst_port; |
1253 | 1264 | int status; |
… |
… |
|
1266 | 1277 | pxtcp_pcb_associate(pxtcp, pcb); |
1267 | 1278 | |
1268 | 1279 | sslen = sizeof(ss); |
1269 | | status = getpeername(pxtcp->sock, (struct sockaddr *)&ss, &sslen); |
| 1280 | status = getpeername(pxtcp->sock, (struct sockaddr *)&ss, (int *)&sslen); |
1270 | 1281 | if (status == SOCKET_ERROR) { |
1271 | 1282 | goto reset; |
1272 | 1283 | } |
… |
… |
|
1279 | 1290 | goto reset; |
1280 | 1291 | } |
1281 | 1292 | |
| 1293 | #ifdef IPv6 |
1282 | 1294 | if (ss.ss_family == PF_INET) { |
| 1295 | #else |
| 1296 | if (ss.sin_family == PF_INET) { |
| 1297 | #endif |
1283 | 1298 | const struct sockaddr_in *peer4 = (const struct sockaddr_in *)&ss; |
1284 | 1299 | |
1285 | 1300 | src_port = peer4->sin_port; |
… |
… |
|
1287 | 1302 | memcpy(&dst_addr.ip4, &fwspec->dst.sin.sin_addr, sizeof(ip_addr_t)); |
1288 | 1303 | dst_port = fwspec->dst.sin.sin_port; |
1289 | 1304 | } |
| 1305 | #ifdef IPv6 |
1290 | 1306 | else { /* PF_INET6 */ |
1291 | 1307 | const struct sockaddr_in6 *peer6 = (const struct sockaddr_in6 *)&ss; |
1292 | 1308 | ip_set_v6(pcb, 1); |
… |
… |
|
1297 | 1313 | dst_port = fwspec->dst.sin6.sin6_port; |
1298 | 1314 | } |
1299 | 1315 | |
| 1316 | #endif |
1300 | 1317 | /* lwip port arguments are in host order */ |
1301 | 1318 | src_port = ntohs(src_port); |
1302 | 1319 | dst_port = ntohs(dst_port); |
… |
… |
|
1687 | 1704 | socklen_t optlen = (socklen_t)sizeof(sockerr); |
1688 | 1705 | |
1689 | 1706 | status = getsockopt(pxtcp->sock, SOL_SOCKET, SO_ERROR, |
1690 | | (char *)&sockerr, &optlen); |
| 1707 | (char *)&sockerr, (int *)&optlen); |
1691 | 1708 | if (status == SOCKET_ERROR) { /* should not happen */ |
1692 | 1709 | DPRINTF(("sock %d: SO_ERROR failed: %R[sockerr]\n", |
1693 | 1710 | fd, SOCKERRNO())); |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/pxudp.c vbox-trunk\src\VBox\NetworkServices/NAT/pxudp.c
old
|
new
|
|
33 | 33 | #include <stdint.h> |
34 | 34 | #include <stdio.h> |
35 | 35 | #include <poll.h> |
| 36 | #ifdef RT_OS_OS2 |
| 37 | typedef unsigned long socklen_t; |
| 38 | #endif |
36 | 39 | |
37 | 40 | #include <err.h> /* BSD'ism */ |
38 | 41 | #else |
… |
… |
|
657 | 660 | } |
658 | 661 | } |
659 | 662 | } |
| 663 | #ifdef IPv6 |
660 | 664 | else { /* IPv6 */ |
661 | 665 | const struct ip6_hdr *iph = ip6_current_header(); |
662 | 666 | int ttl; |
… |
… |
|
679 | 683 | } |
680 | 684 | } |
681 | 685 | |
| 686 | #endif |
682 | 687 | if (pxudp->pcb->local_port == 53) { |
683 | 688 | ++pxudp->count; |
684 | 689 | } |
… |
… |
|
743 | 748 | int status; |
744 | 749 | |
745 | 750 | status = getsockopt(pxudp->sock, SOL_SOCKET, |
746 | | SO_ERROR, (char *)&sockerr, &optlen); |
| 751 | SO_ERROR, (char *)&sockerr, (int *)&optlen); |
747 | 752 | if (status < 0) { |
748 | 753 | DPRINTF(("%s: sock %d: SO_ERROR failed:%R[sockerr]\n", |
749 | 754 | __func__, pxudp->sock, SOCKERRNO())); |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NAT/VBoxNetLwipNAT.cpp vbox-trunk\src\VBox\NetworkServices/NAT/VBoxNetLwipNAT.cpp
old
|
new
|
|
68 | 68 | # ifdef RT_OS_LINUX |
69 | 69 | # include <linux/icmp.h> /* ICMP_FILTER */ |
70 | 70 | # endif |
| 71 | # ifdef IPv6 |
71 | 72 | # include <netinet/icmp6.h> |
| 73 | # endif |
72 | 74 | #endif |
73 | 75 | |
74 | 76 | #include <map> |
… |
… |
|
153 | 155 | private: |
154 | 156 | struct proxy_options m_ProxyOptions; |
155 | 157 | struct sockaddr_in m_src4; |
| 158 | #ifdef IPv6 |
156 | 159 | struct sockaddr_in6 m_src6; |
| 160 | #endif |
157 | 161 | /** |
158 | 162 | * place for registered local interfaces. |
159 | 163 | */ |
… |
… |
|
646 | 650 | m_ProxyOptions.icmpsock6 = icmpsock6; |
647 | 651 | m_ProxyOptions.tftp_root = NULL; |
648 | 652 | m_ProxyOptions.src4 = NULL; |
649 | | m_ProxyOptions.src6 = NULL; |
650 | 653 | RT_ZERO(m_src4); |
651 | | RT_ZERO(m_src6); |
652 | 654 | m_src4.sin_family = AF_INET; |
| 655 | #ifdef IPv6 |
| 656 | m_ProxyOptions.src6 = NULL; |
| 657 | RT_ZERO(m_src6); |
653 | 658 | m_src6.sin6_family = AF_INET6; |
| 659 | #endif |
654 | 660 | #if HAVE_SA_LEN |
655 | 661 | m_src4.sin_len = sizeof(m_src4); |
| 662 | #ifdef IPv6 |
656 | 663 | m_src6.sin6_len = sizeof(m_src6); |
657 | 664 | #endif |
| 665 | #endif |
658 | 666 | m_ProxyOptions.nameservers = NULL; |
659 | 667 | |
660 | 668 | m_LwipNetIf.name[0] = 'N'; |
… |
… |
|
1085 | 1093 | |
1086 | 1094 | SOCKET icmpsock4 = INVALID_SOCKET; |
1087 | 1095 | SOCKET icmpsock6 = INVALID_SOCKET; |
1088 | | #ifndef RT_OS_DARWIN |
| 1096 | #if !defined(RT_OS_DARWIN) && !defined(RT_OS_OS2) |
1089 | 1097 | const int icmpstype = SOCK_RAW; |
1090 | 1098 | #else |
1091 | 1099 | /* on OS X it's not privileged */ |
… |
… |
|
1121 | 1129 | #endif |
1122 | 1130 | } |
1123 | 1131 | |
| 1132 | #ifdef IPv6 |
1124 | 1133 | icmpsock6 = socket(AF_INET6, icmpstype, IPPROTO_ICMPV6); |
1125 | 1134 | if (icmpsock6 == INVALID_SOCKET) |
1126 | 1135 | { |
… |
… |
|
1155 | 1164 | } |
1156 | 1165 | #endif |
1157 | 1166 | } |
| 1167 | #endif |
1158 | 1168 | |
1159 | 1169 | HRESULT hrc = com::Initialize(); |
1160 | 1170 | if (FAILED(hrc)) |
… |
… |
|
1291 | 1301 | { |
1292 | 1302 | HRESULT hrc; |
1293 | 1303 | com::SafeArray<BSTR> rules; |
| 1304 | #ifdef IPv6 |
1294 | 1305 | if (fIsIPv6) |
1295 | 1306 | hrc = nat->COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(rules)); |
1296 | 1307 | else |
| 1308 | #endif |
1297 | 1309 | hrc = nat->COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(rules)); |
1298 | 1310 | AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); |
1299 | 1311 | |
diff -urN vbox-trunk-bk\src\VBox\NetworkServices/NetLib/VBoxPortForwardString.h vbox-trunk\src\VBox\NetworkServices/NetLib/VBoxPortForwardString.h
old
|
new
|
|
23 | 23 | |
24 | 24 | RT_C_DECLS_BEGIN |
25 | 25 | |
| 26 | #ifdef RT_OS_OS2 |
| 27 | #include <netinet/in.h> |
| 28 | #define INET6_ADDRSTRLEN 65 |
| 29 | #endif |
| 30 | |
26 | 31 | #define PF_NAMELEN 64 |
27 | 32 | /* |
28 | 33 | * TBD: Here is shared implementation of parsing port-forward string |