Changeset 16946 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Feb 19, 2009 1:06:30 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43102
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/slirp.c
r16937 r16946 626 626 #define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED) 627 627 #define CONN_CANFRCV(so) (((so)->so_state & (SS_FCANTRCVMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED) 628 #define UPD_NFDS(x) if (nfds < (x)) nfds = (x)628 #define UPD_NFDS(x) do { if (nfds < (x)) nfds = (x); } while (0) 629 629 630 630 /* 631 631 * curtime kept to an accuracy of 1ms 632 632 */ 633 static void updtime(PNATState pData) 634 { 633 635 #ifdef RT_OS_WINDOWS 634 static void updtime(PNATState pData)635 {636 636 struct _timeb tb; 637 637 638 638 _ftime(&tb); 639 curtime = (u_int)tb.time * (u_int)1000;639 curtime = (u_int)tb.time * (u_int)1000; 640 640 curtime += (u_int)tb.millitm; 641 } 642 #else 643 static void updtime(PNATState pData) 644 { 645 gettimeofday(&tt, 0); 646 647 curtime = (u_int)tt.tv_sec * (u_int)1000; 648 curtime += (u_int)tt.tv_usec / (u_int)1000; 649 650 if ((tt.tv_usec % 1000) >= 500) 651 curtime++; 652 } 653 #endif 641 #else 642 gettimeofday(&tt, 0); 643 644 curtime = (u_int)tt.tv_sec * (u_int)1000; 645 curtime += (u_int)tt.tv_usec / (u_int)1000; 646 647 if ((tt.tv_usec % 1000) >= 500) 648 curtime++; 649 #endif 650 } 654 651 655 652 #ifndef VBOX_WITH_SIMPLIFIED_SLIRP_SYNC … … 1211 1208 son = so->so_next; 1212 1209 } 1213 if ( 1210 if ( so->so_prev != &udb 1214 1211 && so->so_prev != NULL) 1215 1212 { … … 1265 1262 unsigned short h_proto; /* packet type ID field */ 1266 1263 }; 1264 AssertCompileSize(struct ethhdr, 14); 1267 1265 1268 1266 struct arphdr … … 1282 1280 unsigned char ar_tip[4]; /* target IP address */ 1283 1281 }; 1284 1285 static 1282 AssertCompileSize(struct arphdr, 28); 1283 1286 1284 #ifdef VBOX_WITH_SIMPLIFIED_SLIRP_SYNC 1287 void arp_input(PNATState pData, struct mbuf *m)1288 #else 1289 void arp_input(PNATState pData, const uint8_t *pkt, int pkt_len)1285 static void arp_input(PNATState pData, struct mbuf *m) 1286 #else 1287 static void arp_input(PNATState pData, const uint8_t *pkt, int pkt_len) 1290 1288 #endif 1291 1289 { -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r16562 r16946 297 297 #define _str(x) #x 298 298 #define str(x) _str(x) 299 299 300 #ifdef VBOX_WITH_SLIRP_MT 300 #define QSOCKET_LOCK(queue) \ 301 do { \ 302 int rc; \ 303 /* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \ 304 rc = RTCritSectEnter(&_X(queue) ## _mutex); \ 305 AssertReleaseRC(rc); \ 306 } while (0) 307 #define QSOCKET_UNLOCK(queue) \ 308 do { \ 309 int rc; \ 310 rc = RTCritSectLeave(&_X(queue) ## _mutex); \ 311 AssertReleaseRC(rc); \ 312 } while (0) 313 #define QSOCKET_LOCK_CREATE(queue) \ 314 do { \ 315 int rc; \ 316 rc = RTCritSectInit(&pData->queue ## _mutex); \ 317 AssertReleaseRC(rc); \ 318 } while (0) 319 #define QSOCKET_LOCK_DESTROY(queue) \ 320 do { \ 321 int rc = RTCritSectDelete(&pData->queue ## _mutex); \ 322 AssertReleaseRC(rc); \ 323 } while (0) 324 325 # define QSOCKET_FOREACH(so, sonext, label) \ 326 QSOCKET_LOCK(__X(queue_## label ## _label)); \ 327 (so) = (_X(queue_ ## label ## _label)).so_next; \ 328 QSOCKET_UNLOCK(__X(queue_## label ##_label)); \ 329 if ((so) != &(_X(queue_## label ## _label))) SOCKET_LOCK((so)); \ 330 for(;;) \ 331 { \ 332 if ((so) == &(_X(queue_## label ## _label))) \ 333 { \ 334 break; \ 335 } \ 336 Log2(("%s:%d Processing so:%R[natsock]\n", __FUNCTION__, __LINE__, (so))); 301 302 # define QSOCKET_LOCK(queue) \ 303 do { \ 304 int rc; \ 305 /* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \ 306 rc = RTCritSectEnter(&_X(queue) ## _mutex); \ 307 AssertReleaseRC(rc); \ 308 } while (0) 309 # define QSOCKET_UNLOCK(queue) \ 310 do { \ 311 int rc; \ 312 rc = RTCritSectLeave(&_X(queue) ## _mutex); \ 313 AssertReleaseRC(rc); \ 314 } while (0) 315 # define QSOCKET_LOCK_CREATE(queue) \ 316 do { \ 317 int rc; \ 318 rc = RTCritSectInit(&pData->queue ## _mutex); \ 319 AssertReleaseRC(rc); \ 320 } while (0) 321 # define QSOCKET_LOCK_DESTROY(queue) \ 322 do { \ 323 int rc = RTCritSectDelete(&pData->queue ## _mutex); \ 324 AssertReleaseRC(rc); \ 325 } while (0) 326 327 # define QSOCKET_FOREACH(so, sonext, label) \ 328 QSOCKET_LOCK(__X(queue_## label ## _label)); \ 329 (so) = (_X(queue_ ## label ## _label)).so_next; \ 330 QSOCKET_UNLOCK(__X(queue_## label ##_label)); \ 331 if ((so) != &(_X(queue_## label ## _label))) SOCKET_LOCK((so)); \ 332 for(;;) \ 333 { \ 334 if ((so) == &(_X(queue_## label ## _label))) \ 335 { \ 336 break; \ 337 } \ 338 Log2(("%s:%d Processing so:%R[natsock]\n", __FUNCTION__, __LINE__, (so))); 337 339 338 340 # define CONTINUE_NO_UNLOCK(label) goto loop_end_ ## label ## _mt_nounlock … … 360 362 (so) = (sonext) 361 363 362 # define DO_TCP_OUTPUT(data, sotcb)\363 do {\364 PRTREQ pReq = NULL;\365 int rc;\366 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL);\367 AssertReleaseRC(rc);\368 pReq->u.Internal.pfn = (PFNRT)tcp_output;\369 pReq->u.Internal.cArgs = 2;\370 pReq->u.Internal.aArgs[0] = (uintptr_t)(data);\371 pReq->u.Internal.aArgs[1] = (uintptr_t)(sotcb);\372 pReq->fFlags = RTREQFLAGS_VOID;\373 rc = RTReqQueue(pReq, 0);\374 if (RT_LIKELY(rc) == VERR_TIMEOUT)\375 {\376 SOCKET_UNLOCK(so);\377 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT);\378 AssertReleaseRC(rc);\379 SOCKET_LOCK(so);\380 RTReqFree(pReq);\381 }\382 else\383 AssertReleaseRC(rc);\364 # define DO_TCP_OUTPUT(data, sotcb) \ 365 do { \ 366 PRTREQ pReq = NULL; \ 367 int rc; \ 368 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 369 AssertReleaseRC(rc); \ 370 pReq->u.Internal.pfn = (PFNRT)tcp_output; \ 371 pReq->u.Internal.cArgs = 2; \ 372 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 373 pReq->u.Internal.aArgs[1] = (uintptr_t)(sotcb); \ 374 pReq->fFlags = RTREQFLAGS_VOID; \ 375 rc = RTReqQueue(pReq, 0); \ 376 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 377 { \ 378 SOCKET_UNLOCK(so); \ 379 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 380 AssertReleaseRC(rc); \ 381 SOCKET_LOCK(so); \ 382 RTReqFree(pReq); \ 383 } \ 384 else \ 385 AssertReleaseRC(rc); \ 384 386 } while(0) 385 387 386 #define DO_TCP_INPUT(data, mbuf, size, so) \ 387 do { \ 388 PRTREQ pReq = NULL; \ 389 int rc; \ 390 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 391 AssertReleaseRC(rc); \ 392 pReq->u.Internal.pfn = (PFNRT)tcp_input; \ 393 pReq->u.Internal.cArgs = 4; \ 394 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 395 pReq->u.Internal.aArgs[1] = (uintptr_t)(mbuf); \ 396 pReq->u.Internal.aArgs[2] = (uintptr_t)(size); \ 397 pReq->u.Internal.aArgs[3] = (uintptr_t)(so); \ 398 pReq->fFlags = RTREQFLAGS_VOID|RTREQFLAGS_NO_WAIT; \ 399 rc = RTReqQueue(pReq, 0); \ 400 AssertReleaseRC(rc); \ 401 } while(0) 402 403 #define DO_TCP_CONNECT(data, so) \ 404 do { \ 405 PRTREQ pReq = NULL; \ 406 int rc; \ 407 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 408 AssertReleaseRC(rc); \ 409 pReq->u.Internal.pfn = (PFNRT)tcp_connect; \ 410 pReq->u.Internal.cArgs = 2; \ 411 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 412 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 413 pReq->fFlags = RTREQFLAGS_VOID; \ 414 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 415 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 416 { \ 417 SOCKET_UNLOCK(so); \ 418 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 419 AssertReleaseRC(rc); \ 420 SOCKET_LOCK(so); \ 421 RTReqFree(pReq); \ 422 } \ 423 else \ 424 AssertReleaseRC(rc); \ 425 } while(0) 426 427 #define DO_SOREAD(ret, data, so, ifclose) \ 428 do { \ 429 PRTREQ pReq = NULL; \ 430 int rc; \ 431 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 432 AssertReleaseRC(rc); \ 433 pReq->u.Internal.pfn = (PFNRT)soread_queue; \ 434 pReq->u.Internal.cArgs = 4; \ 435 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 436 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 437 pReq->u.Internal.aArgs[2] = (uintptr_t)(ifclose); \ 438 pReq->u.Internal.aArgs[3] = (uintptr_t)&(ret); \ 439 pReq->fFlags = RTREQFLAGS_VOID; \ 440 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 441 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 442 { \ 443 SOCKET_UNLOCK(so); \ 444 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 445 AssertReleaseRC(rc); \ 446 SOCKET_LOCK(so); \ 447 RTReqFree(pReq); \ 448 } \ 449 else \ 450 AssertReleaseRC(rc); \ 451 } while(0) 452 453 #define DO_SOWRITE(ret, data, so) \ 454 do { \ 455 PRTREQ pReq = NULL; \ 456 int rc; \ 457 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 458 AssertReleaseRC(rc); \ 459 pReq->u.Internal.pfn = (PFNRT)sowrite; \ 460 pReq->u.Internal.cArgs = 2; \ 461 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 462 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 463 pReq->fFlags = RTREQFLAGS_RETURN_MASK; \ 464 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 465 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 466 { \ 467 SOCKET_UNLOCK(so); \ 468 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 469 SOCKET_LOCK(so); \ 470 ret = pReq->iStatus; \ 471 RTReqFree(pReq); \ 472 } \ 473 else \ 474 AssertReleaseRC(rc); \ 475 } while(0) 476 477 #define DO_SORECFROM(data, so) \ 478 do { \ 479 PRTREQ pReq = NULL; \ 480 int rc; \ 481 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 482 AssertReleaseRC(rc); \ 483 pReq->u.Internal.pfn = (PFNRT)sorecvfrom; \ 484 pReq->u.Internal.cArgs = 2; \ 485 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 486 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 487 pReq->fFlags = RTREQFLAGS_VOID; \ 488 rc = RTReqQueue(pReq, 0); \ 489 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 490 { \ 491 SOCKET_UNLOCK(so); \ 492 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 493 AssertReleaseRC(rc); \ 494 SOCKET_LOCK(so); \ 495 RTReqFree(pReq); \ 496 } \ 497 else \ 498 AssertReleaseRC(rc); \ 499 } while(0) 500 501 #define DO_UDP_DETACH(data, so, so_next) \ 502 do { \ 503 PRTREQ pReq = NULL; \ 504 int rc; \ 505 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 506 AssertReleaseRC(rc); \ 507 pReq->u.Internal.pfn = (PFNRT)udp_detach; \ 508 pReq->u.Internal.cArgs = 2; \ 509 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 510 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 511 pReq->fFlags = RTREQFLAGS_VOID; \ 512 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 513 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 514 { \ 515 SOCKET_UNLOCK(so); \ 516 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 517 AssertReleaseRC(rc); \ 518 if ((so_next) != &udb) SOCKET_LOCK((so_next)); \ 519 RTReqFree(pReq); \ 520 } \ 521 else \ 522 AssertReleaseRC(rc); \ 523 } while(0) 524 525 #define SOLOOKUP(so, label, src, sport, dst, dport) \ 526 do { \ 527 struct socket *sonxt; \ 528 (so) = NULL; \ 529 QSOCKET_FOREACH(so, sonxt, label) \ 530 /* { */ \ 531 if ( so->so_lport == (sport) \ 532 && so->so_laddr.s_addr == (src).s_addr \ 533 && so->so_faddr.s_addr == (dst).s_addr \ 534 && so->so_fport == (dport)) \ 535 { \ 536 if (sonxt != &__X(queue_ ## label ## _label)) \ 537 SOCKET_UNLOCK(sonxt); \ 538 break; /*so is locked*/ \ 388 # define DO_TCP_INPUT(data, mbuf, size, so) \ 389 do { \ 390 PRTREQ pReq = NULL; \ 391 int rc; \ 392 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 393 AssertReleaseRC(rc); \ 394 pReq->u.Internal.pfn = (PFNRT)tcp_input; \ 395 pReq->u.Internal.cArgs = 4; \ 396 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 397 pReq->u.Internal.aArgs[1] = (uintptr_t)(mbuf); \ 398 pReq->u.Internal.aArgs[2] = (uintptr_t)(size); \ 399 pReq->u.Internal.aArgs[3] = (uintptr_t)(so); \ 400 pReq->fFlags = RTREQFLAGS_VOID|RTREQFLAGS_NO_WAIT; \ 401 rc = RTReqQueue(pReq, 0); \ 402 AssertReleaseRC(rc); \ 403 } while(0) 404 405 # define DO_TCP_CONNECT(data, so) \ 406 do { \ 407 PRTREQ pReq = NULL; \ 408 int rc; \ 409 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 410 AssertReleaseRC(rc); \ 411 pReq->u.Internal.pfn = (PFNRT)tcp_connect; \ 412 pReq->u.Internal.cArgs = 2; \ 413 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 414 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 415 pReq->fFlags = RTREQFLAGS_VOID; \ 416 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 417 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 418 { \ 419 SOCKET_UNLOCK(so); \ 420 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 421 AssertReleaseRC(rc); \ 422 SOCKET_LOCK(so); \ 423 RTReqFree(pReq); \ 424 } \ 425 else \ 426 AssertReleaseRC(rc); \ 427 } while(0) 428 429 # define DO_SOREAD(ret, data, so, ifclose) \ 430 do { \ 431 PRTREQ pReq = NULL; \ 432 int rc; \ 433 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 434 AssertReleaseRC(rc); \ 435 pReq->u.Internal.pfn = (PFNRT)soread_queue; \ 436 pReq->u.Internal.cArgs = 4; \ 437 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 438 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 439 pReq->u.Internal.aArgs[2] = (uintptr_t)(ifclose); \ 440 pReq->u.Internal.aArgs[3] = (uintptr_t)&(ret); \ 441 pReq->fFlags = RTREQFLAGS_VOID; \ 442 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 443 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 444 { \ 445 SOCKET_UNLOCK(so); \ 446 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 447 AssertReleaseRC(rc); \ 448 SOCKET_LOCK(so); \ 449 RTReqFree(pReq); \ 450 } \ 451 else \ 452 AssertReleaseRC(rc); \ 453 } while(0) 454 455 # define DO_SOWRITE(ret, data, so) \ 456 do { \ 457 PRTREQ pReq = NULL; \ 458 int rc; \ 459 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 460 AssertReleaseRC(rc); \ 461 pReq->u.Internal.pfn = (PFNRT)sowrite; \ 462 pReq->u.Internal.cArgs = 2; \ 463 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 464 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 465 pReq->fFlags = RTREQFLAGS_RETURN_MASK; \ 466 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 467 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 468 { \ 469 SOCKET_UNLOCK(so); \ 470 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 471 SOCKET_LOCK(so); \ 472 ret = pReq->iStatus; \ 473 RTReqFree(pReq); \ 474 } \ 475 else \ 476 AssertReleaseRC(rc); \ 477 } while(0) 478 479 # define DO_SORECFROM(data, so) \ 480 do { \ 481 PRTREQ pReq = NULL; \ 482 int rc; \ 483 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 484 AssertReleaseRC(rc); \ 485 pReq->u.Internal.pfn = (PFNRT)sorecvfrom; \ 486 pReq->u.Internal.cArgs = 2; \ 487 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 488 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 489 pReq->fFlags = RTREQFLAGS_VOID; \ 490 rc = RTReqQueue(pReq, 0); \ 491 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 492 { \ 493 SOCKET_UNLOCK(so); \ 494 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 495 AssertReleaseRC(rc); \ 496 SOCKET_LOCK(so); \ 497 RTReqFree(pReq); \ 498 } \ 499 else \ 500 AssertReleaseRC(rc); \ 501 } while(0) 502 503 # define DO_UDP_DETACH(data, so, so_next) \ 504 do { \ 505 PRTREQ pReq = NULL; \ 506 int rc; \ 507 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \ 508 AssertReleaseRC(rc); \ 509 pReq->u.Internal.pfn = (PFNRT)udp_detach; \ 510 pReq->u.Internal.cArgs = 2; \ 511 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \ 512 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \ 513 pReq->fFlags = RTREQFLAGS_VOID; \ 514 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \ 515 if (RT_LIKELY(rc) == VERR_TIMEOUT) \ 516 { \ 517 SOCKET_UNLOCK(so); \ 518 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \ 519 AssertReleaseRC(rc); \ 520 if ((so_next) != &udb) SOCKET_LOCK((so_next)); \ 521 RTReqFree(pReq); \ 522 } \ 523 else \ 524 AssertReleaseRC(rc); \ 525 } while(0) 526 527 # define SOLOOKUP(so, label, src, sport, dst, dport) \ 528 do { \ 529 struct socket *sonxt; \ 530 (so) = NULL; \ 531 QSOCKET_FOREACH(so, sonxt, label) \ 532 /* { */ \ 533 if ( so->so_lport == (sport) \ 534 && so->so_laddr.s_addr == (src).s_addr \ 535 && so->so_faddr.s_addr == (dst).s_addr \ 536 && so->so_fport == (dport)) \ 537 { \ 538 if (sonxt != &__X(queue_ ## label ## _label)) \ 539 SOCKET_UNLOCK(sonxt); \ 540 break; /*so is locked*/ \ 541 } \ 542 LOOP_LABEL(so, sonxt, label); \ 539 543 } \ 540 LOOP_LABEL(so, sonxt, label); \ 541 } \ 542 } \ 543 }while (0) 544 545 #else 546 #define QSOCKET_LOCK(queue) do {} while (0) 547 #define QSOCKET_UNLOCK(queue) do {} while (0) 548 #define QSOCKET_LOCK_CREATE(queue) do {} while (0) 549 #define QSOCKET_LOCK_DESTROY(queue) do {} while (0) 550 # define QSOCKET_FOREACH(so, sonext, label) \ 551 for ((so) = __X(queue_ ## label ## _label).so_next; so != &(__X(queue_ ## label ## _label)); (so) = (sonext)) \ 552 { \ 553 (sonext) = (so)->so_next; 544 } \ 545 } while (0) 546 547 #else /* !VBOX_WITH_SLIRP_MT */ 548 549 # define QSOCKET_LOCK(queue) do {} while (0) 550 # define QSOCKET_UNLOCK(queue) do {} while (0) 551 # define QSOCKET_LOCK_CREATE(queue) do {} while (0) 552 # define QSOCKET_LOCK_DESTROY(queue) do {} while (0) 553 # define QSOCKET_FOREACH(so, sonext, label) \ 554 for ((so) = __X(queue_ ## label ## _label).so_next; \ 555 (so) != &(__X(queue_ ## label ## _label)); \ 556 (so) = (sonext)) \ 557 { \ 558 (sonext) = (so)->so_next; 554 559 # define CONTINUE(label) continue 555 560 # define CONTINUE_NO_UNLOCK(label) continue 556 561 # define LOOP_LABEL(label, so, sonext) /* empty*/ 557 #define DO_TCP_OUTPUT(data, sotcb) tcp_output((data), (sotcb)) 558 #define DO_TCP_INPUT(data, mbuf, size, so) tcp_input((data), (mbuf), (size), (so)) 559 #define DO_TCP_CONNECT(data, so) tcp_connect((data), (so)) 560 #define DO_SOREAD(ret, data, so, ifclose) do{(ret) = soread((data), (so), (ifclose));}while(0) 561 #define DO_SOWRITE(ret, data, so) do{(ret) = sowrite((data), (so));}while(0) 562 #define DO_SORECFROM(data, so) sorecvfrom((data), (so)) 563 #define SOLOOKUP(so, label, src, sport, dst, dport) \ 564 do { \ 565 (so) = solookup(&__X(queue_ ## label ## _label), (src), (sport), (dst), (dport)); \ 566 } while (0) 567 #define DO_UDP_DETACH(data, so, ignored) udp_detach((data), (so)) 568 #endif 562 # define DO_TCP_OUTPUT(data, sotcb) tcp_output((data), (sotcb)) 563 # define DO_TCP_INPUT(data, mbuf, size, so) tcp_input((data), (mbuf), (size), (so)) 564 # define DO_TCP_CONNECT(data, so) tcp_connect((data), (so)) 565 # define DO_SOREAD(ret, data, so, ifclose) \ 566 do { \ 567 (ret) = soread((data), (so), (ifclose)); \ 568 } while(0) 569 # define DO_SOWRITE(ret, data, so) \ 570 do { \ 571 (ret) = sowrite((data), (so)); \ 572 } while(0) 573 # define DO_SORECFROM(data, so) sorecvfrom((data), (so)) 574 # define SOLOOKUP(so, label, src, sport, dst, dport) \ 575 do { \ 576 (so) = solookup(&__X(queue_ ## label ## _label), (src), (sport), (dst), (dport)); \ 577 } while (0) 578 # define DO_UDP_DETACH(data, so, ignored) udp_detach((data), (so)) 579 580 #endif /* !VBOX_WITH_SLIRP_MT */ 569 581 570 582 #define TCP_OUTPUT(data, sotcb) DO_TCP_OUTPUT((data), (sotcb)) … … 575 587 #define SORECVFROM(data, so) DO_SORECFROM((data), (so)) 576 588 #define UDP_DETACH(data, so, so_next) DO_UDP_DETACH((data), (so), (so_next)) 589 577 590 #endif /* !_slirp_state_h_ */ -
trunk/src/VBox/Devices/Network/slirp/tcpip.h
r15093 r16946 46 46 struct tcphdr ti_t; /* tcp header */ 47 47 }; 48 AssertCompileSize(struct tcpiphdr, 40); 48 49 #define ti_next ti_i.ih_next 49 50 #define ti_prev ti_i.ih_prev -
trunk/src/VBox/Devices/Network/slirp/udp.c
r16938 r16946 708 708 709 709 so->s = socket(AF_INET,SOCK_DGRAM,0); 710 if (so->s == -1) 711 { 712 LogRel(("NAT: can't create datagram socket\n 710 if (so->s == -1) 711 { 712 LogRel(("NAT: can't create datagram socket\n")); 713 713 RTMemFree(so); 714 714 return NULL; -
trunk/src/VBox/Devices/Network/slirp/udp.h
r15054 r16946 54 54 uint16_t uh_sum; /* udp checksum */ 55 55 }; 56 AssertCompileSize(struct udphdr, 8); 56 57 57 58 /* … … 63 64 struct udphdr ui_u; /* udp header */ 64 65 }; 66 AssertCompileSize(struct udpiphdr, 28); 65 67 #define ui_next ui_i.ih_next 66 68 #define ui_prev ui_i.ih_prev
Note:
See TracChangeset
for help on using the changeset viewer.