Commit 661e4731 authored by Thomas Haller's avatar Thomas Haller

core: add const qualifier to functions in nm-ip[46]-config

Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
parent 17607e74
......@@ -85,7 +85,7 @@ nm_dns_utils_get_ip4_rdns_domains (NMIP4Config *ip4)
}
for (i = 0; i < nm_ip4_config_get_num_routes (ip4); i++) {
NMPlatformIP4Route *route = nm_ip4_config_get_route (ip4, i);
const NMPlatformIP4Route *route = nm_ip4_config_get_route (ip4, i);
add_ip4_to_rdns_array (route->network, domains);
}
......
......@@ -292,7 +292,7 @@ nm_ip4_config_update_setting (NMIP4Config *config, NMSettingIP4Config *setting)
/* Routes */
for (i = 0; i < nroutes; i++) {
NMPlatformIP4Route *route = nm_ip4_config_get_route (config, i);
const NMPlatformIP4Route *route = nm_ip4_config_get_route (config, i);
NMIP4Route *s_route;
/* Ignore default route. */
......@@ -430,10 +430,10 @@ nm_ip4_config_subtract (NMIP4Config *dst, NMIP4Config *src)
/* routes */
for (i = 0; i < nm_ip4_config_get_num_routes (src); i++) {
NMPlatformIP4Route *src_route = nm_ip4_config_get_route (src, i);
const NMPlatformIP4Route *src_route = nm_ip4_config_get_route (src, i);
for (j = 0; j < nm_ip4_config_get_num_routes (dst); j++) {
NMPlatformIP4Route *dst_route = nm_ip4_config_get_route (dst, j);
const NMPlatformIP4Route *dst_route = nm_ip4_config_get_route (dst, j);
if (src_route->network == dst_route->network && src_route->plen == dst_route->plen) {
nm_ip4_config_del_route (dst, j);
......@@ -545,7 +545,7 @@ nm_ip4_config_dump (NMIP4Config *config, const char *detail)
/* routes */
for (i = 0; i < nm_ip4_config_get_num_routes (config); i++) {
NMPlatformIP4Route *route = nm_ip4_config_get_route (config, i);
const NMPlatformIP4Route *route = nm_ip4_config_get_route (config, i);
if (inet_ntop (AF_INET, &route->network, buf, sizeof (buf)) &&
inet_ntop (AF_INET, &route->gateway, buf2, sizeof (buf2))) {
......@@ -706,13 +706,13 @@ nm_ip4_config_reset_routes (NMIP4Config *config)
}
static gboolean
routes_are_duplicate (NMPlatformIP4Route *a, NMPlatformIP4Route *b)
routes_are_duplicate (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b)
{
return a->network == b->network && a->plen == b->plen;
}
void
nm_ip4_config_add_route (NMIP4Config *config, NMPlatformIP4Route *new)
nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *new)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int i;
......@@ -749,7 +749,7 @@ nm_ip4_config_get_num_routes (NMIP4Config *config)
return priv->routes->len;
}
NMPlatformIP4Route *
const NMPlatformIP4Route *
nm_ip4_config_get_route (NMIP4Config *config, guint i)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
......
......@@ -83,10 +83,10 @@ const NMPlatformIP4Address *nm_ip4_config_get_address (NMIP4Config *config, guin
/* Routes */
void nm_ip4_config_reset_routes (NMIP4Config *config);
void nm_ip4_config_add_route (NMIP4Config *config, NMPlatformIP4Route *route);
void nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *route);
void nm_ip4_config_del_route (NMIP4Config *config, guint i);
guint32 nm_ip4_config_get_num_routes (NMIP4Config *config);
NMPlatformIP4Route * nm_ip4_config_get_route (NMIP4Config *config, guint32 i);
const NMPlatformIP4Route *nm_ip4_config_get_route (NMIP4Config *config, guint32 i);
/* Nameservers */
void nm_ip4_config_reset_nameservers (NMIP4Config *config);
......
......@@ -256,7 +256,7 @@ nm_ip6_config_update_setting (NMIP6Config *config, NMSettingIP6Config *setting)
/* Addresses */
for (i = 0; i < naddresses; i++) {
NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
const NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
NMIP6Address *s_addr;
/* Ignore link-local address. */
......@@ -289,7 +289,7 @@ nm_ip6_config_update_setting (NMIP6Config *config, NMSettingIP6Config *setting)
/* Routes */
for (i = 0; i < nroutes; i++) {
NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
const NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
NMIP6Route *s_route = nm_ip6_route_new ();
/* Ignore link-local route. */
......@@ -371,7 +371,7 @@ nm_ip6_config_destination_is_direct (NMIP6Config *config, const struct in6_addr
int i;
for (i = 0; i < num; i++) {
NMPlatformIP6Address *item = nm_ip6_config_get_address (config, i);
const NMPlatformIP6Address *item = nm_ip6_config_get_address (config, i);
if (item->plen <= plen && same_prefix (&item->address, network, item->plen))
return TRUE;
......@@ -381,7 +381,7 @@ nm_ip6_config_destination_is_direct (NMIP6Config *config, const struct in6_addr
}
static gboolean
routes_are_duplicate (NMPlatformIP6Route *a, NMPlatformIP6Route *b)
routes_are_duplicate (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b)
{
return IN6_ARE_ADDR_EQUAL (&a->network, &b->network) && a->plen == b->plen;
}
......@@ -445,10 +445,10 @@ nm_ip6_config_subtract (NMIP6Config *dst, NMIP6Config *src)
/* routes */
for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) {
NMPlatformIP6Route *src_route = nm_ip6_config_get_route (src, i);
const NMPlatformIP6Route *src_route = nm_ip6_config_get_route (src, i);
for (j = 0; j < nm_ip6_config_get_num_routes (dst); j++) {
NMPlatformIP6Route *dst_route = nm_ip6_config_get_route (dst, j);
const NMPlatformIP6Route *dst_route = nm_ip6_config_get_route (dst, j);
if (routes_are_duplicate (src_route, dst_route)) {
nm_ip6_config_del_route (dst, j);
......@@ -575,7 +575,7 @@ nm_ip6_config_get_num_addresses (NMIP6Config *config)
return priv->addresses->len;
}
NMPlatformIP6Address *
const NMPlatformIP6Address *
nm_ip6_config_get_address (NMIP6Config *config, guint i)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
......@@ -594,7 +594,7 @@ nm_ip6_config_reset_routes (NMIP6Config *config)
}
void
nm_ip6_config_add_route (NMIP6Config *config, NMPlatformIP6Route *new)
nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *new)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
int i;
......@@ -631,7 +631,7 @@ nm_ip6_config_get_num_routes (NMIP6Config *config)
return priv->routes->len;
}
NMPlatformIP6Route *
const NMPlatformIP6Route *
nm_ip6_config_get_route (NMIP6Config *config, guint i)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
......@@ -865,14 +865,14 @@ nm_ip6_config_hash (NMIP6Config *config, GChecksum *sum, gboolean dns_only)
hash_in6addr (sum, nm_ip6_config_get_gateway (config));
for (i = 0; i < nm_ip6_config_get_num_addresses (config); i++) {
NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
const NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
hash_in6addr (sum, &address->address);
hash_u32 (sum, address->plen);
}
for (i = 0; i < nm_ip6_config_get_num_routes (config); i++) {
NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
const NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
hash_in6addr (sum, &route->network);
hash_u32 (sum, route->plen);
......@@ -991,7 +991,7 @@ get_property (GObject *object, guint prop_id,
int i;
for (i = 0; i < naddr; i++) {
NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
const NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
GValueArray *array = g_value_array_new (3);
GValue element = G_VALUE_INIT;
......@@ -1032,7 +1032,7 @@ get_property (GObject *object, guint prop_id,
int i;
for (i = 0; i < nroutes; i++) {
NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
const NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
GValueArray *array = g_value_array_new (4);
GByteArray *ba;
......
......@@ -77,14 +77,14 @@ void nm_ip6_config_reset_addresses (NMIP6Config *config);
void nm_ip6_config_add_address (NMIP6Config *config, const NMPlatformIP6Address *address);
void nm_ip6_config_del_address (NMIP6Config *config, guint i);
guint nm_ip6_config_get_num_addresses (NMIP6Config *config);
NMPlatformIP6Address *nm_ip6_config_get_address (NMIP6Config *config, guint i);
const NMPlatformIP6Address *nm_ip6_config_get_address (NMIP6Config *config, guint i);
/* Routes */
void nm_ip6_config_reset_routes (NMIP6Config *config);
void nm_ip6_config_add_route (NMIP6Config *config, NMPlatformIP6Route *route);
void nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *route);
void nm_ip6_config_del_route (NMIP6Config *config, guint i);
guint32 nm_ip6_config_get_num_routes (NMIP6Config *config);
NMPlatformIP6Route * nm_ip6_config_get_route (NMIP6Config *config, guint32 i);
const NMPlatformIP6Route *nm_ip6_config_get_route (NMIP6Config *config, guint32 i);
/* Nameservers */
void nm_ip6_config_reset_nameservers (NMIP6Config *config);
......
......@@ -479,7 +479,7 @@ update_system_hostname (NMPolicy *policy, NMDevice *best4, NMDevice *best6)
G_SOCKET_FAMILY_IPV4);
} else {
NMIP6Config *ip6_config;
NMPlatformIP6Address *addr6;
const NMPlatformIP6Address *addr6;
ip6_config = nm_device_get_ip6_config (best6);
if ( !ip6_config
......
......@@ -102,7 +102,7 @@ test_generic_options (const char *client)
GHashTable *options;
NMIP4Config *ip4_config;
const NMPlatformIP4Address *address;
NMPlatformIP4Route *route;
const NMPlatformIP4Route *route;
guint32 tmp;
const char *expected_addr = "192.168.1.106";
const char *expected_gw = "192.168.1.1";
......@@ -258,7 +258,7 @@ ip4_test_route (const char *test,
const char *expected_gw,
guint expected_prefix)
{
NMPlatformIP4Route *route;
const NMPlatformIP4Route *route;
guint32 tmp;
route = nm_ip4_config_get_route (ip4_config, route_num);
......
......@@ -102,8 +102,9 @@ test_subtract (void)
{
NMIP4Config *src, *dst;
NMPlatformIP4Address addr;
NMPlatformIP4Route route;
const NMPlatformIP4Address *test_addr;
NMPlatformIP4Route route, *test_route;
const NMPlatformIP4Route *test_route;
const char *expected_addr = "192.168.1.12";
guint32 expected_addr_plen = 24;
const char *expected_route_dest = "8.7.6.5";
......
......@@ -93,8 +93,9 @@ test_subtract (void)
{
NMIP6Config *src, *dst;
NMPlatformIP6Address addr;
NMPlatformIP6Route route;
const NMPlatformIP6Address *test_addr;
NMPlatformIP6Route route, *test_route;
const NMPlatformIP6Route *test_route;
const char *expected_addr = "1122:3344:5566::7788";
guint32 expected_addr_plen = 96;
const char *expected_route_dest = "9991:8882:7773::";
......
......@@ -577,7 +577,7 @@ print_vpn_config (NMVPNConnection *connection)
num = nm_ip4_config_get_num_routes (priv->ip4_config);
for (i = 0; i < num; i++) {
NMPlatformIP4Route *route = nm_ip4_config_get_route (priv->ip4_config, i);
const NMPlatformIP4Route *route = nm_ip4_config_get_route (priv->ip4_config, i);
nm_log_info (LOGD_VPN, " Static Route: %s/%d Next Hop: %s",
ip_address_to_string (route->network),
......@@ -616,7 +616,7 @@ print_vpn_config (NMVPNConnection *connection)
num = nm_ip6_config_get_num_routes (priv->ip6_config);
for (i = 0; i < num; i++) {
NMPlatformIP6Route *route = nm_ip6_config_get_route (priv->ip6_config, i);
const NMPlatformIP6Route *route = nm_ip6_config_get_route (priv->ip6_config, i);
nm_log_info (LOGD_VPN, " Static Route: %s/%d Next Hop: %s",
ip6_address_to_string (&route->network),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment