diff options
Diffstat (limited to 'nuttx/include/net/if.h')
-rw-r--r-- | nuttx/include/net/if.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/nuttx/include/net/if.h b/nuttx/include/net/if.h index cd44f495b..6970baae1 100644 --- a/nuttx/include/net/if.h +++ b/nuttx/include/net/if.h @@ -65,24 +65,49 @@ #define IFF_SET_DOWN(f) do { (f) |= IFF_DOWN; } while (0) #define IFF_SET_UP(f) do { (f) |= IFF_UP; } while (0) #define IFF_SET_RUNNING(f) do { (f) |= IFF_RUNNING; } while (0) -#define IFF_SET_IPv6(f) do { (f) |= IFF_IPv6; } while (0) #define IFF_SET_NOARP(f) do { (f) |= IFF_NOARP; } while (0) #define IFF_CLR_DOWN(f) do { (f) &= ~IFF_DOWN; } while (0) #define IFF_CLR_UP(f) do { (f) &= ~IFF_UP; } while (0) #define IFF_CLR_RUNNING(f) do { (f) &= ~IFF_RUNNING; } while (0) -#define IFF_CLR_IPv6(f) do { (f) &= ~IFF_IPv6; } while (0) #define IFF_CLR_NOARP(f) do { (f) &= ~IFF_NOARP; } while (0) #define IFF_IS_DOWN(f) (((f) & IFF_DOWN) != 0) #define IFF_IS_UP(f) (((f) & IFF_UP) != 0) #define IFF_IS_RUNNING(f) (((f) & IFF_RUNNING) != 0) -#define IFF_IS_IPv6(f) (((f) & IFF_IPv6) != 0) #define IFF_IS_NOARP(f) (((f) & IFF_NOARP) != 0) -#define IFF_SET_IPv4(f) IFF_CLR_IPv6(f) -#define IFF_CLR_IPv4(f) IFF_SET_IPv6(f) -#define IFF_IS_IPv4(f) (!IFF_IS_IPv6(f)) +/* We only need to manage the IPv6 bit if both IPv6 and IPv4 are supported. Otherwise, + * we can save a few bytes by ignoring it. + */ + +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) +# define IFF_SET_IPv6(f) do { (f) |= IFF_IPv6; } while (0) +# define IFF_CLR_IPv6(f) do { (f) &= ~IFF_IPv6; } while (0) +# define IFF_IS_IPv6(f) (((f) & IFF_IPv6) != 0) + +# define IFF_SET_IPv4(f) IFF_CLR_IPv6(f) +# define IFF_CLR_IPv4(f) IFF_SET_IPv6(f) +# define IFF_IS_IPv4(f) (!IFF_IS_IPv6(f)) + +#elif defined(CONFIG_NET_IPv6) +# define IFF_SET_IPv6(f) +# define IFF_CLR_IPv6(f) +# define IFF_IS_IPv6(f) (1) + +# define IFF_SET_IPv4(f) +# define IFF_CLR_IPv4(f) +# define IFF_IS_IPv4(f) (0) + +#else /* if defined(CONFIG_NET_IPv4) */ +# define IFF_SET_IPv6(f) +# define IFF_CLR_IPv6(f) +# define IFF_IS_IPv6(f) (0) + +# define IFF_SET_IPv4(f) +# define IFF_CLR_IPv4(f) +# define IFF_IS_IPv4(f) (1) +#endif /******************************************************************************************* * Public Type Definitions |