547
548
real_hw_is_up (NMDevice *device)
549
return nm_system_device_is_up (device);
550
return nm_system_iface_is_up (nm_device_get_ip_ifindex (device));
553
554
real_hw_bring_up (NMDevice *dev, gboolean *no_firmware)
555
return nm_system_device_set_up_down (dev, TRUE, no_firmware);
556
return nm_system_iface_set_up (nm_device_get_ip_ifindex (dev), TRUE, no_firmware);
559
560
real_hw_take_down (NMDevice *dev)
561
nm_system_device_set_up_down (dev, FALSE, NULL);
562
nm_system_iface_set_up (nm_device_get_ip_ifindex (dev), FALSE, NULL);
677
678
/* Can't change MAC address while device is up */
678
679
real_hw_take_down (dev);
680
success = nm_system_device_set_mac (iface, (struct ether_addr *) addr);
681
success = nm_system_iface_set_mac (nm_device_get_ip_ifindex (dev), (struct ether_addr *) addr);
682
683
/* MAC address succesfully changed; update the current MAC to match */
683
684
_update_hw_addr (self, addr);
1806
check_one_address (struct nl_object *object, void *user_data)
1808
AddrData *data = user_data;
1809
struct rtnl_addr *addr = (struct rtnl_addr *) object;
1810
struct nl_addr *local;
1813
if (rtnl_addr_get_ifindex (addr) != data->ifindex)
1815
if (rtnl_addr_get_family (addr) != AF_INET)
1818
if (nm_ip4_address_get_prefix (data->addr) != rtnl_addr_get_prefixlen (addr))
1821
local = rtnl_addr_get_local (addr);
1822
if (nl_addr_get_family (local) != AF_INET)
1824
if (nl_addr_get_len (local) != sizeof (struct in_addr))
1826
if (!nl_addr_get_binary_addr (local))
1829
memcpy (&tmp, nl_addr_get_binary_addr (local), nl_addr_get_len (local));
1830
if (tmp.s_addr != nm_ip4_address_get_address (data->addr))
1837
1800
static gboolean
1838
1801
ip4_match_config (NMDevice *self, NMConnection *connection)
1840
1803
NMSettingIP4Config *s_ip4;
1841
struct nl_handle *nlh = NULL;
1842
struct nl_cache *addr_cache = NULL;
1844
1805
GSList *leases, *iter;
1845
1806
NMDHCPManager *dhcp_mgr;
1846
1807
const char *method;
1848
AddrData check_data;
1850
ifindex = nm_device_get_ifindex (self);
1852
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
1809
s_ip4 = nm_connection_get_setting_ip4_config (connection);
1856
/* Read all the device's IP addresses */
1857
nlh = nm_netlink_get_default_handle ();
1861
addr_cache = rtnl_addr_alloc_cache (nlh);
1864
nl_cache_mngt_provide (addr_cache);
1866
1813
/* Get any saved leases that apply to this connection */
1867
1814
dhcp_mgr = nm_dhcp_manager_get ();
1868
1815
leases = nm_dhcp_manager_get_lease_config (dhcp_mgr,
1877
1824
/* Find at least one lease's address on the device */
1878
1825
for (iter = leases; iter; iter = g_slist_next (iter)) {
1879
NMIP4Config *addr = iter->data;
1881
memset (&check_data, 0, sizeof (check_data));
1882
check_data.ifindex = ifindex;
1883
check_data.found = FALSE;
1884
check_data.addr = nm_ip4_config_get_address (addr, 0);
1886
nl_cache_foreach (addr_cache, check_one_address, &check_data);
1887
if (check_data.found) {
1826
NMIP4Config *ip4_config = iter->data;
1827
NMIP4Address *addr = nm_ip4_config_get_address (ip4_config, 0);
1828
struct in_addr tmp = { .s_addr = nm_ip4_address_get_address (addr) };
1830
if (addr && nm_netlink_find_address (nm_device_get_ip_ifindex (self),
1833
nm_ip4_address_get_prefix (addr))) {
1888
1834
found = TRUE; /* Yay, device has same address as a lease */
1909
1855
/* Everything below for static addressing */
1911
/* Find all IP4 addresses of this connection in the device's address list */
1857
/* Find all IP4 addresses of this connection on the device */
1912
1858
num = nm_setting_ip4_config_get_num_addresses (s_ip4);
1913
1859
for (i = 0; i < num; i++) {
1914
memset (&check_data, 0, sizeof (check_data));
1915
check_data.ifindex = ifindex;
1916
check_data.found = FALSE;
1917
check_data.addr = nm_setting_ip4_config_get_address (s_ip4, i);
1860
NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
1861
struct in_addr tmp = { .s_addr = nm_ip4_address_get_address (addr) };
1919
nl_cache_foreach (addr_cache, check_one_address, &check_data);
1920
if (!check_data.found)
1863
if (!nm_netlink_find_address (nm_device_get_ip_ifindex (self),
1866
nm_ip4_address_get_prefix (addr)))