mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-02 19:20:12 +01:00
core: add ip-config implementation for NMIP4Config vs. NMIP6Config
This commit is contained in:
parent
d7d8611e72
commit
d77485e36b
1 changed files with 53 additions and 17 deletions
|
|
@ -397,12 +397,38 @@ nm_ip_config_add_address (NMIPConfig *self, const NMPlatformIPAddress *address)
|
|||
_NM_IP_CONFIG_DISPATCH_VOID (self, nm_ip4_config_add_address, nm_ip6_config_add_address, (gconstpointer) address);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_ip_config_reset_addresses (NMIPConfig *self)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_VOID (self, nm_ip4_config_reset_addresses, nm_ip6_config_reset_addresses);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_ip_config_add_route (NMIPConfig *self,
|
||||
const NMPlatformIPRoute *new,
|
||||
const NMPObject **out_obj_new)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_VOID (self, nm_ip4_config_add_route, nm_ip6_config_add_route, (gpointer) new, out_obj_new);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_ip_config_reset_routes (NMIPConfig *self)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_VOID (self, nm_ip4_config_reset_routes, nm_ip6_config_reset_routes);
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_ip_config_get_dns_priority (const NMIPConfig *self)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH (self, nm_ip4_config_get_dns_priority, nm_ip6_config_get_dns_priority);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_ip_config_set_dns_priority (NMIPConfig *self, gint priority)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_VOID (self, nm_ip4_config_set_dns_priority, nm_ip6_config_set_dns_priority, priority);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_ip_config_add_nameserver (NMIPConfig *self, const NMIPAddr *ns)
|
||||
{
|
||||
|
|
@ -475,18 +501,17 @@ nm_ip_config_get_dns_option (const NMIPConfig *self, guint i)
|
|||
_NM_IP_CONFIG_DISPATCH (self, nm_ip4_config_get_dns_option, nm_ip6_config_get_dns_option, i);
|
||||
}
|
||||
|
||||
#define _NM_IP_CONFIG_DISPATCH_SET_OP(dst, src, v4_func, v6_func, ...) \
|
||||
#define _NM_IP_CONFIG_DISPATCH_SET_OP(_return, dst, src, v4_func, v6_func, ...) \
|
||||
G_STMT_START { \
|
||||
gpointer _dst = (dst); \
|
||||
gconstpointer _src = (src); \
|
||||
int family = nm_ip_config_get_addr_family (_dst); \
|
||||
\
|
||||
nm_assert (family == nm_ip_config_get_addr_family (_src)); \
|
||||
if (family == AF_INET) { \
|
||||
v4_func ((NMIP4Config *) _dst, (const NMIP4Config *) _src, ##__VA_ARGS__); \
|
||||
if (NM_IS_IP4_CONFIG (_dst)) { \
|
||||
nm_assert (NM_IS_IP4_CONFIG (_src)); \
|
||||
_return v4_func ((NMIP4Config *) _dst, (const NMIP4Config *) _src, ##__VA_ARGS__); \
|
||||
} else { \
|
||||
nm_assert (family == AF_INET6); \
|
||||
v6_func ((NMIP6Config *) _dst, (const NMIP6Config *) _src, ##__VA_ARGS__); \
|
||||
nm_assert (NM_IS_IP6_CONFIG (_src)); \
|
||||
_return v6_func ((NMIP6Config *) _dst, (const NMIP6Config *) _src, ##__VA_ARGS__); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
|
|
@ -495,7 +520,7 @@ nm_ip_config_intersect (NMIPConfig *dst,
|
|||
const NMIPConfig *src,
|
||||
guint32 default_route_metric_penalty)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_SET_OP (dst, src,
|
||||
_NM_IP_CONFIG_DISPATCH_SET_OP (, dst, src,
|
||||
nm_ip4_config_intersect,
|
||||
nm_ip6_config_intersect,
|
||||
default_route_metric_penalty);
|
||||
|
|
@ -506,7 +531,7 @@ nm_ip_config_subtract (NMIPConfig *dst,
|
|||
const NMIPConfig *src,
|
||||
guint32 default_route_metric_penalty)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_SET_OP (dst, src,
|
||||
_NM_IP_CONFIG_DISPATCH_SET_OP (, dst, src,
|
||||
nm_ip4_config_subtract,
|
||||
nm_ip6_config_subtract,
|
||||
default_route_metric_penalty);
|
||||
|
|
@ -518,30 +543,41 @@ nm_ip_config_merge (NMIPConfig *dst,
|
|||
NMIPConfigMergeFlags merge_flags,
|
||||
guint32 default_route_metric_penalty)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_SET_OP (dst, src,
|
||||
_NM_IP_CONFIG_DISPATCH_SET_OP (, dst, src,
|
||||
nm_ip4_config_merge,
|
||||
nm_ip6_config_merge,
|
||||
merge_flags,
|
||||
default_route_metric_penalty);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_ip_config_replace (NMIPConfig *dst,
|
||||
const NMIPConfig *src,
|
||||
gboolean *relevant_changes)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_SET_OP (return, dst, src,
|
||||
nm_ip4_config_replace,
|
||||
nm_ip6_config_replace,
|
||||
relevant_changes);
|
||||
}
|
||||
|
||||
static inline NMIPConfig *
|
||||
nm_ip_config_intersect_alloc (const NMIPConfig *a,
|
||||
const NMIPConfig *b,
|
||||
guint32 default_route_metric_penalty)
|
||||
{
|
||||
int family;
|
||||
|
||||
family = nm_ip_config_get_addr_family (a);
|
||||
nm_assert (family == nm_ip_config_get_addr_family (b));
|
||||
|
||||
if (family == AF_INET)
|
||||
if (NM_IS_IP4_CONFIG (a)) {
|
||||
nm_assert (NM_IS_IP4_CONFIG (b));
|
||||
return (NMIPConfig *) nm_ip4_config_intersect_alloc ((const NMIP4Config *) a,
|
||||
(const NMIP4Config *) b,
|
||||
default_route_metric_penalty);
|
||||
else
|
||||
} else {
|
||||
nm_assert (NM_IS_IP6_CONFIG (a));
|
||||
nm_assert (NM_IS_IP6_CONFIG (b));
|
||||
return (NMIPConfig *) nm_ip6_config_intersect_alloc ((const NMIP6Config *) a,
|
||||
(const NMIP6Config *) b,
|
||||
default_route_metric_penalty);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __NETWORKMANAGER_IP4_CONFIG_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue