Changeset 97071 in vbox for trunk/src/VBox/NetworkServices/Dhcpd
- Timestamp:
- Oct 10, 2022 4:30:56 PM (2 years ago)
- Location:
- trunk/src/VBox/NetworkServices/Dhcpd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/Dhcpd/Makefile.kmk
r96407 r97071 65 65 VBoxNetDHCP_DEFS = KBUILD_TYPE=\"$(KBUILD_TYPE)\" 66 66 endif 67 #VBoxNetDHCP_DEFS = IPv6 67 VBoxNetDHCP_DEFS += \ 68 $(if $(VBOX_WITH_INTNET_SERVICE_IN_R3),VBOX_WITH_INTNET_SERVICE_IN_R3,) 69 70 #VBoxNetDHCP_DEFS += IPv6 68 71 #VBoxNetDHCP_DEFS.linux = WITH_VALGRIND 69 72 ifneq ($(KBUILD_TARGET),win) … … 75 78 endif 76 79 endif 80 VBoxNetDHCP_INCS += \ 81 ../NetLib 77 82 VBoxNetDHCP_SOURCES = \ 78 83 ClientId.cpp \ … … 85 90 Timestamp.cpp \ 86 91 VBoxNetDhcpd.cpp \ 92 ../NetLib/IntNetIfCtx.cpp \ 87 93 ../../Main/glue/VBoxLogRelCreate.cpp \ 88 94 ../../Main/glue/GetVBoxUserHomeDirectory.cpp \ -
trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
r96407 r97071 88 88 #endif 89 89 90 #include "IntNetIf.h" 91 90 92 struct delete_pbuf 91 93 { … … 97 99 98 100 99 #define CALL_VMMR0(op, req) \100 (SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, (op), 0, &(req).Hdr))101 102 103 101 class VBoxNetDhcpd 104 102 { … … 109 107 110 108 /* intnet plumbing */ 111 PSUPDRVSESSION m_pSession; 112 INTNETIFHANDLE m_hIf; 113 PINTNETBUF m_pIfBuf; 109 INTNETIFCTX m_hIf; 110 PINTNETBUF m_pIfBuf; 114 111 115 112 /* lwip stack connected to the intnet */ … … 178 175 VBoxNetDhcpd::VBoxNetDhcpd() 179 176 : m_pStderrReleaseLogger(NULL), 180 m_pSession(NIL_RTR0PTR),181 177 m_hIf(INTNET_HANDLE_INVALID), 182 178 m_pIfBuf(NULL), … … 185 181 m_Dhcp4Pcb(NULL) 186 182 { 187 int rc;188 189 183 logInitStderr(); 190 191 rc = r3Init();192 if (RT_FAILURE(rc))193 return;194 195 vmmInit();196 184 } 197 185 … … 200 188 { 201 189 ifClose(); 202 r3Fini();203 190 } 204 191 … … 241 228 242 229 243 int VBoxNetDhcpd::r3Init()244 {245 AssertReturn(m_pSession == NIL_RTR0PTR, VERR_GENERAL_FAILURE);246 247 int rc = SUPR3Init(&m_pSession);248 return rc;249 }250 251 252 void VBoxNetDhcpd::r3Fini()253 {254 if (m_pSession == NIL_RTR0PTR)255 return;256 257 SUPR3Term();258 m_pSession = NIL_RTR0PTR;259 }260 261 262 int VBoxNetDhcpd::vmmInit()263 {264 char szPathVMMR0[RTPATH_MAX];265 int rc = RTPathExecDir(szPathVMMR0, sizeof(szPathVMMR0));266 if (RT_SUCCESS(rc))267 rc = RTPathAppend(szPathVMMR0, sizeof(szPathVMMR0), "VMMR0.r0");268 if (RT_SUCCESS(rc))269 rc = SUPR3LoadVMM(szPathVMMR0, NULL /*pErrInfo*/);270 return rc;271 }272 273 274 230 int VBoxNetDhcpd::ifInit(const RTCString &strNetwork, 275 231 const RTCString &strTrunk, … … 298 254 INTNETTRUNKTYPE enmTrunkType) 299 255 { 300 AssertReturn(m_pSession != NIL_RTR0PTR, VERR_GENERAL_FAILURE); 301 AssertReturn(m_hIf == INTNET_HANDLE_INVALID, VERR_GENERAL_FAILURE); 302 303 INTNETOPENREQ OpenReq; 304 RT_ZERO(OpenReq); 305 306 OpenReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 307 OpenReq.Hdr.cbReq = sizeof(OpenReq); 308 OpenReq.pSession = m_pSession; 309 310 int rc = RTStrCopy(OpenReq.szNetwork, sizeof(OpenReq.szNetwork), strNetwork.c_str()); 311 AssertRCReturn(rc, rc); 312 313 rc = RTStrCopy(OpenReq.szTrunk, sizeof(OpenReq.szTrunk), strTrunk.c_str()); 314 AssertRCReturn(rc, rc); 315 316 if (enmTrunkType != kIntNetTrunkType_Invalid) 317 OpenReq.enmTrunkType = enmTrunkType; 318 else 319 OpenReq.enmTrunkType = kIntNetTrunkType_WhateverNone; 320 321 OpenReq.fFlags = 0; 322 OpenReq.cbSend = _128K; 323 OpenReq.cbRecv = _256K; 324 325 OpenReq.hIf = INTNET_HANDLE_INVALID; 326 327 rc = CALL_VMMR0(VMMR0_DO_INTNET_OPEN, OpenReq); 328 if (RT_FAILURE(rc)) 329 return rc; 330 331 m_hIf = OpenReq.hIf; 332 AssertReturn(m_hIf != INTNET_HANDLE_INVALID, VERR_GENERAL_FAILURE); 333 334 return VINF_SUCCESS; 256 AssertReturn(m_hIf == NULL, VERR_GENERAL_FAILURE); 257 258 if (enmTrunkType == kIntNetTrunkType_Invalid) 259 enmTrunkType = kIntNetTrunkType_WhateverNone; 260 261 return IntNetR3IfCtxCreate(&m_hIf, strNetwork.c_str(), enmTrunkType, 262 strTrunk.c_str(), _128K /*cbSend*/, _256K /*cbRecv*/, 263 0 /*fFlags*/); 335 264 } 336 265 … … 338 267 int VBoxNetDhcpd::ifGetBuf() 339 268 { 340 AssertReturn(m_pSession != NIL_RTR0PTR, VERR_GENERAL_FAILURE); 341 AssertReturn(m_hIf != INTNET_HANDLE_INVALID, VERR_GENERAL_FAILURE); 269 AssertReturn(m_hIf != NULL, VERR_GENERAL_FAILURE); 342 270 AssertReturn(m_pIfBuf == NULL, VERR_GENERAL_FAILURE); 343 271 344 INTNETIFGETBUFFERPTRSREQ GetBufferPtrsReq; 345 int rc; 346 347 GetBufferPtrsReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 348 GetBufferPtrsReq.Hdr.cbReq = sizeof(GetBufferPtrsReq); 349 GetBufferPtrsReq.pSession = m_pSession; 350 GetBufferPtrsReq.hIf = m_hIf; 351 352 GetBufferPtrsReq.pRing0Buf = NIL_RTR0PTR; 353 GetBufferPtrsReq.pRing3Buf = NULL; 354 355 rc = CALL_VMMR0(VMMR0_DO_INTNET_IF_GET_BUFFER_PTRS, GetBufferPtrsReq); 356 if (RT_FAILURE(rc)) 357 return rc; 358 359 m_pIfBuf = GetBufferPtrsReq.pRing3Buf; 272 return IntNetR3IfCtxQueryBufferPtr(m_hIf, &m_pIfBuf); 273 } 274 275 276 int VBoxNetDhcpd::ifActivate() 277 { 278 AssertReturn(m_hIf != NULL, VERR_GENERAL_FAILURE); 360 279 AssertReturn(m_pIfBuf != NULL, VERR_GENERAL_FAILURE); 361 280 362 return VINF_SUCCESS; 363 } 364 365 366 int VBoxNetDhcpd::ifActivate() 367 { 368 AssertReturn(m_pSession != NIL_RTR0PTR, VERR_GENERAL_FAILURE); 369 AssertReturn(m_hIf != INTNET_HANDLE_INVALID, VERR_GENERAL_FAILURE); 370 AssertReturn(m_pIfBuf != NULL, VERR_GENERAL_FAILURE); 371 372 INTNETIFSETACTIVEREQ ActiveReq; 373 int rc; 374 375 ActiveReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 376 ActiveReq.Hdr.cbReq = sizeof(ActiveReq); 377 ActiveReq.pSession = m_pSession; 378 ActiveReq.hIf = m_hIf; 379 380 ActiveReq.fActive = 1; 381 382 rc = CALL_VMMR0(VMMR0_DO_INTNET_IF_SET_ACTIVE, ActiveReq); 383 return rc; 281 return IntNetR3IfCtxSetActive(m_hIf, true /*fActive*/); 384 282 } 385 283 … … 398 296 * Wait for input: 399 297 */ 400 INTNETIFWAITREQ WaitReq; 401 WaitReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 402 WaitReq.Hdr.cbReq = sizeof(WaitReq); 403 WaitReq.pSession = m_pSession; 404 WaitReq.hIf = m_hIf; 405 WaitReq.cMillies = RT_INDEFINITE_WAIT; 406 int rc = CALL_VMMR0(VMMR0_DO_INTNET_IF_WAIT, WaitReq); 407 298 int rc = IntNetR3IfWait(m_hIf, RT_INDEFINITE_WAIT); 408 299 /* 409 300 * Process any pending input before we wait again: … … 424 315 int VBoxNetDhcpd::ifProcessInput() 425 316 { 426 AssertReturn(m_pSession != NIL_RTR0PTR, VERR_GENERAL_FAILURE); 427 AssertReturn(m_hIf != INTNET_HANDLE_INVALID, VERR_GENERAL_FAILURE); 317 AssertReturn(m_hIf != NULL, VERR_GENERAL_FAILURE); 428 318 AssertReturn(m_pIfBuf != NULL, VERR_GENERAL_FAILURE); 429 319 … … 544 434 int VBoxNetDhcpd::ifFlush() 545 435 { 546 INTNETIFSENDREQ SendReq; 547 548 SendReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 549 SendReq.Hdr.cbReq = sizeof(SendReq); 550 SendReq.pSession = m_pSession; 551 552 SendReq.hIf = m_hIf; 553 554 return CALL_VMMR0(VMMR0_DO_INTNET_IF_SEND, SendReq); 436 return IntNetR3IfSend(m_hIf); 555 437 } 556 438 … … 558 440 int VBoxNetDhcpd::ifClose() 559 441 { 560 if (m_hIf == INTNET_HANDLE_INVALID)442 if (m_hIf == NULL) 561 443 return VINF_SUCCESS; 562 444 563 INTNETIFCLOSEREQ CloseReq; 564 565 CloseReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 566 CloseReq.Hdr.cbReq = sizeof(CloseReq); 567 CloseReq.pSession = m_pSession; 568 569 CloseReq.hIf = m_hIf; 570 571 m_hIf = INTNET_HANDLE_INVALID; 572 m_pIfBuf = NULL; 573 574 CALL_VMMR0(VMMR0_DO_INTNET_IF_CLOSE, CloseReq); 575 return VINF_SUCCESS; 445 int rc = IntNetR3IfCtxDestroy(m_hIf); 446 m_hIf = NULL; 447 return rc; 576 448 } 577 449
Note:
See TracChangeset
for help on using the changeset viewer.