mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 16:30:31 +01:00
shared: add NM_IS_IPv4() macro
This is of course trivial. However, we use this macro at several places as and index into an array of length 2, to lookup either the IPv4 or IPv6 element. As such, this MUST return 0 or 1. This promise is what the macro should convey.
This commit is contained in:
parent
56a0aa06ac
commit
7ae8100d7a
1 changed files with 9 additions and 0 deletions
|
|
@ -667,4 +667,13 @@ nm_utils_addr_family_from_size (size_t len)
|
|||
#define nm_assert_addr_family(addr_family) \
|
||||
nm_assert (NM_IN_SET ((addr_family), NM_AF_INET, NM_AF_INET6))
|
||||
|
||||
#define NM_IS_IPv4(addr_family) \
|
||||
({ \
|
||||
const int _addr_family = (addr_family); \
|
||||
\
|
||||
nm_assert_addr_family (_addr_family); \
|
||||
\
|
||||
(_addr_family == NM_AF_INET); \
|
||||
})
|
||||
|
||||
#endif /* __NM_STD_AUX_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue