Changeset 24063 in vbox for trunk/src/VBox
- Timestamp:
- Oct 26, 2009 3:42:53 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/slirp.c
r24062 r24063 1525 1525 } 1526 1526 1527 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 1528 void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len) 1529 #else 1527 1530 void slirp_input(PNATState pData, void *pvArg) 1531 #endif 1528 1532 { 1529 1533 struct mbuf *m; 1530 1534 int proto; 1531 1535 static bool fWarnedIpv6; 1536 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 1537 struct ethhdr *eh = (struct ethhdr*)pkt; 1538 int size = 0; 1539 #else 1532 1540 struct ethhdr *eh; 1533 1541 #endif 1542 1543 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 1534 1544 m = (struct mbuf *)pvArg; 1535 1545 if (m->m_len < ETH_HLEN) … … 1541 1551 eh = mtod(m, struct ethhdr *); 1542 1552 proto = ntohs(eh->h_proto); 1553 #else 1554 Log2(("NAT: slirp_input %d\n", pkt_len)); 1555 if (pkt_len < ETH_HLEN) 1556 { 1557 LogRel(("NAT: packet having size %d has been ingnored\n", pkt_len)); 1558 return; 1559 } 1560 Log4(("NAT: in:%R[ether]->%R[ether]\n", &eh->h_source, &eh->h_dest)); 1561 1562 if (memcmp(eh->h_source, special_ethaddr, ETH_ALEN) == 0) 1563 { 1564 /* @todo vasily: add ether logging routine in debug.c */ 1565 Log(("NAT: packet was addressed to other MAC\n")); 1566 RTMemFree((void *)pkt); 1567 return; 1568 } 1569 1570 if (pkt_len < MSIZE) 1571 { 1572 size = MCLBYTES; 1573 } 1574 else if (pkt_len < MCLBYTES) 1575 { 1576 size = MCLBYTES; 1577 } 1578 else if(pkt_len < MJUM9BYTES) 1579 { 1580 size = MJUM9BYTES; 1581 } 1582 else if (pkt_len < MJUM16BYTES) 1583 { 1584 size = MJUM16BYTES; 1585 } 1586 else 1587 { 1588 AssertMsgFailed(("Unsupported size")); 1589 } 1590 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size); 1591 if (!m) 1592 { 1593 LogRel(("NAT: can't allocate new mbuf\n")); 1594 RTMemFree((void *)pkt); 1595 return; 1596 } 1597 1598 m->m_len = pkt_len ; 1599 memcpy(m->m_data, pkt, pkt_len); 1600 proto = ntohs(*(uint16_t *)(pkt + 12)); 1601 #endif 1543 1602 /* Note: we add to align the IP header */ 1544 1603 … … 1561 1620 m->m_pkthdr.header = mtod(m, void *); 1562 1621 #endif 1622 #if 1 1563 1623 if ( pData->fmbuf_water_line 1564 1624 && pData->fmbuf_water_warn_sent == 0 … … 1569 1629 pData->tsmbuf_water_warn_sent = curtime; 1570 1630 } 1631 #endif 1571 1632 ip_input(pData, m); 1572 1633 break; … … 1584 1645 break; 1585 1646 } 1647 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 1648 RTMemFree((void *)pkt); 1649 #endif 1586 1650 } 1587 1651 … … 2043 2107 #endif 2044 2108 if_encap(pData, ETH_P_ARP, m, ETH_ENCAP_URG); 2109 Log(("NAT: ARP request sent\n")); 2045 2110 } 2046 2111
Note:
See TracChangeset
for help on using the changeset viewer.