Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 443596
Collapse All | Expand All

(-)NetworkManager-0.9.8.8/src/settings/plugins/ifnet/connection_parser.c (-8 / +53 lines)
Lines 516-524 Link Here
516
/* Reading mac address for setting connection option.
516
/* Reading mac address for setting connection option.
517
 * Unmanaged device mac address is required by NetworkManager*/
517
 * Unmanaged device mac address is required by NetworkManager*/
518
static gboolean
518
static gboolean
519
read_mac_address (const char *conn_name, GByteArray **array, GError **error)
519
read_mac_address (const char *conn_name, const char *key, GByteArray **array, GError **error)
520
{
520
{
521
	const char *value = ifnet_get_data (conn_name, "mac");
521
	const char *value = ifnet_get_data (conn_name, key);
522
523
	/* make sure it's NULL unless we find an address */
524
	*array = NULL;
522
525
523
	if (!value || !strlen (value))
526
	if (!value || !strlen (value))
524
		return TRUE;
527
		return TRUE;
Lines 526-532 Link Here
526
	*array = nm_utils_hwaddr_atoba (value, ARPHRD_ETHER);
529
	*array = nm_utils_hwaddr_atoba (value, ARPHRD_ETHER);
527
	if (!*array) {
530
	if (!*array) {
528
		g_set_error (error, ifnet_plugin_error_quark (), 0,
531
		g_set_error (error, ifnet_plugin_error_quark (), 0,
529
					 "The MAC address '%s' was invalid.", value);
532
					 "%s: The MAC address '%s' was invalid.", key, value);
530
		return FALSE;
533
		return FALSE;
531
	}
534
	}
532
535
Lines 560-566 Link Here
560
				      (guint32) mtu, NULL);
563
				      (guint32) mtu, NULL);
561
	}
564
	}
562
565
563
	if (read_mac_address (conn_name, &mac, error)) {
566
	/* cloned mac address is optional */
567
	if (read_mac_address (conn_name, "mac", &mac, error)) {
568
		if (mac) {
569
			g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS,
570
				      mac, NULL);
571
			g_byte_array_free (mac, TRUE);
572
		}
573
	}
574
575
	/* hardware mac address is required */
576
	if (read_mac_address (conn_name, "hwaddr", &mac, error)) {
564
		if (mac) {
577
		if (mac) {
565
			g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS,
578
			g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS,
566
				      mac, NULL);
579
				      mac, NULL);
Lines 938-950 Link Here
938
	}
951
	}
939
952
940
	wireless_setting = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
953
	wireless_setting = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
941
	if (read_mac_address (conn_name, &mac, error)) {
954
955
	/* cloned mac address is optional */
956
	if (read_mac_address (conn_name, "mac", &mac, error)) {
942
		if (mac) {
957
		if (mac) {
943
			g_object_set (wireless_setting,
958
			g_object_set (wireless_setting,
944
				      NM_SETTING_WIRELESS_MAC_ADDRESS, mac,
959
				      NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, mac,
945
				      NULL);
960
				      NULL);
946
			g_byte_array_free (mac, TRUE);
961
			g_byte_array_free (mac, TRUE);
962
		}
963
	}
947
964
965
	if (read_mac_address (conn_name, "hwaddr", &mac, error)) {
966
		if (mac) {
967
			g_object_set (wireless_setting,
968
				      NM_SETTING_WIRELESS_MAC_ADDRESS, mac,
969
				      NULL);
970
			g_byte_array_free (mac, TRUE);
948
		}
971
		}
949
	} else {
972
	} else {
950
		g_object_unref (wireless_setting);
973
		g_object_unref (wireless_setting);
Lines 2340-2346 Link Here
2340
	}
2363
	}
2341
2364
2342
	ifnet_set_data (ssid_str, "mac", NULL);
2365
	ifnet_set_data (ssid_str, "mac", NULL);
2343
	mac = nm_setting_wireless_get_mac_address (s_wireless);
2366
	mac = nm_setting_wireless_get_cloned_mac_address (s_wireless);
2344
	if (mac) {
2367
	if (mac) {
2345
		tmp = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
2368
		tmp = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
2346
				       mac->data[0], mac->data[1], mac->data[2],
2369
				       mac->data[0], mac->data[1], mac->data[2],
Lines 2350-2355 Link Here
2350
		g_free (tmp);
2373
		g_free (tmp);
2351
	}
2374
	}
2352
2375
2376
	ifnet_set_data (ssid_str, "hwaddr", NULL);
2377
	mac = nm_setting_wireless_get_mac_address (s_wireless);
2378
	if (mac) {
2379
		tmp = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
2380
				       mac->data[0], mac->data[1], mac->data[2],
2381
				       mac->data[3], mac->data[4],
2382
				       mac->data[5]);
2383
		ifnet_set_data (ssid_str, "hwaddr", tmp);
2384
		g_free (tmp);
2385
	}
2386
2353
	ifnet_set_data (ssid_str, "mtu", NULL);
2387
	ifnet_set_data (ssid_str, "mtu", NULL);
2354
	mtu = nm_setting_wireless_get_mtu (s_wireless);
2388
	mtu = nm_setting_wireless_get_mtu (s_wireless);
2355
	if (mtu) {
2389
	if (mtu) {
Lines 2415-2421 Link Here
2415
	}
2449
	}
2416
2450
2417
	ifnet_set_data (conn_name, "mac", NULL);
2451
	ifnet_set_data (conn_name, "mac", NULL);
2418
	mac = nm_setting_wired_get_mac_address (s_wired);
2452
	mac = nm_setting_wired_get_cloned_mac_address (s_wired);
2419
	if (mac) {
2453
	if (mac) {
2420
		tmp = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
2454
		tmp = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
2421
				       mac->data[0], mac->data[1], mac->data[2],
2455
				       mac->data[0], mac->data[1], mac->data[2],
Lines 2425-2430 Link Here
2425
		g_free (tmp);
2459
		g_free (tmp);
2426
	}
2460
	}
2427
2461
2462
	ifnet_set_data (conn_name, "hwaddr", NULL);
2463
	mac = nm_setting_wired_get_mac_address (s_wired);
2464
	if (mac) {
2465
		tmp = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
2466
				       mac->data[0], mac->data[1], mac->data[2],
2467
				       mac->data[3], mac->data[4],
2468
				       mac->data[5]);
2469
		ifnet_set_data (conn_name, "hwaddr", tmp);
2470
		g_free (tmp);
2471
	}
2472
2428
	ifnet_set_data (conn_name, "mtu", NULL);
2473
	ifnet_set_data (conn_name, "mtu", NULL);
2429
	mtu = nm_setting_wired_get_mtu (s_wired);
2474
	mtu = nm_setting_wired_get_mtu (s_wired);
2430
	if (mtu) {
2475
	if (mtu) {

Return to bug 443596