mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 20:30:35 +01:00
core: preserve const-ness in NM_IP4_CONFIG_GET_PRIVATE()
Usually, our _GET_PRIVATE() macros cast away the const-ness of the self argument -- also because they cannot do any better in plain (gcc) C. Now it is possible to preserve const-ness, it seems more correct to do so. After all, the const should also help us not modifying arguments that are not intended to be modified. Although, the more important use of const is to signal that a function promises not to modify an argument, like in memcpy(void*,const void*) it's immediately clear which is source and destination. In C, a const is anyway not enforcable, but can show intent. Likewise for NM_IP6_CONFIG_GET_PRIVATE() and NMIP6Config.
This commit is contained in:
parent
ee29228277
commit
7aac2c8a10
2 changed files with 87 additions and 73 deletions
|
|
@ -67,12 +67,17 @@ struct _NMIP4ConfigClass {
|
|||
|
||||
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
#define NM_IP4_CONFIG_GET_PRIVATE(o) \
|
||||
#define NM_IP4_CONFIG_GET_PRIVATE(self) \
|
||||
({ \
|
||||
const NMIP4ConfigPrivate *_priv = &(o)->_priv; \
|
||||
/* preserve the const-ness of self. Unfortunately, that
|
||||
* way, @self cannot be a void pointer */ \
|
||||
typeof (self) _self = (self); \
|
||||
\
|
||||
/* cast away the const. */ \
|
||||
((NMIP4ConfigPrivate *) _priv); \
|
||||
/* Get compiler error if variable is of wrong type */ \
|
||||
_nm_unused const NMIP4Config *_self2 = (_self); \
|
||||
\
|
||||
nm_assert (NM_IS_IP4_CONFIG (_self)); \
|
||||
&_self->_priv; \
|
||||
})
|
||||
|
||||
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
|
||||
|
|
@ -350,7 +355,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||
gboolean
|
||||
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_full_sync, gint64 default_route_metric)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
gs_unref_ptrarray GPtrArray *added_addresses = NULL;
|
||||
|
||||
|
|
@ -658,7 +663,8 @@ nm_ip4_config_create_setting (const NMIP4Config *config)
|
|||
void
|
||||
nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFlags merge_flags)
|
||||
{
|
||||
NMIP4ConfigPrivate *dst_priv, *src_priv;
|
||||
NMIP4ConfigPrivate *dst_priv;
|
||||
const NMIP4ConfigPrivate *src_priv;
|
||||
guint32 i;
|
||||
|
||||
g_return_if_fail (src != NULL);
|
||||
|
|
@ -748,7 +754,7 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl
|
|||
static int
|
||||
_addresses_get_index (const NMIP4Config *self, const NMPlatformIP4Address *addr)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->addresses->len; i++) {
|
||||
|
|
@ -763,7 +769,7 @@ _addresses_get_index (const NMIP4Config *self, const NMPlatformIP4Address *addr)
|
|||
static int
|
||||
_nameservers_get_index (const NMIP4Config *self, guint32 ns)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->nameservers->len; i++) {
|
||||
|
|
@ -778,7 +784,7 @@ _nameservers_get_index (const NMIP4Config *self, guint32 ns)
|
|||
static int
|
||||
_routes_get_index (const NMIP4Config *self, const NMPlatformIP4Route *route)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->routes->len; i++) {
|
||||
|
|
@ -794,7 +800,7 @@ _routes_get_index (const NMIP4Config *self, const NMPlatformIP4Route *route)
|
|||
static int
|
||||
_domains_get_index (const NMIP4Config *self, const char *domain)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->domains->len; i++) {
|
||||
|
|
@ -809,7 +815,7 @@ _domains_get_index (const NMIP4Config *self, const char *domain)
|
|||
static int
|
||||
_searches_get_index (const NMIP4Config *self, const char *search)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->searches->len; i++) {
|
||||
|
|
@ -824,7 +830,7 @@ _searches_get_index (const NMIP4Config *self, const char *search)
|
|||
static int
|
||||
_dns_options_get_index (const NMIP4Config *self, const char *option)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->dns_options->len; i++) {
|
||||
|
|
@ -839,7 +845,7 @@ _dns_options_get_index (const NMIP4Config *self, const char *option)
|
|||
static int
|
||||
_nis_servers_get_index (const NMIP4Config *self, guint32 nis_server)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->nis->len; i++) {
|
||||
|
|
@ -854,7 +860,7 @@ _nis_servers_get_index (const NMIP4Config *self, guint32 nis_server)
|
|||
static int
|
||||
_wins_get_index (const NMIP4Config *self, guint32 wins_server)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->wins->len; i++) {
|
||||
|
|
@ -1037,7 +1043,8 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
|
|||
#endif
|
||||
gboolean has_minor_changes = FALSE, has_relevant_changes = FALSE, are_equal;
|
||||
guint i, num;
|
||||
NMIP4ConfigPrivate *dst_priv, *src_priv;
|
||||
NMIP4ConfigPrivate *dst_priv;
|
||||
const NMIP4ConfigPrivate *src_priv;
|
||||
const NMPlatformIP4Address *dst_addr, *src_addr;
|
||||
const NMPlatformIP4Route *dst_route, *src_route;
|
||||
|
||||
|
|
@ -1387,7 +1394,7 @@ nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default)
|
|||
gboolean
|
||||
nm_ip4_config_get_never_default (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->never_default;
|
||||
}
|
||||
|
|
@ -1429,7 +1436,7 @@ nm_ip4_config_unset_gateway (NMIP4Config *config)
|
|||
gboolean
|
||||
nm_ip4_config_has_gateway (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->has_gateway;
|
||||
}
|
||||
|
|
@ -1437,7 +1444,7 @@ nm_ip4_config_has_gateway (const NMIP4Config *config)
|
|||
guint32
|
||||
nm_ip4_config_get_gateway (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->gateway;
|
||||
}
|
||||
|
|
@ -1445,7 +1452,7 @@ nm_ip4_config_get_gateway (const NMIP4Config *config)
|
|||
gint64
|
||||
nm_ip4_config_get_route_metric (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->route_metric;
|
||||
}
|
||||
|
|
@ -1536,7 +1543,7 @@ nm_ip4_config_del_address (NMIP4Config *config, guint i)
|
|||
guint
|
||||
nm_ip4_config_get_num_addresses (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->addresses->len;
|
||||
}
|
||||
|
|
@ -1544,7 +1551,7 @@ nm_ip4_config_get_num_addresses (const NMIP4Config *config)
|
|||
const NMPlatformIP4Address *
|
||||
nm_ip4_config_get_address (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return &g_array_index (priv->addresses, NMPlatformIP4Address, i);
|
||||
}
|
||||
|
|
@ -1628,7 +1635,7 @@ nm_ip4_config_del_route (NMIP4Config *config, guint i)
|
|||
guint
|
||||
nm_ip4_config_get_num_routes (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->routes->len;
|
||||
}
|
||||
|
|
@ -1636,7 +1643,7 @@ nm_ip4_config_get_num_routes (const NMIP4Config *config)
|
|||
const NMPlatformIP4Route *
|
||||
nm_ip4_config_get_route (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return &g_array_index (priv->routes, NMPlatformIP4Route, i);
|
||||
}
|
||||
|
|
@ -1644,7 +1651,7 @@ nm_ip4_config_get_route (const NMIP4Config *config, guint i)
|
|||
const NMPlatformIP4Route *
|
||||
nm_ip4_config_get_direct_route_for_host (const NMIP4Config *config, guint32 host)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
guint i;
|
||||
NMPlatformIP4Route *best_route = NULL;
|
||||
|
||||
|
|
@ -1714,7 +1721,7 @@ nm_ip4_config_del_nameserver (NMIP4Config *config, guint i)
|
|||
guint32
|
||||
nm_ip4_config_get_num_nameservers (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->nameservers->len;
|
||||
}
|
||||
|
|
@ -1722,7 +1729,7 @@ nm_ip4_config_get_num_nameservers (const NMIP4Config *config)
|
|||
guint32
|
||||
nm_ip4_config_get_nameserver (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_array_index (priv->nameservers, guint32, i);
|
||||
}
|
||||
|
|
@ -1771,7 +1778,7 @@ nm_ip4_config_del_domain (NMIP4Config *config, guint i)
|
|||
guint32
|
||||
nm_ip4_config_get_num_domains (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->domains->len;
|
||||
}
|
||||
|
|
@ -1779,7 +1786,7 @@ nm_ip4_config_get_num_domains (const NMIP4Config *config)
|
|||
const char *
|
||||
nm_ip4_config_get_domain (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_ptr_array_index (priv->domains, i);
|
||||
}
|
||||
|
|
@ -1843,7 +1850,7 @@ nm_ip4_config_del_search (NMIP4Config *config, guint i)
|
|||
guint32
|
||||
nm_ip4_config_get_num_searches (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->searches->len;
|
||||
}
|
||||
|
|
@ -1851,7 +1858,7 @@ nm_ip4_config_get_num_searches (const NMIP4Config *config)
|
|||
const char *
|
||||
nm_ip4_config_get_search (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_ptr_array_index (priv->searches, i);
|
||||
}
|
||||
|
|
@ -1900,7 +1907,7 @@ nm_ip4_config_del_dns_option(NMIP4Config *config, guint i)
|
|||
guint32
|
||||
nm_ip4_config_get_num_dns_options (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->dns_options->len;
|
||||
}
|
||||
|
|
@ -1908,7 +1915,7 @@ nm_ip4_config_get_num_dns_options (const NMIP4Config *config)
|
|||
const char *
|
||||
nm_ip4_config_get_dns_option (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_ptr_array_index (priv->dns_options, i);
|
||||
}
|
||||
|
|
@ -1926,7 +1933,7 @@ nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss)
|
|||
guint32
|
||||
nm_ip4_config_get_mss (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->mss;
|
||||
}
|
||||
|
|
@ -1967,7 +1974,7 @@ nm_ip4_config_del_nis_server (NMIP4Config *config, guint i)
|
|||
guint32
|
||||
nm_ip4_config_get_num_nis_servers (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->nis->len;
|
||||
}
|
||||
|
|
@ -1975,7 +1982,7 @@ nm_ip4_config_get_num_nis_servers (const NMIP4Config *config)
|
|||
guint32
|
||||
nm_ip4_config_get_nis_server (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_array_index (priv->nis, guint32, i);
|
||||
}
|
||||
|
|
@ -1992,7 +1999,7 @@ nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain)
|
|||
const char *
|
||||
nm_ip4_config_get_nis_domain (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->nis_domain;
|
||||
}
|
||||
|
|
@ -2040,7 +2047,7 @@ nm_ip4_config_del_wins (NMIP4Config *config, guint i)
|
|||
guint32
|
||||
nm_ip4_config_get_num_wins (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->wins->len;
|
||||
}
|
||||
|
|
@ -2048,7 +2055,7 @@ nm_ip4_config_get_num_wins (const NMIP4Config *config)
|
|||
guint32
|
||||
nm_ip4_config_get_wins (const NMIP4Config *config, guint i)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_array_index (priv->wins, guint32, i);
|
||||
}
|
||||
|
|
@ -2070,7 +2077,7 @@ nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu, NMIPConfigSource source
|
|||
guint32
|
||||
nm_ip4_config_get_mtu (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->mtu;
|
||||
}
|
||||
|
|
@ -2078,7 +2085,7 @@ nm_ip4_config_get_mtu (const NMIP4Config *config)
|
|||
NMIPConfigSource
|
||||
nm_ip4_config_get_mtu_source (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->mtu_source;
|
||||
}
|
||||
|
|
@ -2096,7 +2103,7 @@ nm_ip4_config_set_metered (NMIP4Config *config, gboolean metered)
|
|||
gboolean
|
||||
nm_ip4_config_get_metered (const NMIP4Config *config)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->metered;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,12 +59,17 @@ struct _NMIP6ConfigClass {
|
|||
|
||||
G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
#define NM_IP6_CONFIG_GET_PRIVATE(o) \
|
||||
#define NM_IP6_CONFIG_GET_PRIVATE(self) \
|
||||
({ \
|
||||
const NMIP6ConfigPrivate *_priv = &(o)->_priv; \
|
||||
/* preserve the const-ness of self. Unfortunately, that
|
||||
* way, @self cannot be a void pointer */ \
|
||||
typeof (self) _self = (self); \
|
||||
\
|
||||
/* cast away the const. */ \
|
||||
((NMIP6ConfigPrivate *) _priv); \
|
||||
/* Get compiler error if variable is of wrong type */ \
|
||||
_nm_unused const NMIP6Config *_self2 = (_self); \
|
||||
\
|
||||
nm_assert (NM_IS_IP6_CONFIG (_self)); \
|
||||
&_self->_priv; \
|
||||
})
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE (NMIP6Config,
|
||||
|
|
@ -386,7 +391,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
|
|||
gboolean
|
||||
nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_full_sync)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
gboolean success;
|
||||
|
||||
|
|
@ -647,7 +652,8 @@ nm_ip6_config_create_setting (const NMIP6Config *config)
|
|||
void
|
||||
nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFlags merge_flags)
|
||||
{
|
||||
NMIP6ConfigPrivate *dst_priv, *src_priv;
|
||||
NMIP6ConfigPrivate *dst_priv;
|
||||
const NMIP6ConfigPrivate *src_priv;
|
||||
guint32 i;
|
||||
|
||||
g_return_if_fail (src != NULL);
|
||||
|
|
@ -733,7 +739,7 @@ nm_ip6_config_destination_is_direct (const NMIP6Config *config, const struct in6
|
|||
static int
|
||||
_addresses_get_index (const NMIP6Config *self, const NMPlatformIP6Address *addr)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->addresses->len; i++) {
|
||||
|
|
@ -748,7 +754,7 @@ _addresses_get_index (const NMIP6Config *self, const NMPlatformIP6Address *addr)
|
|||
static int
|
||||
_nameservers_get_index (const NMIP6Config *self, const struct in6_addr *ns)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->nameservers->len; i++) {
|
||||
|
|
@ -763,7 +769,7 @@ _nameservers_get_index (const NMIP6Config *self, const struct in6_addr *ns)
|
|||
static int
|
||||
_routes_get_index (const NMIP6Config *self, const NMPlatformIP6Route *route)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->routes->len; i++) {
|
||||
|
|
@ -778,7 +784,7 @@ _routes_get_index (const NMIP6Config *self, const NMPlatformIP6Route *route)
|
|||
static int
|
||||
_domains_get_index (const NMIP6Config *self, const char *domain)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->domains->len; i++) {
|
||||
|
|
@ -793,7 +799,7 @@ _domains_get_index (const NMIP6Config *self, const char *domain)
|
|||
static int
|
||||
_searches_get_index (const NMIP6Config *self, const char *search)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->searches->len; i++) {
|
||||
|
|
@ -808,7 +814,7 @@ _searches_get_index (const NMIP6Config *self, const char *search)
|
|||
static int
|
||||
_dns_options_get_index (const NMIP6Config *self, const char *option)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->dns_options->len; i++) {
|
||||
|
|
@ -972,7 +978,8 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev
|
|||
#endif
|
||||
gboolean has_minor_changes = FALSE, has_relevant_changes = FALSE, are_equal;
|
||||
guint i, num;
|
||||
NMIP6ConfigPrivate *dst_priv, *src_priv;
|
||||
NMIP6ConfigPrivate *dst_priv;
|
||||
const NMIP6ConfigPrivate *src_priv;
|
||||
const NMPlatformIP6Address *dst_addr, *src_addr;
|
||||
const NMPlatformIP6Route *dst_route, *src_route;
|
||||
|
||||
|
|
@ -1220,7 +1227,7 @@ nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_default)
|
|||
gboolean
|
||||
nm_ip6_config_get_never_default (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->never_default;
|
||||
}
|
||||
|
|
@ -1245,7 +1252,7 @@ nm_ip6_config_set_gateway (NMIP6Config *config, const struct in6_addr *gateway)
|
|||
const struct in6_addr *
|
||||
nm_ip6_config_get_gateway (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return IN6_IS_ADDR_UNSPECIFIED (&priv->gateway) ? NULL : &priv->gateway;
|
||||
}
|
||||
|
|
@ -1253,7 +1260,7 @@ nm_ip6_config_get_gateway (const NMIP6Config *config)
|
|||
gint64
|
||||
nm_ip6_config_get_route_metric (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->route_metric;
|
||||
}
|
||||
|
|
@ -1344,7 +1351,7 @@ nm_ip6_config_del_address (NMIP6Config *config, guint i)
|
|||
guint
|
||||
nm_ip6_config_get_num_addresses (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->addresses->len;
|
||||
}
|
||||
|
|
@ -1352,7 +1359,7 @@ nm_ip6_config_get_num_addresses (const NMIP6Config *config)
|
|||
const NMPlatformIP6Address *
|
||||
nm_ip6_config_get_address (const NMIP6Config *config, guint i)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return &g_array_index (priv->addresses, NMPlatformIP6Address, i);
|
||||
}
|
||||
|
|
@ -1367,7 +1374,7 @@ nm_ip6_config_address_exists (const NMIP6Config *config,
|
|||
const NMPlatformIP6Address *
|
||||
nm_ip6_config_get_address_first_nontentative (const NMIP6Config *config, gboolean linklocal)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv;
|
||||
const NMIP6ConfigPrivate *priv;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
|
||||
|
|
@ -1459,7 +1466,7 @@ nm_ip6_config_del_route (NMIP6Config *config, guint i)
|
|||
guint
|
||||
nm_ip6_config_get_num_routes (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->routes->len;
|
||||
}
|
||||
|
|
@ -1467,7 +1474,7 @@ nm_ip6_config_get_num_routes (const NMIP6Config *config)
|
|||
const NMPlatformIP6Route *
|
||||
nm_ip6_config_get_route (const NMIP6Config *config, guint i)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return &g_array_index (priv->routes, NMPlatformIP6Route, i);
|
||||
}
|
||||
|
|
@ -1475,7 +1482,7 @@ nm_ip6_config_get_route (const NMIP6Config *config, guint i)
|
|||
const NMPlatformIP6Route *
|
||||
nm_ip6_config_get_direct_route_for_host (const NMIP6Config *config, const struct in6_addr *host)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
guint i;
|
||||
NMPlatformIP6Route *best_route = NULL;
|
||||
|
||||
|
|
@ -1506,7 +1513,7 @@ nm_ip6_config_get_direct_route_for_host (const NMIP6Config *config, const struct
|
|||
const NMPlatformIP6Address *
|
||||
nm_ip6_config_get_subnet_for_host (const NMIP6Config *config, const struct in6_addr *host)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
guint i;
|
||||
NMPlatformIP6Address *subnet = NULL;
|
||||
struct in6_addr subnet2, host2;
|
||||
|
|
@ -1573,7 +1580,7 @@ nm_ip6_config_del_nameserver (NMIP6Config *config, guint i)
|
|||
guint32
|
||||
nm_ip6_config_get_num_nameservers (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->nameservers->len;
|
||||
}
|
||||
|
|
@ -1581,7 +1588,7 @@ nm_ip6_config_get_num_nameservers (const NMIP6Config *config)
|
|||
const struct in6_addr *
|
||||
nm_ip6_config_get_nameserver (const NMIP6Config *config, guint i)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return &g_array_index (priv->nameservers, struct in6_addr, i);
|
||||
}
|
||||
|
|
@ -1630,7 +1637,7 @@ nm_ip6_config_del_domain (NMIP6Config *config, guint i)
|
|||
guint32
|
||||
nm_ip6_config_get_num_domains (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->domains->len;
|
||||
}
|
||||
|
|
@ -1638,7 +1645,7 @@ nm_ip6_config_get_num_domains (const NMIP6Config *config)
|
|||
const char *
|
||||
nm_ip6_config_get_domain (const NMIP6Config *config, guint i)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_ptr_array_index (priv->domains, i);
|
||||
}
|
||||
|
|
@ -1702,7 +1709,7 @@ nm_ip6_config_del_search (NMIP6Config *config, guint i)
|
|||
guint32
|
||||
nm_ip6_config_get_num_searches (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->searches->len;
|
||||
}
|
||||
|
|
@ -1710,7 +1717,7 @@ nm_ip6_config_get_num_searches (const NMIP6Config *config)
|
|||
const char *
|
||||
nm_ip6_config_get_search (const NMIP6Config *config, guint i)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_ptr_array_index (priv->searches, i);
|
||||
}
|
||||
|
|
@ -1759,7 +1766,7 @@ nm_ip6_config_del_dns_option (NMIP6Config *config, guint i)
|
|||
guint32
|
||||
nm_ip6_config_get_num_dns_options (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->dns_options->len;
|
||||
}
|
||||
|
|
@ -1767,7 +1774,7 @@ nm_ip6_config_get_num_dns_options (const NMIP6Config *config)
|
|||
const char *
|
||||
nm_ip6_config_get_dns_option (const NMIP6Config *config, guint i)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return g_ptr_array_index (priv->dns_options, i);
|
||||
}
|
||||
|
|
@ -1785,7 +1792,7 @@ nm_ip6_config_set_mss (NMIP6Config *config, guint32 mss)
|
|||
guint32
|
||||
nm_ip6_config_get_mss (const NMIP6Config *config)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->mss;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue