qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] slirp: kill ugly macros


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCH] slirp: kill ugly macros
Date: Wed, 15 Feb 2012 20:45:15 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Remove ugly macros for field names,
change done by the following script:

s#\bifq_prev\b#m_prev#g;
s#\bifq_next\b#m_next#g;
s#\bifs_prev\b#m_prevpkt#g;
s#\bifs_next\b#m_nextpkt#g;
s#\bifq_so\b#m_so#g;
s#\bm_next\b#m_hdr.mh_next#g;
s#\bm_prev\b#m_hdr.mh_prev#g;
s#\bm_nextpkt\b#m_hdr.mh_nextpkt#g;
s#\bm_prevpkt\b#m_hdr.mh_prevpkt#g;
s#\bm_flags\b#m_hdr.mh_flags#g;
s#\bm_len\b#m_hdr.mh_len#g;
s#\bm_data\b#m_hdr.mh_data#g;
s#\bm_size\b#m_hdr.mh_size#g;
s#\bm_dat\b#M_dat.m_dat_#g;
s#\bm_ext\b#M_dat.m_ext_#g;
s#\bm_so\b#m_hdr.mh_so#g;

Signed-off-by: Michael S. Tsirkin <address@hidden>
---

Lightly tested, WFM

 slirp/bootp.c      |    8 ++--
 slirp/cksum.c      |    4 +-
 slirp/if.c         |   70 +++++++++++++++++++++---------------------
 slirp/if.h         |    2 +-
 slirp/ip.h         |    2 +-
 slirp/ip_icmp.c    |   64 +++++++++++++++++++-------------------
 slirp/ip_input.c   |   34 ++++++++++----------
 slirp/ip_output.c  |   14 ++++----
 slirp/mbuf.c       |   86 ++++++++++++++++++++++++++--------------------------
 slirp/mbuf.h       |   36 +++++----------------
 slirp/sbuf.c       |   20 ++++++------
 slirp/slirp.c      |   16 +++++-----
 slirp/socket.c     |   12 ++++----
 slirp/tcp_input.c  |   18 +++++-----
 slirp/tcp_output.c |   14 ++++----
 slirp/tcp_subr.c   |   62 +++++++++++++++++++-------------------
 slirp/tftp.c       |   38 +++++++++++-----------
 slirp/udp.c        |   26 ++++++++--------
 18 files changed, 254 insertions(+), 272 deletions(-)

diff --git a/slirp/bootp.c b/slirp/bootp.c
index efd1fe7..84c1182 100644
--- a/slirp/bootp.c
+++ b/slirp/bootp.c
@@ -173,9 +173,9 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t 
*bp)
     if (!m) {
         return;
     }
-    m->m_data += IF_MAXLINKHDR;
-    rbp = (struct bootp_t *)m->m_data;
-    m->m_data += sizeof(struct udpiphdr);
+    m->m_hdr.mh_data += IF_MAXLINKHDR;
+    rbp = (struct bootp_t *)m->m_hdr.mh_data;
+    m->m_hdr.mh_data += sizeof(struct udpiphdr);
     memset(rbp, 0, sizeof(struct bootp_t));
 
     if (dhcp_msg_type == DHCPDISCOVER) {
@@ -304,7 +304,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t 
*bp)
 
     daddr.sin_addr.s_addr = 0xffffffffu;
 
-    m->m_len = sizeof(struct bootp_t) -
+    m->m_hdr.mh_len = sizeof(struct bootp_t) -
         sizeof(struct ip) - sizeof(struct udphdr);
     udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
 }
diff --git a/slirp/cksum.c b/slirp/cksum.c
index e43867d..123dead 100644
--- a/slirp/cksum.c
+++ b/slirp/cksum.c
@@ -61,11 +61,11 @@ int cksum(struct mbuf *m, int len)
                uint32_t l;
        } l_util;
 
-       if (m->m_len == 0)
+       if (m->m_hdr.mh_len == 0)
           goto cont;
        w = mtod(m, uint16_t *);
 
-       mlen = m->m_len;
+       mlen = m->m_hdr.mh_len;
 
        if (len < mlen)
           mlen = len;
diff --git a/slirp/if.c b/slirp/if.c
index 2852396..8a4ea63 100644
--- a/slirp/if.c
+++ b/slirp/if.c
@@ -8,29 +8,29 @@
 #include <slirp.h>
 #include "qemu-timer.h"
 
-#define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm))
+#define ifs_init(ifm) ((ifm)->m_hdr.mh_nextpkt = (ifm)->m_hdr.mh_prevpkt = 
(ifm))
 
 static void
 ifs_insque(struct mbuf *ifm, struct mbuf *ifmhead)
 {
-       ifm->ifs_next = ifmhead->ifs_next;
-       ifmhead->ifs_next = ifm;
-       ifm->ifs_prev = ifmhead;
-       ifm->ifs_next->ifs_prev = ifm;
+       ifm->m_hdr.mh_nextpkt = ifmhead->m_hdr.mh_nextpkt;
+       ifmhead->m_hdr.mh_nextpkt = ifm;
+       ifm->m_hdr.mh_prevpkt = ifmhead;
+       ifm->m_hdr.mh_nextpkt->m_hdr.mh_prevpkt = ifm;
 }
 
 static void
 ifs_remque(struct mbuf *ifm)
 {
-       ifm->ifs_prev->ifs_next = ifm->ifs_next;
-       ifm->ifs_next->ifs_prev = ifm->ifs_prev;
+       ifm->m_hdr.mh_prevpkt->m_hdr.mh_nextpkt = ifm->m_hdr.mh_nextpkt;
+       ifm->m_hdr.mh_nextpkt->m_hdr.mh_prevpkt = ifm->m_hdr.mh_prevpkt;
 }
 
 void
 if_init(Slirp *slirp)
 {
-    slirp->if_fastq.ifq_next = slirp->if_fastq.ifq_prev = &slirp->if_fastq;
-    slirp->if_batchq.ifq_next = slirp->if_batchq.ifq_prev = &slirp->if_batchq;
+    slirp->if_fastq.m_hdr.mh_next = slirp->if_fastq.m_hdr.mh_prev = 
&slirp->if_fastq;
+    slirp->if_batchq.m_hdr.mh_next = slirp->if_batchq.m_hdr.mh_prev = 
&slirp->if_batchq;
     slirp->next_m = &slirp->if_batchq;
 }
 
@@ -60,12 +60,12 @@ if_output(struct socket *so, struct mbuf *ifm)
 
        /*
         * First remove the mbuf from m_usedlist,
-        * since we're gonna use m_next and m_prev ourselves
+        * since we're gonna use m_hdr.mh_next and m_hdr.mh_prev ourselves
         * XXX Shouldn't need this, gotta change dtom() etc.
         */
-       if (ifm->m_flags & M_USEDLIST) {
+       if (ifm->m_hdr.mh_flags & M_USEDLIST) {
                remque(ifm);
-               ifm->m_flags &= ~M_USEDLIST;
+               ifm->m_hdr.mh_flags &= ~M_USEDLIST;
        }
 
        /*
@@ -75,34 +75,34 @@ if_output(struct socket *so, struct mbuf *ifm)
         * We mustn't put this packet back on the fastq (or we'll send it out 
of order)
         * XXX add cache here?
         */
-       for (ifq = slirp->if_batchq.ifq_prev; ifq != &slirp->if_batchq;
-            ifq = ifq->ifq_prev) {
-               if (so == ifq->ifq_so) {
+       for (ifq = slirp->if_batchq.m_hdr.mh_prev; ifq != &slirp->if_batchq;
+            ifq = ifq->m_hdr.mh_prev) {
+               if (so == ifq->m_hdr.mh_so) {
                        /* A match! */
-                       ifm->ifq_so = so;
-                       ifs_insque(ifm, ifq->ifs_prev);
+                       ifm->m_hdr.mh_so = so;
+                       ifs_insque(ifm, ifq->m_hdr.mh_prevpkt);
                        goto diddit;
                }
        }
 
        /* No match, check which queue to put it on */
        if (so && (so->so_iptos & IPTOS_LOWDELAY)) {
-               ifq = slirp->if_fastq.ifq_prev;
+               ifq = slirp->if_fastq.m_hdr.mh_prev;
                on_fastq = 1;
                /*
                 * Check if this packet is a part of the last
                 * packet's session
                 */
-               if (ifq->ifq_so == so) {
-                       ifm->ifq_so = so;
-                       ifs_insque(ifm, ifq->ifs_prev);
+               if (ifq->m_hdr.mh_so == so) {
+                       ifm->m_hdr.mh_so = so;
+                       ifs_insque(ifm, ifq->m_hdr.mh_prevpkt);
                        goto diddit;
                }
        } else
-               ifq = slirp->if_batchq.ifq_prev;
+               ifq = slirp->if_batchq.m_hdr.mh_prev;
 
        /* Create a new doubly linked list for this session */
-       ifm->ifq_so = so;
+       ifm->m_hdr.mh_so = so;
        ifs_init(ifm);
        insque(ifm, ifq);
 
@@ -124,10 +124,10 @@ diddit:
                                 (so->so_nqueued - so->so_queued) >= 3)) {
 
                        /* Remove from current queue... */
-                       remque(ifm->ifs_next);
+                       remque(ifm->m_hdr.mh_nextpkt);
 
                        /* ...And insert in the new.  That'll teach ya! */
-                       insque(ifm->ifs_next, &slirp->if_batchq);
+                       insque(ifm->m_hdr.mh_nextpkt, &slirp->if_batchq);
                }
        }
 
@@ -172,34 +172,34 @@ if_start(Slirp *slirp)
         * See which queue to get next packet from
         * If there's something in the fastq, select it immediately
         */
-       if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
-               ifm = slirp->if_fastq.ifq_next;
+       if (slirp->if_fastq.m_hdr.mh_next != &slirp->if_fastq) {
+               ifm = slirp->if_fastq.m_hdr.mh_next;
        } else {
                /* Nothing on fastq, see if next_m is valid */
                if (slirp->next_m != &slirp->if_batchq)
                   ifm = slirp->next_m;
                else
-                  ifm = slirp->if_batchq.ifq_next;
+                  ifm = slirp->if_batchq.m_hdr.mh_next;
 
                /* Set which packet to send on next iteration */
-               slirp->next_m = ifm->ifq_next;
+               slirp->next_m = ifm->m_hdr.mh_next;
        }
        /* Remove it from the queue */
-       ifqt = ifm->ifq_prev;
+       ifqt = ifm->m_hdr.mh_prev;
        remque(ifm);
        slirp->if_queued--;
 
        /* If there are more packets for this session, re-queue them */
-       if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm) {
-               insque(ifm->ifs_next, ifqt);
+       if (ifm->m_hdr.mh_nextpkt != /* ifm->m_hdr.mh_prevpkt != */ ifm) {
+               insque(ifm->m_hdr.mh_nextpkt, ifqt);
                ifs_remque(ifm);
        }
 
        /* Update so_queued */
-       if (ifm->ifq_so) {
-               if (--ifm->ifq_so->so_queued == 0)
+       if (ifm->m_hdr.mh_so) {
+               if (--ifm->m_hdr.mh_so->so_queued == 0)
                   /* If there's no more queued, reset nqueued */
-                  ifm->ifq_so->so_nqueued = 0;
+                  ifm->m_hdr.mh_so->so_nqueued = 0;
        }
 
         if (ifm->expiration_date < now) {
diff --git a/slirp/if.h b/slirp/if.h
index 2dac1c7..e0d426e 100644
--- a/slirp/if.h
+++ b/slirp/if.h
@@ -20,6 +20,6 @@
 /* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
 #define IF_MAXLINKHDR (2 + 14 + 40)
 
-#define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm))
+#define ifs_init(ifm) ((ifm)->m_hdr.mh_nextpkt = (ifm)->m_hdr.mh_prevpkt = 
(ifm))
 
 #endif
diff --git a/slirp/ip.h b/slirp/ip.h
index 88c903f..5dc1a8a 100644
--- a/slirp/ip.h
+++ b/slirp/ip.h
@@ -241,7 +241,7 @@ struct      ipasfrag {
  * Structure stored in mbuf in inpcb.ip_options
  * and passed to ip_output when ip options are in use.
  * The actual length of the options (including ipopt_dst)
- * is in m_len.
+ * is in m_hdr.mh_len.
  */
 #define MAX_IPOPTLEN   40
 
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 4b43994..243f303 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -89,7 +89,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int 
hlen)
 
     insque(so, &so->slirp->icmp);
 
-    if (sendto(so->s, m->m_data + hlen, m->m_len - hlen, 0,
+    if (sendto(so->s, m->m_hdr.mh_data + hlen, m->m_hdr.mh_len - hlen, 0,
                (struct sockaddr *)&addr, sizeof(addr)) == -1) {
         DEBUG_MISC((dfd, "icmp_input icmp sendto tx errno = %d-%s\n",
                     errno, strerror(errno)));
@@ -119,7 +119,7 @@ icmp_input(struct mbuf *m, int hlen)
 
   DEBUG_CALL("icmp_input");
   DEBUG_ARG("m = %lx", (long )m);
-  DEBUG_ARG("m_len = %d", m->m_len);
+  DEBUG_ARG("m_hdr.mh_len = %d", m->m_hdr.mh_len);
 
   /*
    * Locate icmp structure in mbuf, and check
@@ -131,14 +131,14 @@ icmp_input(struct mbuf *m, int hlen)
     goto end_error;
   }
 
-  m->m_len -= hlen;
-  m->m_data += hlen;
+  m->m_hdr.mh_len -= hlen;
+  m->m_hdr.mh_data += hlen;
   icp = mtod(m, struct icmp *);
   if (cksum(m, icmplen)) {
     goto freeit;
   }
-  m->m_len += hlen;
-  m->m_data -= hlen;
+  m->m_hdr.mh_len += hlen;
+  m->m_hdr.mh_data -= hlen;
 
   DEBUG_ARG("icmp_type = %d", icp->icmp_type);
   switch (icp->icmp_type) {
@@ -246,7 +246,7 @@ icmp_error(struct mbuf *msrc, u_char type, u_char code, int 
minsize,
 
   DEBUG_CALL("icmp_error");
   DEBUG_ARG("msrc = %lx", (long )msrc);
-  DEBUG_ARG("msrc_len = %d", msrc->m_len);
+  DEBUG_ARG("msrc_len = %d", msrc->m_hdr.mh_len);
 
   if(type!=ICMP_UNREACH && type!=ICMP_TIMXCEED) goto end_error;
 
@@ -280,19 +280,19 @@ icmp_error(struct mbuf *msrc, u_char type, u_char code, 
int minsize,
   }
 
   { int new_m_size;
-    new_m_size=sizeof(struct ip )+ICMP_MINLEN+msrc->m_len+ICMP_MAXDATALEN;
-    if(new_m_size>m->m_size) m_inc(m, new_m_size);
+    new_m_size=sizeof(struct ip 
)+ICMP_MINLEN+msrc->m_hdr.mh_len+ICMP_MAXDATALEN;
+    if(new_m_size>m->m_hdr.mh_size) m_inc(m, new_m_size);
   }
-  memcpy(m->m_data, msrc->m_data, msrc->m_len);
-  m->m_len = msrc->m_len;                        /* copy msrc to m */
+  memcpy(m->m_hdr.mh_data, msrc->m_hdr.mh_data, msrc->m_hdr.mh_len);
+  m->m_hdr.mh_len = msrc->m_hdr.mh_len;                        /* copy msrc to 
m */
 
   /* make the header of the reply packet */
   ip  = mtod(m, struct ip *);
   hlen= sizeof(struct ip );     /* no options in reply */
 
   /* fill in icmp */
-  m->m_data += hlen;
-  m->m_len -= hlen;
+  m->m_hdr.mh_data += hlen;
+  m->m_hdr.mh_len -= hlen;
 
   icp = mtod(m, struct icmp *);
 
@@ -300,7 +300,7 @@ icmp_error(struct mbuf *msrc, u_char type, u_char code, int 
minsize,
   else if(s_ip_len>ICMP_MAXDATALEN)         /* maximum size */
     s_ip_len=ICMP_MAXDATALEN;
 
-  m->m_len=ICMP_MINLEN+s_ip_len;        /* 8 bytes ICMP header */
+  m->m_hdr.mh_len=ICMP_MINLEN+s_ip_len;        /* 8 bytes ICMP header */
 
   /* min. size = 8+sizeof(struct ip)+8 */
 
@@ -309,7 +309,7 @@ icmp_error(struct mbuf *msrc, u_char type, u_char code, int 
minsize,
   icp->icmp_id = 0;
   icp->icmp_seq = 0;
 
-  memcpy(&icp->icmp_ip, msrc->m_data, s_ip_len);   /* report the ip packet */
+  memcpy(&icp->icmp_ip, msrc->m_hdr.mh_data, s_ip_len);   /* report the ip 
packet */
   HTONS(icp->icmp_ip.ip_len);
   HTONS(icp->icmp_ip.ip_id);
   HTONS(icp->icmp_ip.ip_off);
@@ -320,21 +320,21 @@ icmp_error(struct mbuf *msrc, u_char type, u_char code, 
int minsize,
     char *cpnt;
     message_len=strlen(message);
     if(message_len>ICMP_MAXDATALEN) message_len=ICMP_MAXDATALEN;
-    cpnt=(char *)m->m_data+m->m_len;
+    cpnt=(char *)m->m_hdr.mh_data+m->m_hdr.mh_len;
     memcpy(cpnt, message, message_len);
-    m->m_len+=message_len;
+    m->m_hdr.mh_len+=message_len;
   }
 #endif
 
   icp->icmp_cksum = 0;
-  icp->icmp_cksum = cksum(m, m->m_len);
+  icp->icmp_cksum = cksum(m, m->m_hdr.mh_len);
 
-  m->m_data -= hlen;
-  m->m_len += hlen;
+  m->m_hdr.mh_data -= hlen;
+  m->m_hdr.mh_len += hlen;
 
   /* fill in ip */
   ip->ip_hl = hlen >> 2;
-  ip->ip_len = m->m_len;
+  ip->ip_len = m->m_hdr.mh_len;
 
   ip->ip_tos=((ip->ip_tos & 0x1E) | 0xC0);  /* high priority for errors */
 
@@ -365,16 +365,16 @@ icmp_reflect(struct mbuf *m)
    * Send an icmp packet back to the ip level,
    * after supplying a checksum.
    */
-  m->m_data += hlen;
-  m->m_len -= hlen;
+  m->m_hdr.mh_data += hlen;
+  m->m_hdr.mh_len -= hlen;
   icp = mtod(m, struct icmp *);
 
   icp->icmp_type = ICMP_ECHOREPLY;
   icp->icmp_cksum = 0;
   icp->icmp_cksum = cksum(m, ip->ip_len - hlen);
 
-  m->m_data -= hlen;
-  m->m_len += hlen;
+  m->m_hdr.mh_data -= hlen;
+  m->m_hdr.mh_len += hlen;
 
   /* fill in ip */
   if (optlen > 0) {
@@ -383,11 +383,11 @@ icmp_reflect(struct mbuf *m)
      * mbuf's data back, and adjust the IP length.
      */
     memmove((caddr_t)(ip + 1), (caddr_t)ip + hlen,
-           (unsigned )(m->m_len - hlen));
+           (unsigned )(m->m_hdr.mh_len - hlen));
     hlen -= optlen;
     ip->ip_hl = hlen >> 2;
     ip->ip_len -= optlen;
-    m->m_len -= optlen;
+    m->m_hdr.mh_len -= optlen;
   }
 
   ip->ip_ttl = MAXTTL;
@@ -410,16 +410,16 @@ void icmp_receive(struct socket *so)
     struct icmp *icp;
     int id, len;
 
-    m->m_data += hlen;
-    m->m_len -= hlen;
+    m->m_hdr.mh_data += hlen;
+    m->m_hdr.mh_len -= hlen;
     icp = mtod(m, struct icmp *);
 
     id = icp->icmp_id;
-    len = qemu_recv(so->s, icp, m->m_len, 0);
+    len = qemu_recv(so->s, icp, m->m_hdr.mh_len, 0);
     icp->icmp_id = id;
 
-    m->m_data -= hlen;
-    m->m_len += hlen;
+    m->m_hdr.mh_data -= hlen;
+    m->m_hdr.mh_len += hlen;
 
     if (len == -1 || len == 0) {
         if (errno == ENETUNREACH) {
diff --git a/slirp/ip_input.c b/slirp/ip_input.c
index c7b3eb4..046e468 100644
--- a/slirp/ip_input.c
+++ b/slirp/ip_input.c
@@ -74,9 +74,9 @@ ip_input(struct mbuf *m)
 
        DEBUG_CALL("ip_input");
        DEBUG_ARG("m = %lx", (long)m);
-       DEBUG_ARG("m_len = %d", m->m_len);
+       DEBUG_ARG("m_hdr.mh_len = %d", m->m_hdr.mh_len);
 
-       if (m->m_len < sizeof (struct ip)) {
+       if (m->m_hdr.mh_len < sizeof (struct ip)) {
                return;
        }
 
@@ -87,7 +87,7 @@ ip_input(struct mbuf *m)
        }
 
        hlen = ip->ip_hl << 2;
-       if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
+       if (hlen<sizeof(struct ip ) || hlen>m->m_hdr.mh_len) {/* min header 
length */
          goto bad;                                  /* or packet too short */
        }
 
@@ -115,13 +115,13 @@ ip_input(struct mbuf *m)
         * Trim mbufs if longer than we expect.
         * Drop packet if shorter than we expect.
         */
-       if (m->m_len < ip->ip_len) {
+       if (m->m_hdr.mh_len < ip->ip_len) {
                goto bad;
        }
 
        /* Should drop packet if mbuf too long? hmmm... */
-       if (m->m_len > ip->ip_len)
-          m_adj(m, ip->ip_len - m->m_len);
+       if (m->m_hdr.mh_len > ip->ip_len)
+          m_adj(m, ip->ip_len - m->m_hdr.mh_len);
 
        /* check ip_ttl for a correct ICMP reply */
        if(ip->ip_ttl==0) {
@@ -233,10 +233,10 @@ ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp)
        /*
         * Presence of header sizes in mbufs
         * would confuse code below.
-         * Fragment m_data is concatenated.
+         * Fragment m_hdr.mh_data is concatenated.
         */
-       m->m_data += hlen;
-       m->m_len -= hlen;
+       m->m_hdr.mh_data += hlen;
+       m->m_hdr.mh_len -= hlen;
 
        /*
         * If first fragment to arrive, create a reassembly queue.
@@ -342,13 +342,13 @@ insert:
        /*
         * If the fragments concatenated to an mbuf that's
         * bigger than the total size of the fragment, then and
-        * m_ext buffer was alloced. But fp->ipq_next points to
+        * M_dat.m_ext_ buffer was alloced. But fp->ipq_next points to
         * the old buffer (in the mbuf), so we must point ip
         * into the new buffer.
         */
-       if (m->m_flags & M_EXT) {
-         int delta = (char *)q - m->m_dat;
-         q = (struct ipasfrag *)(m->m_ext + delta);
+       if (m->m_hdr.mh_flags & M_EXT) {
+         int delta = (char *)q - m->M_dat.m_dat_;
+         q = (struct ipasfrag *)(m->M_dat.m_ext_ + delta);
        }
 
     ip = fragtoip(q);
@@ -358,8 +358,8 @@ insert:
        ip->ip_dst = fp->ipq_dst;
        remque(&fp->ip_link);
        (void) m_free(dtom(slirp, fp));
-       m->m_len += (ip->ip_hl << 2);
-       m->m_data -= (ip->ip_hl << 2);
+       m->m_hdr.mh_len += (ip->ip_hl << 2);
+       m->m_hdr.mh_data -= (ip->ip_hl << 2);
 
        return ip;
 
@@ -654,9 +654,9 @@ ip_stripoptions(register struct mbuf *m, struct mbuf *mopt)
 
        olen = (ip->ip_hl<<2) - sizeof (struct ip);
        opts = (caddr_t)(ip + 1);
-       i = m->m_len - (sizeof (struct ip) + olen);
+       i = m->m_hdr.mh_len - (sizeof (struct ip) + olen);
        memcpy(opts, opts  + olen, (unsigned)i);
-       m->m_len -= olen;
+       m->m_hdr.mh_len -= olen;
 
        ip->ip_hl = sizeof(struct ip) >> 2;
 }
diff --git a/slirp/ip_output.c b/slirp/ip_output.c
index c82830f..5f41c7a 100644
--- a/slirp/ip_output.c
+++ b/slirp/ip_output.c
@@ -102,7 +102,7 @@ ip_output(struct socket *so, struct mbuf *m0)
 
     {
        int mhlen, firstlen = len;
-       struct mbuf **mnext = &m->m_nextpkt;
+       struct mbuf **mnext = &m->m_hdr.mh_nextpkt;
 
        /*
         * Loop through length of segment after first fragment,
@@ -117,11 +117,11 @@ ip_output(struct socket *so, struct mbuf *m0)
            error = -1;
            goto sendorfree;
          }
-         m->m_data += IF_MAXLINKHDR;
+         m->m_hdr.mh_data += IF_MAXLINKHDR;
          mhip = mtod(m, struct ip *);
          *mhip = *ip;
 
-         m->m_len = mhlen;
+         m->m_hdr.mh_len = mhlen;
          mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF);
          if (ip->ip_off & IP_MF)
            mhip->ip_off |= IP_MF;
@@ -140,7 +140,7 @@ ip_output(struct socket *so, struct mbuf *m0)
          mhip->ip_sum = 0;
          mhip->ip_sum = cksum(m, mhlen);
          *mnext = m;
-         mnext = &m->m_nextpkt;
+         mnext = &m->m_hdr.mh_nextpkt;
        }
        /*
         * Update first fragment by trimming what's been copied out
@@ -148,14 +148,14 @@ ip_output(struct socket *so, struct mbuf *m0)
         */
        m = m0;
        m_adj(m, hlen + firstlen - (uint16_t)ip->ip_len);
-       ip->ip_len = htons((uint16_t)m->m_len);
+       ip->ip_len = htons((uint16_t)m->m_hdr.mh_len);
        ip->ip_off = htons((uint16_t)(ip->ip_off | IP_MF));
        ip->ip_sum = 0;
        ip->ip_sum = cksum(m, hlen);
 sendorfree:
        for (m = m0; m; m = m0) {
-               m0 = m->m_nextpkt;
-                m->m_nextpkt = NULL;
+               m0 = m->m_hdr.mh_nextpkt;
+                m->m_hdr.mh_nextpkt = NULL;
                if (error == 0)
                        if_output(so, m);
                else
diff --git a/slirp/mbuf.c b/slirp/mbuf.c
index c699c75..beb7ffe 100644
--- a/slirp/mbuf.c
+++ b/slirp/mbuf.c
@@ -11,7 +11,7 @@
  * so that one whole packet can fit.  Mbuf's cannot be
  * chained together.  If there's more data than the mbuf
  * could hold, an external malloced buffer is pointed to
- * by m_ext (and the data pointers) and M_EXT is set in
+ * by M_dat.m_ext_ (and the data pointers) and M_EXT is set in
  * the flags
  */
 
@@ -23,13 +23,13 @@
  * Find a nice value for msize
  * XXX if_maxlinkhdr already in mtu
  */
-#define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + offsetof(struct mbuf, m_dat) + 6)
+#define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + offsetof(struct mbuf, 
M_dat.m_dat_) + 6)
 
 void
 m_init(Slirp *slirp)
 {
-    slirp->m_freelist.m_next = slirp->m_freelist.m_prev = &slirp->m_freelist;
-    slirp->m_usedlist.m_next = slirp->m_usedlist.m_prev = &slirp->m_usedlist;
+    slirp->m_freelist.m_hdr.mh_next = slirp->m_freelist.m_hdr.mh_prev = 
&slirp->m_freelist;
+    slirp->m_usedlist.m_hdr.mh_next = slirp->m_usedlist.m_hdr.mh_prev = 
&slirp->m_usedlist;
 }
 
 /*
@@ -48,7 +48,7 @@ m_get(Slirp *slirp)
 
        DEBUG_CALL("m_get");
 
-       if (slirp->m_freelist.m_next == &slirp->m_freelist) {
+       if (slirp->m_freelist.m_hdr.mh_next == &slirp->m_freelist) {
                m = (struct mbuf *)malloc(SLIRP_MSIZE);
                if (m == NULL) goto end_error;
                slirp->mbuf_alloced++;
@@ -56,20 +56,20 @@ m_get(Slirp *slirp)
                        flags = M_DOFREE;
                m->slirp = slirp;
        } else {
-               m = slirp->m_freelist.m_next;
+               m = slirp->m_freelist.m_hdr.mh_next;
                remque(m);
        }
 
        /* Insert it in the used list */
        insque(m,&slirp->m_usedlist);
-       m->m_flags = (flags | M_USEDLIST);
+       m->m_hdr.mh_flags = (flags | M_USEDLIST);
 
        /* Initialise it */
-       m->m_size = SLIRP_MSIZE - offsetof(struct mbuf, m_dat);
-       m->m_data = m->m_dat;
-       m->m_len = 0;
-        m->m_nextpkt = NULL;
-        m->m_prevpkt = NULL;
+       m->m_hdr.mh_size = SLIRP_MSIZE - offsetof(struct mbuf, M_dat.m_dat_);
+       m->m_hdr.mh_data = m->M_dat.m_dat_;
+       m->m_hdr.mh_len = 0;
+        m->m_hdr.mh_nextpkt = NULL;
+        m->m_hdr.mh_prevpkt = NULL;
         m->arp_requested = false;
         m->expiration_date = (uint64_t)-1;
 end_error:
@@ -86,22 +86,22 @@ m_free(struct mbuf *m)
 
   if(m) {
        /* Remove from m_usedlist */
-       if (m->m_flags & M_USEDLIST)
+       if (m->m_hdr.mh_flags & M_USEDLIST)
           remque(m);
 
        /* If it's M_EXT, free() it */
-       if (m->m_flags & M_EXT)
-          free(m->m_ext);
+       if (m->m_hdr.mh_flags & M_EXT)
+          free(m->M_dat.m_ext_);
 
        /*
         * Either free() it or put it on the free list
         */
-       if (m->m_flags & M_DOFREE) {
+       if (m->m_hdr.mh_flags & M_DOFREE) {
                m->slirp->mbuf_alloced--;
                free(m);
-       } else if ((m->m_flags & M_FREELIST) == 0) {
+       } else if ((m->m_hdr.mh_flags & M_FREELIST) == 0) {
                insque(m,&m->slirp->m_freelist);
-               m->m_flags = M_FREELIST; /* Clobber other flags */
+               m->m_hdr.mh_flags = M_FREELIST; /* Clobber other flags */
        }
   } /* if(m) */
 }
@@ -117,11 +117,11 @@ m_cat(struct mbuf *m, struct mbuf *n)
        /*
         * If there's no room, realloc
         */
-       if (M_FREEROOM(m) < n->m_len)
-               m_inc(m,m->m_size+MINCSIZE);
+       if (M_FREEROOM(m) < n->m_hdr.mh_len)
+               m_inc(m,m->m_hdr.mh_size+MINCSIZE);
 
-       memcpy(m->m_data+m->m_len, n->m_data, n->m_len);
-       m->m_len += n->m_len;
+       memcpy(m->m_hdr.mh_data+m->m_hdr.mh_len, n->m_hdr.mh_data, 
n->m_hdr.mh_len);
+       m->m_hdr.mh_len += n->m_hdr.mh_len;
 
        m_free(n);
 }
@@ -134,24 +134,24 @@ m_inc(struct mbuf *m, int size)
        int datasize;
 
        /* some compiles throw up on gotos.  This one we can fake. */
-        if(m->m_size>size) return;
+        if(m->m_hdr.mh_size>size) return;
 
-        if (m->m_flags & M_EXT) {
-         datasize = m->m_data - m->m_ext;
-         m->m_ext = (char *)realloc(m->m_ext,size);
-         m->m_data = m->m_ext + datasize;
+        if (m->m_hdr.mh_flags & M_EXT) {
+         datasize = m->m_hdr.mh_data - m->M_dat.m_ext_;
+         m->M_dat.m_ext_ = (char *)realloc(m->M_dat.m_ext_,size);
+         m->m_hdr.mh_data = m->M_dat.m_ext_ + datasize;
         } else {
          char *dat;
-         datasize = m->m_data - m->m_dat;
+         datasize = m->m_hdr.mh_data - m->M_dat.m_dat_;
          dat = (char *)malloc(size);
-         memcpy(dat, m->m_dat, m->m_size);
+         memcpy(dat, m->M_dat.m_dat_, m->m_hdr.mh_size);
 
-         m->m_ext = dat;
-         m->m_data = m->m_ext + datasize;
-         m->m_flags |= M_EXT;
+         m->M_dat.m_ext_ = dat;
+         m->m_hdr.mh_data = m->M_dat.m_ext_ + datasize;
+         m->m_hdr.mh_flags |= M_EXT;
         }
 
-        m->m_size = size;
+        m->m_hdr.mh_size = size;
 
 }
 
@@ -164,12 +164,12 @@ m_adj(struct mbuf *m, int len)
                return;
        if (len >= 0) {
                /* Trim from head */
-               m->m_data += len;
-               m->m_len -= len;
+               m->m_hdr.mh_data += len;
+               m->m_hdr.mh_len -= len;
        } else {
                /* Trim from tail */
                len = -len;
-               m->m_len -= len;
+               m->m_hdr.mh_len -= len;
        }
 }
 
@@ -183,8 +183,8 @@ m_copy(struct mbuf *n, struct mbuf *m, int off, int len)
        if (len > M_FREEROOM(n))
                return -1;
 
-       memcpy((n->m_data + n->m_len), (m->m_data + off), len);
-       n->m_len += len;
+       memcpy((n->m_hdr.mh_data + n->m_hdr.mh_len), (m->m_hdr.mh_data + off), 
len);
+       n->m_hdr.mh_len += len;
        return 0;
 }
 
@@ -203,13 +203,13 @@ dtom(Slirp *slirp, void *dat)
        DEBUG_ARG("dat = %lx", (long )dat);
 
        /* bug corrected for M_EXT buffers */
-       for (m = slirp->m_usedlist.m_next; m != &slirp->m_usedlist;
-            m = m->m_next) {
-         if (m->m_flags & M_EXT) {
-           if( (char *)dat>=m->m_ext && (char *)dat<(m->m_ext + m->m_size) )
+       for (m = slirp->m_usedlist.m_hdr.mh_next; m != &slirp->m_usedlist;
+            m = m->m_hdr.mh_next) {
+         if (m->m_hdr.mh_flags & M_EXT) {
+           if( (char *)dat>=m->M_dat.m_ext_ && (char *)dat<(m->M_dat.m_ext_ + 
m->m_hdr.mh_size) )
              return m;
          } else {
-           if( (char *)dat >= m->m_dat && (char *)dat<(m->m_dat + m->m_size) )
+           if( (char *)dat >= m->M_dat.m_dat_ && (char *)dat<(m->M_dat.m_dat_ 
+ m->m_hdr.mh_size) )
              return m;
          }
        }
diff --git a/slirp/mbuf.h b/slirp/mbuf.h
index 0708840..292cbb3 100644
--- a/slirp/mbuf.h
+++ b/slirp/mbuf.h
@@ -39,14 +39,14 @@
  * Macros for type conversion
  * mtod(m,t) - convert mbuf pointer to data pointer of correct type
  */
-#define mtod(m,t)      ((t)(m)->m_data)
+#define mtod(m,t)      ((t)(m)->m_hdr.mh_data)
 
 /* XXX About mbufs for slirp:
  * Only one mbuf is ever used in a chain, for each "cell" of data.
- * m_nextpkt points to the next packet, if fragmented.
+ * m_hdr.mh_nextpkt points to the next packet, if fragmented.
  * If the data is too large, the M_EXT is used, and a larger block
  * is alloced.  Therefore, m_free[m] must check for M_EXT and if set
- * free the m_ext.  This is inefficient memory-wise, but who cares.
+ * free the M_dat.m_ext_.  This is inefficient memory-wise, but who cares.
  */
 
 /* XXX should union some of these! */
@@ -66,17 +66,17 @@ struct m_hdr {
 };
 
 /*
- * How much room is in the mbuf, from m_data to the end of the mbuf
+ * How much room is in the mbuf, from m_hdr.mh_data to the end of the mbuf
  */
-#define M_ROOM(m) ((m->m_flags & M_EXT)? \
-                       (((m)->m_ext + (m)->m_size) - (m)->m_data) \
+#define M_ROOM(m) ((m->m_hdr.mh_flags & M_EXT)? \
+                       (((m)->M_dat.m_ext_ + (m)->m_hdr.mh_size) - 
(m)->m_hdr.mh_data) \
                   : \
-                       (((m)->m_dat + (m)->m_size) - (m)->m_data))
+                       (((m)->M_dat.m_dat_ + (m)->m_hdr.mh_size) - 
(m)->m_hdr.mh_data))
 
 /*
  * How much free room there is
  */
-#define M_FREEROOM(m) (M_ROOM(m) - (m)->m_len)
+#define M_FREEROOM(m) (M_ROOM(m) - (m)->m_hdr.mh_len)
 #define M_TRAILINGSPACE M_FREEROOM
 
 struct mbuf {
@@ -91,25 +91,7 @@ struct mbuf {
        } M_dat;
 };
 
-#define m_next         m_hdr.mh_next
-#define m_prev         m_hdr.mh_prev
-#define m_nextpkt      m_hdr.mh_nextpkt
-#define m_prevpkt      m_hdr.mh_prevpkt
-#define m_flags                m_hdr.mh_flags
-#define        m_len           m_hdr.mh_len
-#define        m_data          m_hdr.mh_data
-#define m_size         m_hdr.mh_size
-#define m_dat          M_dat.m_dat_
-#define m_ext          M_dat.m_ext_
-#define m_so           m_hdr.mh_so
-
-#define ifq_prev m_prev
-#define ifq_next m_next
-#define ifs_prev m_prevpkt
-#define ifs_next m_nextpkt
-#define ifq_so m_so
-
-#define M_EXT                  0x01    /* m_ext points to more (malloced) data 
*/
+#define M_EXT                  0x01    /* M_dat.m_ext_ points to more 
(malloced) data */
 #define M_FREELIST             0x02    /* mbuf is on free list */
 #define M_USEDLIST             0x04    /* XXX mbuf is on used list (for 
dtom()) */
 #define M_DOFREE               0x08    /* when m_free is called on the mbuf, 
free()
diff --git a/slirp/sbuf.c b/slirp/sbuf.c
index 5a1ccbf..182e643 100644
--- a/slirp/sbuf.c
+++ b/slirp/sbuf.c
@@ -68,10 +68,10 @@ sbappend(struct socket *so, struct mbuf *m)
        DEBUG_CALL("sbappend");
        DEBUG_ARG("so = %lx", (long)so);
        DEBUG_ARG("m = %lx", (long)m);
-       DEBUG_ARG("m->m_len = %d", m->m_len);
+       DEBUG_ARG("m->m_hdr.mh_len = %d", m->m_hdr.mh_len);
 
        /* Shouldn't happen, but...  e.g. foreign host closes connection */
-       if (m->m_len <= 0) {
+       if (m->m_hdr.mh_len <= 0) {
                m_free(m);
                return;
        }
@@ -93,7 +93,7 @@ sbappend(struct socket *so, struct mbuf *m)
         * ottherwise it'll arrive out of order, and hence corrupt
         */
        if (!so->so_rcv.sb_cc)
-          ret = slirp_send(so, m->m_data, m->m_len, 0);
+          ret = slirp_send(so, m->m_hdr.mh_data, m->m_hdr.mh_len, 0);
 
        if (ret <= 0) {
                /*
@@ -103,13 +103,13 @@ sbappend(struct socket *so, struct mbuf *m)
                 * it will be detected in the normal way by soread()
                 */
                sbappendsb(&so->so_rcv, m);
-       } else if (ret != m->m_len) {
+       } else if (ret != m->m_hdr.mh_len) {
                /*
                 * Something was written, but not everything..
                 * sbappendsb the rest
                 */
-               m->m_len -= ret;
-               m->m_data += ret;
+               m->m_hdr.mh_len -= ret;
+               m->m_hdr.mh_data += ret;
                sbappendsb(&so->so_rcv, m);
        } /* else */
        /* Whatever happened, we free the mbuf */
@@ -125,23 +125,23 @@ sbappendsb(struct sbuf *sb, struct mbuf *m)
 {
        int len, n,  nn;
 
-       len = m->m_len;
+       len = m->m_hdr.mh_len;
 
        if (sb->sb_wptr < sb->sb_rptr) {
                n = sb->sb_rptr - sb->sb_wptr;
                if (n > len) n = len;
-               memcpy(sb->sb_wptr, m->m_data, n);
+               memcpy(sb->sb_wptr, m->m_hdr.mh_data, n);
        } else {
                /* Do the right edge first */
                n = sb->sb_data + sb->sb_datalen - sb->sb_wptr;
                if (n > len) n = len;
-               memcpy(sb->sb_wptr, m->m_data, n);
+               memcpy(sb->sb_wptr, m->m_hdr.mh_data, n);
                len -= n;
                if (len) {
                        /* Now the left edge */
                        nn = sb->sb_rptr - sb->sb_data;
                        if (nn > len) nn = len;
-                       memcpy(sb->sb_data,m->m_data+n,nn);
+                       memcpy(sb->sb_data,m->m_hdr.mh_data+n,nn);
                        n += nn;
                }
        }
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 19d69eb..b33211c 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -679,11 +679,11 @@ void slirp_input(Slirp *slirp, const uint8_t *pkt, int 
pkt_len)
         if (M_FREEROOM(m) < pkt_len + 2) {
             m_inc(m, pkt_len + 2);
         }
-        m->m_len = pkt_len + 2;
-        memcpy(m->m_data + 2, pkt, pkt_len);
+        m->m_hdr.mh_len = pkt_len + 2;
+        memcpy(m->m_hdr.mh_data + 2, pkt, pkt_len);
 
-        m->m_data += 2 + ETH_HLEN;
-        m->m_len -= 2 + ETH_HLEN;
+        m->m_hdr.mh_data += 2 + ETH_HLEN;
+        m->m_hdr.mh_len -= 2 + ETH_HLEN;
 
         ip_input(m);
         break;
@@ -700,9 +700,9 @@ int if_encap(Slirp *slirp, struct mbuf *ifm)
     uint8_t buf[1600];
     struct ethhdr *eh = (struct ethhdr *)buf;
     uint8_t ethaddr[ETH_ALEN];
-    const struct ip *iph = (const struct ip *)ifm->m_data;
+    const struct ip *iph = (const struct ip *)ifm->m_hdr.mh_data;
 
-    if (ifm->m_len + ETH_HLEN > sizeof(buf)) {
+    if (ifm->m_hdr.mh_len + ETH_HLEN > sizeof(buf)) {
         return 1;
     }
 
@@ -749,8 +749,8 @@ int if_encap(Slirp *slirp, struct mbuf *ifm)
         /* XXX: not correct */
         memcpy(&eh->h_source[2], &slirp->vhost_addr, 4);
         eh->h_proto = htons(ETH_P_IP);
-        memcpy(buf + sizeof(struct ethhdr), ifm->m_data, ifm->m_len);
-        slirp_output(slirp->opaque, buf, ifm->m_len + ETH_HLEN);
+        memcpy(buf + sizeof(struct ethhdr), ifm->m_hdr.mh_data, 
ifm->m_hdr.mh_len);
+        slirp_output(slirp->opaque, buf, ifm->m_hdr.mh_len + ETH_HLEN);
         return 1;
     }
 }
diff --git a/slirp/socket.c b/slirp/socket.c
index 77b0c98..f59c403 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -478,7 +478,7 @@ sorecvfrom(struct socket *so)
          if (!m) {
              return;
          }
-         m->m_data += IF_MAXLINKHDR;
+         m->m_hdr.mh_data += IF_MAXLINKHDR;
 
          /*
           * XXX Shouldn't FIONREAD packets destined for port 53,
@@ -489,17 +489,17 @@ sorecvfrom(struct socket *so)
          ioctlsocket(so->s, FIONREAD, &n);
 
          if (n > len) {
-           n = (m->m_data - m->m_dat) + m->m_len + n + 1;
+           n = (m->m_hdr.mh_data - m->M_dat.m_dat_) + m->m_hdr.mh_len + n + 1;
            m_inc(m, n);
            len = M_FREEROOM(m);
          }
          /* } */
 
-         m->m_len = recvfrom(so->s, m->m_data, len, 0,
+         m->m_hdr.mh_len = recvfrom(so->s, m->m_hdr.mh_data, len, 0,
                              (struct sockaddr *)&addr, &addrlen);
          DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
-                     m->m_len, errno,strerror(errno)));
-         if(m->m_len<0) {
+                     m->m_hdr.mh_len, errno,strerror(errno)));
+         if(m->m_hdr.mh_len<0) {
            u_char code=ICMP_UNREACH_PORT;
 
            if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
@@ -562,7 +562,7 @@ sosendto(struct socket *so, struct mbuf *m)
        DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, 
addr.sin_addr.s_addr=%.16s\n", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
 
        /* Don't care what port we get */
-       ret = sendto(so->s, m->m_data, m->m_len, 0,
+       ret = sendto(so->s, m->m_hdr.mh_data, m->m_hdr.mh_len, 0,
                     (struct sockaddr *)&addr, sizeof (struct sockaddr));
        if (ret < 0)
                return -1;
diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c
index 942aaf4..f740978 100644
--- a/slirp/tcp_input.c
+++ b/slirp/tcp_input.c
@@ -313,8 +313,8 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
        /*
         * Drop TCP, IP headers and TCP options.
         */
-       m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
-       m->m_len  -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
+       m->m_hdr.mh_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
+       m->m_hdr.mh_len  -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
 
     if (slirp->restricted) {
         for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
@@ -592,8 +592,8 @@ findso:
              HTONL(ti->ti_ack);
              HTONS(ti->ti_win);
              HTONS(ti->ti_urp);
-             m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
-             m->m_len  += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
+             m->m_hdr.mh_data -= sizeof(struct tcpiphdr)+off-sizeof(struct 
tcphdr);
+             m->m_hdr.mh_len  += sizeof(struct tcpiphdr)+off-sizeof(struct 
tcphdr);
              *ip=save_ip;
              icmp_error(m, ICMP_UNREACH,code, 0,strerror(errno));
            }
@@ -1342,18 +1342,18 @@ tcp_pulloutofband(so, ti, m)
        int cnt = ti->ti_urp - 1;
 
        while (cnt >= 0) {
-               if (m->m_len > cnt) {
+               if (m->m_hdr.mh_len > cnt) {
                        char *cp = mtod(m, caddr_t) + cnt;
                        struct tcpcb *tp = sototcpcb(so);
 
                        tp->t_iobc = *cp;
                        tp->t_oobflags |= TCPOOB_HAVEDATA;
-                       memcpy(sp, cp+1, (unsigned)(m->m_len - cnt - 1));
-                       m->m_len--;
+                       memcpy(sp, cp+1, (unsigned)(m->m_hdr.mh_len - cnt - 1));
+                       m->m_hdr.mh_len--;
                        return;
                }
-               cnt -= m->m_len;
-               m = m->m_next; /* XXX WRONG! Fix it! */
+               cnt -= m->m_hdr.mh_len;
+               m = m->m_hdr.mh_next; /* XXX WRONG! Fix it! */
                if (m == 0)
                        break;
        }
diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c
index 779314b..269b642 100644
--- a/slirp/tcp_output.c
+++ b/slirp/tcp_output.c
@@ -295,11 +295,11 @@ send:
                        error = 1;
                        goto out;
                }
-               m->m_data += IF_MAXLINKHDR;
-               m->m_len = hdrlen;
+               m->m_hdr.mh_data += IF_MAXLINKHDR;
+               m->m_hdr.mh_len = hdrlen;
 
                sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
-               m->m_len += len;
+               m->m_hdr.mh_len += len;
 
                /*
                 * If we're sending everything we've got, set PUSH.
@@ -315,8 +315,8 @@ send:
                        error = 1;
                        goto out;
                }
-               m->m_data += IF_MAXLINKHDR;
-               m->m_len = hdrlen;
+               m->m_hdr.mh_data += IF_MAXLINKHDR;
+               m->m_hdr.mh_len = hdrlen;
        }
 
        ti = mtod(m, struct tcpiphdr *);
@@ -444,11 +444,11 @@ send:
         * to handle ttl and tos; we could keep them in
         * the template, but need a way to checksum without them.
         */
-       m->m_len = hdrlen + len; /* XXX Needed? m_len should be correct */
+       m->m_hdr.mh_len = hdrlen + len; /* XXX Needed? m_hdr.mh_len should be 
correct */
 
     {
 
-       ((struct ip *)ti)->ip_len = m->m_len;
+       ((struct ip *)ti)->ip_len = m->m_hdr.mh_len;
 
        ((struct ip *)ti)->ip_ttl = IPDEFTTL;
        ((struct ip *)ti)->ip_tos = so->so_iptos;
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 143a238..bf52689 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -120,7 +120,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct 
mbuf *m,
                if ((m = m_get(tp->t_socket->slirp)) == NULL)
                        return;
                tlen = 0;
-               m->m_data += IF_MAXLINKHDR;
+               m->m_hdr.mh_data += IF_MAXLINKHDR;
                *mtod(m, struct tcpiphdr *) = *ti;
                ti = mtod(m, struct tcpiphdr *);
                flags = TH_ACK;
@@ -129,9 +129,9 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct 
mbuf *m,
                 * ti points into m so the next line is just making
                 * the mbuf point to ti
                 */
-               m->m_data = (caddr_t)ti;
+               m->m_hdr.mh_data = (caddr_t)ti;
 
-               m->m_len = sizeof (struct tcpiphdr);
+               m->m_hdr.mh_len = sizeof (struct tcpiphdr);
                tlen = 0;
 #define xchg(a,b,type) { type t; t=a; a=b; b=t; }
                xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, uint32_t);
@@ -140,7 +140,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct 
mbuf *m,
        }
        ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
        tlen += sizeof (struct tcpiphdr);
-       m->m_len = tlen;
+       m->m_hdr.mh_len = tlen;
 
         ti->ti_mbuf = NULL;
        ti->ti_x1 = 0;
@@ -570,11 +570,11 @@ tcp_emu(struct socket *so, struct mbuf *m)
                        socklen_t addrlen = sizeof(struct sockaddr_in);
                        struct sbuf *so_rcv = &so->so_rcv;
 
-                       memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
-                       so_rcv->sb_wptr += m->m_len;
-                       so_rcv->sb_rptr += m->m_len;
-                       m->m_data[m->m_len] = 0; /* NULL terminate */
-                       if (strchr(m->m_data, '\r') || strchr(m->m_data, '\n')) 
{
+                       memcpy(so_rcv->sb_wptr, m->m_hdr.mh_data, 
m->m_hdr.mh_len);
+                       so_rcv->sb_wptr += m->m_hdr.mh_len;
+                       so_rcv->sb_rptr += m->m_hdr.mh_len;
+                       m->m_hdr.mh_data[m->m_hdr.mh_len] = 0; /* NULL 
terminate */
+                       if (strchr(m->m_hdr.mh_data, '\r') || 
strchr(m->m_hdr.mh_data, '\n')) {
                                if (sscanf(so_rcv->sb_data, "%u%*[ ,]%u", &n1, 
&n2) == 2) {
                                        HTONS(n1);
                                        HTONS(n2);
@@ -604,8 +604,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
                }
 
         case EMU_FTP: /* ftp */
-                *(m->m_data+m->m_len) = 0; /* NUL terminate for strstr */
-               if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
+                *(m->m_hdr.mh_data+m->m_hdr.mh_len) = 0; /* NUL terminate for 
strstr */
+               if ((bptr = (char *)strstr(m->m_hdr.mh_data, "ORT")) != NULL) {
                        /*
                         * Need to emulate the PORT command
                         */
@@ -633,12 +633,12 @@ tcp_emu(struct socket *so, struct mbuf *m)
                        n3 = ((laddr >> 8)  & 0xff);
                        n4 =  (laddr & 0xff);
 
-                       m->m_len = bptr - m->m_data; /* Adjust length */
-                        m->m_len += snprintf(bptr, m->m_hdr.mh_size - m->m_len,
+                       m->m_hdr.mh_len = bptr - m->m_hdr.mh_data; /* Adjust 
length */
+                        m->m_hdr.mh_len += snprintf(bptr, m->m_hdr.mh_size - 
m->m_hdr.mh_len,
                                              "ORT %d,%d,%d,%d,%d,%d\r\n%s",
                                              n1, n2, n3, n4, n5, n6, 
x==7?buff:"");
                        return 1;
-               } else if ((bptr = (char *)strstr(m->m_data, "27 Entering")) != 
NULL) {
+               } else if ((bptr = (char *)strstr(m->m_hdr.mh_data, "27 
Entering")) != NULL) {
                        /*
                         * Need to emulate the PASV response
                         */
@@ -666,8 +666,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
                        n3 = ((laddr >> 8)  & 0xff);
                        n4 =  (laddr & 0xff);
 
-                       m->m_len = bptr - m->m_data; /* Adjust length */
-                       m->m_len += snprintf(bptr, m->m_hdr.mh_size - m->m_len,
+                       m->m_hdr.mh_len = bptr - m->m_hdr.mh_data; /* Adjust 
length */
+                       m->m_hdr.mh_len += snprintf(bptr, m->m_hdr.mh_size - 
m->m_hdr.mh_len,
                                              "27 Entering Passive Mode 
(%d,%d,%d,%d,%d,%d)\r\n%s",
                                              n1, n2, n3, n4, n5, n6, 
x==7?buff:"");
 
@@ -684,16 +684,16 @@ tcp_emu(struct socket *so, struct mbuf *m)
                 * of the connection as a NUL-terminated decimal ASCII string.
                 */
                so->so_emu = 0;
-               for (lport = 0, i = 0; i < m->m_len-1; ++i) {
-                       if (m->m_data[i] < '0' || m->m_data[i] > '9')
+               for (lport = 0, i = 0; i < m->m_hdr.mh_len-1; ++i) {
+                       if (m->m_hdr.mh_data[i] < '0' || m->m_hdr.mh_data[i] > 
'9')
                                return 1;       /* invalid number */
                        lport *= 10;
-                       lport += m->m_data[i] - '0';
+                       lport += m->m_hdr.mh_data[i] - '0';
                }
-               if (m->m_data[m->m_len-1] == '\0' && lport != 0 &&
+               if (m->m_hdr.mh_data[m->m_hdr.mh_len-1] == '\0' && lport != 0 &&
                    (so = tcp_listen(slirp, INADDR_ANY, 0, so->so_laddr.s_addr,
                                     htons(lport), SS_FACCEPTONCE)) != NULL)
-                    m->m_len = snprintf(m->m_data, m->m_hdr.mh_size, "%d",
+                    m->m_hdr.mh_len = snprintf(m->m_hdr.mh_data, 
m->m_hdr.mh_size, "%d",
                                         ntohs(so->so_fport)) + 1;
                return 1;
 
@@ -701,8 +701,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
                /*
                 * Need to emulate DCC CHAT, DCC SEND and DCC MOVE
                 */
-               *(m->m_data+m->m_len) = 0; /* NULL terminate the string for 
strstr */
-               if ((bptr = (char *)strstr(m->m_data, "DCC")) == NULL)
+               *(m->m_hdr.mh_data+m->m_hdr.mh_len) = 0; /* NULL terminate the 
string for strstr */
+               if ((bptr = (char *)strstr(m->m_hdr.mh_data, "DCC")) == NULL)
                         return 1;
 
                /* The %256s is for the broken mIRC */
@@ -712,8 +712,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
                                             SS_FACCEPTONCE)) == NULL) {
                                return 1;
                        }
-                       m->m_len = bptr - m->m_data; /* Adjust length */
-                        m->m_len += snprintf(bptr, m->m_hdr.mh_size,
+                       m->m_hdr.mh_len = bptr - m->m_hdr.mh_data; /* Adjust 
length */
+                        m->m_hdr.mh_len += snprintf(bptr, m->m_hdr.mh_size,
                                              "DCC CHAT chat %lu %u%c\n",
                                              (unsigned 
long)ntohl(so->so_faddr.s_addr),
                                              ntohs(so->so_fport), 1);
@@ -723,8 +723,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
                                             SS_FACCEPTONCE)) == NULL) {
                                return 1;
                        }
-                       m->m_len = bptr - m->m_data; /* Adjust length */
-                        m->m_len += snprintf(bptr, m->m_hdr.mh_size,
+                       m->m_hdr.mh_len = bptr - m->m_hdr.mh_data; /* Adjust 
length */
+                        m->m_hdr.mh_len += snprintf(bptr, m->m_hdr.mh_size,
                                              "DCC SEND %s %lu %u %u%c\n", buff,
                                              (unsigned 
long)ntohl(so->so_faddr.s_addr),
                                              ntohs(so->so_fport), n1, 1);
@@ -734,8 +734,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
                                             SS_FACCEPTONCE)) == NULL) {
                                return 1;
                        }
-                       m->m_len = bptr - m->m_data; /* Adjust length */
-                        m->m_len += snprintf(bptr, m->m_hdr.mh_size,
+                       m->m_hdr.mh_len = bptr - m->m_hdr.mh_data; /* Adjust 
length */
+                        m->m_hdr.mh_len += snprintf(bptr, m->m_hdr.mh_size,
                                              "DCC MOVE %s %lu %u %u%c\n", buff,
                                              (unsigned 
long)ntohl(so->so_faddr.s_addr),
                                              ntohs(so->so_fport), n1, 1);
@@ -779,8 +779,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
                 * us where we're going.
                 */
 
-               bptr = m->m_data;
-               while (bptr < m->m_data + m->m_len) {
+               bptr = m->m_hdr.mh_data;
+               while (bptr < m->m_hdr.mh_data + m->m_hdr.mh_len) {
                        u_short p;
                        static int ra = 0;
                        char ra_tbl[4];
diff --git a/slirp/tftp.c b/slirp/tftp.c
index b78765f..5ed5882 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -129,11 +129,11 @@ static int tftp_send_oack(struct tftp_session *spt,
     if (!m)
        return -1;
 
-    memset(m->m_data, 0, m->m_size);
+    memset(m->m_hdr.mh_data, 0, m->m_hdr.mh_size);
 
-    m->m_data += IF_MAXLINKHDR;
-    tp = (void *)m->m_data;
-    m->m_data += sizeof(struct udpiphdr);
+    m->m_hdr.mh_data += IF_MAXLINKHDR;
+    tp = (void *)m->m_hdr.mh_data;
+    m->m_hdr.mh_data += sizeof(struct udpiphdr);
 
     tp->tp_op = htons(TFTP_OACK);
     n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",
@@ -147,7 +147,7 @@ static int tftp_send_oack(struct tftp_session *spt,
     daddr.sin_addr = spt->client_ip;
     daddr.sin_port = spt->client_port;
 
-    m->m_len = sizeof(struct tftp_t) - 514 + n -
+    m->m_hdr.mh_len = sizeof(struct tftp_t) - 514 + n -
         sizeof(struct ip) - sizeof(struct udphdr);
     udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
 
@@ -168,11 +168,11 @@ static void tftp_send_error(struct tftp_session *spt,
     goto out;
   }
 
-  memset(m->m_data, 0, m->m_size);
+  memset(m->m_hdr.mh_data, 0, m->m_hdr.mh_size);
 
-  m->m_data += IF_MAXLINKHDR;
-  tp = (void *)m->m_data;
-  m->m_data += sizeof(struct udpiphdr);
+  m->m_hdr.mh_data += IF_MAXLINKHDR;
+  tp = (void *)m->m_hdr.mh_data;
+  m->m_hdr.mh_data += sizeof(struct udpiphdr);
 
   tp->tp_op = htons(TFTP_ERROR);
   tp->x.tp_error.tp_error_code = htons(errorcode);
@@ -184,7 +184,7 @@ static void tftp_send_error(struct tftp_session *spt,
   daddr.sin_addr = spt->client_ip;
   daddr.sin_port = spt->client_port;
 
-  m->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) -
+  m->m_hdr.mh_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) -
         sizeof(struct ip) - sizeof(struct udphdr);
 
   udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
@@ -212,11 +212,11 @@ static int tftp_send_data(struct tftp_session *spt,
     return -1;
   }
 
-  memset(m->m_data, 0, m->m_size);
+  memset(m->m_hdr.mh_data, 0, m->m_hdr.mh_size);
 
-  m->m_data += IF_MAXLINKHDR;
-  tp = (void *)m->m_data;
-  m->m_data += sizeof(struct udpiphdr);
+  m->m_hdr.mh_data += IF_MAXLINKHDR;
+  tp = (void *)m->m_hdr.mh_data;
+  m->m_hdr.mh_data += sizeof(struct udpiphdr);
 
   tp->tp_op = htons(TFTP_DATA);
   tp->x.tp_data.tp_block_nr = htons(block_nr);
@@ -239,7 +239,7 @@ static int tftp_send_data(struct tftp_session *spt,
     return -1;
   }
 
-  m->m_len = sizeof(struct tftp_t) - (512 - nobytes) -
+  m->m_hdr.mh_len = sizeof(struct tftp_t) - (512 - nobytes) -
         sizeof(struct ip) - sizeof(struct udphdr);
 
   udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
@@ -404,19 +404,19 @@ static void tftp_handle_error(Slirp *slirp, struct tftp_t 
*tp, int pktlen)
 
 void tftp_input(struct mbuf *m)
 {
-  struct tftp_t *tp = (struct tftp_t *)m->m_data;
+  struct tftp_t *tp = (struct tftp_t *)m->m_hdr.mh_data;
 
   switch(ntohs(tp->tp_op)) {
   case TFTP_RRQ:
-    tftp_handle_rrq(m->slirp, tp, m->m_len);
+    tftp_handle_rrq(m->slirp, tp, m->m_hdr.mh_len);
     break;
 
   case TFTP_ACK:
-    tftp_handle_ack(m->slirp, tp, m->m_len);
+    tftp_handle_ack(m->slirp, tp, m->m_hdr.mh_len);
     break;
 
   case TFTP_ERROR:
-    tftp_handle_error(m->slirp, tp, m->m_len);
+    tftp_handle_error(m->slirp, tp, m->m_hdr.mh_len);
     break;
   }
 }
diff --git a/slirp/udp.c b/slirp/udp.c
index 5b060f3..3035e4f 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -49,8 +49,8 @@ udp_init(Slirp *slirp)
     slirp->udb.so_next = slirp->udb.so_prev = &slirp->udb;
     slirp->udp_last_so = &slirp->udb;
 }
-/* m->m_data  points at ip packet header
- * m->m_len   length ip packet
+/* m->m_hdr.mh_data  points at ip packet header
+ * m->m_hdr.mh_len   length ip packet
  * ip->ip_len length data (IPDU)
  */
 void
@@ -198,15 +198,15 @@ udp_input(register struct mbuf *m, int iphlen)
         so->so_fport = uh->uh_dport; /* XXX */
 
        iphlen += sizeof(struct udphdr);
-       m->m_len -= iphlen;
-       m->m_data += iphlen;
+       m->m_hdr.mh_len -= iphlen;
+       m->m_hdr.mh_data += iphlen;
 
        /*
         * Now we sendto() the packet.
         */
        if(sosendto(so,m) == -1) {
-         m->m_len += iphlen;
-         m->m_data -= iphlen;
+         m->m_hdr.mh_len += iphlen;
+         m->m_hdr.mh_data -= iphlen;
          *ip=save_ip;
          DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
          icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
@@ -215,8 +215,8 @@ udp_input(register struct mbuf *m, int iphlen)
        m_free(so->so_m);   /* used for ICMP if error on sorecvfrom */
 
        /* restore the orig mbuf packet */
-       m->m_len += iphlen;
-       m->m_data -= iphlen;
+       m->m_hdr.mh_len += iphlen;
+       m->m_hdr.mh_data -= iphlen;
        *ip=save_ip;
        so->so_m=m;         /* ICMP backup */
 
@@ -242,8 +242,8 @@ int udp_output2(struct socket *so, struct mbuf *m,
        /*
         * Adjust for header
         */
-       m->m_data -= sizeof(struct udpiphdr);
-       m->m_len += sizeof(struct udpiphdr);
+       m->m_hdr.mh_data -= sizeof(struct udpiphdr);
+       m->m_hdr.mh_len += sizeof(struct udpiphdr);
 
        /*
         * Fill in mbuf with extended UDP header
@@ -253,7 +253,7 @@ int udp_output2(struct socket *so, struct mbuf *m,
     memset(&ui->ui_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr));
        ui->ui_x1 = 0;
        ui->ui_pr = IPPROTO_UDP;
-       ui->ui_len = htons(m->m_len - sizeof(struct ip));
+       ui->ui_len = htons(m->m_hdr.mh_len - sizeof(struct ip));
        /* XXXXX Check for from-one-location sockets, or from-any-location 
sockets */
         ui->ui_src = saddr->sin_addr;
        ui->ui_dst = daddr->sin_addr;
@@ -265,9 +265,9 @@ int udp_output2(struct socket *so, struct mbuf *m,
         * Stuff checksum and output datagram.
         */
        ui->ui_sum = 0;
-       if ((ui->ui_sum = cksum(m, m->m_len)) == 0)
+       if ((ui->ui_sum = cksum(m, m->m_hdr.mh_len)) == 0)
                ui->ui_sum = 0xffff;
-       ((struct ip *)ui)->ip_len = m->m_len;
+       ((struct ip *)ui)->ip_len = m->m_hdr.mh_len;
 
        ((struct ip *)ui)->ip_ttl = IPDEFTTL;
        ((struct ip *)ui)->ip_tos = iptos;
-- 
1.7.9.111.gf3fb0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]