Changeset 22897 in vbox
- Timestamp:
- Sep 10, 2009 7:18:07 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r22576 r22897 487 487 register struct icmp *icp; 488 488 register struct mbuf *m; 489 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 490 uint8_t *buf; /*(vvl) probably should be used mbuf of corresponded size instead*/ 491 #endif 489 492 490 493 DEBUG_CALL("icmp_error"); 491 494 DEBUG_ARG("msrc = %lx", (long )msrc); 492 495 DEBUG_ARG("msrc_len = %d", msrc ? msrc->m_len : 0); 496 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 497 M_ASSERTPKTHDR(msrc); 498 #endif 493 499 494 500 if (type!=ICMP_UNREACH && type!=ICMP_TIMXCEED) … … 524 530 } 525 531 532 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 526 533 /* make a copy */ 527 534 if (!(m = m_get(pData))) … … 537 544 memcpy(m->m_data, msrc->m_data, msrc->m_len); 538 545 m->m_len = msrc->m_len; /* copy msrc to m */ 546 #else 547 if (!(m = m_gethdr(pData, M_DONTWAIT, MT_HEADER))) 548 goto end_error; /* get mbuf */ 549 if (m_append(pData, m, m_length(msrc, NULL), mtod(msrc, const char *)) == 0) 550 { 551 m_freem(pData, m); 552 goto end_error; 553 } 554 m->m_pkthdr.header = mtod(m, void *); 555 #endif 539 556 540 557 /* make the header of the reply packet */ … … 543 560 544 561 /* fill in icmp */ 562 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 545 563 m->m_data += hlen; 546 564 m->m_len -= hlen; 565 #else 566 m_adj(m, hlen); 567 #endif 547 568 548 569 icp = mtod(m, struct icmp *); … … 553 574 s_ip_len = ICMP_MAXDATALEN; 554 575 576 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 555 577 m->m_len = ICMP_MINLEN + s_ip_len; /* 8 bytes ICMP header */ 578 #else 579 m_adj(m, ICMP_MINLEN); 580 #endif 556 581 557 582 /* min. size = 8+sizeof(struct ip)+8 */ … … 562 587 icp->icmp_seq = 0; 563 588 589 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 564 590 memcpy(&icp->icmp_ip, msrc->m_data, s_ip_len); /* report the ip packet */ 591 #else 592 buf = RTMemAlloc(s_ip_len); 593 if (buf == NULL) 594 { 595 m_free(pData, m); 596 LogRel(("NAT:ICMP: can't allocate intermediate buffer, icmp error wasn't sent\n")); 597 goto end_error; 598 } 599 m_copydata(msrc, 0, s_ip_len, buf); 600 m_append(pData, m, s_ip_len, buf); 601 #endif 565 602 HTONS(icp->icmp_ip.ip_len); 566 603 HTONS(icp->icmp_ip.ip_id); … … 577 614 message_len = ICMP_MAXDATALEN; 578 615 cpnt = (char *)m->m_data+m->m_len; 616 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 579 617 memcpy(cpnt, message, message_len); 580 618 m->m_len += message_len; 619 #else 620 m_append(pData, m, message_len, message); 621 #endif 581 622 } 582 623 #endif … … 585 626 icp->icmp_cksum = cksum(m, m->m_len); 586 627 628 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 587 629 m->m_data -= hlen; 588 630 m->m_len += hlen; 631 #endif 589 632 590 633 /* fill in ip */
Note:
See TracChangeset
for help on using the changeset viewer.