static char *
get_new_connection_ifname (NMPlatform *platform,
                           const GSList *existing,
                           const char *prefix)
{
	int i;
	char *name;
	const GSList *iter;
	gboolean found;

	for (i = 0; i < 500; i++) {
		name = g_strdup_printf ("%s%d", prefix, i);

		if (nm_platform_link_get_by_ifname (platform, name))
			goto next;

		for (iter = existing, found = FALSE; iter; iter = g_slist_next (iter)) {
			NMConnection *candidate = iter->data;

			if (g_strcmp0 (nm_connection_get_interface_name (candidate), name) == 0) {
				found = TRUE;
				break;
			}
		}

		if (!found)
			return name;

	next:
		g_free (name);
	}

	return NULL;
}
예제 #2
0
static gboolean
do_link_exists (char **argv)
{
	gboolean value = !!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, argv[0]);

	print_boolean (value);

	return TRUE;
}