VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp@ 49119

Last change on this file since 49119 was 49119, checked in by vboxsync, 12 years ago

VBoxNetNAT: drops Windows's limitation on registering listeners.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.2 KB
Line 
1/* $Id: VBoxNetLwipNAT.cpp 49119 2013-10-15 15:05:37Z vboxsync $ */
2/** @file
3 * VBoxNetNAT - NAT Service for connecting to IntNet.
4 */
5
6/*
7 * Copyright (C) 2009 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "winutils.h"
19
20#include <VBox/com/com.h>
21#include <VBox/com/listeners.h>
22#include <VBox/com/string.h>
23#include <VBox/com/Guid.h>
24#include <VBox/com/array.h>
25#include <VBox/com/ErrorInfo.h>
26#include <VBox/com/errorprint.h>
27#include <VBox/com/VirtualBox.h>
28#include <VBox/com/NativeEventQueue.h>
29
30#include <iprt/net.h>
31#include <iprt/initterm.h>
32#include <iprt/alloca.h>
33#ifndef RT_OS_WINDOWS
34# include <arpa/inet.h>
35#endif
36#include <iprt/err.h>
37#include <iprt/time.h>
38#include <iprt/timer.h>
39#include <iprt/thread.h>
40#include <iprt/stream.h>
41#include <iprt/path.h>
42#include <iprt/param.h>
43#include <iprt/pipe.h>
44#include <iprt/getopt.h>
45#include <iprt/string.h>
46#include <iprt/mem.h>
47#include <iprt/message.h>
48#include <iprt/req.h>
49#include <iprt/file.h>
50#include <iprt/semaphore.h>
51#include <iprt/cpp/utils.h>
52#define LOG_GROUP LOG_GROUP_NAT_SERVICE
53#include <VBox/log.h>
54
55#include <VBox/sup.h>
56#include <VBox/intnet.h>
57#include <VBox/intnetinline.h>
58#include <VBox/vmm/pdmnetinline.h>
59#include <VBox/vmm/vmm.h>
60#include <VBox/version.h>
61
62#ifndef RT_OS_WINDOWS
63# include <sys/poll.h>
64# include <sys/socket.h>
65# include <netinet/in.h>
66#endif
67
68#include <vector>
69#include <string>
70
71#include "../NetLib/VBoxNetLib.h"
72#include "../NetLib/VBoxNetBaseService.h"
73#include "VBoxLwipCore.h"
74
75extern "C"
76{
77/* bunch of LWIP headers */
78#include "lwip/opt.h"
79#ifdef LWIP_SOCKET
80# undef LWIP_SOCKET
81# define LWIP_SOCKET 0
82#endif
83#include "lwip/sys.h"
84#include "lwip/stats.h"
85#include "lwip/mem.h"
86#include "lwip/memp.h"
87#include "lwip/pbuf.h"
88#include "lwip/netif.h"
89#include "lwip/api.h"
90#include "lwip/tcp_impl.h"
91#include "ipv6/lwip/ethip6.h"
92#include "lwip/nd6.h" // for proxy_na_hook
93#include "lwip/mld6.h"
94#include "lwip/udp.h"
95#include "lwip/tcp.h"
96#include "lwip/tcpip.h"
97#include "lwip/sockets.h"
98#include "netif/etharp.h"
99
100#include "proxy.h"
101#include "pxremap.h"
102#include "portfwd.h"
103}
104
105#include "../NetLib/VBoxPortForwardString.h"
106
107static RTGETOPTDEF g_aGetOptDef[] =
108{
109 { "--port-forward4", 'p', RTGETOPT_REQ_STRING },
110 { "--port-forward6", 'P', RTGETOPT_REQ_STRING }
111};
112
113typedef struct NATSEVICEPORTFORWARDRULE
114{
115 PORTFORWARDRULE Pfr;
116 fwspec FWSpec;
117} NATSEVICEPORTFORWARDRULE, *PNATSEVICEPORTFORWARDRULE;
118
119typedef std::vector<NATSEVICEPORTFORWARDRULE> VECNATSERVICEPF;
120typedef VECNATSERVICEPF::iterator ITERATORNATSERVICEPF;
121typedef VECNATSERVICEPF::const_iterator CITERATORNATSERVICEPF;
122
123
124class VBoxNetLwipNAT;
125
126
127class NATNetworkListener
128{
129public:
130 NATNetworkListener():m_pNAT(NULL){}
131
132 HRESULT init(VBoxNetLwipNAT *pNAT)
133 {
134 AssertPtrReturn(pNAT, E_INVALIDARG);
135
136 m_pNAT = pNAT;
137 return S_OK;
138 }
139
140 HRESULT init()
141 {
142 m_pNAT = NULL;
143 return S_OK;
144 }
145
146 void uninit() { m_pNAT = NULL; }
147
148 STDMETHOD(HandleEvent)(VBoxEventType_T aEventType, IEvent *pEvent);
149
150private:
151 VBoxNetLwipNAT *m_pNAT;
152};
153typedef ListenerImpl<NATNetworkListener, VBoxNetLwipNAT *> NATNetworkListenerImpl;
154VBOX_LISTENER_DECLARE(NATNetworkListenerImpl)
155
156
157class VBoxNetLwipNAT: public VBoxNetBaseService
158{
159 friend class NATNetworkListener;
160 public:
161 VBoxNetLwipNAT();
162 virtual ~VBoxNetLwipNAT();
163 void usage(){ /* @todo: should be implemented */ };
164 int run();
165 virtual int init(void);
166 /* @todo: when configuration would be really needed */
167 virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal);
168
169 private:
170 struct proxy_options m_ProxyOptions;
171 struct sockaddr_in m_src4;
172 struct sockaddr_in6 m_src6;
173 /**
174 * place for registered local interfaces.
175 */
176 ip4_lomap m_lo2off[10];
177 ip4_lomap_desc m_loOptDescriptor;
178
179 uint16_t m_u16Mtu;
180 netif m_LwipNetIf;
181 /* Queues */
182 RTREQQUEUE hReqIntNet;
183 /* thread where we're waiting for a frames, no semaphores needed */
184 RTTHREAD hThrIntNetRecv;
185
186 /* Our NAT network descriptor in Main */
187 ComPtr<INATNetwork> net;
188 ComPtr<NATNetworkListenerImpl> m_listener;
189 STDMETHOD(HandleEvent)(VBoxEventType_T aEventType, IEvent *pEvent);
190
191 RTSEMEVENT hSemSVC;
192 /* Only for debug needs, by default NAT service should load rules from SVC
193 * on startup, and then on sync them on events.
194 */
195 bool fDontLoadRulesOnStartup;
196 static void onLwipTcpIpInit(void *arg);
197 static void onLwipTcpIpFini(void *arg);
198 static err_t netifInit(netif *pNetif);
199 static err_t netifLinkoutput(netif *pNetif, pbuf *pBuf);
200 static int intNetThreadRecv(RTTHREAD, void *);
201 static void vboxNetLwipNATProcessXmit(void);
202
203 VECNATSERVICEPF m_vecPortForwardRule4;
204 VECNATSERVICEPF m_vecPortForwardRule6;
205
206 static int natServicePfRegister(NATSEVICEPORTFORWARDRULE& natServicePf);
207 static int natServiceProcessRegisteredPf(VECNATSERVICEPF& vecPf);
208};
209
210
211static VBoxNetLwipNAT *g_pLwipNat;
212
213STDMETHODIMP NATNetworkListener::HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent)
214{
215 if (m_pNAT)
216 return m_pNAT->HandleEvent(aEventType, pEvent);
217 else
218 return E_FAIL;
219}
220
221
222
223STDMETHODIMP VBoxNetLwipNAT::HandleEvent(VBoxEventType_T aEventType,
224 IEvent *pEvent)
225{
226 HRESULT hrc = S_OK;
227 switch (aEventType)
228 {
229 case VBoxEventType_OnNATNetworkSetting:
230 {
231 ComPtr<INATNetworkSettingEvent> evSettings(pEvent);
232 // XXX: only handle IPv6 default route for now
233
234 if (!m_ProxyOptions.ipv6_enabled)
235 {
236 break;
237 }
238
239 BOOL fIPv6DefaultRoute = FALSE;
240 hrc = evSettings->COMGETTER(AdvertiseDefaultIPv6RouteEnabled)(&fIPv6DefaultRoute);
241 AssertReturn(SUCCEEDED(hrc), hrc);
242
243 if (m_ProxyOptions.ipv6_defroute == fIPv6DefaultRoute)
244 {
245 break;
246 }
247
248 // XXX: TODO: should prod rtadvd for immediate unsolicited
249 // advertisement with new router lifetime
250 m_ProxyOptions.ipv6_defroute = fIPv6DefaultRoute;
251
252 break;
253 }
254
255 case VBoxEventType_OnNATNetworkPortForward:
256 {
257 com::Bstr name, strHostAddr, strGuestAddr;
258 LONG lHostPort, lGuestPort;
259 BOOL fCreateFW, fIPv6FW;
260 NATProtocol_T proto = NATProtocol_TCP;
261
262
263 ComPtr<INATNetworkPortForwardEvent> pfEvt = pEvent;
264
265 hrc = pfEvt->COMGETTER(Name)(name.asOutParam());
266 AssertReturn(SUCCEEDED(hrc), hrc);
267
268 hrc = pfEvt->COMGETTER(Proto)(&proto);
269 AssertReturn(SUCCEEDED(hrc), hrc);
270
271 hrc = pfEvt->COMGETTER(HostIp)(strHostAddr.asOutParam());
272 AssertReturn(SUCCEEDED(hrc), hrc);
273
274 hrc = pfEvt->COMGETTER(HostPort)(&lHostPort);
275 AssertReturn(SUCCEEDED(hrc), hrc);
276
277 hrc = pfEvt->COMGETTER(GuestIp)(strGuestAddr.asOutParam());
278 AssertReturn(SUCCEEDED(hrc), hrc);
279
280 hrc = pfEvt->COMGETTER(GuestPort)(&lGuestPort);
281 AssertReturn(SUCCEEDED(hrc), hrc);
282
283 hrc = pfEvt->COMGETTER(Create)(&fCreateFW);
284 AssertReturn(SUCCEEDED(hrc), hrc);
285
286 hrc = pfEvt->COMGETTER(Ipv6)(&fIPv6FW);
287 AssertReturn(SUCCEEDED(hrc), hrc);
288
289 VECNATSERVICEPF& rules = (fIPv6FW ?
290 m_vecPortForwardRule6 :
291 m_vecPortForwardRule4);
292
293 NATSEVICEPORTFORWARDRULE r;
294
295 RT_ZERO(r);
296
297 if (name.length() > sizeof(r.Pfr.szPfrName))
298 {
299 hrc = E_INVALIDARG;
300 goto port_forward_done;
301 }
302
303 switch (proto)
304 {
305 case NATProtocol_TCP:
306 r.Pfr.iPfrProto = IPPROTO_TCP;
307 break;
308 case NATProtocol_UDP:
309 r.Pfr.iPfrProto = IPPROTO_UDP;
310 break;
311 default:
312 goto port_forward_done;
313 }
314
315
316 RTStrPrintf(r.Pfr.szPfrName, sizeof(r.Pfr.szPfrName),
317 "%s", com::Utf8Str(name).c_str());
318
319 RTStrPrintf(r.Pfr.szPfrHostAddr, sizeof(r.Pfr.szPfrHostAddr),
320 "%s", com::Utf8Str(strHostAddr).c_str());
321
322 /* XXX: limits should be checked */
323 r.Pfr.u16PfrHostPort = (uint16_t)lHostPort;
324
325 RTStrPrintf(r.Pfr.szPfrGuestAddr, sizeof(r.Pfr.szPfrGuestAddr),
326 "%s", com::Utf8Str(strGuestAddr).c_str());
327
328 /* XXX: limits should be checked */
329 r.Pfr.u16PfrGuestPort = (uint16_t)lGuestPort;
330
331 if (fCreateFW) /* Addition */
332 {
333 rules.push_back(r);
334
335 natServicePfRegister(rules.back());
336 }
337 else /* Deletion */
338 {
339 ITERATORNATSERVICEPF it;
340 for (it = rules.begin(); it != rules.end(); ++it)
341 {
342 /* compare */
343 NATSEVICEPORTFORWARDRULE& natFw = *it;
344 if ( natFw.Pfr.iPfrProto == r.Pfr.iPfrProto
345 && natFw.Pfr.u16PfrHostPort == r.Pfr.u16PfrHostPort
346 && (strncmp(natFw.Pfr.szPfrHostAddr, r.Pfr.szPfrHostAddr, INET6_ADDRSTRLEN) == 0)
347 && natFw.Pfr.u16PfrGuestPort == r.Pfr.u16PfrGuestPort
348 && (strncmp(natFw.Pfr.szPfrGuestAddr, r.Pfr.szPfrGuestAddr, INET6_ADDRSTRLEN) == 0))
349 {
350 fwspec *pFwCopy = (fwspec *)RTMemAllocZ(sizeof(fwspec));
351 if (!pFwCopy)
352 {
353 break;
354 }
355 memcpy(pFwCopy, &natFw.FWSpec, sizeof(fwspec));
356
357 /* We shouldn't care about pFwCopy this memory will be freed when
358 * will message will arrive to the destination.
359 */
360 portfwd_rule_del(pFwCopy);
361
362 rules.erase(it);
363 break;
364 }
365 } /* loop over vector elements */
366 } /* condition add or delete */
367 port_forward_done:
368 /* clean up strings */
369 name.setNull();
370 strHostAddr.setNull();
371 strGuestAddr.setNull();
372 break;
373 }
374 }
375 return hrc;
376}
377
378
379void VBoxNetLwipNAT::onLwipTcpIpInit(void* arg)
380{
381 AssertPtrReturnVoid(arg);
382 VBoxNetLwipNAT *pNat = static_cast<VBoxNetLwipNAT *>(arg);
383
384 HRESULT hrc = com::Initialize();
385 Assert(!FAILED(hrc));
386
387 proxy_arp_hook = pxremap_proxy_arp;
388 proxy_ip4_divert_hook = pxremap_ip4_divert;
389
390 proxy_na_hook = pxremap_proxy_na;
391 proxy_ip6_divert_hook = pxremap_ip6_divert;
392
393 /* lwip thread */
394 RTNETADDRIPV4 IpNetwork;
395 IpNetwork.u = g_pLwipNat->m_Ipv4Address.u & g_pLwipNat->m_Ipv4Netmask.u;
396
397 ip_addr LwipIpAddr, LwipIpNetMask, LwipIpNetwork;
398
399 memcpy(&LwipIpAddr, &g_pLwipNat->m_Ipv4Address, sizeof(ip_addr));
400 memcpy(&LwipIpNetMask, &g_pLwipNat->m_Ipv4Netmask, sizeof(ip_addr));
401 memcpy(&LwipIpNetwork, &IpNetwork, sizeof(ip_addr));
402
403 netif *pNetif = netif_add(&g_pLwipNat->m_LwipNetIf /* Lwip Interface */,
404 &LwipIpAddr /* IP address*/,
405 &LwipIpNetMask /* Network mask */,
406 &LwipIpAddr /* gateway address, @todo: is self IP acceptable? */,
407 g_pLwipNat /* state */,
408 VBoxNetLwipNAT::netifInit /* netif_init_fn */,
409 lwip_tcpip_input /* netif_input_fn */);
410
411 AssertPtrReturnVoid(pNetif);
412
413 netif_set_up(pNetif);
414 netif_set_link_up(pNetif);
415
416 if (pNat->m_ProxyOptions.ipv6_enabled) {
417 /*
418 * XXX: lwIP currently only ever calls mld6_joingroup() in
419 * nd6_tmr() for fresh tentative addresses, which is a wrong place
420 * to do it - but I'm not keen on fixing this properly for now
421 * (with correct handling of interface up and down transitions,
422 * etc). So stick it here as a kludge.
423 */
424 for (int i = 0; i <= 1; ++i) {
425 ip6_addr_t *paddr = netif_ip6_addr(pNetif, i);
426
427 ip6_addr_t solicited_node_multicast_address;
428 ip6_addr_set_solicitednode(&solicited_node_multicast_address,
429 paddr->addr[3]);
430 mld6_joingroup(paddr, &solicited_node_multicast_address);
431 }
432
433 /*
434 * XXX: We must join the solicited-node multicast for the
435 * addresses we do IPv6 NA-proxy for. We map IPv6 loopback to
436 * proxy address + 1. We only need the low 24 bits, and those are
437 * fixed.
438 */
439 {
440 ip6_addr_t solicited_node_multicast_address;
441
442 ip6_addr_set_solicitednode(&solicited_node_multicast_address,
443 /* last 24 bits of the address */
444 PP_HTONL(0x00000002));
445 mld6_netif_joingroup(pNetif, &solicited_node_multicast_address);
446 }
447 }
448
449 proxy_init(&g_pLwipNat->m_LwipNetIf, &g_pLwipNat->m_ProxyOptions);
450
451 natServiceProcessRegisteredPf(g_pLwipNat->m_vecPortForwardRule4);
452 natServiceProcessRegisteredPf(g_pLwipNat->m_vecPortForwardRule6);
453}
454
455
456void VBoxNetLwipNAT::onLwipTcpIpFini(void* arg)
457{
458 AssertPtrReturnVoid(arg);
459 VBoxNetLwipNAT *pThis = (VBoxNetLwipNAT *)arg;
460
461 /* XXX: proxy finalization */
462 netif_set_link_down(&g_pLwipNat->m_LwipNetIf);
463 netif_set_down(&g_pLwipNat->m_LwipNetIf);
464 netif_remove(&g_pLwipNat->m_LwipNetIf);
465
466}
467
468/*
469 * Callback for netif_add() to initialize the interface.
470 */
471err_t VBoxNetLwipNAT::netifInit(netif *pNetif)
472{
473 err_t rcLwip = ERR_OK;
474
475 AssertPtrReturn(pNetif, ERR_ARG);
476
477 VBoxNetLwipNAT *pNat = static_cast<VBoxNetLwipNAT *>(pNetif->state);
478 AssertPtrReturn(pNat, ERR_ARG);
479
480 LogFlowFunc(("ENTER: pNetif[%c%c%d]\n", pNetif->name[0], pNetif->name[1], pNetif->num));
481 /* validity */
482 AssertReturn( pNetif->name[0] == 'N'
483 && pNetif->name[1] == 'T', ERR_ARG);
484
485
486 pNetif->hwaddr_len = sizeof(RTMAC);
487 memcpy(pNetif->hwaddr, &pNat->m_MacAddress, sizeof(RTMAC));
488
489 pNat->m_u16Mtu = 1500; // XXX: FIXME
490 pNetif->mtu = pNat->m_u16Mtu;
491
492 pNetif->flags = NETIF_FLAG_BROADCAST
493 | NETIF_FLAG_ETHARP /* Don't bother driver with ARP and let Lwip resolve ARP handling */
494 | NETIF_FLAG_ETHERNET; /* Lwip works with ethernet too */
495
496 pNetif->linkoutput = netifLinkoutput; /* ether-level-pipe */
497 pNetif->output = lwip_etharp_output; /* ip-pipe */
498
499 if (pNat->m_ProxyOptions.ipv6_enabled) {
500 pNetif->output_ip6 = ethip6_output;
501
502 /* IPv6 link-local address in slot 0 */
503 netif_create_ip6_linklocal_address(pNetif, /* :from_mac_48bit */ 1);
504 netif_ip6_addr_set_state(pNetif, 0, IP6_ADDR_PREFERRED); // skip DAD
505
506 /*
507 * RFC 4193 Locally Assigned Global ID (ULA) in slot 1
508 * [fd17:625c:f037:XXXX::1] where XXXX, 16 bit Subnet ID, are two
509 * bytes from the middle of the IPv4 address, e.g. :dead: for
510 * 10.222.173.1
511 */
512 u8_t nethi = ip4_addr2(&pNetif->ip_addr);
513 u8_t netlo = ip4_addr3(&pNetif->ip_addr);
514
515 ip6_addr_t *paddr = netif_ip6_addr(pNetif, 1);
516 IP6_ADDR(paddr, 0, 0xFD, 0x17, 0x62, 0x5C);
517 IP6_ADDR(paddr, 1, 0xF0, 0x37, nethi, netlo);
518 IP6_ADDR(paddr, 2, 0x00, 0x00, 0x00, 0x00);
519 IP6_ADDR(paddr, 3, 0x00, 0x00, 0x00, 0x01);
520 netif_ip6_addr_set_state(pNetif, 1, IP6_ADDR_PREFERRED);
521
522#if LWIP_IPV6_SEND_ROUTER_SOLICIT
523 pNetif->rs_count = 0;
524#endif
525 }
526
527 LogFlowFunc(("LEAVE: %d\n", rcLwip));
528 return rcLwip;
529}
530
531
532/**
533 * Intnet-recv thread
534 */
535int VBoxNetLwipNAT::intNetThreadRecv(RTTHREAD, void *)
536{
537 int rc = VINF_SUCCESS;
538
539 /* 1. initialization and connection */
540 HRESULT hrc = com::Initialize();
541 if (FAILED(hrc))
542 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!");
543
544 /* Well we're ready */
545 PINTNETRINGBUF pRingBuf = &g_pLwipNat->m_pIfBuf->Recv;
546
547 for (;;)
548 {
549 /*
550 * Wait for a packet to become available.
551 */
552 /* 2. waiting for request for */
553 rc = g_pLwipNat->waitForIntNetEvent(2000);
554 if (RT_FAILURE(rc))
555 {
556 if (rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED)
557 {
558 /* do we want interrupt anyone ??? */
559 continue;
560 }
561 LogRel(("VBoxNetNAT: waitForIntNetEvent returned %Rrc\n", rc));
562 AssertRCReturn(rc,ERR_IF);
563 }
564
565 /*
566 * Process the receive buffer.
567 */
568 PCINTNETHDR pHdr;
569
570 while ((pHdr = IntNetRingGetNextFrameToRead(pRingBuf)) != NULL)
571 {
572 uint8_t const u8Type = pHdr->u8Type;
573 size_t cbFrame = pHdr->cbFrame;
574 uint8_t *pu8Frame = NULL;
575 pbuf *pPbufHdr = NULL;
576 pbuf *pPbuf = NULL;
577 switch (u8Type)
578 {
579
580 case INTNETHDR_TYPE_FRAME:
581 /* @todo:should it be really here?
582 * Well well well, we're accessing lwip code here
583 */
584 pPbufHdr = pPbuf = pbuf_alloc(PBUF_RAW, pHdr->cbFrame, PBUF_POOL);
585 if (!pPbuf)
586 {
587 LogRel(("NAT: Can't allocate send buffer cbFrame=%u\n", cbFrame));
588 break;
589 }
590 Assert(pPbufHdr->tot_len == cbFrame);
591 pu8Frame = (uint8_t *)IntNetHdrGetFramePtr(pHdr, g_pLwipNat->m_pIfBuf);
592 while(pPbuf)
593 {
594 memcpy(pPbuf->payload, pu8Frame, pPbuf->len);
595 pu8Frame += pPbuf->len;
596 pPbuf = pPbuf->next;
597 }
598
599 g_pLwipNat->m_LwipNetIf.input(pPbufHdr, &g_pLwipNat->m_LwipNetIf);
600
601 AssertReleaseRC(rc);
602 break;
603 case INTNETHDR_TYPE_GSO:
604 {
605 PCPDMNETWORKGSO pGso = IntNetHdrGetGsoContext(pHdr,
606 g_pLwipNat->m_pIfBuf);
607 if (!PDMNetGsoIsValid(pGso, cbFrame,
608 cbFrame - sizeof(PDMNETWORKGSO)))
609 break;
610 cbFrame -= sizeof(PDMNETWORKGSO);
611 uint8_t abHdrScratch[256];
612 uint32_t const cSegs = PDMNetGsoCalcSegmentCount(pGso,
613 cbFrame);
614 for (size_t iSeg = 0; iSeg < cSegs; iSeg++)
615 {
616 uint32_t cbSegFrame;
617 void *pvSegFrame =
618 PDMNetGsoCarveSegmentQD(pGso,
619 (uint8_t *)(pGso + 1),
620 cbFrame,
621 abHdrScratch,
622 iSeg,
623 cSegs,
624 &cbSegFrame);
625
626 pPbuf = pbuf_alloc(PBUF_RAW, cbSegFrame, PBUF_POOL);
627 if (!pPbuf)
628 {
629 LogRel(("NAT: Can't allocate send buffer cbFrame=%u\n", cbSegFrame));
630 break;
631 }
632 Assert( !pPbuf->next
633 && pPbuf->len == cbSegFrame);
634 memcpy(pPbuf->payload, pvSegFrame, cbSegFrame);
635 g_pLwipNat->m_LwipNetIf.input(pPbuf, &g_pLwipNat->m_LwipNetIf);
636
637 }
638
639 }
640 break;
641 case INTNETHDR_TYPE_PADDING:
642 break;
643 default:
644 STAM_REL_COUNTER_INC(&g_pLwipNat->m_pIfBuf->cStatBadFrames);
645 break;
646 }
647 IntNetRingSkipFrame(&g_pLwipNat->m_pIfBuf->Recv);
648
649 } /* loop */
650 }
651 /* 3. deinitilization and termination */
652 LogFlowFuncLeaveRC(rc);
653 return rc;
654}
655
656
657/**
658 *
659 */
660void VBoxNetLwipNAT::vboxNetLwipNATProcessXmit()
661{
662 int rc = VINF_SUCCESS;
663 INTNETIFSENDREQ SendReq;
664 SendReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
665 SendReq.Hdr.cbReq = sizeof(SendReq);
666 SendReq.pSession = g_pLwipNat->m_pSession;
667 SendReq.hIf = g_pLwipNat->m_hIf;
668 rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_SEND, 0, &SendReq.Hdr);
669 AssertRC(rc);
670}
671
672
673err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf)
674{
675 int rc = VINF_SUCCESS;
676 err_t rcLwip = ERR_OK;
677 AssertPtrReturn(pNetif, ERR_ARG);
678 AssertPtrReturn(pPBuf, ERR_ARG);
679 AssertReturn((void *)g_pLwipNat == pNetif->state, ERR_ARG);
680 LogFlowFunc(("ENTER: pNetif[%c%c%d], pPbuf:%p\n",
681 pNetif->name[0],
682 pNetif->name[1],
683 pNetif->num,
684 pPBuf));
685
686 /*
687 * We're on the lwip thread ...
688 * try accure Xmit lock (actually we DO accure the lock ... )
689 * 1. we've entered csXmit so we should create frame
690 * 1.a. Frame creation success see 2.
691 * 1.b. (hm ... what about queue processing in place)
692 * 1.c. 2nd attempt create frame
693 * 1.d. Unlock the Xmit
694 * 1.e. goto BUSY.1
695 * 2. Copy pbuf to the frame
696 * 3. Send
697 * 4. leave csXmit & return.
698 *
699 * @todo: perhaps we can use it for optimization,
700 * e.g. drop UDP and reoccure lock on TCP NOTE: now BUSY is unachievable!
701 * Otherwise (BUSY)
702 * 1. Unbuffered (drop)
703 * (buffered)
704 * 1. Copy pbuf to entermediate buffer.
705 * 2. Add call buffer to the queue
706 * 3. return.
707 */
708 /* see p.1 */
709 rc = VINF_SUCCESS;
710 PINTNETHDR pHdr = NULL;
711 uint8_t *pu8Frame = NULL;
712 int offFrame = 0;
713 int idxSg = 0;
714 struct pbuf *pPBufPtr = pPBuf;
715 /* Allocate frame, and pad it if required. */
716 rc = IntNetRingAllocateFrame(&g_pLwipNat->m_pIfBuf->Send, pPBuf->tot_len, &pHdr, (void **)&pu8Frame);
717 if (RT_SUCCESS(rc))
718 {
719 /* see p. 2 */
720 while (pPBufPtr)
721 {
722 memcpy(&pu8Frame[offFrame], pPBufPtr->payload, pPBufPtr->len);
723 offFrame += pPBufPtr->len;
724 pPBufPtr = pPBufPtr->next;
725 }
726 }
727 if (RT_FAILURE(rc))
728 {
729 /* Could it be that some frames are still in the ring buffer */
730 /* 1.c */
731 AssertMsgFailed(("Debug Me!"));
732 }
733
734 /* Commit - what really this function do */
735 IntNetRingCommitFrameEx(&g_pLwipNat->m_pIfBuf->Send, pHdr, pPBuf->tot_len);
736
737 g_pLwipNat->vboxNetLwipNATProcessXmit();
738
739 AssertRCReturn(rc, ERR_IF);
740 LogFlowFunc(("LEAVE: %d\n", rcLwip));
741 return rcLwip;
742}
743
744
745VBoxNetLwipNAT::VBoxNetLwipNAT()
746{
747 LogFlowFuncEnter();
748
749 m_ProxyOptions.ipv6_enabled = 0;
750 m_ProxyOptions.ipv6_defroute = 0;
751 m_ProxyOptions.tftp_root = NULL;
752 m_ProxyOptions.src4 = NULL;
753 m_ProxyOptions.src6 = NULL;
754 memset(&m_src4, 0, sizeof(m_src4));
755 memset(&m_src6, 0, sizeof(m_src6));
756 m_src4.sin_family = AF_INET;
757 m_src6.sin6_family = AF_INET6;
758#if HAVE_SA_LEN
759 m_src4.sin_len = sizeof(m_src4);
760 m_src6.sin6_len = sizeof(m_src6);
761#endif
762
763 m_LwipNetIf.name[0] = 'N';
764 m_LwipNetIf.name[1] = 'T';
765 m_MacAddress.au8[0] = 0x52;
766 m_MacAddress.au8[1] = 0x54;
767 m_MacAddress.au8[2] = 0;
768 m_MacAddress.au8[3] = 0x12;
769 m_MacAddress.au8[4] = 0x35;
770 m_MacAddress.au8[5] = 0;
771 m_Ipv4Address.u = RT_MAKE_U32_FROM_U8( 10, 0, 2, 2); // NB: big-endian
772 m_Ipv4Netmask.u = RT_H2N_U32_C(0xffffff00);
773
774 fDontLoadRulesOnStartup = false;
775
776 for(unsigned int i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i)
777 m_vecOptionDefs.push_back(&g_aGetOptDef[i]);
778
779 m_enmTrunkType = kIntNetTrunkType_SrvNat;
780
781 LogFlowFuncLeave();
782}
783
784
785VBoxNetLwipNAT::~VBoxNetLwipNAT()
786{
787 if (m_ProxyOptions.tftp_root != NULL)
788 {
789 RTStrFree((char *)m_ProxyOptions.tftp_root);
790 }
791}
792
793
794int VBoxNetLwipNAT::natServicePfRegister(NATSEVICEPORTFORWARDRULE& natPf)
795{
796 int lrc = 0;
797 int rc = VINF_SUCCESS;
798 int socketSpec = SOCK_STREAM;
799 char *pszHostAddr;
800 int sockFamily = (natPf.Pfr.fPfrIPv6 ? PF_INET6 : PF_INET);
801
802 switch(natPf.Pfr.iPfrProto)
803 {
804 case IPPROTO_TCP:
805 socketSpec = SOCK_STREAM;
806 break;
807 case IPPROTO_UDP:
808 socketSpec = SOCK_DGRAM;
809 break;
810 default:
811 return VERR_IGNORED; /* Ah, just ignore the garbage */
812 }
813
814 pszHostAddr = natPf.Pfr.szPfrHostAddr;
815
816 /* XXX: workaround for inet_pton and an empty ipv4 address
817 * in rule declaration.
818 */
819 if ( sockFamily == PF_INET
820 && pszHostAddr[0] == 0)
821 pszHostAddr = (char *)"0.0.0.0"; /* XXX: fix it! without type cast */
822
823
824 lrc = fwspec_set(&natPf.FWSpec,
825 sockFamily,
826 socketSpec,
827 pszHostAddr,
828 natPf.Pfr.u16PfrHostPort,
829 natPf.Pfr.szPfrGuestAddr,
830 natPf.Pfr.u16PfrGuestPort);
831
832 AssertReturn(!lrc, VERR_IGNORED);
833
834 fwspec *pFwCopy = (fwspec *)RTMemAllocZ(sizeof(fwspec));
835 AssertPtrReturn(pFwCopy, VERR_IGNORED);
836
837 /*
838 * We need pass the copy, because we can't be sure
839 * how much this pointer will be valid in LWIP environment.
840 */
841 memcpy(pFwCopy, &natPf.FWSpec, sizeof(fwspec));
842
843 lrc = portfwd_rule_add(pFwCopy);
844
845 AssertReturn(!lrc, VERR_IGNORED);
846
847 return VINF_SUCCESS;
848}
849
850
851int VBoxNetLwipNAT::natServiceProcessRegisteredPf(VECNATSERVICEPF& vecRules){
852 ITERATORNATSERVICEPF it;
853 for (it = vecRules.begin();
854 it != vecRules.end(); ++it)
855 {
856 int rc = natServicePfRegister((*it));
857 if (RT_FAILURE(rc))
858 {
859 LogRel(("PF: %s is ignored\n", (*it).Pfr.szPfrName));
860 continue;
861 }
862 }
863 return VINF_SUCCESS;
864}
865
866
867int VBoxNetLwipNAT::init()
868{
869 com::Bstr bstr;
870 int rc = VINF_SUCCESS;
871 LogFlowFuncEnter();
872
873
874 /* virtualbox initialized in super class */
875
876 HRESULT hrc;
877 hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(),
878 net.asOutParam());
879 AssertComRCReturn(hrc, VERR_NOT_FOUND);
880
881 BOOL fIPv6Enabled = FALSE;
882 hrc = net->COMGETTER(IPv6Enabled)(&fIPv6Enabled);
883 AssertComRCReturn(hrc, VERR_NOT_FOUND);
884
885 BOOL fIPv6DefaultRoute = FALSE;
886 if (fIPv6Enabled)
887 {
888 hrc = net->COMGETTER(AdvertiseDefaultIPv6RouteEnabled)(&fIPv6DefaultRoute);
889 AssertComRCReturn(hrc, VERR_NOT_FOUND);
890 }
891
892 m_ProxyOptions.ipv6_enabled = fIPv6Enabled;
893 m_ProxyOptions.ipv6_defroute = fIPv6DefaultRoute;
894
895 /* XXX: Temporaly disabled this code on Windows for further debugging */
896 ComPtr<IEventSource> pES;
897
898 hrc = net->COMGETTER(EventSource)(pES.asOutParam());
899 AssertComRC(hrc);
900
901 ComObjPtr<NATNetworkListenerImpl> listener;
902 hrc = listener.createObject();
903 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
904
905 hrc = listener->init(new NATNetworkListener(), this);
906 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
907
908 com::SafeArray<VBoxEventType_T> events;
909 events.push_back(VBoxEventType_OnNATNetworkPortForward);
910 events.push_back(VBoxEventType_OnNATNetworkSetting);
911
912 hrc = pES->RegisterListener(listener, ComSafeArrayAsInParam(events), true);
913 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
914
915 m_listener = listener;
916
917 com::Bstr bstrSourceIp4Key = com::BstrFmt("NAT/%s/SourceIp4",m_Network.c_str());
918 com::Bstr bstrSourceIpX;
919 RTNETADDRIPV4 addr;
920 hrc = virtualbox->GetExtraData(bstrSourceIp4Key.raw(), bstrSourceIpX.asOutParam());
921 if (SUCCEEDED(hrc))
922 {
923 rc = RTNetStrToIPv4Addr(com::Utf8Str(bstrSourceIpX).c_str(), &addr);
924 if (RT_SUCCESS(rc))
925 {
926 RT_ZERO(m_src4);
927
928 m_src4.sin_addr.s_addr = addr.u;
929 m_ProxyOptions.src4 = &m_src4;
930
931 bstrSourceIpX.setNull();
932 }
933 }
934
935 if (!fDontLoadRulesOnStartup)
936 {
937 /* XXX: extract function and do not duplicate */
938 com::SafeArray<BSTR> rules;
939 hrc = net->COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(rules));
940 Assert(SUCCEEDED(hrc));
941
942 size_t idxRules = 0;
943 for (idxRules = 0; idxRules < rules.size(); ++idxRules)
944 {
945 Log(("%d-rule: %ls\n", idxRules, rules[idxRules]));
946 NATSEVICEPORTFORWARDRULE Rule;
947 RT_ZERO(Rule);
948 rc = netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), 0, &Rule.Pfr);
949 AssertRC(rc);
950 m_vecPortForwardRule4.push_back(Rule);
951 }
952
953 rules.setNull();
954 hrc = net->COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(rules));
955 Assert(SUCCEEDED(hrc));
956
957 for (idxRules = 0; idxRules < rules.size(); ++idxRules)
958 {
959 Log(("%d-rule: %ls\n", idxRules, rules[idxRules]));
960 NATSEVICEPORTFORWARDRULE Rule;
961 netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), 1, &Rule.Pfr);
962 m_vecPortForwardRule6.push_back(Rule);
963 }
964 } /* if (!fDontLoadRulesOnStartup) */
965
966 com::SafeArray<BSTR> strs;
967 int count_strs;
968 hrc = net->COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs));
969 if ( SUCCEEDED(hrc)
970 && (count_strs = strs.size()))
971 {
972 unsigned int j = 0;
973 int i;
974
975 for (i = 0; i < count_strs && j < RT_ELEMENTS(m_lo2off); ++i)
976 {
977 char szAddr[17];
978 RTNETADDRIPV4 ip4addr;
979 char *pszTerm;
980 uint32_t u32Off;
981 com::Utf8Str strLo2Off(strs[i]);
982 const char *pszLo2Off = strLo2Off.c_str();
983
984 RT_ZERO(szAddr);
985
986 pszTerm = RTStrStr(pszLo2Off, "=");
987
988 if ( !pszTerm
989 || (pszTerm - pszLo2Off) >= 17)
990 continue;
991
992 memcpy(szAddr, pszLo2Off, (pszTerm - pszLo2Off));
993 rc = RTNetStrToIPv4Addr(szAddr, &ip4addr);
994 if (RT_FAILURE(rc))
995 continue;
996
997 u32Off = RTStrToUInt32(pszTerm + 1);
998 if (u32Off == 0)
999 continue;
1000
1001 ip4_addr_set_u32(&m_lo2off[j].loaddr, ip4addr.u);
1002 m_lo2off[j].off = u32Off;
1003 ++j;
1004 }
1005
1006 m_loOptDescriptor.lomap = m_lo2off;
1007 m_loOptDescriptor.num_lomap = j;
1008 m_ProxyOptions.lomap_desc = &m_loOptDescriptor;
1009 }
1010
1011 hrc = virtualbox->COMGETTER(HomeFolder)(bstr.asOutParam());
1012 AssertComRCReturn(hrc, VERR_NOT_FOUND);
1013 if (!bstr.isEmpty())
1014 {
1015 com::Utf8Str strTftpRoot(com::Utf8StrFmt("%ls%c%s",
1016 bstr.raw(), RTPATH_DELIMITER, "TFTP"));
1017 char *pszStrTemp; // avoid const char ** vs char **
1018 rc = RTStrUtf8ToCurrentCP(&pszStrTemp, strTftpRoot.c_str());
1019 AssertRC(rc);
1020 m_ProxyOptions.tftp_root = pszStrTemp;
1021 }
1022
1023 /* end of COM initialization */
1024
1025 rc = RTSemEventCreate(&hSemSVC);
1026 AssertRCReturn(rc, rc);
1027
1028 rc = RTReqQueueCreate(&hReqIntNet);
1029 AssertRCReturn(rc, rc);
1030
1031 g_pLwipNat->tryGoOnline();
1032 vboxLwipCoreInitialize(VBoxNetLwipNAT::onLwipTcpIpInit, this);
1033
1034 rc = RTThreadCreate(&g_pLwipNat->hThrIntNetRecv, /* thread handle*/
1035 VBoxNetLwipNAT::intNetThreadRecv, /* routine */
1036 NULL, /* user data */
1037 128 * _1K, /* stack size */
1038 RTTHREADTYPE_IO, /* type */
1039 0, /* flags, @todo: waitable ?*/
1040 "INTNET-RECV");
1041 AssertRCReturn(rc,rc);
1042
1043
1044
1045 LogFlowFuncLeaveRC(rc);
1046 return rc;
1047}
1048
1049
1050int VBoxNetLwipNAT::parseOpt(int rc, const RTGETOPTUNION& Val)
1051{
1052 switch (rc)
1053 {
1054 case 'p':
1055 case 'P':
1056 {
1057 NATSEVICEPORTFORWARDRULE Rule;
1058 VECNATSERVICEPF& rules = (rc == 'P'?
1059 m_vecPortForwardRule6
1060 : m_vecPortForwardRule4);
1061
1062 fDontLoadRulesOnStartup = true;
1063
1064 RT_ZERO(Rule);
1065
1066 int irc = netPfStrToPf(Val.psz, (rc == 'P'), &Rule.Pfr);
1067 rules.push_back(Rule);
1068 return VINF_SUCCESS;
1069 }
1070 default:;
1071 }
1072 return VERR_NOT_FOUND;
1073}
1074
1075
1076int VBoxNetLwipNAT::run()
1077{
1078 /* EventQueue processing from VBoxHeadless.cpp */
1079 com::NativeEventQueue *gEventQ = NULL;
1080 gEventQ = com::NativeEventQueue::getMainEventQueue();
1081 while(true)
1082 {
1083 /* XXX:todo: graceful termination */
1084 gEventQ->processEventQueue(0);
1085 gEventQ->processEventQueue(500);
1086 }
1087
1088 vboxLwipCoreFinalize(VBoxNetLwipNAT::onLwipTcpIpFini, this);
1089
1090 m_vecPortForwardRule4.clear();
1091 m_vecPortForwardRule6.clear();
1092
1093 return VINF_SUCCESS;
1094}
1095
1096
1097/**
1098 * Entry point.
1099 */
1100extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
1101{
1102 LogFlowFuncEnter();
1103
1104 NOREF(envp);
1105
1106#ifdef RT_OS_WINDOWS
1107 WSADATA wsaData;
1108 int err;
1109
1110 err = WSAStartup(MAKEWORD(2,2), &wsaData);
1111 if (err)
1112 {
1113 fprintf(stderr, "wsastartup: failed (%d)\n", err);
1114 return 1;
1115 }
1116#endif
1117
1118 HRESULT hrc = com::Initialize();
1119#ifdef VBOX_WITH_XPCOM
1120 if (hrc == NS_ERROR_FILE_ACCESS_DENIED)
1121 {
1122 char szHome[RTPATH_MAX] = "";
1123 com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome));
1124 return RTMsgErrorExit(RTEXITCODE_FAILURE,
1125 "Failed to initialize COM because the global settings directory '%s' is not accessible!", szHome);
1126 }
1127#endif
1128 if (FAILED(hrc))
1129 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!");
1130
1131 g_pLwipNat = new VBoxNetLwipNAT();
1132
1133 Log2(("NAT: initialization\n"));
1134 int rc = g_pLwipNat->parseArgs(argc - 1, argv + 1);
1135 AssertRC(rc);
1136
1137
1138 if (!rc)
1139 {
1140
1141 g_pLwipNat->init();
1142 g_pLwipNat->run();
1143
1144 }
1145 delete g_pLwipNat;
1146 return 0;
1147}
1148
1149
1150#ifndef VBOX_WITH_HARDENING
1151
1152int main(int argc, char **argv, char **envp)
1153{
1154 int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
1155 if (RT_FAILURE(rc))
1156 return RTMsgInitFailure(rc);
1157
1158 return TrustedMain(argc, argv, envp);
1159}
1160
1161# if defined(RT_OS_WINDOWS)
1162
1163static LRESULT CALLBACK WindowProc(HWND hwnd,
1164 UINT uMsg,
1165 WPARAM wParam,
1166 LPARAM lParam
1167)
1168{
1169 if(uMsg == WM_DESTROY)
1170 {
1171 PostQuitMessage(0);
1172 return 0;
1173 }
1174 return DefWindowProc (hwnd, uMsg, wParam, lParam);
1175}
1176
1177static LPCWSTR g_WndClassName = L"VBoxNetNatLwipClass";
1178
1179static DWORD WINAPI MsgThreadProc(__in LPVOID lpParameter)
1180{
1181 HWND hwnd = 0;
1182 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle (NULL);
1183 bool bExit = false;
1184
1185 /* Register the Window Class. */
1186 WNDCLASS wc;
1187 wc.style = 0;
1188 wc.lpfnWndProc = WindowProc;
1189 wc.cbClsExtra = 0;
1190 wc.cbWndExtra = sizeof(void *);
1191 wc.hInstance = hInstance;
1192 wc.hIcon = NULL;
1193 wc.hCursor = NULL;
1194 wc.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
1195 wc.lpszMenuName = NULL;
1196 wc.lpszClassName = g_WndClassName;
1197
1198 ATOM atomWindowClass = RegisterClass(&wc);
1199
1200 if (atomWindowClass != 0)
1201 {
1202 /* Create the window. */
1203 hwnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST,
1204 g_WndClassName, g_WndClassName,
1205 WS_POPUPWINDOW,
1206 -200, -200, 100, 100, NULL, NULL, hInstance, NULL);
1207
1208 if (hwnd)
1209 {
1210 SetWindowPos(hwnd, HWND_TOPMOST, -200, -200, 0, 0,
1211 SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE);
1212
1213 MSG msg;
1214 while (GetMessage(&msg, NULL, 0, 0))
1215 {
1216 TranslateMessage(&msg);
1217 DispatchMessage(&msg);
1218 }
1219
1220 DestroyWindow (hwnd);
1221
1222 bExit = true;
1223 }
1224
1225 UnregisterClass (g_WndClassName, hInstance);
1226 }
1227
1228 if(bExit)
1229 {
1230 /* no need any accuracy here, in anyway the DHCP server usually gets terminated with TerminateProcess */
1231 exit(0);
1232 }
1233
1234 return 0;
1235}
1236
1237
1238
1239/** (We don't want a console usually.) */
1240int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
1241{
1242#if 0
1243 NOREF(hInstance); NOREF(hPrevInstance); NOREF(lpCmdLine); NOREF(nCmdShow);
1244
1245 HANDLE hThread = CreateThread(
1246 NULL, /*__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes, */
1247 0, /*__in SIZE_T dwStackSize, */
1248 MsgThreadProc, /*__in LPTHREAD_START_ROUTINE lpStartAddress,*/
1249 NULL, /*__in_opt LPVOID lpParameter,*/
1250 0, /*__in DWORD dwCreationFlags,*/
1251 NULL /*__out_opt LPDWORD lpThreadId*/
1252 );
1253
1254 if(hThread != NULL)
1255 CloseHandle(hThread);
1256
1257#endif
1258 return main(__argc, __argv, environ);
1259}
1260# endif /* RT_OS_WINDOWS */
1261
1262#endif /* !VBOX_WITH_HARDENING */
1263
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette