ifaddrs: add union ifa_ifu include ifu_broadaddr and ifu_dstaddr

In order to support the compilation of third-party library, we encounter
some situations where the macro is not defined, refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2023-06-26 23:36:56 +08:00 committed by Xiang Xiao
parent 6ee9ec7656
commit 08b92ef7cf
1 changed files with 15 additions and 2 deletions

View File

@ -32,7 +32,10 @@
****************************************************************************/
#ifndef ifa_broadaddr
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
# define ifa_broadaddr ifa_ifu.ifu_broadaddr /* Broadcast address of this interface. */
#endif
#ifndef ifa_dstaddr
# define ifa_dstaddr ifa_ifu.ifu_dstaddr /* Point-to-point destination address. */
#endif
/****************************************************************************
@ -46,7 +49,17 @@ struct ifaddrs
unsigned int ifa_flags;
FAR struct sockaddr *ifa_addr;
FAR struct sockaddr *ifa_netmask;
FAR struct sockaddr *ifa_dstaddr;
union
{
/* At most one of the following two is valid. If the IFF_BROADCAST
* bit is set in `ifa_flags', then `ifa_broadaddr' is valid. If the
* IFF_POINTOPOINT bit is set, then `ifa_dstaddr' is valid.
* It is never the case that both these bits are set at once.
*/
FAR struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */
FAR struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */
} ifa_ifu;
FAR void *ifa_data;
};