Changeset 26404 in vbox
- Timestamp:
- Feb 10, 2010 10:32:37 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Makefile.kmk
r26222 r26404 826 826 Network/slirp/udp.c \ 827 827 Network/slirp/dnsproxy/hash.c \ 828 Network/slirp/tftp.c \ 828 829 Network/slirp/dnsproxy/dnsproxy.c 829 830 … … 837 838 else 838 839 # some notes dnsproxy will probably deprecate 839 # tftp.c is temporally out of global slirp section840 840 VBOX_SLIRP_SOURCES += \ 841 841 Network/slirp/mbuf.c \ 842 Network/slirp/cksum.c \ 843 Network/slirp/tftp.c 842 Network/slirp/cksum.c 844 843 endif 845 844 -
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r26309 r26404 310 310 311 311 slirp_ext_m_free(pThis->pNATState, pvArg); 312 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 313 RTMemFree(pu8Buf); 314 #endif 312 315 if (ASMAtomicDecU32(&pThis->cUrgPkt) == 0) 313 316 { … … 351 354 rc = RTCritSectLeave(&pThis->csDevAccess); 352 355 AssertRC(rc); 356 353 357 done_unlocked: 354 358 slirp_ext_m_free(pThis->pNATState, pvArg); 359 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 360 RTMemFree(pu8Buf); 361 #endif 355 362 ASMAtomicDecU32(&pThis->cPkt); 356 363 … … 369 376 Assert(pThis->enmLinkState == PDMNETWORKLINKSTATE_UP); 370 377 if (pThis->enmLinkState == PDMNETWORKLINKSTATE_UP) 371 slirp_input(pThis->pNATState, pvBuf);378 slirp_input(pThis->pNATState, (uint8_t *)pvBuf); 372 379 } 373 380 … … 399 406 400 407 /* @todo: Here we should get mbuf instead temporal buffer */ 401 #if 0 402 buf = RTMemAlloc(cb); 403 if (buf == NULL) 404 { 405 LogRel(("NAT: Can't allocate send buffer\n")); 406 return VERR_NO_MEMORY; 407 } 408 memcpy(buf, pvBuf, cb); 409 #else 408 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 410 409 void *pvmBuf = slirp_ext_m_get(pThis->pNATState); 411 410 Assert(pvmBuf); 412 411 slirp_ext_m_append(pThis->pNATState, pvmBuf, (uint8_t *)pvBuf, cb); 412 #else 413 void *pvmBuf = slirp_ext_m_get(pThis->pNATState, (uint8_t *)pvBuf, cb); 414 Assert(pvmBuf); 413 415 #endif 414 416 … … 966 968 "PassDomain\0TFTPPrefix\0BootFile\0Network" 967 969 "\0NextServer\0DNSProxy\0BindIP\0UseHostResolver\0" 968 #ifdef VBOX_WITH_SLIRP_BSD_MBUF969 970 "SlirpMTU\0" 970 #endif 971 "SocketRcvBuf\0SocketSndBuf\0TcpRcvSpace\0TcpSndSpace\0")) 971 "SockRcv\0SockSnd\0TcpRcv\0TcpSnd\0")) 972 972 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, 973 973 N_("Unknown NAT configuration option, only supports PassDomain," … … 1073 1073 } while(0) 1074 1074 1075 SLIRP_SET_TUNING_VALUE("Sock etRcvBuf", slirp_set_rcvbuf);1076 SLIRP_SET_TUNING_VALUE("Sock etSndBuf", slirp_set_sndbuf);1077 SLIRP_SET_TUNING_VALUE("TcpRcv Space", slirp_set_tcp_rcvspace);1078 SLIRP_SET_TUNING_VALUE("TcpSnd Space", slirp_set_tcp_sndspace);1075 SLIRP_SET_TUNING_VALUE("SockRcv", slirp_set_rcvbuf); 1076 SLIRP_SET_TUNING_VALUE("SockSnd", slirp_set_sndbuf); 1077 SLIRP_SET_TUNING_VALUE("TcpRcv", slirp_set_tcp_rcvspace); 1078 SLIRP_SET_TUNING_VALUE("TcpSnd", slirp_set_tcp_sndspace); 1079 1079 1080 1080 slirp_register_statistics(pThis->pNATState, pDrvIns); -
trunk/src/VBox/Devices/Network/slirp/dnsproxy/dnsproxy.c
r25265 r26404 100 100 ++removed_queries; 101 101 } 102 #else 102 #else /* VBOX */ 103 103 static void 104 104 timeout(PNATState pData, struct socket *so, void *arg) … … 154 154 m->m_len += req->nbyte; 155 155 ip->ip_src.s_addr = so->so_laddr.s_addr; 156 ip->ip_dst.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_DNS);156 ip->ip_dst.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_DNS); 157 157 udp->uh_dport = ntohs(53); 158 158 udp->uh_sport = so->so_lport; … … 169 169 } 170 170 } 171 #endif 171 #endif /* VBOX */ 172 172 173 173 /* do_query -- Called by the event loop when a packet arrives at our -
trunk/src/VBox/Devices/Network/slirp/ip_input.c
r25822 r26404 77 77 #else 78 78 struct m_tag *t; 79 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 80 { 79 if ((t = m_tag_find(m, PACKET_TAG_ALIAS, NULL)) != 0) 81 80 return (struct libalias *)&t[1]; 82 }83 81 #endif 84 82 -
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r25822 r26404 189 189 struct m_tag *t; 190 190 STAM_PROFILE_START(&pData->StatALIAS_output, b); 191 if ( t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0)191 if ((t = m_tag_find(m, PACKET_TAG_ALIAS, NULL)) != 0) 192 192 rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), 193 193 m_length(m, NULL)); … … 207 207 memcpy(eh->h_source, eth_dst, ETH_ALEN); 208 208 209 #ifdef VBOX_WITH_SLIRP_BSD_MBUF210 if_output(pData, so, m);211 #else212 209 if_encap(pData, ETH_P_IP, m, urg? ETH_ENCAP_URG : 0); 213 #endif214 210 goto done; 215 211 } … … 237 233 struct mbuf **mnext = &m->m_nextpkt; 238 234 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 239 uint8_t *buf; /* intermediate buffer we'll use for copy from orriginal packet*/235 char *buf; /* intermediate buffer we'll use for copy from orriginal packet */ 240 236 #endif 241 237 { … … 269 265 } 270 266 271 if ( t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0)267 if ((t = m_tag_find(m, PACKET_TAG_ALIAS, NULL)) != 0) 272 268 rcLa = LibAliasOut((struct libalias *)&t[1], tmpbuf, tmplen); 273 269 else … … 390 386 memcpy(eh->h_source, eth_dst, ETH_ALEN); 391 387 392 #ifdef VBOX_WITH_SLIRP_BSD_MBUF393 if_output(pData, so, m);394 #else395 388 if_encap(pData, ETH_P_IP, m, 0); 396 #endif397 389 } 398 390 else -
trunk/src/VBox/Devices/Network/slirp/libslirp.h
r25402 r26404 48 48 #endif /* !RT_OS_WINDOWS */ 49 49 50 #ifdef VBOX_WITH_SLIRP_BSD_MBUF51 void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len);52 #else53 50 void slirp_input(PNATState pData, void *pvData); 54 #endif55 51 void slirp_set_ethaddr_and_activate_port_forwarding(PNATState pData, const uint8_t *ethaddr, uint32_t GuestIP); 56 52 … … 123 119 void slirp_ext_m_append(PNATState pData, void *, uint8_t *, size_t); 124 120 void slirp_push_recv_thread(void *pvUser); 121 #else 122 void *slirp_ext_m_get(PNATState pData, uint8_t *, size_t); 123 void slirp_ext_m_free(PNATState pData, void *); 125 124 #endif 126 125 -
trunk/src/VBox/Devices/Network/slirp/mbuf.h
r23462 r26404 37 37 #ifndef _MBUF_H_ 38 38 #define _MBUF_H_ 39 39 40 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 40 41 /* #define M_BUF_DEBUG */ … … 157 158 158 159 #define MBUF_IP_HEADER(m) (caddr_t)(MBUF_HEAD(m) + if_maxlinkhdr) 159 #else 160 161 #else /* VBOX_WITH_SLIRP_BSD_MBUF */ 160 162 # include "bsd/sys/mbuf.h" 161 #endif 162 #endif 163 #endif /* VBOX_WITH_SLIRP_BSD_MBUF */ 164 165 #endif /* _MBUF_H_ */ 163 166 164 167 #if defined(M_BUF_DEBUG) && !defined(RT_OS_WINDOWS) -
trunk/src/VBox/Devices/Network/slirp/misc.c
r23369 r26404 130 130 uint32_t magic; 131 131 PNATState pData; /* to minimize changes in the rest of UMA emulation code */ 132 RTCRITSECT csZone; 132 133 const char *name; 133 134 size_t size; /* item size */ … … 150 151 { 151 152 struct item *it; 152 if ( (zone->max_items != 0 && zone->cur_items >= zone->max_items) 153 RTCritSectEnter(&zone->csZone); 154 if ( (zone->max_items != 0 && zone->cur_items >= zone->max_items) 153 155 || (zone->max_items == 0 && !LIST_EMPTY(&zone->free_items)) 154 )156 ) 155 157 { 156 158 /* … … 160 162 */ 161 163 if (LIST_EMPTY(&zone->free_items)) 164 { 165 RTCritSectLeave(&zone->csZone); 162 166 return NULL; 167 } 163 168 it = LIST_FIRST(&zone->free_items); 164 169 LIST_REMOVE(it, list); … … 166 171 goto allocated; 167 172 } 173 168 174 /*@todo 'Z' should be depend on flag */ 169 175 it = RTMemAllocZ(sizeof(struct item) + zone->size); … … 171 177 { 172 178 Log(("NAT: uma no memory")); 179 RTCritSectLeave(&zone->csZone); 173 180 return NULL; 174 181 } … … 181 188 if (zone->pfInit) 182 189 zone->pfInit(zone->pData, (void *)&it[1], zone->size, M_DONTWAIT); 190 RTCritSectLeave(&zone->csZone); 183 191 return (void *)&it[1]; 184 192 } … … 192 200 Assert(it->magic == ITEM_MAGIC); 193 201 zone = it->zone; 202 RTCritSectEnter(&zone->csZone); 194 203 Assert(zone->magic == ZONE_MAGIC); 195 204 LIST_REMOVE(it, list); 196 205 LIST_INSERT_HEAD(&zone->free_items, it, list); 206 zone->cur_items--; 207 RTCritSectLeave(&zone->csZone); 197 208 } 198 209 … … 212 223 zone->pfAlloc = slirp_uma_alloc; 213 224 zone->pfFree = slirp_uma_free; 225 RTCritSectInit(&zone->csZone); 214 226 return zone; 215 227 … … 239 251 zone->pfFree = slirp_uma_free; 240 252 zone->size = master->size; 253 RTCritSectInit(&zone->csZone); 241 254 return zone; 242 255 } … … 256 269 uint32_t *uma_find_refcnt(uma_zone_t zone, void *mem) 257 270 { 258 /*@todo ( r-vvl) this function supposed to work with special zone storing271 /*@todo (vvl) this function supposed to work with special zone storing 259 272 reference counters */ 260 273 struct item *it = (struct item *)mem; /* 1st element */ 274 Assert(mem != NULL); 261 275 Assert(zone->magic == ZONE_MAGIC); 262 276 /* for returning pointer to counter we need get 0 elemnt */ … … 270 284 if (zone->pfAlloc == NULL) 271 285 return NULL; 286 RTCritSectEnter(&zone->csZone); 272 287 mem = zone->pfAlloc(zone, zone->size, NULL, 0); 273 288 if (zone->pfCtor) 274 289 zone->pfCtor(zone->pData, mem, zone->size, args, M_DONTWAIT); 290 RTCritSectLeave(&zone->csZone); 275 291 return mem; 276 292 } … … 288 304 return; 289 305 Assert((mem)); 306 RTCritSectEnter(&zone->csZone); 290 307 it = &((struct item *)mem)[-1]; 291 308 if (it->magic != ITEM_MAGIC) … … 293 310 Log(("NAT:UMA: %p seems to be allocated on heap ... freeing\n", mem)); 294 311 RTMemFree(mem); 312 RTCritSectLeave(&zone->csZone); 295 313 return; 296 314 } … … 300 318 zone->pfDtor(zone->pData, mem, zone->size, flags); 301 319 zone->pfFree(mem, 0, 0); 320 RTCritSectLeave(&zone->csZone); 302 321 } 303 322 int uma_zone_exhausted_nolock(uma_zone_t zone) … … 320 339 return NULL; 321 340 } 322 #endif 341 342 void *slirp_ext_m_get(PNATState pData, uint8_t *pkt, size_t pkt_len) 343 { 344 struct mbuf *m; 345 size_t size = MCLBYTES; 346 if (pkt_len < MSIZE) 347 size = MCLBYTES; 348 else if (pkt_len < MCLBYTES) 349 size = MCLBYTES; 350 else if (pkt_len < MJUM9BYTES) 351 size = MJUM9BYTES; 352 else if (pkt_len < MJUM16BYTES) 353 size = MJUM16BYTES; 354 else 355 AssertMsgFailed(("Unsupported size")); 356 357 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size); 358 m->m_len = pkt_len ; 359 memcpy(m->m_data, pkt, pkt_len); 360 return (void *)m; 361 } 362 363 void slirp_ext_m_free(PNATState pData, void *arg) 364 { 365 struct mbuf *m = (struct mbuf *)arg; 366 m_free(pData, m); 367 } 368 369 static void zone_destroy(uma_zone_t zone) 370 { 371 RTCritSectDelete(&zone->csZone); 372 RTMemFree(zone); 373 } 374 void m_fini(PNATState pData) 375 { 376 zone_destroy(pData->zone_mbuf); 377 zone_destroy(pData->zone_clust); 378 zone_destroy(pData->zone_pack); 379 zone_destroy(pData->zone_jumbop); 380 zone_destroy(pData->zone_jumbo9); 381 zone_destroy(pData->zone_jumbo16); 382 /*@todo do finalize here.*/ 383 } 384 #endif /* VBOX_WITH_SLIRP_BSD_MBUF */ -
trunk/src/VBox/Devices/Network/slirp/misc.h
r22943 r26404 108 108 109 109 void slirp_null_arg_free(void *, void *); 110 #endif 110 void m_fini(PNATState pData); 111 #endif /* VBOX_WITH_SLIRP_BSD_MBUF */ 111 112 112 113 #endif -
trunk/src/VBox/Devices/Network/slirp/sbuf.c
r23369 r26404 79 79 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 80 80 int mlen = 0; 81 uint8_t *buf = NULL;81 caddr_t buf = NULL; 82 82 #endif 83 83 -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r25822 r26404 833 833 so->so_poll_index = -1; 834 834 #endif 835 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 835 836 if (pData->fmbuf_water_line == 1) 836 837 { … … 840 841 pData->fmbuf_water_line = 0; 841 842 } 842 # ifndef RT_OS_WINDOWS843 # ifndef RT_OS_WINDOWS 843 844 poll_index = 0; 844 # endif845 # endif 845 846 goto done; 846 847 } 848 #endif /* !VBOX_WITH_SLIRP_BSD_MBUF */ 847 849 STAM_COUNTER_INC(&pData->StatTCP); 848 850 … … 916 918 /* { */ 917 919 920 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 918 921 if (pData->fmbuf_water_line == 1) 919 922 { … … 923 926 pData->fmbuf_water_warn_sent = 0; 924 927 } 925 # ifndef RT_OS_WINDOWS928 # ifndef RT_OS_WINDOWS 926 929 poll_index = 0; 927 # endif930 # endif 928 931 goto done; 929 932 } 933 #endif /* !VBOX_WITH_SLIRP_BSD_MBUF */ 930 934 STAM_COUNTER_INC(&pData->StatUDP); 931 935 #if !defined(RT_OS_WINDOWS) … … 1056 1060 QSOCKET_FOREACH(so, so_next, tcp) 1057 1061 /* { */ 1062 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 1058 1063 if (pData->fmbuf_water_line == 1) 1059 1064 { … … 1065 1070 goto done; 1066 1071 } 1072 #endif 1067 1073 1068 1074 #ifdef VBOX_WITH_SLIRP_MT … … 1353 1359 QSOCKET_FOREACH(so, so_next, udp) 1354 1360 /* { */ 1361 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 1355 1362 if (pData->fmbuf_water_line == 1) 1356 1363 { … … 1362 1369 goto done; 1363 1370 } 1371 #endif 1364 1372 #ifdef VBOX_WITH_SLIRP_MT 1365 1373 if ( so->so_state & SS_NOFDREF … … 1553 1561 } 1554 1562 1555 #ifdef VBOX_WITH_SLIRP_BSD_MBUF1556 void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len)1557 #else1558 1563 void slirp_input(PNATState pData, void *pvArg) 1559 #endif1560 1564 { 1561 1565 struct mbuf *m; 1562 1566 int proto; 1563 1567 static bool fWarnedIpv6; 1564 #ifdef VBOX_WITH_SLIRP_BSD_MBUF1565 struct ethhdr *eh = (struct ethhdr*)pkt;1566 int size = 0;1567 #else1568 1568 struct ethhdr *eh; 1569 #endif1570 1569 uint8_t au8Ether[ETH_ALEN]; 1571 1570 1572 #ifndef VBOX_WITH_SLIRP_BSD_MBUF1573 1571 m = (struct mbuf *)pvArg; 1574 1572 if (m->m_len < ETH_HLEN) … … 1580 1578 eh = mtod(m, struct ethhdr *); 1581 1579 proto = RT_N2H_U16(eh->h_proto); 1582 #else1583 Log2(("NAT: slirp_input %d\n", pkt_len));1584 if (pkt_len < ETH_HLEN)1585 {1586 LogRel(("NAT: packet having size %d has been ingnored\n", pkt_len));1587 return;1588 }1589 Log4(("NAT: in:%R[ether]->%R[ether]\n", &eh->h_source, &eh->h_dest));1590 1591 if (memcmp(eh->h_source, special_ethaddr, ETH_ALEN) == 0)1592 {1593 /* @todo vasily: add ether logging routine in debug.c */1594 Log(("NAT: packet was addressed to other MAC\n"));1595 RTMemFree((void *)pkt);1596 return;1597 }1598 1599 if (pkt_len < MSIZE)1600 size = MCLBYTES;1601 else if (pkt_len < MCLBYTES)1602 size = MCLBYTES;1603 else if (pkt_len < MJUM9BYTES)1604 size = MJUM9BYTES;1605 else if (pkt_len < MJUM16BYTES)1606 size = MJUM16BYTES;1607 else1608 AssertMsgFailed(("Unsupported size"));1609 1610 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size);1611 if (!m)1612 {1613 LogRel(("NAT: can't allocate new mbuf\n"));1614 RTMemFree((void *)pkt);1615 return;1616 }1617 1618 m->m_len = pkt_len ;1619 memcpy(m->m_data, pkt, pkt_len);1620 proto = RT_N2H_U16(*(uint16_t *)(pkt + 12));1621 #endif1622 /* Note: we add to align the IP header */1623 1580 1624 1581 memcpy(au8Ether, eh->h_source, ETH_ALEN); … … 1638 1595 M_ASSERTPKTHDR(m); 1639 1596 m->m_pkthdr.header = mtod(m, void *); 1640 #endif 1641 #if 1 1597 #else /* !VBOX_WITH_SLIRP_BSD_MBUF */ 1642 1598 if ( pData->fmbuf_water_line 1643 1599 && pData->fmbuf_water_warn_sent == 0 … … 1648 1604 pData->tsmbuf_water_warn_sent = curtime; 1649 1605 } 1650 #endif 1606 #endif /* !VBOX_WITH_SLIRP_BSD_MBUF */ 1651 1607 ip_input(pData, m); 1652 1608 break; … … 1669 1625 if (pData->cRedirectionsActive != pData->cRedirectionsStored) 1670 1626 activate_port_forwarding(pData, au8Ether); 1671 1672 #ifdef VBOX_WITH_SLIRP_BSD_MBUF1673 RTMemFree((void *)pkt);1674 #endif1675 1627 } 1676 1628 … … 1708 1660 { 1709 1661 /* don't do anything */ 1662 m_free(pData, m); 1710 1663 goto done; 1711 1664 } … … 1719 1672 { 1720 1673 LogRel(("NAT: Can't alloc memory for outgoing buffer\n")); 1674 m_free(pData, m); 1721 1675 goto done; 1722 1676 } … … 1725 1679 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 1726 1680 m_copydata(m, 0, mlen, (char *)buf); 1681 if (flags & ETH_ENCAP_URG) 1682 slirp_urg_output(pData->pvUser, m, buf, mlen); 1683 else 1684 slirp_output(pData->pvUser, m, buf, mlen); 1727 1685 #else 1728 1686 if (flags & ETH_ENCAP_URG) … … 1733 1691 done: 1734 1692 STAM_PROFILE_STOP(&pData->StatIF_encap, a); 1735 #ifdef VBOX_WITH_SLIRP_BSD_MBUF1736 m_free(pData, m);1737 #endif1738 1693 } 1739 1694 -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r25822 r26404 398 398 399 399 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 400 /* @todo might be useful to make it configurable,401 * especially in terms of Intnet behind NAT400 /** 401 * @todo might be useful to make it configurable, especially in terms of Intnet behind NAT 402 402 */ 403 403 # define maxusers 32 404 404 # define max_protohdr 0 405 /* @todo (r=vvl) for now ignore value,406 * latter here should be fetching of tuning parameters entered405 /** 406 * @todo (vvl) for now ignore these values, later perhaps initialize tuning parameters 407 407 */ 408 408 # define TUNABLE_INT_FETCH(name, pval) do { } while (0) 409 # define SYSCTL_PROC(a0, a1, a2, a3, a4, a5, a6, a7, a8) 410 # define SYSCTL_STRUCT(a0, a1, a2, a3, a4, a5, a6) 411 # define SYSINIT(a0, a1, a2, a3, a4) 409 # define SYSCTL_PROC(a0, a1, a2, a3, a4, a5, a6, a7, a8) const int dummy_ ## a6 = 0 410 # define SYSCTL_STRUCT(a0, a1, a2, a3, a4, a5, a6) const int dummy_ ## a5 = 0 411 # define SYSINIT(a0, a1, a2, a3, a4) const int dummy_ ## a3 = 0 412 412 # define sysctl_handle_int(a0, a1, a2, a3) 0 413 413 # define EVENTHANDLER_INVOKE(a) do{}while(0) -
trunk/src/VBox/Devices/Network/slirp/socket.c
r25822 r26404 647 647 len += n; 648 648 649 size = MCLBYTES; 649 650 if (len < MSIZE) 650 {651 651 size = MCLBYTES; 652 }653 652 else if (len < MCLBYTES) 654 {655 653 size = MCLBYTES; 656 }657 654 else if (len < MJUM9BYTES) 658 {659 655 size = MJUM9BYTES; 660 }661 656 else if (len < MJUM16BYTES) 662 {663 657 size = MJUM16BYTES; 664 }665 658 else 666 {667 659 AssertMsgFailed(("Unsupported size")); 668 } 660 669 661 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size); 670 662 m->m_data += ETH_HLEN; … … 673 665 ret = recvfrom(so->s, mtod(m, char *), n, 0, 674 666 (struct sockaddr *)&addr, &addrlen); 675 /* @todo ( r=vvl) check which flags and type should be passed */667 /* @todo (vvl) check which flags and type should be passed */ 676 668 #endif 677 669 m->m_len = ret; … … 751 743 #endif 752 744 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 753 uint8_t *buf;745 caddr_t buf; 754 746 int mlen; 755 747 #endif -
trunk/src/VBox/Devices/Network/slirp/tcp_output.c
r25822 r26404 375 375 m = m_get(pData); 376 376 #else 377 size = MCLBYTES; 377 378 if ((len + hdrlen + ETH_HLEN) < MSIZE) 378 {379 379 size = MCLBYTES; 380 }381 380 else if ((len + hdrlen + ETH_HLEN) < MCLBYTES) 382 {383 381 size = MCLBYTES; 384 }385 382 else if((len + hdrlen + ETH_HLEN) < MJUM9BYTES) 386 {387 383 size = MJUM9BYTES; 388 }389 384 else if ((len + hdrlen + ETH_HLEN) < MJUM16BYTES) 390 {391 385 size = MJUM16BYTES; 392 }393 386 else 394 {395 387 AssertMsgFailed(("Unsupported size")); 396 }397 388 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size); 398 389 #endif -
trunk/src/VBox/Devices/Network/slirp/tftp.c
r25822 r26404 126 126 int n = 0; 127 127 128 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 128 129 m = m_get(pData); 130 #else 131 m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR); 132 #endif 129 133 if (!m) 130 134 return -1; 131 135 136 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 132 137 memset(m->m_data, 0, m->m_size); 133 134 138 m->m_data += if_maxlinkhdr; 139 #else 140 m->m_pkthdr.header = mtod(m, void *); 141 #endif 135 142 tp = (void *)m->m_data; 136 143 m->m_data += sizeof(struct udpiphdr); 137 144 138 145 tp->tp_op = RT_H2N_U16_C(TFTP_OACK); 146 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 139 147 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_FREEROOM(m), "%s", key) + 1; 140 148 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_FREEROOM(m), "%u", value) + 1; 149 #else 150 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_TRAILINGSPACE(m), "%s", key) + 1; 151 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_TRAILINGSPACE(m), "%u", value) + 1; 152 #endif 141 153 142 154 saddr.sin_addr = recv_tp->ip.ip_dst; … … 152 164 return 0; 153 165 } 154 155 156 166 157 167 static int tftp_send_error(PNATState pData, … … 165 175 int nobytes; 166 176 177 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 167 178 m = m_get(pData); 179 #else 180 if ((m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR)) == NULL) 181 #endif 168 182 if (!m) 169 183 return -1; 170 184 185 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 171 186 memset(m->m_data, 0, m->m_size); 172 173 187 m->m_data += if_maxlinkhdr; 188 #else 189 m->m_pkthdr.header = mtod(m, void *); 190 #endif 174 191 tp = (void *)m->m_data; 175 192 m->m_data += sizeof(struct udpiphdr); … … 214 231 return -1; 215 232 233 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 216 234 m = m_get(pData); 235 #else 236 if ((m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR)) == NULL) 237 #endif 217 238 if (!m) 218 239 return -1; 219 240 241 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 220 242 memset(m->m_data, 0, m->m_size); 221 222 243 m->m_data += if_maxlinkhdr; 244 #else 245 m->m_pkthdr.header = mtod(m, void *); 246 #endif 223 247 tp = (void *)m->m_data; 224 248 m->m_data += sizeof(struct udpiphdr); -
trunk/src/VBox/Devices/Network/slirp/udp.c
r25822 r26404 181 181 * handle TFTP 182 182 */ 183 #ifndef VBOX_WITH_SLIRP_BSD_MBUF184 183 if ( uh->uh_dport == RT_H2N_U16_C(TFTP_SERVER) 185 184 && CTL_CHECK(RT_N2H_U32(ip->ip_dst.s_addr), CTL_TFTP)) … … 188 187 goto done; 189 188 } 190 #endif191 189 192 190 /*
Note:
See TracChangeset
for help on using the changeset viewer.