qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] slirp: Use lduw_be_p in slirp_input


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH] slirp: Use lduw_be_p in slirp_input
Date: Fri, 18 Jan 2019 15:37:17 +0400

Hi

On Fri, Jan 18, 2019 at 3:25 PM Marc-André Lureau
<address@hidden> wrote:
>
> Hi
>
> On Thu, Jan 17, 2019 at 5:56 PM Peter Maydell <address@hidden> wrote:
> >
> > On Thu, 17 Jan 2019 at 13:41, Philippe Mathieu-Daudé <address@hidden> wrote:
> > > On 1/17/19 12:50 AM, Samuel Thibault wrote:
> > > > --- a/slirp/slirp.c
> > > > +++ b/slirp/slirp.c
> > > > @@ -851,7 +851,7 @@ void slirp_input(Slirp *slirp, const uint8_t *pkt, 
> > > > int pkt_len)
> > > >      if (pkt_len < ETH_HLEN)
> > > >          return;
> > > >
> > > > -    proto = ntohs(*(uint16_t *)(pkt + 12));
> > > > +    proto = (((uint16_t) pkt[12]) << 8) + pkt[13];
> > > >      switch(proto) {
> > > >      case ETH_P_ARP:
> > > >          arp_input(slirp, pkt, pkt_len);
> > >
> > > What about using memcpy?
> >
> > We should use whatever the new libslirp wants to consistently
> > use as its mechanism for loading unaligned data. I don't
> > suppose this is the only place where it ever needs to do this.
> >
> > Personally I would vote for having libslirp have versions of
> > the ld*_p functions, because they solve the problem in a
> > clear and correct way. But that's up to Marc-André really.
>
> I think I would go with a copy of qemu bswap.h, unless there is an
> equivalent in glib (I don't think so) or gnulib? Or other standard
> compiler solution.
>

The GStreamer solution is also quite readable.
https://gitlab.freedesktop.org/gstreamer/gstreamer/blob/master/gst/gstutils.h#L165


-- 
Marc-André Lureau



reply via email to

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