all: replace struct in_addr with guint32

This commit is contained in:
Pavel Šimerda
2013-07-31 23:59:50 +02:00
committed by Dan Williams
parent 6762b2f792
commit 320a9d16a3
26 changed files with 215 additions and 219 deletions

View File

@@ -112,17 +112,17 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
NMIP4Address *addr = (NMIP4Address *) iter->data;
char str_addr[INET_ADDRSTRLEN + 1];
char str_gw[INET_ADDRSTRLEN + 1];
struct in_addr tmp_addr;
guint32 tmp_addr;
guint32 ip_prefix = nm_ip4_address_get_prefix (addr);
char *addrtmp;
memset (str_addr, 0, sizeof (str_addr));
tmp_addr.s_addr = nm_ip4_address_get_address (addr);
tmp_addr = nm_ip4_address_get_address (addr);
if (!inet_ntop (AF_INET, &tmp_addr, str_addr, sizeof (str_addr)))
continue;
memset (str_gw, 0, sizeof (str_gw));
tmp_addr.s_addr = nm_ip4_address_get_gateway (addr);
tmp_addr = nm_ip4_address_get_gateway (addr);
inet_ntop (AF_INET, &tmp_addr, str_gw, sizeof (str_gw));
addrtmp = g_strdup_printf ("%sIP4_ADDRESS_%d=%s/%d %s", prefix, num++, str_addr, ip_prefix, str_gw);
@@ -146,10 +146,10 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
tmp = g_string_new (NULL);
g_string_append_printf (tmp, "%sIP4_NAMESERVERS=", prefix);
for (i = 0; i < dns->len; i++) {
struct in_addr addr;
guint32 addr;
char buf[INET_ADDRSTRLEN + 1];
addr.s_addr = g_array_index (dns, guint32, i);
addr = g_array_index (dns, guint32, i);
memset (buf, 0, sizeof (buf));
if (inet_ntop (AF_INET, &addr, buf, sizeof (buf))) {
if (!first)
@@ -176,10 +176,10 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
tmp = g_string_new (NULL);
g_string_append_printf (tmp, "%sIP4_WINS_SERVERS=", prefix);
for (i = 0; i < wins->len; i++) {
struct in_addr addr;
guint32 addr;
char buf[INET_ADDRSTRLEN + 1];
addr.s_addr = g_array_index (wins, guint32, i);
addr = g_array_index (wins, guint32, i);
memset (buf, 0, sizeof (buf));
if (inet_ntop (AF_INET, &addr, buf, sizeof (buf))) {
if (!first)
@@ -201,18 +201,18 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
NMIP4Route *route = (NMIP4Route *) iter->data;
char str_addr[INET_ADDRSTRLEN + 1];
char str_nh[INET_ADDRSTRLEN + 1];
struct in_addr tmp_addr;
guint32 tmp_addr;
guint32 ip_prefix = nm_ip4_route_get_prefix (route);
guint32 metric = nm_ip4_route_get_metric (route);
char *routetmp;
memset (str_addr, 0, sizeof (str_addr));
tmp_addr.s_addr = nm_ip4_route_get_dest (route);
tmp_addr = nm_ip4_route_get_dest (route);
if (!inet_ntop (AF_INET, &tmp_addr, str_addr, sizeof (str_addr)))
continue;
memset (str_nh, 0, sizeof (str_nh));
tmp_addr.s_addr = nm_ip4_route_get_next_hop (route);
tmp_addr = nm_ip4_route_get_next_hop (route);
inet_ntop (AF_INET, &tmp_addr, str_nh, sizeof (str_nh));
routetmp = g_strdup_printf ("%sIP4_ROUTE_%d=%s/%d %s %d", prefix, num++, str_addr, ip_prefix, str_nh, metric);

View File

@@ -238,10 +238,10 @@ add_uint_array (GKeyFile *kf,
items = g_array_sized_new (FALSE, TRUE, sizeof (guint32), g_strv_length (split));
for (iter = split; iter && *iter; iter++) {
if (strlen (g_strstrip (*iter))) {
struct in_addr addr;
guint32 addr;
g_assert_cmpint (inet_pton (AF_INET, *iter, &addr), ==, 1);
g_array_append_val (items, addr.s_addr);
g_array_append_val (items, addr);
}
}
value_hash_add_uint_array (props, key, items);
@@ -294,7 +294,7 @@ parse_ip4 (GKeyFile *kf, GHashTable **out_props, const char *section, GError **e
list = NULL;
for (iter = split; iter && *iter; iter++) {
NMIP4Address *addr;
struct in_addr a;
guint32 a;
char *p;
if (strlen (g_strstrip (*iter)) == 0)
@@ -307,7 +307,7 @@ parse_ip4 (GKeyFile *kf, GHashTable **out_props, const char *section, GError **e
*p++ = '\0';
g_assert_cmpint (inet_pton (AF_INET, *iter, &a), ==, 1);
nm_ip4_address_set_address (addr, a.s_addr);
nm_ip4_address_set_address (addr, a);
nm_ip4_address_set_prefix (addr, (guint) atoi (p));
p = strchr (p, ' ');
@@ -315,7 +315,7 @@ parse_ip4 (GKeyFile *kf, GHashTable **out_props, const char *section, GError **e
p++;
g_assert_cmpint (inet_pton (AF_INET, p, &a), ==, 1);
nm_ip4_address_set_gateway (addr, a.s_addr);
nm_ip4_address_set_gateway (addr, a);
list = g_slist_append (list, addr);
}
@@ -338,7 +338,7 @@ parse_ip4 (GKeyFile *kf, GHashTable **out_props, const char *section, GError **e
list = NULL;
for (iter = split; iter && *iter; iter++) {
NMIP4Route *route;
struct in_addr a;
guint32 a;
char *p;
if (strlen (g_strstrip (*iter)) == 0)
@@ -351,7 +351,7 @@ parse_ip4 (GKeyFile *kf, GHashTable **out_props, const char *section, GError **e
*p++ = '\0';
g_assert_cmpint (inet_pton (AF_INET, *iter, &a), ==, 1);
nm_ip4_route_set_dest (route, a.s_addr);
nm_ip4_route_set_dest (route, a);
nm_ip4_route_set_prefix (route, (guint) atoi (p));
p = strchr (p, ' ');
@@ -359,7 +359,7 @@ parse_ip4 (GKeyFile *kf, GHashTable **out_props, const char *section, GError **e
p++;
g_assert_cmpint (inet_pton (AF_INET, p, &a), ==, 1);
nm_ip4_route_set_next_hop (route, a.s_addr);
nm_ip4_route_set_next_hop (route, a);
p = strchr (p, ' ');
g_assert (p);

View File

@@ -370,7 +370,7 @@ NMIP4Address *
nmc_parse_and_build_ip4_address (const char *ip_str, const char *gw_str, GError **error)
{
NMIP4Address *addr = NULL;
struct in_addr ip4_addr, gw_addr;
guint32 ip4_addr, gw_addr;
char *tmp;
char *plen;
long int prefix;
@@ -405,9 +405,9 @@ nmc_parse_and_build_ip4_address (const char *ip_str, const char *gw_str, GError
}
addr = nm_ip4_address_new ();
nm_ip4_address_set_address (addr, ip4_addr.s_addr);
nm_ip4_address_set_address (addr, ip4_addr);
nm_ip4_address_set_prefix (addr, (guint32) prefix);
nm_ip4_address_set_gateway (addr, gw_addr.s_addr);
nm_ip4_address_set_gateway (addr, gw_addr);
finish:
g_free (tmp);
@@ -477,7 +477,7 @@ NMIP4Route *
nmc_parse_and_build_ip4_route (const char *ip_str, const char *next_hop_str, const char *metric_str, GError **error)
{
NMIP4Route *route = NULL;
struct in_addr ip4_addr, next_hop_addr;
guint32 ip4_addr, next_hop_addr;
char *tmp;
char *plen;
long int prefix, metric;
@@ -521,9 +521,9 @@ nmc_parse_and_build_ip4_route (const char *ip_str, const char *next_hop_str, con
}
route = nm_ip4_route_new ();
nm_ip4_route_set_dest (route, ip4_addr.s_addr);
nm_ip4_route_set_dest (route, ip4_addr);
nm_ip4_route_set_prefix (route, (guint32) prefix);
nm_ip4_route_set_next_hop (route, next_hop_addr.s_addr);
nm_ip4_route_set_next_hop (route, next_hop_addr);
nm_ip4_route_set_metric (route, (guint32) metric);
finish:

View File

@@ -2561,7 +2561,7 @@ static gboolean
nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
{
char **strv = NULL, **iter;
struct in_addr ip4_addr;
guint32 ip4_addr;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -2572,7 +2572,7 @@ nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val
g_strfreev (strv);
return FALSE;
}
nm_setting_ip4_config_add_dns (NM_SETTING_IP4_CONFIG (setting), ip4_addr.s_addr);
nm_setting_ip4_config_add_dns (NM_SETTING_IP4_CONFIG (setting), ip4_addr);
}
g_strfreev (strv);
return TRUE;

View File

@@ -175,19 +175,19 @@ ssid_to_hex (const char *str, gsize len)
char *
nmc_ip4_address_as_string (guint32 ip, GError **error)
{
struct in_addr tmp_addr;
guint32 tmp_addr;
char buf[INET_ADDRSTRLEN];
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
memset (&buf, '\0', sizeof (buf));
tmp_addr.s_addr = ip;
tmp_addr = ip;
if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) {
return g_strdup (buf);
} else {
g_set_error (error, NMCLI_ERROR, 0, _("Error converting IP4 address '0x%X' to text form"),
ntohl (tmp_addr.s_addr));
ntohl (tmp_addr));
return NULL;
}
}

View File

@@ -70,16 +70,16 @@ static gchar *
ip4_address_as_string (guint32 ip)
{
char buf[INET_ADDRSTRLEN+1];
struct in_addr tmp_addr;
guint32 tmp_addr;
memset (&buf, '\0', sizeof (buf));
tmp_addr.s_addr = ip;
tmp_addr = ip;
if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) {
return g_strdup (buf);
} else {
g_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (tmp_addr.s_addr));
__func__, ntohl (tmp_addr));
return NULL;
}
}

View File

@@ -145,16 +145,16 @@ _nm_utils_convert_uint_array_to_string (const GValue *src_value, GValue *dest_va
printable = g_string_new (NULL);
while (array && (i < array->len)) {
char buf[INET_ADDRSTRLEN + 1];
struct in_addr addr;
guint32 addr;
if (i > 0)
g_string_append (printable, ", ");
memset (buf, 0, sizeof (buf));
addr.s_addr = g_array_index (array, guint32, i++);
addr = g_array_index (array, guint32, i++);
if (!inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN))
g_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
__func__, ntohl (addr));
g_string_append (printable, buf);
}
@@ -176,7 +176,7 @@ _nm_utils_convert_ip4_addr_route_struct_array_to_string (const GValue *src_value
while (ptr_array && (i < ptr_array->len)) {
GArray *array;
char buf[INET_ADDRSTRLEN + 1];
struct in_addr addr;
guint32 addr;
gboolean is_addr; /* array contains address x route */
if (i > 0)
@@ -191,10 +191,10 @@ _nm_utils_convert_ip4_addr_route_struct_array_to_string (const GValue *src_value
is_addr = (array->len < 4);
memset (buf, 0, sizeof (buf));
addr.s_addr = g_array_index (array, guint32, 0);
addr = g_array_index (array, guint32, 0);
if (!inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN))
g_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
__func__, ntohl (addr));
if (is_addr)
g_string_append_printf (printable, "ip = %s", buf);
else
@@ -205,10 +205,10 @@ _nm_utils_convert_ip4_addr_route_struct_array_to_string (const GValue *src_value
if (array->len > 2) {
memset (buf, 0, sizeof (buf));
addr.s_addr = g_array_index (array, guint32, 2);
addr = g_array_index (array, guint32, 2);
if (!inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN))
g_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
__func__, ntohl (addr));
if (is_addr)
g_string_append_printf (printable, ", gw = %s", buf);
else

View File

@@ -2018,7 +2018,7 @@ aipd_cleanup (NMDevice *self)
}
static NMIP4Config *
aipd_get_ip4_config (NMDevice *self, struct in_addr lla)
aipd_get_ip4_config (NMDevice *self, guint32 lla)
{
NMIP4Config *config = NULL;
NMPlatformIP4Address address;
@@ -2028,7 +2028,7 @@ aipd_get_ip4_config (NMDevice *self, struct in_addr lla)
g_assert (config);
memset (&address, 0, sizeof (address));
address.address = lla.s_addr;
address.address = lla;
address.plen = 16;
nm_ip4_config_add_address (config, &address);
@@ -2074,7 +2074,7 @@ nm_device_handle_autoip4_event (NMDevice *self,
iface = nm_device_get_iface (self);
if (strcmp (event, "BIND") == 0) {
struct in_addr lla;
guint32 lla;
NMIP4Config *config;
if (inet_pton (AF_INET, address, &lla) <= 0) {
@@ -2084,7 +2084,7 @@ nm_device_handle_autoip4_event (NMDevice *self,
return;
}
if ((lla.s_addr & IPV4LL_NETMASK) != IPV4LL_NETWORK) {
if ((lla & IPV4LL_NETMASK) != IPV4LL_NETWORK) {
nm_log_err (LOGD_AUTOIP4, "(%s): invalid address %s received from avahi-autoipd (not link-local).",
iface, address);
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR);

View File

@@ -833,8 +833,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
char *slash;
NMPlatformIP4Route route;
int rt_cidr = 32;
struct in_addr rt_addr;
struct in_addr rt_route;
guint32 rt_addr, rt_route;
slash = strchr(*r, '/');
if (slash) {
@@ -856,15 +855,15 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
}
have_routes = TRUE;
if (rt_cidr == 0 && rt_addr.s_addr == 0) {
if (rt_cidr == 0 && rt_addr == 0) {
/* FIXME: how to handle multiple routers? */
*gwaddr = rt_route.s_addr;
*gwaddr = rt_route;
} else {
nm_log_info (LOGD_DHCP4, " classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
memset (&route, 0, sizeof (route));
route.network = rt_addr.s_addr;
route.network = rt_addr;
route.plen = rt_cidr;
route.gateway = rt_route.s_addr;
route.gateway = rt_route;
nm_ip4_config_add_route (ip4_config, &route);
}
}
@@ -881,7 +880,7 @@ process_dhclient_rfc3442_route (const char **octets, NMPlatformIP4Route *route,
int addr_len = 0, i = 0;
long int tmp;
char *next_hop;
struct in_addr tmp_addr;
guint32 tmp_addr;
*success = FALSE;
@@ -915,8 +914,8 @@ process_dhclient_rfc3442_route (const char **octets, NMPlatformIP4Route *route,
g_free (str_addr);
goto error;
}
tmp_addr.s_addr &= nm_utils_ip4_prefix_to_netmask ((guint32) tmp);
route->network = tmp_addr.s_addr;
tmp_addr &= nm_utils_ip4_prefix_to_netmask ((guint32) tmp);
route->network = tmp_addr;
}
/* Handle next hop */
@@ -925,7 +924,7 @@ process_dhclient_rfc3442_route (const char **octets, NMPlatformIP4Route *route,
g_free (next_hop);
goto error;
}
route->gateway = tmp_addr.s_addr;
route->gateway = tmp_addr;
g_free (next_hop);
*success = TRUE;
@@ -1063,8 +1062,7 @@ process_classful_routes (GHashTable *options, NMIP4Config *ip4_config)
for (s = searches; *s; s += 2) {
NMPlatformIP4Route route;
struct in_addr rt_addr;
struct in_addr rt_route;
guint32 rt_addr, rt_route;
if (inet_pton (AF_INET, *s, &rt_addr) <= 0) {
nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route address: '%s'", *s);
@@ -1078,9 +1076,9 @@ process_classful_routes (GHashTable *options, NMIP4Config *ip4_config)
// FIXME: ensure the IP addresse and route are sane
memset (&route, 0, sizeof (route));
route.network = rt_addr.s_addr;
route.network = rt_addr;
route.plen = 32;
route.gateway = rt_route.s_addr;
route.gateway = rt_route;
nm_ip4_config_add_route (ip4_config, &route);
nm_log_info (LOGD_DHCP, " static route %s gw %s", *s, *(s + 1));
@@ -1141,7 +1139,7 @@ ip4_options_to_config (NMDHCPClient *self)
{
NMDHCPClientPrivate *priv;
NMIP4Config *ip4_config = NULL;
struct in_addr tmp_addr;
guint32 tmp_addr;
NMPlatformIP4Address address;
char *str = NULL;
guint32 gwaddr = 0, plen = 0;
@@ -1157,14 +1155,14 @@ ip4_options_to_config (NMDHCPClient *self)
str = g_hash_table_lookup (priv->options, "new_ip_address");
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
address.address = tmp_addr.s_addr;
address.address = tmp_addr;
nm_log_info (LOGD_DHCP4, " address %s", str);
} else
goto error;
str = g_hash_table_lookup (priv->options, "new_subnet_mask");
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
plen = nm_utils_ip4_netmask_to_prefix (tmp_addr.s_addr);
plen = nm_utils_ip4_netmask_to_prefix (tmp_addr);
nm_log_info (LOGD_DHCP4, " plen %d (%s)", plen, str);
} else {
/* Get default netmask for the IP according to appropriate class. */
@@ -1197,7 +1195,7 @@ ip4_options_to_config (NMDHCPClient *self)
for (s = routers; *s; s++) {
/* FIXME: how to handle multiple routers? */
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
nm_ip4_config_set_gateway (ip4_config, tmp_addr.s_addr);
nm_ip4_config_set_gateway (ip4_config, tmp_addr);
nm_log_info (LOGD_DHCP4, " gateway %s", *s);
break;
} else
@@ -1226,7 +1224,7 @@ ip4_options_to_config (NMDHCPClient *self)
for (s = searches; *s; s++) {
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
nm_ip4_config_add_nameserver (ip4_config, tmp_addr.s_addr);
nm_ip4_config_add_nameserver (ip4_config, tmp_addr);
nm_log_info (LOGD_DHCP4, " nameserver '%s'", *s);
} else
nm_log_warn (LOGD_DHCP4, "ignoring invalid nameserver '%s'", *s);
@@ -1257,7 +1255,7 @@ ip4_options_to_config (NMDHCPClient *self)
for (s = searches; *s; s++) {
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
nm_ip4_config_add_wins (ip4_config, tmp_addr.s_addr);
nm_ip4_config_add_wins (ip4_config, tmp_addr);
nm_log_info (LOGD_DHCP4, " wins '%s'", *s);
} else
nm_log_warn (LOGD_DHCP4, "ignoring invalid WINS server '%s'", *s);
@@ -1291,7 +1289,7 @@ ip4_options_to_config (NMDHCPClient *self)
for (s = searches; *s; s++) {
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
nm_ip4_config_add_nis_server (ip4_config, tmp_addr.s_addr);
nm_ip4_config_add_nis_server (ip4_config, tmp_addr);
nm_log_info (LOGD_DHCP4, " nis '%s'", *s);
} else
nm_log_warn (LOGD_DHCP4, "ignoring invalid NIS server '%s'", *s);

View File

@@ -238,7 +238,7 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid, gboolean
NMIP4Config *ip4;
NMPlatformIP4Address address;
const char *data;
struct in_addr tmp;
guint32 tmp;
guint32 plen;
struct tm expire;
@@ -302,7 +302,7 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid, gboolean
nm_log_warn (LOGD_DHCP, "couldn't parse DHCP lease file IP4 address '%s'", data);
goto error;
}
address.address = tmp.s_addr;
address.address = tmp;
/* Netmask */
data = g_hash_table_lookup (hash, "option subnet-mask");
@@ -311,7 +311,7 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid, gboolean
nm_log_warn (LOGD_DHCP, "couldn't parse DHCP lease file IP4 subnet mask '%s'", data);
goto error;
}
plen = nm_utils_ip4_netmask_to_prefix (tmp.s_addr);
plen = nm_utils_ip4_netmask_to_prefix (tmp);
} else {
/* Get default netmask for the IP according to appropriate class. */
plen = nm_utils_ip4_get_default_prefix (address.address);
@@ -325,7 +325,7 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid, gboolean
nm_log_warn (LOGD_DHCP, "couldn't parse DHCP lease file IP4 gateway '%s'", data);
goto error;
}
nm_ip4_config_set_gateway (ip4, tmp.s_addr);
nm_ip4_config_set_gateway (ip4, tmp);
}
nm_ip4_config_add_address (ip4, &address);

View File

@@ -111,10 +111,10 @@ merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src)
num = nm_ip4_config_get_num_nameservers (src);
for (i = 0; i < num; i++) {
struct in_addr addr;
guint32 addr;
char buf[INET_ADDRSTRLEN];
addr.s_addr = nm_ip4_config_get_nameserver (src, i);
addr = nm_ip4_config_get_nameserver (src, i);
if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0)
add_string_item (rc->nameservers, buf);
}
@@ -136,10 +136,10 @@ merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src)
/* NIS stuff */
num = nm_ip4_config_get_num_nis_servers (src);
for (i = 0; i < num; i++) {
struct in_addr addr;
guint32 addr;
char buf[INET_ADDRSTRLEN];
addr.s_addr = nm_ip4_config_get_nis_server (src, i);
addr = nm_ip4_config_get_nis_server (src, i);
if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0)
add_string_item (rc->nis_servers, buf);
}

View File

@@ -250,7 +250,7 @@ create_dm_cmd_line (const char *iface,
NMCmdLine *cmd;
GString *s;
const NMPlatformIP4Address *tmp;
struct in_addr addr;
guint32 addr;
char buf[INET_ADDRSTRLEN + 15];
char localaddr[INET_ADDRSTRLEN + 1];
@@ -294,10 +294,10 @@ create_dm_cmd_line (const char *iface,
nm_cmd_line_add_string (cmd, "--strict-order");
s = g_string_new ("--listen-address=");
addr.s_addr = tmp->address;
addr = tmp->address;
if (!inet_ntop (AF_INET, &addr, &localaddr[0], INET_ADDRSTRLEN)) {
char *err_msg = g_strdup_printf ("error converting IP4 address 0x%X",
ntohl (addr.s_addr));
ntohl (addr));
g_set_error_literal (error, NM_DNSMASQ_MANAGER_ERROR, NM_DNSMASQ_MANAGER_ERROR_NOT_FOUND, err_msg);
nm_log_warn (LOGD_SHARING, "%s", err_msg);
g_free (err_msg);
@@ -310,10 +310,10 @@ create_dm_cmd_line (const char *iface,
s = g_string_new ("--dhcp-range=");
/* Add start of address range */
addr.s_addr = tmp->address + htonl (9);
addr = tmp->address + htonl (9);
if (!inet_ntop (AF_INET, &addr, &buf[0], INET_ADDRSTRLEN)) {
char *err_msg = g_strdup_printf ("error converting IP4 address 0x%X",
ntohl (addr.s_addr));
ntohl (addr));
g_set_error_literal (error, NM_DNSMASQ_MANAGER_ERROR, NM_DNSMASQ_MANAGER_ERROR_NOT_FOUND, err_msg);
nm_log_warn (LOGD_SHARING, "%s", err_msg);
g_free (err_msg);
@@ -324,10 +324,10 @@ create_dm_cmd_line (const char *iface,
g_string_append_c (s, ',');
/* Add end of address range */
addr.s_addr = tmp->address + htonl (99);
addr = tmp->address + htonl (99);
if (!inet_ntop (AF_INET, &addr, &buf[0], INET_ADDRSTRLEN)) {
char *err_msg = g_strdup_printf ("error converting IP4 address 0x%X",
ntohl (addr.s_addr));
ntohl (addr));
g_set_error_literal (error, NM_DNSMASQ_MANAGER_ERROR, NM_DNSMASQ_MANAGER_ERROR_NOT_FOUND, err_msg);
nm_log_warn (LOGD_SHARING, "%s", err_msg);
g_free (err_msg);

View File

@@ -614,13 +614,13 @@ static gboolean
ip_string_to_network_address (const gchar *str,
guint32 *out)
{
struct in_addr addr;
guint32 addr;
/* IP address */
if (inet_pton (AF_INET, str, &addr) <= 0)
return FALSE;
*out = (guint32)addr.s_addr;
*out = (guint32)addr;
return TRUE;
}

View File

@@ -577,16 +577,16 @@ static char addr_to_string_buf[INET6_ADDRSTRLEN + 1];
static const char *
ip_address_to_string (guint32 numeric)
{
struct in_addr temp_addr;
guint32 temp_addr;
memset (&addr_to_string_buf, '\0', sizeof (addr_to_string_buf));
temp_addr.s_addr = numeric;
temp_addr = numeric;
if (inet_ntop (AF_INET, &temp_addr, addr_to_string_buf, INET_ADDRSTRLEN)) {
return addr_to_string_buf;
} else {
nm_log_warn (LOGD_VPN, "error converting IP4 address 0x%X",
ntohl (temp_addr.s_addr));
ntohl (temp_addr));
return NULL;
}
}

View File

@@ -334,10 +334,10 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg,
GByteArray *ifcfg_mac = NULL;
char **lines = NULL, **iter;
const char *method = NULL;
struct in_addr ipaddr;
struct in_addr gateway;
struct in_addr dns1;
struct in_addr dns2;
guint32 ipaddr;
guint32 gateway;
guint32 dns1;
guint32 dns2;
guint32 prefix = 0;
g_return_val_if_fail (s_ip4 != NULL, FALSE);
@@ -397,23 +397,23 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg,
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
NMIP4Address *addr;
if (!ipaddr.s_addr || !prefix) {
if (!ipaddr || !prefix) {
g_warning ("%s: malformed iscsiadm record: BOOTPROTO=static "
"but missing IP address or prefix.", __func__);
goto done;
}
addr = nm_ip4_address_new ();
nm_ip4_address_set_address (addr, ipaddr.s_addr);
nm_ip4_address_set_address (addr, ipaddr);
nm_ip4_address_set_prefix (addr, prefix);
nm_ip4_address_set_gateway (addr, gateway.s_addr);
nm_ip4_address_set_gateway (addr, gateway);
nm_setting_ip4_config_add_address (s_ip4, addr);
nm_ip4_address_unref (addr);
if (dns1.s_addr)
nm_setting_ip4_config_add_dns (s_ip4, dns1.s_addr);
if (dns2.s_addr)
nm_setting_ip4_config_add_dns (s_ip4, dns2.s_addr);
if (dns1)
nm_setting_ip4_config_add_dns (s_ip4, dns1);
if (dns2)
nm_setting_ip4_config_add_dns (s_ip4, dns2);
// FIXME: DNS search domains?
}
@@ -478,7 +478,7 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg,
}
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_SUBNET_TAG, &skip))) {
struct in_addr mask;
guint32 mask;
if (inet_pton (AF_INET, p, &mask) < 1) {
g_warning ("%s: malformed iscsiadm record: invalid subnet mask '%s'.",
@@ -487,7 +487,7 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg,
continue;
}
prefix = nm_utils_ip4_netmask_to_prefix (mask.s_addr);
prefix = nm_utils_ip4_netmask_to_prefix (mask);
}
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_GATEWAY_TAG, &skip))) {
@@ -537,7 +537,7 @@ read_ip4_address (shvarFile *ifcfg,
GError **error)
{
char *value = NULL;
struct in_addr ip4_addr;
guint32 ip4_addr;
gboolean success = FALSE;
g_return_val_if_fail (ifcfg != NULL, FALSE);
@@ -553,7 +553,7 @@ read_ip4_address (shvarFile *ifcfg,
return TRUE;
if (inet_pton (AF_INET, value, &ip4_addr) > 0) {
*out_addr = ip4_addr.s_addr;
*out_addr = ip4_addr;
success = TRUE;
} else {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
@@ -819,7 +819,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric;
GMatchInfo *match_info;
NMIP4Route *route;
struct in_addr ip4_addr;
guint32 ip4_addr;
char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL;
long int prefix_int, metric_int;
gboolean success = FALSE;
@@ -881,7 +881,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
g_free (dest);
goto error;
}
nm_ip4_route_set_dest (route, ip4_addr.s_addr);
nm_ip4_route_set_dest (route, ip4_addr);
g_free (dest);
/* Prefix - is optional; 32 if missing */
@@ -917,7 +917,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
g_free (next_hop);
goto error;
}
nm_ip4_route_set_next_hop (route, ip4_addr.s_addr);
nm_ip4_route_set_next_hop (route, ip4_addr);
g_free (next_hop);
/* Metric */
@@ -1677,7 +1677,7 @@ make_ip6_setting (shvarFile *ifcfg,
for (i = 1; i <= 10; i++) {
char *tag;
struct in6_addr ip6_dns;
struct in_addr ip4_addr;
guint32 ip4_addr;
tag = g_strdup_printf ("DNS%u", i);
value = svGetValue (ifcfg, tag, FALSE);

View File

@@ -347,7 +347,7 @@ test_read_wired_static (const char *file,
char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0xee };
const char *expected_dns1 = "4.2.2.1";
const char *expected_dns2 = "4.2.2.2";
struct in_addr addr;
guint32 addr;
struct in6_addr addr6;
const char *expected_address1 = "192.168.1.5";
const char *expected_address1_gw = "192.168.1.1";
@@ -395,9 +395,9 @@ test_read_wired_static (const char *file,
/* DNS Addresses */
g_assert_cmpint (nm_setting_ip4_config_get_num_dns (s_ip4), ==, 2);
g_assert_cmpint (inet_pton (AF_INET, expected_dns1, &addr), >, 0);
g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 0), ==, addr.s_addr);
g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 0), ==, addr);
g_assert_cmpint (inet_pton (AF_INET, expected_dns2, &addr), >, 0);
g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 1), ==, addr.s_addr);
g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 1), ==, addr);
/* IP addresses */
g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 1);
@@ -405,9 +405,9 @@ test_read_wired_static (const char *file,
g_assert (ip4_addr);
g_assert_cmpint (nm_ip4_address_get_prefix (ip4_addr), ==, 24);
g_assert_cmpint (inet_pton (AF_INET, expected_address1, &addr), >, 0);
g_assert_cmpint (nm_ip4_address_get_address (ip4_addr), ==, addr.s_addr);
g_assert_cmpint (nm_ip4_address_get_address (ip4_addr), ==, addr);
g_assert_cmpint (inet_pton (AF_INET, expected_address1_gw, &addr), >, 0);
g_assert_cmpint (nm_ip4_address_get_gateway (ip4_addr), ==, addr.s_addr);
g_assert_cmpint (nm_ip4_address_get_gateway (ip4_addr), ==, addr);
/* ===== IPv6 SETTING ===== */
s_ip6 = nm_connection_get_setting_ip6_config (connection);
@@ -506,7 +506,7 @@ test_read_wired_dhcp (void)
const char *expected_id = "System test-wired-dhcp";
const char *expected_dns1 = "4.2.2.1";
const char *expected_dns2 = "4.2.2.2";
struct in_addr addr;
guint32 addr;
const char *expected_dhcp_hostname = "foobar";
connection = connection_from_file (TEST_IFCFG_WIRED_DHCP,
@@ -635,7 +635,7 @@ test_read_wired_dhcp (void)
TEST_IFCFG_WIRED_DHCP,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr,
"wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_WIRED_DHCP,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -646,7 +646,7 @@ test_read_wired_dhcp (void)
TEST_IFCFG_WIRED_DHCP,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr,
"wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2",
TEST_IFCFG_WIRED_DHCP,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -677,7 +677,7 @@ test_read_wired_global_gateway (void)
GError *error = NULL;
const char *tmp;
const char *expected_id = "System test-wired-global-gateway";
struct in_addr addr;
guint32 addr;
const char *expected_address1 = "192.168.1.5";
const char *expected_address1_gw = "192.168.1.2";
NMIP4Address *ip4_addr;
@@ -765,7 +765,7 @@ test_read_wired_global_gateway (void)
TEST_IFCFG_WIRED_GLOBAL_GATEWAY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr,
"wired-global-gateway-verify-ip4", "failed to verify %s: unexpected IP4 address #1",
TEST_IFCFG_WIRED_GLOBAL_GATEWAY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -776,7 +776,7 @@ test_read_wired_global_gateway (void)
TEST_IFCFG_WIRED_GLOBAL_GATEWAY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_ADDRESSES);
ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr,
"wired-global-gateway-verify-ip4", "failed to verify %s: unexpected IP4 address #1 gateway",
TEST_IFCFG_WIRED_GLOBAL_GATEWAY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1177,7 +1177,7 @@ test_read_wired_static_routes (void)
GError *error = NULL;
const char *tmp;
NMIP4Route *ip4_route;
struct in_addr addr;
guint32 addr;
const char *expected_id = "System test-wired-static-routes";
const char *expected_dst1 = "11.22.33.0";
const char *expected_dst2 = "44.55.66.77";
@@ -1269,7 +1269,7 @@ test_read_wired_static_routes (void)
ASSERT (inet_pton (AF_INET, expected_dst1, &addr) > 0,
"wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert destination IP address #1",
TEST_IFCFG_WIRED_STATIC_ROUTES);
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr,
"wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_WIRED_STATIC_ROUTES,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1282,7 +1282,7 @@ test_read_wired_static_routes (void)
ASSERT (inet_pton (AF_INET, expected_gw1, &addr) > 0,
"wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #1",
TEST_IFCFG_WIRED_STATIC_ROUTES);
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr,
"wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_WIRED_STATIC_ROUTES,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1296,7 +1296,7 @@ test_read_wired_static_routes (void)
ASSERT (inet_pton (AF_INET, expected_dst2, &addr) > 0,
"wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert destination IP address #2",
TEST_IFCFG_WIRED_STATIC_ROUTES);
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr,
"wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2",
TEST_IFCFG_WIRED_STATIC_ROUTES,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1309,7 +1309,7 @@ test_read_wired_static_routes (void)
ASSERT (inet_pton (AF_INET, expected_gw2, &addr) > 0,
"wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #2",
TEST_IFCFG_WIRED_STATIC_ROUTES);
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr,
"wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2",
TEST_IFCFG_WIRED_STATIC_ROUTES,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1342,7 +1342,7 @@ test_read_wired_static_routes_legacy (void)
GError *error = NULL;
const char *tmp;
NMIP4Route *ip4_route;
struct in_addr addr;
guint32 addr;
const char *expected_id = "System test-wired-static-routes-legacy";
const char *expected_dst1 = "21.31.41.0";
const char *expected_dst2 = "32.42.52.62";
@@ -1437,7 +1437,7 @@ test_read_wired_static_routes_legacy (void)
ASSERT (inet_pton (AF_INET, expected_dst1, &addr) > 0,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert destination IP address #1",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY);
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1450,7 +1450,7 @@ test_read_wired_static_routes_legacy (void)
ASSERT (inet_pton (AF_INET, expected_gw1, &addr) > 0,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #1",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY);
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1469,7 +1469,7 @@ test_read_wired_static_routes_legacy (void)
ASSERT (inet_pton (AF_INET, expected_dst2, &addr) > 0,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert destination IP address #2",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY);
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1482,7 +1482,7 @@ test_read_wired_static_routes_legacy (void)
ASSERT (inet_pton (AF_INET, expected_gw2, &addr) > 0,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #2",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY);
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1501,7 +1501,7 @@ test_read_wired_static_routes_legacy (void)
ASSERT (inet_pton (AF_INET, expected_dst3, &addr) > 0,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert destination IP address #3",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY);
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_dest (ip4_route) == addr,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #3",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1514,7 +1514,7 @@ test_read_wired_static_routes_legacy (void)
ASSERT (inet_pton (AF_INET, expected_gw3, &addr) > 0,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #3",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY);
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr.s_addr,
ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr,
"wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #3",
TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -1552,7 +1552,7 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id)
guint32 expected_prefix2 = 16;
guint32 expected_prefix3 = 8;
NMIP4Address *ip4_addr;
struct in_addr addr;
guint32 addr;
connection = connection_from_file (file,
NULL,
@@ -1638,7 +1638,7 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id)
ASSERT (inet_pton (AF_INET, expected_address1, &addr) > 0,
"wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #1",
file);
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr,
"wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #1",
file);
@@ -1655,7 +1655,7 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id)
ASSERT (inet_pton (AF_INET, expected_address2, &addr) > 0,
"wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #2",
file);
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr,
"wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #2",
file);
@@ -1672,7 +1672,7 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id)
ASSERT (inet_pton (AF_INET, expected_address3, &addr) > 0,
"wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #3",
file);
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr,
"wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #3",
file);
@@ -3340,7 +3340,7 @@ test_read_wifi_wep_adhoc (void)
const char *expected_ssid = "blahblah";
const char *expected_mode = "adhoc";
const char *expected_wep_key0 = "0123456789abcdef0123456789";
struct in_addr addr;
guint32 addr;
const char *expected_dns1 = "4.2.2.1";
const char *expected_dns2 = "4.2.2.2";
@@ -3562,7 +3562,7 @@ test_read_wifi_wep_adhoc (void)
TEST_IFCFG_WIFI_WEP_ADHOC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr,
"wifi-wep-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_WIFI_WEP_ADHOC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -3573,7 +3573,7 @@ test_read_wifi_wep_adhoc (void)
TEST_IFCFG_WIFI_WEP_ADHOC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr,
"wifi-wep-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2",
TEST_IFCFG_WIFI_WEP_ADHOC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -10048,7 +10048,7 @@ test_read_ibft_static (void)
guint64 expected_timestamp = 0;
const char *expected_dns1 = "10.16.255.2";
const char *expected_dns2 = "10.16.255.3";
struct in_addr addr;
guint32 addr;
const char *expected_address1 = "192.168.32.72";
const char *expected_address1_gw = "192.168.35.254";
NMIP4Address *ip4_addr;
@@ -10176,7 +10176,7 @@ test_read_ibft_static (void)
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr,
"ibft-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -10187,7 +10187,7 @@ test_read_ibft_static (void)
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr,
"ibft-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2",
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -10218,7 +10218,7 @@ test_read_ibft_static (void)
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr,
"ibft-static-verify-ip4", "failed to verify %s: unexpected IP4 address #1",
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -10229,7 +10229,7 @@ test_read_ibft_static (void)
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_ADDRESSES);
ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr,
"ibft-static-verify-ip4", "failed to verify %s: unexpected IP4 address #1 gateway",
TEST_IFCFG_IBFT_STATIC,
NM_SETTING_IP4_CONFIG_SETTING_NAME,

View File

@@ -353,7 +353,7 @@ static ip_block *
create_ip4_block (gchar * ip)
{
ip_block *iblock = g_slice_new0 (ip_block);
struct in_addr tmp_ip4_addr;
guint32 tmp_ip4_addr;
int i;
guint length;
gchar **ip_mask;
@@ -366,7 +366,7 @@ create_ip4_block (gchar * ip)
length = g_strv_length (ip_mask);
if (!inet_pton (AF_INET, ip_mask[0], &tmp_ip4_addr))
goto error;
iblock->ip = tmp_ip4_addr.s_addr;
iblock->ip = tmp_ip4_addr;
prefix = ip_mask[1];
i = 0;
while (i < length && g_ascii_isdigit (prefix[i]))
@@ -380,7 +380,7 @@ create_ip4_block (gchar * ip)
length = g_strv_length (ip_mask);
if (!inet_pton (AF_INET, ip_mask[0], &tmp_ip4_addr))
goto error;
iblock->ip = tmp_ip4_addr.s_addr;
iblock->ip = tmp_ip4_addr;
i = 0;
while (i < length && !strstr (ip_mask[++i], "netmask")) ;
while (i < length && ip_mask[++i][0] == '\0') ;
@@ -388,7 +388,7 @@ create_ip4_block (gchar * ip)
goto error;
if (!inet_pton (AF_INET, ip_mask[i], &tmp_ip4_addr))
goto error;
iblock->netmask = tmp_ip4_addr.s_addr;
iblock->netmask = tmp_ip4_addr;
} else {
g_slice_free (ip_block, iblock);
if (!is_ip6_address (ip) && !strstr (ip, "dhcp"))
@@ -449,7 +449,7 @@ static guint32
get_ip4_gateway (gchar * gateway)
{
gchar *tmp, *split;
struct in_addr tmp_ip4_addr;
guint32 tmp_ip4_addr;
if (!gateway)
return 0;
@@ -470,7 +470,7 @@ get_ip4_gateway (gchar * gateway)
if (!inet_pton (AF_INET, tmp, &tmp_ip4_addr))
goto error;
g_free (tmp);
return tmp_ip4_addr.s_addr;
return tmp_ip4_addr;
error:
if (!is_ip6_address (tmp))
PLUGIN_WARN (IFNET_PLUGIN_NAME, "Can't handle IPv4 gateway: %s",
@@ -688,7 +688,7 @@ set_ip4_dns_servers (NMSettingIP4Config *s_ip4, const char *conn_name)
const char *dns_servers;
gchar **server_list, *stripped;
guint length, i;
struct in_addr tmp_ip4_addr;
guint32 tmp_ip4_addr;
guint32 new_dns;
dns_servers = ifnet_get_data (conn_name, "dns_servers");
@@ -714,7 +714,7 @@ set_ip4_dns_servers (NMSettingIP4Config *s_ip4, const char *conn_name)
server_list[i]);
continue;
}
new_dns = tmp_ip4_addr.s_addr;
new_dns = tmp_ip4_addr;
if (new_dns && !nm_setting_ip4_config_add_dns (s_ip4, new_dns))
PLUGIN_WARN (IFNET_PLUGIN_NAME,
"warning: duplicate DNS server %s",

View File

@@ -159,18 +159,18 @@ static void
check_ip_block (ip_block * iblock, gchar * ip, gchar * netmask, gchar * gateway)
{
char *str;
struct in_addr tmp_ip4_addr;
guint32 tmp_ip4_addr;
str = malloc (INET_ADDRSTRLEN);
tmp_ip4_addr.s_addr = iblock->ip;
tmp_ip4_addr = iblock->ip;
inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
ASSERT (strcmp (ip, str) == 0, "check ip",
"ip expected:%s, find:%s", ip, str);
tmp_ip4_addr.s_addr = iblock->netmask;
tmp_ip4_addr = iblock->netmask;
inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
ASSERT (strcmp (netmask, str) == 0, "check netmask",
"netmask expected:%s, find:%s", netmask, str);
tmp_ip4_addr.s_addr = iblock->gateway;
tmp_ip4_addr = iblock->gateway;
inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
ASSERT (strcmp (gateway, str) == 0, "check gateway",
"gateway expected:%s, find:%s", gateway, str);

View File

@@ -437,7 +437,7 @@ eni_plugin_error_quark() {
static void
ifupdown_ip4_add_dns (NMSettingIP4Config *s_ip4, const char *dns)
{
struct in_addr addr;
guint32 addr;
char **list, **iter;
if (dns == NULL)
@@ -454,7 +454,7 @@ ifupdown_ip4_add_dns (NMSettingIP4Config *s_ip4, const char *dns)
continue;
}
if (!nm_setting_ip4_config_add_dns (s_ip4, addr.s_addr)) {
if (!nm_setting_ip4_config_add_dns (s_ip4, addr)) {
PLUGIN_WARN ("SCPlugin-Ifupdown",
" warning: duplicate DNS domain '%s'", *iter);
}
@@ -475,7 +475,7 @@ update_ip4_setting_from_if_block(NMConnection *connection,
if (!is_static) {
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
} else {
struct in_addr tmp_addr, tmp_mask, tmp_gw;
guint32 tmp_addr, tmp_mask, tmp_gw;
NMIP4Address *addr;
const char *address_v;
const char *netmask_v;
@@ -510,7 +510,7 @@ update_ip4_setting_from_if_block(NMConnection *connection,
"Invalid IPv4 netmask '%s'", netmask_v);
goto error;
} else {
netmask_int = nm_utils_ip4_netmask_to_prefix (tmp_mask.s_addr);
netmask_int = nm_utils_ip4_netmask_to_prefix (tmp_mask);
}
}
@@ -526,9 +526,9 @@ update_ip4_setting_from_if_block(NMConnection *connection,
/* Add the new address to the setting */
addr = nm_ip4_address_new ();
nm_ip4_address_set_address (addr, tmp_addr.s_addr);
nm_ip4_address_set_address (addr, tmp_addr);
nm_ip4_address_set_prefix (addr, netmask_int);
nm_ip4_address_set_gateway (addr, tmp_gw.s_addr);
nm_ip4_address_set_gateway (addr, tmp_gw);
if (nm_setting_ip4_config_add_address (s_ip4, addr)) {
PLUGIN_PRINT("SCPlugin-Ifupdown", "addresses count: %d",

View File

@@ -476,7 +476,7 @@ test17_read_static_ipv4 (const char *path)
const char *expected_search2 = "foo.example.com";
guint32 expected_prefix = 8;
NMIP4Address *ip4_addr;
struct in_addr addr;
guint32 addr;
#define TEST17_NAME "wired-static-verify-ip4"
if_block *block = NULL;
@@ -561,9 +561,9 @@ test17_read_static_ipv4 (const char *path)
TEST17_NAME, "failed to verify %s: unexpected IP4 address prefix",
file);
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr,
TEST17_NAME, "failed to verify %s: unexpected IP4 address: %s",
file, addr.s_addr);
file, addr);
/* DNS Addresses */
ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 2,
@@ -578,7 +578,7 @@ test17_read_static_ipv4 (const char *path)
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr,
TEST17_NAME, "failed to verify %s: unexpected %s / %s key value #1",
file,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -590,7 +590,7 @@ test17_read_static_ipv4 (const char *path)
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr,
TEST17_NAME, "failed to verify %s: unexpected %s / %s key value #2",
file,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -848,7 +848,7 @@ test19_read_static_ipv4_plen (const char *path)
const char *expected_address = "10.0.0.3";
guint32 expected_prefix = 8;
NMIP4Address *ip4_addr;
struct in_addr addr;
guint32 addr;
#define TEST19_NAME "wired-static-verify-ip4-plen"
if_block *block = NULL;
@@ -896,9 +896,9 @@ test19_read_static_ipv4_plen (const char *path)
TEST19_NAME, "failed to verify %s: unexpected IP4 address prefix",
file);
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr,
ASSERT (nm_ip4_address_get_address (ip4_addr) == addr,
TEST19_NAME, "failed to verify %s: unexpected IP4 address: %s",
file, addr.s_addr);
file, addr);
g_object_unref (connection);
}

View File

@@ -114,7 +114,7 @@ static gpointer
build_ip4_address_or_route (const char *address_str, guint32 plen, const char *gateway_str, guint32 metric, gboolean route)
{
GArray *result;
struct in_addr addr;
guint32 addr;
guint32 address = 0;
guint32 gateway = 0;
int err;
@@ -127,7 +127,7 @@ build_ip4_address_or_route (const char *address_str, guint32 plen, const char *g
g_warning ("%s: ignoring invalid IPv4 address '%s'", __func__, address_str);
return NULL;
}
address = addr.s_addr;
address = addr;
/* Gateway */
if (gateway_str) {
err = inet_pton (AF_INET, gateway_str, &addr);
@@ -135,7 +135,7 @@ build_ip4_address_or_route (const char *address_str, guint32 plen, const char *g
g_warning ("%s: ignoring invalid IPv4 gateway '%s'", __func__, gateway_str);
return NULL;
}
gateway = addr.s_addr;
gateway = addr;
}
else
gateway = 0;
@@ -445,7 +445,7 @@ ip4_dns_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const ch
array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), length);
for (iter = list; *iter; iter++) {
struct in_addr addr;
guint32 addr;
ret = inet_pton (AF_INET, *iter, &addr);
if (ret <= 0) {
@@ -453,7 +453,7 @@ ip4_dns_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const ch
continue;
}
g_array_append_val (array, addr.s_addr);
g_array_append_val (array, addr);
}
g_strfreev (list);

View File

@@ -53,16 +53,15 @@ static void
check_ip4_address (NMSettingIP4Config *config, int idx, const char *address_str, int plen, const char *gateway_str)
{
NMIP4Address *ip4 = nm_setting_ip4_config_get_address (config, idx);
struct in_addr address;
struct in_addr gateway;
guint32 address, gateway;
g_assert (inet_pton (AF_INET, address_str, &address) == 1);
g_assert (inet_pton (AF_INET, gateway_str, &gateway) == 1);
g_assert (ip4);
g_assert (nm_ip4_address_get_address (ip4) == address.s_addr);
g_assert (nm_ip4_address_get_address (ip4) == address);
g_assert (nm_ip4_address_get_prefix (ip4) == plen);
g_assert (nm_ip4_address_get_gateway (ip4) == gateway.s_addr);
g_assert (nm_ip4_address_get_gateway (ip4) == gateway);
}
static void
@@ -86,16 +85,15 @@ check_ip4_route (NMSettingIP4Config *config, int idx, const char *destination_st
const char *nexthop_str, int metric)
{
NMIP4Route *route = nm_setting_ip4_config_get_route (config, idx);
struct in_addr destination;
struct in_addr nexthop;
guint32 destination, nexthop;
g_assert (inet_pton (AF_INET, destination_str, &destination) == 1);
g_assert (inet_pton (AF_INET, nexthop_str, &nexthop) == 1);
g_assert (route);
g_assert (nm_ip4_route_get_dest (route) == destination.s_addr);
g_assert (nm_ip4_route_get_dest (route) == destination);
g_assert (nm_ip4_route_get_prefix (route) == plen);
g_assert (nm_ip4_route_get_next_hop (route) == nexthop.s_addr);
g_assert (nm_ip4_route_get_next_hop (route) == nexthop);
g_assert (nm_ip4_route_get_metric (route) == metric);
}
@@ -135,7 +133,7 @@ test_read_valid_wired_connection (void)
guint64 timestamp;
const char *expected_dns1 = "4.2.2.1";
const char *expected_dns2 = "4.2.2.2";
struct in_addr addr;
guint32 addr;
struct in6_addr addr6;
const char *expected6_dns1 = "1111:dddd::aaaa";
const char *expected6_dns2 = "1::cafe";
@@ -259,7 +257,7 @@ test_read_valid_wired_connection (void)
TEST_WIRED_FILE,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr,
"connection-verify-wired", "failed to verify %s: unexpected %s / %s key value #1",
TEST_WIRED_FILE,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -270,7 +268,7 @@ test_read_valid_wired_connection (void)
TEST_WIRED_FILE,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_DNS);
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr.s_addr,
ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr,
"connection-verify-wired", "failed to verify %s: unexpected %s / %s key value #2",
TEST_WIRED_FILE,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
@@ -377,17 +375,17 @@ add_one_ip4_address (NMSettingIP4Config *s_ip4,
const char *gw,
guint32 prefix)
{
struct in_addr tmp;
guint32 tmp;
NMIP4Address *ip4_addr;
ip4_addr = nm_ip4_address_new ();
nm_ip4_address_set_prefix (ip4_addr, prefix);
inet_pton (AF_INET, addr, &tmp);
nm_ip4_address_set_address (ip4_addr, tmp.s_addr);
nm_ip4_address_set_address (ip4_addr, tmp);
inet_pton (AF_INET, gw, &tmp);
nm_ip4_address_set_gateway (ip4_addr, tmp.s_addr);
nm_ip4_address_set_gateway (ip4_addr, tmp);
nm_setting_ip4_config_add_address (s_ip4, ip4_addr);
nm_ip4_address_unref (ip4_addr);
@@ -400,7 +398,7 @@ add_one_ip4_route (NMSettingIP4Config *s_ip4,
guint32 prefix,
guint32 metric)
{
struct in_addr addr;
guint32 addr;
NMIP4Route *route;
route = nm_ip4_route_new ();
@@ -408,10 +406,10 @@ add_one_ip4_route (NMSettingIP4Config *s_ip4,
nm_ip4_route_set_metric (route, metric);
inet_pton (AF_INET, dest, &addr);
nm_ip4_route_set_dest (route, addr.s_addr);
nm_ip4_route_set_dest (route, addr);
inet_pton (AF_INET, nh, &addr);
nm_ip4_route_set_next_hop (route, addr.s_addr);
nm_ip4_route_set_next_hop (route, addr);
nm_setting_ip4_config_add_route (s_ip4, route);
nm_ip4_route_unref (route);
@@ -483,7 +481,7 @@ test_write_wired_connection (void)
GError *error = NULL;
pid_t owner_grp;
uid_t owner_uid;
struct in_addr addr;
guint32 addr;
struct in6_addr addr6;
const char *dns1 = "4.2.2.1";
const char *dns2 = "4.2.2.2";
@@ -554,9 +552,9 @@ test_write_wired_connection (void)
/* DNS servers */
inet_pton (AF_INET, dns1, &addr);
nm_setting_ip4_config_add_dns (s_ip4, addr.s_addr);
nm_setting_ip4_config_add_dns (s_ip4, addr);
inet_pton (AF_INET, dns2, &addr);
nm_setting_ip4_config_add_dns (s_ip4, addr.s_addr);
nm_setting_ip4_config_add_dns (s_ip4, addr);
/* IP6 setting */

View File

@@ -118,12 +118,12 @@ ip4_dns_writer (GKeyFile *file,
for (i = 0; i < array->len; i++) {
char buf[INET_ADDRSTRLEN + 1];
struct in_addr addr;
guint32 addr;
addr.s_addr = g_array_index (array, guint32, i);
addr = g_array_index (array, guint32, i);
if (!inet_ntop (AF_INET, &addr, buf, sizeof (buf))) {
g_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
__func__, ntohl (addr));
} else
list[num++] = g_strdup (buf);
}
@@ -155,13 +155,13 @@ write_ip4_values (GKeyFile *file,
for (k = 0; k < tuple_len; k++) {
if (k == addr1_pos || k == addr2_pos) {
char buf[INET_ADDRSTRLEN + 1];
struct in_addr addr;
guint32 addr;
/* IP addresses */
addr.s_addr = g_array_index (tuple, guint32, k);
addr = g_array_index (tuple, guint32, k);
if (!inet_ntop (AF_INET, &addr, buf, sizeof (buf))) {
g_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
__func__, ntohl (addr));
success = FALSE;
break;
} else {

View File

@@ -103,7 +103,7 @@ test_generic_options (const char *client)
NMIP4Config *ip4_config;
const NMPlatformIP4Address *address;
NMPlatformIP4Route *route;
struct in_addr tmp;
guint32 tmp;
const char *expected_addr = "192.168.1.106";
const char *expected_gw = "192.168.1.1";
const char *expected_dns1 = "216.254.95.2";
@@ -127,7 +127,7 @@ test_generic_options (const char *client)
ASSERT (inet_pton (AF_INET, expected_addr, &tmp) > 0,
"dhcp-generic", "couldn't convert expected IP address");
ASSERT (address->address == tmp.s_addr,
ASSERT (address->address == tmp,
"dhcp-generic", "unexpected IP address");
ASSERT (address->plen == 24,
@@ -136,7 +136,7 @@ test_generic_options (const char *client)
/* Gateway */
ASSERT (inet_pton (AF_INET, expected_gw, &tmp) > 0,
"dhcp-generic", "couldn't convert expected IP gateway");
ASSERT (nm_ip4_config_get_gateway (ip4_config) == tmp.s_addr,
ASSERT (nm_ip4_config_get_gateway (ip4_config) == tmp,
"dhcp-generic", "unexpected IP gateway");
ASSERT (nm_ip4_config_get_ptp_address (ip4_config) == 0,
@@ -161,11 +161,11 @@ test_generic_options (const char *client)
"dhcp-generic", "unexpected number of domain name servers");
ASSERT (inet_pton (AF_INET, expected_dns1, &tmp) > 0,
"dhcp-generic", "couldn't convert expected DNS server address #1");
ASSERT (nm_ip4_config_get_nameserver (ip4_config, 0) == tmp.s_addr,
ASSERT (nm_ip4_config_get_nameserver (ip4_config, 0) == tmp,
"dhcp-generic", "unexpected domain name server #1");
ASSERT (inet_pton (AF_INET, expected_dns2, &tmp) > 0,
"dhcp-generic", "couldn't convert expected DNS server address #2");
ASSERT (nm_ip4_config_get_nameserver (ip4_config, 1) == tmp.s_addr,
ASSERT (nm_ip4_config_get_nameserver (ip4_config, 1) == tmp,
"dhcp-generic", "unexpected domain name server #2");
/* Routes */
@@ -176,12 +176,12 @@ test_generic_options (const char *client)
route = nm_ip4_config_get_route (ip4_config, 0);
ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
"dhcp-generic", "couldn't convert expected route destination #1");
ASSERT (route->network == tmp.s_addr,
ASSERT (route->network == tmp,
"dhcp-generic", "unexpected route #1 destination");
ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
"dhcp-generic", "couldn't convert expected route next hop #1");
ASSERT (route->gateway == tmp.s_addr,
ASSERT (route->gateway == tmp,
"dhcp-generic", "unexpected route #1 next hop");
ASSERT (route->plen == 32,
@@ -193,12 +193,12 @@ test_generic_options (const char *client)
route = nm_ip4_config_get_route (ip4_config, 1);
ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0,
"dhcp-generic", "couldn't convert expected route destination #2");
ASSERT (route->network == tmp.s_addr,
ASSERT (route->network == tmp,
"dhcp-generic", "unexpected route #2 destination");
ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0,
"dhcp-generic", "couldn't convert expected route next hop #2");
ASSERT (route->gateway == tmp.s_addr,
ASSERT (route->gateway == tmp,
"dhcp-generic", "unexpected route #2 next hop");
ASSERT (route->plen == 32,
@@ -220,7 +220,7 @@ test_wins_options (const char *client)
GHashTable *options;
NMIP4Config *ip4_config;
const NMPlatformIP4Address *address;
struct in_addr tmp;
guint32 tmp;
const char *expected_wins1 = "63.12.199.5";
const char *expected_wins2 = "150.4.88.120";
@@ -240,11 +240,11 @@ test_wins_options (const char *client)
"dhcp-wins", "unexpected number of WINS servers");
ASSERT (inet_pton (AF_INET, expected_wins1, &tmp) > 0,
"dhcp-wins", "couldn't convert expected WINS server address #1");
ASSERT (nm_ip4_config_get_wins (ip4_config, 0) == tmp.s_addr,
ASSERT (nm_ip4_config_get_wins (ip4_config, 0) == tmp,
"dhcp-wins", "unexpected WINS server #1");
ASSERT (inet_pton (AF_INET, expected_wins2, &tmp) > 0,
"dhcp-wins", "couldn't convert expected WINS server address #1");
ASSERT (nm_ip4_config_get_wins (ip4_config, 1) == tmp.s_addr,
ASSERT (nm_ip4_config_get_wins (ip4_config, 1) == tmp,
"dhcp-wins", "unexpected WINS server #1");
g_hash_table_destroy (options);
@@ -259,18 +259,18 @@ ip4_test_route (const char *test,
guint expected_prefix)
{
NMPlatformIP4Route *route;
struct in_addr tmp;
guint32 tmp;
route = nm_ip4_config_get_route (ip4_config, route_num);
ASSERT (inet_pton (AF_INET, expected_dest, &tmp) > 0,
test, "couldn't convert expected route destination #1");
ASSERT (route->network == tmp.s_addr,
ASSERT (route->network == tmp,
test, "unexpected route %d destination", route_num + 1);
ASSERT (inet_pton (AF_INET, expected_gw, &tmp) > 0,
test, "couldn't convert expected route next hop %d",
route_num + 1);
ASSERT (route->gateway == tmp.s_addr,
ASSERT (route->gateway == tmp,
test, "unexpected route %d next hop", route_num + 1);
ASSERT (route->plen == expected_prefix,
@@ -284,13 +284,13 @@ ip4_test_gateway (const char *test,
NMIP4Config *ip4_config,
const char *expected_gw)
{
struct in_addr tmp;
guint32 tmp;
ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1,
test, "unexpected number of IP addresses");
ASSERT (inet_pton (AF_INET, expected_gw, &tmp) > 0,
test, "couldn't convert expected IP gateway");
ASSERT (nm_ip4_config_get_gateway (ip4_config) == tmp.s_addr,
ASSERT (nm_ip4_config_get_gateway (ip4_config) == tmp,
test, "unexpected IP gateway");
}

View File

@@ -517,16 +517,16 @@ static char addr_to_string_buf[INET6_ADDRSTRLEN + 1];
static const char *
ip_address_to_string (guint32 numeric)
{
struct in_addr temp_addr;
guint32 temp_addr;
memset (&addr_to_string_buf, '\0', sizeof (addr_to_string_buf));
temp_addr.s_addr = numeric;
temp_addr = numeric;
if (inet_ntop (AF_INET, &temp_addr, addr_to_string_buf, INET_ADDRSTRLEN)) {
return addr_to_string_buf;
} else {
nm_log_warn (LOGD_VPN, "error converting IP4 address 0x%X",
ntohl (temp_addr.s_addr));
ntohl (temp_addr));
return NULL;
}
}

View File

@@ -202,7 +202,7 @@ void print_array (DBusConnection *connection, int opt)
fprintf (stderr, "%d ('%s'): (%d %s of type %s) ", opt, name, num_items, num_items > 1 ? "elements" : "element", dbus_type_to_string (opt_type));
for (i = 0; i < num_items; i++)
{
struct in_addr in;
guint32 in;
gboolean last = (i == num_items - 1) ? TRUE : FALSE;
switch (opt_type)
@@ -214,10 +214,10 @@ void print_array (DBusConnection *connection, int opt)
fprintf (stderr, "%d%s", bool[i], last ? "" : ", ");
break;
case DBUS_TYPE_UINT32:
in.s_addr = uint32[i];
in = uint32[i];
if (!inet_ntop (AF_INET, &in, buf, INET_ADDRSTRLEN))
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (in.s_addr));
__func__, ntohl (in));
else
fprintf (stderr, "%u (%s)%s", uint32[i], buf, last ? "" : ", ");
break;