VirtualBox

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

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

VBoxNetLwipNAT.cpp: extend listener scope to class level.

  • 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 49110 2013-10-15 08:56:52Z 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() > RT_ELEMENTS(r.Pfr.aszPfrName))
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.aszPfrName, RT_ELEMENTS(r.Pfr.aszPfrName),
317 "%s",
318 com::Utf8Str(name).c_str());
319
320 RTStrPrintf(r.Pfr.aszPfrHostAddr, RT_ELEMENTS(r.Pfr.aszPfrHostAddr),
321 "%s",
322 com::Utf8Str(strHostAddr).c_str());
323
324 /* XXX: limits should be checked */
325 r.Pfr.u16PfrHostPort = (uint16_t)lHostPort;
326
327 RTStrPrintf(r.Pfr.aszPfrGuestAddr, RT_ELEMENTS(r.Pfr.aszPfrGuestAddr),
328 "%s",
329 com::Utf8Str(strGuestAddr).c_str());
330
331 /* XXX: limits should be checked */
332 r.Pfr.u16PfrGuestPort = (uint16_t)lGuestPort;
333
334 if (fCreateFW) /* Addition */
335 {
336 rules.push_back(r);
337
338 natServicePfRegister(rules.back());
339 }
340 else /* Deletion */
341 {
342 ITERATORNATSERVICEPF it;
343 for (it = rules.begin(); it != rules.end(); ++it)
344 {
345 /* compare */
346 NATSEVICEPORTFORWARDRULE& natFw = *it;
347 if ( natFw.Pfr.iPfrProto == r.Pfr.iPfrProto
348 && natFw.Pfr.u16PfrHostPort == r.Pfr.u16PfrHostPort
349 && (strncmp(natFw.Pfr.aszPfrHostAddr, r.Pfr.aszPfrHostAddr, INET6_ADDRSTRLEN) == 0)
350 && natFw.Pfr.u16PfrGuestPort == r.Pfr.u16PfrGuestPort
351 && (strncmp(natFw.Pfr.aszPfrGuestAddr, r.Pfr.aszPfrGuestAddr, INET6_ADDRSTRLEN) == 0))
352 {
353 fwspec *pFwCopy = (fwspec *)RTMemAllocZ(sizeof(fwspec));
354 if (!pFwCopy)
355 {
356 break;
357 }
358 memcpy(pFwCopy, &natFw.FWSpec, sizeof(fwspec));
359
360 /* We shouldn't care about pFwCopy this memory will be freed when
361 * will message will arrive to the destination.
362 */
363 portfwd_rule_del(pFwCopy);
364
365 rules.erase(it);
366 break;
367 }
368 } /* loop over vector elements */
369 } /* condition add or delete */
370 port_forward_done:
371 /* clean up strings */
372 name.setNull();
373 strHostAddr.setNull();
374 strGuestAddr.setNull();
375 break;
376 }
377 }
378 return hrc;
379}
380
381
382void VBoxNetLwipNAT::onLwipTcpIpInit(void* arg)
383{
384 AssertPtrReturnVoid(arg);
385 VBoxNetLwipNAT *pNat = static_cast<VBoxNetLwipNAT *>(arg);
386
387 HRESULT hrc = com::Initialize();
388 Assert(!FAILED(hrc));
389
390 proxy_arp_hook = pxremap_proxy_arp;
391 proxy_ip4_divert_hook = pxremap_ip4_divert;
392
393 proxy_na_hook = pxremap_proxy_na;
394 proxy_ip6_divert_hook = pxremap_ip6_divert;
395
396 /* lwip thread */
397 RTNETADDRIPV4 IpNetwork;
398 IpNetwork.u = g_pLwipNat->m_Ipv4Address.u & g_pLwipNat->m_Ipv4Netmask.u;
399
400 ip_addr LwipIpAddr, LwipIpNetMask, LwipIpNetwork;
401
402 memcpy(&LwipIpAddr, &g_pLwipNat->m_Ipv4Address, sizeof(ip_addr));
403 memcpy(&LwipIpNetMask, &g_pLwipNat->m_Ipv4Netmask, sizeof(ip_addr));
404 memcpy(&LwipIpNetwork, &IpNetwork, sizeof(ip_addr));
405
406 netif *pNetif = netif_add(&g_pLwipNat->m_LwipNetIf /* Lwip Interface */,
407 &LwipIpAddr /* IP address*/,
408 &LwipIpNetMask /* Network mask */,
409 &LwipIpAddr /* gateway address, @todo: is self IP acceptable? */,
410 g_pLwipNat /* state */,
411 VBoxNetLwipNAT::netifInit /* netif_init_fn */,
412 lwip_tcpip_input /* netif_input_fn */);
413
414 AssertPtrReturnVoid(pNetif);
415
416 netif_set_up(pNetif);
417 netif_set_link_up(pNetif);
418
419 if (pNat->m_ProxyOptions.ipv6_enabled) {
420 /*
421 * XXX: lwIP currently only ever calls mld6_joingroup() in
422 * nd6_tmr() for fresh tentative addresses, which is a wrong place
423 * to do it - but I'm not keen on fixing this properly for now
424 * (with correct handling of interface up and down transitions,
425 * etc). So stick it here as a kludge.
426 */
427 for (int i = 0; i <= 1; ++i) {
428 ip6_addr_t *paddr = netif_ip6_addr(pNetif, i);
429
430 ip6_addr_t solicited_node_multicast_address;
431 ip6_addr_set_solicitednode(&solicited_node_multicast_address,
432 paddr->addr[3]);
433 mld6_joingroup(paddr, &solicited_node_multicast_address);
434 }
435
436 /*
437 * XXX: We must join the solicited-node multicast for the
438 * addresses we do IPv6 NA-proxy for. We map IPv6 loopback to
439 * proxy address + 1. We only need the low 24 bits, and those are
440 * fixed.
441 */
442 {
443 ip6_addr_t solicited_node_multicast_address;
444
445 ip6_addr_set_solicitednode(&solicited_node_multicast_address,
446 /* last 24 bits of the address */
447 PP_HTONL(0x00000002));
448 mld6_netif_joingroup(pNetif, &solicited_node_multicast_address);
449 }
450 }
451
452 proxy_init(&g_pLwipNat->m_LwipNetIf, &g_pLwipNat->m_ProxyOptions);
453
454 natServiceProcessRegisteredPf(g_pLwipNat->m_vecPortForwardRule4);
455 natServiceProcessRegisteredPf(g_pLwipNat->m_vecPortForwardRule6);
456}
457
458
459void VBoxNetLwipNAT::onLwipTcpIpFini(void* arg)
460{
461 AssertPtrReturnVoid(arg);
462 VBoxNetLwipNAT *pThis = (VBoxNetLwipNAT *)arg;
463
464 /* XXX: proxy finalization */
465 netif_set_link_down(&g_pLwipNat->m_LwipNetIf);
466 netif_set_down(&g_pLwipNat->m_LwipNetIf);
467 netif_remove(&g_pLwipNat->m_LwipNetIf);
468
469}
470
471/*
472 * Callback for netif_add() to initialize the interface.
473 */
474err_t VBoxNetLwipNAT::netifInit(netif *pNetif)
475{
476 err_t rcLwip = ERR_OK;
477
478 AssertPtrReturn(pNetif, ERR_ARG);
479
480 VBoxNetLwipNAT *pNat = static_cast<VBoxNetLwipNAT *>(pNetif->state);
481 AssertPtrReturn(pNat, ERR_ARG);
482
483 LogFlowFunc(("ENTER: pNetif[%c%c%d]\n", pNetif->name[0], pNetif->name[1], pNetif->num));
484 /* validity */
485 AssertReturn( pNetif->name[0] == 'N'
486 && pNetif->name[1] == 'T', ERR_ARG);
487
488
489 pNetif->hwaddr_len = sizeof(RTMAC);
490 memcpy(pNetif->hwaddr, &pNat->m_MacAddress, sizeof(RTMAC));
491
492 pNat->m_u16Mtu = 1500; // XXX: FIXME
493 pNetif->mtu = pNat->m_u16Mtu;
494
495 pNetif->flags = NETIF_FLAG_BROADCAST
496 | NETIF_FLAG_ETHARP /* Don't bother driver with ARP and let Lwip resolve ARP handling */
497 | NETIF_FLAG_ETHERNET; /* Lwip works with ethernet too */
498
499 pNetif->linkoutput = netifLinkoutput; /* ether-level-pipe */
500 pNetif->output = lwip_etharp_output; /* ip-pipe */
501
502 if (pNat->m_ProxyOptions.ipv6_enabled) {
503 pNetif->output_ip6 = ethip6_output;
504
505 /* IPv6 link-local address in slot 0 */
506 netif_create_ip6_linklocal_address(pNetif, /* :from_mac_48bit */ 1);
507 netif_ip6_addr_set_state(pNetif, 0, IP6_ADDR_PREFERRED); // skip DAD
508
509 /*
510 * RFC 4193 Locally Assigned Global ID (ULA) in slot 1
511 * [fd17:625c:f037:XXXX::1] where XXXX, 16 bit Subnet ID, are two
512 * bytes from the middle of the IPv4 address, e.g. :dead: for
513 * 10.222.173.1
514 */
515 u8_t nethi = ip4_addr2(&pNetif->ip_addr);
516 u8_t netlo = ip4_addr3(&pNetif->ip_addr);
517
518 ip6_addr_t *paddr = netif_ip6_addr(pNetif, 1);
519 IP6_ADDR(paddr, 0, 0xFD, 0x17, 0x62, 0x5C);
520 IP6_ADDR(paddr, 1, 0xF0, 0x37, nethi, netlo);
521 IP6_ADDR(paddr, 2, 0x00, 0x00, 0x00, 0x00);
522 IP6_ADDR(paddr, 3, 0x00, 0x00, 0x00, 0x01);
523 netif_ip6_addr_set_state(pNetif, 1, IP6_ADDR_PREFERRED);
524
525#if LWIP_IPV6_SEND_ROUTER_SOLICIT
526 pNetif->rs_count = 0;
527#endif
528 }
529
530 LogFlowFunc(("LEAVE: %d\n", rcLwip));
531 return rcLwip;
532}
533
534
535/**
536 * Intnet-recv thread
537 */
538int VBoxNetLwipNAT::intNetThreadRecv(RTTHREAD, void *)
539{
540 int rc = VINF_SUCCESS;
541
542 /* 1. initialization and connection */
543 HRESULT hrc = com::Initialize();
544 if (FAILED(hrc))
545 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!");
546
547 /* Well we're ready */
548 PINTNETRINGBUF pRingBuf = &g_pLwipNat->m_pIfBuf->Recv;
549
550 for (;;)
551 {
552 /*
553 * Wait for a packet to become available.
554 */
555 /* 2. waiting for request for */
556 rc = g_pLwipNat->waitForIntNetEvent(2000);
557 if (RT_FAILURE(rc))
558 {
559 if (rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED)
560 {
561 /* do we want interrupt anyone ??? */
562 continue;
563 }
564 LogRel(("VBoxNetNAT: waitForIntNetEvent returned %Rrc\n", rc));
565 AssertRCReturn(rc,ERR_IF);
566 }
567
568 /*
569 * Process the receive buffer.
570 */
571 PCINTNETHDR pHdr;
572
573 while ((pHdr = IntNetRingGetNextFrameToRead(pRingBuf)) != NULL)
574 {
575 uint8_t const u8Type = pHdr->u8Type;
576 size_t cbFrame = pHdr->cbFrame;
577 uint8_t *pu8Frame = NULL;
578 pbuf *pPbufHdr = NULL;
579 pbuf *pPbuf = NULL;
580 switch (u8Type)
581 {
582
583 case INTNETHDR_TYPE_FRAME:
584 /* @todo:should it be really here?
585 * Well well well, we're accessing lwip code here
586 */
587 pPbufHdr = pPbuf = pbuf_alloc(PBUF_RAW, pHdr->cbFrame, PBUF_POOL);
588 if (!pPbuf)
589 {
590 LogRel(("NAT: Can't allocate send buffer cbFrame=%u\n", cbFrame));
591 break;
592 }
593 Assert(pPbufHdr->tot_len == cbFrame);
594 pu8Frame = (uint8_t *)IntNetHdrGetFramePtr(pHdr, g_pLwipNat->m_pIfBuf);
595 while(pPbuf)
596 {
597 memcpy(pPbuf->payload, pu8Frame, pPbuf->len);
598 pu8Frame += pPbuf->len;
599 pPbuf = pPbuf->next;
600 }
601
602 g_pLwipNat->m_LwipNetIf.input(pPbufHdr, &g_pLwipNat->m_LwipNetIf);
603
604 AssertReleaseRC(rc);
605 break;
606 case INTNETHDR_TYPE_GSO:
607 {
608 PCPDMNETWORKGSO pGso = IntNetHdrGetGsoContext(pHdr,
609 g_pLwipNat->m_pIfBuf);
610 if (!PDMNetGsoIsValid(pGso, cbFrame,
611 cbFrame - sizeof(PDMNETWORKGSO)))
612 break;
613 cbFrame -= sizeof(PDMNETWORKGSO);
614 uint8_t abHdrScratch[256];
615 uint32_t const cSegs = PDMNetGsoCalcSegmentCount(pGso,
616 cbFrame);
617 for (size_t iSeg = 0; iSeg < cSegs; iSeg++)
618 {
619 uint32_t cbSegFrame;
620 void *pvSegFrame =
621 PDMNetGsoCarveSegmentQD(pGso,
622 (uint8_t *)(pGso + 1),
623 cbFrame,
624 abHdrScratch,
625 iSeg,
626 cSegs,
627 &cbSegFrame);
628
629 pPbuf = pbuf_alloc(PBUF_RAW, cbSegFrame, PBUF_POOL);
630 if (!pPbuf)
631 {
632 LogRel(("NAT: Can't allocate send buffer cbFrame=%u\n", cbSegFrame));
633 break;
634 }
635 Assert( !pPbuf->next
636 && pPbuf->len == cbSegFrame);
637 memcpy(pPbuf->payload, pvSegFrame, cbSegFrame);
638 g_pLwipNat->m_LwipNetIf.input(pPbuf, &g_pLwipNat->m_LwipNetIf);
639
640 }
641
642 }
643 break;
644 case INTNETHDR_TYPE_PADDING:
645 break;
646 default:
647 STAM_REL_COUNTER_INC(&g_pLwipNat->m_pIfBuf->cStatBadFrames);
648 break;
649 }
650 IntNetRingSkipFrame(&g_pLwipNat->m_pIfBuf->Recv);
651
652 } /* loop */
653 }
654 /* 3. deinitilization and termination */
655 LogFlowFuncLeaveRC(rc);
656 return rc;
657}
658
659
660/**
661 *
662 */
663void VBoxNetLwipNAT::vboxNetLwipNATProcessXmit()
664{
665 int rc = VINF_SUCCESS;
666 INTNETIFSENDREQ SendReq;
667 SendReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
668 SendReq.Hdr.cbReq = sizeof(SendReq);
669 SendReq.pSession = g_pLwipNat->m_pSession;
670 SendReq.hIf = g_pLwipNat->m_hIf;
671 rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_SEND, 0, &SendReq.Hdr);
672 AssertRC(rc);
673}
674
675
676err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf)
677{
678 int rc = VINF_SUCCESS;
679 err_t rcLwip = ERR_OK;
680 AssertPtrReturn(pNetif, ERR_ARG);
681 AssertPtrReturn(pPBuf, ERR_ARG);
682 AssertReturn((void *)g_pLwipNat == pNetif->state, ERR_ARG);
683 LogFlowFunc(("ENTER: pNetif[%c%c%d], pPbuf:%p\n",
684 pNetif->name[0],
685 pNetif->name[1],
686 pNetif->num,
687 pPBuf));
688
689 /*
690 * We're on the lwip thread ...
691 * try accure Xmit lock (actually we DO accure the lock ... )
692 * 1. we've entered csXmit so we should create frame
693 * 1.a. Frame creation success see 2.
694 * 1.b. (hm ... what about queue processing in place)
695 * 1.c. 2nd attempt create frame
696 * 1.d. Unlock the Xmit
697 * 1.e. goto BUSY.1
698 * 2. Copy pbuf to the frame
699 * 3. Send
700 * 4. leave csXmit & return.
701 *
702 * @todo: perhaps we can use it for optimization,
703 * e.g. drop UDP and reoccure lock on TCP NOTE: now BUSY is unachievable!
704 * Otherwise (BUSY)
705 * 1. Unbuffered (drop)
706 * (buffered)
707 * 1. Copy pbuf to entermediate buffer.
708 * 2. Add call buffer to the queue
709 * 3. return.
710 */
711 /* see p.1 */
712 rc = VINF_SUCCESS;
713 PINTNETHDR pHdr = NULL;
714 uint8_t *pu8Frame = NULL;
715 int offFrame = 0;
716 int idxSg = 0;
717 struct pbuf *pPBufPtr = pPBuf;
718 /* Allocate frame, and pad it if required. */
719 rc = IntNetRingAllocateFrame(&g_pLwipNat->m_pIfBuf->Send, pPBuf->tot_len, &pHdr, (void **)&pu8Frame);
720 if (RT_SUCCESS(rc))
721 {
722 /* see p. 2 */
723 while (pPBufPtr)
724 {
725 memcpy(&pu8Frame[offFrame], pPBufPtr->payload, pPBufPtr->len);
726 offFrame += pPBufPtr->len;
727 pPBufPtr = pPBufPtr->next;
728 }
729 }
730 if (RT_FAILURE(rc))
731 {
732 /* Could it be that some frames are still in the ring buffer */
733 /* 1.c */
734 AssertMsgFailed(("Debug Me!"));
735 }
736
737 /* Commit - what really this function do */
738 IntNetRingCommitFrameEx(&g_pLwipNat->m_pIfBuf->Send, pHdr, pPBuf->tot_len);
739
740 g_pLwipNat->vboxNetLwipNATProcessXmit();
741
742 AssertRCReturn(rc, ERR_IF);
743 LogFlowFunc(("LEAVE: %d\n", rcLwip));
744 return rcLwip;
745}
746
747
748VBoxNetLwipNAT::VBoxNetLwipNAT()
749{
750 LogFlowFuncEnter();
751
752 m_ProxyOptions.ipv6_enabled = 0;
753 m_ProxyOptions.ipv6_defroute = 0;
754 m_ProxyOptions.tftp_root = NULL;
755 m_ProxyOptions.src4 = NULL;
756 m_ProxyOptions.src6 = NULL;
757 memset(&m_src4, 0, sizeof(m_src4));
758 memset(&m_src6, 0, sizeof(m_src6));
759 m_src4.sin_family = AF_INET;
760 m_src6.sin6_family = AF_INET6;
761#if HAVE_SA_LEN
762 m_src4.sin_len = sizeof(m_src4);
763 m_src6.sin6_len = sizeof(m_src6);
764#endif
765
766 m_LwipNetIf.name[0] = 'N';
767 m_LwipNetIf.name[1] = 'T';
768 m_MacAddress.au8[0] = 0x52;
769 m_MacAddress.au8[1] = 0x54;
770 m_MacAddress.au8[2] = 0;
771 m_MacAddress.au8[3] = 0x12;
772 m_MacAddress.au8[4] = 0x35;
773 m_MacAddress.au8[5] = 0;
774 m_Ipv4Address.u = RT_MAKE_U32_FROM_U8( 10, 0, 2, 2); // NB: big-endian
775 m_Ipv4Netmask.u = RT_H2N_U32_C(0xffffff00);
776
777 fDontLoadRulesOnStartup = false;
778
779 for(unsigned int i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i)
780 m_vecOptionDefs.push_back(&g_aGetOptDef[i]);
781
782 m_enmTrunkType = kIntNetTrunkType_SrvNat;
783
784 LogFlowFuncLeave();
785}
786
787
788VBoxNetLwipNAT::~VBoxNetLwipNAT()
789{
790 if (m_ProxyOptions.tftp_root != NULL)
791 {
792 RTStrFree((char *)m_ProxyOptions.tftp_root);
793 }
794}
795
796
797int VBoxNetLwipNAT::natServicePfRegister(NATSEVICEPORTFORWARDRULE& natPf)
798{
799 int lrc = 0;
800 int rc = VINF_SUCCESS;
801 int socketSpec = SOCK_STREAM;
802 char *pszHostAddr;
803 int sockFamily = (natPf.Pfr.fPfrIPv6 ? PF_INET6 : PF_INET);
804
805 switch(natPf.Pfr.iPfrProto)
806 {
807 case IPPROTO_TCP:
808 socketSpec = SOCK_STREAM;
809 break;
810 case IPPROTO_UDP:
811 socketSpec = SOCK_DGRAM;
812 break;
813 default:
814 return VERR_IGNORED; /* Ah, just ignore the garbage */
815 }
816
817 pszHostAddr = natPf.Pfr.aszPfrHostAddr;
818
819 /* XXX: workaround for inet_pton and an empty ipv4 address
820 * in rule declaration.
821 */
822 if ( sockFamily == PF_INET
823 && pszHostAddr[0] == 0)
824 pszHostAddr = (char *)"0.0.0.0"; /* XXX: fix it! without type cast */
825
826
827 lrc = fwspec_set(&natPf.FWSpec,
828 sockFamily,
829 socketSpec,
830 pszHostAddr,
831 natPf.Pfr.u16PfrHostPort,
832 natPf.Pfr.aszPfrGuestAddr,
833 natPf.Pfr.u16PfrGuestPort);
834
835 AssertReturn(!lrc, VERR_IGNORED);
836
837 fwspec *pFwCopy = (fwspec *)RTMemAllocZ(sizeof(fwspec));
838 AssertPtrReturn(pFwCopy, VERR_IGNORED);
839
840 /*
841 * We need pass the copy, because we can't be sure
842 * how much this pointer will be valid in LWIP environment.
843 */
844 memcpy(pFwCopy, &natPf.FWSpec, sizeof(fwspec));
845
846 lrc = portfwd_rule_add(pFwCopy);
847
848 AssertReturn(!lrc, VERR_IGNORED);
849
850 return VINF_SUCCESS;
851}
852
853
854int VBoxNetLwipNAT::natServiceProcessRegisteredPf(VECNATSERVICEPF& vecRules){
855 ITERATORNATSERVICEPF it;
856 for (it = vecRules.begin();
857 it != vecRules.end(); ++it)
858 {
859 int rc = natServicePfRegister((*it));
860 if (RT_FAILURE(rc))
861 {
862 LogRel(("PF: %s is ignored\n", (*it).Pfr.aszPfrName));
863 continue;
864 }
865 }
866 return VINF_SUCCESS;
867}
868
869
870int VBoxNetLwipNAT::init()
871{
872 com::Bstr bstr;
873 int rc = VINF_SUCCESS;
874 LogFlowFuncEnter();
875
876
877 /* virtualbox initialized in super class */
878
879 HRESULT hrc;
880 hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(),
881 net.asOutParam());
882 AssertComRCReturn(hrc, VERR_NOT_FOUND);
883
884 BOOL fIPv6Enabled = FALSE;
885 hrc = net->COMGETTER(IPv6Enabled)(&fIPv6Enabled);
886 AssertComRCReturn(hrc, VERR_NOT_FOUND);
887
888 BOOL fIPv6DefaultRoute = FALSE;
889 if (fIPv6Enabled)
890 {
891 hrc = net->COMGETTER(AdvertiseDefaultIPv6RouteEnabled)(&fIPv6DefaultRoute);
892 AssertComRCReturn(hrc, VERR_NOT_FOUND);
893 }
894
895 m_ProxyOptions.ipv6_enabled = fIPv6Enabled;
896 m_ProxyOptions.ipv6_defroute = fIPv6DefaultRoute;
897
898#if !defined(RT_OS_WINDOWS)
899 /* XXX: Temporaly disabled this code on Windows for further debugging */
900 ComPtr<IEventSource> pES;
901
902 hrc = net->COMGETTER(EventSource)(pES.asOutParam());
903 AssertComRC(hrc);
904
905 ComObjPtr<NATNetworkListenerImpl> listener;
906 hrc = listener.createObject();
907 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
908
909 hrc = listener->init(new NATNetworkListener(), this);
910 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
911
912 com::SafeArray<VBoxEventType_T> events;
913 events.push_back(VBoxEventType_OnNATNetworkPortForward);
914 events.push_back(VBoxEventType_OnNATNetworkSetting);
915
916 hrc = pES->RegisterListener(listener, ComSafeArrayAsInParam(events), true);
917 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);
918
919 m_listener = listener;
920#endif
921
922 com::Bstr bstrSourceIp4Key = com::BstrFmt("NAT/%s/SourceIp4",m_Network.c_str());
923 com::Bstr bstrSourceIpX;
924 RTNETADDRIPV4 addr;
925 hrc = virtualbox->GetExtraData(bstrSourceIp4Key.raw(), bstrSourceIpX.asOutParam());
926 if (SUCCEEDED(hrc))
927 {
928 rc = RTNetStrToIPv4Addr(com::Utf8Str(bstrSourceIpX).c_str(), &addr);
929 if (RT_SUCCESS(rc))
930 {
931 RT_ZERO(m_src4);
932
933 m_src4.sin_addr.s_addr = addr.u;
934 m_ProxyOptions.src4 = &m_src4;
935
936 bstrSourceIpX.setNull();
937 }
938 }
939
940 if (!fDontLoadRulesOnStartup)
941 {
942 /* XXX: extract function and do not duplicate */
943 com::SafeArray<BSTR> rules;
944 hrc = net->COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(rules));
945 Assert(SUCCEEDED(hrc));
946
947 size_t idxRules = 0;
948 for (idxRules = 0; idxRules < rules.size(); ++idxRules)
949 {
950 Log(("%d-rule: %ls\n", idxRules, rules[idxRules]));
951 NATSEVICEPORTFORWARDRULE Rule;
952 RT_ZERO(Rule);
953 rc = netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), 0, &Rule.Pfr);
954 AssertRC(rc);
955 m_vecPortForwardRule4.push_back(Rule);
956 }
957
958 rules.setNull();
959 hrc = net->COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(rules));
960 Assert(SUCCEEDED(hrc));
961
962 for (idxRules = 0; idxRules < rules.size(); ++idxRules)
963 {
964 Log(("%d-rule: %ls\n", idxRules, rules[idxRules]));
965 NATSEVICEPORTFORWARDRULE Rule;
966 netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), 1, &Rule.Pfr);
967 m_vecPortForwardRule6.push_back(Rule);
968 }
969 } /* if (!fDontLoadRulesOnStartup) */
970
971 com::SafeArray<BSTR> strs;
972 int count_strs;
973 hrc = net->COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs));
974 if ( SUCCEEDED(hrc)
975 && (count_strs = strs.size()))
976 {
977 unsigned int j = 0;
978 int i;
979
980 for (i = 0; i < count_strs && j < RT_ELEMENTS(m_lo2off); ++i)
981 {
982 char aszAddr[17];
983 RTNETADDRIPV4 ip4addr;
984 char *pszTerm;
985 uint32_t u32Off;
986 com::Utf8Str strLo2Off(strs[i]);
987 const char *pszLo2Off = strLo2Off.c_str();
988
989 RT_ZERO(aszAddr);
990
991 pszTerm = RTStrStr(pszLo2Off, "=");
992
993 if ( !pszTerm
994 || (pszTerm - pszLo2Off) >= 17)
995 continue;
996
997 memcpy(aszAddr, pszLo2Off, (pszTerm - pszLo2Off));
998 rc = RTNetStrToIPv4Addr(aszAddr, &ip4addr);
999 if (RT_FAILURE(rc))
1000 continue;
1001
1002 u32Off = RTStrToUInt32(pszTerm + 1);
1003 if (u32Off == 0)
1004 continue;
1005
1006 ip4_addr_set_u32(&m_lo2off[j].loaddr, ip4addr.u);
1007 m_lo2off[j].off = u32Off;
1008 ++j;
1009 }
1010
1011 m_loOptDescriptor.lomap = m_lo2off;
1012 m_loOptDescriptor.num_lomap = j;
1013 m_ProxyOptions.lomap_desc = &m_loOptDescriptor;
1014 }
1015
1016 hrc = virtualbox->COMGETTER(HomeFolder)(bstr.asOutParam());
1017 AssertComRCReturn(hrc, VERR_NOT_FOUND);
1018 if (!bstr.isEmpty())
1019 {
1020 com::Utf8Str strTftpRoot(com::Utf8StrFmt("%ls%c%s",
1021 bstr.raw(), RTPATH_DELIMITER, "TFTP"));
1022 char *pszStrTemp; // avoid const char ** vs char **
1023 rc = RTStrUtf8ToCurrentCP(&pszStrTemp, strTftpRoot.c_str());
1024 AssertRC(rc);
1025 m_ProxyOptions.tftp_root = pszStrTemp;
1026 }
1027
1028 /* end of COM initialization */
1029
1030 rc = RTSemEventCreate(&hSemSVC);
1031 AssertRCReturn(rc, rc);
1032
1033 rc = RTReqQueueCreate(&hReqIntNet);
1034 AssertRCReturn(rc, rc);
1035
1036 g_pLwipNat->tryGoOnline();
1037 vboxLwipCoreInitialize(VBoxNetLwipNAT::onLwipTcpIpInit, this);
1038
1039 rc = RTThreadCreate(&g_pLwipNat->hThrIntNetRecv, /* thread handle*/
1040 VBoxNetLwipNAT::intNetThreadRecv, /* routine */
1041 NULL, /* user data */
1042 128 * _1K, /* stack size */
1043 RTTHREADTYPE_IO, /* type */
1044 0, /* flags, @todo: waitable ?*/
1045 "INTNET-RECV");
1046 AssertRCReturn(rc,rc);
1047
1048
1049
1050 LogFlowFuncLeaveRC(rc);
1051 return rc;
1052}
1053
1054
1055int VBoxNetLwipNAT::parseOpt(int rc, const RTGETOPTUNION& Val)
1056{
1057 switch (rc)
1058 {
1059 case 'p':
1060 case 'P':
1061 {
1062 NATSEVICEPORTFORWARDRULE Rule;
1063 VECNATSERVICEPF& rules = (rc == 'P'?
1064 m_vecPortForwardRule6
1065 : m_vecPortForwardRule4);
1066
1067 fDontLoadRulesOnStartup = true;
1068
1069 RT_ZERO(Rule);
1070
1071 int irc = netPfStrToPf(Val.psz, (rc == 'P'), &Rule.Pfr);
1072 rules.push_back(Rule);
1073 return VINF_SUCCESS;
1074 }
1075 default:;
1076 }
1077 return VERR_NOT_FOUND;
1078}
1079
1080
1081int VBoxNetLwipNAT::run()
1082{
1083
1084 while(true)
1085 {
1086 RTSemEventWait(g_pLwipNat->hSemSVC, RT_INDEFINITE_WAIT);
1087 }
1088
1089 vboxLwipCoreFinalize(VBoxNetLwipNAT::onLwipTcpIpFini, this);
1090
1091 /* @todo: clean up of port-forward rules */
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