On Thu, Jun 30, 2022 at 12:40 AM Nathan Hartman <hartman.nat...@gmail.com>
wrote:

> On Wed, Jun 29, 2022 at 12:23 PM Xiang Xiao <xiaoxiang781...@gmail.com>
> wrote:
> >
> > On Wed, Jun 29, 2022 at 4:44 AM Nathan Hartman <hartman.nat...@gmail.com
> >
> > wrote:
> >
> > > On Tue, Jun 28, 2022 at 4:05 PM Nathan Hartman <
> hartman.nat...@gmail.com>
> > > wrote:
> > > >
> > > > I have a program that builds under Linux, BSD, and macOS which
> > > > includes the net/if_arp.h header.
> > > >
> > > > This header does not seem to exist under NuttX.
> > > >
> > > > It is included for the ARPHRD_ETHER define (and possibly other
> things).
> > > >
> > > > I see that under NuttX, this is defined in net/arp.h, rather than
> > > net/if_arp.h.
> > > >
> > > > Is net/if_arp.h supposed to be a standard header? I cannot seem to
> > > > find any meaningful information about it.
> > > >
> > >
> >
> > If no standard defines it, it's better to follow other OS(especially,
> other
> > POSIX compliant)'s practices.
>
>
> Hmm... well the net/if_arp.h header seems to exist on Linux and macOS
> (BSD), so maybe we need to do something similar.
>
> I still can't seem to find much information about this header, so for
> now I added a special case: if __NuttX__ is defined then I #include
> <nuttx/net/arp.h>. Otherwise I include <net/if_arp.h>. It builds, but
> I do not know if the code that uses the ARPHRD_ETHER define is working
> correctly because I haven't tested it yet.
>
> The code is trying to get the MAC address of a Ethernet interface
> using ioctl SIOCGIFHWADDR on a temporary socket. In the returned
> struct ifreq, it checks if ifr_hwaddr.sa_family == ARPHRD_ETHER to
> ensure it is a Ethernet MAC and not a different type of interface.
>
>
here is NuttX's implementation:
https://github.com/apache/incubator-nuttx/blob/master/net/netdev/netdev_ioctl.c#L914-L949
If the implementation isn't fully compatible with other OS, I normally
prefer to update NuttX's one.


> Maybe there is a better way to do this in NuttX but I prefer to leave
> the application code unchanged if possible.
>
> More below...
>
>
> > > Also, do we lack the defines IFF_LOOPBACK, IFF_UP, IFF_BROADCAST, and
> > > IFF_MULTICAST? I can't find them anywhere, except in comments.
> > >
> > > For example, a grep for IFF_LOOPBACK shows it in the comments for
> > > getifaddrs():
> > >
> > > [[[
> > >  *  Depending on whether the bit IFF_BROADCAST or IFF_POINTOPOINT is
> > >  *  set in ifa_flags (only one can be set at a time), either
> > >  *  ifa_broadaddr will contain the broadcast address associated with
> > >  *  ifa_addr (if applicable for the address family) or ifa_dstaddr
> > >  *  will contain the destination address of the point-to-point
> > >  *  interface.
> > > ]]]
> > >
> > > but no such define exists in NuttX.
> > >
> >
> > We just added the related code a couple weeks ago. My teammate will
> > upstream the change soon.
>
>
> That is very good news! I'll be looking out for it when it lands. Feel
> free to ping me for review on GitHub.
>
>
It's here:
https://github.com/apache/incubator-nuttx/pull/6543


> Thanks for the reply.
>
> Cheers,
> Nathan
>

Reply via email to