dispatcher: trivial code rearrangement
Reorganize some code in preparation for the GDBus port. (Most of the diff is actually just reindentation.) This also makes explicit something that was probably a bug; IP4_NUM_ROUTES is always set, even if it's "0" (while the same is not true of IP6_NUM_ROUTES). (This behavior is preserved for compatibility.)
This commit is contained in:
@@ -91,8 +91,8 @@ add_domains (GSList *items,
|
||||
static GSList *
|
||||
construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
|
||||
{
|
||||
GSList *addresses = NULL, *routes = NULL, *iter;
|
||||
GArray *dns = NULL, *wins = NULL;
|
||||
GSList *addresses, *routes, *iter;
|
||||
GArray *dns, *wins;
|
||||
guint32 num, i;
|
||||
GString *tmp;
|
||||
GValue *val;
|
||||
@@ -107,7 +107,7 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
|
||||
|
||||
/* IP addresses */
|
||||
val = g_hash_table_lookup (ip4_config, "addresses");
|
||||
if (val)
|
||||
if (val) {
|
||||
addresses = nm_utils_ip4_addresses_from_gvalue (val);
|
||||
|
||||
for (iter = addresses, num = 0; iter; iter = g_slist_next (iter)) {
|
||||
@@ -123,12 +123,12 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
|
||||
}
|
||||
if (num)
|
||||
items = g_slist_prepend (items, g_strdup_printf ("%sIP4_NUM_ADDRESSES=%d", prefix, num));
|
||||
if (addresses)
|
||||
g_slist_free_full (addresses, (GDestroyNotify) nm_ip4_address_unref);
|
||||
}
|
||||
|
||||
/* DNS servers */
|
||||
val = g_hash_table_lookup (ip4_config, "nameservers");
|
||||
if (val && G_VALUE_HOLDS (val, DBUS_TYPE_G_UINT_ARRAY))
|
||||
if (val && G_VALUE_HOLDS (val, DBUS_TYPE_G_UINT_ARRAY)) {
|
||||
dns = (GArray *) g_value_get_boxed (val);
|
||||
|
||||
if (dns && (dns->len > 0)) {
|
||||
@@ -148,13 +148,14 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
|
||||
items = g_slist_prepend (items, tmp->str);
|
||||
g_string_free (tmp, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search domains */
|
||||
items = add_domains (items, ip4_config, prefix, '4');
|
||||
|
||||
/* WINS servers */
|
||||
val = g_hash_table_lookup (ip4_config, "wins-servers");
|
||||
if (val && G_VALUE_HOLDS (val, DBUS_TYPE_G_UINT_ARRAY))
|
||||
if (val && G_VALUE_HOLDS (val, DBUS_TYPE_G_UINT_ARRAY)) {
|
||||
wins = (GArray *) g_value_get_boxed (val);
|
||||
|
||||
if (wins && wins->len) {
|
||||
@@ -174,10 +175,11 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
|
||||
items = g_slist_prepend (items, tmp->str);
|
||||
g_string_free (tmp, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Static routes */
|
||||
val = g_hash_table_lookup (ip4_config, "routes");
|
||||
if (val)
|
||||
if (val) {
|
||||
routes = nm_utils_ip4_routes_from_gvalue (val);
|
||||
|
||||
for (iter = routes, num = 0; iter; iter = g_slist_next (iter)) {
|
||||
@@ -193,8 +195,9 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
|
||||
items = g_slist_prepend (items, routetmp);
|
||||
}
|
||||
items = g_slist_prepend (items, g_strdup_printf ("%sIP4_NUM_ROUTES=%d", prefix, num));
|
||||
if (routes)
|
||||
g_slist_free_full (routes, (GDestroyNotify) nm_ip4_route_unref);
|
||||
} else
|
||||
items = g_slist_prepend (items, g_strdup_printf ("%sIP4_NUM_ROUTES=0", prefix));
|
||||
|
||||
return items;
|
||||
}
|
||||
@@ -223,7 +226,7 @@ construct_device_dhcp4_items (GSList *items, GHashTable *dhcp4_config)
|
||||
static GSList *
|
||||
construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix)
|
||||
{
|
||||
GSList *addresses = NULL, *routes = NULL, *dns = NULL, *iter;
|
||||
GSList *addresses, *routes, *dns, *iter;
|
||||
guint32 num;
|
||||
GString *tmp;
|
||||
GValue *val;
|
||||
@@ -238,7 +241,7 @@ construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix)
|
||||
|
||||
/* IP addresses */
|
||||
val = g_hash_table_lookup (ip6_config, "addresses");
|
||||
if (val)
|
||||
if (val) {
|
||||
addresses = nm_utils_ip6_addresses_from_gvalue (val);
|
||||
|
||||
for (iter = addresses, num = 0; iter; iter = g_slist_next (iter)) {
|
||||
@@ -254,12 +257,12 @@ construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix)
|
||||
}
|
||||
if (num)
|
||||
items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ADDRESSES=%d", prefix, num));
|
||||
if (addresses)
|
||||
g_slist_free_full (addresses, (GDestroyNotify) nm_ip6_address_unref);
|
||||
}
|
||||
|
||||
/* DNS servers */
|
||||
val = g_hash_table_lookup (ip6_config, "nameservers");
|
||||
if (val)
|
||||
if (val) {
|
||||
dns = nm_utils_ip6_dns_from_gvalue (val);
|
||||
|
||||
if (g_slist_length (dns)) {
|
||||
@@ -280,13 +283,14 @@ construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix)
|
||||
items = g_slist_prepend (items, tmp->str);
|
||||
g_string_free (tmp, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search domains */
|
||||
items = add_domains (items, ip6_config, prefix, '6');
|
||||
|
||||
/* Static routes */
|
||||
val = g_hash_table_lookup (ip6_config, "routes");
|
||||
if (val)
|
||||
if (val) {
|
||||
routes = nm_utils_ip6_routes_from_gvalue (val);
|
||||
|
||||
for (iter = routes, num = 0; iter; iter = g_slist_next (iter)) {
|
||||
@@ -303,8 +307,8 @@ construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix)
|
||||
}
|
||||
if (num)
|
||||
items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ROUTES=%d", prefix, num));
|
||||
if (routes)
|
||||
g_slist_free_full (routes, (GDestroyNotify) nm_ip6_route_unref);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
Reference in New Issue
Block a user