VirtualBox

Ignore:
Timestamp:
Dec 13, 2008 11:55:20 AM (16 years ago)
Author:
vboxsync
Message:

slirp:icmp: Reusing of original header (sent from guest) to use in response
Need to be checked on Linux

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r15396 r15435  
    792792    struct icmp *icp;
    793793    int old_ip_len;
     794    int hlen, original_hlen;
    794795    struct mbuf *m;
    795796    struct icmp_msg *icm;
     
    797798
    798799    ip = (struct ip *)buff;
    799     icp = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
     800    hlen = (ip->ip_hl << 2);
     801    icp = (struct icmp *)((char *)ip + hlen);
    800802
    801803    LogRel(("ICMP:received msg(t:%d, c:%d)\n", icp->icmp_type, icp->icmp_code));
     
    834836
    835837    /* overide ther tail of old packet */
    836     memcpy(m->m_data, buff, len);
    837     m->m_len = len;
    838838    ip = mtod(m, struct ip *); /* ip is from mbuf we've overrided */
     839    original_hlen = ip->ip_hl << 2;
     840    /* saves original ip header and options */
     841    memcpy(m->m_data + original_hlen, buff + hlen, len - hlen);
     842    m->m_len = len - hlen + original_hlen;
    839843
    840844    icp = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
     
    847851
    848852    /* the low level expects fields to be in host format so let's convert them*/
    849 #ifndef RT_OS_DARWIN
    850     /* Darwin returns this fields in host byte order */
     853#if 0 /* need check on linux */
    851854    NTOHS(ip->ip_len);
    852855    NTOHS(ip->ip_off);
    853 #endif
    854856    NTOHS(ip->ip_id);
     857#endif
    855858    ip->ip_src.s_addr = src;
    856859    ip->ip_dst.s_addr = dst;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette