VirtualBox

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

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

VBoxNetLwipNAT::HandleEvent: set NATSEVICEPORTFORWARDRULE::Pfr::fPfrIPv6

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