VirtualBox

Changeset 22897 in vbox


Ignore:
Timestamp:
Sep 10, 2009 7:18:07 AM (15 years ago)
Author:
vboxsync
Message:

NAT: BSD mbufs related changeset. (icmp)

File:
1 edited

Legend:

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

    r22576 r22897  
    487487    register struct icmp *icp;
    488488    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
    489492
    490493    DEBUG_CALL("icmp_error");
    491494    DEBUG_ARG("msrc = %lx", (long )msrc);
    492495    DEBUG_ARG("msrc_len = %d", msrc ? msrc->m_len : 0);
     496#ifdef VBOX_WITH_SLIRP_BSD_MBUF
     497    M_ASSERTPKTHDR(msrc);
     498#endif
    493499
    494500    if (type!=ICMP_UNREACH && type!=ICMP_TIMXCEED)
     
    524530    }
    525531
     532#ifndef VBOX_WITH_SLIRP_BSD_MBUF
    526533    /* make a copy */
    527534    if (!(m = m_get(pData)))
     
    537544    memcpy(m->m_data, msrc->m_data, msrc->m_len);
    538545    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
    539556
    540557    /* make the header of the reply packet */
     
    543560
    544561    /* fill in icmp */
     562#ifndef VBOX_WITH_SLIRP_BSD_MBUF
    545563    m->m_data += hlen;
    546564    m->m_len  -= hlen;
     565#else
     566    m_adj(m, hlen);
     567#endif
    547568
    548569    icp = mtod(m, struct icmp *);
     
    553574        s_ip_len = ICMP_MAXDATALEN;
    554575
     576#ifndef VBOX_WITH_SLIRP_BSD_MBUF
    555577    m->m_len = ICMP_MINLEN + s_ip_len;     /* 8 bytes ICMP header */
     578#else
     579    m_adj(m, ICMP_MINLEN);
     580#endif
    556581
    557582    /* min. size = 8+sizeof(struct ip)+8 */
     
    562587    icp->icmp_seq = 0;
    563588
     589#ifndef VBOX_WITH_SLIRP_BSD_MBUF
    564590    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
    565602    HTONS(icp->icmp_ip.ip_len);
    566603    HTONS(icp->icmp_ip.ip_id);
     
    577614            message_len = ICMP_MAXDATALEN;
    578615        cpnt = (char *)m->m_data+m->m_len;
     616#ifndef VBOX_WITH_SLIRP_BSD_MBUF
    579617        memcpy(cpnt, message, message_len);
    580618        m->m_len += message_len;
     619#else
     620        m_append(pData, m, message_len, message);
     621#endif
    581622    }
    582623#endif
     
    585626    icp->icmp_cksum = cksum(m, m->m_len);
    586627
     628#ifndef VBOX_WITH_SLIRP_BSD_MBUF
    587629    m->m_data -= hlen;
    588630    m->m_len += hlen;
     631#endif
    589632
    590633    /* fill in ip */
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