VirtualBox

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

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

NetworkServices: coding style

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.3 KB
Line 
1/* $Id: VBoxNetLwipNAT.cpp 49113 2013-10-15 09:36:22Z 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.virtualbox.org. 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#if !defined(RT_OS_WINDOWS)
896 /* XXX: Temporaly disabled this code on Windows for further debugging */
897 ComPtr<IEventSource> pES;
898
899 hrc = net->COMGETTER(EventSource)(pES.asOutParam());
900 AssertComRC(hrc);
901
902 ComObjPtr<NATNetworkListenerImpl> listener;
903 hrc = listener.createObject();
904 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
905
906 hrc = listener->init(new NATNetworkListener(), this);
907 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
908
909 com::SafeArray<VBoxEventType_T> events;
910 events.push_back(VBoxEventType_OnNATNetworkPortForward);
911 events.push_back(VBoxEventType_OnNATNetworkSetting);
912
913 hrc = pES->RegisterListener(listener, ComSafeArrayAsInParam(events), true);
914 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
915
916 m_listener = listener;
917#endif
918
919 com::Bstr bstrSourceIp4Key = com::BstrFmt("NAT/%s/SourceIp4",m_Network.c_str());
920 com::Bstr bstrSourceIpX;
921 RTNETADDRIPV4 addr;
922 hrc = virtualbox->GetExtraData(bstrSourceIp4Key.raw(), bstrSourceIpX.asOutParam());
923 if (SUCCEEDED(hrc))
924 {
925 rc = RTNetStrToIPv4Addr(com::Utf8Str(bstrSourceIpX).c_str(), &addr);
926 if (RT_SUCCESS(rc))
927 {
928 RT_ZERO(m_src4);
929
930 m_src4.sin_addr.s_addr = addr.u;
931 m_ProxyOptions.src4 = &m_src4;
932
933 bstrSourceIpX.setNull();
934 }
935 }
936
937 if (!fDontLoadRulesOnStartup)
938 {
939 /* XXX: extract function and do not duplicate */
940 com::SafeArray<BSTR> rules;
941 hrc = net->COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(rules));
942 Assert(SUCCEEDED(hrc));
943
944 size_t idxRules = 0;
945 for (idxRules = 0; idxRules < rules.size(); ++idxRules)
946 {
947 Log(("%d-rule: %ls\n", idxRules, rules[idxRules]));
948 NATSEVICEPORTFORWARDRULE Rule;
949 RT_ZERO(Rule);
950 rc = netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), 0, &Rule.Pfr);
951 AssertRC(rc);
952 m_vecPortForwardRule4.push_back(Rule);
953 }
954
955 rules.setNull();
956 hrc = net->COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(rules));
957 Assert(SUCCEEDED(hrc));
958
959 for (idxRules = 0; idxRules < rules.size(); ++idxRules)
960 {
961 Log(("%d-rule: %ls\n", idxRules, rules[idxRules]));
962 NATSEVICEPORTFORWARDRULE Rule;
963 netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), 1, &Rule.Pfr);
964 m_vecPortForwardRule6.push_back(Rule);
965 }
966 } /* if (!fDontLoadRulesOnStartup) */
967
968 com::SafeArray<BSTR> strs;
969 int count_strs;
970 hrc = net->COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs));
971 if ( SUCCEEDED(hrc)
972 && (count_strs = strs.size()))
973 {
974 unsigned int j = 0;
975 int i;
976
977 for (i = 0; i < count_strs && j < RT_ELEMENTS(m_lo2off); ++i)
978 {
979 char szAddr[17];
980 RTNETADDRIPV4 ip4addr;
981 char *pszTerm;
982 uint32_t u32Off;
983 com::Utf8Str strLo2Off(strs[i]);
984 const char *pszLo2Off = strLo2Off.c_str();
985
986 RT_ZERO(szAddr);
987
988 pszTerm = RTStrStr(pszLo2Off, "=");
989
990 if ( !pszTerm
991 || (pszTerm - pszLo2Off) >= 17)
992 continue;
993
994 memcpy(szAddr, pszLo2Off, (pszTerm - pszLo2Off));
995 rc = RTNetStrToIPv4Addr(szAddr, &ip4addr);
996 if (RT_FAILURE(rc))
997 continue;
998
999 u32Off = RTStrToUInt32(pszTerm + 1);
1000 if (u32Off == 0)
1001 continue;
1002
1003 ip4_addr_set_u32(&m_lo2off[j].loaddr, ip4addr.u);
1004 m_lo2off[j].off = u32Off;
1005 ++j;
1006 }
1007
1008 m_loOptDescriptor.lomap = m_lo2off;
1009 m_loOptDescriptor.num_lomap = j;
1010 m_ProxyOptions.lomap_desc = &m_loOptDescriptor;
1011 }
1012
1013 hrc = virtualbox->COMGETTER(HomeFolder)(bstr.asOutParam());
1014 AssertComRCReturn(hrc, VERR_NOT_FOUND);
1015 if (!bstr.isEmpty())
1016 {
1017 com::Utf8Str strTftpRoot(com::Utf8StrFmt("%ls%c%s",
1018 bstr.raw(), RTPATH_DELIMITER, "TFTP"));
1019 char *pszStrTemp; // avoid const char ** vs char **
1020 rc = RTStrUtf8ToCurrentCP(&pszStrTemp, strTftpRoot.c_str());
1021 AssertRC(rc);
1022 m_ProxyOptions.tftp_root = pszStrTemp;
1023 }
1024
1025 /* end of COM initialization */
1026
1027 rc = RTSemEventCreate(&hSemSVC);
1028 AssertRCReturn(rc, rc);
1029
1030 rc = RTReqQueueCreate(&hReqIntNet);
1031 AssertRCReturn(rc, rc);
1032
1033 g_pLwipNat->tryGoOnline();
1034 vboxLwipCoreInitialize(VBoxNetLwipNAT::onLwipTcpIpInit, this);
1035
1036 rc = RTThreadCreate(&g_pLwipNat->hThrIntNetRecv, /* thread handle*/
1037 VBoxNetLwipNAT::intNetThreadRecv, /* routine */
1038 NULL, /* user data */
1039 128 * _1K, /* stack size */
1040 RTTHREADTYPE_IO, /* type */
1041 0, /* flags, @todo: waitable ?*/
1042 "INTNET-RECV");
1043 AssertRCReturn(rc,rc);
1044
1045
1046
1047 LogFlowFuncLeaveRC(rc);
1048 return rc;
1049}
1050
1051
1052int VBoxNetLwipNAT::parseOpt(int rc, const RTGETOPTUNION& Val)
1053{
1054 switch (rc)
1055 {
1056 case 'p':
1057 case 'P':
1058 {
1059 NATSEVICEPORTFORWARDRULE Rule;
1060 VECNATSERVICEPF& rules = (rc == 'P'?
1061 m_vecPortForwardRule6
1062 : m_vecPortForwardRule4);
1063
1064 fDontLoadRulesOnStartup = true;
1065
1066 RT_ZERO(Rule);
1067
1068 int irc = netPfStrToPf(Val.psz, (rc == 'P'), &Rule.Pfr);
1069 rules.push_back(Rule);
1070 return VINF_SUCCESS;
1071 }
1072 default:;
1073 }
1074 return VERR_NOT_FOUND;
1075}
1076
1077
1078int VBoxNetLwipNAT::run()
1079{
1080 /* EventQueue processing from VBoxHeadless.cpp */
1081 com::NativeEventQueue *gEventQ = NULL;
1082 gEventQ = com::NativeEventQueue::getMainEventQueue();
1083 while(true)
1084 {
1085 /* XXX:todo: graceful termination */
1086 gEventQ->processEventQueue(0);
1087 gEventQ->processEventQueue(500);
1088 }
1089
1090 vboxLwipCoreFinalize(VBoxNetLwipNAT::onLwipTcpIpFini, this);
1091
1092 m_vecPortForwardRule4.clear();
1093 m_vecPortForwardRule6.clear();
1094
1095 return VINF_SUCCESS;
1096}
1097
1098
1099/**
1100 * Entry point.
1101 */
1102extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
1103{
1104 LogFlowFuncEnter();
1105
1106 NOREF(envp);
1107
1108#ifdef RT_OS_WINDOWS
1109 WSADATA wsaData;
1110 int err;
1111
1112 err = WSAStartup(MAKEWORD(2,2), &wsaData);
1113 if (err)
1114 {
1115 fprintf(stderr, "wsastartup: failed (%d)\n", err);
1116 return 1;
1117 }
1118#endif
1119
1120 HRESULT hrc = com::Initialize();
1121#ifdef VBOX_WITH_XPCOM
1122 if (hrc == NS_ERROR_FILE_ACCESS_DENIED)
1123 {
1124 char szHome[RTPATH_MAX] = "";
1125 com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome));
1126 return RTMsgErrorExit(RTEXITCODE_FAILURE,
1127 "Failed to initialize COM because the global settings directory '%s' is not accessible!", szHome);
1128 }
1129#endif
1130 if (FAILED(hrc))
1131 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!");
1132
1133 g_pLwipNat = new VBoxNetLwipNAT();
1134
1135 Log2(("NAT: initialization\n"));
1136 int rc = g_pLwipNat->parseArgs(argc - 1, argv + 1);
1137 AssertRC(rc);
1138
1139
1140 if (!rc)
1141 {
1142
1143 g_pLwipNat->init();
1144 g_pLwipNat->run();
1145
1146 }
1147 delete g_pLwipNat;
1148 return 0;
1149}
1150
1151
1152#ifndef VBOX_WITH_HARDENING
1153
1154int main(int argc, char **argv, char **envp)
1155{
1156 int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
1157 if (RT_FAILURE(rc))
1158 return RTMsgInitFailure(rc);
1159
1160 return TrustedMain(argc, argv, envp);
1161}
1162
1163# if defined(RT_OS_WINDOWS)
1164
1165static LRESULT CALLBACK WindowProc(HWND hwnd,
1166 UINT uMsg,
1167 WPARAM wParam,
1168 LPARAM lParam
1169)
1170{
1171 if(uMsg == WM_DESTROY)
1172 {
1173 PostQuitMessage(0);
1174 return 0;
1175 }
1176 return DefWindowProc (hwnd, uMsg, wParam, lParam);
1177}
1178
1179static LPCWSTR g_WndClassName = L"VBoxNetNatLwipClass";
1180
1181static DWORD WINAPI MsgThreadProc(__in LPVOID lpParameter)
1182{
1183 HWND hwnd = 0;
1184 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle (NULL);
1185 bool bExit = false;
1186
1187 /* Register the Window Class. */
1188 WNDCLASS wc;
1189 wc.style = 0;
1190 wc.lpfnWndProc = WindowProc;
1191 wc.cbClsExtra = 0;
1192 wc.cbWndExtra = sizeof(void *);
1193 wc.hInstance = hInstance;
1194 wc.hIcon = NULL;
1195 wc.hCursor = NULL;
1196 wc.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
1197 wc.lpszMenuName = NULL;
1198 wc.lpszClassName = g_WndClassName;
1199
1200 ATOM atomWindowClass = RegisterClass(&wc);
1201
1202 if (atomWindowClass != 0)
1203 {
1204 /* Create the window. */
1205 hwnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST,
1206 g_WndClassName, g_WndClassName,
1207 WS_POPUPWINDOW,
1208 -200, -200, 100, 100, NULL, NULL, hInstance, NULL);
1209
1210 if (hwnd)
1211 {
1212 SetWindowPos(hwnd, HWND_TOPMOST, -200, -200, 0, 0,
1213 SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE);
1214
1215 MSG msg;
1216 while (GetMessage(&msg, NULL, 0, 0))
1217 {
1218 TranslateMessage(&msg);
1219 DispatchMessage(&msg);
1220 }
1221
1222 DestroyWindow (hwnd);
1223
1224 bExit = true;
1225 }
1226
1227 UnregisterClass (g_WndClassName, hInstance);
1228 }
1229
1230 if(bExit)
1231 {
1232 /* no need any accuracy here, in anyway the DHCP server usually gets terminated with TerminateProcess */
1233 exit(0);
1234 }
1235
1236 return 0;
1237}
1238
1239
1240
1241/** (We don't want a console usually.) */
1242int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
1243{
1244#if 0
1245 NOREF(hInstance); NOREF(hPrevInstance); NOREF(lpCmdLine); NOREF(nCmdShow);
1246
1247 HANDLE hThread = CreateThread(
1248 NULL, /*__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes, */
1249 0, /*__in SIZE_T dwStackSize, */
1250 MsgThreadProc, /*__in LPTHREAD_START_ROUTINE lpStartAddress,*/
1251 NULL, /*__in_opt LPVOID lpParameter,*/
1252 0, /*__in DWORD dwCreationFlags,*/
1253 NULL /*__out_opt LPDWORD lpThreadId*/
1254 );
1255
1256 if(hThread != NULL)
1257 CloseHandle(hThread);
1258
1259#endif
1260 return main(__argc, __argv, environ);
1261}
1262# endif /* RT_OS_WINDOWS */
1263
1264#endif /* !VBOX_WITH_HARDENING */
1265
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