Commit 320a9d16 authored by Pavel Šimerda's avatar Pavel Šimerda Committed by Dan Williams

all: replace struct in_addr with guint32

parent 6762b2f7
......@@ -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);
......
......@@ -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);
......
......@@ -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:
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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;
}
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;