Changeset 30363 in vbox
- Timestamp:
- Jun 22, 2010 11:21:22 AM (14 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r30016 r30363 200 200 201 201 eh = mtod(m, struct ethhdr *); 202 memcpy(eh->h_source, bp->bp_hwaddr, ETH_ALEN); /* XXX: if_encap just swap source with dest */202 memcpy(eh->h_source, bp->bp_hwaddr, ETH_ALEN); /* XXX: if_encap just swap source with dest */ 203 203 204 204 m->m_data += if_maxlinkhdr; /*reserve ether header */ … … 650 650 p = dhcp_find_option(bp->bp_vend, RFC2132_MSG_TYPE); 651 651 Assert(p); 652 if ( p == NULL)652 if (!p) 653 653 return; 654 654 /* … … 657 657 */ 658 658 if ( !pData->fUseHostResolver 659 660 659 && ( pData->dnsLastUpdate == 0 660 || curtime - pData->dnsLastUpdate > 60 * 1000)) /* one minute*/ 661 661 { 662 662 uint8_t i = 2; /* i = 0 - tag, i == 1 - length */ … … 674 674 } 675 675 676 if ((m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR)) == NULL) 676 m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR); 677 if (!m) 677 678 { 678 679 LogRel(("NAT: can't alocate memory for response!\n")); … … 684 685 case DHCPDISCOVER: 685 686 fDhcpDiscover = 1; 686 /* */687 /* fall through */ 687 688 case DHCPINFORM: 688 689 rc = dhcp_decode_discover(pData, bp, buf, size, fDhcpDiscover, m); … … 722 723 AssertMsgFailed(("unsupported DHCP message type")); 723 724 } 724 Assert(m); 725 /*silently ignore*/ 725 /* silently ignore */ 726 726 m_freem(pData, m); 727 727 return; … … 729 729 reply: 730 730 bootp_reply(pData, m, rc, bp->bp_flags); 731 return;732 731 } 733 732 -
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r30016 r30363 510 510 511 511 512 /* 512 /** 513 513 * Send an ICMP message in response to a situation 514 514 * … … 526 526 * ICMP fragmentation is illegal. All machines must accept 576 bytes in one 527 527 * packet. The maximum payload is 576-20(ip hdr)-8(icmp hdr)=548 528 * 529 * @note This function will free msrc! 528 530 */ 529 531 … … 544 546 M_ASSERTPKTHDR(msrc); 545 547 546 if (type!=ICMP_UNREACH && type!=ICMP_TIMXCEED && type != ICMP_SOURCEQUENCH) 548 if ( type != ICMP_UNREACH 549 && type != ICMP_TIMXCEED 550 && type != ICMP_SOURCEQUENCH) 547 551 goto end_error; 548 552 … … 560 564 } 561 565 #endif 562 if (ip->ip_off & IP_OFFMASK && type != ICMP_SOURCEQUENCH) 566 if ( ip->ip_off & IP_OFFMASK 567 && type != ICMP_SOURCEQUENCH) 563 568 goto end_error; /* Only reply to fragment 0 */ 564 569 … … 598 603 } 599 604 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size); 600 601 if (m == NULL) 602 goto end_error; /* get mbuf */ 605 if (!m) 606 goto end_error; 603 607 604 608 m->m_data += if_maxlinkhdr; … … 674 678 end_error_free_m: 675 679 m_freem(pData, m); 680 676 681 end_error: 677 LogRel(("NAT: error occurred while sending ICMP error message 682 LogRel(("NAT: error occurred while sending ICMP error message\n")); 678 683 } 679 684 #undef ICMP_MAXDATALEN -
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r30352 r30363 105 105 } 106 106 107 /* This function will free m0! */ 107 108 int 108 109 ip_output0(PNATState pData, struct socket *so, struct mbuf *m0, int urg) … … 218 219 if (m->m_next != NULL) 219 220 { 220 /* we've receive spacket in fragments */221 /* we've received a packet in fragments */ 221 222 tmplen = m_length(m, NULL); 222 223 tmpbuf = RTMemAlloc(tmplen); … … 269 270 error = -1; 270 271 ipstat.ips_odropped++; 271 goto send orfree;272 goto send_or_free; 272 273 } 273 274 m->m_data += if_maxlinkhdr; … … 320 321 ip->ip_sum = cksum(m, hlen); 321 322 322 send orfree:323 send_or_free: 323 324 for (m = m0; m; m = m0) 324 325 { … … 335 336 } 336 337 else 337 {338 338 m_freem(pData, m); 339 }340 339 } 341 340 -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r30354 r30363 1380 1380 AssertCompileSize(struct arphdr, 28); 1381 1381 1382 /** 1383 * @note This function will free m! 1384 */ 1382 1385 static void arp_input(PNATState pData, struct mbuf *m) 1383 1386 { … … 1526 1529 } 1527 1530 1528 /* output the IP packet to the ethernet device */ 1531 /** 1532 * Output the IP packet to the ethernet device. 1533 * 1534 * @note This function will free m! 1535 */ 1529 1536 void if_encap(PNATState pData, uint16_t eth_proto, struct mbuf *m, int flags) 1530 1537 { … … 1553 1560 mlen = m_length(m, NULL); 1554 1561 buf = RTMemAlloc(mlen); 1555 if ( buf == NULL)1562 if (!buf) 1556 1563 { 1557 1564 LogRel(("NAT: Can't alloc memory for outgoing buffer\n")); -
trunk/src/VBox/Devices/Network/slirp/socket.c
r30047 r30363 766 766 if (m == NULL) 767 767 return; 768 768 769 m->m_data += ETH_HLEN; 769 770 m->m_pkthdr.header = mtod(m, void *); 770 771 m->m_data += sizeof(struct udpiphdr); 771 772 ret = recvfrom(so->s, mtod(m, char *), n, 0, 772 773 (struct sockaddr *)&addr, &addrlen); 773 774 /* @todo (vvl) check which flags and type should be passed */ 774 775 m->m_len = ret; -
trunk/src/VBox/Devices/Network/slirp/tftp.c
r30016 r30363 181 181 int nobytes; 182 182 183 if ((m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR)) == NULL)183 m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR); 184 184 if (!m) 185 185 return -1; … … 229 229 return -1; 230 230 231 if ((m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR)) == NULL)231 m = m_getcl(pData, M_DONTWAIT, MT_HEADER, M_PKTHDR); 232 232 if (!m) 233 233 return -1; -
trunk/src/VBox/Devices/Network/slirp/udp.c
r30352 r30363 298 298 *ip = save_ip; 299 299 DEBUG_MISC((dfd,"NAT: UDP tx errno = %d-%s (on sent to %R[IP4])\n", errno, 300 strerror(errno), &ip->ip_dst));300 strerror(errno), &ip->ip_dst)); 301 301 icmp_error(pData, m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno)); 302 302 /* in case we receive ICMP on this socket we'll aware that ICMP has been already sent to host*/ … … 328 328 329 329 /** 330 * Output a UDP packet. This function will finally free the mbuf so 331 * do NOT free any passed mbuf. 330 * Output a UDP packet. 331 * 332 * @note This function will finally free m! 332 333 */ 333 334 int udp_output2(PNATState pData, struct socket *so, struct mbuf *m, … … 336 337 { 337 338 register struct udpiphdr *ui; 338 int error = 0;339 int error; 339 340 340 341 DEBUG_CALL("udp_output"); … … 385 386 } 386 387 388 /** 389 * @note This function will free m! 390 */ 387 391 int udp_output(PNATState pData, struct socket *so, struct mbuf *m, 388 392 struct sockaddr_in *addr)
Note:
See TracChangeset
for help on using the changeset viewer.