diff options
author | Dan Winship <danw@gnome.org> | 2014-07-07 12:04:14 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-08-07 12:11:49 -0400 |
commit | ea456aaa81f2290618421d28a824b85e02002fdf (patch) | |
tree | 9139087dc2ac31de6c44d6a21596daed3ff85fc1 /libnm | |
parent | 0dcba8a9a0b9d1dcfff90348bb433d2625489017 (diff) | |
download | NetworkManager-ea456aaa81f2290618421d28a824b85e02002fdf.tar.gz |
all: remove use of struct ether_addr / ether_aton()
Lots of old code used struct ether_addr to store hardware addresses,
and ether_aton() to parse them, but more recent code generally uses
guint8 arrays, and the nm_utils_hwaddr_* methods, to be able to share
code between ETH_ALEN and INFINIBAND_ALEN cases. So update the old
code to match the new. (In many places, this ends up getting rid of
casts between struct ether_addr and guint8* anyway.)
(Also, in some places, variables were switched from struct ether_addr
to guint8[] a while back, but some code still used "&" when referring
to them even though that's unnecessary now. Clean that up.)
Diffstat (limited to 'libnm')
-rw-r--r-- | libnm/nm-access-point.c | 11 | ||||
-rw-r--r-- | libnm/nm-device-bt.c | 8 | ||||
-rw-r--r-- | libnm/nm-device-ethernet.c | 8 | ||||
-rw-r--r-- | libnm/nm-device-wifi.c | 8 | ||||
-rw-r--r-- | libnm/nm-device-wimax.c | 8 |
5 files changed, 21 insertions, 22 deletions
diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 19d92d99dc..0e29bee29e 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -240,7 +240,7 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) const GByteArray *setting_ssid; const GByteArray *ap_ssid; const GByteArray *setting_bssid; - struct ether_addr *ap_bssid; + guint8 ap_bssid[ETH_ALEN]; const char *setting_mode; NM80211Mode ap_mode; const char *setting_band; @@ -271,12 +271,11 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) setting_bssid = nm_setting_wireless_get_bssid (s_wifi); if (setting_bssid && ap_bssid_str) { g_assert (setting_bssid->len == ETH_ALEN); - ap_bssid = ether_aton (ap_bssid_str); - g_warn_if_fail (ap_bssid); - if (ap_bssid) { - if (memcmp (ap_bssid->ether_addr_octet, setting_bssid->data, ETH_ALEN) != 0) + if (nm_utils_hwaddr_aton (ap_bssid_str, ap_bssid, ETH_ALEN)) { + if (memcmp (ap_bssid, setting_bssid->data, ETH_ALEN) != 0) return FALSE; - } + } else + g_warn_if_reached (); } /* Mode */ diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index 5daa015fc9..edda2e95ad 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -27,6 +27,7 @@ #include <nm-setting-connection.h> #include <nm-setting-bluetooth.h> +#include <nm-utils.h> #include "nm-device-bt.h" #include "nm-device-private.h" @@ -148,7 +149,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro const char *ctype; const GByteArray *mac; const char *hw_str; - struct ether_addr *hw_mac; + guint8 hw_mac[ETH_ALEN]; NMBluetoothCapabilities dev_caps; NMBluetoothCapabilities bt_type; @@ -172,14 +173,13 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro /* Check BT address */ hw_str = nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); if (hw_str) { - hw_mac = ether_aton (hw_str); - if (!hw_mac) { + if (!nm_utils_hwaddr_aton (hw_str, hw_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC, "Invalid device MAC address."); return FALSE; } mac = nm_setting_bluetooth_get_bdaddr (s_bt); - if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) { + if (mac && memcmp (mac->data, hw_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MAC_MISMATCH, "The MACs of the device and the connection didn't match."); return FALSE; diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index 8990062356..d2e2d0e1c6 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -28,6 +28,7 @@ #include <nm-setting-connection.h> #include <nm-setting-wired.h> #include <nm-setting-pppoe.h> +#include <nm-utils.h> #include "nm-device-ethernet.h" #include "nm-device-private.h" @@ -170,21 +171,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro if (s_wired) { const GByteArray *mac; const char *perm_str; - struct ether_addr *perm_mac; + guint8 perm_mac[ETH_ALEN]; /* FIXME: filter using s390 subchannels when they are exported over the bus */ /* Check MAC address */ perm_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device)); if (perm_str) { - perm_mac = ether_aton (perm_str); - if (!perm_mac) { + if (!nm_utils_hwaddr_aton (perm_str, perm_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC, "Invalid device MAC address."); return FALSE; } mac = nm_setting_wired_get_mac_address (s_wired); - if (mac && perm_mac && memcmp (mac->data, perm_mac->ether_addr_octet, ETH_ALEN)) { + if (mac && memcmp (mac->data, perm_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH, "The MACs of the device and the connection didn't match."); return FALSE; diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 7abab9aa61..81c9a3279d 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -28,6 +28,7 @@ #include <nm-setting-connection.h> #include <nm-setting-wireless.h> #include <nm-setting-wireless-security.h> +#include <nm-utils.h> #include "nm-device-wifi.h" #include "nm-device-private.h" @@ -420,7 +421,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro const char *ctype; const GByteArray *mac; const char *hw_str; - struct ether_addr *hw_mac; + guint8 hw_mac[ETH_ALEN]; NMDeviceWifiCapabilities wifi_caps; const char *key_mgmt; @@ -444,14 +445,13 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro /* Check MAC address */ hw_str = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device)); if (hw_str) { - hw_mac = ether_aton (hw_str); - if (!hw_mac) { + if (!nm_utils_hwaddr_aton (hw_str, hw_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC, "Invalid device MAC address."); return FALSE; } mac = nm_setting_wireless_get_mac_address (s_wifi); - if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) { + if (mac && memcmp (mac->data, hw_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MAC_MISMATCH, "The MACs of the device and the connection didn't match."); return FALSE; diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 1459365f7c..eb5d87fd68 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -27,6 +27,7 @@ #include <nm-setting-connection.h> #include <nm-setting-wimax.h> +#include <nm-utils.h> #include "nm-device-wimax.h" #include "nm-object-private.h" @@ -324,7 +325,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro const char *ctype; const GByteArray *mac; const char *hw_str; - struct ether_addr *hw_mac; + guint8 hw_mac[ETH_ALEN]; s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); @@ -346,14 +347,13 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro /* Check MAC address */ hw_str = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device)); if (hw_str) { - hw_mac = ether_aton (hw_str); - if (!hw_mac) { + if (!nm_utils_hwaddr_aton (hw_str, hw_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC, "Invalid device MAC address."); return FALSE; } mac = nm_setting_wimax_get_mac_address (s_wimax); - if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) { + if (mac && memcmp (mac->data, hw_mac, ETH_ALEN)) { g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH, "The MACs of the device and the connection didn't match."); return FALSE; |