diff options
author | Michael Biebl <biebl@debian.org> | 2015-08-28 01:13:48 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2015-08-28 01:13:48 +0200 |
commit | 81836c2d44802b4cca833d7775dd627e0797a7e2 (patch) | |
tree | 91154e6cefc0465306603f51ec0010d9963bbea4 | |
parent | 50a58f0fabd8a34c1b6108a107e08abe3c1ccd24 (diff) |
Imported Upstream version 1.0.6upstream/1.0.6upstream
181 files changed, 5479 insertions, 1200 deletions
diff --git a/Makefile.in b/Makefile.in index e409d1c71..58cc69bfe 100644 --- a/Makefile.in +++ b/Makefile.in @@ -222,7 +222,7 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/NetworkManager.pc.in \ $(top_srcdir)/initscript/linexa/networkmanager.in ABOUT-NLS \ AUTHORS COPYING ChangeLog INSTALL NEWS README TODO \ build-aux/compile build-aux/config.guess \ - build-aux/config.rpath build-aux/config.sub \ + build-aux/config.rpath build-aux/config.sub build-aux/depcomp \ build-aux/install-sh build-aux/ltmain.sh build-aux/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) @@ -1,4 +1,28 @@ =============================================== +NetworkManager-1.0.6 +Overview of changes since NetworkManager-1.0.4 +=============================================== + +This is a new stable release of NetworkManager. Notable changes include: + +* Improved capture portal detection. + +* Default route through WiFi connection is now preferred to Mobile + Broadband if both are available. + +* Expose a flag to determine whether a particular connection is metered + via API and client tools. + +* Add support for locking connections to a channel within a particular + band. + +* Add support for configuring Wake-on-LAN capabilitites. + +* Allow overriding the MTU for team device. + +* Usual pile of bug fixes and robustness improvements. + +=============================================== NetworkManager-1.0.4 Overview of changes since NetworkManager-1.0.2 =============================================== diff --git a/clients/cli/common.c b/clients/cli/common.c index 97d0bb940..35676d0f2 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -522,6 +522,23 @@ nmc_device_state_to_string (NMDeviceState state) } const char * +nmc_device_metered_to_string (NMMetered value) +{ + switch (value) { + case NM_METERED_YES: + return _("yes"); + case NM_METERED_NO: + return _("no"); + case NM_METERED_GUESS_YES: + return _("yes (guessed)"); + case NM_METERED_GUESS_NO: + return _("no (guessed)"); + default: + return _("unknown"); + } +} + +const char * nmc_device_reason_to_string (NMDeviceStateReason reason) { switch (reason) { diff --git a/clients/cli/common.h b/clients/cli/common.h index 8bb043f4d..bb3f44e85 100644 --- a/clients/cli/common.h +++ b/clients/cli/common.h @@ -35,6 +35,7 @@ NMIPRoute *nmc_parse_and_build_route (int family, const char *first, const char const char * nmc_device_state_to_string (NMDeviceState state); const char * nmc_device_reason_to_string (NMDeviceStateReason reason); +const char * nmc_device_metered_to_string (NMMetered value); char ** nmc_vlan_parse_priority_maps (const char *priority_map, diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 979c59063..c9ff8970f 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -78,11 +78,12 @@ static NmcOutputField nmc_fields_dev_show_general[] = { {"CONNECTION", N_("CONNECTION"), 20}, /* 20 */ {"CON-UUID", N_("CON-UUID"), 38}, /* 21 */ {"CON-PATH", N_("CON-PATH"), 51}, /* 22 */ + {"METERED", N_("METERED"), 10}, /* 23 */ {NULL, NULL, 0} }; #define NMC_FIELDS_DEV_SHOW_GENERAL_ALL "NAME,DEVICE,TYPE,NM-TYPE,VENDOR,PRODUCT,DRIVER,DRIVER-VERSION,FIRMWARE-VERSION,HWADDR,MTU,"\ "STATE,REASON,UDI,IP-IFACE,IS-SOFTWARE,NM-MANAGED,AUTOCONNECT,FIRMWARE-MISSING,PHYS-PORT-ID,"\ - "CONNECTION,CON-UUID,CON-PATH" + "CONNECTION,CON-UUID,CON-PATH,METERED" #define NMC_FIELDS_DEV_SHOW_GENERAL_COMMON "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,HWADDR,STATE" /* Available fields for 'device show' - CONNECTIONS part */ @@ -275,8 +276,8 @@ usage (void) " delete <ifname> ...\n\n" " wifi [list [ifname <ifname>] [bssid <BSSID>]]\n\n" " wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n" - " [bssid <BSSID>] [name <name>] [private yes|no]\n\n" - " wifi rescan [[ifname] <ifname>]\n\n" + " [bssid <BSSID>] [name <name>] [private yes|no] [hidden yes|no]\n\n" + " wifi rescan [ifname <ifname>] [[ssid <SSID to scan>] ...]\n\n" #if WITH_WIMAX " wimax [list [ifname <ifname>] [nsp <name>]]\n\n" #endif @@ -359,7 +360,7 @@ usage_device_wifi (void) "used to list APs for a particular interface, or with a specific BSSID.\n" "\n" "ARGUMENTS := connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n" - " [bssid <BSSID>] [name <name>] [private yes|no]\n" + " [bssid <BSSID>] [name <name>] [private yes|no] [hidden yes|no]\n" "\n" "Connect to a Wi-Fi network specified by SSID or BSSID. The command creates\n" "a new connection and then activates it on a device. This is a command-line\n" @@ -370,12 +371,14 @@ usage_device_wifi (void) "only open, WEP and WPA-PSK networks are supported at the moment. It is also\n" "assumed that IP configuration is obtained via DHCP.\n" "\n" - "ARGUMENTS := rescan [[ifname] <ifname>]\n" + "ARGUMENTS := rescan [ifname <ifname>] [[ssid <SSID to scan>] ...]\n" "\n" "Request that NetworkManager immediately re-scan for available access points.\n" "NetworkManager scans Wi-Fi networks periodically, but in some cases it might\n" - "be useful to start scanning manually. Note that this command does not show\n" - "the APs, use 'nmcli device wifi list' for that.\n\n")); + "be useful to start scanning manually. 'ssid' allows scanning for a specific\n" + "SSID, which is useful for APs with hidden SSIDs. More 'ssid' parameters can be\n" + "given. Note that this command does not show the APs,\n" + "use 'nmcli device wifi list' for that.\n\n")); } #if WITH_WIMAX @@ -858,6 +861,8 @@ show_device_info (NMDevice *device, NmCli *nmc) set_val_strc (arr, 20, get_active_connection_id (device)); set_val_strc (arr, 21, acon ? nm_active_connection_get_uuid (acon) : NULL); set_val_strc (arr, 22, acon ? nm_object_get_path (NM_OBJECT (acon)) : NULL); + set_val_strc (arr, 23, nmc_device_metered_to_string (nm_device_get_metered (device))); + g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -2300,9 +2305,9 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) { NMDevice *device = NULL; NMAccessPoint *ap = NULL; - NM80211ApFlags ap_flags; - NM80211ApSecurityFlags ap_wpa_flags; - NM80211ApSecurityFlags ap_rsn_flags; + NM80211ApFlags ap_flags = NM_802_11_AP_FLAGS_NONE; + NM80211ApSecurityFlags ap_wpa_flags = NM_802_11_AP_SEC_NONE; + NM80211ApSecurityFlags ap_rsn_flags = NM_802_11_AP_SEC_NONE; NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; @@ -2314,6 +2319,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) const char *password = NULL; const char *con_name = NULL; gboolean private = FALSE; + gboolean hidden = FALSE; gboolean wep_passphrase = FALSE; GByteArray *bssid1_arr = NULL; GByteArray *bssid2_arr = NULL; @@ -2413,6 +2419,19 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) g_clear_error (&err_tmp); goto error; } + } else if (strcmp (*argv, "hidden") == 0) { + GError *err_tmp = NULL; + if (next_arg (&argc, &argv) != 0) { + g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1)); + nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; + goto error; + } + if (!nmc_string_to_bool (*argv, &hidden, &err_tmp)) { + g_string_printf (nmc->return_text, _("Error: %s: %s."), *(argv-1), err_tmp->message); + nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; + g_clear_error (&err_tmp); + goto error; + } } else { g_printerr (_("Unknown parameter: %s\n"), *argv); } @@ -2449,14 +2468,41 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) goto error; } + /* For hidden SSID first scan it so that NM learns about the AP */ + if (hidden) { + GVariantBuilder builder, array_builder; + GVariant *options; + GError *scan_err = NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aay")); + g_variant_builder_add (&array_builder, "@ay", + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, param_user, strlen (param_user), 1)); + g_variant_builder_add (&builder, "{sv}", "ssids", g_variant_builder_end (&array_builder)); + options = g_variant_builder_end (&builder); + + nm_device_wifi_request_scan_options (NM_DEVICE_WIFI (device), options, NULL, &scan_err); + if (scan_err) { + g_string_printf (nmc->return_text, _("Error: Failed to scan hidden SSID: %s."), + scan_err->message); + g_clear_error (&scan_err); + nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND; + goto error; + } + } + /* Find an AP to connect to */ ap = find_ap_on_device (device, bssid1_arr, bssid1_arr ? NULL : param_user); if (!ap && !ifname) { - /* AP not found. ifname was not specified, so try finding the AP on another device. */ - while ((device = find_wifi_device_by_iface (devices, NULL, &devices_idx)) != NULL) { - ap = find_ap_on_device (device, bssid1_arr, bssid1_arr ? NULL : param_user); - if (ap) + NMDevice *dev; + + /* AP not found, ifname was not specified, so try finding the AP on another device. */ + while ((dev = find_wifi_device_by_iface (devices, NULL, &devices_idx)) != NULL) { + ap = find_ap_on_device (dev, bssid1_arr, bssid1_arr ? NULL : param_user); + if (ap) { + device = dev; break; + } } } @@ -2471,7 +2517,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) /* If there are some connection data from user, create a connection and * fill them into proper settings. */ - if (con_name || private || bssid2_arr || password) + if (con_name || private || bssid2_arr || password || hidden) connection = nm_simple_connection_new (); if (con_name || private) { @@ -2486,12 +2532,24 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) if (private) nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL); } - if (bssid2_arr) { + if (bssid2_arr || hidden) { s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - /* 'bssid' parameter is used to restrict the conenction only to the BSSID */ - g_object_set (s_wifi, NM_SETTING_WIRELESS_BSSID, bssid2_arr, NULL); + /* 'bssid' parameter is used to restrict the connection only to the BSSID */ + if (bssid2_arr) + g_object_set (s_wifi, NM_SETTING_WIRELESS_BSSID, bssid2_arr, NULL); + + /* 'hidden' parameter is used to indicate that SSID is not broadcasted */ + if (hidden) { + GBytes *ssid = g_bytes_new (param_user, strlen (param_user)); + + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_HIDDEN, hidden, + NULL); + g_bytes_unref (ssid); + } } /* handle password */ @@ -2582,21 +2640,44 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv) { NMDevice *device; const char *ifname = NULL; + GPtrArray *ssids; const GPtrArray *devices; int devices_idx; + GVariantBuilder builder, array_builder; + GVariant *options; + const char *ssid; + int i; nmc->should_wait = TRUE; + ssids = g_ptr_array_new (); + /* Get the parameters */ - if (argc > 0) { + while (argc > 0) { if (strcmp (*argv, "ifname") == 0) { + if (ifname) { + g_string_printf (nmc->return_text, _("Error: '%s' cannot repeat."), *(argv-1)); + nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; + goto error; + } if (next_arg (&argc, &argv) != 0) { g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1)); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; goto error; } - } - ifname = *argv; + ifname = *argv; + } else if (strcmp (*argv, "ssid") == 0) { + if (next_arg (&argc, &argv) != 0) { + g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1)); + nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; + goto error; + } + g_ptr_array_add (ssids, *argv); + } else + g_printerr (_("Unknown parameter: %s\n"), *argv); + + argc--; + argv++; } /* Find Wi-Fi device to scan on. When no ifname is provided, the first Wi-Fi is used. */ @@ -2605,26 +2686,39 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv) device = find_wifi_device_by_iface (devices, ifname, &devices_idx); if (!device) { - if (ifname) { - const char *err_msg; - if ( nm_device_get_device_type (device) == NM_DEVICE_TYPE_GENERIC - && g_strcmp0 (nm_device_get_type_description (device), "wifi") == 0) - err_msg = _("Error: Device '%s' was not recognized as a Wi-Fi device, check NetworkManager Wi-Fi plugin."); - else - err_msg = _("Error: Device '%s' is not a Wi-Fi device."); - g_string_printf (nmc->return_text, err_msg, ifname); - } else + if (ifname) + g_string_printf (nmc->return_text, _("Error: Device '%s' is not a Wi-Fi device."), ifname); + else g_string_printf (nmc->return_text, _("Error: No Wi-Fi device found.")); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; goto error; } - nm_device_wifi_request_scan_async (NM_DEVICE_WIFI (device), NULL, - request_rescan_cb, nmc); + if (ssids->len) { + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aay")); + + for (i = 0; i < ssids->len; i++) { + ssid = g_ptr_array_index (ssids, i); + g_variant_builder_add (&array_builder, "@ay", + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, ssid, strlen (ssid), 1)); + } + + g_variant_builder_add (&builder, "{sv}", "ssids", g_variant_builder_end (&array_builder)); + options = g_variant_builder_end (&builder); + + nm_device_wifi_request_scan_options_async (NM_DEVICE_WIFI (device), options, + NULL, request_rescan_cb, nmc); + } else + nm_device_wifi_request_scan_async (NM_DEVICE_WIFI (device), + NULL, request_rescan_cb, nmc); + + g_ptr_array_free (ssids, FALSE); return nmc->return_value; error: nmc->should_wait = FALSE; + g_ptr_array_free (ssids, FALSE); return nmc->return_value; } diff --git a/clients/cli/nmcli-completion b/clients/cli/nmcli-completion index 38d7e5857..4146eae09 100644 --- a/clients/cli/nmcli-completion +++ b/clients/cli/nmcli-completion @@ -455,6 +455,7 @@ _nmcli_compl_ARGS() stp| \ hairpin| \ save| \ + hidden| \ private) if [[ "${#words[@]}" -eq 2 ]]; then _nmcli_list "yes no" @@ -539,7 +540,9 @@ _nmcli_compl_ARGS() # remove the options already seen. for i in ${!OPTIONS[*]}; do if [[ "${OPTIONS[$i]}" = "${REMOVE_OPTIONS[0]}" || "${OPTIONS[$i]}" = "${REMOVE_OPTIONS[1]}" ]]; then - unset OPTIONS[$i] + if ! _nmcli_array_has_value OPTIONS_REPEATABLE "${OPTIONS[$i]}" ; then + unset OPTIONS[$i] + fi fi done for i in ${!OPTIONS_MANDATORY[*]}; do @@ -678,7 +681,7 @@ _nmcli() cur='' fi - local OPTIONS_UNKNOWN_OPTION OPTIONS_TYPE OPTIONS_TYPED OPTIONS OPTIONS_MANDATORY COMMAND_ARGS_WAIT_OPTIONS OPTIONS_IP OPTIONS_MANDATORY OPTIONS_NEXT_GROUP + local OPTIONS_UNKNOWN_OPTION OPTIONS_TYPE OPTIONS_TYPED OPTIONS OPTIONS_MANDATORY COMMAND_ARGS_WAIT_OPTIONS OPTIONS_IP OPTIONS_MANDATORY OPTIONS_NEXT_GROUP OPTIONS_REPEATABLE local COMMAND_CONNECTION_TYPE COMMAND_CONNECTION_ID OPTIONS_MANDATORY_IFNAME HELP_ONLY_AS_FIRST local COMMAND_CONNECTION_ACTIVE="" @@ -1248,13 +1251,14 @@ _nmcli() fi else _nmcli_array_delete_at words 0 3 - local OPTIONS=(password wep-key-type ifname bssid name private) + local OPTIONS=(password wep-key-type ifname bssid name private hidden) _nmcli_compl_ARGS fi ;; r|re|res|resc|resca|rescan) _nmcli_array_delete_at words 0 2 - OPTIONS=(ifname) + OPTIONS_REPEATABLE=(ssid) + OPTIONS=(ifname ssid) _nmcli_compl_ARGS ;; esac diff --git a/clients/cli/settings-docs.c b/clients/cli/settings-docs.c index 2ed41cb86..d48d4b087 100644 --- a/clients/cli/settings-docs.c +++ b/clients/cli/settings-docs.c @@ -99,6 +99,8 @@ NmcPropertyDesc setting_802_3_ethernet[] = { { "s390-options", "Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include \"portno\", \"layer2\", \"portname\", \"protocol\", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9])." }, { "s390-subchannels", "Identifies specific subchannels that this network device uses for communication with z/VM or s390 host. Like the \"mac-address\" property for non-z/VM devices, this property can be used to ensure this connection only applies to the network device that uses these subchannels. The list should contain exactly 3 strings, and each string may only be composed of hexadecimal characters and the period (.) character." }, { "speed", "If non-zero, request that the device use only the specified speed. In Mbit/s, ie 100 == 100Mbit/s." }, + { "wake-on-lan", "The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40)." }, + { "wake-on-lan-password", "If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required." }, }; NmcPropertyDesc setting_adsl[] = { @@ -157,6 +159,7 @@ NmcPropertyDesc setting_connection[] = { { "id", "A human readable unique identifier for the connection, like \"Work Wi-Fi\" or \"T-Mobile 3G\"." }, { "interface-name", "The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface." }, { "master", "Interface name of the master device or UUID of the master connection." }, + { "metered", "Whether the connection is metered." }, { "name", "The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\"." }, { "permissions", "An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection. Otherwise a user is allowed to access this connection if and only if they are in this list. Each entry is of the form \"[type]:[id]:[reserved]\"; for example, \"user:dcbw:blah\". At this time only the \"user\" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the \":\" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8." }, { "read-only", "FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified." }, @@ -335,14 +338,14 @@ NmcSettingDesc all_settings[] = { { "802-11-wireless", setting_802_11_wireless, 14 }, { "802-11-wireless-security", setting_802_11_wireless_security, 18 }, { "802-1x", setting_802_1x, 33 }, - { "802-3-ethernet", setting_802_3_ethernet, 12 }, + { "802-3-ethernet", setting_802_3_ethernet, 14 }, { "adsl", setting_adsl, 8 }, { "bluetooth", setting_bluetooth, 3 }, { "bond", setting_bond, 2 }, { "bridge", setting_bridge, 8 }, { "bridge-port", setting_bridge_port, 4 }, { "cdma", setting_cdma, 5 }, - { "connection", setting_connection, 16 }, + { "connection", setting_connection, 17 }, { "dcb", setting_dcb, 16 }, { "generic", setting_generic, 1 }, { "gsm", setting_gsm, 10 }, diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 66e6f6224..8c4af22d4 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -30,6 +30,7 @@ #include "settings.h" #include "nm-glib-compat.h" #include "nm-macros-internal.h" +#include "gsystem-local-alloc.h" /* Forward declarations */ static char *wep_key_type_to_string (NMWepKeyType type); @@ -60,6 +61,7 @@ NmcOutputField nmc_fields_setting_connection[] = { SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, 13), /* 13 */ SETTING_FIELD (NM_SETTING_CONNECTION_SECONDARIES, 40), /* 14 */ SETTING_FIELD (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, 30), /* 15 */ + SETTING_FIELD (NM_SETTING_CONNECTION_METERED, 10), /* 16 */ {NULL, NULL, 0, NULL, FALSE, FALSE, 0} }; #define NMC_FIELDS_SETTING_CONNECTION_ALL "name"","\ @@ -77,7 +79,8 @@ NmcOutputField nmc_fields_setting_connection[] = { NM_SETTING_CONNECTION_SLAVE_TYPE","\ NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES","\ NM_SETTING_CONNECTION_SECONDARIES","\ - NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT + NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT","\ + NM_SETTING_CONNECTION_METERED #define NMC_FIELDS_SETTING_CONNECTION_COMMON NMC_FIELDS_SETTING_CONNECTION_ALL /* Available fields for NM_SETTING_WIRED_SETTING_NAME */ @@ -94,6 +97,8 @@ NmcOutputField nmc_fields_setting_wired[] = { SETTING_FIELD (NM_SETTING_WIRED_S390_SUBCHANNELS, 20), /* 9 */ SETTING_FIELD (NM_SETTING_WIRED_S390_NETTYPE, 15), /* 10 */ SETTING_FIELD (NM_SETTING_WIRED_S390_OPTIONS, 20), /* 11 */ + SETTING_FIELD (NM_SETTING_WIRED_WAKE_ON_LAN, 10), /* 12 */ + SETTING_FIELD (NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, 20), /* 13 */ {NULL, NULL, 0, NULL, FALSE, FALSE, 0} }; #define NMC_FIELDS_SETTING_WIRED_ALL "name"","\ @@ -107,7 +112,9 @@ NmcOutputField nmc_fields_setting_wired[] = { NM_SETTING_WIRED_MTU","\ NM_SETTING_WIRED_S390_SUBCHANNELS","\ NM_SETTING_WIRED_S390_NETTYPE","\ - NM_SETTING_WIRED_S390_OPTIONS + NM_SETTING_WIRED_S390_OPTIONS","\ + NM_SETTING_WIRED_WAKE_ON_LAN","\ + NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD #define NMC_FIELDS_SETTING_WIRED_COMMON NMC_FIELDS_SETTING_WIRED_ALL /* Available fields for NM_SETTING_802_1X_SETTING_NAME */ @@ -1497,6 +1504,7 @@ DEFINE_GETTER (nmc_property_wired_get_mac_address_blacklist, NM_SETTING_WIRED_MA DEFINE_GETTER (nmc_property_wired_get_s390_subchannels, NM_SETTING_WIRED_S390_SUBCHANNELS) DEFINE_GETTER (nmc_property_wired_get_s390_nettype, NM_SETTING_WIRED_S390_NETTYPE) DEFINE_GETTER (nmc_property_wired_get_s390_options, NM_SETTING_WIRED_S390_OPTIONS) +DEFINE_GETTER (nmc_property_wired_get_wake_on_lan_password, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD) static char * nmc_property_wired_get_mtu (NMSetting *setting, NmcPropertyGetType get_type) @@ -1511,6 +1519,45 @@ nmc_property_wired_get_mtu (NMSetting *setting, NmcPropertyGetType get_type) return g_strdup_printf ("%d", mtu); } +static char * +nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type) +{ + NMSettingWired *s_wired = NM_SETTING_WIRED (setting); + NMSettingWiredWakeOnLan wol; + + wol = nm_setting_wired_get_wake_on_lan (s_wired); + return nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (), wol); +} + +static gboolean +nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop, + const char *val, GError **error) +{ + NMSettingWiredWakeOnLan wol; + gs_free char *err_token = NULL; + gboolean ret; + + ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), val, + (int *) &wol, &err_token); + + if (!ret) { + g_set_error (error, 1, 0, _("invalid option '%s', use a combination of %s or 'default'"), + err_token, + nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (), + NM_SETTING_WIRED_WAKE_ON_LAN_ALL)); + return FALSE; + } + + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) && + NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ALL)) { + g_set_error_literal (error, 1, 0, _("'default' is incompatible with other flags")); + return FALSE; + } + + g_object_set (setting, prop, (guint) wol, NULL); + return TRUE; +} + /* --- NM_SETTING_WIRELESS_SETTING_NAME property get functions --- */ DEFINE_GETTER (nmc_property_wireless_get_mode, NM_SETTING_WIRELESS_MODE) DEFINE_GETTER (nmc_property_wireless_get_band, NM_SETTING_WIRELESS_BAND) @@ -2034,6 +2081,46 @@ validate_uint (NMSetting *setting, const char* prop, guint val, GError **error) return success; } +static char * +flag_values_to_string (GFlagsValue *array, guint n) +{ + GString *str; + guint i; + + str = g_string_new (NULL); + for (i = 0; i < n; i++) + g_string_append_printf (str, "%u, ", array[i].value); + if (str->len) + g_string_truncate (str, str->len-2); /* chop off trailing ', ' */ + return g_string_free (str, FALSE); +} + +static gboolean +validate_flags (NMSetting *setting, const char* prop, guint val, GError **error) +{ + GParamSpec *pspec; + GValue value = G_VALUE_INIT; + gboolean success = TRUE; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop); + g_assert (G_IS_PARAM_SPEC (pspec)); + + g_value_init (&value, pspec->value_type); + g_value_set_flags (&value, val); + + if (g_param_value_validate (pspec, &value)) { + GParamSpecFlags *pspec_flags = (GParamSpecFlags *) pspec; + char *flag_values = flag_values_to_string (pspec_flags->flags_class->values, + pspec_flags->flags_class->n_values); + g_set_error (error, 1, 0, _("'%u' flags are not valid; use combination of %s"), + val, flag_values); + g_free (flag_values); + success = FALSE; + } + g_value_unset (&value); + return success; +} + static gboolean check_and_set_string (NMSetting *setting, const char *prop, @@ -2257,6 +2344,26 @@ nmc_property_set_int64 (NMSetting *setting, const char *prop, const char *val, G } static gboolean +nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error) +{ + unsigned long val_int; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val); + return FALSE; + } + + /* Validate the flags according to the property spec */ + if (!validate_flags (setting, prop, (guint) val_int, error)) + return FALSE; + + g_object_set (setting, prop, (guint) val_int, NULL); + return TRUE; +} + +static gboolean nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error) { gboolean val_bool; @@ -2684,6 +2791,62 @@ nmc_property_connection_describe_secondaries (NMSetting *setting, const char *pr "Example: private-openvpn, fe6ba5d8-c2fc-4aae-b2e3-97efddd8d9a7\n"); } +/* 'metered' */ +static char * +nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_type) +{ + NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting); + + if (get_type == NMC_PROPERTY_GET_PARSABLE) { + switch (nm_setting_connection_get_metered (s_conn)) { + case NM_METERED_YES: + return g_strdup ("yes"); + case NM_METERED_NO: + return g_strdup ("no"); + case NM_METERED_UNKNOWN: + default: + return g_strdup ("unknown"); + } + } + switch (nm_setting_connection_get_metered (s_conn)) { + case NM_METERED_YES: + return g_strdup (_("yes")); + case NM_METERED_NO: + return g_strdup (_("no")); + case NM_METERED_UNKNOWN: + default: + return g_strdup (_("unknown")); + } +} + +static gboolean +nmc_property_connection_set_metered (NMSetting *setting, const char *prop, + const char *val, GError **error) +{ + NMMetered metered; + NMCTriStateValue ts_val; + + if (!nmc_string_to_tristate (val, &ts_val, error)) + return FALSE; + + switch (ts_val) { + case NMC_TRI_STATE_YES: + metered = NM_METERED_YES; + break; + case NMC_TRI_STATE_NO: + metered = NM_METERED_NO; + break; + case NMC_TRI_STATE_UNKNOWN: + metered = NM_METERED_UNKNOWN; + break; + default: + g_assert_not_reached(); + } + + g_object_set (setting, prop, metered, NULL); + return TRUE; +} + /* --- NM_SETTING_802_1X_SETTING_NAME property setter functions --- */ #define DEFINE_SETTER_STR_LIST(def_func, set_func) \ static gboolean \ @@ -4495,8 +4658,8 @@ nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *va g_strfreev (strv); } - /* Validate the number according to the property spec */ - if (!validate_uint (setting, prop, (guint) flags, error)) + /* Validate the flags according to the property spec */ + if (!validate_flags (setting, prop, (guint) flags, error)) return FALSE; g_object_set (setting, prop, (guint) flags, NULL); @@ -5264,6 +5427,13 @@ nmc_properties_init (void) NULL, NULL, NULL); + nmc_add_prop_funcs (GLUE (CONNECTION, METERED), + nmc_property_connection_get_metered, + nmc_property_connection_set_metered, + NULL, + NULL, + NULL, + NULL); /* Add editable properties for NM_SETTING_DCB_SETTING_NAME */ nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_FLAGS), @@ -5927,7 +6097,7 @@ nmc_properties_init (void) NULL); nmc_add_prop_funcs (GLUE (VLAN, FLAGS), nmc_property_vlan_get_flags, - nmc_property_set_uint, + nmc_property_set_flags, NULL, NULL, NULL, @@ -6078,6 +6248,20 @@ nmc_properties_init (void) nmc_property_wired_describe_s390_options, nmc_property_wired_allowed_s390_options, NULL); + nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN), + nmc_property_wired_get_wake_on_lan, + nmc_property_wired_set_wake_on_lan, + NULL, + NULL, + NULL, + NULL); + nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN_PASSWORD), + nmc_property_wired_get_wake_on_lan_password, + nmc_property_set_mac, + NULL, + NULL, + NULL, + NULL); /* Add editable properties for NM_SETTING_WIRELESS_SETTING_NAME */ nmc_add_prop_funcs (GLUE (WIRELESS, SSID), @@ -6624,6 +6808,7 @@ setting_connection_details (NMSetting *setting, NmCli *nmc, const char *one_pro set_val_str (arr, 13, nmc_property_connection_get_autoconnect_slaves (setting, NMC_PROPERTY_GET_PRETTY)); set_val_str (arr, 14, nmc_property_connection_get_secondaries (setting, NMC_PROPERTY_GET_PRETTY)); set_val_str (arr, 15, nmc_property_connection_get_gateway_ping_timeout (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_connection_get_metered (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -6660,6 +6845,8 @@ setting_wired_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gb set_val_str (arr, 9, nmc_property_wired_get_s390_subchannels (setting, NMC_PROPERTY_GET_PRETTY)); set_val_str (arr, 10, nmc_property_wired_get_s390_nettype (setting, NMC_PROPERTY_GET_PRETTY)); set_val_str (arr, 11, nmc_property_wired_get_s390_options (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_wired_get_wake_on_lan (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_wired_get_wake_on_lan_password (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ diff --git a/clients/cli/utils.c b/clients/cli/utils.c index dfd002edc..3cc836d83 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -407,7 +407,10 @@ nmc_string_to_bool (const char *str, gboolean *val_bool, GError **error) if (g_strcmp0 (str, "o") == 0) { g_set_error (error, 1, 0, - _("'%s' is ambiguous (on x off)"), str); + /* Translators: the first %s is the partial value entered by + * the user, the second %s a list of compatible values. + */ + _("'%s' is ambiguous (%s)"), str, "on x off"); return FALSE; } @@ -424,6 +427,39 @@ nmc_string_to_bool (const char *str, gboolean *val_bool, GError **error) return TRUE; } +gboolean +nmc_string_to_tristate (const char *str, NMCTriStateValue *val, GError **error) +{ + const char *s_true[] = { "true", "yes", "on", NULL }; + const char *s_false[] = { "false", "no", "off", NULL }; + const char *s_unknown[] = { "unknown", NULL }; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (g_strcmp0 (str, "o") == 0) { + g_set_error (error, 1, 0, + /* Translators: the first %s is the partial value entered by + * the user, the second %s a list of compatible values. + */ + _("'%s' is ambiguous (%s)"), str, "on x off"); + return FALSE; + } + + if (nmc_string_is_valid (str, s_true, NULL)) + *val = NMC_TRI_STATE_YES; + else if (nmc_string_is_valid (str, s_false, NULL)) + *val = NMC_TRI_STATE_NO; + else if (nmc_string_is_valid (str, s_unknown, NULL)) + *val = NMC_TRI_STATE_UNKNOWN; + else { + g_set_error (error, 1, 0, + _("'%s' is not valid; use [%s], [%s] or [%s]"), + str, "true, yes, on", "false, no, off", "unknown"); + return FALSE; + } + return TRUE; +} + /* * Ask user for input and return the string. * The caller is responsible for freeing the returned string. diff --git a/clients/cli/utils.h b/clients/cli/utils.h index 77e697af6..ba649f8fa 100644 --- a/clients/cli/utils.h +++ b/clients/cli/utils.h @@ -32,6 +32,12 @@ typedef struct { gboolean found; } nmc_arg_t; +typedef enum { + NMC_TRI_STATE_NO, + NMC_TRI_STATE_YES, + NMC_TRI_STATE_UNKNOWN, +} NMCTriStateValue; + /* === Functions === */ int matches (const char *cmd, const char *pattern); int next_arg (int *argc, char ***argv); @@ -62,6 +68,7 @@ gboolean nmc_string_to_uint (const char *str, unsigned long int max, unsigned long int *value); gboolean nmc_string_to_bool (const char *str, gboolean *val_bool, GError **error); +gboolean nmc_string_to_tristate (const char *str, NMCTriStateValue *val, GError **error); char *nmc_ip4_address_as_string (guint32 ip, GError **error); char *nmc_ip6_address_as_string (const struct in6_addr *ip, GError **error); void nmc_terminal_erase_line (void); diff --git a/config.h.in b/config.h.in index 689a497ea..ce3d6c43c 100644 --- a/config.h.in +++ b/config.h.in @@ -151,7 +151,7 @@ /* Define if more asserts are enabled */ #undef NM_MORE_ASSERTS -/* Define if more asserts are enabled */ +/* Define if more debug logging is enabled */ #undef NM_MORE_LOGGING /* Name of package */ @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for NetworkManager 1.0.4. +# Generated by GNU Autoconf 2.69 for NetworkManager 1.0.6. # # Report bugs to <http://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='NetworkManager' PACKAGE_TARNAME='NetworkManager' -PACKAGE_VERSION='1.0.4' -PACKAGE_STRING='NetworkManager 1.0.4' +PACKAGE_VERSION='1.0.6' +PACKAGE_STRING='NetworkManager 1.0.6' PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager' PACKAGE_URL='' @@ -1680,7 +1680,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures NetworkManager 1.0.4 to adapt to many kinds of systems. +\`configure' configures NetworkManager 1.0.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1750,7 +1750,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of NetworkManager 1.0.4:";; + short | recursive ) echo "Configuration of NetworkManager 1.0.6:";; esac cat <<\_ACEOF @@ -2032,7 +2032,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -NetworkManager configure 1.0.4 +NetworkManager configure 1.0.6 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2576,7 +2576,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by NetworkManager $as_me 1.0.4, which was +It was created by NetworkManager $as_me 1.0.6, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3446,7 +3446,7 @@ fi # Define the identity of the package. PACKAGE='NetworkManager' - VERSION='1.0.4' + VERSION='1.0.6' cat >>confdefs.h <<_ACEOF @@ -16731,9 +16731,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu NM_MAJOR_VERSION=1 NM_MINOR_VERSION=0 -NM_MICRO_VERSION=4 -NM_VERSION=1.0.4 -NM_GIT_SHA=f27429138ff951309556c30c67e2f34e7ed29281 +NM_MICRO_VERSION=6 +NM_VERSION=1.0.6 +NM_GIT_SHA=59deb78f851961eec159ba7e11c01f5d9ae667d4 @@ -23258,9 +23258,9 @@ fi GLIB_MAKEFILE='$(top_srcdir)/Makefile.glib' -GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0` +GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` -GLIB_MKENUMS=`pkg-config --variable=glib_mkenums glib-2.0` +GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` @@ -26415,7 +26415,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by NetworkManager $as_me 1.0.4, which was +This file was extended by NetworkManager $as_me 1.0.6, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -26481,7 +26481,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -NetworkManager config.status 1.0.4 +NetworkManager config.status 1.0.6 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 381b6215d..74dacb63a 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) dnl The NM version number m4_define([nm_major_version], [1]) m4_define([nm_minor_version], [0]) -m4_define([nm_micro_version], [4]) +m4_define([nm_micro_version], [6]) m4_define([nm_version], [nm_major_version.nm_minor_version.nm_micro_version]) m4_define([nm_git_sha], [m4_esyscmd([ ( [ -d ./.git/ ] && [ "$(readlink -f ./.git/)" = "$(readlink -f "$(git rev-parse --git-dir 2>/dev/null)" 2>/dev/null)" ] && git rev-parse --verify -q HEAD 2>/dev/null ) || true ])]) @@ -588,9 +588,9 @@ fi GLIB_MAKEFILE='$(top_srcdir)/Makefile.glib' AC_SUBST(GLIB_MAKEFILE) -GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0` +GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` AC_SUBST(GLIB_GENMARSHAL) -GLIB_MKENUMS=`pkg-config --variable=glib_mkenums glib-2.0` +GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` AC_SUBST(GLIB_MKENUMS) AC_ARG_WITH(dbus-sys-dir, AS_HELP_STRING([--with-dbus-sys-dir=DIR], [where D-BUS system.d directory is])) @@ -848,7 +848,7 @@ fi AC_ARG_ENABLE(more-logging, AS_HELP_STRING([--enable-more-logging], [Enable more debug logging (default: no)])) if test "${enable_more_logging}" = "yes"; then - AC_DEFINE(NM_MORE_LOGGING, [1], [Define if more asserts are enabled]) + AC_DEFINE(NM_MORE_LOGGING, [1], [Define if more debug logging is enabled]) fi AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto], [Enable Link Time Optimization for smaller size (default: no)])) diff --git a/data/85-nm-unmanaged.rules b/data/85-nm-unmanaged.rules index aefab5c46..9d2ad7737 100644 --- a/data/85-nm-unmanaged.rules +++ b/data/85-nm-unmanaged.rules @@ -2,11 +2,12 @@ # To override or extend the rules place a file in /etc/udev/rules.d SUBSYSTEM!="net", GOTO="nm_unmanaged_end" +ACTION!="add|change", GOTO="nm_unmanaged_end" # Determine ID_NET_DRIVER if there's no ID_NET_DRIVER or DRIVERS (old udev?) ENV{ID_NET_DRIVER}=="?*", GOTO="nm_unmanaged_driver" DRIVERS=="?*", GOTO="nm_unmanaged_driver" -PROGRAM="/bin/sh -c '/usr/sbin/ethtool -i $env{INTERFACE} |/bin/sed -n s/^driver:\ //p'", RESULT=="?*", ENV{ID_NET_DRIVER}="%c" +PROGRAM="/bin/sh -c '/usr/sbin/ethtool -i $1 | /bin/sed -n s/^driver:\ //p' -- $env{INTERFACE}", RESULT=="?*", ENV{ID_NET_DRIVER}="%c" LABEL="nm_unmanaged_driver" # VirtualBox host networking. Out-of-tree driver that looks like an ordinary @@ -19,13 +20,13 @@ ENV{INTERFACE}=="vboxnet[0-9]*", ENV{NM_UNMANAGED}="1" # Ethernet. No parent device (lives in /virtual/), no support for # ethtool to identify the driver. They have their own MAC prefix that # can not be changed. -PROGRAM="/bin/cat %S%p/address", RESULT=="00:50:56:*", ENV{INTERFACE}=="vmnet[0-9]*", ENV{NM_UNMANAGED}="1" +ATTR{address}=="00:50:56:*", ENV{INTERFACE}=="vmnet[0-9]*", ENV{NM_UNMANAGED}="1" # Parallels Workstation host networking. Out-of-tree driver that looks like # an ordinary Ethernet. No parent device (lives in /virtual/), no support for # ethtool to identify the driver and the interface name is too generic. # However, they have their own MAC prefix that can not be changed. -PROGRAM="/bin/cat %S%p/address", RESULT=="00:1c:42:*", ENV{INTERFACE}=="vnic[0-9]*", ENV{NM_UNMANAGED}="1" +ATTR{address}=="00:1c:42:*", ENV{INTERFACE}=="vnic[0-9]*", ENV{NM_UNMANAGED}="1" # Virtual Ethernet device pair. Often used to communicate with a peer interface # in another net namespace and managed by libvirt, Docker or the like. diff --git a/docs/api/html/index.html b/docs/api/html/index.html index c2c59933b..5656932f8 100644 --- a/docs/api/html/index.html +++ b/docs/api/html/index.html @@ -14,7 +14,7 @@ <div class="titlepage"> <div> <div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">NetworkManager D-Bus Reference Manual</p></th></tr></table></div> -<div><p class="releaseinfo">Version 1.0.4 +<div><p class="releaseinfo">Version 1.0.6 </p></div> <div><p class="copyright">Copyright © 2012 The NetworkManager Authors</p></div> <div><div class="legalnotice"> diff --git a/docs/api/html/ref-settings.html b/docs/api/html/ref-settings.html index 10405a35e..501656bca 100644 --- a/docs/api/html/ref-settings.html +++ b/docs/api/html/ref-settings.html @@ -625,6 +625,12 @@ <td>Interface name of the master device or UUID of the master connection.</td> </tr> <tr> +<td><pre class="screen">metered</pre></td> +<td><pre class="screen">NMMetered (int32)</pre></td> +<td><pre class="screen"></pre></td> +<td>Whether the connection is metered.</td> +</tr> +<tr> <td><pre class="screen">name</pre></td> <td><pre class="screen">string</pre></td> <td><pre class="screen">connection</pre></td> @@ -1800,6 +1806,18 @@ <td><pre class="screen">0</pre></td> <td>If non-zero, request that the device use only the specified speed. In Mbit/s, ie 100 == 100Mbit/s.</td> </tr> +<tr> +<td><pre class="screen">wake-on-lan</pre></td> +<td><pre class="screen">uint32</pre></td> +<td><pre class="screen">1</pre></td> +<td>The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40).</td> +</tr> +<tr> +<td><pre class="screen">wake-on-lan-password</pre></td> +<td><pre class="screen">string</pre></td> +<td><pre class="screen"></pre></td> +<td>If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required.</td> +</tr> </tbody> </table></div> </div> diff --git a/docs/api/html/spec.html b/docs/api/html/spec.html index bcd634dd7..7f7559c57 100644 --- a/docs/api/html/spec.html +++ b/docs/api/html/spec.html @@ -1,4 +1,4 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ascii" /><title>NetworkManager D-Bus Interface Specification version 1.0.4</title><style type="text/css"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ascii" /><title>NetworkManager D-Bus Interface Specification version 1.0.6</title><style type="text/css"> body { font-family: sans-serif; @@ -97,7 +97,7 @@ margin-right: 4em; } - </style></head><body><h1 class="topbox">NetworkManager D-Bus Interface Specification</h1><h2>Version 1.0.4</h2><div>Copyright (C) 2008 - 2011 Red Hat, Inc.</div><div>Copyright (C) 2008 - 2009 Novell, Inc.</div><div class="license"> + </style></head><body><h1 class="topbox">NetworkManager D-Bus Interface Specification</h1><h2>Version 1.0.6</h2><div>Copyright (C) 2008 - 2011 Red Hat, Inc.</div><div>Copyright (C) 2008 - 2009 Novell, Inc.</div><div class="license"> <p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -381,6 +381,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ The connection type of the "primary" active connection being used to access the network. This is the same as the Type property on the object indicated by PrimaryConnection. + </dd><dt><code>Metered</code> - + <code>u</code> - + <code>(read)</code> + (<a xmlns="" href="#type-NM_METERED">NM_METERED</a>) + </dt><dd> + Wheter the connectivity is metered. This is equivalent to the + metered property of the device associated with the primary + connection. </dd><dt><code>ActivatingConnection</code> - <code>o</code> - <code>(read)</code></dt><dd> @@ -478,7 +486,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ <code>u</code> - <code>(read)</code></dt><dd>The maximum bitrate this access point is capable of, in kilobits/second (Kb/s).</dd><dt><code>Strength</code> - <code>y</code> - - <code>(read)</code></dt><dd>The current signal quality of the access point, in percent.</dd></dl><h2>Sets of flags:</h2><h3 xmlns=""><a name="type-NM_802_11_AP_FLAGS" id="type-NM_802_11_AP_FLAGS">NM_802_11_AP_FLAGS</a></h3> + <code>(read)</code></dt><dd>The current signal quality of the access point, in percent.</dd><dt><code>LastSeen</code> - + <code>i</code> - + <code>(read)</code></dt><dd> + The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access + point was found in scan results. A value of -1 means the access point + has never been found in scan results. + </dd></dl><h2>Sets of flags:</h2><h3 xmlns=""><a name="type-NM_802_11_AP_FLAGS" id="type-NM_802_11_AP_FLAGS">NM_802_11_AP_FLAGS</a></h3> Flags describing the general capabilities of the access point. <dl><dt><code>NM_802_11_AP_FLAGS_NONE = 0x0</code></dt><dd>Null capability - says nothing about the access point.</dd><dt><code>NM_802_11_AP_FLAGS_PRIVACY = 0x1</code></dt><dd>Access point supports privacy measures.</dd></dl><h3 xmlns=""><a name="type-NM_802_11_AP_SEC" id="type-NM_802_11_AP_SEC">NM_802_11_AP_SEC</a></h3> Flags describing the security capabilities of the access point. @@ -635,6 +649,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ <code>u</code> - <code>(read)</code></dt><dd> The device MTU (maximum transmission unit). + </dd><dt><code>Metered</code> - + <code>u</code> - + <code>(read)</code> + (<a xmlns="" href="#type-NM_METERED">NM_METERED</a>) + </dt><dd> + Whether the amount of traffic flowing through the device is + subject to limitations, for example set by service providers. </dd></dl><h2>Enumerated types:</h2><h3><a name="type-NM_DEVICE_STATE" id="type-NM_DEVICE_STATE">NM_DEVICE_STATE</a></h3><dl><dt><code>NM_DEVICE_STATE_UNKNOWN = 0</code></dt><dd> The device is in an unknown state. </dd><dt><code>NM_DEVICE_STATE_UNMANAGED = 10</code></dt><dd> @@ -817,6 +838,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ The device's parent changed. </dd><dt><code>NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62</code></dt><dd> The device parent's management changed. + </dd></dl><h3><a name="type-NM_METERED" id="type-NM_METERED">NM_METERED</a></h3><dl><dt><code>NM_METERED_UNKNOWN = 0</code></dt><dd> + The device metered status is unknown. + </dd><dt><code>NM_METERED_YES = 1</code></dt><dd> + The device is metered and the value was statically set. + </dd><dt><code>NM_METERED_NO = 2</code></dt><dd> + The device is not metered and the value was statically set. + </dd><dt><code>NM_METERED_GUESS_YES = 3</code></dt><dd> + The device is metered and the value was guessed. + </dd><dt><code>NM_METERED_GUESS_NO = 4</code></dt><dd> + The device is not metered and the value was guessed. </dd></dl><h2>Sets of flags:</h2><h3 xmlns=""><a name="type-NM_DEVICE_CAP" id="type-NM_DEVICE_CAP">NM_DEVICE_CAP</a></h3><dl><dt><code>NM_DEVICE_CAP_NONE = 0x0</code></dt><dd>Null capability.</dd><dt><code>NM_DEVICE_CAP_NM_SUPPORTED = 0x1</code></dt><dd>The device is supported by NetworkManager.</dd><dt><code>NM_DEVICE_CAP_CARRIER_DETECT = 0x2</code></dt><dd>The device supports carrier detection.</dd></dl><h2>Structure types:</h2><div class="struct"><h3><a name="type-NM_DEVICE_STATE_REASON_STRUCT" id="type-NM_DEVICE_STATE_REASON_STRUCT">NM_DEVICE_STATE_REASON_STRUCT</a> - ( u: state, u: reason ) @@ -885,7 +916,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ Request the device to scan </div><div><h4>Parameters</h4><dl><dt><code>options</code> - <code>a{sv}</code></dt><dd> - Options of scan (currently unused argument). + Options of scan. + Currently 'ssids' option with value of "aay" type is supported. </dd></dl></div></div><h2>Signals:</h2><div class="signal"><h3><a name="org.freedesktop.NetworkManager.Device.Wireless.PropertiesChanged" id="org.freedesktop.NetworkManager.Device.Wireless.PropertiesChanged">PropertiesChanged</a> ( a{sv}: properties )</h3><div class="docstring"> @@ -2372,6 +2404,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ - u</li><li><code><a href="#type-NM_DEVICE_STATE_REASON_STRUCT">NM_DEVICE_STATE_REASON_STRUCT</a></code> - ( u, u ) </li><li><code><a href="#type-NM_DEVICE_TYPE">NM_DEVICE_TYPE</a></code> + - u</li><li><code><a href="#type-NM_METERED">NM_METERED</a></code> - u</li><li><code><a href="#type-NM_SECRET_AGENT_CAPABILITIES">NM_SECRET_AGENT_CAPABILITIES</a></code> - u</li><li><code><a href="#type-NM_SECRET_AGENT_GET_SECRETS_FLAGS">NM_SECRET_AGENT_GET_SECRETS_FLAGS</a></code> - u</li><li><code><a href="#type-NM_STATE">NM_STATE</a></code> diff --git a/docs/api/settings-spec.xml b/docs/api/settings-spec.xml index f1b507fe0..6f8645a76 100644 --- a/docs/api/settings-spec.xml +++ b/docs/api/settings-spec.xml @@ -88,6 +88,7 @@ <row><entry><screen>id</screen></entry><entry><screen>string</screen></entry><entry><screen/></entry><entry>A human readable unique identifier for the connection, like "Work Wi-Fi" or "T-Mobile 3G".</entry></row> <row><entry><screen>interface-name</screen></entry><entry><screen>string</screen></entry><entry><screen/></entry><entry>The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface.</entry></row> <row><entry><screen>master</screen></entry><entry><screen>string</screen></entry><entry><screen/></entry><entry>Interface name of the master device or UUID of the master connection.</entry></row> + <row><entry><screen>metered</screen></entry><entry><screen>NMMetered (int32)</screen></entry><entry><screen/></entry><entry>Whether the connection is metered.</entry></row> <row><entry><screen>name</screen></entry><entry><screen>string</screen></entry><entry><screen>connection</screen></entry><entry>The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example "ppp" or "wireless" or "wired".</entry></row> <row><entry><screen>permissions</screen></entry><entry><screen>array of string</screen></entry><entry><screen>[]</screen></entry><entry>An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection. Otherwise a user is allowed to access this connection if and only if they are in this list. Each entry is of the form "[type]:[id]:[reserved]"; for example, "user:dcbw:blah". At this time only the "user" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the ":" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8.</entry></row> <row><entry><screen>read-only</screen></entry><entry><screen>boolean</screen></entry><entry><screen>FALSE</screen></entry><entry>FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified.</entry></row> @@ -263,6 +264,8 @@ <row><entry><screen>s390-options</screen></entry><entry><screen>dict of string to string</screen></entry><entry><screen>{}</screen></entry><entry>Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include "portno", "layer2", "portname", "protocol", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]).</entry></row> <row><entry><screen>s390-subchannels</screen></entry><entry><screen>array of string</screen></entry><entry><screen>[]</screen></entry><entry>Identifies specific subchannels that this network device uses for communication with z/VM or s390 host. Like the "mac-address" property for non-z/VM devices, this property can be used to ensure this connection only applies to the network device that uses these subchannels. The list should contain exactly 3 strings, and each string may only be composed of hexadecimal characters and the period (.) character.</entry></row> <row><entry><screen>speed</screen></entry><entry><screen>uint32</screen></entry><entry><screen>0</screen></entry><entry>If non-zero, request that the device use only the specified speed. In Mbit/s, ie 100 == 100Mbit/s.</entry></row> + <row><entry><screen>wake-on-lan</screen></entry><entry><screen>uint32</screen></entry><entry><screen>1</screen></entry><entry>The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40).</entry></row> + <row><entry><screen>wake-on-lan-password</screen></entry><entry><screen>string</screen></entry><entry><screen/></entry><entry>If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required.</entry></row> </tbody></tgroup></table></para> <para><table><title>802-11-wireless setting</title><tgroup cols="4"><thead><row><entry>Key Name</entry><entry>Value Type</entry><entry>Default Value</entry><entry>Value Description</entry></row></thead><tbody> <row><entry><screen>band</screen></entry><entry><screen>string</screen></entry><entry><screen/></entry><entry>802.11 frequency band of the network. One of "a" for 5GHz 802.11a or "bg" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network to the specific band, i.e. if "a" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible. This setting depends on specific driver capability and may not work with all drivers.</entry></row> diff --git a/docs/api/spec.html b/docs/api/spec.html index bcd634dd7..7f7559c57 100644 --- a/docs/api/spec.html +++ b/docs/api/spec.html @@ -1,4 +1,4 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ascii" /><title>NetworkManager D-Bus Interface Specification version 1.0.4</title><style type="text/css"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ascii" /><title>NetworkManager D-Bus Interface Specification version 1.0.6</title><style type="text/css"> body { font-family: sans-serif; @@ -97,7 +97,7 @@ margin-right: 4em; } - </style></head><body><h1 class="topbox">NetworkManager D-Bus Interface Specification</h1><h2>Version 1.0.4</h2><div>Copyright (C) 2008 - 2011 Red Hat, Inc.</div><div>Copyright (C) 2008 - 2009 Novell, Inc.</div><div class="license"> + </style></head><body><h1 class="topbox">NetworkManager D-Bus Interface Specification</h1><h2>Version 1.0.6</h2><div>Copyright (C) 2008 - 2011 Red Hat, Inc.</div><div>Copyright (C) 2008 - 2009 Novell, Inc.</div><div class="license"> <p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -381,6 +381,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ The connection type of the "primary" active connection being used to access the network. This is the same as the Type property on the object indicated by PrimaryConnection. + </dd><dt><code>Metered</code> - + <code>u</code> - + <code>(read)</code> + (<a xmlns="" href="#type-NM_METERED">NM_METERED</a>) + </dt><dd> + Wheter the connectivity is metered. This is equivalent to the + metered property of the device associated with the primary + connection. </dd><dt><code>ActivatingConnection</code> - <code>o</code> - <code>(read)</code></dt><dd> @@ -478,7 +486,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ <code>u</code> - <code>(read)</code></dt><dd>The maximum bitrate this access point is capable of, in kilobits/second (Kb/s).</dd><dt><code>Strength</code> - <code>y</code> - - <code>(read)</code></dt><dd>The current signal quality of the access point, in percent.</dd></dl><h2>Sets of flags:</h2><h3 xmlns=""><a name="type-NM_802_11_AP_FLAGS" id="type-NM_802_11_AP_FLAGS">NM_802_11_AP_FLAGS</a></h3> + <code>(read)</code></dt><dd>The current signal quality of the access point, in percent.</dd><dt><code>LastSeen</code> - + <code>i</code> - + <code>(read)</code></dt><dd> + The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access + point was found in scan results. A value of -1 means the access point + has never been found in scan results. + </dd></dl><h2>Sets of flags:</h2><h3 xmlns=""><a name="type-NM_802_11_AP_FLAGS" id="type-NM_802_11_AP_FLAGS">NM_802_11_AP_FLAGS</a></h3> Flags describing the general capabilities of the access point. <dl><dt><code>NM_802_11_AP_FLAGS_NONE = 0x0</code></dt><dd>Null capability - says nothing about the access point.</dd><dt><code>NM_802_11_AP_FLAGS_PRIVACY = 0x1</code></dt><dd>Access point supports privacy measures.</dd></dl><h3 xmlns=""><a name="type-NM_802_11_AP_SEC" id="type-NM_802_11_AP_SEC">NM_802_11_AP_SEC</a></h3> Flags describing the security capabilities of the access point. @@ -635,6 +649,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ <code>u</code> - <code>(read)</code></dt><dd> The device MTU (maximum transmission unit). + </dd><dt><code>Metered</code> - + <code>u</code> - + <code>(read)</code> + (<a xmlns="" href="#type-NM_METERED">NM_METERED</a>) + </dt><dd> + Whether the amount of traffic flowing through the device is + subject to limitations, for example set by service providers. </dd></dl><h2>Enumerated types:</h2><h3><a name="type-NM_DEVICE_STATE" id="type-NM_DEVICE_STATE">NM_DEVICE_STATE</a></h3><dl><dt><code>NM_DEVICE_STATE_UNKNOWN = 0</code></dt><dd> The device is in an unknown state. </dd><dt><code>NM_DEVICE_STATE_UNMANAGED = 10</code></dt><dd> @@ -817,6 +838,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ The device's parent changed. </dd><dt><code>NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62</code></dt><dd> The device parent's management changed. + </dd></dl><h3><a name="type-NM_METERED" id="type-NM_METERED">NM_METERED</a></h3><dl><dt><code>NM_METERED_UNKNOWN = 0</code></dt><dd> + The device metered status is unknown. + </dd><dt><code>NM_METERED_YES = 1</code></dt><dd> + The device is metered and the value was statically set. + </dd><dt><code>NM_METERED_NO = 2</code></dt><dd> + The device is not metered and the value was statically set. + </dd><dt><code>NM_METERED_GUESS_YES = 3</code></dt><dd> + The device is metered and the value was guessed. + </dd><dt><code>NM_METERED_GUESS_NO = 4</code></dt><dd> + The device is not metered and the value was guessed. </dd></dl><h2>Sets of flags:</h2><h3 xmlns=""><a name="type-NM_DEVICE_CAP" id="type-NM_DEVICE_CAP">NM_DEVICE_CAP</a></h3><dl><dt><code>NM_DEVICE_CAP_NONE = 0x0</code></dt><dd>Null capability.</dd><dt><code>NM_DEVICE_CAP_NM_SUPPORTED = 0x1</code></dt><dd>The device is supported by NetworkManager.</dd><dt><code>NM_DEVICE_CAP_CARRIER_DETECT = 0x2</code></dt><dd>The device supports carrier detection.</dd></dl><h2>Structure types:</h2><div class="struct"><h3><a name="type-NM_DEVICE_STATE_REASON_STRUCT" id="type-NM_DEVICE_STATE_REASON_STRUCT">NM_DEVICE_STATE_REASON_STRUCT</a> - ( u: state, u: reason ) @@ -885,7 +916,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ Request the device to scan </div><div><h4>Parameters</h4><dl><dt><code>options</code> - <code>a{sv}</code></dt><dd> - Options of scan (currently unused argument). + Options of scan. + Currently 'ssids' option with value of "aay" type is supported. </dd></dl></div></div><h2>Signals:</h2><div class="signal"><h3><a name="org.freedesktop.NetworkManager.Device.Wireless.PropertiesChanged" id="org.freedesktop.NetworkManager.Device.Wireless.PropertiesChanged">PropertiesChanged</a> ( a{sv}: properties )</h3><div class="docstring"> @@ -2372,6 +2404,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ - u</li><li><code><a href="#type-NM_DEVICE_STATE_REASON_STRUCT">NM_DEVICE_STATE_REASON_STRUCT</a></code> - ( u, u ) </li><li><code><a href="#type-NM_DEVICE_TYPE">NM_DEVICE_TYPE</a></code> + - u</li><li><code><a href="#type-NM_METERED">NM_METERED</a></code> - u</li><li><code><a href="#type-NM_SECRET_AGENT_CAPABILITIES">NM_SECRET_AGENT_CAPABILITIES</a></code> - u</li><li><code><a href="#type-NM_SECRET_AGENT_GET_SECRETS_FLAGS">NM_SECRET_AGENT_GET_SECRETS_FLAGS</a></code> - u</li><li><code><a href="#type-NM_STATE">NM_STATE</a></code> diff --git a/docs/api/version.xml b/docs/api/version.xml index ee90284c2..af0b7ddbf 100644 --- a/docs/api/version.xml +++ b/docs/api/version.xml @@ -1 +1 @@ -1.0.4 +1.0.6 diff --git a/docs/libnm-glib/html/NMAccessPoint.html b/docs/libnm-glib/html/NMAccessPoint.html index 9182a27a7..b6e6a3788 100644 --- a/docs/libnm-glib/html/NMAccessPoint.html +++ b/docs/libnm-glib/html/NMAccessPoint.html @@ -121,6 +121,14 @@ </tr> <tr> <td class="function_type"> +<span class="returnvalue">gint32</span> +</td> +<td class="function_name"> +<a class="link" href="NMAccessPoint.html#nm-access-point-get-last-seen" title="nm_access_point_get_last_seen ()">nm_access_point_get_last_seen</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type"> <span class="returnvalue">GSList</span> * </td> <td class="function_name"> @@ -177,6 +185,11 @@ <td class="property_flags">Read</td> </tr> <tr> +<td class="property_type"><span class="type">gint</span></td> +<td class="property_name"><a class="link" href="NMAccessPoint.html#NMAccessPoint--last-seen" title="The “last-seen” property">last-seen</a></td> +<td class="property_flags">Read</td> +</tr> +<tr> <td class="property_type"><span class="type">guint</span></td> <td class="property_name"><a class="link" href="NMAccessPoint.html#NMAccessPoint--max-bitrate" title="The “max-bitrate” property">max-bitrate</a></td> <td class="property_flags">Read</td> @@ -256,6 +269,10 @@ </tr> <tr> <td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS" title="NM_ACCESS_POINT_LAST_SEEN">NM_ACCESS_POINT_LAST_SEEN</a></td> +</tr> +<tr> +<td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-HW-ADDRESS:CAPS" title="NM_ACCESS_POINT_HW_ADDRESS">NM_ACCESS_POINT_HW_ADDRESS</a></td> </tr> </tbody> @@ -546,6 +563,35 @@ nm_access_point_get_strength (<em class="parameter"><code><a class="link" href=" </div> <hr> <div class="refsect2"> +<a name="nm-access-point-get-last-seen"></a><h3>nm_access_point_get_last_seen ()</h3> +<pre class="programlisting"><span class="returnvalue">gint32</span> +nm_access_point_get_last_seen (<em class="parameter"><code><a class="link" href="NMAccessPoint.html" title="NMAccessPoint"><span class="type">NMAccessPoint</span></a> *ap</code></em>);</pre> +<p>Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last time the +access point was found in scan results. A value of -1 means the access +point has not been found in a scan.</p> +<div class="refsect3"> +<a name="id-1.3.19.8.12.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody><tr> +<td class="parameter_name"><p>ap</p></td> +<td class="parameter_description"><p>a <a class="link" href="NMAccessPoint.html" title="NMAccessPoint"><span class="type">NMAccessPoint</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr></tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.3.19.8.12.6"></a><h4>Returns</h4> +<p> the last seen time in seconds</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="nm-access-point-filter-connections"></a><h3>nm_access_point_filter_connections ()</h3> <pre class="programlisting"><span class="returnvalue">GSList</span> * nm_access_point_filter_connections (<em class="parameter"><code><a class="link" href="NMAccessPoint.html" title="NMAccessPoint"><span class="type">NMAccessPoint</span></a> *ap</code></em>, @@ -560,7 +606,7 @@ use <a class="link" href="NMRemoteSettings.html#nm-remote-settings-list-connecti for a given <a class="link" href="NMDevice.html" title="NMDevice"><span class="type">NMDevice</span></a> using <a class="link" href="NMDevice.html#nm-device-filter-connections" title="nm_device_filter_connections ()"><code class="function">nm_device_filter_connections()</code></a> and finally filter that list with this function.</p> <div class="refsect3"> -<a name="id-1.3.19.8.12.6"></a><h4>Parameters</h4> +<a name="id-1.3.19.8.13.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -583,7 +629,7 @@ filter that list with this function.</p> </table></div> </div> <div class="refsect3"> -<a name="id-1.3.19.8.12.7"></a><h4>Returns</h4> +<a name="id-1.3.19.8.13.7"></a><h4>Returns</h4> <p> a list of <a href="https://developer.gnome.org/libnm-util/0.9/NMConnection.html"><span class="type">NMConnection</span></a> objects that could be activated with the given <em class="parameter"><code>ap</code></em> . @@ -605,7 +651,7 @@ the connection may be activated with that AP. The connection must match the 's SSID, (if given) BSSID, and other attributes like security settings, channel, band, etc.</p> <div class="refsect3"> -<a name="id-1.3.19.8.13.5"></a><h4>Parameters</h4> +<a name="id-1.3.19.8.14.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -629,7 +675,7 @@ against</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.3.19.8.13.6"></a><h4>Returns</h4> +<a name="id-1.3.19.8.14.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if the connection may be activated with this Wi-Fi AP, <code class="literal">FALSE</code> if it cannot be.</p> </div> @@ -645,7 +691,7 @@ nm_access_point_get_hw_address (<em class="parameter"><code><a class="link" href </div> <p>Gets the hardware (MAC) address of the access point.</p> <div class="refsect3"> -<a name="id-1.3.19.8.14.6"></a><h4>Parameters</h4> +<a name="id-1.3.19.8.15.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -660,7 +706,7 @@ nm_access_point_get_hw_address (<em class="parameter"><code><a class="link" href </table></div> </div> <div class="refsect3"> -<a name="id-1.3.19.8.14.7"></a><h4>Returns</h4> +<a name="id-1.3.19.8.15.7"></a><h4>Returns</h4> <p> the hardware address of the access point. This is the internal string used by the access point and must not be modified.</p> </div> @@ -723,6 +769,12 @@ access point and must not be modified.</p> </div> <hr> <div class="refsect2"> +<a name="NM-ACCESS-POINT-LAST-SEEN:CAPS"></a><h3>NM_ACCESS_POINT_LAST_SEEN</h3> +<pre class="programlisting">#define NM_ACCESS_POINT_LAST_SEEN "last-seen" +</pre> +</div> +<hr> +<div class="refsect2"> <a name="NM-ACCESS-POINT-HW-ADDRESS:CAPS"></a><h3>NM_ACCESS_POINT_HW_ADDRESS</h3> <pre class="programlisting">#define NM_ACCESS_POINT_HW_ADDRESS "hw-address" </pre> @@ -765,6 +817,18 @@ access point and must not be modified.</p> </div> <hr> <div class="refsect2"> +<a name="NMAccessPoint--last-seen"></a><h3>The <code class="literal">“last-seen”</code> property</h3> +<pre class="programlisting"> “last-seen” <span class="type">gint</span></pre> +<p>The timestamp (in CLOCK_BOOTTIME seconds) for the last time the +access point was found in scan results. A value of -1 means the +access point has not been found in a scan.</p> +<p>Flags: Read</p> +<p>Allowed values: >= -1</p> +<p>Default value: -1</p> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="NMAccessPoint--max-bitrate"></a><h3>The <code class="literal">“max-bitrate”</code> property</h3> <pre class="programlisting"> “max-bitrate” <span class="type">guint</span></pre> <p>The maximum bit rate of the access point in kbit/s.</p> diff --git a/docs/libnm-glib/html/NMActiveConnection.html b/docs/libnm-glib/html/NMActiveConnection.html index 51037dca3..e14a0408a 100644 --- a/docs/libnm-glib/html/NMActiveConnection.html +++ b/docs/libnm-glib/html/NMActiveConnection.html @@ -655,7 +655,7 @@ nm_active_connection_get_ip4_config (<em class="parameter"><code><a class="link" <div class="refsect3"> <a name="id-1.3.3.8.12.6"></a><h4>Returns</h4> <p> the <a class="link" href="NMIP4Config.html" title="NMIP4Config"><span class="type">NMIP4Config</span></a>, or <code class="literal">NULL</code> if the -connection is not in the <a href="https://developer.gnome.org/libnm-util/0.9/libnm-util-NetworkManager.html#NM-ACTIVE-CONNECTION-STATE-ACTIVATED:CAPS"><code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code></a> +connection is not in the <code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code> state. </p> <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> </div> @@ -687,7 +687,7 @@ nm_active_connection_get_dhcp4_config (<em class="parameter"><code><a class="lin <a name="id-1.3.3.8.13.6"></a><h4>Returns</h4> <p> the <a class="link" href="NMDHCP4Config.html" title="NMDHCP4Config"><span class="type">NMDHCP4Config</span></a>, or <code class="literal">NULL</code> if the connection does not use DHCP, or is not in the -<a href="https://developer.gnome.org/libnm-util/0.9/libnm-util-NetworkManager.html#NM-ACTIVE-CONNECTION-STATE-ACTIVATED:CAPS"><code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code></a> state. </p> +<code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code> state. </p> <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> </div> <p class="since">Since: 0.9.10</p> @@ -743,7 +743,7 @@ nm_active_connection_get_ip6_config (<em class="parameter"><code><a class="link" <div class="refsect3"> <a name="id-1.3.3.8.15.6"></a><h4>Returns</h4> <p> the <a class="link" href="NMIP6Config.html" title="NMIP6Config"><span class="type">NMIP6Config</span></a>, or <code class="literal">NULL</code> if the -connection is not in the <a href="https://developer.gnome.org/libnm-util/0.9/libnm-util-NetworkManager.html#NM-ACTIVE-CONNECTION-STATE-ACTIVATED:CAPS"><code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code></a> +connection is not in the <code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code> state. </p> <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> </div> @@ -775,7 +775,7 @@ nm_active_connection_get_dhcp6_config (<em class="parameter"><code><a class="lin <a name="id-1.3.3.8.16.6"></a><h4>Returns</h4> <p> the <a class="link" href="NMDHCP6Config.html" title="NMDHCP6Config"><span class="type">NMDHCP6Config</span></a>, or <code class="literal">NULL</code> if the connection does not use DHCPv6, or is not in the -<a href="https://developer.gnome.org/libnm-util/0.9/libnm-util-NetworkManager.html#NM-ACTIVE-CONNECTION-STATE-ACTIVATED:CAPS"><code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code></a> state. </p> +<code class="literal">NM_ACTIVE_CONNECTION_STATE_ACTIVATED</code> state. </p> <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> </div> <p class="since">Since: 0.9.10</p> diff --git a/docs/libnm-glib/html/NMSecretAgent.html b/docs/libnm-glib/html/NMSecretAgent.html index 8acd02c17..354c1209d 100644 --- a/docs/libnm-glib/html/NMSecretAgent.html +++ b/docs/libnm-glib/html/NMSecretAgent.html @@ -289,7 +289,7 @@ something like this:</p> <span class="normal"> <a href="https://developer.gnome.org/libnm-util/0.9/NMSettingWirelessSecurity.html#NM-SETTING-WIRELESS-SECURITY-PSK:CAPS">NM_SETTING_WIRELESS_SECURITY_PSK</a></span><span class="symbol">,</span><span class="normal"> </span><span class="string">"my really cool PSK"</span><span class="symbol">,</span> <span class="normal"> NULL</span><span class="symbol">);</span> <span class="function"><a href="https://developer.gnome.org/libnm-util/0.9/NMConnection.html#nm-connection-add-setting">nm_connection_add_setting</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">secrets</span><span class="symbol">,</span><span class="normal"> </span><span class="function">NM_SETTING</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">s_wsec</span><span class="symbol">));</span> -<span class="normal">secrets_hash </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="https://developer.gnome.org/libnm-util/0.9/NMConnection.html#nm-connection-to-hash">nm_connection_to_hash</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">secrets</span><span class="symbol">,</span><span class="normal"> <a href="https://developer.gnome.org/libnm-util/0.9/NMSetting.html#NM-SETTING-HASH-FLAG-ALL:CAPS">NM_SETTING_HASH_FLAG_ALL</a></span><span class="symbol">);</span> +<span class="normal">secrets_hash </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="https://developer.gnome.org/libnm-util/0.9/NMConnection.html#nm-connection-to-hash">nm_connection_to_hash</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">secrets</span><span class="symbol">,</span><span class="normal"> NM_SETTING_HASH_FLAG_ALL</span><span class="symbol">);</span> <span class="symbol">(</span><span class="normal">call the NMSecretAgentGetSecretsFunc </span><span class="usertype">with</span><span class="normal"> secrets_hash</span><span class="symbol">)</span> diff --git a/docs/libnm-glib/html/api-index-full.html b/docs/libnm-glib/html/api-index-full.html index 1f09388cc..e11ae148c 100644 --- a/docs/libnm-glib/html/api-index-full.html +++ b/docs/libnm-glib/html/api-index-full.html @@ -56,6 +56,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMAccessPoint.html#NMAccessPoint--last-seen" title="The “last-seen” property">NMAccessPoint:last-seen</a>, object property in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMAccessPoint.html#NMAccessPoint--max-bitrate" title="The “max-bitrate” property">NMAccessPoint:max-bitrate</a>, object property in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> </dt> <dd></dd> @@ -116,6 +120,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMAccessPoint.html#nm-access-point-get-last-seen" title="nm_access_point_get_last_seen ()">nm_access_point_get_last_seen</a>, function in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMAccessPoint.html#nm-access-point-get-max-bitrate" title="nm_access_point_get_max_bitrate ()">nm_access_point_get_max_bitrate</a>, function in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> </dt> <dd></dd> @@ -144,6 +152,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS" title="NM_ACCESS_POINT_LAST_SEEN">NM_ACCESS_POINT_LAST_SEEN</a>, macro in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-MAX-BITRATE:CAPS" title="NM_ACCESS_POINT_MAX_BITRATE">NM_ACCESS_POINT_MAX_BITRATE</a>, macro in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> </dt> <dd></dd> diff --git a/docs/libnm-glib/html/index.html b/docs/libnm-glib/html/index.html index bec4797cf..6a1342929 100644 --- a/docs/libnm-glib/html/index.html +++ b/docs/libnm-glib/html/index.html @@ -15,7 +15,7 @@ <div> <div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">libnm-glib Reference Manual</p></th></tr></table></div> <div><p class="releaseinfo"> - for libnm-glib 1.0.4 + for libnm-glib 1.0.6 The latest version of this documentation can be found on-line at <a class="ulink" href="https://developer.gnome.org/libnm-glib/0.9/" target="_top">https://developer.gnome.org/libnm-glib/0.9/</a>. diff --git a/docs/libnm-glib/html/index.sgml b/docs/libnm-glib/html/index.sgml index 5b020fd0b..80069edb6 100644 --- a/docs/libnm-glib/html/index.sgml +++ b/docs/libnm-glib/html/index.sgml @@ -678,6 +678,7 @@ <ANCHOR id="nm-access-point-get-mode" href="libnm-glib/NMAccessPoint.html#nm-access-point-get-mode"> <ANCHOR id="nm-access-point-get-max-bitrate" href="libnm-glib/NMAccessPoint.html#nm-access-point-get-max-bitrate"> <ANCHOR id="nm-access-point-get-strength" href="libnm-glib/NMAccessPoint.html#nm-access-point-get-strength"> +<ANCHOR id="nm-access-point-get-last-seen" href="libnm-glib/NMAccessPoint.html#nm-access-point-get-last-seen"> <ANCHOR id="nm-access-point-filter-connections" href="libnm-glib/NMAccessPoint.html#nm-access-point-filter-connections"> <ANCHOR id="nm-access-point-connection-valid" href="libnm-glib/NMAccessPoint.html#nm-access-point-connection-valid"> <ANCHOR id="nm-access-point-get-hw-address" href="libnm-glib/NMAccessPoint.html#nm-access-point-get-hw-address"> @@ -691,12 +692,14 @@ <ANCHOR id="NM-ACCESS-POINT-MODE:CAPS" href="libnm-glib/NMAccessPoint.html#NM-ACCESS-POINT-MODE:CAPS"> <ANCHOR id="NM-ACCESS-POINT-MAX-BITRATE:CAPS" href="libnm-glib/NMAccessPoint.html#NM-ACCESS-POINT-MAX-BITRATE:CAPS"> <ANCHOR id="NM-ACCESS-POINT-STRENGTH:CAPS" href="libnm-glib/NMAccessPoint.html#NM-ACCESS-POINT-STRENGTH:CAPS"> +<ANCHOR id="NM-ACCESS-POINT-LAST-SEEN:CAPS" href="libnm-glib/NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS"> <ANCHOR id="NM-ACCESS-POINT-HW-ADDRESS:CAPS" href="libnm-glib/NMAccessPoint.html#NM-ACCESS-POINT-HW-ADDRESS:CAPS"> <ANCHOR id="NMAccessPoint.property-details" href="libnm-glib/NMAccessPoint.html#NMAccessPoint.property-details"> <ANCHOR id="NMAccessPoint--bssid" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--bssid"> <ANCHOR id="NMAccessPoint--flags" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--flags"> <ANCHOR id="NMAccessPoint--frequency" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--frequency"> <ANCHOR id="NMAccessPoint--hw-address" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--hw-address"> +<ANCHOR id="NMAccessPoint--last-seen" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--last-seen"> <ANCHOR id="NMAccessPoint--max-bitrate" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--max-bitrate"> <ANCHOR id="NMAccessPoint--mode" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--mode"> <ANCHOR id="NMAccessPoint--rsn-flags" href="libnm-glib/NMAccessPoint.html#NMAccessPoint--rsn-flags"> diff --git a/docs/libnm-glib/html/libnm-glib.devhelp2 b/docs/libnm-glib/html/libnm-glib.devhelp2 index 00b0f0756..017e1861f 100644 --- a/docs/libnm-glib/html/libnm-glib.devhelp2 +++ b/docs/libnm-glib/html/libnm-glib.devhelp2 @@ -467,6 +467,7 @@ <keyword type="function" name="nm_access_point_get_mode ()" link="NMAccessPoint.html#nm-access-point-get-mode"/> <keyword type="function" name="nm_access_point_get_max_bitrate ()" link="NMAccessPoint.html#nm-access-point-get-max-bitrate"/> <keyword type="function" name="nm_access_point_get_strength ()" link="NMAccessPoint.html#nm-access-point-get-strength"/> + <keyword type="function" name="nm_access_point_get_last_seen ()" link="NMAccessPoint.html#nm-access-point-get-last-seen" since="1.0.6"/> <keyword type="function" name="nm_access_point_filter_connections ()" link="NMAccessPoint.html#nm-access-point-filter-connections"/> <keyword type="function" name="nm_access_point_connection_valid ()" link="NMAccessPoint.html#nm-access-point-connection-valid"/> <keyword type="function" name="nm_access_point_get_hw_address ()" link="NMAccessPoint.html#nm-access-point-get-hw-address" deprecated="0.9: Use nm_access_point_get_bssid() instead."/> @@ -479,11 +480,13 @@ <keyword type="macro" name="NM_ACCESS_POINT_MODE" link="NMAccessPoint.html#NM-ACCESS-POINT-MODE:CAPS"/> <keyword type="macro" name="NM_ACCESS_POINT_MAX_BITRATE" link="NMAccessPoint.html#NM-ACCESS-POINT-MAX-BITRATE:CAPS"/> <keyword type="macro" name="NM_ACCESS_POINT_STRENGTH" link="NMAccessPoint.html#NM-ACCESS-POINT-STRENGTH:CAPS"/> + <keyword type="macro" name="NM_ACCESS_POINT_LAST_SEEN" link="NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS"/> <keyword type="macro" name="NM_ACCESS_POINT_HW_ADDRESS" link="NMAccessPoint.html#NM-ACCESS-POINT-HW-ADDRESS:CAPS"/> <keyword type="property" name="The “bssid” property" link="NMAccessPoint.html#NMAccessPoint--bssid"/> <keyword type="property" name="The “flags” property" link="NMAccessPoint.html#NMAccessPoint--flags"/> <keyword type="property" name="The “frequency” property" link="NMAccessPoint.html#NMAccessPoint--frequency"/> <keyword type="property" name="The “hw-address” property" link="NMAccessPoint.html#NMAccessPoint--hw-address"/> + <keyword type="property" name="The “last-seen” property" link="NMAccessPoint.html#NMAccessPoint--last-seen"/> <keyword type="property" name="The “max-bitrate” property" link="NMAccessPoint.html#NMAccessPoint--max-bitrate"/> <keyword type="property" name="The “mode” property" link="NMAccessPoint.html#NMAccessPoint--mode"/> <keyword type="property" name="The “rsn-flags” property" link="NMAccessPoint.html#NMAccessPoint--rsn-flags"/> diff --git a/docs/libnm-glib/libnm-glib-sections.txt b/docs/libnm-glib/libnm-glib-sections.txt index d21040d20..420d1610f 100644 --- a/docs/libnm-glib/libnm-glib-sections.txt +++ b/docs/libnm-glib/libnm-glib-sections.txt @@ -10,6 +10,7 @@ NM_ACCESS_POINT_FREQUENCY NM_ACCESS_POINT_MODE NM_ACCESS_POINT_MAX_BITRATE NM_ACCESS_POINT_STRENGTH +NM_ACCESS_POINT_LAST_SEEN NM_ACCESS_POINT_HW_ADDRESS nm_access_point_new nm_access_point_get_flags @@ -21,6 +22,7 @@ nm_access_point_get_frequency nm_access_point_get_mode nm_access_point_get_max_bitrate nm_access_point_get_strength +nm_access_point_get_last_seen nm_access_point_filter_connections nm_access_point_connection_valid nm_access_point_get_hw_address diff --git a/docs/libnm-glib/version.xml b/docs/libnm-glib/version.xml index ee90284c2..af0b7ddbf 100644 --- a/docs/libnm-glib/version.xml +++ b/docs/libnm-glib/version.xml @@ -1 +1 @@ -1.0.4 +1.0.6 diff --git a/docs/libnm-util/html/index.html b/docs/libnm-util/html/index.html index 7be228838..453e0d983 100644 --- a/docs/libnm-util/html/index.html +++ b/docs/libnm-util/html/index.html @@ -15,7 +15,7 @@ <div> <div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">libnm-util Reference Manual</p></th></tr></table></div> <div><p class="releaseinfo"> - for libnm-util 1.0.4 + for libnm-util 1.0.6 The latest version of this documentation can be found on-line at <a class="ulink" href="https://developer.gnome.org/libnm-util/0.9/" target="_top">https://developer.gnome.org/libnm-util/0.9/</a>. diff --git a/docs/libnm-util/version.xml b/docs/libnm-util/version.xml index ee90284c2..af0b7ddbf 100644 --- a/docs/libnm-util/version.xml +++ b/docs/libnm-util/version.xml @@ -1 +1 @@ -1.0.4 +1.0.6 diff --git a/docs/libnm/Makefile.am b/docs/libnm/Makefile.am index 28938f89f..2525856d5 100644 --- a/docs/libnm/Makefile.am +++ b/docs/libnm/Makefile.am @@ -53,7 +53,8 @@ IGNORE_HFILES= \ nm-setting-private.h \ nm-types.h \ nm-utils-private.h \ - nm-vpn-plugin-old.h + nm-vpn-plugin-old.h \ + nm-core-tests-enum-types.h # Images to copy into HTML directory. HTML_IMAGES = libnm.png diff --git a/docs/libnm/Makefile.in b/docs/libnm/Makefile.in index 54ad32871..bb41ba14c 100644 --- a/docs/libnm/Makefile.in +++ b/docs/libnm/Makefile.in @@ -455,7 +455,8 @@ IGNORE_HFILES = \ nm-setting-private.h \ nm-types.h \ nm-utils-private.h \ - nm-vpn-plugin-old.h + nm-vpn-plugin-old.h \ + nm-core-tests-enum-types.h # Images to copy into HTML directory. diff --git a/docs/libnm/html/NMAccessPoint.html b/docs/libnm/html/NMAccessPoint.html index 1daa7c012..4aa880dcb 100644 --- a/docs/libnm/html/NMAccessPoint.html +++ b/docs/libnm/html/NMAccessPoint.html @@ -114,6 +114,14 @@ </tr> <tr> <td class="function_type"> +<span class="returnvalue">gint</span> +</td> +<td class="function_name"> +<a class="link" href="NMAccessPoint.html#nm-access-point-get-last-seen" title="nm_access_point_get_last_seen ()">nm_access_point_get_last_seen</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type"> <span class="returnvalue">GPtrArray</span> * </td> <td class="function_name"> @@ -163,6 +171,11 @@ <td class="property_flags">Read</td> </tr> <tr> +<td class="property_type"><span class="type">gint</span></td> +<td class="property_name"><a class="link" href="NMAccessPoint.html#NMAccessPoint--last-seen" title="The “last-seen” property">last-seen</a></td> +<td class="property_flags">Read</td> +</tr> +<tr> <td class="property_type"><span class="type">guint</span></td> <td class="property_name"><a class="link" href="NMAccessPoint.html#NMAccessPoint--max-bitrate" title="The “max-bitrate” property">max-bitrate</a></td> <td class="property_flags">Read</td> @@ -242,6 +255,10 @@ </tr> <tr> <td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS" title="NM_ACCESS_POINT_LAST_SEEN">NM_ACCESS_POINT_LAST_SEEN</a></td> +</tr> +<tr> +<td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-HW-ADDRESS:CAPS" title="NM_ACCESS_POINT_HW_ADDRESS">NM_ACCESS_POINT_HW_ADDRESS</a></td> </tr> </tbody> @@ -498,6 +515,35 @@ nm_access_point_get_strength (<em class="parameter"><code><a class="link" href=" </div> <hr> <div class="refsect2"> +<a name="nm-access-point-get-last-seen"></a><h3>nm_access_point_get_last_seen ()</h3> +<pre class="programlisting"><span class="returnvalue">gint</span> +nm_access_point_get_last_seen (<em class="parameter"><code><a class="link" href="NMAccessPoint.html" title="NMAccessPoint"><span class="type">NMAccessPoint</span></a> *ap</code></em>);</pre> +<p>Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last time the +access point was found in scan results. A value of -1 means the access +point has not been found in a scan.</p> +<div class="refsect3"> +<a name="id-1.5.19.8.11.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody><tr> +<td class="parameter_name"><p>ap</p></td> +<td class="parameter_description"><p>a <a class="link" href="NMAccessPoint.html" title="NMAccessPoint"><span class="type">NMAccessPoint</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr></tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.5.19.8.11.6"></a><h4>Returns</h4> +<p> the last seen time in seconds</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="nm-access-point-filter-connections"></a><h3>nm_access_point_filter_connections ()</h3> <pre class="programlisting"><span class="returnvalue">GPtrArray</span> * nm_access_point_filter_connections (<em class="parameter"><code><a class="link" href="NMAccessPoint.html" title="NMAccessPoint"><span class="type">NMAccessPoint</span></a> *ap</code></em>, @@ -512,7 +558,7 @@ use <a class="link" href="NMClient.html#nm-client-get-connections" title="nm_cli <a class="link" href="NMDevice.html" title="NMDevice"><span class="type">NMDevice</span></a> using <a class="link" href="NMDevice.html#nm-device-filter-connections" title="nm_device_filter_connections ()"><code class="function">nm_device_filter_connections()</code></a> and finally filter that list with this function.</p> <div class="refsect3"> -<a name="id-1.5.19.8.11.6"></a><h4>Parameters</h4> +<a name="id-1.5.19.8.12.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -535,7 +581,7 @@ filter. </p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.5.19.8.11.7"></a><h4>Returns</h4> +<a name="id-1.5.19.8.12.7"></a><h4>Returns</h4> <p> an array of <a href="https://developer.gnome.org/libnm-util/0.9/NMConnection.html"><span class="type">NMConnections</span></a> that could be activated with the given <em class="parameter"><code>ap</code></em> . The array should @@ -555,7 +601,7 @@ the connection may be activated with that AP. The connection must match the 's SSID, (if given) BSSID, and other attributes like security settings, channel, band, etc.</p> <div class="refsect3"> -<a name="id-1.5.19.8.12.5"></a><h4>Parameters</h4> +<a name="id-1.5.19.8.13.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -579,7 +625,7 @@ against</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.5.19.8.12.6"></a><h4>Returns</h4> +<a name="id-1.5.19.8.13.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if the connection may be activated with this Wi-Fi AP, <code class="literal">FALSE</code> if it cannot be.</p> </div> @@ -642,6 +688,12 @@ against</p></td> </div> <hr> <div class="refsect2"> +<a name="NM-ACCESS-POINT-LAST-SEEN:CAPS"></a><h3>NM_ACCESS_POINT_LAST_SEEN</h3> +<pre class="programlisting">#define NM_ACCESS_POINT_LAST_SEEN "last-seen" +</pre> +</div> +<hr> +<div class="refsect2"> <a name="NM-ACCESS-POINT-HW-ADDRESS:CAPS"></a><h3>NM_ACCESS_POINT_HW_ADDRESS</h3> <pre class="programlisting">#define NM_ACCESS_POINT_HW_ADDRESS "hw-address" </pre> @@ -686,6 +738,18 @@ against</p></td> </div> <hr> <div class="refsect2"> +<a name="NMAccessPoint--last-seen"></a><h3>The <code class="literal">“last-seen”</code> property</h3> +<pre class="programlisting"> “last-seen” <span class="type">gint</span></pre> +<p>The timestamp (in CLOCK_BOOTTIME seconds) for the last time the +access point was found in scan results. A value of -1 means the +access point has not been found in a scan.</p> +<p>Flags: Read</p> +<p>Allowed values: >= -1</p> +<p>Default value: -1</p> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="NMAccessPoint--max-bitrate"></a><h3>The <code class="literal">“max-bitrate”</code> property</h3> <pre class="programlisting"> “max-bitrate” <span class="type">guint</span></pre> <p>The maximum bit rate of the access point in kbit/s.</p> diff --git a/docs/libnm/html/NMClient.html b/docs/libnm/html/NMClient.html index 950d72514..1914ba7b1 100644 --- a/docs/libnm/html/NMClient.html +++ b/docs/libnm/html/NMClient.html @@ -523,6 +523,11 @@ <td class="property_flags">Read</td> </tr> <tr> +<td class="property_type"><span class="type">guint</span></td> +<td class="property_name"><a class="link" href="NMClient.html#NMClient--metered" title="The “metered” property">metered</a></td> +<td class="property_flags">Read</td> +</tr> +<tr> <td class="property_type"><span class="type">gboolean</span></td> <td class="property_name"><a class="link" href="NMClient.html#NMClient--networking-enabled" title="The “networking-enabled” property">networking-enabled</a></td> <td class="property_flags">Read / Write</td> @@ -710,6 +715,10 @@ </tr> <tr> <td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="NMClient.html#NM-CLIENT-METERED:CAPS" title="NM_CLIENT_METERED">NM_CLIENT_METERED</a></td> +</tr> +<tr> +<td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="NMClient.html#NM-CLIENT-DEVICE-ADDED:CAPS" title="NM_CLIENT_DEVICE_ADDED">NM_CLIENT_DEVICE_ADDED</a></td> </tr> <tr> @@ -2989,6 +2998,12 @@ nm_client_reload_connections_finish (<em class="parameter"><code><a class="link" </div> <hr> <div class="refsect2"> +<a name="NM-CLIENT-METERED:CAPS"></a><h3>NM_CLIENT_METERED</h3> +<pre class="programlisting">#define NM_CLIENT_METERED "metered" +</pre> +</div> +<hr> +<div class="refsect2"> <a name="NM-CLIENT-DEVICE-ADDED:CAPS"></a><h3>NM_CLIENT_DEVICE_ADDED</h3> <pre class="programlisting">#define NM_CLIENT_DEVICE_ADDED "device-added" </pre> @@ -3023,7 +3038,7 @@ nm_client_reload_connections_finish (<em class="parameter"><code><a class="link" <p><a class="link" href="NMClient.html#NMClientPermission" title="enum NMClientPermission"><span class="type">NMClientPermission</span></a> values indicate various permissions that NetworkManager clients can obtain to perform certain tasks on behalf of the current user.</p> <div class="refsect3"> -<a name="id-1.3.2.10.26.4"></a><h4>Members</h4> +<a name="id-1.3.2.10.27.4"></a><h4>Members</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="300px" class="enum_members_name"> @@ -3143,7 +3158,7 @@ clients can obtain to perform certain tasks on behalf of the current user.</p> <p><a class="link" href="NMClient.html#NMClientPermissionResult" title="enum NMClientPermissionResult"><span class="type">NMClientPermissionResult</span></a> values indicate what authorizations and permissions the user requires to obtain a given <a class="link" href="NMClient.html#NMClientPermission" title="enum NMClientPermission"><span class="type">NMClientPermission</span></a></p> <div class="refsect3"> -<a name="id-1.3.2.10.27.4"></a><h4>Members</h4> +<a name="id-1.3.2.10.28.4"></a><h4>Members</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="300px" class="enum_members_name"> @@ -3192,7 +3207,7 @@ the user requires to obtain a given <a class="link" href="NMClient.html#NMClient <p>D-Bus operations may also return errors from other domains, including <a class="link" href="libnm-nm-errors.html#NMManagerError" title="enum NMManagerError"><span class="type">NMManagerError</span></a>, <a class="link" href="libnm-nm-errors.html#NMSettingsError" title="enum NMSettingsError"><span class="type">NMSettingsError</span></a>, <a class="link" href="libnm-nm-errors.html#NMAgentManagerError" title="enum NMAgentManagerError"><span class="type">NMAgentManagerError</span></a>, and <a class="link" href="libnm-nm-errors.html#NMConnectionError" title="enum NMConnectionError"><span class="type">NMConnectionError</span></a>.</p> <div class="refsect3"> -<a name="id-1.3.2.10.28.5"></a><h4>Members</h4> +<a name="id-1.3.2.10.29.5"></a><h4>Members</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="300px" class="enum_members_name"> @@ -3299,6 +3314,15 @@ modified by calling <a class="link" href="NMClient.html#nm-client-save-hostname" </div> <hr> <div class="refsect2"> +<a name="NMClient--metered"></a><h3>The <code class="literal">“metered”</code> property</h3> +<pre class="programlisting"> “metered” <span class="type">guint</span></pre> +<p>Whether the connectivity is metered.</p> +<p>Flags: Read</p> +<p>Default value: 0</p> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="NMClient--networking-enabled"></a><h3>The <code class="literal">“networking-enabled”</code> property</h3> <pre class="programlisting"> “networking-enabled” <span class="type">gboolean</span></pre> <p>Whether networking is enabled.</p> diff --git a/docs/libnm/html/NMDevice.html b/docs/libnm/html/NMDevice.html index 8065247c7..ff38ac071 100644 --- a/docs/libnm/html/NMDevice.html +++ b/docs/libnm/html/NMDevice.html @@ -255,6 +255,14 @@ </tr> <tr> <td class="function_type"> +<a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered"><span class="returnvalue">NMMetered</span></a> +</td> +<td class="function_name"> +<a class="link" href="NMDevice.html#nm-device-get-metered" title="nm_device_get_metered ()">nm_device_get_metered</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type"> <span class="returnvalue">char</span> ** </td> <td class="function_name"> @@ -446,6 +454,11 @@ </tr> <tr> <td class="property_type"><span class="type">guint</span></td> +<td class="property_name"><a class="link" href="NMDevice.html#NMDevice--metered" title="The “metered” property">metered</a></td> +<td class="property_flags">Read</td> +</tr> +<tr> +<td class="property_type"><span class="type">guint</span></td> <td class="property_name"><a class="link" href="NMDevice.html#NMDevice--mtu" title="The “mtu” property">mtu</a></td> <td class="property_flags">Read</td> </tr> @@ -601,6 +614,10 @@ <td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="NMDevice.html#NM-DEVICE-MTU:CAPS" title="NM_DEVICE_MTU">NM_DEVICE_MTU</a></td> </tr> +<tr> +<td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="NMDevice.html#NM-DEVICE-METERED:CAPS" title="NM_DEVICE_METERED">NM_DEVICE_METERED</a></td> +</tr> </tbody> </table></div> </div> @@ -1410,6 +1427,33 @@ product name is unknown, this returns the interface name.</p> </div> <hr> <div class="refsect2"> +<a name="nm-device-get-metered"></a><h3>nm_device_get_metered ()</h3> +<pre class="programlisting"><a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered"><span class="returnvalue">NMMetered</span></a> +nm_device_get_metered (<em class="parameter"><code><a class="link" href="NMDevice.html" title="NMDevice"><span class="type">NMDevice</span></a> *device</code></em>);</pre> +<p>Gets the metered setting of a <a class="link" href="NMDevice.html" title="NMDevice"><span class="type">NMDevice</span></a>.</p> +<div class="refsect3"> +<a name="id-1.5.2.9.30.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody><tr> +<td class="parameter_name"><p>device</p></td> +<td class="parameter_description"><p>a <a class="link" href="NMDevice.html" title="NMDevice"><span class="type">NMDevice</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr></tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.5.2.9.30.6"></a><h4>Returns</h4> +<p> the metered setting.</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="nm-device-disambiguate-names"></a><h3>nm_device_disambiguate_names ()</h3> <pre class="programlisting"><span class="returnvalue">char</span> ** nm_device_disambiguate_names (<em class="parameter"><code><a class="link" href="NMDevice.html" title="NMDevice"><span class="type">NMDevice</span></a> **devices</code></em>, @@ -1418,7 +1462,7 @@ nm_device_disambiguate_names (<em class="parameter"><code><a class="link" href=" devices in <em class="parameter"><code>devices</code></em> .</p> <div class="refsect3"> -<a name="id-1.5.2.9.30.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.31.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1441,7 +1485,7 @@ devices in <em class="parameter"><code>devices</code></em> </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.30.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.31.6"></a><h4>Returns</h4> <p> the device names. </p> <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>][<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> zero-terminated=1]</span></p> </div> @@ -1457,7 +1501,7 @@ nm_device_disconnect (<em class="parameter"><code><a class="link" href="NMDevice automatically connecting to networks until the next manual network connection request.</p> <div class="refsect3"> -<a name="id-1.5.2.9.31.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.32.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1484,7 +1528,7 @@ request.</p> </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.31.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.32.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> on success, <code class="literal">FALSE</code> on error, in which case <em class="parameter"><code>error</code></em> will be set.</p> </div> @@ -1501,7 +1545,7 @@ nm_device_disconnect_async (<em class="parameter"><code><a class="link" href="NM prevents the device from automatically connecting to networks until the next manual network connection request.</p> <div class="refsect3"> -<a name="id-1.5.2.9.32.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.33.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1543,7 +1587,7 @@ nm_device_disconnect_finish (<em class="parameter"><code><a class="link" href="N <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre> <p>Gets the result of a call to <a class="link" href="NMDevice.html#nm-device-disconnect-async" title="nm_device_disconnect_async ()"><code class="function">nm_device_disconnect_async()</code></a>.</p> <div class="refsect3"> -<a name="id-1.5.2.9.33.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.34.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1570,7 +1614,7 @@ nm_device_disconnect_finish (<em class="parameter"><code><a class="link" href="N </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.33.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.34.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> on success, <code class="literal">FALSE</code> on error, in which case <em class="parameter"><code>error</code></em> will be set.</p> </div> @@ -1584,7 +1628,7 @@ nm_device_delete (<em class="parameter"><code><a class="link" href="NMDevice.htm <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre> <p>Deletes the software device. Hardware devices can't be deleted.</p> <div class="refsect3"> -<a name="id-1.5.2.9.34.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.35.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1611,7 +1655,7 @@ nm_device_delete (<em class="parameter"><code><a class="link" href="NMDevice.htm </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.34.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.35.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> on success, <code class="literal">FALSE</code> on error, in which case <em class="parameter"><code>error</code></em> will be set.</p> </div> @@ -1627,7 +1671,7 @@ nm_device_delete_async (<em class="parameter"><code><a class="link" href="NMDevi <p>Asynchronously begins deleteing the software device. Hardware devices can't be deleted.</p> <div class="refsect3"> -<a name="id-1.5.2.9.35.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.36.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1669,7 +1713,7 @@ nm_device_delete_finish (<em class="parameter"><code><a class="link" href="NMDev <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre> <p>Gets the result of a call to <a class="link" href="NMDevice.html#nm-device-delete-async" title="nm_device_delete_async ()"><code class="function">nm_device_delete_async()</code></a>.</p> <div class="refsect3"> -<a name="id-1.5.2.9.36.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.37.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1696,7 +1740,7 @@ nm_device_delete_finish (<em class="parameter"><code><a class="link" href="NMDev </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.36.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.37.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> on success, <code class="literal">FALSE</code> on error, in which case <em class="parameter"><code>error</code></em> will be set.</p> </div> @@ -1718,7 +1762,7 @@ Ethernet, Bluetooth, Wi-Fi WPA connections, or any other connection that is incompatible with the device. To get the full list of connections see <a class="link" href="NMClient.html#nm-client-get-connections" title="nm_client_get_connections ()"><code class="function">nm_client_get_connections()</code></a>.</p> <div class="refsect3"> -<a name="id-1.5.2.9.37.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.38.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1740,7 +1784,7 @@ incompatible with the device. To get the full list of connections see </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.37.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.38.6"></a><h4>Returns</h4> <p> an array of <a href="https://developer.gnome.org/libnm-util/0.9/NMConnection.html"><span class="type">NMConnections</span></a> that could be activated with the given <em class="parameter"><code>device</code></em> . The array @@ -1763,7 +1807,7 @@ network, and will not be valid if it describes a WPA network, or if it is an Ethernet, Bluetooth, WWAN, etc connection that is incompatible with the device.</p> <div class="refsect3"> -<a name="id-1.5.2.9.38.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.39.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1787,7 +1831,7 @@ against</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.38.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.39.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if the connection may be activated with this device, <code class="literal">FALSE</code> if is incompatible with the device's capabilities and characteristics.</p> </div> @@ -1811,7 +1855,7 @@ device.</p> compatibility of the given device and connection. But, in addition, it sets GError when FALSE is returned.</p> <div class="refsect3"> -<a name="id-1.5.2.9.39.6"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.40.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1840,7 +1884,7 @@ against</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.39.7"></a><h4>Returns</h4> +<a name="id-1.5.2.9.40.7"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if the connection may be activated with this device, <code class="literal">FALSE</code> if is incompatible with the device's capabilities and characteristics.</p> </div> @@ -1854,7 +1898,7 @@ nm_device_get_setting_type (<em class="parameter"><code><a class="link" href="NM that can be used on <em class="parameter"><code>device</code></em> .</p> <div class="refsect3"> -<a name="id-1.5.2.9.40.5"></a><h4>Parameters</h4> +<a name="id-1.5.2.9.41.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1869,7 +1913,7 @@ that can be used on <em class="parameter"><code>device</code></em> </table></div> </div> <div class="refsect3"> -<a name="id-1.5.2.9.40.6"></a><h4>Returns</h4> +<a name="id-1.5.2.9.41.6"></a><h4>Returns</h4> <p> <em class="parameter"><code>device</code></em> 's associated <a class="link" href="NMSetting.html" title="NMSetting"><span class="type">NMSetting</span></a> type</p> </div> @@ -2014,6 +2058,12 @@ that can be used on <em class="parameter"><code>device</code></em> <pre class="programlisting">#define NM_DEVICE_MTU "mtu" </pre> </div> +<hr> +<div class="refsect2"> +<a name="NM-DEVICE-METERED:CAPS"></a><h3>NM_DEVICE_METERED</h3> +<pre class="programlisting">#define NM_DEVICE_METERED "metered" +</pre> +</div> </div> <div class="refsect1"> <a name="NMDevice.property-details"></a><h2>Property Details</h2> @@ -2142,6 +2192,15 @@ operations like addressing and routing.</p> </div> <hr> <div class="refsect2"> +<a name="NMDevice--metered"></a><h3>The <code class="literal">“metered”</code> property</h3> +<pre class="programlisting"> “metered” <span class="type">guint</span></pre> +<p>Whether the device is metered.</p> +<p>Flags: Read</p> +<p>Default value: 0</p> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="NMDevice--mtu"></a><h3>The <code class="literal">“mtu”</code> property</h3> <pre class="programlisting"> “mtu” <span class="type">guint</span></pre> <p>The MTU of the device.</p> diff --git a/docs/libnm/html/NMDeviceWifi.html b/docs/libnm/html/NMDeviceWifi.html index db0dca479..776aba148 100644 --- a/docs/libnm/html/NMDeviceWifi.html +++ b/docs/libnm/html/NMDeviceWifi.html @@ -113,6 +113,14 @@ </tr> <tr> <td class="function_type"> +<span class="returnvalue">gboolean</span> +</td> +<td class="function_name"> +<a class="link" href="NMDeviceWifi.html#nm-device-wifi-request-scan-options" title="nm_device_wifi_request_scan_options ()">nm_device_wifi_request_scan_options</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type"> <span class="returnvalue">void</span> </td> <td class="function_name"> @@ -121,6 +129,14 @@ </tr> <tr> <td class="function_type"> +<span class="returnvalue">void</span> +</td> +<td class="function_name"> +<a class="link" href="NMDeviceWifi.html#nm-device-wifi-request-scan-options-async" title="nm_device_wifi_request_scan_options_async ()">nm_device_wifi_request_scan_options_async</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type"> <span class="returnvalue">gboolean</span> </td> <td class="function_name"> @@ -527,6 +543,64 @@ set.</p> </div> <hr> <div class="refsect2"> +<a name="nm-device-wifi-request-scan-options"></a><h3>nm_device_wifi_request_scan_options ()</h3> +<pre class="programlisting"><span class="returnvalue">gboolean</span> +nm_device_wifi_request_scan_options (<em class="parameter"><code><a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi"><span class="type">NMDeviceWifi</span></a> *device</code></em>, + <em class="parameter"><code><span class="type">GVariant</span> *options</code></em>, + <em class="parameter"><code><span class="type">GCancellable</span> *cancellable</code></em>, + <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre> +<p>Request NM to scan for access points on <em class="parameter"><code>device</code></em> +. Note that the function +returns immediately after requesting the scan, and it may take some time +after that for the scan to complete. +This is the same as <em class="parameter"><code>nm_device_wifi_request_scan</code></em> + except it accepts <em class="parameter"><code>options</code></em> + +for the scanning. The argument is the dictionary passed to <code class="function">RequestScan()</code> +D-Bus call. Valid otions inside the dictionary are: +'ssids' => array of SSIDs (saay)</p> +<div class="refsect3"> +<a name="id-1.5.14.9.11.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody> +<tr> +<td class="parameter_name"><p>device</p></td> +<td class="parameter_description"><p>a <a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi"><span class="type">NMDeviceWifi</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>options</p></td> +<td class="parameter_description"><p>dictionary with options for <code class="function">RequestScan()</code>, or <code class="literal">NULL</code></p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>cancellable</p></td> +<td class="parameter_description"><p>a <span class="type">GCancellable</span>, or <code class="literal">NULL</code></p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>error</p></td> +<td class="parameter_description"><p>location for a <span class="type">GError</span>, or <code class="literal">NULL</code></p></td> +<td class="parameter_annotations"> </td> +</tr> +</tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.5.14.9.11.6"></a><h4>Returns</h4> +<p> <code class="literal">TRUE</code> on success, <code class="literal">FALSE</code> on error, in which case <em class="parameter"><code>error</code></em> +will be +set.</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="nm-device-wifi-request-scan-async"></a><h3>nm_device_wifi_request_scan_async ()</h3> <pre class="programlisting"><span class="returnvalue">void</span> nm_device_wifi_request_scan_async (<em class="parameter"><code><a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi"><span class="type">NMDeviceWifi</span></a> *device</code></em>, @@ -539,7 +613,7 @@ nm_device_wifi_request_scan_async (<em class="parameter"><code><a class="link" h called immediately after requesting the scan, and it may take some time after that for the scan to complete.</p> <div class="refsect3"> -<a name="id-1.5.14.9.11.5"></a><h4>Parameters</h4> +<a name="id-1.5.14.9.12.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -574,6 +648,67 @@ that for the scan to complete.</p> </div> <hr> <div class="refsect2"> +<a name="nm-device-wifi-request-scan-options-async"></a><h3>nm_device_wifi_request_scan_options_async ()</h3> +<pre class="programlisting"><span class="returnvalue">void</span> +nm_device_wifi_request_scan_options_async + (<em class="parameter"><code><a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi"><span class="type">NMDeviceWifi</span></a> *device</code></em>, + <em class="parameter"><code><span class="type">GVariant</span> *options</code></em>, + <em class="parameter"><code><span class="type">GCancellable</span> *cancellable</code></em>, + <em class="parameter"><code><span class="type">GAsyncReadyCallback</span> callback</code></em>, + <em class="parameter"><code><span class="type">gpointer</span> user_data</code></em>);</pre> +<p>Request NM to scan for access points on <em class="parameter"><code>device</code></em> +. Note that <em class="parameter"><code>callback</code></em> + will be +called immediately after requesting the scan, and it may take some time after +that for the scan to complete. +This is the same as <em class="parameter"><code>nm_device_wifi_request_scan_async</code></em> + except it accepts <em class="parameter"><code>options</code></em> + +for the scanning. The argument is the dictionary passed to <code class="function">RequestScan()</code> +D-Bus call. Valid otions inside the dictionary are: +'ssids' => array of SSIDs (saay)</p> +<div class="refsect3"> +<a name="id-1.5.14.9.13.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody> +<tr> +<td class="parameter_name"><p>device</p></td> +<td class="parameter_description"><p>a <a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi"><span class="type">NMDeviceWifi</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>options</p></td> +<td class="parameter_description"><p>dictionary with options for <code class="function">RequestScan()</code>, or <code class="literal">NULL</code></p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>cancellable</p></td> +<td class="parameter_description"><p>a <span class="type">GCancellable</span>, or <code class="literal">NULL</code></p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>callback</p></td> +<td class="parameter_description"><p>callback to be called when the scan has been requested</p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>user_data</p></td> +<td class="parameter_description"><p>caller-specific data passed to <em class="parameter"><code>callback</code></em> +</p></td> +<td class="parameter_annotations"> </td> +</tr> +</tbody> +</table></div> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="nm-device-wifi-request-scan-finish"></a><h3>nm_device_wifi_request_scan_finish ()</h3> <pre class="programlisting"><span class="returnvalue">gboolean</span> nm_device_wifi_request_scan_finish (<em class="parameter"><code><a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi"><span class="type">NMDeviceWifi</span></a> *device</code></em>, @@ -581,7 +716,7 @@ nm_device_wifi_request_scan_finish (<em class="parameter"><code><a class="link" <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre> <p>Gets the result of a call to <a class="link" href="NMDeviceWifi.html#nm-device-wifi-request-scan-async" title="nm_device_wifi_request_scan_async ()"><code class="function">nm_device_wifi_request_scan_async()</code></a>.</p> <div class="refsect3"> -<a name="id-1.5.14.9.12.5"></a><h4>Parameters</h4> +<a name="id-1.5.14.9.14.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -608,7 +743,7 @@ nm_device_wifi_request_scan_finish (<em class="parameter"><code><a class="link" </table></div> </div> <div class="refsect3"> -<a name="id-1.5.14.9.12.6"></a><h4>Returns</h4> +<a name="id-1.5.14.9.14.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> on success, <code class="literal">FALSE</code> on error, in which case <em class="parameter"><code>error</code></em> will be set.</p> diff --git a/docs/libnm/html/NMSettingConnection.html b/docs/libnm/html/NMSettingConnection.html index f33e2b888..aef026589 100644 --- a/docs/libnm/html/NMSettingConnection.html +++ b/docs/libnm/html/NMSettingConnection.html @@ -241,6 +241,14 @@ <a class="link" href="NMSettingConnection.html#nm-setting-connection-get-gateway-ping-timeout" title="nm_setting_connection_get_gateway_ping_timeout ()">nm_setting_connection_get_gateway_ping_timeout</a> <span class="c_punctuation">()</span> </td> </tr> +<tr> +<td class="function_type"> +<a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered"><span class="returnvalue">NMMetered</span></a> +</td> +<td class="function_name"> +<a class="link" href="NMSettingConnection.html#nm-setting-connection-get-metered" title="nm_setting_connection_get_metered ()">nm_setting_connection_get_metered</a> <span class="c_punctuation">()</span> +</td> +</tr> </tbody> </table></div> </div> @@ -292,6 +300,11 @@ <td class="property_flags">Read / Write</td> </tr> <tr> +<td class="property_type"><a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered"><span class="type">NMMetered</span></a></td> +<td class="property_name"><a class="link" href="NMSettingConnection.html#NMSettingConnection--metered" title="The “metered” property">metered</a></td> +<td class="property_flags">Read / Write</td> +</tr> +<tr> <td class="property_type"><span class="type">GStrv</span></td> <td class="property_name"><a class="link" href="NMSettingConnection.html#NMSettingConnection--permissions" title="The “permissions” property">permissions</a></td> <td class="property_flags">Read / Write</td> @@ -423,6 +436,10 @@ <td class="function_name"><a class="link" href="NMSettingConnection.html#NM-SETTING-CONNECTION-GATEWAY-PING-TIMEOUT:CAPS" title="NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT">NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT</a></td> </tr> <tr> +<td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="NMSettingConnection.html#NM-SETTING-CONNECTION-METERED:CAPS" title="NM_SETTING_CONNECTION_METERED">NM_SETTING_CONNECTION_METERED</a></td> +</tr> +<tr> <td class="datatype_keyword">enum</td> <td class="function_name"><a class="link" href="NMSettingConnection.html#NMSettingConnectionAutoconnectSlaves" title="enum NMSettingConnectionAutoconnectSlaves">NMSettingConnectionAutoconnectSlaves</a></td> </tr> @@ -1264,6 +1281,32 @@ nm_setting_connection_get_gateway_ping_timeout property.</p> </div> </div> +<hr> +<div class="refsect2"> +<a name="nm-setting-connection-get-metered"></a><h3>nm_setting_connection_get_metered ()</h3> +<pre class="programlisting"><a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered"><span class="returnvalue">NMMetered</span></a> +nm_setting_connection_get_metered (<em class="parameter"><code><a class="link" href="NMSettingConnection.html" title="NMSettingConnection"><span class="type">NMSettingConnection</span></a> *setting</code></em>);</pre> +<div class="refsect3"> +<a name="id-1.4.5.8.28.4"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody><tr> +<td class="parameter_name"><p>setting</p></td> +<td class="parameter_description"><p>the <a class="link" href="NMSettingConnection.html" title="NMSettingConnection"><span class="type">NMSettingConnection</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr></tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.4.5.8.28.5"></a><h4>Returns</h4> +<p> the <a class="link" href="NMSettingConnection.html#NMSettingConnection--metered" title="The “metered” property"><span class="type">“metered”</span></a> property of the setting.</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> </div> <div class="refsect1"> <a name="NMSettingConnection.other_details"></a><h2>Types and Values</h2> @@ -1382,11 +1425,17 @@ property.</p> </div> <hr> <div class="refsect2"> +<a name="NM-SETTING-CONNECTION-METERED:CAPS"></a><h3>NM_SETTING_CONNECTION_METERED</h3> +<pre class="programlisting">#define NM_SETTING_CONNECTION_METERED "metered" +</pre> +</div> +<hr> +<div class="refsect2"> <a name="NMSettingConnectionAutoconnectSlaves"></a><h3>enum NMSettingConnectionAutoconnectSlaves</h3> <p><a class="link" href="NMSettingConnection.html#NMSettingConnectionAutoconnectSlaves" title="enum NMSettingConnectionAutoconnectSlaves"><span class="type">NMSettingConnectionAutoconnectSlaves</span></a> values indicate whether slave connections should be activated when master is activated.</p> <div class="refsect3"> -<a name="id-1.4.5.9.21.4"></a><h4>Members</h4> +<a name="id-1.4.5.9.22.4"></a><h4>Members</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="300px" class="enum_members_name"> @@ -1512,6 +1561,15 @@ connection may be applied to the wrong interface.</p> </div> <hr> <div class="refsect2"> +<a name="NMSettingConnection--metered"></a><h3>The <code class="literal">“metered”</code> property</h3> +<pre class="programlisting"> “metered” <a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered"><span class="type">NMMetered</span></a></pre> +<p>Whether the connection is metered.</p> +<p>Flags: Read / Write</p> +<p>Default value: NM_METERED_UNKNOWN</p> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="NMSettingConnection--permissions"></a><h3>The <code class="literal">“permissions”</code> property</h3> <pre class="programlisting"> “permissions” <span class="type">GStrv</span></pre> <p>An array of strings defining what access a given user has to this diff --git a/docs/libnm/html/NMSettingWired.html b/docs/libnm/html/NMSettingWired.html index 6255f6c83..1ee7de448 100644 --- a/docs/libnm/html/NMSettingWired.html +++ b/docs/libnm/html/NMSettingWired.html @@ -215,6 +215,21 @@ <a class="link" href="NMSettingWired.html#nm-setting-wired-get-valid-s390-options" title="nm_setting_wired_get_valid_s390_options ()">nm_setting_wired_get_valid_s390_options</a> <span class="c_punctuation">()</span> </td> </tr> +<tr> +<td class="function_type"> +<a class="link" href="NMSettingWired.html#NMSettingWiredWakeOnLan" title="enum NMSettingWiredWakeOnLan"><span class="returnvalue">NMSettingWiredWakeOnLan</span></a> +</td> +<td class="function_name"> +<a class="link" href="NMSettingWired.html#nm-setting-wired-get-wake-on-lan" title="nm_setting_wired_get_wake_on_lan ()">nm_setting_wired_get_wake_on_lan</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type">const <span class="returnvalue">char</span> * +</td> +<td class="function_name"> +<a class="link" href="NMSettingWired.html#nm-setting-wired-get-wake-on-lan-password" title="nm_setting_wired_get_wake_on_lan_password ()">nm_setting_wired_get_wake_on_lan_password</a> <span class="c_punctuation">()</span> +</td> +</tr> </tbody> </table></div> </div> @@ -288,6 +303,17 @@ <td class="property_name"><a class="link" href="NMSettingWired.html#NMSettingWired--speed" title="The “speed” property">speed</a></td> <td class="property_flags">Read / Write / Construct</td> </tr> +<tr> +<td class="property_type"><span class="type">guint</span></td> +<td class="property_name"><a class="link" href="NMSettingWired.html#NMSettingWired--wake-on-lan" title="The “wake-on-lan” property">wake-on-lan</a></td> +<td class="property_flags">Read / Write / Construct</td> +</tr> +<tr> +<td class="property_type"> +<span class="type">gchar</span> *</td> +<td class="property_name"><a class="link" href="NMSettingWired.html#NMSettingWired--wake-on-lan-password" title="The “wake-on-lan-password” property">wake-on-lan-password</a></td> +<td class="property_flags">Read / Write</td> +</tr> </tbody> </table></div> </div> @@ -304,6 +330,10 @@ <td class="function_name"><a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-SETTING-NAME:CAPS" title="NM_SETTING_WIRED_SETTING_NAME">NM_SETTING_WIRED_SETTING_NAME</a></td> </tr> <tr> +<td class="datatype_keyword">enum</td> +<td class="function_name"><a class="link" href="NMSettingWired.html#NMSettingWiredWakeOnLan" title="enum NMSettingWiredWakeOnLan">NMSettingWiredWakeOnLan</a></td> +</tr> +<tr> <td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-PORT:CAPS" title="NM_SETTING_WIRED_PORT">NM_SETTING_WIRED_PORT</a></td> </tr> @@ -347,12 +377,22 @@ <td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-S390-OPTIONS:CAPS" title="NM_SETTING_WIRED_S390_OPTIONS">NM_SETTING_WIRED_S390_OPTIONS</a></td> </tr> +<tr> +<td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN:CAPS" title="NM_SETTING_WIRED_WAKE_ON_LAN">NM_SETTING_WIRED_WAKE_ON_LAN</a></td> +</tr> +<tr> +<td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-PASSWORD:CAPS" title="NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD">NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD</a></td> +</tr> </tbody> </table></div> </div> <div class="refsect1"> <a name="NMSettingWired.object-hierarchy"></a><h2>Object Hierarchy</h2> -<pre class="screen"> GObject +<pre class="screen"> <a href="/usr/share/gtk-doc/html/gobject/gobject-Enumeration-and-Flag-Types.html">GFlags</a> + <span class="lineart">╰──</span> NMSettingWiredWakeOnLan + GObject <span class="lineart">╰──</span> <a class="link" href="NMSetting.html" title="NMSetting">NMSetting</a> <span class="lineart">╰──</span> NMSettingWired </pre> @@ -1055,6 +1095,62 @@ nm_setting_wired_get_valid_s390_options <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> </div> </div> +<hr> +<div class="refsect2"> +<a name="nm-setting-wired-get-wake-on-lan"></a><h3>nm_setting_wired_get_wake_on_lan ()</h3> +<pre class="programlisting"><a class="link" href="NMSettingWired.html#NMSettingWiredWakeOnLan" title="enum NMSettingWiredWakeOnLan"><span class="returnvalue">NMSettingWiredWakeOnLan</span></a> +nm_setting_wired_get_wake_on_lan (<em class="parameter"><code><a class="link" href="NMSettingWired.html" title="NMSettingWired"><span class="type">NMSettingWired</span></a> *setting</code></em>);</pre> +<p>Returns the Wake-on-LAN options enabled for the connection</p> +<div class="refsect3"> +<a name="id-1.4.29.8.25.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody><tr> +<td class="parameter_name"><p>setting</p></td> +<td class="parameter_description"><p>the <a class="link" href="NMSettingWired.html" title="NMSettingWired"><span class="type">NMSettingWired</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr></tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.4.29.8.25.6"></a><h4>Returns</h4> +<p> the Wake-on-LAN options</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> +<a name="nm-setting-wired-get-wake-on-lan-password"></a><h3>nm_setting_wired_get_wake_on_lan_password ()</h3> +<pre class="programlisting">const <span class="returnvalue">char</span> * +nm_setting_wired_get_wake_on_lan_password + (<em class="parameter"><code><a class="link" href="NMSettingWired.html" title="NMSettingWired"><span class="type">NMSettingWired</span></a> *setting</code></em>);</pre> +<p>Returns the Wake-on-LAN password. This only applies to +<a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-MAGIC:CAPS"><code class="literal">NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC</code></a>.</p> +<div class="refsect3"> +<a name="id-1.4.29.8.26.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody><tr> +<td class="parameter_name"><p>setting</p></td> +<td class="parameter_description"><p>the <a class="link" href="NMSettingWired.html" title="NMSettingWired"><span class="type">NMSettingWired</span></a></p></td> +<td class="parameter_annotations"> </td> +</tr></tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.4.29.8.26.6"></a><h4>Returns</h4> +<p> the Wake-on-LAN setting password, or <code class="literal">NULL</code> if there is no password.</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> </div> <div class="refsect1"> <a name="NMSettingWired.other_details"></a><h2>Types and Values</h2> @@ -1065,6 +1161,93 @@ nm_setting_wired_get_valid_s390_options </div> <hr> <div class="refsect2"> +<a name="NMSettingWiredWakeOnLan"></a><h3>enum NMSettingWiredWakeOnLan</h3> +<p>Options for <a class="link" href="NMSettingWired.html#NMSettingWired--wake-on-lan" title="The “wake-on-lan” property"><span class="type">“wake-on-lan”</span></a>. Note that not all options +are supported by all devices.</p> +<div class="refsect3"> +<a name="id-1.4.29.9.3.4"></a><h4>Members</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="300px" class="enum_members_name"> +<col class="enum_members_description"> +<col width="200px" class="enum_members_annotations"> +</colgroup> +<tbody> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-NONE:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_NONE</p></td> +<td class="enum_member_description"> +<p>Wake-on-LAN disabled</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-DEFAULT:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT</p></td> +<td class="enum_member_description"> +<p>Use the default value</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-PHY:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_PHY</p></td> +<td class="enum_member_description"> +<p>Wake on PHY activity</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-UNICAST:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST</p></td> +<td class="enum_member_description"> +<p>Wake on unicast messages</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-MULTICAST:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST</p></td> +<td class="enum_member_description"> +<p>Wake on multicast messages</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-BROADCAST:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST</p></td> +<td class="enum_member_description"> +<p>Wake on broadcast messages</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-ARP:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_ARP</p></td> +<td class="enum_member_description"> +<p>Wake on ARP</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-MAGIC:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC</p></td> +<td class="enum_member_description"> +<p>Wake on magic packet</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-LAST:CAPS"></a>_NM_SETTING_WIRED_WAKE_ON_LAN_LAST</p></td> +<td> </td> +<td> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-SETTING-WIRED-WAKE-ON-LAN-ALL:CAPS"></a>NM_SETTING_WIRED_WAKE_ON_LAN_ALL</p></td> +<td class="enum_member_description"> +<p>Wake on all events</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +</tbody> +</table></div> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="NM-SETTING-WIRED-PORT:CAPS"></a><h3>NM_SETTING_WIRED_PORT</h3> <pre class="programlisting">#define NM_SETTING_WIRED_PORT "port" </pre> @@ -1129,6 +1312,18 @@ nm_setting_wired_get_valid_s390_options <pre class="programlisting">#define NM_SETTING_WIRED_S390_OPTIONS "s390-options" </pre> </div> +<hr> +<div class="refsect2"> +<a name="NM-SETTING-WIRED-WAKE-ON-LAN:CAPS"></a><h3>NM_SETTING_WIRED_WAKE_ON_LAN</h3> +<pre class="programlisting">#define NM_SETTING_WIRED_WAKE_ON_LAN "wake-on-lan" +</pre> +</div> +<hr> +<div class="refsect2"> +<a name="NM-SETTING-WIRED-WAKE-ON-LAN-PASSWORD:CAPS"></a><h3>NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD</h3> +<pre class="programlisting">#define NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD "wake-on-lan-password" +</pre> +</div> </div> <div class="refsect1"> <a name="NMSettingWired.property-details"></a><h2>Property Details</h2> @@ -1241,6 +1436,30 @@ Mbit/s, ie 100 == 100Mbit/s.</p> <p>Flags: Read / Write / Construct</p> <p>Default value: 0</p> </div> +<hr> +<div class="refsect2"> +<a name="NMSettingWired--wake-on-lan"></a><h3>The <code class="literal">“wake-on-lan”</code> property</h3> +<pre class="programlisting"> “wake-on-lan” <span class="type">guint</span></pre> +<p>The <a class="link" href="NMSettingWired.html#NMSettingWiredWakeOnLan" title="enum NMSettingWiredWakeOnLan"><span class="type">NMSettingWiredWakeOnLan</span></a> options to enable. Not all devices support all options. +May be any combination of <a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-PHY:CAPS"><code class="literal">NM_SETTING_WIRED_WAKE_ON_LAN_PHY</code></a>, +<a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-UNICAST:CAPS"><code class="literal">NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST</code></a>, <a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-MULTICAST:CAPS"><code class="literal">NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST</code></a>, +<a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-BROADCAST:CAPS"><code class="literal">NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST</code></a>, <a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-ARP:CAPS"><code class="literal">NM_SETTING_WIRED_WAKE_ON_LAN_ARP</code></a>, +<a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-MAGIC:CAPS"><code class="literal">NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC</code></a>.</p> +<p>Flags: Read / Write / Construct</p> +<p>Default value: 1</p> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> +<a name="NMSettingWired--wake-on-lan-password"></a><h3>The <code class="literal">“wake-on-lan-password”</code> property</h3> +<pre class="programlisting"> “wake-on-lan-password” <span class="type">gchar</span> *</pre> +<p>If specified, the password used with magic-packet-based +Wake-on-LAN, represented as an Ethernet MAC address. If <code class="literal">NULL</code>, +no password will be required.</p> +<p>Flags: Read / Write</p> +<p>Default value: NULL</p> +<p class="since">Since: 1.0.6</p> +</div> </div> </div> <div class="footer"> diff --git a/docs/libnm/html/api-index-full.html b/docs/libnm/html/api-index-full.html index aac846df6..cc075c7dd 100644 --- a/docs/libnm/html/api-index-full.html +++ b/docs/libnm/html/api-index-full.html @@ -37,6 +37,8 @@ <span class="dim">|</span> <a class="shortcut" href="#idxS">S</a> <span class="dim">|</span> + <a class="shortcut" href="#idxT">T</a> + <span class="dim">|</span> <a class="shortcut" href="#idxU">U</a> <span class="dim">|</span> <a class="shortcut" href="#idxV">V</a> @@ -81,6 +83,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMAccessPoint.html#NMAccessPoint--last-seen" title="The “last-seen” property">NMAccessPoint:last-seen</a>, object property in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMAccessPoint.html#NMAccessPoint--max-bitrate" title="The “max-bitrate” property">NMAccessPoint:max-bitrate</a>, object property in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> </dt> <dd></dd> @@ -137,6 +143,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMAccessPoint.html#nm-access-point-get-last-seen" title="nm_access_point_get_last_seen ()">nm_access_point_get_last_seen</a>, function in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMAccessPoint.html#nm-access-point-get-max-bitrate" title="nm_access_point_get_max_bitrate ()">nm_access_point_get_max_bitrate</a>, function in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> </dt> <dd></dd> @@ -165,6 +175,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS" title="NM_ACCESS_POINT_LAST_SEEN">NM_ACCESS_POINT_LAST_SEEN</a>, macro in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMAccessPoint.html#NM-ACCESS-POINT-MAX-BITRATE:CAPS" title="NM_ACCESS_POINT_MAX_BITRATE">NM_ACCESS_POINT_MAX_BITRATE</a>, macro in <a class="link" href="NMAccessPoint.html" title="NMAccessPoint">NMAccessPoint</a> </dt> <dd></dd> @@ -396,6 +410,10 @@ <a class="link" href="libnm-nm-version.html#NM-AVAILABLE-IN-1-0-4:CAPS" title="NM_AVAILABLE_IN_1_0_4">NM_AVAILABLE_IN_1_0_4</a>, macro in <a class="link" href="libnm-nm-version.html" title="nm-version">nm-version</a> </dt> <dd></dd> +<dt> +<a class="link" href="libnm-nm-version.html#NM-AVAILABLE-IN-1-0-6:CAPS" title="NM_AVAILABLE_IN_1_0_6">NM_AVAILABLE_IN_1_0_6</a>, macro in <a class="link" href="libnm-nm-version.html" title="nm-version">nm-version</a> +</dt> +<dd></dd> <a name="idxB"></a><h3 class="title">B</h3> <dt> <a class="link" href="libnm-nm-dbus-interface.html#NMBluetoothCapabilities" title="enum NMBluetoothCapabilities">NMBluetoothCapabilities</a>, enum in <a class="link" href="libnm-nm-dbus-interface.html" title="nm-dbus-interface">nm-dbus-interface</a> @@ -455,6 +473,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMClient.html#NMClient--metered" title="The “metered” property">NMClient:metered</a>, object property in <a class="link" href="NMClient.html" title="NMClient">NMClient</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMClient.html#NMClient--networking-enabled" title="The “networking-enabled” property">NMClient:networking-enabled</a>, object property in <a class="link" href="NMClient.html" title="NMClient">NMClient</a> </dt> <dd></dd> @@ -695,6 +717,10 @@ </dt> <dd></dd> <dt> +<a class="link" href="NMClient.html#NM-CLIENT-METERED:CAPS" title="NM_CLIENT_METERED">NM_CLIENT_METERED</a>, macro in <a class="link" href="NMClient.html" title="NMClient">NMClient</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMClient.html#NM-CLIENT-NETWORKING-ENABLED:CAPS" title="NM_CLIENT_NETWORKING_ENABLED">NM_CLIENT_NETWORKING_ENABLED</a>, macro in <a class="link" href="NMClient.html" title="NMClient">NMClient</a> </dt> <dd></dd> @@ -1440,6 +1466,10 @@ DEFINE_KF_WRAPPER_PROTO, macro in nm-keyfile-utils </dt> <dd></dd> <dt> +<a class="link" href="NMDevice.html#NMDevice--metered" title="The “metered” property">NMDevice:metered</a>, object property in <a class="link" href="NMDevice.html" title="NMDevice">NMDevice</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMDevice.html#NMDevice--mtu" title="The “mtu” property">NMDevice:mtu</a>, object property in <a class="link" href="NMDevice.html" title="NMDevice">NMDevice</a> </dt> <dd></dd> @@ -1980,6 +2010,10 @@ DEFINE_KF_WRAPPER_PROTO, macro in nm-keyfile-utils </dt> <dd></dd> <dt> +<a class="link" href="NMDevice.html#nm-device-get-metered" title="nm_device_get_metered ()">nm_device_get_metered</a>, function in <a class="link" href="NMDevice.html" title="NMDevice">NMDevice</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMDevice.html#nm-device-get-mtu" title="nm_device_get_mtu ()">nm_device_get_mtu</a>, function in <a class="link" href="NMDevice.html" title="NMDevice">NMDevice</a> </dt> <dd></dd> @@ -2056,6 +2090,10 @@ DEFINE_KF_WRAPPER_PROTO, macro in nm-keyfile-utils </dt> <dd></dd> <dt> +<a class="link" href="NMDevice.html#NM-DEVICE-METERED:CAPS" title="NM_DEVICE_METERED">NM_DEVICE_METERED</a>, macro in <a class="link" href="NMDevice.html" title="NMDevice">NMDevice</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMDeviceModem.html#NM-DEVICE-MODEM-CURRENT-CAPABILITIES:CAPS" title="NM_DEVICE_MODEM_CURRENT_CAPABILITIES">NM_DEVICE_MODEM_CURRENT_CAPABILITIES</a>, macro in <a class="link" href="NMDeviceModem.html" title="NMDeviceModem">NMDeviceModem</a> </dt> <dd></dd> @@ -2256,6 +2294,14 @@ DEFINE_KF_WRAPPER_PROTO, macro in nm-keyfile-utils </dt> <dd></dd> <dt> +<a class="link" href="NMDeviceWifi.html#nm-device-wifi-request-scan-options" title="nm_device_wifi_request_scan_options ()">nm_device_wifi_request_scan_options</a>, function in <a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi">NMDeviceWifi</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="NMDeviceWifi.html#nm-device-wifi-request-scan-options-async" title="nm_device_wifi_request_scan_options_async ()">nm_device_wifi_request_scan_options_async</a>, function in <a class="link" href="NMDeviceWifi.html" title="NMDeviceWifi">NMDeviceWifi</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMDeviceWimax.html#NM-DEVICE-WIMAX-ACTIVE-NSP:CAPS" title="NM_DEVICE_WIMAX_ACTIVE_NSP">NM_DEVICE_WIMAX_ACTIVE_NSP</a>, macro in <a class="link" href="NMDeviceWimax.html" title="NMDeviceWimax">NMDeviceWimax</a> </dt> <dd></dd> @@ -2696,6 +2742,10 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered">NMMetered</a>, enum in <a class="link" href="libnm-nm-dbus-interface.html" title="nm-dbus-interface">nm-dbus-interface</a> +</dt> +<dd></dd> +<dt> <a class="link" href="libnm-nm-version.html#NM-MICRO-VERSION:CAPS" title="NM_MICRO_VERSION">NM_MICRO_VERSION</a>, macro in <a class="link" href="libnm-nm-version.html" title="nm-version">nm-version</a> </dt> <dd></dd> @@ -3195,6 +3245,10 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="NMSettingConnection.html#NMSettingConnection--metered" title="The “metered” property">NMSettingConnection:metered</a>, object property in <a class="link" href="NMSettingConnection.html" title="NMSettingConnection">NMSettingConnection</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMSettingConnection.html#NMSettingConnection--permissions" title="The “permissions” property">NMSettingConnection:permissions</a>, object property in <a class="link" href="NMSettingConnection.html" title="NMSettingConnection">NMSettingConnection</a> </dt> <dd></dd> @@ -3663,6 +3717,18 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="NMSettingWired.html#NMSettingWired--wake-on-lan" title="The “wake-on-lan” property">NMSettingWired:wake-on-lan</a>, object property in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="NMSettingWired.html#NMSettingWired--wake-on-lan-password" title="The “wake-on-lan-password” property">NMSettingWired:wake-on-lan-password</a>, object property in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="NMSettingWired.html#NMSettingWiredWakeOnLan" title="enum NMSettingWiredWakeOnLan">NMSettingWiredWakeOnLan</a>, enum in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMSettingWireless.html#NMSettingWireless--band" title="The “band” property">NMSettingWireless:band</a>, object property in <a class="link" href="NMSettingWireless.html" title="NMSettingWireless">NMSettingWireless</a> </dt> <dd></dd> @@ -4619,6 +4685,10 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="NMSettingConnection.html#nm-setting-connection-get-metered" title="nm_setting_connection_get_metered ()">nm_setting_connection_get_metered</a>, function in <a class="link" href="NMSettingConnection.html" title="NMSettingConnection">NMSettingConnection</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMSettingConnection.html#nm-setting-connection-get-num-permissions" title="nm_setting_connection_get_num_permissions ()">nm_setting_connection_get_num_permissions</a>, function in <a class="link" href="NMSettingConnection.html" title="NMSettingConnection">NMSettingConnection</a> </dt> <dd></dd> @@ -4671,6 +4741,10 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="NMSettingConnection.html#NM-SETTING-CONNECTION-METERED:CAPS" title="NM_SETTING_CONNECTION_METERED">NM_SETTING_CONNECTION_METERED</a>, macro in <a class="link" href="NMSettingConnection.html" title="NMSettingConnection">NMSettingConnection</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMSettingConnection.html#nm-setting-connection-new" title="nm_setting_connection_new ()">nm_setting_connection_new</a>, function in <a class="link" href="NMSettingConnection.html" title="NMSettingConnection">NMSettingConnection</a> </dt> <dd></dd> @@ -5915,6 +5989,14 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="NMSettingWired.html#nm-setting-wired-get-wake-on-lan" title="nm_setting_wired_get_wake_on_lan ()">nm_setting_wired_get_wake_on_lan</a>, function in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="NMSettingWired.html#nm-setting-wired-get-wake-on-lan-password" title="nm_setting_wired_get_wake_on_lan_password ()">nm_setting_wired_get_wake_on_lan_password</a>, function in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-MAC-ADDRESS:CAPS" title="NM_SETTING_WIRED_MAC_ADDRESS">NM_SETTING_WIRED_MAC_ADDRESS</a>, macro in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> </dt> <dd></dd> @@ -5967,6 +6049,14 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN:CAPS" title="NM_SETTING_WIRED_WAKE_ON_LAN">NM_SETTING_WIRED_WAKE_ON_LAN</a>, macro in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-PASSWORD:CAPS" title="NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD">NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD</a>, macro in <a class="link" href="NMSettingWired.html" title="NMSettingWired">NMSettingWired</a> +</dt> +<dd></dd> +<dt> <a class="link" href="NMSettingWireless.html#nm-setting-wireless-add-mac-blacklist-item" title="nm_setting_wireless_add_mac_blacklist_item ()">nm_setting_wireless_add_mac_blacklist_item</a>, function in <a class="link" href="NMSettingWireless.html" title="NMSettingWireless">NMSettingWireless</a> </dt> <dd></dd> @@ -6338,6 +6428,19 @@ nm_keyfile_write, function in nm-keyfile-internal <a class="link" href="libnm-nm-dbus-interface.html#NMState" title="enum NMState">NMState</a>, enum in <a class="link" href="libnm-nm-dbus-interface.html" title="nm-dbus-interface">nm-dbus-interface</a> </dt> <dd></dd> +<a name="idxT"></a><h3 class="title">T</h3> +<dt> +NMTestGeneralBoolEnum, enum in test-general-enums +</dt> +<dd></dd> +<dt> +NMTestGeneralColorFlags, enum in test-general-enums +</dt> +<dd></dd> +<dt> +NMTestGeneralMetaFlags, enum in test-general-enums +</dt> +<dd></dd> <a name="idxU"></a><h3 class="title">U</h3> <dt> <a class="link" href="libnm-nm-utils.html#NMUtilsFileSearchInPathsPredicate" title="NMUtilsFileSearchInPathsPredicate ()">NMUtilsFileSearchInPathsPredicate</a>, user_function in <a class="link" href="libnm-nm-utils.html" title="nm-utils">nm-utils</a> @@ -6360,6 +6463,14 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="libnm-nm-utils.html#nm-utils-enum-from-str" title="nm_utils_enum_from_str ()">nm_utils_enum_from_str</a>, function in <a class="link" href="libnm-nm-utils.html" title="nm-utils">nm-utils</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="libnm-nm-utils.html#nm-utils-enum-to-str" title="nm_utils_enum_to_str ()">nm_utils_enum_to_str</a>, function in <a class="link" href="libnm-nm-utils.html" title="nm-utils">nm-utils</a> +</dt> +<dd></dd> +<dt> <a class="link" href="libnm-nm-utils.html#nm-utils-escape-ssid" title="nm_utils_escape_ssid ()">nm_utils_escape_ssid</a>, function in <a class="link" href="libnm-nm-utils.html" title="nm-utils">nm-utils</a> </dt> <dd></dd> @@ -6540,6 +6651,14 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="libnm-nm-utils.html#nm-utils-wifi-2ghz-freqs" title="nm_utils_wifi_2ghz_freqs ()">nm_utils_wifi_2ghz_freqs</a>, function in <a class="link" href="libnm-nm-utils.html" title="nm-utils">nm-utils</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="libnm-nm-utils.html#nm-utils-wifi-5ghz-freqs" title="nm_utils_wifi_5ghz_freqs ()">nm_utils_wifi_5ghz_freqs</a>, function in <a class="link" href="libnm-nm-utils.html" title="nm-utils">nm-utils</a> +</dt> +<dd></dd> +<dt> <a class="link" href="libnm-nm-utils.html#nm-utils-wifi-channel-to-freq" title="nm_utils_wifi_channel_to_freq ()">nm_utils_wifi_channel_to_freq</a>, function in <a class="link" href="libnm-nm-utils.html" title="nm-utils">nm-utils</a> </dt> <dd></dd> @@ -6589,6 +6708,14 @@ nm_keyfile_write, function in nm-keyfile-internal </dt> <dd></dd> <dt> +<a class="link" href="libnm-nm-version.html#NM-VERSION-1-0-6:CAPS" title="NM_VERSION_1_0_6">NM_VERSION_1_0_6</a>, macro in <a class="link" href="libnm-nm-version.html" title="nm-version">nm-version</a> +</dt> +<dd></dd> +<dt> +<a class="link" href="libnm-nm-version.html#NM-VERSION-1-0-8:CAPS" title="NM_VERSION_1_0_8">NM_VERSION_1_0_8</a>, macro in <a class="link" href="libnm-nm-version.html" title="nm-version">nm-version</a> +</dt> +<dd></dd> +<dt> <a class="link" href="libnm-nm-version.html#NM-VERSION-CUR-STABLE:CAPS" title="NM_VERSION_CUR_STABLE">NM_VERSION_CUR_STABLE</a>, macro in <a class="link" href="libnm-nm-version.html" title="nm-version">nm-version</a> </dt> <dd></dd> diff --git a/docs/libnm/html/index.html b/docs/libnm/html/index.html index f197c752c..1e7720842 100644 --- a/docs/libnm/html/index.html +++ b/docs/libnm/html/index.html @@ -15,7 +15,7 @@ <div> <div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">libnm Reference Manual</p></th></tr></table></div> <div><p class="releaseinfo"> - for libnm 1.0.4 + for libnm 1.0.6 The latest version of this documentation can be found on-line at <a class="ulink" href="https://developer.gnome.org/libnm/1.0/" target="_top">https://developer.gnome.org/libnm/1.0/</a>. diff --git a/docs/libnm/html/index.sgml b/docs/libnm/html/index.sgml index 0f085cb34..946d38181 100644 --- a/docs/libnm/html/index.sgml +++ b/docs/libnm/html/index.sgml @@ -81,6 +81,7 @@ <ANCHOR id="NM-CLIENT-CONNECTIONS:CAPS" href="libnm/NMClient.html#NM-CLIENT-CONNECTIONS:CAPS"> <ANCHOR id="NM-CLIENT-HOSTNAME:CAPS" href="libnm/NMClient.html#NM-CLIENT-HOSTNAME:CAPS"> <ANCHOR id="NM-CLIENT-CAN-MODIFY:CAPS" href="libnm/NMClient.html#NM-CLIENT-CAN-MODIFY:CAPS"> +<ANCHOR id="NM-CLIENT-METERED:CAPS" href="libnm/NMClient.html#NM-CLIENT-METERED:CAPS"> <ANCHOR id="NM-CLIENT-DEVICE-ADDED:CAPS" href="libnm/NMClient.html#NM-CLIENT-DEVICE-ADDED:CAPS"> <ANCHOR id="NM-CLIENT-DEVICE-REMOVED:CAPS" href="libnm/NMClient.html#NM-CLIENT-DEVICE-REMOVED:CAPS"> <ANCHOR id="NM-CLIENT-PERMISSION-CHANGED:CAPS" href="libnm/NMClient.html#NM-CLIENT-PERMISSION-CHANGED:CAPS"> @@ -118,6 +119,7 @@ <ANCHOR id="NMClient--connectivity" href="libnm/NMClient.html#NMClient--connectivity"> <ANCHOR id="NMClient--devices" href="libnm/NMClient.html#NMClient--devices"> <ANCHOR id="NMClient--hostname" href="libnm/NMClient.html#NMClient--hostname"> +<ANCHOR id="NMClient--metered" href="libnm/NMClient.html#NMClient--metered"> <ANCHOR id="NMClient--networking-enabled" href="libnm/NMClient.html#NMClient--networking-enabled"> <ANCHOR id="NMClient--nm-running" href="libnm/NMClient.html#NMClient--nm-running"> <ANCHOR id="NMClient--primary-connection" href="libnm/NMClient.html#NMClient--primary-connection"> @@ -479,6 +481,12 @@ <ANCHOR id="NM-DEVICE-STATE-REASON-NEW-ACTIVATION:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-DEVICE-STATE-REASON-NEW-ACTIVATION:CAPS"> <ANCHOR id="NM-DEVICE-STATE-REASON-PARENT-CHANGED:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-DEVICE-STATE-REASON-PARENT-CHANGED:CAPS"> <ANCHOR id="NM-DEVICE-STATE-REASON-PARENT-MANAGED-CHANGED:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-DEVICE-STATE-REASON-PARENT-MANAGED-CHANGED:CAPS"> +<ANCHOR id="NMMetered" href="libnm/libnm-nm-dbus-interface.html#NMMetered"> +<ANCHOR id="NM-METERED-UNKNOWN:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-METERED-UNKNOWN:CAPS"> +<ANCHOR id="NM-METERED-YES:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-METERED-YES:CAPS"> +<ANCHOR id="NM-METERED-NO:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-METERED-NO:CAPS"> +<ANCHOR id="NM-METERED-GUESS-YES:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-METERED-GUESS-YES:CAPS"> +<ANCHOR id="NM-METERED-GUESS-NO:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-METERED-GUESS-NO:CAPS"> <ANCHOR id="NMActiveConnectionState" href="libnm/libnm-nm-dbus-interface.html#NMActiveConnectionState"> <ANCHOR id="NM-ACTIVE-CONNECTION-STATE-UNKNOWN:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-ACTIVE-CONNECTION-STATE-UNKNOWN:CAPS"> <ANCHOR id="NM-ACTIVE-CONNECTION-STATE-ACTIVATING:CAPS" href="libnm/libnm-nm-dbus-interface.html#NM-ACTIVE-CONNECTION-STATE-ACTIVATING:CAPS"> @@ -657,6 +665,7 @@ <ANCHOR id="nm-setting-connection-remove-secondary" href="libnm/NMSettingConnection.html#nm-setting-connection-remove-secondary"> <ANCHOR id="nm-setting-connection-remove-secondary-by-value" href="libnm/NMSettingConnection.html#nm-setting-connection-remove-secondary-by-value"> <ANCHOR id="nm-setting-connection-get-gateway-ping-timeout" href="libnm/NMSettingConnection.html#nm-setting-connection-get-gateway-ping-timeout"> +<ANCHOR id="nm-setting-connection-get-metered" href="libnm/NMSettingConnection.html#nm-setting-connection-get-metered"> <ANCHOR id="NMSettingConnection.other_details" href="libnm/NMSettingConnection.html#NMSettingConnection.other_details"> <ANCHOR id="NM-SETTING-CONNECTION-SETTING-NAME:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-SETTING-NAME:CAPS"> <ANCHOR id="NM-SETTING-CONNECTION-AUTOCONNECT-PRIORITY-MIN:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-AUTOCONNECT-PRIORITY-MIN:CAPS"> @@ -677,6 +686,7 @@ <ANCHOR id="NM-SETTING-CONNECTION-AUTOCONNECT-SLAVES:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-AUTOCONNECT-SLAVES:CAPS"> <ANCHOR id="NM-SETTING-CONNECTION-SECONDARIES:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-SECONDARIES:CAPS"> <ANCHOR id="NM-SETTING-CONNECTION-GATEWAY-PING-TIMEOUT:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-GATEWAY-PING-TIMEOUT:CAPS"> +<ANCHOR id="NM-SETTING-CONNECTION-METERED:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-METERED:CAPS"> <ANCHOR id="NMSettingConnectionAutoconnectSlaves" href="libnm/NMSettingConnection.html#NMSettingConnectionAutoconnectSlaves"> <ANCHOR id="NM-SETTING-CONNECTION-AUTOCONNECT-SLAVES-DEFAULT:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-AUTOCONNECT-SLAVES-DEFAULT:CAPS"> <ANCHOR id="NM-SETTING-CONNECTION-AUTOCONNECT-SLAVES-NO:CAPS" href="libnm/NMSettingConnection.html#NM-SETTING-CONNECTION-AUTOCONNECT-SLAVES-NO:CAPS"> @@ -690,6 +700,7 @@ <ANCHOR id="NMSettingConnection--id" href="libnm/NMSettingConnection.html#NMSettingConnection--id"> <ANCHOR id="NMSettingConnection--interface-name" href="libnm/NMSettingConnection.html#NMSettingConnection--interface-name"> <ANCHOR id="NMSettingConnection--master" href="libnm/NMSettingConnection.html#NMSettingConnection--master"> +<ANCHOR id="NMSettingConnection--metered" href="libnm/NMSettingConnection.html#NMSettingConnection--metered"> <ANCHOR id="NMSettingConnection--permissions" href="libnm/NMSettingConnection.html#NMSettingConnection--permissions"> <ANCHOR id="NMSettingConnection--read-only" href="libnm/NMSettingConnection.html#NMSettingConnection--read-only"> <ANCHOR id="NMSettingConnection--secondaries" href="libnm/NMSettingConnection.html#NMSettingConnection--secondaries"> @@ -1601,8 +1612,21 @@ <ANCHOR id="nm-setting-wired-add-s390-option" href="libnm/NMSettingWired.html#nm-setting-wired-add-s390-option"> <ANCHOR id="nm-setting-wired-remove-s390-option" href="libnm/NMSettingWired.html#nm-setting-wired-remove-s390-option"> <ANCHOR id="nm-setting-wired-get-valid-s390-options" href="libnm/NMSettingWired.html#nm-setting-wired-get-valid-s390-options"> +<ANCHOR id="nm-setting-wired-get-wake-on-lan" href="libnm/NMSettingWired.html#nm-setting-wired-get-wake-on-lan"> +<ANCHOR id="nm-setting-wired-get-wake-on-lan-password" href="libnm/NMSettingWired.html#nm-setting-wired-get-wake-on-lan-password"> <ANCHOR id="NMSettingWired.other_details" href="libnm/NMSettingWired.html#NMSettingWired.other_details"> <ANCHOR id="NM-SETTING-WIRED-SETTING-NAME:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-SETTING-NAME:CAPS"> +<ANCHOR id="NMSettingWiredWakeOnLan" href="libnm/NMSettingWired.html#NMSettingWiredWakeOnLan"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-NONE:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-NONE:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-DEFAULT:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-DEFAULT:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-PHY:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-PHY:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-UNICAST:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-UNICAST:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-MULTICAST:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-MULTICAST:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-BROADCAST:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-BROADCAST:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-ARP:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-ARP:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-MAGIC:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-MAGIC:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-LAST:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-LAST:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-ALL:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-ALL:CAPS"> <ANCHOR id="NM-SETTING-WIRED-PORT:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-PORT:CAPS"> <ANCHOR id="NM-SETTING-WIRED-SPEED:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-SPEED:CAPS"> <ANCHOR id="NM-SETTING-WIRED-DUPLEX:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-DUPLEX:CAPS"> @@ -1614,6 +1638,8 @@ <ANCHOR id="NM-SETTING-WIRED-S390-SUBCHANNELS:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-S390-SUBCHANNELS:CAPS"> <ANCHOR id="NM-SETTING-WIRED-S390-NETTYPE:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-S390-NETTYPE:CAPS"> <ANCHOR id="NM-SETTING-WIRED-S390-OPTIONS:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-S390-OPTIONS:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN:CAPS"> +<ANCHOR id="NM-SETTING-WIRED-WAKE-ON-LAN-PASSWORD:CAPS" href="libnm/NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-PASSWORD:CAPS"> <ANCHOR id="NMSettingWired.property-details" href="libnm/NMSettingWired.html#NMSettingWired.property-details"> <ANCHOR id="NMSettingWired--auto-negotiate" href="libnm/NMSettingWired.html#NMSettingWired--auto-negotiate"> <ANCHOR id="NMSettingWired--cloned-mac-address" href="libnm/NMSettingWired.html#NMSettingWired--cloned-mac-address"> @@ -1626,6 +1652,8 @@ <ANCHOR id="NMSettingWired--s390-options" href="libnm/NMSettingWired.html#NMSettingWired--s390-options"> <ANCHOR id="NMSettingWired--s390-subchannels" href="libnm/NMSettingWired.html#NMSettingWired--s390-subchannels"> <ANCHOR id="NMSettingWired--speed" href="libnm/NMSettingWired.html#NMSettingWired--speed"> +<ANCHOR id="NMSettingWired--wake-on-lan" href="libnm/NMSettingWired.html#NMSettingWired--wake-on-lan"> +<ANCHOR id="NMSettingWired--wake-on-lan-password" href="libnm/NMSettingWired.html#NMSettingWired--wake-on-lan-password"> <ANCHOR id="NMSettingWireless" href="libnm/NMSettingWireless.html"> <ANCHOR id="NMSettingWireless.functions" href="libnm/NMSettingWireless.html#NMSettingWireless.functions"> <ANCHOR id="NMSettingWireless.properties" href="libnm/NMSettingWireless.html#NMSettingWireless.properties"> @@ -1804,6 +1832,7 @@ <ANCHOR id="nm-device-get-product" href="libnm/NMDevice.html#nm-device-get-product"> <ANCHOR id="nm-device-get-vendor" href="libnm/NMDevice.html#nm-device-get-vendor"> <ANCHOR id="nm-device-get-description" href="libnm/NMDevice.html#nm-device-get-description"> +<ANCHOR id="nm-device-get-metered" href="libnm/NMDevice.html#nm-device-get-metered"> <ANCHOR id="nm-device-disambiguate-names" href="libnm/NMDevice.html#nm-device-disambiguate-names"> <ANCHOR id="nm-device-disconnect" href="libnm/NMDevice.html#nm-device-disconnect"> <ANCHOR id="nm-device-disconnect-async" href="libnm/NMDevice.html#nm-device-disconnect-async"> @@ -1839,6 +1868,7 @@ <ANCHOR id="NM-DEVICE-PRODUCT:CAPS" href="libnm/NMDevice.html#NM-DEVICE-PRODUCT:CAPS"> <ANCHOR id="NM-DEVICE-PHYSICAL-PORT-ID:CAPS" href="libnm/NMDevice.html#NM-DEVICE-PHYSICAL-PORT-ID:CAPS"> <ANCHOR id="NM-DEVICE-MTU:CAPS" href="libnm/NMDevice.html#NM-DEVICE-MTU:CAPS"> +<ANCHOR id="NM-DEVICE-METERED:CAPS" href="libnm/NMDevice.html#NM-DEVICE-METERED:CAPS"> <ANCHOR id="NMDevice.property-details" href="libnm/NMDevice.html#NMDevice.property-details"> <ANCHOR id="NMDevice--active-connection" href="libnm/NMDevice.html#NMDevice--active-connection"> <ANCHOR id="NMDevice--autoconnect" href="libnm/NMDevice.html#NMDevice--autoconnect"> @@ -1856,6 +1886,7 @@ <ANCHOR id="NMDevice--ip4-config" href="libnm/NMDevice.html#NMDevice--ip4-config"> <ANCHOR id="NMDevice--ip6-config" href="libnm/NMDevice.html#NMDevice--ip6-config"> <ANCHOR id="NMDevice--managed" href="libnm/NMDevice.html#NMDevice--managed"> +<ANCHOR id="NMDevice--metered" href="libnm/NMDevice.html#NMDevice--metered"> <ANCHOR id="NMDevice--mtu" href="libnm/NMDevice.html#NMDevice--mtu"> <ANCHOR id="NMDevice--physical-port-id" href="libnm/NMDevice.html#NMDevice--physical-port-id"> <ANCHOR id="NMDevice--product" href="libnm/NMDevice.html#NMDevice--product"> @@ -2070,7 +2101,9 @@ <ANCHOR id="nm-device-wifi-get-access-point-by-path" href="libnm/NMDeviceWifi.html#nm-device-wifi-get-access-point-by-path"> <ANCHOR id="nm-device-wifi-get-access-points" href="libnm/NMDeviceWifi.html#nm-device-wifi-get-access-points"> <ANCHOR id="nm-device-wifi-request-scan" href="libnm/NMDeviceWifi.html#nm-device-wifi-request-scan"> +<ANCHOR id="nm-device-wifi-request-scan-options" href="libnm/NMDeviceWifi.html#nm-device-wifi-request-scan-options"> <ANCHOR id="nm-device-wifi-request-scan-async" href="libnm/NMDeviceWifi.html#nm-device-wifi-request-scan-async"> +<ANCHOR id="nm-device-wifi-request-scan-options-async" href="libnm/NMDeviceWifi.html#nm-device-wifi-request-scan-options-async"> <ANCHOR id="nm-device-wifi-request-scan-finish" href="libnm/NMDeviceWifi.html#nm-device-wifi-request-scan-finish"> <ANCHOR id="NMDeviceWifi.other_details" href="libnm/NMDeviceWifi.html#NMDeviceWifi.other_details"> <ANCHOR id="NM-DEVICE-WIFI-HW-ADDRESS:CAPS" href="libnm/NMDeviceWifi.html#NM-DEVICE-WIFI-HW-ADDRESS:CAPS"> @@ -2246,6 +2279,7 @@ <ANCHOR id="nm-access-point-get-mode" href="libnm/NMAccessPoint.html#nm-access-point-get-mode"> <ANCHOR id="nm-access-point-get-max-bitrate" href="libnm/NMAccessPoint.html#nm-access-point-get-max-bitrate"> <ANCHOR id="nm-access-point-get-strength" href="libnm/NMAccessPoint.html#nm-access-point-get-strength"> +<ANCHOR id="nm-access-point-get-last-seen" href="libnm/NMAccessPoint.html#nm-access-point-get-last-seen"> <ANCHOR id="nm-access-point-filter-connections" href="libnm/NMAccessPoint.html#nm-access-point-filter-connections"> <ANCHOR id="nm-access-point-connection-valid" href="libnm/NMAccessPoint.html#nm-access-point-connection-valid"> <ANCHOR id="NMAccessPoint.other_details" href="libnm/NMAccessPoint.html#NMAccessPoint.other_details"> @@ -2258,12 +2292,14 @@ <ANCHOR id="NM-ACCESS-POINT-MODE:CAPS" href="libnm/NMAccessPoint.html#NM-ACCESS-POINT-MODE:CAPS"> <ANCHOR id="NM-ACCESS-POINT-MAX-BITRATE:CAPS" href="libnm/NMAccessPoint.html#NM-ACCESS-POINT-MAX-BITRATE:CAPS"> <ANCHOR id="NM-ACCESS-POINT-STRENGTH:CAPS" href="libnm/NMAccessPoint.html#NM-ACCESS-POINT-STRENGTH:CAPS"> +<ANCHOR id="NM-ACCESS-POINT-LAST-SEEN:CAPS" href="libnm/NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS"> <ANCHOR id="NM-ACCESS-POINT-HW-ADDRESS:CAPS" href="libnm/NMAccessPoint.html#NM-ACCESS-POINT-HW-ADDRESS:CAPS"> <ANCHOR id="NMAccessPoint.property-details" href="libnm/NMAccessPoint.html#NMAccessPoint.property-details"> <ANCHOR id="NMAccessPoint--bssid" href="libnm/NMAccessPoint.html#NMAccessPoint--bssid"> <ANCHOR id="NMAccessPoint--flags" href="libnm/NMAccessPoint.html#NMAccessPoint--flags"> <ANCHOR id="NMAccessPoint--frequency" href="libnm/NMAccessPoint.html#NMAccessPoint--frequency"> <ANCHOR id="NMAccessPoint--hw-address" href="libnm/NMAccessPoint.html#NMAccessPoint--hw-address"> +<ANCHOR id="NMAccessPoint--last-seen" href="libnm/NMAccessPoint.html#NMAccessPoint--last-seen"> <ANCHOR id="NMAccessPoint--max-bitrate" href="libnm/NMAccessPoint.html#NMAccessPoint--max-bitrate"> <ANCHOR id="NMAccessPoint--mode" href="libnm/NMAccessPoint.html#NMAccessPoint--mode"> <ANCHOR id="NMAccessPoint--rsn-flags" href="libnm/NMAccessPoint.html#NMAccessPoint--rsn-flags"> @@ -2387,6 +2423,8 @@ <ANCHOR id="nm-utils-wifi-channel-to-freq" href="libnm/libnm-nm-utils.html#nm-utils-wifi-channel-to-freq"> <ANCHOR id="nm-utils-wifi-find-next-channel" href="libnm/libnm-nm-utils.html#nm-utils-wifi-find-next-channel"> <ANCHOR id="nm-utils-wifi-is-channel-valid" href="libnm/libnm-nm-utils.html#nm-utils-wifi-is-channel-valid"> +<ANCHOR id="nm-utils-wifi-2ghz-freqs" href="libnm/libnm-nm-utils.html#nm-utils-wifi-2ghz-freqs"> +<ANCHOR id="nm-utils-wifi-5ghz-freqs" href="libnm/libnm-nm-utils.html#nm-utils-wifi-5ghz-freqs"> <ANCHOR id="nm-utils-wifi-strength-bars" href="libnm/libnm-nm-utils.html#nm-utils-wifi-strength-bars"> <ANCHOR id="nm-utils-hwaddr-len" href="libnm/libnm-nm-utils.html#nm-utils-hwaddr-len"> <ANCHOR id="nm-utils-hwaddr-ntoa" href="libnm/libnm-nm-utils.html#nm-utils-hwaddr-ntoa"> @@ -2403,6 +2441,8 @@ <ANCHOR id="nm-utils-inet6-ntop" href="libnm/libnm-nm-utils.html#nm-utils-inet6-ntop"> <ANCHOR id="nm-utils-ipaddr-valid" href="libnm/libnm-nm-utils.html#nm-utils-ipaddr-valid"> <ANCHOR id="nm-utils-check-virtual-device-compatibility" href="libnm/libnm-nm-utils.html#nm-utils-check-virtual-device-compatibility"> +<ANCHOR id="nm-utils-enum-to-str" href="libnm/libnm-nm-utils.html#nm-utils-enum-to-str"> +<ANCHOR id="nm-utils-enum-from-str" href="libnm/libnm-nm-utils.html#nm-utils-enum-from-str"> <ANCHOR id="libnm-nm-utils.other_details" href="libnm/libnm-nm-utils.html#libnm-nm-utils.other_details"> <ANCHOR id="NMUtilsSecurityType" href="libnm/libnm-nm-utils.html#NMUtilsSecurityType"> <ANCHOR id="NMU-SEC-INVALID:CAPS" href="libnm/libnm-nm-utils.html#NMU-SEC-INVALID:CAPS"> @@ -2431,6 +2471,8 @@ <ANCHOR id="NM-VERSION-1-0:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-1-0:CAPS"> <ANCHOR id="NM-VERSION-1-0-2:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-1-0-2:CAPS"> <ANCHOR id="NM-VERSION-1-0-4:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-1-0-4:CAPS"> +<ANCHOR id="NM-VERSION-1-0-6:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-1-0-6:CAPS"> +<ANCHOR id="NM-VERSION-1-0-8:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-1-0-8:CAPS"> <ANCHOR id="NM-VERSION-MIN-REQUIRED:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-MIN-REQUIRED:CAPS"> <ANCHOR id="NM-VERSION-MAX-ALLOWED:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-MAX-ALLOWED:CAPS"> <ANCHOR id="NM-DEPRECATED-IN-0-9-10-FOR:CAPS" href="libnm/libnm-nm-version.html#NM-DEPRECATED-IN-0-9-10-FOR:CAPS"> @@ -2439,10 +2481,11 @@ <ANCHOR id="NM-VERSION-CUR-STABLE:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-CUR-STABLE:CAPS"> <ANCHOR id="NM-VERSION-NEXT-STABLE:CAPS" href="libnm/libnm-nm-version.html#NM-VERSION-NEXT-STABLE:CAPS"> <ANCHOR id="NM-DEPRECATED-IN-0-9-10:CAPS" href="libnm/libnm-nm-version.html#NM-DEPRECATED-IN-0-9-10:CAPS"> -<ANCHOR id="NM-DEPRECATED-IN-1-0:CAPS" href="libnm/libnm-nm-version.html#NM-DEPRECATED-IN-1-0:CAPS"> <ANCHOR id="NM-AVAILABLE-IN-0-9-10:CAPS" href="libnm/libnm-nm-version.html#NM-AVAILABLE-IN-0-9-10:CAPS"> +<ANCHOR id="NM-DEPRECATED-IN-1-0:CAPS" href="libnm/libnm-nm-version.html#NM-DEPRECATED-IN-1-0:CAPS"> <ANCHOR id="NM-AVAILABLE-IN-1-0:CAPS" href="libnm/libnm-nm-version.html#NM-AVAILABLE-IN-1-0:CAPS"> <ANCHOR id="NM-AVAILABLE-IN-1-0-4:CAPS" href="libnm/libnm-nm-version.html#NM-AVAILABLE-IN-1-0-4:CAPS"> +<ANCHOR id="NM-AVAILABLE-IN-1-0-6:CAPS" href="libnm/libnm-nm-version.html#NM-AVAILABLE-IN-1-0-6:CAPS"> <ANCHOR id="libnm-nm-vpn-dbus-interface" href="libnm/libnm-nm-vpn-dbus-interface.html"> <ANCHOR id="libnm-nm-vpn-dbus-interface.other" href="libnm/libnm-nm-vpn-dbus-interface.html#libnm-nm-vpn-dbus-interface.other"> <ANCHOR id="libnm-nm-vpn-dbus-interface.object-hierarchy" href="libnm/libnm-nm-vpn-dbus-interface.html#libnm-nm-vpn-dbus-interface.object-hierarchy"> diff --git a/docs/libnm/html/libnm-nm-dbus-interface.html b/docs/libnm/html/libnm-nm-dbus-interface.html index 1272e0d3e..f67efaba4 100644 --- a/docs/libnm/html/libnm-nm-dbus-interface.html +++ b/docs/libnm/html/libnm-nm-dbus-interface.html @@ -250,6 +250,10 @@ </tr> <tr> <td class="datatype_keyword">enum</td> +<td class="function_name"><a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered">NMMetered</a></td> +</tr> +<tr> +<td class="datatype_keyword">enum</td> <td class="function_name"><a class="link" href="libnm-nm-dbus-interface.html#NMActiveConnectionState" title="enum NMActiveConnectionState">NMActiveConnectionState</a></td> </tr> <tr> @@ -272,6 +276,7 @@ <span class="lineart">├──</span> NMDeviceState <span class="lineart">├──</span> NMDeviceStateReason <span class="lineart">├──</span> NMDeviceType + <span class="lineart">├──</span> NMMetered <span class="lineart">╰──</span> NMState <a href="/usr/share/gtk-doc/html/gobject/gobject-Enumeration-and-Flag-Types.html">GFlags</a> <span class="lineart">├──</span> NM80211ApFlags @@ -1820,13 +1825,66 @@ GPRS, EDGE, UMTS, HSDPA, HSUPA, or HSPA+ packet switched data capability</p> </div> <hr> <div class="refsect2"> +<a name="NMMetered"></a><h3>enum NMMetered</h3> +<p>(Corresponds to the NM_METERED type in nm-device.xml.)</p> +<div class="refsect3"> +<a name="id-1.3.6.7.54.4"></a><h4>Members</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="300px" class="enum_members_name"> +<col class="enum_members_description"> +<col width="200px" class="enum_members_annotations"> +</colgroup> +<tbody> +<tr> +<td class="enum_member_name"><p><a name="NM-METERED-UNKNOWN:CAPS"></a>NM_METERED_UNKNOWN</p></td> +<td class="enum_member_description"> +<p>The metered status is unknown</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-METERED-YES:CAPS"></a>NM_METERED_YES</p></td> +<td class="enum_member_description"> +<p>Metered, the value was statically set</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-METERED-NO:CAPS"></a>NM_METERED_NO</p></td> +<td class="enum_member_description"> +<p>Not metered, the value was statically set</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-METERED-GUESS-YES:CAPS"></a>NM_METERED_GUESS_YES</p></td> +<td class="enum_member_description"> +<p>Metered, the value was guessed</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +<tr> +<td class="enum_member_name"><p><a name="NM-METERED-GUESS-NO:CAPS"></a>NM_METERED_GUESS_NO</p></td> +<td class="enum_member_description"> +<p>Not metered, the value was guessed</p> +</td> +<td class="enum_member_annotations"> </td> +</tr> +</tbody> +</table></div> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="NMActiveConnectionState"></a><h3>enum NMActiveConnectionState</h3> <p><a class="link" href="libnm-nm-dbus-interface.html#NMActiveConnectionState" title="enum NMActiveConnectionState"><span class="type">NMActiveConnectionState</span></a> values indicate the state of a connection to a specific network while it is starting, connected, or disconnecting from that network.</p> <p>(Corresponds to the NM_ACTIVE_CONNECTION_STATE type in nm-active-connection.xml.)</p> <div class="refsect3"> -<a name="id-1.3.6.7.54.5"></a><h4>Members</h4> +<a name="id-1.3.6.7.55.5"></a><h4>Members</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="300px" class="enum_members_name"> @@ -1881,7 +1939,7 @@ network.</p> <p><a class="link" href="libnm-nm-dbus-interface.html#NMSecretAgentGetSecretsFlags" title="enum NMSecretAgentGetSecretsFlags"><span class="type">NMSecretAgentGetSecretsFlags</span></a> values modify the behavior of a GetSecrets request.</p> <p>(Corresponds to the NM_SECRET_AGENT_GET_SECRETS_FLAGS type in nm-secret-agent.xml.)</p> <div class="refsect3"> -<a name="id-1.3.6.7.55.5"></a><h4>Members</h4> +<a name="id-1.3.6.7.56.5"></a><h4>Members</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="300px" class="enum_members_name"> @@ -1953,7 +2011,7 @@ network.</p> <p><a class="link" href="libnm-nm-dbus-interface.html#NMSecretAgentCapabilities" title="enum NMSecretAgentCapabilities"><span class="type">NMSecretAgentCapabilities</span></a> indicate various capabilities of the agent.</p> <p>(Corresponds to the NM_SECRET_AGENT_CAPABILITIES type in nm-secret-agent.xml.)</p> <div class="refsect3"> -<a name="id-1.3.6.7.56.5"></a><h4>Members</h4> +<a name="id-1.3.6.7.57.5"></a><h4>Members</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="300px" class="enum_members_name"> diff --git a/docs/libnm/html/libnm-nm-utils.html b/docs/libnm/html/libnm-nm-utils.html index d3789e5b6..5406f9665 100644 --- a/docs/libnm/html/libnm-nm-utils.html +++ b/docs/libnm/html/libnm-nm-utils.html @@ -335,6 +335,20 @@ </td> </tr> <tr> +<td class="function_type">const <span class="returnvalue">guint</span> * +</td> +<td class="function_name"> +<a class="link" href="libnm-nm-utils.html#nm-utils-wifi-2ghz-freqs" title="nm_utils_wifi_2ghz_freqs ()">nm_utils_wifi_2ghz_freqs</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type">const <span class="returnvalue">guint</span> * +</td> +<td class="function_name"> +<a class="link" href="libnm-nm-utils.html#nm-utils-wifi-5ghz-freqs" title="nm_utils_wifi_5ghz_freqs ()">nm_utils_wifi_5ghz_freqs</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> <td class="function_type">const <span class="returnvalue">char</span> * </td> <td class="function_name"> @@ -459,6 +473,22 @@ <a class="link" href="libnm-nm-utils.html#nm-utils-check-virtual-device-compatibility" title="nm_utils_check_virtual_device_compatibility ()">nm_utils_check_virtual_device_compatibility</a> <span class="c_punctuation">()</span> </td> </tr> +<tr> +<td class="function_type"> +<span class="returnvalue">char</span> * +</td> +<td class="function_name"> +<a class="link" href="libnm-nm-utils.html#nm-utils-enum-to-str" title="nm_utils_enum_to_str ()">nm_utils_enum_to_str</a> <span class="c_punctuation">()</span> +</td> +</tr> +<tr> +<td class="function_type"> +<span class="returnvalue">gboolean</span> +</td> +<td class="function_name"> +<a class="link" href="libnm-nm-utils.html#nm-utils-enum-from-str" title="nm_utils_enum_from_str ()">nm_utils_enum_from_str</a> <span class="c_punctuation">()</span> +</td> +</tr> </tbody> </table></div> </div> @@ -1820,6 +1850,30 @@ nm_utils_wifi_is_channel_valid (<em class="parameter"><code><span class="type">g </div> <hr> <div class="refsect2"> +<a name="nm-utils-wifi-2ghz-freqs"></a><h3>nm_utils_wifi_2ghz_freqs ()</h3> +<pre class="programlisting">const <span class="returnvalue">guint</span> * +nm_utils_wifi_2ghz_freqs (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> +<p>Utility function to return 2.4 GHz Wi-Fi frequencies (802.11bg band).</p> +<div class="refsect3"> +<a name="id-1.6.2.7.39.5"></a><h4>Returns</h4> +<p> zero-terminated array of frequencies numbers (in MHz)</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> +<a name="nm-utils-wifi-5ghz-freqs"></a><h3>nm_utils_wifi_5ghz_freqs ()</h3> +<pre class="programlisting">const <span class="returnvalue">guint</span> * +nm_utils_wifi_5ghz_freqs (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> +<p>Utility function to return 5 GHz Wi-Fi frequencies (802.11a band).</p> +<div class="refsect3"> +<a name="id-1.6.2.7.40.5"></a><h4>Returns</h4> +<p> zero-terminated array of frequencies numbers (in MHz)</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> <a name="nm-utils-wifi-strength-bars"></a><h3>nm_utils_wifi_strength_bars ()</h3> <pre class="programlisting">const <span class="returnvalue">char</span> * nm_utils_wifi_strength_bars (<em class="parameter"><code><span class="type">guint8</span> strength</code></em>);</pre> @@ -1829,7 +1883,7 @@ strength suitable for printing to stdout. If the current locale and terminal support it, this will use unicode graphics characters to represent "bars". Otherwise it will use 0 to 4 asterisks.</p> <div class="refsect3"> -<a name="id-1.6.2.7.39.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.41.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1844,7 +1898,7 @@ support it, this will use unicode graphics characters to represent </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.39.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.41.6"></a><h4>Returns</h4> <p> the graphical representation of the access point strength</p> </div> </div> @@ -1858,7 +1912,7 @@ nm_utils_hwaddr_len (<em class="parameter"><code><span class="type">int</span> t <p>It is an error to call this function with any value other than <code class="literal">ARPHRD_ETHER</code> or <code class="literal">ARPHRD_INFINIBAND</code>.</p> <div class="refsect3"> -<a name="id-1.6.2.7.40.6"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.42.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1874,7 +1928,7 @@ nm_utils_hwaddr_len (<em class="parameter"><code><span class="type">int</span> t </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.40.7"></a><h4>Returns</h4> +<a name="id-1.6.2.7.42.7"></a><h4>Returns</h4> <p> the length.</p> </div> </div> @@ -1887,7 +1941,7 @@ nm_utils_hwaddr_ntoa (<em class="parameter"><code><span class="type">gconstpoint <p>Converts <em class="parameter"><code>addr</code></em> to textual form.</p> <div class="refsect3"> -<a name="id-1.6.2.7.41.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.43.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1910,7 +1964,7 @@ nm_utils_hwaddr_ntoa (<em class="parameter"><code><span class="type">gconstpoint </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.41.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.43.6"></a><h4>Returns</h4> <p> the textual form of <em class="parameter"><code>addr</code></em> . </p> <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> @@ -1926,7 +1980,7 @@ nm_utils_hwaddr_atoba (<em class="parameter"><code>const <span class="type">char and converts it to binary form in a <span class="type">GByteArray</span>. See <a class="link" href="libnm-nm-utils.html#nm-utils-hwaddr-aton" title="nm_utils_hwaddr_aton ()"><code class="function">nm_utils_hwaddr_aton()</code></a> if you don't want a <span class="type">GByteArray</span>.</p> <div class="refsect3"> -<a name="id-1.6.2.7.42.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.44.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1948,7 +2002,7 @@ nm_utils_hwaddr_atoba (<em class="parameter"><code>const <span class="type">char </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.42.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.44.6"></a><h4>Returns</h4> <p> a new <span class="type">GByteArray</span>, or <code class="literal">NULL</code> if <em class="parameter"><code>asc</code></em> couldn't be parsed. </p> @@ -1968,7 +2022,7 @@ nm_utils_hwaddr_aton (<em class="parameter"><code>const <span class="type">char< Bytes in <em class="parameter"><code>asc</code></em> can be sepatared by colons (:), or hyphens (-), but not mixed.</p> <div class="refsect3"> -<a name="id-1.6.2.7.43.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.45.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -1996,7 +2050,7 @@ the size of the buffer in bytes.</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.43.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.45.6"></a><h4>Returns</h4> <p> <em class="parameter"><code>buffer</code></em> , or <code class="literal">NULL</code> if <em class="parameter"><code>asc</code></em> couldn't be parsed @@ -2014,7 +2068,7 @@ nm_utils_hwaddr_valid (<em class="parameter"><code>const <span class="type">char to see if it is a valid hardware address of the given length.</p> <div class="refsect3"> -<a name="id-1.6.2.7.44.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.46.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2038,7 +2092,7 @@ is expected to convert to </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.44.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.46.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if <em class="parameter"><code>asc</code></em> appears to be a valid hardware address of the indicated length, <code class="literal">FALSE</code> if not.</p> @@ -2055,7 +2109,7 @@ nm_utils_hwaddr_canonical (<em class="parameter"><code>const <span class="type"> length, and if so, returns it in canonical form (uppercase, with leading 0s as needed, and with colons rather than hyphens).</p> <div class="refsect3"> -<a name="id-1.6.2.7.45.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.47.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2079,7 +2133,7 @@ is expected to convert to </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.45.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.47.6"></a><h4>Returns</h4> <p> the canonicalized address if <em class="parameter"><code>asc</code></em> appears to be a valid hardware address of the indicated length, <code class="literal">NULL</code> if not. </p> @@ -2126,7 +2180,7 @@ match. (This means that externally-provided address strings do not need to be sanity-checked before comparing them against known good addresses; they are guaranteed to not match if they are invalid.)</p> <div class="refsect3"> -<a name="id-1.6.2.7.46.7"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.48.7"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2162,7 +2216,7 @@ is ASCII</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.46.8"></a><h4>Returns</h4> +<a name="id-1.6.2.7.48.8"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if <em class="parameter"><code>hwaddr1</code></em> and <em class="parameter"><code>hwaddr2</code></em> are equivalent, <code class="literal">FALSE</code> if they are @@ -2182,7 +2236,7 @@ nm_utils_bin2hexstr (<em class="parameter"><code><span class="type">gconstpointe greater than -1, the returned string is terminated at that index (returned_string[final_len] == '\0'),</p> <div class="refsect3"> -<a name="id-1.6.2.7.47.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.49.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2210,7 +2264,7 @@ array</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.47.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.49.6"></a><h4>Returns</h4> <p> the textual form of <em class="parameter"><code>bytes</code></em> . </p> <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> @@ -2229,7 +2283,7 @@ eg "00:11" or "0:1". Any "0x" at the beginning of <em class="parameter"><code>h may not start or end with ':'.</p> <div class="refsect3"> -<a name="id-1.6.2.7.48.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.50.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2244,7 +2298,7 @@ may not start or end with ':'.</p> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.48.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.50.6"></a><h4>Returns</h4> <p> the converted bytes, or <code class="literal">NULL</code> on error. </p> <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> </div> @@ -2257,7 +2311,7 @@ nm_utils_iface_valid_name (<em class="parameter"><code>const <span class="type"> <p>This function is a 1:1 copy of the kernel's interface validation function in net/core/dev.c.</p> <div class="refsect3"> -<a name="id-1.6.2.7.49.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.51.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2272,7 +2326,7 @@ function in net/core/dev.c.</p> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.49.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.51.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if interface name is valid, otherwise <code class="literal">FALSE</code> is returned.</p> </div> </div> @@ -2284,7 +2338,7 @@ nm_utils_is_uuid (<em class="parameter"><code>const <span class="type">char</spa <p>Checks if <em class="parameter"><code>str</code></em> is a UUID</p> <div class="refsect3"> -<a name="id-1.6.2.7.50.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.52.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2299,7 +2353,7 @@ nm_utils_is_uuid (<em class="parameter"><code>const <span class="type">char</spa </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.50.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.52.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> if <em class="parameter"><code>str</code></em> is a UUID, <code class="literal">FALSE</code> if not</p> </div> @@ -2313,7 +2367,7 @@ nm_utils_inet4_ntop (<em class="parameter"><code><span class="type">in_addr_t</s <p>Wrapper for inet_ntop.</p> <p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p> <div class="refsect3"> -<a name="id-1.6.2.7.51.6"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.53.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2344,7 +2398,7 @@ buffer to avoid these issues.</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.51.7"></a><h4>Returns</h4> +<a name="id-1.6.2.7.53.7"></a><h4>Returns</h4> <p> the input buffer <em class="parameter"><code>dst</code></em> , or a pointer to an internal, static buffer. This function cannot fail.</p> @@ -2359,7 +2413,7 @@ nm_utils_inet6_ntop (<em class="parameter"><code>const <span class="type">struct <p>Wrapper for inet_ntop.</p> <p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p> <div class="refsect3"> -<a name="id-1.6.2.7.52.6"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.54.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2390,7 +2444,7 @@ buffer to avoid these issues.</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.52.7"></a><h4>Returns</h4> +<a name="id-1.6.2.7.54.7"></a><h4>Returns</h4> <p> the input buffer <em class="parameter"><code>dst</code></em> , or a pointer to an internal, static buffer. <code class="literal">NULL</code> is not allowed as <em class="parameter"><code>in6addr</code></em> @@ -2407,7 +2461,7 @@ nm_utils_ipaddr_valid (<em class="parameter"><code><span class="type">int</span> <p>Checks if <em class="parameter"><code>ip</code></em> contains a valid IP address of the given family.</p> <div class="refsect3"> -<a name="id-1.6.2.7.53.5"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.55.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2430,7 +2484,7 @@ nm_utils_ipaddr_valid (<em class="parameter"><code><span class="type">int</span> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.53.6"></a><h4>Returns</h4> +<a name="id-1.6.2.7.55.6"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> or <code class="literal">FALSE</code></p> </div> </div> @@ -2462,7 +2516,7 @@ compatible with <em class="parameter"><code>virtual_type</code></em> configuration of the two connections, or on the capabilities of an underlying device driver.</p> <div class="refsect3"> -<a name="id-1.6.2.7.54.8"></a><h4>Parameters</h4> +<a name="id-1.6.2.7.56.8"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> @@ -2485,10 +2539,100 @@ underlying device driver.</p> </table></div> </div> <div class="refsect3"> -<a name="id-1.6.2.7.54.9"></a><h4>Returns</h4> +<a name="id-1.6.2.7.56.9"></a><h4>Returns</h4> <p> <code class="literal">TRUE</code> or <code class="literal">FALSE</code></p> </div> </div> +<hr> +<div class="refsect2"> +<a name="nm-utils-enum-to-str"></a><h3>nm_utils_enum_to_str ()</h3> +<pre class="programlisting"><span class="returnvalue">char</span> * +nm_utils_enum_to_str (<em class="parameter"><code><span class="type">GType</span> type</code></em>, + <em class="parameter"><code><span class="type">int</span> value</code></em>);</pre> +<p>Converts an enum value to its string representation. If the enum is a +<code class="literal">G_TYPE_FLAGS</code> the function returns a comma-separated list of matching values. +If the enum is a <code class="literal">G_TYPE_ENUM</code> and the given value is not valid the +function returns <code class="literal">NULL</code>.</p> +<div class="refsect3"> +<a name="id-1.6.2.7.57.5"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody> +<tr> +<td class="parameter_name"><p>type</p></td> +<td class="parameter_description"><p>the <code class="literal">GType</code> of the enum</p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>value</p></td> +<td class="parameter_description"><p>the value to be translated</p></td> +<td class="parameter_annotations"> </td> +</tr> +</tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.6.2.7.57.6"></a><h4>Returns</h4> +<p> a newly allocated string or <code class="literal">NULL</code></p> +</div> +<p class="since">Since: 1.0.6</p> +</div> +<hr> +<div class="refsect2"> +<a name="nm-utils-enum-from-str"></a><h3>nm_utils_enum_from_str ()</h3> +<pre class="programlisting"><span class="returnvalue">gboolean</span> +nm_utils_enum_from_str (<em class="parameter"><code><span class="type">GType</span> type</code></em>, + <em class="parameter"><code>const <span class="type">char</span> *str</code></em>, + <em class="parameter"><code><span class="type">int</span> *out_value</code></em>, + <em class="parameter"><code><span class="type">char</span> **err_token</code></em>);</pre> +<p>Converts a string to the matching enum value.</p> +<p>If the enum is a <code class="literal">G_TYPE_FLAGS</code> the function returns the logical OR of values +matching the comma-separated tokens in the string; if an unknown token is found +the function returns <code class="literal">FALSE</code> and stores a pointer to a newly allocated string +containing the unrecognized token in <em class="parameter"><code>err_token</code></em> +.</p> +<div class="refsect3"> +<a name="id-1.6.2.7.58.6"></a><h4>Parameters</h4> +<div class="informaltable"><table width="100%" border="0"> +<colgroup> +<col width="150px" class="parameters_name"> +<col class="parameters_description"> +<col width="200px" class="parameters_annotations"> +</colgroup> +<tbody> +<tr> +<td class="parameter_name"><p>type</p></td> +<td class="parameter_description"><p>the <code class="literal">GType</code> of the enum</p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>str</p></td> +<td class="parameter_description"><p>the input string</p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>out_value</p></td> +<td class="parameter_description"><p>(out) (allow-none) the output value</p></td> +<td class="parameter_annotations"> </td> +</tr> +<tr> +<td class="parameter_name"><p>err_token</p></td> +<td class="parameter_description"><p>(out) (allow-none) location to store the first unrecognized token</p></td> +<td class="parameter_annotations"> </td> +</tr> +</tbody> +</table></div> +</div> +<div class="refsect3"> +<a name="id-1.6.2.7.58.7"></a><h4>Returns</h4> +<p> <code class="literal">TRUE</code> if the conversion was successful, <code class="literal">FALSE</code> otherwise</p> +</div> +<p class="since">Since: 1.0.6</p> +</div> </div> <div class="refsect1"> <a name="libnm-nm-utils.other_details"></a><h2>Types and Values</h2> diff --git a/docs/libnm/html/libnm-nm-version.html b/docs/libnm/html/libnm-nm-version.html index 99310a5c0..81f2b0d2f 100644 --- a/docs/libnm/html/libnm-nm-version.html +++ b/docs/libnm/html/libnm-nm-version.html @@ -85,6 +85,14 @@ </tr> <tr> <td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="libnm-nm-version.html#NM-VERSION-1-0-6:CAPS" title="NM_VERSION_1_0_6">NM_VERSION_1_0_6</a></td> +</tr> +<tr> +<td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="libnm-nm-version.html#NM-VERSION-1-0-8:CAPS" title="NM_VERSION_1_0_8">NM_VERSION_1_0_8</a></td> +</tr> +<tr> +<td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="libnm-nm-version.html#NM-VERSION-MIN-REQUIRED:CAPS" title="NM_VERSION_MIN_REQUIRED">NM_VERSION_MIN_REQUIRED</a></td> </tr> <tr> @@ -128,11 +136,11 @@ </tr> <tr> <td class="define_keyword">#define</td> -<td class="function_name"><a class="link" href="libnm-nm-version.html#NM-DEPRECATED-IN-1-0:CAPS" title="NM_DEPRECATED_IN_1_0">NM_DEPRECATED_IN_1_0</a></td> +<td class="function_name"><a class="link" href="libnm-nm-version.html#NM-AVAILABLE-IN-0-9-10:CAPS" title="NM_AVAILABLE_IN_0_9_10">NM_AVAILABLE_IN_0_9_10</a></td> </tr> <tr> <td class="define_keyword">#define</td> -<td class="function_name"><a class="link" href="libnm-nm-version.html#NM-AVAILABLE-IN-0-9-10:CAPS" title="NM_AVAILABLE_IN_0_9_10">NM_AVAILABLE_IN_0_9_10</a></td> +<td class="function_name"><a class="link" href="libnm-nm-version.html#NM-DEPRECATED-IN-1-0:CAPS" title="NM_DEPRECATED_IN_1_0">NM_DEPRECATED_IN_1_0</a></td> </tr> <tr> <td class="define_keyword">#define</td> @@ -142,6 +150,10 @@ <td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="libnm-nm-version.html#NM-AVAILABLE-IN-1-0-4:CAPS" title="NM_AVAILABLE_IN_1_0_4">NM_AVAILABLE_IN_1_0_4</a></td> </tr> +<tr> +<td class="define_keyword">#define</td> +<td class="function_name"><a class="link" href="libnm-nm-version.html#NM-AVAILABLE-IN-1-0-6:CAPS" title="NM_AVAILABLE_IN_1_0_6">NM_AVAILABLE_IN_1_0_6</a></td> +</tr> </tbody> </table></div> </div> @@ -168,7 +180,7 @@ is compiled against.</p> <hr> <div class="refsect2"> <a name="NM-MICRO-VERSION:CAPS"></a><h3>NM_MICRO_VERSION</h3> -<pre class="programlisting">#define NM_MICRO_VERSION (4) +<pre class="programlisting">#define NM_MICRO_VERSION (6) </pre> <p>Evaluates to the micro version number of NetworkManager which this source compiled against.</p> @@ -248,6 +260,18 @@ is the same as or newer than the passed-in version.</p> </div> <hr> <div class="refsect2"> +<a name="NM-VERSION-1-0-6:CAPS"></a><h3>NM_VERSION_1_0_6</h3> +<pre class="programlisting">#define NM_VERSION_1_0_6 (NM_ENCODE_VERSION (1, 0, 6)) +</pre> +</div> +<hr> +<div class="refsect2"> +<a name="NM-VERSION-1-0-8:CAPS"></a><h3>NM_VERSION_1_0_8</h3> +<pre class="programlisting">#define NM_VERSION_1_0_8 (NM_ENCODE_VERSION (1, 0, 8)) +</pre> +</div> +<hr> +<div class="refsect2"> <a name="NM-VERSION-MIN-REQUIRED:CAPS"></a><h3>NM_VERSION_MIN_REQUIRED</h3> <pre class="programlisting"># define NM_VERSION_MIN_REQUIRED (NM_VERSION_CUR_STABLE) </pre> @@ -275,13 +299,13 @@ is the same as or newer than the passed-in version.</p> <a name="libnm-nm-version.other_details"></a><h2>Types and Values</h2> <div class="refsect2"> <a name="NM-VERSION-CUR-STABLE:CAPS"></a><h3>NM_VERSION_CUR_STABLE</h3> -<pre class="programlisting">#define NM_VERSION_CUR_STABLE NM_VERSION_1_0_2 +<pre class="programlisting">#define NM_VERSION_CUR_STABLE NM_VERSION_1_0_6 </pre> </div> <hr> <div class="refsect2"> <a name="NM-VERSION-NEXT-STABLE:CAPS"></a><h3>NM_VERSION_NEXT_STABLE</h3> -<pre class="programlisting">#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_4 +<pre class="programlisting">#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_8 </pre> </div> <hr> @@ -292,14 +316,14 @@ is the same as or newer than the passed-in version.</p> </div> <hr> <div class="refsect2"> -<a name="NM-DEPRECATED-IN-1-0:CAPS"></a><h3>NM_DEPRECATED_IN_1_0</h3> -<pre class="programlisting"># define NM_DEPRECATED_IN_1_0 G_DEPRECATED +<a name="NM-AVAILABLE-IN-0-9-10:CAPS"></a><h3>NM_AVAILABLE_IN_0_9_10</h3> +<pre class="programlisting"># define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) </pre> </div> <hr> <div class="refsect2"> -<a name="NM-AVAILABLE-IN-0-9-10:CAPS"></a><h3>NM_AVAILABLE_IN_0_9_10</h3> -<pre class="programlisting"># define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) +<a name="NM-DEPRECATED-IN-1-0:CAPS"></a><h3>NM_DEPRECATED_IN_1_0</h3> +<pre class="programlisting"># define NM_DEPRECATED_IN_1_0 G_DEPRECATED </pre> </div> <hr> @@ -314,6 +338,12 @@ is the same as or newer than the passed-in version.</p> <pre class="programlisting"># define NM_AVAILABLE_IN_1_0_4 G_UNAVAILABLE(1,0.4) </pre> </div> +<hr> +<div class="refsect2"> +<a name="NM-AVAILABLE-IN-1-0-6:CAPS"></a><h3>NM_AVAILABLE_IN_1_0_6</h3> +<pre class="programlisting"># define NM_AVAILABLE_IN_1_0_6 G_UNAVAILABLE(1,0.6) +</pre> +</div> </div> </div> <div class="footer"> diff --git a/docs/libnm/html/libnm.devhelp2 b/docs/libnm/html/libnm.devhelp2 index ff7493085..daf26d9c0 100644 --- a/docs/libnm/html/libnm.devhelp2 +++ b/docs/libnm/html/libnm.devhelp2 @@ -150,6 +150,7 @@ <keyword type="macro" name="NM_CLIENT_CONNECTIONS" link="NMClient.html#NM-CLIENT-CONNECTIONS:CAPS"/> <keyword type="macro" name="NM_CLIENT_HOSTNAME" link="NMClient.html#NM-CLIENT-HOSTNAME:CAPS"/> <keyword type="macro" name="NM_CLIENT_CAN_MODIFY" link="NMClient.html#NM-CLIENT-CAN-MODIFY:CAPS"/> + <keyword type="macro" name="NM_CLIENT_METERED" link="NMClient.html#NM-CLIENT-METERED:CAPS"/> <keyword type="macro" name="NM_CLIENT_DEVICE_ADDED" link="NMClient.html#NM-CLIENT-DEVICE-ADDED:CAPS"/> <keyword type="macro" name="NM_CLIENT_DEVICE_REMOVED" link="NMClient.html#NM-CLIENT-DEVICE-REMOVED:CAPS"/> <keyword type="macro" name="NM_CLIENT_PERMISSION_CHANGED" link="NMClient.html#NM-CLIENT-PERMISSION-CHANGED:CAPS"/> @@ -166,6 +167,7 @@ <keyword type="property" name="The “connectivity” property" link="NMClient.html#NMClient--connectivity"/> <keyword type="property" name="The “devices” property" link="NMClient.html#NMClient--devices"/> <keyword type="property" name="The “hostname” property" link="NMClient.html#NMClient--hostname"/> + <keyword type="property" name="The “metered” property" link="NMClient.html#NMClient--metered"/> <keyword type="property" name="The “networking-enabled” property" link="NMClient.html#NMClient--networking-enabled"/> <keyword type="property" name="The “nm-running” property" link="NMClient.html#NMClient--nm-running"/> <keyword type="property" name="The “primary-connection” property" link="NMClient.html#NMClient--primary-connection"/> @@ -286,6 +288,7 @@ <keyword type="enum" name="enum NMDeviceModemCapabilities" link="libnm-nm-dbus-interface.html#NMDeviceModemCapabilities"/> <keyword type="enum" name="enum NMDeviceState" link="libnm-nm-dbus-interface.html#NMDeviceState"/> <keyword type="enum" name="enum NMDeviceStateReason" link="libnm-nm-dbus-interface.html#NMDeviceStateReason"/> + <keyword type="enum" name="enum NMMetered" link="libnm-nm-dbus-interface.html#NMMetered" since="1.0.6"/> <keyword type="enum" name="enum NMActiveConnectionState" link="libnm-nm-dbus-interface.html#NMActiveConnectionState"/> <keyword type="enum" name="enum NMSecretAgentGetSecretsFlags" link="libnm-nm-dbus-interface.html#NMSecretAgentGetSecretsFlags"/> <keyword type="enum" name="enum NMSecretAgentCapabilities" link="libnm-nm-dbus-interface.html#NMSecretAgentCapabilities"/> @@ -400,6 +403,7 @@ <keyword type="function" name="nm_setting_connection_remove_secondary ()" link="NMSettingConnection.html#nm-setting-connection-remove-secondary"/> <keyword type="function" name="nm_setting_connection_remove_secondary_by_value ()" link="NMSettingConnection.html#nm-setting-connection-remove-secondary-by-value"/> <keyword type="function" name="nm_setting_connection_get_gateway_ping_timeout ()" link="NMSettingConnection.html#nm-setting-connection-get-gateway-ping-timeout"/> + <keyword type="function" name="nm_setting_connection_get_metered ()" link="NMSettingConnection.html#nm-setting-connection-get-metered" since="1.0.6"/> <keyword type="macro" name="NM_SETTING_CONNECTION_SETTING_NAME" link="NMSettingConnection.html#NM-SETTING-CONNECTION-SETTING-NAME:CAPS"/> <keyword type="macro" name="NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN" link="NMSettingConnection.html#NM-SETTING-CONNECTION-AUTOCONNECT-PRIORITY-MIN:CAPS"/> <keyword type="macro" name="NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX" link="NMSettingConnection.html#NM-SETTING-CONNECTION-AUTOCONNECT-PRIORITY-MAX:CAPS"/> @@ -419,6 +423,7 @@ <keyword type="macro" name="NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES" link="NMSettingConnection.html#NM-SETTING-CONNECTION-AUTOCONNECT-SLAVES:CAPS"/> <keyword type="macro" name="NM_SETTING_CONNECTION_SECONDARIES" link="NMSettingConnection.html#NM-SETTING-CONNECTION-SECONDARIES:CAPS"/> <keyword type="macro" name="NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT" link="NMSettingConnection.html#NM-SETTING-CONNECTION-GATEWAY-PING-TIMEOUT:CAPS"/> + <keyword type="macro" name="NM_SETTING_CONNECTION_METERED" link="NMSettingConnection.html#NM-SETTING-CONNECTION-METERED:CAPS"/> <keyword type="enum" name="enum NMSettingConnectionAutoconnectSlaves" link="NMSettingConnection.html#NMSettingConnectionAutoconnectSlaves"/> <keyword type="struct" name="struct NMSettingConnection" link="NMSettingConnection.html#NMSettingConnection-struct"/> <keyword type="property" name="The “autoconnect” property" link="NMSettingConnection.html#NMSettingConnection--autoconnect"/> @@ -428,6 +433,7 @@ <keyword type="property" name="The “id” property" link="NMSettingConnection.html#NMSettingConnection--id"/> <keyword type="property" name="The “interface-name” property" link="NMSettingConnection.html#NMSettingConnection--interface-name"/> <keyword type="property" name="The “master” property" link="NMSettingConnection.html#NMSettingConnection--master"/> + <keyword type="property" name="The “metered” property" link="NMSettingConnection.html#NMSettingConnection--metered"/> <keyword type="property" name="The “permissions” property" link="NMSettingConnection.html#NMSettingConnection--permissions"/> <keyword type="property" name="The “read-only” property" link="NMSettingConnection.html#NMSettingConnection--read-only"/> <keyword type="property" name="The “secondaries” property" link="NMSettingConnection.html#NMSettingConnection--secondaries"/> @@ -1100,7 +1106,10 @@ <keyword type="function" name="nm_setting_wired_add_s390_option ()" link="NMSettingWired.html#nm-setting-wired-add-s390-option"/> <keyword type="function" name="nm_setting_wired_remove_s390_option ()" link="NMSettingWired.html#nm-setting-wired-remove-s390-option"/> <keyword type="function" name="nm_setting_wired_get_valid_s390_options ()" link="NMSettingWired.html#nm-setting-wired-get-valid-s390-options"/> + <keyword type="function" name="nm_setting_wired_get_wake_on_lan ()" link="NMSettingWired.html#nm-setting-wired-get-wake-on-lan" since="1.0.6"/> + <keyword type="function" name="nm_setting_wired_get_wake_on_lan_password ()" link="NMSettingWired.html#nm-setting-wired-get-wake-on-lan-password" since="1.0.6"/> <keyword type="macro" name="NM_SETTING_WIRED_SETTING_NAME" link="NMSettingWired.html#NM-SETTING-WIRED-SETTING-NAME:CAPS"/> + <keyword type="enum" name="enum NMSettingWiredWakeOnLan" link="NMSettingWired.html#NMSettingWiredWakeOnLan" since="1.0.6"/> <keyword type="macro" name="NM_SETTING_WIRED_PORT" link="NMSettingWired.html#NM-SETTING-WIRED-PORT:CAPS"/> <keyword type="macro" name="NM_SETTING_WIRED_SPEED" link="NMSettingWired.html#NM-SETTING-WIRED-SPEED:CAPS"/> <keyword type="macro" name="NM_SETTING_WIRED_DUPLEX" link="NMSettingWired.html#NM-SETTING-WIRED-DUPLEX:CAPS"/> @@ -1112,6 +1121,8 @@ <keyword type="macro" name="NM_SETTING_WIRED_S390_SUBCHANNELS" link="NMSettingWired.html#NM-SETTING-WIRED-S390-SUBCHANNELS:CAPS"/> <keyword type="macro" name="NM_SETTING_WIRED_S390_NETTYPE" link="NMSettingWired.html#NM-SETTING-WIRED-S390-NETTYPE:CAPS"/> <keyword type="macro" name="NM_SETTING_WIRED_S390_OPTIONS" link="NMSettingWired.html#NM-SETTING-WIRED-S390-OPTIONS:CAPS"/> + <keyword type="macro" name="NM_SETTING_WIRED_WAKE_ON_LAN" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN:CAPS"/> + <keyword type="macro" name="NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-PASSWORD:CAPS"/> <keyword type="property" name="The “auto-negotiate” property" link="NMSettingWired.html#NMSettingWired--auto-negotiate"/> <keyword type="property" name="The “cloned-mac-address” property" link="NMSettingWired.html#NMSettingWired--cloned-mac-address"/> <keyword type="property" name="The “duplex” property" link="NMSettingWired.html#NMSettingWired--duplex"/> @@ -1123,6 +1134,8 @@ <keyword type="property" name="The “s390-options” property" link="NMSettingWired.html#NMSettingWired--s390-options"/> <keyword type="property" name="The “s390-subchannels” property" link="NMSettingWired.html#NMSettingWired--s390-subchannels"/> <keyword type="property" name="The “speed” property" link="NMSettingWired.html#NMSettingWired--speed"/> + <keyword type="property" name="The “wake-on-lan” property" link="NMSettingWired.html#NMSettingWired--wake-on-lan"/> + <keyword type="property" name="The “wake-on-lan-password” property" link="NMSettingWired.html#NMSettingWired--wake-on-lan-password"/> <keyword type="function" name="nm_setting_wireless_new ()" link="NMSettingWireless.html#nm-setting-wireless-new"/> <keyword type="function" name="nm_setting_wireless_get_ssid ()" link="NMSettingWireless.html#nm-setting-wireless-get-ssid"/> <keyword type="function" name="nm_setting_wireless_get_mode ()" link="NMSettingWireless.html#nm-setting-wireless-get-mode"/> @@ -1271,6 +1284,7 @@ <keyword type="function" name="nm_device_get_product ()" link="NMDevice.html#nm-device-get-product"/> <keyword type="function" name="nm_device_get_vendor ()" link="NMDevice.html#nm-device-get-vendor"/> <keyword type="function" name="nm_device_get_description ()" link="NMDevice.html#nm-device-get-description"/> + <keyword type="function" name="nm_device_get_metered ()" link="NMDevice.html#nm-device-get-metered" since="1.0.6"/> <keyword type="function" name="nm_device_disambiguate_names ()" link="NMDevice.html#nm-device-disambiguate-names"/> <keyword type="function" name="nm_device_disconnect ()" link="NMDevice.html#nm-device-disconnect"/> <keyword type="function" name="nm_device_disconnect_async ()" link="NMDevice.html#nm-device-disconnect-async"/> @@ -1305,6 +1319,7 @@ <keyword type="macro" name="NM_DEVICE_PRODUCT" link="NMDevice.html#NM-DEVICE-PRODUCT:CAPS"/> <keyword type="macro" name="NM_DEVICE_PHYSICAL_PORT_ID" link="NMDevice.html#NM-DEVICE-PHYSICAL-PORT-ID:CAPS"/> <keyword type="macro" name="NM_DEVICE_MTU" link="NMDevice.html#NM-DEVICE-MTU:CAPS"/> + <keyword type="macro" name="NM_DEVICE_METERED" link="NMDevice.html#NM-DEVICE-METERED:CAPS"/> <keyword type="property" name="The “active-connection” property" link="NMDevice.html#NMDevice--active-connection"/> <keyword type="property" name="The “autoconnect” property" link="NMDevice.html#NMDevice--autoconnect"/> <keyword type="property" name="The “available-connections” property" link="NMDevice.html#NMDevice--available-connections"/> @@ -1321,6 +1336,7 @@ <keyword type="property" name="The “ip4-config” property" link="NMDevice.html#NMDevice--ip4-config"/> <keyword type="property" name="The “ip6-config” property" link="NMDevice.html#NMDevice--ip6-config"/> <keyword type="property" name="The “managed” property" link="NMDevice.html#NMDevice--managed"/> + <keyword type="property" name="The “metered” property" link="NMDevice.html#NMDevice--metered"/> <keyword type="property" name="The “mtu” property" link="NMDevice.html#NMDevice--mtu"/> <keyword type="property" name="The “physical-port-id” property" link="NMDevice.html#NMDevice--physical-port-id"/> <keyword type="property" name="The “product” property" link="NMDevice.html#NMDevice--product"/> @@ -1427,7 +1443,9 @@ <keyword type="function" name="nm_device_wifi_get_access_point_by_path ()" link="NMDeviceWifi.html#nm-device-wifi-get-access-point-by-path"/> <keyword type="function" name="nm_device_wifi_get_access_points ()" link="NMDeviceWifi.html#nm-device-wifi-get-access-points"/> <keyword type="function" name="nm_device_wifi_request_scan ()" link="NMDeviceWifi.html#nm-device-wifi-request-scan"/> + <keyword type="function" name="nm_device_wifi_request_scan_options ()" link="NMDeviceWifi.html#nm-device-wifi-request-scan-options" since="1.0.6"/> <keyword type="function" name="nm_device_wifi_request_scan_async ()" link="NMDeviceWifi.html#nm-device-wifi-request-scan-async"/> + <keyword type="function" name="nm_device_wifi_request_scan_options_async ()" link="NMDeviceWifi.html#nm-device-wifi-request-scan-options-async" since="1.0.6"/> <keyword type="function" name="nm_device_wifi_request_scan_finish ()" link="NMDeviceWifi.html#nm-device-wifi-request-scan-finish"/> <keyword type="macro" name="NM_DEVICE_WIFI_HW_ADDRESS" link="NMDeviceWifi.html#NM-DEVICE-WIFI-HW-ADDRESS:CAPS"/> <keyword type="macro" name="NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS" link="NMDeviceWifi.html#NM-DEVICE-WIFI-PERMANENT-HW-ADDRESS:CAPS"/> @@ -1553,6 +1571,7 @@ <keyword type="function" name="nm_access_point_get_mode ()" link="NMAccessPoint.html#nm-access-point-get-mode"/> <keyword type="function" name="nm_access_point_get_max_bitrate ()" link="NMAccessPoint.html#nm-access-point-get-max-bitrate"/> <keyword type="function" name="nm_access_point_get_strength ()" link="NMAccessPoint.html#nm-access-point-get-strength"/> + <keyword type="function" name="nm_access_point_get_last_seen ()" link="NMAccessPoint.html#nm-access-point-get-last-seen" since="1.0.6"/> <keyword type="function" name="nm_access_point_filter_connections ()" link="NMAccessPoint.html#nm-access-point-filter-connections"/> <keyword type="function" name="nm_access_point_connection_valid ()" link="NMAccessPoint.html#nm-access-point-connection-valid"/> <keyword type="macro" name="NM_ACCESS_POINT_FLAGS" link="NMAccessPoint.html#NM-ACCESS-POINT-FLAGS:CAPS"/> @@ -1564,11 +1583,13 @@ <keyword type="macro" name="NM_ACCESS_POINT_MODE" link="NMAccessPoint.html#NM-ACCESS-POINT-MODE:CAPS"/> <keyword type="macro" name="NM_ACCESS_POINT_MAX_BITRATE" link="NMAccessPoint.html#NM-ACCESS-POINT-MAX-BITRATE:CAPS"/> <keyword type="macro" name="NM_ACCESS_POINT_STRENGTH" link="NMAccessPoint.html#NM-ACCESS-POINT-STRENGTH:CAPS"/> + <keyword type="macro" name="NM_ACCESS_POINT_LAST_SEEN" link="NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS"/> <keyword type="macro" name="NM_ACCESS_POINT_HW_ADDRESS" link="NMAccessPoint.html#NM-ACCESS-POINT-HW-ADDRESS:CAPS"/> <keyword type="property" name="The “bssid” property" link="NMAccessPoint.html#NMAccessPoint--bssid"/> <keyword type="property" name="The “flags” property" link="NMAccessPoint.html#NMAccessPoint--flags"/> <keyword type="property" name="The “frequency” property" link="NMAccessPoint.html#NMAccessPoint--frequency"/> <keyword type="property" name="The “hw-address” property" link="NMAccessPoint.html#NMAccessPoint--hw-address"/> + <keyword type="property" name="The “last-seen” property" link="NMAccessPoint.html#NMAccessPoint--last-seen"/> <keyword type="property" name="The “max-bitrate” property" link="NMAccessPoint.html#NMAccessPoint--max-bitrate"/> <keyword type="property" name="The “mode” property" link="NMAccessPoint.html#NMAccessPoint--mode"/> <keyword type="property" name="The “rsn-flags” property" link="NMAccessPoint.html#NMAccessPoint--rsn-flags"/> @@ -1655,6 +1676,8 @@ <keyword type="function" name="nm_utils_wifi_channel_to_freq ()" link="libnm-nm-utils.html#nm-utils-wifi-channel-to-freq"/> <keyword type="function" name="nm_utils_wifi_find_next_channel ()" link="libnm-nm-utils.html#nm-utils-wifi-find-next-channel"/> <keyword type="function" name="nm_utils_wifi_is_channel_valid ()" link="libnm-nm-utils.html#nm-utils-wifi-is-channel-valid"/> + <keyword type="function" name="nm_utils_wifi_2ghz_freqs ()" link="libnm-nm-utils.html#nm-utils-wifi-2ghz-freqs" since="1.0.6"/> + <keyword type="function" name="nm_utils_wifi_5ghz_freqs ()" link="libnm-nm-utils.html#nm-utils-wifi-5ghz-freqs" since="1.0.6"/> <keyword type="function" name="nm_utils_wifi_strength_bars ()" link="libnm-nm-utils.html#nm-utils-wifi-strength-bars"/> <keyword type="function" name="nm_utils_hwaddr_len ()" link="libnm-nm-utils.html#nm-utils-hwaddr-len"/> <keyword type="function" name="nm_utils_hwaddr_ntoa ()" link="libnm-nm-utils.html#nm-utils-hwaddr-ntoa"/> @@ -1671,6 +1694,8 @@ <keyword type="function" name="nm_utils_inet6_ntop ()" link="libnm-nm-utils.html#nm-utils-inet6-ntop"/> <keyword type="function" name="nm_utils_ipaddr_valid ()" link="libnm-nm-utils.html#nm-utils-ipaddr-valid"/> <keyword type="function" name="nm_utils_check_virtual_device_compatibility ()" link="libnm-nm-utils.html#nm-utils-check-virtual-device-compatibility"/> + <keyword type="function" name="nm_utils_enum_to_str ()" link="libnm-nm-utils.html#nm-utils-enum-to-str" since="1.0.6"/> + <keyword type="function" name="nm_utils_enum_from_str ()" link="libnm-nm-utils.html#nm-utils-enum-from-str" since="1.0.6"/> <keyword type="enum" name="enum NMUtilsSecurityType" link="libnm-nm-utils.html#NMUtilsSecurityType"/> <keyword type="macro" name="NM_UTILS_HWADDR_LEN_MAX" link="libnm-nm-utils.html#NM-UTILS-HWADDR-LEN-MAX:CAPS"/> <keyword type="macro" name="NM_UTILS_INET_ADDRSTRLEN" link="libnm-nm-utils.html#NM-UTILS-INET-ADDRSTRLEN:CAPS"/> @@ -1684,6 +1709,8 @@ <keyword type="macro" name="NM_VERSION_1_0" link="libnm-nm-version.html#NM-VERSION-1-0:CAPS"/> <keyword type="macro" name="NM_VERSION_1_0_2" link="libnm-nm-version.html#NM-VERSION-1-0-2:CAPS"/> <keyword type="macro" name="NM_VERSION_1_0_4" link="libnm-nm-version.html#NM-VERSION-1-0-4:CAPS"/> + <keyword type="macro" name="NM_VERSION_1_0_6" link="libnm-nm-version.html#NM-VERSION-1-0-6:CAPS"/> + <keyword type="macro" name="NM_VERSION_1_0_8" link="libnm-nm-version.html#NM-VERSION-1-0-8:CAPS"/> <keyword type="macro" name="NM_VERSION_MIN_REQUIRED" link="libnm-nm-version.html#NM-VERSION-MIN-REQUIRED:CAPS"/> <keyword type="macro" name="NM_VERSION_MAX_ALLOWED" link="libnm-nm-version.html#NM-VERSION-MAX-ALLOWED:CAPS"/> <keyword type="macro" name="NM_DEPRECATED_IN_0_9_10_FOR()" link="libnm-nm-version.html#NM-DEPRECATED-IN-0-9-10-FOR:CAPS"/> @@ -1691,10 +1718,11 @@ <keyword type="macro" name="NM_VERSION_CUR_STABLE" link="libnm-nm-version.html#NM-VERSION-CUR-STABLE:CAPS"/> <keyword type="macro" name="NM_VERSION_NEXT_STABLE" link="libnm-nm-version.html#NM-VERSION-NEXT-STABLE:CAPS"/> <keyword type="macro" name="NM_DEPRECATED_IN_0_9_10" link="libnm-nm-version.html#NM-DEPRECATED-IN-0-9-10:CAPS"/> - <keyword type="macro" name="NM_DEPRECATED_IN_1_0" link="libnm-nm-version.html#NM-DEPRECATED-IN-1-0:CAPS"/> <keyword type="macro" name="NM_AVAILABLE_IN_0_9_10" link="libnm-nm-version.html#NM-AVAILABLE-IN-0-9-10:CAPS"/> + <keyword type="macro" name="NM_DEPRECATED_IN_1_0" link="libnm-nm-version.html#NM-DEPRECATED-IN-1-0:CAPS"/> <keyword type="macro" name="NM_AVAILABLE_IN_1_0" link="libnm-nm-version.html#NM-AVAILABLE-IN-1-0:CAPS"/> <keyword type="macro" name="NM_AVAILABLE_IN_1_0_4" link="libnm-nm-version.html#NM-AVAILABLE-IN-1-0-4:CAPS"/> + <keyword type="macro" name="NM_AVAILABLE_IN_1_0_6" link="libnm-nm-version.html#NM-AVAILABLE-IN-1-0-6:CAPS"/> <keyword type="macro" name="NM_DBUS_PATH_VPN" link="libnm-nm-vpn-dbus-interface.html#NM-DBUS-PATH-VPN:CAPS"/> <keyword type="macro" name="NM_DBUS_INTERFACE_VPN" link="libnm-nm-vpn-dbus-interface.html#NM-DBUS-INTERFACE-VPN:CAPS"/> <keyword type="macro" name="NM_DBUS_PATH_VPN_CONNECTION" link="libnm-nm-vpn-dbus-interface.html#NM-DBUS-PATH-VPN-CONNECTION:CAPS"/> @@ -2005,6 +2033,11 @@ <keyword type="constant" name="NM_DEVICE_STATE_REASON_NEW_ACTIVATION" link="libnm-nm-dbus-interface.html#NM-DEVICE-STATE-REASON-NEW-ACTIVATION:CAPS"/> <keyword type="constant" name="NM_DEVICE_STATE_REASON_PARENT_CHANGED" link="libnm-nm-dbus-interface.html#NM-DEVICE-STATE-REASON-PARENT-CHANGED:CAPS"/> <keyword type="constant" name="NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED" link="libnm-nm-dbus-interface.html#NM-DEVICE-STATE-REASON-PARENT-MANAGED-CHANGED:CAPS"/> + <keyword type="constant" name="NM_METERED_UNKNOWN" link="libnm-nm-dbus-interface.html#NM-METERED-UNKNOWN:CAPS"/> + <keyword type="constant" name="NM_METERED_YES" link="libnm-nm-dbus-interface.html#NM-METERED-YES:CAPS"/> + <keyword type="constant" name="NM_METERED_NO" link="libnm-nm-dbus-interface.html#NM-METERED-NO:CAPS"/> + <keyword type="constant" name="NM_METERED_GUESS_YES" link="libnm-nm-dbus-interface.html#NM-METERED-GUESS-YES:CAPS"/> + <keyword type="constant" name="NM_METERED_GUESS_NO" link="libnm-nm-dbus-interface.html#NM-METERED-GUESS-NO:CAPS"/> <keyword type="constant" name="NM_ACTIVE_CONNECTION_STATE_UNKNOWN" link="libnm-nm-dbus-interface.html#NM-ACTIVE-CONNECTION-STATE-UNKNOWN:CAPS"/> <keyword type="constant" name="NM_ACTIVE_CONNECTION_STATE_ACTIVATING" link="libnm-nm-dbus-interface.html#NM-ACTIVE-CONNECTION-STATE-ACTIVATING:CAPS"/> <keyword type="constant" name="NM_ACTIVE_CONNECTION_STATE_ACTIVATED" link="libnm-nm-dbus-interface.html#NM-ACTIVE-CONNECTION-STATE-ACTIVATED:CAPS"/> @@ -2066,6 +2099,16 @@ <keyword type="constant" name="NM_VLAN_FLAG_REORDER_HEADERS" link="NMSettingVlan.html#NM-VLAN-FLAG-REORDER-HEADERS:CAPS"/> <keyword type="constant" name="NM_VLAN_FLAG_GVRP" link="NMSettingVlan.html#NM-VLAN-FLAG-GVRP:CAPS"/> <keyword type="constant" name="NM_VLAN_FLAG_LOOSE_BINDING" link="NMSettingVlan.html#NM-VLAN-FLAG-LOOSE-BINDING:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_NONE" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-NONE:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-DEFAULT:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_PHY" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-PHY:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-UNICAST:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-MULTICAST:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-BROADCAST:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_ARP" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-ARP:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-MAGIC:CAPS"/> + <keyword type="constant" name="_NM_SETTING_WIRED_WAKE_ON_LAN_LAST" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-LAST:CAPS"/> + <keyword type="constant" name="NM_SETTING_WIRED_WAKE_ON_LAN_ALL" link="NMSettingWired.html#NM-SETTING-WIRED-WAKE-ON-LAN-ALL:CAPS"/> <keyword type="constant" name="NM_WEP_KEY_TYPE_UNKNOWN" link="NMSettingWirelessSecurity.html#NM-WEP-KEY-TYPE-UNKNOWN:CAPS"/> <keyword type="constant" name="NM_WEP_KEY_TYPE_KEY" link="NMSettingWirelessSecurity.html#NM-WEP-KEY-TYPE-KEY:CAPS"/> <keyword type="constant" name="NM_WEP_KEY_TYPE_PASSPHRASE" link="NMSettingWirelessSecurity.html#NM-WEP-KEY-TYPE-PASSPHRASE:CAPS"/> diff --git a/docs/libnm/html/object-tree.html b/docs/libnm/html/object-tree.html index 424f0762f..871987597 100644 --- a/docs/libnm/html/object-tree.html +++ b/docs/libnm/html/object-tree.html @@ -92,6 +92,7 @@ <span class="lineart">├──</span> <a class="link" href="libnm-nm-dbus-interface.html#NMSecretAgentGetSecretsFlags" title="enum NMSecretAgentGetSecretsFlags">NMSecretAgentGetSecretsFlags</a> <span class="lineart">├──</span> <a class="link" href="NMSettingDcb.html#NMSettingDcbFlags" title="enum NMSettingDcbFlags">NMSettingDcbFlags</a> <span class="lineart">├──</span> <a class="link" href="NMSetting.html#NMSettingSecretFlags" title="enum NMSettingSecretFlags">NMSettingSecretFlags</a> + <span class="lineart">├──</span> <a class="link" href="NMSettingWired.html#NMSettingWiredWakeOnLan" title="enum NMSettingWiredWakeOnLan">NMSettingWiredWakeOnLan</a> <span class="lineart">├──</span> <a class="link" href="NMSettingVlan.html#NMVlanFlags" title="enum NMVlanFlags">NMVlanFlags</a> <span class="lineart">╰──</span> <a class="link" href="NMVpnEditor.html#NMVpnEditorPluginCapability" title="enum NMVpnEditorPluginCapability">NMVpnEditorPluginCapability</a> <a href="/usr/share/gtk-doc/html/gobject/gobject-Enumeration-and-Flag-Types.html">GEnum</a> @@ -112,6 +113,7 @@ <span class="lineart">├──</span> <a class="link" href="libnm-nm-dbus-interface.html#NMDeviceState" title="enum NMDeviceState">NMDeviceState</a> <span class="lineart">├──</span> <a class="link" href="libnm-nm-dbus-interface.html#NMDeviceStateReason" title="enum NMDeviceStateReason">NMDeviceStateReason</a> <span class="lineart">├──</span> <a class="link" href="libnm-nm-dbus-interface.html#NMDeviceType" title="enum NMDeviceType">NMDeviceType</a> + <span class="lineart">├──</span> <a class="link" href="libnm-nm-dbus-interface.html#NMMetered" title="enum NMMetered">NMMetered</a> <span class="lineart">├──</span> <a class="link" href="NMSetting8021x.html#NMSetting8021xCKFormat" title="enum NMSetting8021xCKFormat">NMSetting8021xCKFormat</a> <span class="lineart">├──</span> <a class="link" href="NMSetting8021x.html#NMSetting8021xCKScheme" title="enum NMSetting8021xCKScheme">NMSetting8021xCKScheme</a> <span class="lineart">├──</span> <a class="link" href="NMSetting.html#NMSettingCompareFlags" title="enum NMSettingCompareFlags">NMSettingCompareFlags</a> diff --git a/docs/libnm/libnm-sections.txt b/docs/libnm/libnm-sections.txt index ed0cefa8c..35ea15330 100644 --- a/docs/libnm/libnm-sections.txt +++ b/docs/libnm/libnm-sections.txt @@ -10,6 +10,7 @@ NM_ACCESS_POINT_FREQUENCY NM_ACCESS_POINT_MODE NM_ACCESS_POINT_MAX_BITRATE NM_ACCESS_POINT_STRENGTH +NM_ACCESS_POINT_LAST_SEEN NM_ACCESS_POINT_HW_ADDRESS nm_access_point_get_flags nm_access_point_get_wpa_flags @@ -20,6 +21,7 @@ nm_access_point_get_frequency nm_access_point_get_mode nm_access_point_get_max_bitrate nm_access_point_get_strength +nm_access_point_get_last_seen nm_access_point_filter_connections nm_access_point_connection_valid <SUBSECTION Standard> @@ -101,6 +103,7 @@ NM_CLIENT_DEVICES NM_CLIENT_CONNECTIONS NM_CLIENT_HOSTNAME NM_CLIENT_CAN_MODIFY +NM_CLIENT_METERED NM_CLIENT_DEVICE_ADDED NM_CLIENT_DEVICE_REMOVED NM_CLIENT_PERMISSION_CHANGED @@ -269,6 +272,7 @@ NM_TYPE_DEVICE_STATE_REASON NM_TYPE_DEVICE_TYPE NM_TYPE_DEVICE_WIFI_CAPABILITIES NM_TYPE_MANAGER_ERROR +NM_TYPE_METERED NM_TYPE_SECRET_AGENT_CAPABILITIES NM_TYPE_SECRET_AGENT_ERROR NM_TYPE_SECRET_AGENT_GET_SECRETS_FLAGS @@ -282,6 +286,7 @@ NM_TYPE_SETTING_DIFF_RESULT NM_TYPE_SETTING_IP6_CONFIG_PRIVACY NM_TYPE_SETTING_SECRET_FLAGS NM_TYPE_SETTING_SERIAL_PARITY +NM_TYPE_SETTING_WIRED_WAKE_ON_LAN NM_TYPE_STATE NM_TYPE_UTILS_SECURITY_TYPE NM_TYPE_VLAN_FLAGS @@ -310,6 +315,7 @@ nm_device_state_reason_get_type nm_device_type_get_type nm_device_wifi_capabilities_get_type nm_manager_error_get_type +nm_metered_get_type nm_secret_agent_capabilities_get_type nm_secret_agent_error_get_type nm_secret_agent_get_secrets_flags_get_type @@ -322,6 +328,7 @@ nm_setting_diff_result_get_type nm_setting_ip6_config_privacy_get_type nm_setting_secret_flags_get_type nm_setting_serial_parity_get_type +nm_setting_wired_wake_on_lan_get_type nm_settings_error_get_type nm_state_get_type nm_utils_security_type_get_type @@ -389,6 +396,7 @@ NMBluetoothCapabilities NMDeviceModemCapabilities NMDeviceState NMDeviceStateReason +NMMetered NMActiveConnectionState NMSecretAgentGetSecretsFlags NMSecretAgentCapabilities @@ -420,6 +428,7 @@ NM_DEVICE_VENDOR NM_DEVICE_PRODUCT NM_DEVICE_PHYSICAL_PORT_ID NM_DEVICE_MTU +NM_DEVICE_METERED nm_device_get_iface nm_device_get_ip_iface nm_device_get_device_type @@ -448,6 +457,7 @@ nm_device_is_software nm_device_get_product nm_device_get_vendor nm_device_get_description +nm_device_get_metered nm_device_disambiguate_names nm_device_disconnect nm_device_disconnect_async @@ -714,7 +724,9 @@ nm_device_wifi_get_active_access_point nm_device_wifi_get_access_point_by_path nm_device_wifi_get_access_points nm_device_wifi_request_scan +nm_device_wifi_request_scan_options nm_device_wifi_request_scan_async +nm_device_wifi_request_scan_options_async nm_device_wifi_request_scan_finish <SUBSECTION Standard> NMDeviceWifi @@ -1320,6 +1332,7 @@ NM_SETTING_CONNECTION_SLAVE_TYPE NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES NM_SETTING_CONNECTION_SECONDARIES NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT +NM_SETTING_CONNECTION_METERED NMSettingConnectionAutoconnectSlaves NMSettingConnection nm_setting_connection_new @@ -1348,6 +1361,7 @@ nm_setting_connection_add_secondary nm_setting_connection_remove_secondary nm_setting_connection_remove_secondary_by_value nm_setting_connection_get_gateway_ping_timeout +nm_setting_connection_get_metered <SUBSECTION Standard> NMSettingConnectionClass NM_IS_SETTING_CONNECTION @@ -1911,6 +1925,7 @@ nm_setting_wimax_get_type <FILE>nm-setting-wired</FILE> <TITLE>NMSettingWired</TITLE> NM_SETTING_WIRED_SETTING_NAME +NMSettingWiredWakeOnLan NM_SETTING_WIRED_PORT NM_SETTING_WIRED_SPEED NM_SETTING_WIRED_DUPLEX @@ -1922,6 +1937,8 @@ NM_SETTING_WIRED_MTU NM_SETTING_WIRED_S390_SUBCHANNELS NM_SETTING_WIRED_S390_NETTYPE NM_SETTING_WIRED_S390_OPTIONS +NM_SETTING_WIRED_WAKE_ON_LAN +NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD nm_setting_wired_new nm_setting_wired_get_port nm_setting_wired_get_speed @@ -1945,6 +1962,8 @@ nm_setting_wired_get_s390_option_by_key nm_setting_wired_add_s390_option nm_setting_wired_remove_s390_option nm_setting_wired_get_valid_s390_options +nm_setting_wired_get_wake_on_lan +nm_setting_wired_get_wake_on_lan_password <SUBSECTION Standard> NMSettingWired NMSettingWiredClass @@ -2135,6 +2154,8 @@ nm_utils_wifi_freq_to_channel nm_utils_wifi_channel_to_freq nm_utils_wifi_find_next_channel nm_utils_wifi_is_channel_valid +nm_utils_wifi_2ghz_freqs +nm_utils_wifi_5ghz_freqs nm_utils_wifi_strength_bars NM_UTILS_HWADDR_LEN_MAX nm_utils_hwaddr_len @@ -2153,6 +2174,8 @@ nm_utils_inet4_ntop nm_utils_inet6_ntop nm_utils_ipaddr_valid nm_utils_check_virtual_device_compatibility +nm_utils_enum_to_str +nm_utils_enum_from_str </SECTION> <SECTION> @@ -2167,17 +2190,20 @@ NM_VERSION_0_9_10 NM_VERSION_1_0 NM_VERSION_1_0_2 NM_VERSION_1_0_4 +NM_VERSION_1_0_6 +NM_VERSION_1_0_8 NM_VERSION_CUR_STABLE NM_VERSION_NEXT_STABLE NM_VERSION_MIN_REQUIRED NM_VERSION_MAX_ALLOWED NM_DEPRECATED_IN_0_9_10 NM_DEPRECATED_IN_0_9_10_FOR +NM_AVAILABLE_IN_0_9_10 NM_DEPRECATED_IN_1_0 NM_DEPRECATED_IN_1_0_FOR -NM_AVAILABLE_IN_0_9_10 NM_AVAILABLE_IN_1_0 NM_AVAILABLE_IN_1_0_4 +NM_AVAILABLE_IN_1_0_6 </SECTION> <SECTION> @@ -2322,3 +2348,10 @@ NM_WIMAX_NSP_GET_CLASS nm_wimax_nsp_get_type </SECTION> +<SECTION> +<FILE>test-general-enums</FILE> +NMTestGeneralBoolEnum +NMTestGeneralMetaFlags +NMTestGeneralColorFlags +</SECTION> + diff --git a/docs/libnm/libnm.types b/docs/libnm/libnm.types index 2742a215a..c148200c2 100644 --- a/docs/libnm/libnm.types +++ b/docs/libnm/libnm.types @@ -41,6 +41,7 @@ nm_ip_address_get_type nm_ip_config_get_type nm_ip_route_get_type nm_manager_error_get_type +nm_metered_get_type nm_object_get_type nm_remote_connection_get_type nm_secret_agent_capabilities_get_type @@ -82,6 +83,7 @@ nm_setting_vlan_get_type nm_setting_vpn_get_type nm_setting_wimax_get_type nm_setting_wired_get_type +nm_setting_wired_wake_on_lan_get_type nm_setting_wireless_get_type nm_setting_wireless_security_get_type nm_settings_error_get_type diff --git a/docs/libnm/version.xml b/docs/libnm/version.xml index ee90284c2..af0b7ddbf 100644 --- a/docs/libnm/version.xml +++ b/docs/libnm/version.xml @@ -1 +1 @@ -1.0.4 +1.0.6 diff --git a/include/nm-macros-internal.h b/include/nm-macros-internal.h index 405051f38..170fb46cf 100644 --- a/include/nm-macros-internal.h +++ b/include/nm-macros-internal.h @@ -46,6 +46,31 @@ /********************************************************/ +/* http://stackoverflow.com/a/2124385/354393 */ + +#define NM_NARG(...) \ + _NM_NARG(__VA_ARGS__,_NM_NARG_RSEQ_N()) +#define _NM_NARG(...) \ + _NM_NARG_ARG_N(__VA_ARGS__) +#define _NM_NARG_ARG_N( \ + _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \ + _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ + _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ + _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ + _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ + _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ + _61,_62,_63,N,...) N +#define _NM_NARG_RSEQ_N() \ + 63,62,61,60, \ + 59,58,57,56,55,54,53,52,51,50, \ + 49,48,47,46,45,44,43,42,41,40, \ + 39,38,37,36,35,34,33,32,31,30, \ + 29,28,27,26,25,24,23,22,21,20, \ + 19,18,17,16,15,14,13,12,11,10, \ + 9,8,7,6,5,4,3,2,1,0 + +/********************************************************/ + #if defined (__GNUC__) #define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(GCC diagnostic ignored warning) #elif defined (__clang__) @@ -85,21 +110,68 @@ /* macro to return strlen() of a compile time string. */ #define STRLEN(str) ( sizeof ("" str) - 1 ) -#define NM_IN_SET(x, y, ...) \ - ({ \ - const typeof(y) _y = (y); \ - typeof(_y) _x = (x); \ - unsigned _i; \ - gboolean _found = FALSE; \ - for (_i = 0; _i < 1 + sizeof((typeof(_x)[]) { __VA_ARGS__ })/sizeof(typeof(_x)); _i++) { \ - if (((typeof(_x)[]) { _y, __VA_ARGS__ })[_i] == _x) { \ - _found = TRUE; \ - break; \ - } \ - } \ - _found; \ +/********************************************************/ + +#define _NM_IN_SET_EVAL_1(op, x, y1) \ + ({ \ + typeof(x) _x = (x); \ + ( (_x == (y1)) \ + ); \ + }) + +#define _NM_IN_SET_EVAL_2(op, x, y1, y2) \ + ({ \ + typeof(x) _x = (x); \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + ); \ + }) + +#define _NM_IN_SET_EVAL_3(op, x, y1, y2, y3) \ + ({ \ + typeof(x) _x = (x); \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + op (_x == (y3)) \ + ); \ }) +#define _NM_IN_SET_EVAL_4(op, x, y1, y2, y3, y4) \ + ({ \ + typeof(x) _x = (x); \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + op (_x == (y3)) \ + op (_x == (y4)) \ + ); \ + }) + +#define _NM_IN_SET_EVAL_5(op, x, y1, y2, y3, y4, y5) \ + ({ \ + typeof(x) _x = (x); \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + op (_x == (y3)) \ + op (_x == (y4)) \ + op (_x == (y5)) \ + ); \ + }) + +#define _NM_IN_SET_EVAL_N2(op, x, n, ...) _NM_IN_SET_EVAL_##n(op, x, __VA_ARGS__) +#define _NM_IN_SET_EVAL_N(op, x, n, ...) _NM_IN_SET_EVAL_N2(op, x, n, __VA_ARGS__) + +/* Beware that this does short-circuit evaluation (use "||" instead of "|") + * which has a possibly unexpected non-function-like behavior. + * Use NM_IN_SET_SE if you need all arguments to be evaluted. */ +#define NM_IN_SET(x, ...) _NM_IN_SET_EVAL_N(||, x, NM_NARG (__VA_ARGS__), __VA_ARGS__) + +/* "SE" stands for "side-effect". Contrary to NM_IN_SET(), this does not do + * short-circuit evaluation, which can make a difference if the arguments have + * side-effects. */ +#define NM_IN_SET_SE(x, ...) _NM_IN_SET_EVAL_N(|, x, NM_NARG (__VA_ARGS__), __VA_ARGS__) + +/*****************************************************************************/ + #define NM_PRINT_FMT_QUOTED(cond, prefix, str, suffix, str_else) \ (cond) ? (prefix) : "", \ (cond) ? (str) : (str_else), \ diff --git a/introspection/nm-access-point.xml b/introspection/nm-access-point.xml index 21f238ffa..ef5af6ab7 100644 --- a/introspection/nm-access-point.xml +++ b/introspection/nm-access-point.xml @@ -30,6 +30,13 @@ <property name="Strength" type="y" access="read"> <tp:docstring>The current signal quality of the access point, in percent.</tp:docstring> </property> + <property name="LastSeen" type="i" access="read"> + <tp:docstring> + The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access + point was found in scan results. A value of -1 means the access point + has never been found in scan results. + </tp:docstring> + </property> <signal name="PropertiesChanged"> <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> diff --git a/introspection/nm-device-wifi.xml b/introspection/nm-device-wifi.xml index d1c5313ed..b94aae846 100644 --- a/introspection/nm-device-wifi.xml +++ b/introspection/nm-device-wifi.xml @@ -37,7 +37,8 @@ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="options" type="a{sv}" direction="in"> <tp:docstring> - Options of scan (currently unused argument). + Options of scan. + Currently 'ssids' option with value of "aay" type is supported. </tp:docstring> </arg> <tp:docstring> diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index e405a384b..b2e3827e2 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -139,6 +139,12 @@ The device MTU (maximum transmission unit). </tp:docstring> </property> + <property name="Metered" type="u" access="read" tp:type="NM_METERED"> + <tp:docstring> + Whether the amount of traffic flowing through the device is + subject to limitations, for example set by service providers. + </tp:docstring> + </property> <method name="Disconnect"> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/> @@ -654,6 +660,34 @@ </tp:enumvalue> </tp:enum> + <tp:enum name="NM_METERED" type="u"> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The device metered status is unknown. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="YES" value="1"> + <tp:docstring> + The device is metered and the value was statically set. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NO" value="2"> + <tp:docstring> + The device is not metered and the value was statically set. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GUESS_YES" value="3"> + <tp:docstring> + The device is metered and the value was guessed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GUESS_NO" value="4"> + <tp:docstring> + The device is not metered and the value was guessed. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + <tp:struct name="NM_DEVICE_STATE_REASON_STRUCT"> <tp:member type="u" name="state" tp:type="NM_DEVICE_STATE"> <tp:docstring> diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml index a9bb6dcf1..f0d04438d 100644 --- a/introspection/nm-manager.xml +++ b/introspection/nm-manager.xml @@ -335,6 +335,14 @@ </tp:docstring> </property> + <property name="Metered" type="u" access="read" tp:type="NM_METERED"> + <tp:docstring> + Wheter the connectivity is metered. This is equivalent to the + metered property of the device associated with the primary + connection. + </tp:docstring> + </property> + <property name="ActivatingConnection" type="o" access="read"> <tp:docstring> The object path of an active connection that is currently diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index acdc8b89c..8f226582c 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -1498,7 +1498,8 @@ nm_connection_get_uuid (NMConnection *connection) g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); s_con = nm_connection_get_setting_connection (connection); - g_return_val_if_fail (s_con != NULL, NULL); + if (!s_con) + return NULL; return nm_setting_connection_get_uuid (s_con); } diff --git a/libnm-core/nm-core-enum-types.c b/libnm-core/nm-core-enum-types.c index cfb264cfb..a9e4266a7 100644 --- a/libnm-core/nm-core-enum-types.c +++ b/libnm-core/nm-core-enum-types.c @@ -413,6 +413,28 @@ nm_device_state_reason_get_type (void) return g_define_type_id__volatile; } GType +nm_metered_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_METERED_UNKNOWN, "NM_METERED_UNKNOWN", "unknown" }, + { NM_METERED_YES, "NM_METERED_YES", "yes" }, + { NM_METERED_NO, "NM_METERED_NO", "no" }, + { NM_METERED_GUESS_YES, "NM_METERED_GUESS_YES", "guess-yes" }, + { NM_METERED_GUESS_NO, "NM_METERED_GUESS_NO", "guess-no" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMMetered"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType nm_active_connection_state_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; @@ -839,6 +861,30 @@ nm_vlan_flags_get_type (void) return g_define_type_id__volatile; } GType +nm_setting_wired_wake_on_lan_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GFlagsValue values[] = { + { NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT, "NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT", "default" }, + { NM_SETTING_WIRED_WAKE_ON_LAN_PHY, "NM_SETTING_WIRED_WAKE_ON_LAN_PHY", "phy" }, + { NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST, "NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST", "unicast" }, + { NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST, "NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST", "multicast" }, + { NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST, "NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST", "broadcast" }, + { NM_SETTING_WIRED_WAKE_ON_LAN_ARP, "NM_SETTING_WIRED_WAKE_ON_LAN_ARP", "arp" }, + { NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC, "NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC", "magic" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_flags_register_static (g_intern_static_string ("NMSettingWiredWakeOnLan"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType nm_wep_key_type_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; diff --git a/libnm-core/nm-core-enum-types.h b/libnm-core/nm-core-enum-types.h index abc646b20..7e5c6df0b 100644 --- a/libnm-core/nm-core-enum-types.h +++ b/libnm-core/nm-core-enum-types.h @@ -35,6 +35,8 @@ GType nm_device_state_get_type (void) G_GNUC_CONST; #define NM_TYPE_DEVICE_STATE (nm_device_state_get_type ()) GType nm_device_state_reason_get_type (void) G_GNUC_CONST; #define NM_TYPE_DEVICE_STATE_REASON (nm_device_state_reason_get_type ()) +GType nm_metered_get_type (void) G_GNUC_CONST; +#define NM_TYPE_METERED (nm_metered_get_type ()) GType nm_active_connection_state_get_type (void) G_GNUC_CONST; #define NM_TYPE_ACTIVE_CONNECTION_STATE (nm_active_connection_state_get_type ()) GType nm_secret_agent_get_secrets_flags_get_type (void) G_GNUC_CONST; @@ -73,6 +75,8 @@ GType nm_vlan_priority_map_get_type (void) G_GNUC_CONST; #define NM_TYPE_VLAN_PRIORITY_MAP (nm_vlan_priority_map_get_type ()) GType nm_vlan_flags_get_type (void) G_GNUC_CONST; #define NM_TYPE_VLAN_FLAGS (nm_vlan_flags_get_type ()) +GType nm_setting_wired_wake_on_lan_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_WIRED_WAKE_ON_LAN (nm_setting_wired_wake_on_lan_get_type ()) GType nm_wep_key_type_get_type (void) G_GNUC_CONST; #define NM_TYPE_WEP_KEY_TYPE (nm_wep_key_type_get_type ()) GType nm_setting_secret_flags_get_type (void) G_GNUC_CONST; diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index dd5151e08..73a379c34 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -159,4 +159,6 @@ const char *nm_utils_bond_mode_int_to_string (int mode); gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback); +gboolean _nm_dbus_error_has_name (GError *error, + const char *dbus_error_name); #endif diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index ccc3b3a9e..8c5cd3c4c 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -403,7 +403,6 @@ typedef enum { NM_DEVICE_STATE_FAILED = 120 } NMDeviceState; - /** * NMDeviceStateReason: * @NM_DEVICE_STATE_REASON_NONE: No reason given @@ -540,6 +539,26 @@ typedef enum { NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62, } NMDeviceStateReason; +/** + * NMMetered: + * @NM_METERED_UNKNOWN: The metered status is unknown + * @NM_METERED_YES: Metered, the value was statically set + * @NM_METERED_NO: Not metered, the value was statically set + * @NM_METERED_GUESS_YES: Metered, the value was guessed + * @NM_METERED_GUESS_NO: Not metered, the value was guessed + * + * (Corresponds to the NM_METERED type in nm-device.xml.) + * + * Since: 1.0.6 + **/ +NM_AVAILABLE_IN_1_0_6 +typedef enum { + NM_METERED_UNKNOWN = 0, + NM_METERED_YES = 1, + NM_METERED_NO = 2, + NM_METERED_GUESS_YES = 3, + NM_METERED_GUESS_NO = 4, +} NMMetered; /** * NMActiveConnectionState: diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 07b3401d1..28e590df3 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -76,6 +76,7 @@ typedef struct { char *zone; GSList *secondaries; /* secondary connections to activate with the base connection */ guint gateway_ping_timeout; + NMMetered metered; } NMSettingConnectionPrivate; enum { @@ -95,6 +96,7 @@ enum { PROP_AUTOCONNECT_SLAVES, PROP_SECONDARIES, PROP_GATEWAY_PING_TIMEOUT, + PROP_METERED, LAST_PROP }; @@ -760,6 +762,23 @@ nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting) return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->gateway_ping_timeout; } +/** + * nm_setting_connection_get_metered: + * @setting: the #NMSettingConnection + * + * Returns: the #NMSettingConnection:metered property of the setting. + * + * Since: 1.0.6 + **/ +NMMetered +nm_setting_connection_get_metered (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), + NM_METERED_UNKNOWN); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->metered; +} + static void _set_error_missing_base_setting (GError **error, const char *type) { @@ -921,6 +940,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } + if (priv->metered != NM_METERED_UNKNOWN && + priv->metered != NM_METERED_YES && + priv->metered != NM_METERED_NO) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("metered value %d is not valid"), priv->metered); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_METERED); + return FALSE; + } + /* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */ if (!priv->uuid) { @@ -1154,6 +1185,9 @@ set_property (GObject *object, guint prop_id, case PROP_GATEWAY_PING_TIMEOUT: priv->gateway_ping_timeout = g_value_get_uint (value); break; + case PROP_METERED: + priv->metered = g_value_get_enum (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1227,6 +1261,9 @@ get_property (GObject *object, guint prop_id, case PROP_GATEWAY_PING_TIMEOUT: g_value_set_uint (value, priv->gateway_ping_timeout); break; + case PROP_METERED: + g_value_set_enum (value, priv->metered); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1626,4 +1663,27 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)); + + /** + * NMSettingConnection:metered: + * + * Whether the connection is metered. + * + * Since: 1.0.6 + **/ + /* ---ifcfg-rh--- + * property: metered + * variable: CONNECTION_METERED + * values: yes,no,unknown + * description: Whether the device is metered + * example: CONNECTION_METERED=yes + * ---end--- + */ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_enum (NM_SETTING_CONNECTION_METERED, "", "", + NM_TYPE_METERED, + NM_METERED_UNKNOWN, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h index ff89d2008..24b5f6acc 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -59,6 +59,7 @@ G_BEGIN_DECLS #define NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES "autoconnect-slaves" #define NM_SETTING_CONNECTION_SECONDARIES "secondaries" #define NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT "gateway-ping-timeout" +#define NM_SETTING_CONNECTION_METERED "metered" /* Types for property values */ /** @@ -142,6 +143,8 @@ void nm_setting_connection_remove_secondary (NMSettingConnection *set gboolean nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting, const char *sec_uuid); guint32 nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting); +NM_AVAILABLE_IN_1_0_6 +NMMetered nm_setting_connection_get_metered (NMSettingConnection *setting); G_END_DECLS diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index e6f0401a0..4b73d5fd0 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -53,10 +53,8 @@ canonicalize_ip (int family, const char *ip, gboolean null_any) char addr_str[NM_UTILS_INET_ADDRSTRLEN]; int ret; - if (!ip) { - g_return_val_if_fail (null_any == TRUE, NULL); + if (!ip) return NULL; - } ret = inet_pton (family, ip, addr_bytes); g_return_val_if_fail (ret == 1, NULL); @@ -74,6 +72,11 @@ canonicalize_ip (int family, const char *ip, gboolean null_any) static gboolean valid_ip (int family, const char *ip, GError **error) { + if (!ip) { + g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED, + family == AF_INET ? _("Missing IPv4 address") : _("Missing IPv6 address'")); + return FALSE; + } if (!nm_utils_ipaddr_valid (family, ip)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED, family == AF_INET ? _("Invalid IPv4 address '%s'") : _("Invalid IPv6 address '%s"), @@ -2012,7 +2015,7 @@ set_property (GObject *object, guint prop_id, gateway = g_value_get_string (value); g_return_if_fail (!gateway || nm_utils_ipaddr_valid (NM_SETTING_IP_CONFIG_GET_FAMILY (setting), gateway)); g_free (priv->gateway); - priv->gateway = canonicalize_ip (NM_SETTING_IP_CONFIG_GET_FAMILY (setting), gateway, TRUE); + priv->gateway = canonicalize_ip (NM_SETTING_IP_CONFIG_GET_FAMILY (setting), gateway, FALSE); break; case PROP_ROUTES: g_ptr_array_unref (priv->routes); diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c index f622ddcbf..d904ad52d 100644 --- a/libnm-core/nm-setting-vlan.c +++ b/libnm-core/nm-setting-vlan.c @@ -742,7 +742,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class) * property: flags * variable: VLAN_FLAGS, REORDER_HDR * values: "GVRP", "LOOSE_BINDING" for VLAN_FLAGS; 0 or 1 for REORDER_HDR - * description: Parent interface of the VLAN. + * description: VLAN flags. * ---end--- */ g_object_class_install_property diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 2a7479405..3d0c5b646 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -30,6 +30,7 @@ #include "nm-utils.h" #include "nm-utils-private.h" #include "nm-setting-private.h" +#include "nm-macros-internal.h" /** * SECTION:nm-setting-wired @@ -57,6 +58,8 @@ typedef struct { char **s390_subchannels; char *s390_nettype; GHashTable *s390_options; + NMSettingWiredWakeOnLan wol; + char *wol_password; } NMSettingWiredPrivate; enum { @@ -72,6 +75,8 @@ enum { PROP_S390_SUBCHANNELS, PROP_S390_NETTYPE, PROP_S390_OPTIONS, + PROP_WAKE_ON_LAN, + PROP_WAKE_ON_LAN_PASSWORD, LAST_PROP }; @@ -554,6 +559,43 @@ nm_setting_wired_get_valid_s390_options (NMSettingWired *setting) return valid_s390_opts; } +/** + * nm_setting_wired_get_wake_on_lan: + * @setting: the #NMSettingWired + * + * Returns the Wake-on-LAN options enabled for the connection + * + * Returns: the Wake-on-LAN options + * + * Since: 1.0.6 + */ +NMSettingWiredWakeOnLan +nm_setting_wired_get_wake_on_lan (NMSettingWired *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NM_SETTING_WIRED_WAKE_ON_LAN_NONE); + + return NM_SETTING_WIRED_GET_PRIVATE (setting)->wol; +} + +/** + * nm_setting_wired_get_wake_on_lan_password: + * @setting: the #NMSettingWired + * + * Returns the Wake-on-LAN password. This only applies to + * %NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC. + * + * Returns: the Wake-on-LAN setting password, or %NULL if there is no password. + * + * Since: 1.0.6 + */ +const char * +nm_setting_wired_get_wake_on_lan_password (NMSettingWired *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + + return NM_SETTING_WIRED_GET_PRIVATE (setting)->wol_password; +} + static gboolean verify (NMSetting *setting, NMConnection *connection, GError **error) { @@ -654,6 +696,34 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + if ( NM_FLAGS_HAS (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) + && NM_FLAGS_ANY (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_ALL)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Wake-on-LAN mode 'default' is incompatible with other flags")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN); + return FALSE; + } + + if (priv->wol_password && !NM_FLAGS_HAS (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Wake-on-LAN password can only be used with magic packet mode")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD); + return FALSE; + } + + if (priv->wol_password && !nm_utils_hwaddr_valid (priv->wol_password, ETH_ALEN)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("is not a valid MAC address")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD); + return FALSE; + } + return TRUE; } @@ -693,6 +763,8 @@ finalize (GObject *object) if (priv->s390_subchannels) g_strfreev (priv->s390_subchannels); + g_free (priv->wol_password); + G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object); } @@ -756,6 +828,13 @@ set_property (GObject *object, guint prop_id, g_hash_table_unref (priv->s390_options); priv->s390_options = _nm_utils_copy_strdict (g_value_get_boxed (value)); break; + case PROP_WAKE_ON_LAN: + priv->wol = g_value_get_uint (value); + break; + case PROP_WAKE_ON_LAN_PASSWORD: + g_free (priv->wol_password); + priv->wol_password = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -803,6 +882,12 @@ get_property (GObject *object, guint prop_id, case PROP_S390_OPTIONS: g_value_take_boxed (value, _nm_utils_copy_strdict (priv->s390_options)); break; + case PROP_WAKE_ON_LAN: + g_value_set_uint (value, priv->wol); + break; + case PROP_WAKE_ON_LAN_PASSWORD: + g_value_set_string (value, priv->wol_password); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1097,4 +1182,39 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class) G_VARIANT_TYPE ("a{ss}"), _nm_utils_strdict_to_dbus, _nm_utils_strdict_from_dbus); + + /** + * NMSettingWired:wake-on-lan: + * + * The #NMSettingWiredWakeOnLan options to enable. Not all devices support all options. + * May be any combination of %NM_SETTING_WIRED_WAKE_ON_LAN_PHY, + * %NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST, %NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST, + * %NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST, %NM_SETTING_WIRED_WAKE_ON_LAN_ARP, + * %NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_WAKE_ON_LAN, + g_param_spec_uint (NM_SETTING_WIRED_WAKE_ON_LAN, "", "", + 0, G_MAXUINT32, NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT, + G_PARAM_CONSTRUCT | + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + /** + * NMSettingWired:wake-on-lan-password: + * + * If specified, the password used with magic-packet-based + * Wake-on-LAN, represented as an Ethernet MAC address. If %NULL, + * no password will be required. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_WAKE_ON_LAN_PASSWORD, + g_param_spec_string (NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm-core/nm-setting-wired.h b/libnm-core/nm-setting-wired.h index 4189b6896..44b7c4d02 100644 --- a/libnm-core/nm-setting-wired.h +++ b/libnm-core/nm-setting-wired.h @@ -40,6 +40,36 @@ G_BEGIN_DECLS #define NM_SETTING_WIRED_SETTING_NAME "802-3-ethernet" +/** + * NMSettingWiredWakeOnLan: + * @NM_SETTING_WIRED_WAKE_ON_LAN_NONE: Wake-on-LAN disabled + * @NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT: Use the default value + * @NM_SETTING_WIRED_WAKE_ON_LAN_PHY: Wake on PHY activity + * @NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST: Wake on unicast messages + * @NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST: Wake on multicast messages + * @NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST: Wake on broadcast messages + * @NM_SETTING_WIRED_WAKE_ON_LAN_ARP: Wake on ARP + * @NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC: Wake on magic packet + * @NM_SETTING_WIRED_WAKE_ON_LAN_ALL: Wake on all events + * + * Options for #NMSettingWired:wake-on-lan. Note that not all options + * are supported by all devices. + * + * Since: 1.0.6 + */ +typedef enum { /*< flags >*/ + NM_SETTING_WIRED_WAKE_ON_LAN_NONE = 0, /*< skip >*/ + NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT = (1 << 0), + NM_SETTING_WIRED_WAKE_ON_LAN_PHY = (1 << 1), + NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST = (1 << 2), + NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST = (1 << 3), + NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST = (1 << 4), + NM_SETTING_WIRED_WAKE_ON_LAN_ARP = (1 << 5), + NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC = (1 << 6), + _NM_SETTING_WIRED_WAKE_ON_LAN_LAST, /*< skip >*/ + NM_SETTING_WIRED_WAKE_ON_LAN_ALL = (((_NM_SETTING_WIRED_WAKE_ON_LAN_LAST - 1) << 1) - 1 - NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) /*< skip >*/ +} NMSettingWiredWakeOnLan; + #define NM_SETTING_WIRED_PORT "port" #define NM_SETTING_WIRED_SPEED "speed" #define NM_SETTING_WIRED_DUPLEX "duplex" @@ -51,6 +81,8 @@ G_BEGIN_DECLS #define NM_SETTING_WIRED_S390_SUBCHANNELS "s390-subchannels" #define NM_SETTING_WIRED_S390_NETTYPE "s390-nettype" #define NM_SETTING_WIRED_S390_OPTIONS "s390-options" +#define NM_SETTING_WIRED_WAKE_ON_LAN "wake-on-lan" +#define NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD "wake-on-lan-password" struct _NMSettingWired { NMSetting parent; @@ -104,6 +136,11 @@ gboolean nm_setting_wired_remove_s390_option (NMSettingWired *setting const char *key); const char ** nm_setting_wired_get_valid_s390_options (NMSettingWired *setting); +NM_AVAILABLE_IN_1_0_6 +NMSettingWiredWakeOnLan nm_setting_wired_get_wake_on_lan (NMSettingWired *setting); +NM_AVAILABLE_IN_1_0_6 +const char * nm_setting_wired_get_wake_on_lan_password (NMSettingWired *setting); + G_END_DECLS #endif /* __NM_SETTING_WIRED_H__ */ diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 14686ed1f..66dd1c872 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -317,6 +317,21 @@ nm_utils_ssid_to_utf8 (const guint8 *ssid, gsize len) "UTF-8", e1, "?", NULL, NULL, NULL); } + if (!converted) { + /* If there is still no converted string, the SSID probably + * contains characters not valid in the current locale. Convert + * the string to ASCII instead. + */ + + /* Use the printable range of 0x20-0x7E */ + gchar *valid_chars = " !\"#$%&'()*+,-./0123456789:;<=>?@" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" + "abcdefghijklmnopqrstuvwxyz{|}~"; + + converted = g_strndup ((const gchar *)ssid, len); + g_strcanon (converted, valid_chars, '?'); + } + return converted; } @@ -2677,6 +2692,61 @@ nm_utils_wifi_is_channel_valid (guint32 channel, const char *band) return FALSE; } +static const guint * +_wifi_freqs (gboolean bg_band) +{ + static guint *freqs_2ghz = NULL; + static guint *freqs_5ghz = NULL; + guint *freqs; + + freqs = bg_band ? freqs_2ghz : freqs_5ghz; + if (G_UNLIKELY (freqs == NULL)) { + struct cf_pair *table; + int i; + + table = bg_band ? bg_table : a_table; + freqs = g_new0 (guint, bg_band ? G_N_ELEMENTS (bg_table) : G_N_ELEMENTS (a_table)); + for (i = 0; table[i].chan; i++) + freqs[i] = table[i].freq; + freqs[i] = 0; + if (bg_band) + freqs_2ghz = freqs; + else + freqs_5ghz = freqs; + } + return freqs; +} + +/** + * nm_utils_wifi_2ghz_freqs: + * + * Utility function to return 2.4 GHz Wi-Fi frequencies (802.11bg band). + * + * Returns: zero-terminated array of frequencies numbers (in MHz) + * + * Since: 1.0.6 + **/ +const guint * +nm_utils_wifi_2ghz_freqs (void) +{ + return _wifi_freqs (TRUE); +} + +/** + * nm_utils_wifi_5ghz_freqs: + * + * Utility function to return 5 GHz Wi-Fi frequencies (802.11a band). + * + * Returns: zero-terminated array of frequencies numbers (in MHz) + * + * Since: 1.0.6 + **/ +const guint * +nm_utils_wifi_5ghz_freqs (void) +{ + return _wifi_freqs (FALSE); +} + /** * nm_utils_wifi_strength_bars: * @strength: the access point strength, from 0 to 100 @@ -3338,6 +3408,9 @@ nm_utils_ipaddr_valid (int family, const char *ip) g_return_val_if_fail (family == AF_INET || family == AF_INET6 || family == AF_UNSPEC, FALSE); + if (!ip) + return FALSE; + if (family == AF_UNSPEC) family = strchr (ip, ':') ? AF_INET6 : AF_INET; @@ -3540,3 +3613,150 @@ _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 ma return v; } +/** + * _nm_dbus_error_has_name: + * @error: (allow-none): a #GError, or %NULL + * @dbus_error_name: a D-Bus error name + * + * Checks if @error is set and corresponds to the D-Bus error @dbus_error_name. + * + * Returns: %TRUE or %FALSE + */ +gboolean +_nm_dbus_error_has_name (GError *error, + const char *dbus_error_name) +{ + gboolean has_name = FALSE; + + if (error && g_dbus_error_is_remote_error (error)) { + char *error_name; + + error_name = g_dbus_error_get_remote_error (error); + has_name = !g_strcmp0 (error_name, dbus_error_name); + g_free (error_name); + } + + return has_name; +} + +/** + * nm_utils_enum_to_str: + * @type: the %GType of the enum + * @value: the value to be translated + * + * Converts an enum value to its string representation. If the enum is a + * %G_TYPE_FLAGS the function returns a comma-separated list of matching values. + * If the enum is a %G_TYPE_ENUM and the given value is not valid the + * function returns %NULL. + * + * Returns: a newly allocated string or %NULL + * + * Since: 1.0.6 + */ +char *nm_utils_enum_to_str (GType type, int value) +{ + GTypeClass *class; + char *ret; + + class = g_type_class_ref (type); + + if (G_IS_ENUM_CLASS (class)) { + GEnumValue *enum_value; + + enum_value = g_enum_get_value (G_ENUM_CLASS (class), value); + ret = enum_value ? strdup (enum_value->value_nick) : NULL; + } else if (G_IS_FLAGS_CLASS (class)) { + GFlagsValue *flags_value; + GString *str = g_string_new (""); + gboolean first = TRUE; + + while (value) { + flags_value = g_flags_get_first_value (G_FLAGS_CLASS (class), value); + if (!flags_value) + break; + + if (!first) + g_string_append_c (str, ','); + g_string_append (str, flags_value->value_nick); + + value &= ~flags_value->value; + first = FALSE; + } + ret = g_string_free (str, FALSE); + } else + g_return_val_if_reached (NULL); + + g_type_class_unref (class); + return ret; +} + +/** + * nm_utils_enum_from_str: + * @type: the %GType of the enum + * @str: the input string + * @out_value: (out) (allow-none) the output value + * @err_token: (out) (allow-none) location to store the first unrecognized token + * + * Converts a string to the matching enum value. + * + * If the enum is a %G_TYPE_FLAGS the function returns the logical OR of values + * matching the comma-separated tokens in the string; if an unknown token is found + * the function returns %FALSE and stores a pointer to a newly allocated string + * containing the unrecognized token in @err_token. + * + * Returns: %TRUE if the conversion was successful, %FALSE otherwise + * + * Since: 1.0.6 + */ +gboolean nm_utils_enum_from_str (GType type, const char *str, + int *out_value, char **err_token) +{ + GTypeClass *class; + gboolean ret = FALSE; + int value = 0; + gs_free char *stripped = NULL; + + g_return_val_if_fail (str, FALSE); + stripped = g_strstrip (strdup (str)); + class = g_type_class_ref (type); + + if (G_IS_ENUM_CLASS (class)) { + GEnumValue *enum_value; + + enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (class), stripped); + if (enum_value) { + value = enum_value->value; + ret = TRUE; + } + } else if (G_IS_FLAGS_CLASS (class)) { + GFlagsValue *flags_value; + gs_strfreev char **strv = NULL; + int i; + + strv = g_strsplit (stripped, ",", 0); + for (i = 0; strv[i]; i++) { + if (!strv[i][0]) + continue; + + flags_value = g_flags_get_value_by_nick (G_FLAGS_CLASS (class), strv[i]); + if (!flags_value) + break; + + value |= flags_value->value; + } + + if (strv[i]) { + if (err_token) + *err_token = strdup (strv[i]); + value = 0; + } else + ret = TRUE; + } else + g_return_val_if_reached (FALSE); + + if (out_value) + *out_value = value; + + g_type_class_unref (class); + return ret; +} diff --git a/libnm-core/nm-utils.h b/libnm-core/nm-utils.h index 8c22cfd16..d1f4bcf4d 100644 --- a/libnm-core/nm-utils.h +++ b/libnm-core/nm-utils.h @@ -140,6 +140,10 @@ guint32 nm_utils_wifi_freq_to_channel (guint32 freq); guint32 nm_utils_wifi_channel_to_freq (guint32 channel, const char *band); guint32 nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band); gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band); +NM_AVAILABLE_IN_1_0_6 +const guint *nm_utils_wifi_2ghz_freqs (void); +NM_AVAILABLE_IN_1_0_6 +const guint *nm_utils_wifi_5ghz_freqs (void); const char *nm_utils_wifi_strength_bars (guint8 strength); @@ -185,6 +189,12 @@ gboolean nm_utils_ipaddr_valid (int family, const char *ip); gboolean nm_utils_check_virtual_device_compatibility (GType virtual_type, GType other_type); +NM_AVAILABLE_IN_1_0_6 +char *nm_utils_enum_to_str (GType type, int value); + +NM_AVAILABLE_IN_1_0_6 +gboolean nm_utils_enum_from_str (GType type, const char *str, int *out_value, char **err_token); + G_END_DECLS #endif /* __NM_UTILS_H__ */ diff --git a/libnm-core/nm-version.h b/libnm-core/nm-version.h index e36d921e0..e26feca6f 100644 --- a/libnm-core/nm-version.h +++ b/libnm-core/nm-version.h @@ -21,6 +21,8 @@ #ifndef NM_VERSION_H #define NM_VERSION_H +#include <glib.h> + /** * NM_MAJOR_VERSION: * @@ -43,7 +45,7 @@ * Evaluates to the micro version number of NetworkManager which this source * compiled against. */ -#define NM_MICRO_VERSION (4) +#define NM_MICRO_VERSION (6) /** * NM_CHECK_VERSION: @@ -69,9 +71,11 @@ #define NM_VERSION_1_0 (NM_ENCODE_VERSION (1, 0, 0)) #define NM_VERSION_1_0_2 (NM_ENCODE_VERSION (1, 0, 2)) #define NM_VERSION_1_0_4 (NM_ENCODE_VERSION (1, 0, 4)) +#define NM_VERSION_1_0_6 (NM_ENCODE_VERSION (1, 0, 6)) +#define NM_VERSION_1_0_8 (NM_ENCODE_VERSION (1, 0, 8)) -#define NM_VERSION_CUR_STABLE NM_VERSION_1_0_2 -#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_4 +#define NM_VERSION_CUR_STABLE NM_VERSION_1_0_6 +#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_8 #if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) # undef NM_VERSION_MIN_REQUIRED @@ -102,6 +106,12 @@ # define NM_DEPRECATED_IN_0_9_10_FOR(f) #endif +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10 +# define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) +#else +# define NM_AVAILABLE_IN_0_9_10 +#endif + #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_0 # define NM_DEPRECATED_IN_1_0 G_DEPRECATED # define NM_DEPRECATED_IN_1_0_FOR(f) G_DEPRECATED_FOR(f) @@ -110,12 +120,6 @@ # define NM_DEPRECATED_IN_1_0_FOR(f) #endif -#if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10 -# define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) -#else -# define NM_AVAILABLE_IN_0_9_10 -#endif - #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0 # define NM_AVAILABLE_IN_1_0 G_UNAVAILABLE(1,0) #else @@ -128,4 +132,10 @@ # define NM_AVAILABLE_IN_1_0_4 #endif +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0_6 +# define NM_AVAILABLE_IN_1_0_6 G_UNAVAILABLE(1,0.6) +#else +# define NM_AVAILABLE_IN_1_0_6 +#endif + #endif /* NM_VERSION_H */ diff --git a/libnm-core/nm-version.h.in b/libnm-core/nm-version.h.in index 9c9219e14..e00f40559 100644 --- a/libnm-core/nm-version.h.in +++ b/libnm-core/nm-version.h.in @@ -21,6 +21,8 @@ #ifndef NM_VERSION_H #define NM_VERSION_H +#include <glib.h> + /** * NM_MAJOR_VERSION: * @@ -69,9 +71,11 @@ #define NM_VERSION_1_0 (NM_ENCODE_VERSION (1, 0, 0)) #define NM_VERSION_1_0_2 (NM_ENCODE_VERSION (1, 0, 2)) #define NM_VERSION_1_0_4 (NM_ENCODE_VERSION (1, 0, 4)) +#define NM_VERSION_1_0_6 (NM_ENCODE_VERSION (1, 0, 6)) +#define NM_VERSION_1_0_8 (NM_ENCODE_VERSION (1, 0, 8)) -#define NM_VERSION_CUR_STABLE NM_VERSION_1_0_2 -#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_4 +#define NM_VERSION_CUR_STABLE NM_VERSION_1_0_6 +#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_8 #if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) # undef NM_VERSION_MIN_REQUIRED @@ -102,6 +106,12 @@ # define NM_DEPRECATED_IN_0_9_10_FOR(f) #endif +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10 +# define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) +#else +# define NM_AVAILABLE_IN_0_9_10 +#endif + #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_0 # define NM_DEPRECATED_IN_1_0 G_DEPRECATED # define NM_DEPRECATED_IN_1_0_FOR(f) G_DEPRECATED_FOR(f) @@ -110,12 +120,6 @@ # define NM_DEPRECATED_IN_1_0_FOR(f) #endif -#if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10 -# define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) -#else -# define NM_AVAILABLE_IN_0_9_10 -#endif - #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0 # define NM_AVAILABLE_IN_1_0 G_UNAVAILABLE(1,0) #else @@ -128,4 +132,10 @@ # define NM_AVAILABLE_IN_1_0_4 #endif +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0_6 +# define NM_AVAILABLE_IN_1_0_6 G_UNAVAILABLE(1,0.6) +#else +# define NM_AVAILABLE_IN_1_0_6 +#endif + #endif /* NM_VERSION_H */ diff --git a/libnm-core/tests/Makefile.am b/libnm-core/tests/Makefile.am index daa5825b5..dd38b3d68 100644 --- a/libnm-core/tests/Makefile.am +++ b/libnm-core/tests/Makefile.am @@ -1,5 +1,14 @@ if ENABLE_TESTS +include $(GLIB_MAKEFILE) + +GLIB_GENERATED = nm-core-tests-enum-types.h nm-core-tests-enum-types.c +nm_core_tests_enum_types_sources = test-general-enums.h +GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM +GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM + +BUILT_SOURCES = $(GLIB_GENERATED) + certsdir = $(srcdir)/certs AM_CPPFLAGS = \ @@ -28,6 +37,12 @@ LDADD = \ @VALGRIND_RULES@ TESTS = $(noinst_PROGRAMS) +test_general_SOURCES = \ + test-general.c \ + test-general-enums.h \ + nm-core-tests-enum-types.c \ + nm-core-tests-enum-types.h + endif # test-cert.p12 created with: diff --git a/libnm-core/tests/Makefile.in b/libnm-core/tests/Makefile.in index edb6a50e8..a37acbe24 100644 --- a/libnm-core/tests/Makefile.in +++ b/libnm-core/tests/Makefile.in @@ -134,8 +134,11 @@ test_crypto_LDADD = $(LDADD) @ENABLE_TESTS_TRUE@test_crypto_DEPENDENCIES = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-core/libnm-core.la \ @ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) -test_general_SOURCES = test-general.c -test_general_OBJECTS = test-general.$(OBJEXT) +am__test_general_SOURCES_DIST = test-general.c test-general-enums.h \ + nm-core-tests-enum-types.c nm-core-tests-enum-types.h +@ENABLE_TESTS_TRUE@am_test_general_OBJECTS = test-general.$(OBJEXT) \ +@ENABLE_TESTS_TRUE@ nm-core-tests-enum-types.$(OBJEXT) +test_general_OBJECTS = $(am_test_general_OBJECTS) test_general_LDADD = $(LDADD) @ENABLE_TESTS_TRUE@test_general_DEPENDENCIES = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-core/libnm-core.la \ @@ -204,12 +207,13 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = test-compare.c test-crypto.c test-general.c test-keyfile.c \ - test-secrets.c test-setting-8021x.c test-setting-dcb.c \ - test-settings-defaults.c -DIST_SOURCES = test-compare.c test-crypto.c test-general.c \ +SOURCES = test-compare.c test-crypto.c $(test_general_SOURCES) \ test-keyfile.c test-secrets.c test-setting-8021x.c \ test-setting-dcb.c test-settings-defaults.c +DIST_SOURCES = test-compare.c test-crypto.c \ + $(am__test_general_SOURCES_DIST) test-keyfile.c test-secrets.c \ + test-setting-8021x.c test-setting-dcb.c \ + test-settings-defaults.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -703,6 +707,11 @@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ +@ENABLE_TESTS_TRUE@GLIB_GENERATED = nm-core-tests-enum-types.h nm-core-tests-enum-types.c +@ENABLE_TESTS_TRUE@nm_core_tests_enum_types_sources = test-general-enums.h +@ENABLE_TESTS_TRUE@GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM +@ENABLE_TESTS_TRUE@GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM +@ENABLE_TESTS_TRUE@BUILT_SOURCES = $(GLIB_GENERATED) @ENABLE_TESTS_TRUE@certsdir = $(srcdir)/certs @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I${top_srcdir}/include \ @@ -718,6 +727,12 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ $(GLIB_LIBS) @ENABLE_TESTS_TRUE@TESTS = $(noinst_PROGRAMS) +@ENABLE_TESTS_TRUE@test_general_SOURCES = \ +@ENABLE_TESTS_TRUE@ test-general.c \ +@ENABLE_TESTS_TRUE@ test-general-enums.h \ +@ENABLE_TESTS_TRUE@ nm-core-tests-enum-types.c \ +@ENABLE_TESTS_TRUE@ nm-core-tests-enum-types.h + # test-cert.p12 created with: # @@ -746,7 +761,8 @@ EXTRA_DIST = \ certs/test-key-only-decrypted.pem \ certs/test-key-only.pem -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs @@ -827,6 +843,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-core-tests-enum-types.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-compare.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-crypto.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-general.Po@am__quote@ @@ -1159,10 +1176,12 @@ distdir: $(DISTFILES) done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) installdirs: -install: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -1195,6 +1214,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ @@ -1266,7 +1286,7 @@ ps-am: uninstall-am: -.MAKE: check-am install-am install-strip +.MAKE: all check check-am install install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ @@ -1285,6 +1305,8 @@ uninstall-am: .PRECIOUS: Makefile +@ENABLE_TESTS_TRUE@include $(GLIB_MAKEFILE) + @ENABLE_TESTS_TRUE@@VALGRIND_RULES@ # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/libnm-core/tests/nm-core-tests-enum-types.c b/libnm-core/tests/nm-core-tests-enum-types.c new file mode 100644 index 000000000..80271e520 --- /dev/null +++ b/libnm-core/tests/nm-core-tests-enum-types.c @@ -0,0 +1,74 @@ + + + +/* Generated by glib-mkenums. Do not edit */ + +#include "nm-core-tests-enum-types.h" + +#include "test-general-enums.h" + +GType +nm_test_general_bool_enum_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_TEST_GENERAL_BOOL_ENUM_NO, "NM_TEST_GENERAL_BOOL_ENUM_NO", "no" }, + { NM_TEST_GENERAL_BOOL_ENUM_YES, "NM_TEST_GENERAL_BOOL_ENUM_YES", "yes" }, + { NM_TEST_GENERAL_BOOL_ENUM_MAYBE, "NM_TEST_GENERAL_BOOL_ENUM_MAYBE", "maybe" }, + { NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN, "NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN", "unknown" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMTestGeneralBoolEnum"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_test_general_meta_flags_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GFlagsValue values[] = { + { NM_TEST_GENERAL_META_FLAGS_NONE, "NM_TEST_GENERAL_META_FLAGS_NONE", "none" }, + { NM_TEST_GENERAL_META_FLAGS_FOO, "NM_TEST_GENERAL_META_FLAGS_FOO", "foo" }, + { NM_TEST_GENERAL_META_FLAGS_BAR, "NM_TEST_GENERAL_META_FLAGS_BAR", "bar" }, + { NM_TEST_GENERAL_META_FLAGS_BAZ, "NM_TEST_GENERAL_META_FLAGS_BAZ", "baz" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_flags_register_static (g_intern_static_string ("NMTestGeneralMetaFlags"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_test_general_color_flags_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GFlagsValue values[] = { + { NM_TEST_GENERAL_COLOR_FLAGS_BLUE, "NM_TEST_GENERAL_COLOR_FLAGS_BLUE", "blue" }, + { NM_TEST_GENERAL_COLOR_FLAGS_RED, "NM_TEST_GENERAL_COLOR_FLAGS_RED", "red" }, + { NM_TEST_GENERAL_COLOR_FLAGS_GREEN, "NM_TEST_GENERAL_COLOR_FLAGS_GREEN", "green" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_flags_register_static (g_intern_static_string ("NMTestGeneralColorFlags"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + + + diff --git a/libnm-core/tests/nm-core-tests-enum-types.h b/libnm-core/tests/nm-core-tests-enum-types.h new file mode 100644 index 000000000..90257866e --- /dev/null +++ b/libnm-core/tests/nm-core-tests-enum-types.h @@ -0,0 +1,23 @@ + + + +/* Generated by glib-mkenums. Do not edit */ + +#ifndef __NM_CORE_TESTS_ENUM_TYPES_H__ +#define __NM_CORE_TESTS_ENUM_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS +GType nm_test_general_bool_enum_get_type (void) G_GNUC_CONST; +#define NM_TYPE_TEST_GENERAL_BOOL_ENUM (nm_test_general_bool_enum_get_type ()) +GType nm_test_general_meta_flags_get_type (void) G_GNUC_CONST; +#define NM_TYPE_TEST_GENERAL_META_FLAGS (nm_test_general_meta_flags_get_type ()) +GType nm_test_general_color_flags_get_type (void) G_GNUC_CONST; +#define NM_TYPE_TEST_GENERAL_COLOR_FLAGS (nm_test_general_color_flags_get_type ()) +G_END_DECLS + +#endif /* __NM_CORE_TESTS_ENUM_TYPES_H__ */ + + + diff --git a/libnm-core/tests/test-general-enums.h b/libnm-core/tests/test-general-enums.h new file mode 100644 index 000000000..d06d6e39f --- /dev/null +++ b/libnm-core/tests/test-general-enums.h @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2015 Red Hat, Inc. + */ + +#ifndef _NM_TEST_GENERAL_ENUMS_H_ +#define _NM_TEST_GENERAL_ENUMS_H_ + +typedef enum { + NM_TEST_GENERAL_BOOL_ENUM_NO = 0, + NM_TEST_GENERAL_BOOL_ENUM_YES = 1, + NM_TEST_GENERAL_BOOL_ENUM_MAYBE = 2, + NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN = 3, + NM_TEST_GENERAL_BOOL_ENUM_INVALID = 4, /*< skip >*/ +} NMTestGeneralBoolEnum; + +typedef enum { + NM_TEST_GENERAL_META_FLAGS_NONE = 0, + NM_TEST_GENERAL_META_FLAGS_FOO = (1 << 0), + NM_TEST_GENERAL_META_FLAGS_BAR = (1 << 1), + NM_TEST_GENERAL_META_FLAGS_BAZ = (1 << 2), +} NMTestGeneralMetaFlags; + +typedef enum { /*< flags >*/ + NM_TEST_GENERAL_COLOR_FLAGS_WHITE = 1, /*< skip >*/ + NM_TEST_GENERAL_COLOR_FLAGS_BLUE = 2, + NM_TEST_GENERAL_COLOR_FLAGS_RED = 4, + NM_TEST_GENERAL_COLOR_FLAGS_GREEN = 8, +} NMTestGeneralColorFlags; + +#endif /* _NM_TEST_GENERAL_ENUMS_H_ */ diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index bd144f384..e94836527 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -32,6 +32,7 @@ #include "nm-setting-private.h" #include "nm-utils.h" #include "nm-core-internal.h" +#include "nm-core-tests-enum-types.h" #include "nm-setting-8021x.h" #include "nm-setting-adsl.h" @@ -62,6 +63,7 @@ #include "nm-glib-compat.h" #include "nm-test-utils.h" +#include "test-general-enums.h" static void vpn_check_func (const char *key, const char *value, gpointer user_data) @@ -1969,6 +1971,7 @@ test_connection_diff_a_only (void) { NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_CONNECTION_SECONDARIES, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_CONNECTION_METERED, NM_SETTING_DIFF_RESULT_IN_A }, { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN } } }, { NM_SETTING_WIRED_SETTING_NAME, { @@ -1983,6 +1986,8 @@ test_connection_diff_a_only (void) { NM_SETTING_WIRED_S390_SUBCHANNELS, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_WIRED_S390_NETTYPE, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_WIRED_S390_OPTIONS, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_WIRED_WAKE_ON_LAN, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, NM_SETTING_DIFF_RESULT_IN_A }, { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }, } }, { NM_SETTING_IP4_CONFIG_SETTING_NAME, { @@ -4448,6 +4453,166 @@ test_nm_utils_ptrarray_find_binary_search (void) /******************************************************************************/ +static int +_test_nm_in_set_get (int *call_counter, gboolean allow_called, int value) +{ + g_assert (call_counter); + *call_counter += 1; + if (!allow_called) + g_assert_not_reached (); + return value; +} + +static void +_test_nm_in_set_assert (int *call_counter, int expected) +{ + g_assert (call_counter); + g_assert_cmpint (expected, ==, *call_counter); + *call_counter = 0; +} + +static void +test_nm_in_set (void) +{ + int call_counter = 0; + +#define G(x) _test_nm_in_set_get (&call_counter, TRUE, x) +#define N(x) _test_nm_in_set_get (&call_counter, FALSE, x) +#define _ASSERT(expected, expr) \ + G_STMT_START { \ + _test_nm_in_set_assert (&call_counter, 0); \ + g_assert (expr); \ + _test_nm_in_set_assert (&call_counter, (expected)); \ + } G_STMT_END + _ASSERT (1, !NM_IN_SET (-1, G( 1))); + _ASSERT (1, NM_IN_SET (-1, G(-1))); + + _ASSERT (2, !NM_IN_SET (-1, G( 1), G( 2))); + _ASSERT (1, NM_IN_SET (-1, G(-1), N( 2))); + _ASSERT (2, NM_IN_SET (-1, G( 1), G(-1))); + _ASSERT (1, NM_IN_SET (-1, G(-1), N(-1))); + + _ASSERT (3, !NM_IN_SET (-1, G( 1), G( 2), G( 3))); + _ASSERT (1, NM_IN_SET (-1, G(-1), N( 2), N( 3))); + _ASSERT (2, NM_IN_SET (-1, G( 1), G(-1), N( 3))); + _ASSERT (3, NM_IN_SET (-1, G( 1), G( 2), G(-1))); + _ASSERT (2, NM_IN_SET (-1, G( 1), G(-1), N(-1))); + _ASSERT (1, NM_IN_SET (-1, G(-1), N( 2), N(-1))); + _ASSERT (1, NM_IN_SET (-1, G(-1), N(-1), N( 3))); + _ASSERT (1, NM_IN_SET (-1, G(-1), N(-1), N(-1))); + + _ASSERT (4, !NM_IN_SET (-1, G( 1), G( 2), G( 3), G( 4))); + _ASSERT (1, NM_IN_SET (-1, G(-1), N( 2), N( 3), N( 4))); + _ASSERT (2, NM_IN_SET (-1, G( 1), G(-1), N( 3), N( 4))); + _ASSERT (3, NM_IN_SET (-1, G( 1), G( 2), G(-1), N( 4))); + _ASSERT (4, NM_IN_SET (-1, G( 1), G( 2), G( 3), G(-1))); + + _ASSERT (4, NM_IN_SET (-1, G( 1), G( 2), G( 3), G(-1), G( 5))); + + _ASSERT (1, !NM_IN_SET_SE (-1, G( 1))); + _ASSERT (1, NM_IN_SET_SE (-1, G(-1))); + + _ASSERT (2, !NM_IN_SET_SE (-1, G( 1), G( 2))); + _ASSERT (2, NM_IN_SET_SE (-1, G(-1), G( 2))); + _ASSERT (2, NM_IN_SET_SE (-1, G( 1), G(-1))); + _ASSERT (2, NM_IN_SET_SE (-1, G(-1), G(-1))); + + _ASSERT (3, !NM_IN_SET_SE (-1, G( 1), G( 2), G( 3))); + _ASSERT (3, NM_IN_SET_SE (-1, G(-1), G( 2), G( 3))); + _ASSERT (3, NM_IN_SET_SE (-1, G( 1), G(-1), G( 3))); + _ASSERT (3, NM_IN_SET_SE (-1, G( 1), G( 2), G(-1))); + _ASSERT (3, NM_IN_SET_SE (-1, G( 1), G(-1), G(-1))); + _ASSERT (3, NM_IN_SET_SE (-1, G(-1), G( 2), G(-1))); + _ASSERT (3, NM_IN_SET_SE (-1, G(-1), G(-1), G( 3))); + _ASSERT (3, NM_IN_SET_SE (-1, G(-1), G(-1), G(-1))); + + _ASSERT (4, !NM_IN_SET_SE (-1, G( 1), G( 2), G( 3), G( 4))); + _ASSERT (4, NM_IN_SET_SE (-1, G(-1), G( 2), G( 3), G( 4))); + _ASSERT (4, NM_IN_SET_SE (-1, G( 1), G(-1), G( 3), G( 4))); + _ASSERT (4, NM_IN_SET_SE (-1, G( 1), G( 2), G(-1), G( 4))); + _ASSERT (4, NM_IN_SET_SE (-1, G( 1), G( 2), G( 3), G(-1))); + + _ASSERT (5, NM_IN_SET_SE (-1, G( 1), G( 2), G( 3), G(-1), G( 5))); +#undef G +#undef N +#undef _ASSERT +} + +/******************************************************************************/ + +static void +test_nm_utils_enum_from_str_do (GType type, const char *str, + gboolean exp_result, int exp_flags, + const char *exp_err_token) +{ + int flags = 1; + char *err_token = NULL; + gboolean result; + + result = nm_utils_enum_from_str (type, str, &flags, &err_token); + + g_assert (result == exp_result); + g_assert_cmpint (flags, ==, exp_flags); + g_assert_cmpstr (err_token, ==, exp_err_token); + + g_free (err_token); +} + +static void +test_nm_utils_enum_to_str_do (GType type, int flags, const char *exp_str) +{ + char *str; + + str = nm_utils_enum_to_str (type, flags); + g_assert_cmpstr (str, ==, exp_str); + g_free (str); +} + +static void test_nm_utils_enum (void) +{ + GType bool_enum = nm_test_general_bool_enum_get_type(); + GType meta_flags = nm_test_general_meta_flags_get_type(); + GType color_flags = nm_test_general_color_flags_get_type(); + + test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES, "yes"); + test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN, "unknown"); + test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_INVALID, NULL); + + test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_NONE, ""); + test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_BAZ, "baz"); + test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_FOO | + NM_TEST_GENERAL_META_FLAGS_BAR | + NM_TEST_GENERAL_META_FLAGS_BAZ, "foo,bar,baz"); + + test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED, "red"); + test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_WHITE, ""); + test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED | + NM_TEST_GENERAL_COLOR_FLAGS_GREEN, "red,green"); + + test_nm_utils_enum_from_str_do (bool_enum, "", FALSE, 0, NULL); + test_nm_utils_enum_from_str_do (bool_enum, " ", FALSE, 0, NULL); + test_nm_utils_enum_from_str_do (bool_enum, "invalid", FALSE, 0, NULL); + test_nm_utils_enum_from_str_do (bool_enum, "yes", TRUE, NM_TEST_GENERAL_BOOL_ENUM_YES, NULL); + test_nm_utils_enum_from_str_do (bool_enum, "no", TRUE, NM_TEST_GENERAL_BOOL_ENUM_NO, NULL); + test_nm_utils_enum_from_str_do (bool_enum, "yes,no", FALSE, 0, NULL); + + test_nm_utils_enum_from_str_do (meta_flags, "", TRUE, 0, NULL); + test_nm_utils_enum_from_str_do (meta_flags, " ", TRUE, 0, NULL); + test_nm_utils_enum_from_str_do (meta_flags, "foo", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO, NULL); + test_nm_utils_enum_from_str_do (meta_flags, "foo,baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | + NM_TEST_GENERAL_META_FLAGS_BAZ, NULL); + test_nm_utils_enum_from_str_do (meta_flags, "foo,,bar", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | + NM_TEST_GENERAL_META_FLAGS_BAR, NULL); + test_nm_utils_enum_from_str_do (meta_flags, "foo,baz,quux,bar", FALSE, 0, "quux"); + + test_nm_utils_enum_from_str_do (color_flags, "green", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_GREEN, NULL); + test_nm_utils_enum_from_str_do (color_flags, "blue,red", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_BLUE | + NM_TEST_GENERAL_COLOR_FLAGS_RED, NULL); + test_nm_utils_enum_from_str_do (color_flags, "blue,white", FALSE, 0, "white"); +} + +/******************************************************************************/ + NMTST_DEFINE (); int main (int argc, char **argv) @@ -4455,6 +4620,7 @@ int main (int argc, char **argv) nmtst_init (&argc, &argv, TRUE); /* The tests */ + g_test_add_func ("/core/general/test_nm_in_set", test_nm_in_set); g_test_add_func ("/core/general/test_setting_vpn_items", test_setting_vpn_items); g_test_add_func ("/core/general/test_setting_vpn_update_secrets", test_setting_vpn_update_secrets); g_test_add_func ("/core/general/test_setting_vpn_modify_during_foreach", test_setting_vpn_modify_during_foreach); @@ -4552,6 +4718,8 @@ int main (int argc, char **argv) g_test_add_func ("/core/general/_glib_compat_g_ptr_array_insert", test_g_ptr_array_insert); g_test_add_func ("/core/general/_nm_utils_ptrarray_find_binary_search", test_nm_utils_ptrarray_find_binary_search); + g_test_add_func ("/core/general/test_nm_utils_enum", test_nm_utils_enum); + return g_test_run (); } diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index 9219c4a2b..dc982e566 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -11,6 +11,7 @@ global: nm_access_point_get_flags; nm_access_point_get_frequency; nm_access_point_get_hw_address; + nm_access_point_get_last_seen; nm_access_point_get_max_bitrate; nm_access_point_get_mode; nm_access_point_get_rsn_flags; diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index abf61cc92..b980943af 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -53,6 +53,7 @@ typedef struct { NM80211Mode mode; guint32 max_bitrate; guint8 strength; + gint32 last_seen; } NMAccessPointPrivate; enum { @@ -67,6 +68,7 @@ enum { PROP_MAX_BITRATE, PROP_STRENGTH, PROP_BSSID, + PROP_LAST_SEEN, LAST_PROP }; @@ -266,6 +268,27 @@ nm_access_point_get_strength (NMAccessPoint *ap) } /** + * nm_access_point_get_last_seen: + * @ap: a #NMAccessPoint + * + * Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last time the + * access point was found in scan results. A value of -1 means the access + * point has not been found in a scan. + * + * Returns: the last seen time in seconds + * + * Since: 1.0.6 + **/ +gint32 +nm_access_point_get_last_seen (NMAccessPoint *ap) +{ + g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), -1); + + _nm_object_ensure_inited (NM_OBJECT (ap)); + return NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen; +} + +/** * nm_access_point_connection_valid: * @ap: an #NMAccessPoint to validate @connection against * @connection: an #NMConnection to validate against @ap @@ -416,6 +439,7 @@ nm_access_point_filter_connections (NMAccessPoint *ap, const GSList *connections static void nm_access_point_init (NMAccessPoint *ap) { + NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen = -1; } static void @@ -482,6 +506,9 @@ get_property (GObject *object, case PROP_STRENGTH: g_value_set_uchar (value, nm_access_point_get_strength (ap)); break; + case PROP_LAST_SEEN: + g_value_set_int (value, nm_access_point_get_last_seen (ap)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -512,6 +539,7 @@ register_properties (NMAccessPoint *ap) { NM_ACCESS_POINT_MODE, &priv->mode }, { NM_ACCESS_POINT_MAX_BITRATE, &priv->max_bitrate }, { NM_ACCESS_POINT_STRENGTH, &priv->strength }, + { NM_ACCESS_POINT_LAST_SEEN, &priv->last_seen }, { NULL }, }; @@ -671,4 +699,20 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) 0, G_MAXUINT8, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /** + * NMAccessPoint:last-seen: + * + * The timestamp (in CLOCK_BOOTTIME seconds) for the last time the + * access point was found in scan results. A value of -1 means the + * access point has not been found in a scan. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_LAST_SEEN, + g_param_spec_int (NM_ACCESS_POINT_LAST_SEEN, "", "", + -1, G_MAXINT, -1, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h index d3150f8ee..57bd6ed16 100644 --- a/libnm-glib/nm-access-point.h +++ b/libnm-glib/nm-access-point.h @@ -46,6 +46,7 @@ G_BEGIN_DECLS #define NM_ACCESS_POINT_MODE "mode" #define NM_ACCESS_POINT_MAX_BITRATE "max-bitrate" #define NM_ACCESS_POINT_STRENGTH "strength" +#define NM_ACCESS_POINT_LAST_SEEN "last-seen" /* DEPRECATED */ #define NM_ACCESS_POINT_HW_ADDRESS "hw-address" @@ -80,6 +81,8 @@ guint32 nm_access_point_get_frequency (NMAccessPoint *ap); NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap); guint8 nm_access_point_get_strength (NMAccessPoint *ap); +NM_AVAILABLE_IN_1_0_6 +gint32 nm_access_point_get_last_seen (NMAccessPoint *ap); GSList * nm_access_point_filter_connections (NMAccessPoint *ap, const GSList *connections); diff --git a/libnm-glib/nm-vpn-plugin.c b/libnm-glib/nm-vpn-plugin.c index 7848c131c..f40ea800f 100644 --- a/libnm-glib/nm-vpn-plugin.c +++ b/libnm-glib/nm-vpn-plugin.c @@ -28,6 +28,7 @@ #include "nm-utils.h" #include "nm-connection.h" #include "nm-dbus-glib-types.h" +#include "nm-macros-internal.h" static gboolean impl_vpn_plugin_connect (NMVPNPlugin *plugin, GHashTable *connection, @@ -257,6 +258,7 @@ connect_timer_expired (gpointer data) NMVPNPlugin *plugin = NM_VPN_PLUGIN (data); GError *err = NULL; + NM_VPN_PLUGIN_GET_PRIVATE (plugin)->connect_timer = 0; g_message ("Connect timer expired, disconnecting."); nm_vpn_plugin_disconnect (plugin, &err); if (err) { @@ -264,26 +266,38 @@ connect_timer_expired (gpointer data) g_error_free (err); } - return FALSE; + return G_SOURCE_REMOVE; } static gboolean quit_timer_expired (gpointer data) { - NMVPNPlugin *plugin = NM_VPN_PLUGIN (data); + NMVPNPlugin *self = NM_VPN_PLUGIN (data); + + NM_VPN_PLUGIN_GET_PRIVATE (self)->quit_timer = 0; + nm_vpn_plugin_emit_quit (self); + return G_SOURCE_REMOVE; +} - nm_vpn_plugin_emit_quit (plugin); +static void +schedule_quit_timer (NMVPNPlugin *self) +{ + NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (self); - return FALSE; + nm_clear_g_source (&priv->quit_timer); + priv->quit_timer = g_timeout_add_seconds (NM_VPN_PLUGIN_QUIT_TIMER, + quit_timer_expired, + self); } static gboolean fail_stop (gpointer data) { - NMVPNPlugin *plugin = NM_VPN_PLUGIN (data); + NMVPNPlugin *self = NM_VPN_PLUGIN (data); - nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED); - return FALSE; + NM_VPN_PLUGIN_GET_PRIVATE (self)->fail_stop_id = 0; + nm_vpn_plugin_set_state (self, NM_VPN_SERVICE_STATE_STOPPED); + return G_SOURCE_REMOVE; } static void @@ -291,8 +305,7 @@ schedule_fail_stop (NMVPNPlugin *plugin) { NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin); - if (priv->fail_stop_id) - g_source_remove (priv->fail_stop_id); + nm_clear_g_source (&priv->fail_stop_id); priv->fail_stop_id = g_idle_add (fail_stop, plugin); } @@ -409,21 +422,11 @@ nm_vpn_plugin_set_ip6_config (NMVPNPlugin *plugin, } static void -connect_timer_removed (gpointer data) -{ - NM_VPN_PLUGIN_GET_PRIVATE (data)->connect_timer = 0; -} - -static void connect_timer_start (NMVPNPlugin *plugin) { NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin); - priv->connect_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, - 60, - connect_timer_expired, - plugin, - connect_timer_removed); + priv->connect_timer = g_timeout_add_seconds (60, connect_timer_expired, plugin); } static gboolean @@ -547,6 +550,11 @@ impl_vpn_plugin_need_secrets (NMVPNPlugin *plugin, ret = TRUE; if (needed) { + /* Push back the quit timer so the VPN plugin doesn't quit in the + * middle of asking the user for secrets. + */ + schedule_quit_timer (plugin); + g_assert (sn); *setting_name = g_strdup (sn); } else { @@ -638,8 +646,7 @@ nm_vpn_plugin_secrets_required (NMVPNPlugin *plugin, /* Cancel the connect timer since secrets might take a while. It'll * get restarted when the secrets come back via NewSecrets(). */ - if (priv->connect_timer) - g_source_remove (priv->connect_timer); + nm_clear_g_source (&priv->connect_timer); g_signal_emit (plugin, signals[SECRETS_REQUIRED], 0, message, hints); } @@ -848,10 +855,9 @@ dispose (GObject *object) NMVPNServiceState state; GError *err = NULL; - if (priv->fail_stop_id) { - g_source_remove (priv->fail_stop_id); - priv->fail_stop_id = 0; - } + nm_clear_g_source (&priv->fail_stop_id); + nm_clear_g_source (&priv->quit_timer); + nm_clear_g_source (&priv->connect_timer); state = nm_vpn_plugin_get_state (plugin); @@ -889,46 +895,23 @@ finalize (GObject *object) } static void -quit_timer_removed (gpointer data) -{ - NM_VPN_PLUGIN_GET_PRIVATE (data)->quit_timer = 0; -} - -static void state_changed (NMVPNPlugin *plugin, NMVPNServiceState state) { NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin); switch (state) { case NM_VPN_SERVICE_STATE_STARTING: - /* Remove the quit timer. */ - if (priv->quit_timer) - g_source_remove (priv->quit_timer); - - if (priv->fail_stop_id) { - g_source_remove (priv->fail_stop_id); - priv->fail_stop_id = 0; - } + nm_clear_g_source (&priv->quit_timer); + nm_clear_g_source (&priv->fail_stop_id); break; case NM_VPN_SERVICE_STATE_STOPPED: - priv->quit_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, - NM_VPN_PLUGIN_QUIT_TIMER, - quit_timer_expired, - plugin, - quit_timer_removed); + schedule_quit_timer (plugin); break; default: /* Clean up all timers we might have set up. */ - if (priv->connect_timer) - g_source_remove (priv->connect_timer); - - if (priv->quit_timer) - g_source_remove (priv->quit_timer); - - if (priv->fail_stop_id) { - g_source_remove (priv->fail_stop_id); - priv->fail_stop_id = 0; - } + nm_clear_g_source (&priv->connect_timer); + nm_clear_g_source (&priv->quit_timer); + nm_clear_g_source (&priv->fail_stop_id); break; } } diff --git a/libnm-glib/tests/common.c b/libnm-glib/tests/common.c index 540d43afa..f071fb5b3 100644 --- a/libnm-glib/tests/common.c +++ b/libnm-glib/tests/common.c @@ -75,7 +75,7 @@ nm_test_service_init (void) g_assert_no_error (error); /* Wait until the service is registered on the bus */ - for (i = 100; i > 0; i--) { + for (i = 1000; i > 0; i--) { if (name_exists (info->bus, "org.freedesktop.NetworkManager")) break; g_usleep (G_USEC_PER_SEC / 50); diff --git a/libnm-util/NetworkManager.h b/libnm-util/NetworkManager.h index 4fa861e88..e8dec062f 100644 --- a/libnm-util/NetworkManager.h +++ b/libnm-util/NetworkManager.h @@ -185,7 +185,7 @@ typedef enum { * * (Corresponds to the NM_DEVICE_CAP type in nm-device-wifi.xml.) **/ -typedef enum { +typedef enum { /*< flags >*/ NM_DEVICE_CAP_NONE = 0x00000000, NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001, NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002, @@ -212,7 +212,7 @@ typedef enum { * * (Corresponds to the NM_802_11_DEVICE_CAP type in nm-device-wifi.xml.) **/ -typedef enum { +typedef enum { /*< flags >*/ NM_WIFI_DEVICE_CAP_NONE = 0x00000000, NM_WIFI_DEVICE_CAP_CIPHER_WEP40 = 0x00000001, NM_WIFI_DEVICE_CAP_CIPHER_WEP104 = 0x00000002, @@ -238,7 +238,7 @@ typedef enum { * * (Corresponds to the NM_802_11_AP_FLAGS type in nm-access-point.xml.) **/ -typedef enum { +typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/ NM_802_11_AP_FLAGS_NONE = 0x00000000, NM_802_11_AP_FLAGS_PRIVACY = 0x00000001 } NM80211ApFlags; @@ -270,7 +270,7 @@ typedef enum { * * (Corresponds to the NM_802_11_AP_SEC type in nm-access-point.xml.) **/ -typedef enum { +typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/ NM_802_11_AP_SEC_NONE = 0x00000000, NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001, NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002, @@ -301,7 +301,7 @@ typedef enum { * * (Corresponds to the NM_802_11_MODE type in generic-types.xml.) **/ -typedef enum { +typedef enum { /*< underscore_name=nm_802_11_mode >*/ NM_802_11_MODE_UNKNOWN = 0, NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, @@ -319,7 +319,7 @@ typedef enum { * * (Corresponds to the NM_BT_CAPABILITY type in nm-device-bt.xml.) **/ -typedef enum { +typedef enum { /*< flags >*/ NM_BT_CAPABILITY_NONE = 0x00000000, NM_BT_CAPABILITY_DUN = 0x00000001, NM_BT_CAPABILITY_NAP = 0x00000002, @@ -343,7 +343,7 @@ typedef enum { * * (Corresponds to the NM_DEVICE_MODEM_CAPABILITY type in nm-device-modem.xml.) **/ -typedef enum { +typedef enum { /*< flags >*/ NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000, NM_DEVICE_MODEM_CAPABILITY_POTS = 0x00000001, NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002, diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index d0c2ca31f..143063e7f 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -332,6 +332,21 @@ nm_utils_ssid_to_utf8 (const GByteArray *ssid) "UTF-8", e1, "?", NULL, NULL, NULL); } + if (!converted) { + /* If there is still no converted string, the SSID probably + * contains characters not valid in the current locale. Convert + * the string to ASCII instead. + */ + + /* Use the printable range of 0x20-0x7E */ + gchar *valid_chars = " !\"#$%&'()*+,-./0123456789:;<=>?@" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" + "abcdefghijklmnopqrstuvwxyz{|}~"; + + converted = g_strndup ((const gchar *)ssid->data, ssid->len); + g_strcanon (converted, valid_chars, '?'); + } + return converted; } diff --git a/libnm-util/nm-version.h.in b/libnm-util/nm-version.h.in index bbbf993a9..e00f40559 100644 --- a/libnm-util/nm-version.h.in +++ b/libnm-util/nm-version.h.in @@ -21,6 +21,8 @@ #ifndef NM_VERSION_H #define NM_VERSION_H +#include <glib.h> + /** * NM_MAJOR_VERSION: * @@ -67,9 +69,13 @@ #define NM_VERSION_0_9_8 (NM_ENCODE_VERSION (0, 9, 8)) #define NM_VERSION_0_9_10 (NM_ENCODE_VERSION (0, 9, 10)) #define NM_VERSION_1_0 (NM_ENCODE_VERSION (1, 0, 0)) +#define NM_VERSION_1_0_2 (NM_ENCODE_VERSION (1, 0, 2)) +#define NM_VERSION_1_0_4 (NM_ENCODE_VERSION (1, 0, 4)) +#define NM_VERSION_1_0_6 (NM_ENCODE_VERSION (1, 0, 6)) +#define NM_VERSION_1_0_8 (NM_ENCODE_VERSION (1, 0, 8)) -#define NM_VERSION_CUR_STABLE NM_VERSION_1_0 -#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0 +#define NM_VERSION_CUR_STABLE NM_VERSION_1_0_6 +#define NM_VERSION_NEXT_STABLE NM_VERSION_1_0_8 #if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) # undef NM_VERSION_MIN_REQUIRED @@ -100,6 +106,12 @@ # define NM_DEPRECATED_IN_0_9_10_FOR(f) #endif +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10 +# define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) +#else +# define NM_AVAILABLE_IN_0_9_10 +#endif + #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_0 # define NM_DEPRECATED_IN_1_0 G_DEPRECATED # define NM_DEPRECATED_IN_1_0_FOR(f) G_DEPRECATED_FOR(f) @@ -108,16 +120,22 @@ # define NM_DEPRECATED_IN_1_0_FOR(f) #endif -#if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10 -# define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10) -#else -# define NM_AVAILABLE_IN_0_9_10 -#endif - #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0 # define NM_AVAILABLE_IN_1_0 G_UNAVAILABLE(1,0) #else # define NM_AVAILABLE_IN_1_0 #endif +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0_4 +# define NM_AVAILABLE_IN_1_0_4 G_UNAVAILABLE(1,0.4) +#else +# define NM_AVAILABLE_IN_1_0_4 +#endif + +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0_6 +# define NM_AVAILABLE_IN_1_0_6 G_UNAVAILABLE(1,0.6) +#else +# define NM_AVAILABLE_IN_1_0_6 +#endif + #endif /* NM_VERSION_H */ diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 294bab410..90c5de04e 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -851,3 +851,19 @@ global: nm_setting_connection_get_autoconnect_slaves; } libnm_1_0_0; +libnm_1_0_6 { +global: + nm_access_point_get_last_seen; + nm_device_get_metered; + nm_device_wifi_request_scan_options; + nm_device_wifi_request_scan_options_async; + nm_metered_get_type; + nm_setting_connection_get_metered; + nm_setting_wired_get_wake_on_lan; + nm_setting_wired_get_wake_on_lan_password; + nm_setting_wired_wake_on_lan_get_type; + nm_utils_enum_from_str; + nm_utils_enum_to_str; + nm_utils_wifi_2ghz_freqs; + nm_utils_wifi_5ghz_freqs; +} libnm_1_0_4; diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index e20cd9971..c071a9276 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -49,6 +49,7 @@ typedef struct { NM80211Mode mode; guint32 max_bitrate; guint8 strength; + gint32 last_seen; } NMAccessPointPrivate; enum { @@ -63,6 +64,7 @@ enum { PROP_MAX_BITRATE, PROP_STRENGTH, PROP_BSSID, + PROP_LAST_SEEN, LAST_PROP }; @@ -221,6 +223,26 @@ nm_access_point_get_strength (NMAccessPoint *ap) } /** + * nm_access_point_get_last_seen: + * @ap: a #NMAccessPoint + * + * Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last time the + * access point was found in scan results. A value of -1 means the access + * point has not been found in a scan. + * + * Returns: the last seen time in seconds + * + * Since: 1.0.6 + **/ +gint32 +nm_access_point_get_last_seen (NMAccessPoint *ap) +{ + g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), -1); + + return NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen; +} + +/** * nm_access_point_connection_valid: * @ap: an #NMAccessPoint to validate @connection against * @connection: an #NMConnection to validate against @ap @@ -364,6 +386,7 @@ nm_access_point_filter_connections (NMAccessPoint *ap, const GPtrArray *connecti static void nm_access_point_init (NMAccessPoint *ap) { + NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen = -1; } static void @@ -418,6 +441,9 @@ get_property (GObject *object, case PROP_STRENGTH: g_value_set_uchar (value, nm_access_point_get_strength (ap)); break; + case PROP_LAST_SEEN: + g_value_set_int (value, nm_access_point_get_last_seen (ap)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -439,6 +465,7 @@ init_dbus (NMObject *object) { NM_ACCESS_POINT_MODE, &priv->mode }, { NM_ACCESS_POINT_MAX_BITRATE, &priv->max_bitrate }, { NM_ACCESS_POINT_STRENGTH, &priv->strength }, + { NM_ACCESS_POINT_LAST_SEEN, &priv->last_seen }, { NULL }, }; @@ -595,4 +622,20 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) 0, G_MAXUINT8, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /** + * NMAccessPoint:last-seen: + * + * The timestamp (in CLOCK_BOOTTIME seconds) for the last time the + * access point was found in scan results. A value of -1 means the + * access point has not been found in a scan. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_LAST_SEEN, + g_param_spec_int (NM_ACCESS_POINT_LAST_SEEN, "", "", + -1, G_MAXINT, -1, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm/nm-access-point.h b/libnm/nm-access-point.h index 6991c19ac..24208fa8a 100644 --- a/libnm/nm-access-point.h +++ b/libnm/nm-access-point.h @@ -46,6 +46,7 @@ G_BEGIN_DECLS #define NM_ACCESS_POINT_MODE "mode" #define NM_ACCESS_POINT_MAX_BITRATE "max-bitrate" #define NM_ACCESS_POINT_STRENGTH "strength" +#define NM_ACCESS_POINT_LAST_SEEN "last-seen" /* DEPRECATED */ #define NM_ACCESS_POINT_HW_ADDRESS "hw-address" @@ -73,6 +74,8 @@ guint32 nm_access_point_get_frequency (NMAccessPoint *ap); NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap); guint8 nm_access_point_get_strength (NMAccessPoint *ap); +NM_AVAILABLE_IN_1_0_6 +gint nm_access_point_get_last_seen (NMAccessPoint *ap); GPtrArray * nm_access_point_filter_connections (NMAccessPoint *ap, const GPtrArray *connections); diff --git a/libnm/nm-client.c b/libnm/nm-client.c index e0a2a7b4f..982717ceb 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -76,6 +76,7 @@ enum { PROP_CONNECTIONS, PROP_HOSTNAME, PROP_CAN_MODIFY, + PROP_METERED, LAST_PROP }; @@ -1288,7 +1289,7 @@ nm_client_add_connection_async (NMClient *client, } simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data, - nm_client_deactivate_connection_async); + nm_client_add_connection_async); nm_remote_settings_add_connection_async (NM_CLIENT_GET_PRIVATE (client)->settings, connection, save_to_disk, cancellable, add_connection_cb, simple); @@ -1871,6 +1872,7 @@ get_property (GObject *object, guint prop_id, case PROP_PRIMARY_CONNECTION: case PROP_ACTIVATING_CONNECTION: case PROP_DEVICES: + case PROP_METERED: g_object_get_property (G_OBJECT (NM_CLIENT_GET_PRIVATE (object)->manager), pspec->name, value); break; @@ -2143,6 +2145,20 @@ nm_client_class_init (NMClientClass *client_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMClient:metered: + * + * Whether the connectivity is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_uint (NM_CLIENT_METERED, "", "", + 0, G_MAXUINT32, NM_METERED_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /* signals */ /** diff --git a/libnm/nm-client.h b/libnm/nm-client.h index 619ad8585..fc309fa1a 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -56,6 +56,7 @@ G_BEGIN_DECLS #define NM_CLIENT_CONNECTIONS "connections" #define NM_CLIENT_HOSTNAME "hostname" #define NM_CLIENT_CAN_MODIFY "can-modify" +#define NM_CLIENT_METERED "metered" #define NM_CLIENT_DEVICE_ADDED "device-added" #define NM_CLIENT_DEVICE_REMOVED "device-removed" diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 4a19f2e5a..536f3082e 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -271,6 +271,52 @@ nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device, return ap; } +static GVariant * +prepare_scan_options (GVariant *options) +{ + + GVariant *variant; + GVariantIter iter; + GVariantBuilder builder; + char *key; + GVariant *value; + + if (!options) + variant = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0); + else { + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + g_variant_iter_init (&iter, options); + while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) + { + // FIXME: verify options here? + g_variant_builder_add (&builder, "{sv}", key, value); + } + variant = g_variant_builder_end (&builder); + } + return variant; +} + +static gboolean +_device_wifi_request_scan (NMDeviceWifi *device, + GVariant *options, + GCancellable *cancellable, + GError **error) +{ + gboolean ret; + GVariant *variant; + + g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), FALSE); + + variant = prepare_scan_options (options); + + ret = nmdbus_device_wifi_call_request_scan_sync (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, + variant, + cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; +} + /** * nm_device_wifi_request_scan: * @device: a #NMDeviceWifi @@ -289,17 +335,36 @@ nm_device_wifi_request_scan (NMDeviceWifi *device, GCancellable *cancellable, GError **error) { - gboolean ret; - - g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), FALSE); + return _device_wifi_request_scan (device, NULL, cancellable, error); +} - ret = nmdbus_device_wifi_call_request_scan_sync (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, - g_variant_new_array (G_VARIANT_TYPE ("{sv}"), - NULL, 0), - cancellable, error); - if (error && *error) - g_dbus_error_strip_remote_error (*error); - return ret; +/** + * nm_device_wifi_request_scan_options: + * @device: a #NMDeviceWifi + * @options: dictionary with options for RequestScan(), or %NULL + * @cancellable: a #GCancellable, or %NULL + * @error: location for a #GError, or %NULL + * + * Request NM to scan for access points on @device. Note that the function + * returns immediately after requesting the scan, and it may take some time + * after that for the scan to complete. + * This is the same as @nm_device_wifi_request_scan except it accepts @options + * for the scanning. The argument is the dictionary passed to RequestScan() + * D-Bus call. Valid otions inside the dictionary are: + * 'ssids' => array of SSIDs (saay) + * + * Returns: %TRUE on success, %FALSE on error, in which case @error will be + * set. + * + * Since: 1.0.6 + **/ +gboolean +nm_device_wifi_request_scan_options (NMDeviceWifi *device, + GVariant *options, + GCancellable *cancellable, + GError **error) +{ + return _device_wifi_request_scan (device, options, cancellable, error); } static void @@ -326,19 +391,9 @@ request_scan_cb (GObject *source, g_slice_free (RequestScanInfo, info); } -/** - * nm_device_wifi_request_scan_async: - * @device: a #NMDeviceWifi - * @cancellable: a #GCancellable, or %NULL - * @callback: callback to be called when the scan has been requested - * @user_data: caller-specific data passed to @callback - * - * Request NM to scan for access points on @device. Note that @callback will be - * called immediately after requesting the scan, and it may take some time after - * that for the scan to complete. - **/ -void -nm_device_wifi_request_scan_async (NMDeviceWifi *device, +static void +_device_wifi_request_scan_async (NMDeviceWifi *device, + GVariant *options, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -346,6 +401,7 @@ nm_device_wifi_request_scan_async (NMDeviceWifi *device, NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); RequestScanInfo *info; GSimpleAsyncResult *simple; + GVariant *variant; g_return_if_fail (NM_IS_DEVICE_WIFI (device)); @@ -364,13 +420,63 @@ nm_device_wifi_request_scan_async (NMDeviceWifi *device, info->device = device; info->simple = simple; + variant = prepare_scan_options (options); + priv->scan_info = info; nmdbus_device_wifi_call_request_scan (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, - g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0), + variant, cancellable, request_scan_cb, info); } /** + * nm_device_wifi_request_scan_async: + * @device: a #NMDeviceWifi + * @cancellable: a #GCancellable, or %NULL + * @callback: callback to be called when the scan has been requested + * @user_data: caller-specific data passed to @callback + * + * Request NM to scan for access points on @device. Note that @callback will be + * called immediately after requesting the scan, and it may take some time after + * that for the scan to complete. + **/ +void +nm_device_wifi_request_scan_async (NMDeviceWifi *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + _device_wifi_request_scan_async (device, NULL, cancellable, callback, user_data); +} + +/** + * nm_device_wifi_request_scan_options_async: + * @device: a #NMDeviceWifi + * @options: dictionary with options for RequestScan(), or %NULL + * @cancellable: a #GCancellable, or %NULL + * @callback: callback to be called when the scan has been requested + * @user_data: caller-specific data passed to @callback + * + * Request NM to scan for access points on @device. Note that @callback will be + * called immediately after requesting the scan, and it may take some time after + * that for the scan to complete. + * This is the same as @nm_device_wifi_request_scan_async except it accepts @options + * for the scanning. The argument is the dictionary passed to RequestScan() + * D-Bus call. Valid otions inside the dictionary are: + * 'ssids' => array of SSIDs (saay) + * + * Since: 1.0.6 + **/ +void +nm_device_wifi_request_scan_options_async (NMDeviceWifi *device, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + _device_wifi_request_scan_async (device, options, cancellable, callback, user_data); +} + +/** * nm_device_wifi_request_scan_finish: * @device: a #NMDeviceWifi * @result: the result passed to the #GAsyncReadyCallback diff --git a/libnm/nm-device-wifi.h b/libnm/nm-device-wifi.h index 24339fd3d..b5a56980c 100644 --- a/libnm/nm-device-wifi.h +++ b/libnm/nm-device-wifi.h @@ -77,11 +77,21 @@ const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi * gboolean nm_device_wifi_request_scan (NMDeviceWifi *device, GCancellable *cancellable, GError **error); - +NM_AVAILABLE_IN_1_0_6 +gboolean nm_device_wifi_request_scan_options (NMDeviceWifi *device, + GVariant *options, + GCancellable *cancellable, + GError **error); void nm_device_wifi_request_scan_async (NMDeviceWifi *device, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); +NM_AVAILABLE_IN_1_0_6 +void nm_device_wifi_request_scan_options_async (NMDeviceWifi *device, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); gboolean nm_device_wifi_request_scan_finish (NMDeviceWifi *device, GAsyncResult *result, GError **error); diff --git a/libnm/nm-device.c b/libnm/nm-device.c index cd14c0e90..d3ac705c1 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -81,6 +81,7 @@ typedef struct { char *driver_version; char *firmware_version; char *type_description; + NMMetered metered; NMDeviceCapabilities capabilities; gboolean managed; gboolean firmware_missing; @@ -130,6 +131,7 @@ enum { PROP_AVAILABLE_CONNECTIONS, PROP_PHYSICAL_PORT_ID, PROP_MTU, + PROP_METERED, LAST_PROP }; @@ -193,6 +195,7 @@ init_dbus (NMObject *object) { NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION }, { NM_DEVICE_PHYSICAL_PORT_ID, &priv->physical_port_id }, { NM_DEVICE_MTU, &priv->mtu }, + { NM_DEVICE_METERED, &priv->metered }, /* Properties that exist in D-Bus but that we don't track */ { "ip4-address", NULL }, @@ -449,6 +452,9 @@ get_property (GObject *object, case PROP_MTU: g_value_set_uint (value, nm_device_get_mtu (device)); break; + case PROP_METERED: + g_value_set_uint (value, nm_device_get_metered (device)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -793,6 +799,20 @@ nm_device_class_init (NMDeviceClass *device_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMDevice:metered: + * + * Whether the device is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_uint (NM_DEVICE_METERED, "", "", + 0, G_MAXUINT32, NM_METERED_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /* signals */ /** @@ -1884,6 +1904,24 @@ nm_device_get_mtu (NMDevice *device) } /** + * nm_device_get_metered: + * @device: a #NMDevice + * + * Gets the metered setting of a #NMDevice. + * + * Returns: the metered setting. + * + * Since: 1.0.6 + **/ +NMMetered +nm_device_get_metered (NMDevice *device) +{ + g_return_val_if_fail (NM_IS_DEVICE (device), NM_METERED_UNKNOWN); + + return NM_DEVICE_GET_PRIVATE (device)->metered; +} + +/** * nm_device_is_software: * @device: a #NMDevice * diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 5cc373569..a61dcf323 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -60,6 +60,7 @@ G_BEGIN_DECLS #define NM_DEVICE_PRODUCT "product" #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id" #define NM_DEVICE_MTU "mtu" +#define NM_DEVICE_METERED "metered" struct _NMDevice { NMObject parent; @@ -119,6 +120,8 @@ gboolean nm_device_is_software (NMDevice *device); const char * nm_device_get_product (NMDevice *device); const char * nm_device_get_vendor (NMDevice *device); const char * nm_device_get_description (NMDevice *device); +NM_AVAILABLE_IN_1_0_6 +NMMetered nm_device_get_metered (NMDevice *device); char ** nm_device_disambiguate_names (NMDevice **devices, int num_devices); diff --git a/libnm/nm-ifcfg-rh-docs.xml b/libnm/nm-ifcfg-rh-docs.xml index 0c287f26d..1ea38141b 100644 --- a/libnm/nm-ifcfg-rh-docs.xml +++ b/libnm/nm-ifcfg-rh-docs.xml @@ -92,6 +92,7 @@ when this connection is activated."/> together with this connection."/> <property name="gateway-ping-timeout" variable="GATEWAY_PING_TIMEOUT(+)" format="" values="" default="0" example="GATEWAY_PING_TIMEOUT=5" description="If greater than zero, the IP connectivity will be checked by pinging the gateway and waiting for the specified timeout (in seconds)."/> +<property name="metered" variable="CONNECTION_METERED" format="" values="yes,no,unknown" default="" example="CONNECTION_METERED=yes" description="Whether the device is metered"/> </setting> <setting name="dcb"> <property name="app-fcoe-flags" variable="DCB_APP_FCOE_ENABLE, DCB_APP_FCOE_ADVERTISE, DCB_APP_FCOE_WILLING" format="" values="" default="no" example="DCB_APP_FCOE_ENABLE=yes DCB_APP_FCOE_ADVERTISE=yes" description="FCOE flags."/> @@ -192,7 +193,7 @@ IPV6_PRIVACY_PREFER_PUBLIC_IP: yes, no" default="no" example="IPV6_PRIVACY=rfc30 <setting name="vlan"> <property name="parent" variable="DEVICE or PHYSDEV" format="" values="" default="" example="" description="Parent interface of the VLAN."/> <property name="id" variable="VLAN_ID or DEVICE" format="" values="" default="" example="" description="VLAN identifier."/> -<property name="flags" variable="VLAN_FLAGS, REORDER_HDR" format="" values=""GVRP", "LOOSE_BINDING" for VLAN_FLAGS; 0 or 1 for REORDER_HDR" default="" example="" description="Parent interface of the VLAN."/> +<property name="flags" variable="VLAN_FLAGS, REORDER_HDR" format="" values=""GVRP", "LOOSE_BINDING" for VLAN_FLAGS; 0 or 1 for REORDER_HDR" default="" example="" description="VLAN flags."/> <property name="ingress-property-map" variable="VLAN_INGRESS_PRIORITY_MAP" format="" values="" default="" example="VLAN_INGRESS_PRIORITY_MAP=4:2,3:5" description="Ingress priority mapping."/> <property name="egress-property-map" variable="VLAN_EGRESS_PRIORITY_MAP" format="" values="" default="" example="VLAN_EGRESS_PRIORITY_MAP=5:4,4:1,3:7" description="Egress priority mapping."/> <property name="interface-name" variable="PHYSDEV and VLAN_ID, or DEVICE" format="" values="" default="" example="PHYSDEV=eth0, VLAN_ID=12; or DEVICE=eth0.12" description="VLAN interface name. diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 003d6b875..2a61a0109 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -64,6 +64,7 @@ typedef struct { NMConnectivityState connectivity; NMActiveConnection *primary_connection; NMActiveConnection *activating_connection; + NMMetered metered; GCancellable *perm_call_cancellable; GHashTable *permissions; @@ -102,6 +103,7 @@ enum { PROP_PRIMARY_CONNECTION, PROP_ACTIVATING_CONNECTION, PROP_DEVICES, + PROP_METERED, LAST_PROP }; @@ -179,6 +181,7 @@ init_dbus (NMObject *object) { NM_MANAGER_PRIMARY_CONNECTION, &priv->primary_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_MANAGER_ACTIVATING_CONNECTION, &priv->activating_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_MANAGER_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE, "device" }, + { NM_MANAGER_METERED, &priv->metered }, { NULL }, }; @@ -1537,6 +1540,9 @@ get_property (GObject *object, case PROP_DEVICES: g_value_take_boxed (value, _nm_utils_copy_object_array (nm_manager_get_devices (self))); break; + case PROP_METERED: + g_value_set_uint (value, priv->metered); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1669,6 +1675,19 @@ nm_manager_class_init (NMManagerClass *manager_class) G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMManager:metered: + * + * Whether the connectivity is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_uint (NM_MANAGER_METERED, "", "", + 0, G_MAXUINT32, NM_METERED_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); /* signals */ diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h index ca9f7dd60..8d04a060f 100644 --- a/libnm/nm-manager.h +++ b/libnm/nm-manager.h @@ -50,6 +50,7 @@ G_BEGIN_DECLS #define NM_MANAGER_PRIMARY_CONNECTION "primary-connection" #define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection" #define NM_MANAGER_DEVICES "devices" +#define NM_MANAGER_METERED "metered" typedef struct { NMObject parent; diff --git a/libnm/nm-property-docs.xml b/libnm/nm-property-docs.xml index 7bbf97a1a..e9a58128c 100644 --- a/libnm/nm-property-docs.xml +++ b/libnm/nm-property-docs.xml @@ -88,6 +88,7 @@ <property name="id" type="string" description="A human readable unique identifier for the connection, like "Work Wi-Fi" or "T-Mobile 3G"." /> <property name="interface-name" type="string" description="The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface." /> <property name="master" type="string" description="Interface name of the master device or UUID of the master connection." /> + <property name="metered" type="NMMetered (int32)" description="Whether the connection is metered." /> <property name="name" type="string" default="connection" description="The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example "ppp" or "wireless" or "wired"." /> <property name="permissions" type="array of string" default="[]" description="An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection. Otherwise a user is allowed to access this connection if and only if they are in this list. Each entry is of the form "[type]:[id]:[reserved]"; for example, "user:dcbw:blah". At this time only the "user" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the ":" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8." /> <property name="read-only" type="boolean" default="FALSE" description="FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified." /> @@ -257,6 +258,8 @@ <property name="s390-options" type="dict of string to string" default="{}" description="Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include "portno", "layer2", "portname", "protocol", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9])." /> <property name="s390-subchannels" type="array of string" default="[]" description="Identifies specific subchannels that this network device uses for communication with z/VM or s390 host. Like the "mac-address" property for non-z/VM devices, this property can be used to ensure this connection only applies to the network device that uses these subchannels. The list should contain exactly 3 strings, and each string may only be composed of hexadecimal characters and the period (.) character." /> <property name="speed" type="uint32" default="0" description="If non-zero, request that the device use only the specified speed. In Mbit/s, ie 100 == 100Mbit/s." /> + <property name="wake-on-lan" type="uint32" default="1" description="The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40)." /> + <property name="wake-on-lan-password" type="string" description="If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required." /> </setting> <setting name="802-11-wireless"> <property name="band" type="string" description="802.11 frequency band of the network. One of "a" for 5GHz 802.11a or "bg" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network to the specific band, i.e. if "a" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible. This setting depends on specific driver capability and may not work with all drivers." /> diff --git a/libnm/nm-setting-docs.xml b/libnm/nm-setting-docs.xml index c2cb80edb..8338fbcab 100644 --- a/libnm/nm-setting-docs.xml +++ b/libnm/nm-setting-docs.xml @@ -90,6 +90,7 @@ <property name="id" type="string" description="A human readable unique identifier for the connection, like "Work Wi-Fi" or "T-Mobile 3G"." /> <property name="interface-name" type="string" description="The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface." /> <property name="master" type="string" description="Interface name of the master device or UUID of the master connection." /> + <property name="metered" type="NMMetered (int32)" description="Whether the connection is metered." /> <property name="name" type="string" default="connection" description="The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example "ppp" or "wireless" or "wired"." /> <property name="permissions" type="array of string" default="[]" description="An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection. Otherwise a user is allowed to access this connection if and only if they are in this list. Each entry is of the form "[type]:[id]:[reserved]"; for example, "user:dcbw:blah". At this time only the "user" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the ":" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8." /> <property name="read-only" type="boolean" default="FALSE" description="FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified." /> @@ -265,6 +266,8 @@ <property name="s390-options" type="dict of string to string" default="{}" description="Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include "portno", "layer2", "portname", "protocol", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9])." /> <property name="s390-subchannels" type="array of string" default="[]" description="Identifies specific subchannels that this network device uses for communication with z/VM or s390 host. Like the "mac-address" property for non-z/VM devices, this property can be used to ensure this connection only applies to the network device that uses these subchannels. The list should contain exactly 3 strings, and each string may only be composed of hexadecimal characters and the period (.) character." /> <property name="speed" type="uint32" default="0" description="If non-zero, request that the device use only the specified speed. In Mbit/s, ie 100 == 100Mbit/s." /> + <property name="wake-on-lan" type="uint32" default="1" description="The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40)." /> + <property name="wake-on-lan-password" type="string" description="If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required." /> </setting> <setting name="802-11-wireless"> <property name="band" type="string" description="802.11 frequency band of the network. One of "a" for 5GHz 802.11a or "bg" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network to the specific band, i.e. if "a" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible. This setting depends on specific driver capability and may not work with all drivers." /> diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index b43c481c7..24d8e4016 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -40,6 +40,7 @@ #include "nm-dbus-helpers.h" #include "nm-core-internal.h" #include "nm-simple-connection.h" +#include "nm-macros-internal.h" #include "nmdbus-vpn-plugin.h" @@ -229,6 +230,7 @@ connect_timer_expired (gpointer data) NMVpnPluginOld *plugin = NM_VPN_PLUGIN_OLD (data); GError *err = NULL; + NM_VPN_PLUGIN_OLD_GET_PRIVATE (plugin)->connect_timer = 0; g_message ("Connect timer expired, disconnecting."); nm_vpn_plugin_old_disconnect (plugin, &err); if (err) { @@ -236,26 +238,38 @@ connect_timer_expired (gpointer data) g_error_free (err); } - return FALSE; + return G_SOURCE_REMOVE; } static gboolean quit_timer_expired (gpointer data) { - NMVpnPluginOld *plugin = NM_VPN_PLUGIN_OLD (data); + NMVpnPluginOld *self = NM_VPN_PLUGIN_OLD (data); + + NM_VPN_PLUGIN_OLD_GET_PRIVATE (self)->quit_timer = 0; + nm_vpn_plugin_old_emit_quit (self); + return G_SOURCE_REMOVE; +} - nm_vpn_plugin_old_emit_quit (plugin); +static void +schedule_quit_timer (NMVpnPluginOld *self) +{ + NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE (self); - return FALSE; + nm_clear_g_source (&priv->quit_timer); + priv->quit_timer = g_timeout_add_seconds (NM_VPN_PLUGIN_OLD_QUIT_TIMER, + quit_timer_expired, + self); } static gboolean fail_stop (gpointer data) { - NMVpnPluginOld *plugin = NM_VPN_PLUGIN_OLD (data); + NMVpnPluginOld *self = NM_VPN_PLUGIN_OLD (data); - nm_vpn_plugin_old_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED); - return FALSE; + NM_VPN_PLUGIN_OLD_GET_PRIVATE (self)->fail_stop_id = 0; + nm_vpn_plugin_old_set_state (self, NM_VPN_SERVICE_STATE_STOPPED); + return G_SOURCE_REMOVE; } static void @@ -263,8 +277,7 @@ schedule_fail_stop (NMVpnPluginOld *plugin) { NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE (plugin); - if (priv->fail_stop_id) - g_source_remove (priv->fail_stop_id); + nm_clear_g_source (&priv->fail_stop_id); priv->fail_stop_id = g_idle_add (fail_stop, plugin); } @@ -369,21 +382,11 @@ nm_vpn_plugin_old_set_ip6_config (NMVpnPluginOld *plugin, } static void -connect_timer_removed (gpointer data) -{ - NM_VPN_PLUGIN_OLD_GET_PRIVATE (data)->connect_timer = 0; -} - -static void connect_timer_start (NMVpnPluginOld *plugin) { NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE (plugin); - priv->connect_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, - 60, - connect_timer_expired, - plugin, - connect_timer_removed); + priv->connect_timer = g_timeout_add_seconds (60, connect_timer_expired, plugin); } static void @@ -508,6 +511,11 @@ impl_vpn_plugin_old_need_secrets (NMVpnPluginOld *plugin, } if (needed) { + /* Push back the quit timer so the VPN plugin doesn't quit in the + * middle of asking the user for secrets. + */ + schedule_quit_timer (plugin); + g_assert (setting_name); g_dbus_method_invocation_return_value (context, g_variant_new ("(s)", setting_name)); @@ -607,8 +615,7 @@ nm_vpn_plugin_old_secrets_required (NMVpnPluginOld *plugin, /* Cancel the connect timer since secrets might take a while. It'll * get restarted when the secrets come back via NewSecrets(). */ - if (priv->connect_timer) - g_source_remove (priv->connect_timer); + nm_clear_g_source (&priv->connect_timer); g_signal_emit (plugin, signals[SECRETS_REQUIRED], 0, message, hints); } @@ -993,10 +1000,9 @@ dispose (GObject *object) NMVpnServiceState state; GError *err = NULL; - if (priv->fail_stop_id) { - g_source_remove (priv->fail_stop_id); - priv->fail_stop_id = 0; - } + nm_clear_g_source (&priv->fail_stop_id); + nm_clear_g_source (&priv->quit_timer); + nm_clear_g_source (&priv->connect_timer); state = nm_vpn_plugin_old_get_state (plugin); @@ -1030,46 +1036,23 @@ finalize (GObject *object) } static void -quit_timer_removed (gpointer data) -{ - NM_VPN_PLUGIN_OLD_GET_PRIVATE (data)->quit_timer = 0; -} - -static void state_changed (NMVpnPluginOld *plugin, NMVpnServiceState state) { NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE (plugin); switch (state) { case NM_VPN_SERVICE_STATE_STARTING: - /* Remove the quit timer. */ - if (priv->quit_timer) - g_source_remove (priv->quit_timer); - - if (priv->fail_stop_id) { - g_source_remove (priv->fail_stop_id); - priv->fail_stop_id = 0; - } + nm_clear_g_source (&priv->quit_timer); + nm_clear_g_source (&priv->fail_stop_id); break; case NM_VPN_SERVICE_STATE_STOPPED: - priv->quit_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, - NM_VPN_PLUGIN_OLD_QUIT_TIMER, - quit_timer_expired, - plugin, - quit_timer_removed); + schedule_quit_timer (plugin); break; default: /* Clean up all timers we might have set up. */ - if (priv->connect_timer) - g_source_remove (priv->connect_timer); - - if (priv->quit_timer) - g_source_remove (priv->quit_timer); - - if (priv->fail_stop_id) { - g_source_remove (priv->fail_stop_id); - priv->fail_stop_id = 0; - } + nm_clear_g_source (&priv->connect_timer); + nm_clear_g_source (&priv->quit_timer); + nm_clear_g_source (&priv->fail_stop_id); break; } } diff --git a/libnm/tests/common.c b/libnm/tests/common.c index a28e5112b..8c1b83a8b 100644 --- a/libnm/tests/common.c +++ b/libnm/tests/common.c @@ -74,7 +74,7 @@ nm_test_service_init (void) g_assert_no_error (error); /* Wait until the service is registered on the bus */ - for (i = 100; i > 0; i--) { + for (i = 1000; i > 0; i--) { if (name_exists (info->bus, "org.freedesktop.NetworkManager")) break; g_usleep (G_USEC_PER_SEC / 50); diff --git a/man/NetworkManager.8 b/man/NetworkManager.8 index 6896f941b..6ea900105 100644 --- a/man/NetworkManager.8 +++ b/man/NetworkManager.8 @@ -2,7 +2,7 @@ .\" Title: NetworkManager .\" Author: .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 07/14/2015 +.\" Date: 08/27/2015 .\" Manual: Network management daemons .\" Source: NetworkManager 1.0 .\" Language: English diff --git a/man/NetworkManager.conf.5 b/man/NetworkManager.conf.5 index ae18f4f6c..011b98d3b 100644 --- a/man/NetworkManager.conf.5 +++ b/man/NetworkManager.conf.5 @@ -2,7 +2,7 @@ .\" Title: NetworkManager.conf .\" Author: .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 07/14/2015 +.\" Date: 08/27/2015 .\" Manual: Configuration .\" Source: NetworkManager 1.0 .\" Language: English @@ -505,6 +505,10 @@ is unset, use the content of "/proc/sys/net/ipv6/conf/default/use_tempaddr" as l \fIconnection\&.autoconnect\-slaves\fR .RS 4 .RE +.PP +\fIethernet\&.wake\-on\-lan\fR +.RS 4 +.RE .SH "CONNECTIVITY SECTION" .PP This section controls NetworkManager\*(Aqs optional connectivity checking functionality\&. This allows NetworkManager to detect whether or not the system can actually access the internet or whether it is behind a captive portal\&. diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in index 40fa49dd7..029db24e5 100644 --- a/man/NetworkManager.conf.xml.in +++ b/man/NetworkManager.conf.xml.in @@ -528,6 +528,9 @@ ipv6.ip6-privacy=1 <varlistentry> <term><varname>connection.autoconnect-slaves</varname></term> </varlistentry> + <varlistentry> + <term><varname>ethernet.wake-on-lan</varname></term> + </varlistentry> </variablelist> </para> </refsect1> diff --git a/man/nm-settings-ifcfg-rh.5 b/man/nm-settings-ifcfg-rh.5 index e31d9a9d6..26ac28d8d 100644 --- a/man/nm-settings-ifcfg-rh.5 +++ b/man/nm-settings-ifcfg-rh.5 @@ -2,12 +2,12 @@ .\" Title: nm-settings-ifcfg-rh .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 14 July 2015 +.\" Date: 27 August 2015 .\" Manual: Configuration -.\" Source: NetworkManager 1.0.4 +.\" Source: NetworkManager 1.0.6 .\" Language: English .\" -.TH "NM\-SETTINGS\-IFCFG\" "5" "" "NetworkManager 1\&.0\&.4" "Configuration" +.TH "NM\-SETTINGS\-IFCFG\" "5" "" "NetworkManager 1\&.0\&.6" "Configuration" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -898,6 +898,7 @@ l l l l l l l l l l l l l l l l +l l l l l l l l. T{ id @@ -1030,6 +1031,19 @@ If greater than zero, the IP connectivity will be checked by pinging the gateway Example: \fRGATEWAY_PING_TIMEOUT=5 T} +T{ +metered +T}:T{ +CONNECTION_METERED +T}:T{ +\ \& +T}:T{ +Whether the device is metered\fB + +Example: \fRCONNECTION_METERED=yes\fB + +Allowed values: \fRyes,no,unknown +T} .TE .sp 1 .sp @@ -1746,7 +1760,7 @@ VLAN_FLAGS, REORDER_HDR T}:T{ \ \& T}:T{ -Parent interface of the VLAN\&.\fB +VLAN flags\&.\fB Allowed values: \fR"GVRP", "LOOSE_BINDING" for VLAN_FLAGS; 0 or 1 for REORDER_HDR T} diff --git a/man/nm-settings-ifcfg-rh.xml b/man/nm-settings-ifcfg-rh.xml index 7146cb43a..868e74207 100644 --- a/man/nm-settings-ifcfg-rh.xml +++ b/man/nm-settings-ifcfg-rh.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> -<refentry id="nm-settings-ifcfg-rh"><refentryinfo><date>14 July 2015</date></refentryinfo><refmeta><refentrytitle>nm-settings-ifcfg-rh</refentrytitle><manvolnum>5</manvolnum><refmiscinfo class="source">NetworkManager</refmiscinfo><refmiscinfo class="manual">Configuration</refmiscinfo><refmiscinfo class="version">1.0.4</refmiscinfo></refmeta><refnamediv><refname>nm-settings-ifcfg-rh</refname><refpurpose>Description of <emphasis>ifcfg-rh</emphasis> settings plugin</refpurpose></refnamediv><refsect1><title>DESCRIPTION</title><para> +<refentry id="nm-settings-ifcfg-rh"><refentryinfo><date>27 August 2015</date></refentryinfo><refmeta><refentrytitle>nm-settings-ifcfg-rh</refentrytitle><manvolnum>5</manvolnum><refmiscinfo class="source">NetworkManager</refmiscinfo><refmiscinfo class="manual">Configuration</refmiscinfo><refmiscinfo class="version">1.0.6</refmiscinfo></refmeta><refnamediv><refname>nm-settings-ifcfg-rh</refname><refpurpose>Description of <emphasis>ifcfg-rh</emphasis> settings plugin</refpurpose></refnamediv><refsect1><title>DESCRIPTION</title><para> NetworkManager is based on the concept of connection profiles that contain network configuration (see <citerefentry><refentrytitle>nm-settings</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details). The profiles can be stored in various formats. NetworkManager uses plugins for reading and writing @@ -235,7 +235,11 @@ Allowed values: </emphasis>-999 to 999</entry></row><row><entry align="left">zon Example: </emphasis>ZONE=Work</entry></row><row><entry align="left">master</entry><entry align="left">MASTER, TEAM_MASTER, BRIDGE</entry><entry align="left"/><entry align="left">Reference to master connection. The variable used depends on the connection type.</entry></row><row><entry align="left">slave-type</entry><entry align="left">MASTER, TEAM_MASTER, DEVICETYPE, BRIDGE</entry><entry align="left"/><entry align="left">Slave type doesn't map directly to a variable, but it is recognized using different variables. MASTER for bonding, TEAM_MASTER and DEVICETYPE for teaming, BRIDGE for bridging.</entry></row><row><entry align="left">autoconnect-slaves</entry><entry align="left">AUTOCONNECT-SLAVES<emphasis>(+)</emphasis></entry><entry align="left">missing variable means global default</entry><entry align="left">Whether slaves of this connection should be auto-connected when this connection is activated.</entry></row><row><entry align="left">secondaries</entry><entry align="left">SECONDARY_UUIDS<emphasis>(+)</emphasis></entry><entry align="left"/><entry align="left">UUID of VPN connections that should be activated together with this connection.</entry></row><row><entry align="left">gateway-ping-timeout</entry><entry align="left">GATEWAY_PING_TIMEOUT<emphasis>(+)</emphasis></entry><entry align="left">0</entry><entry align="left">If greater than zero, the IP connectivity will be checked by pinging the gateway and waiting for the specified timeout (in seconds).<emphasis role="bold"> -Example: </emphasis>GATEWAY_PING_TIMEOUT=5</entry></row></tbody></tgroup></table><table><title>dcb setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">app-fcoe-flags</entry><entry align="left">DCB_APP_FCOE_ENABLE, DCB_APP_FCOE_ADVERTISE, DCB_APP_FCOE_WILLING</entry><entry align="left">no</entry><entry align="left">FCOE flags.<emphasis role="bold"> +Example: </emphasis>GATEWAY_PING_TIMEOUT=5</entry></row><row><entry align="left">metered</entry><entry align="left">CONNECTION_METERED</entry><entry align="left"/><entry align="left">Whether the device is metered<emphasis role="bold"> + +Example: </emphasis>CONNECTION_METERED=yes<emphasis role="bold"> + +Allowed values: </emphasis>yes,no,unknown</entry></row></tbody></tgroup></table><table><title>dcb setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">app-fcoe-flags</entry><entry align="left">DCB_APP_FCOE_ENABLE, DCB_APP_FCOE_ADVERTISE, DCB_APP_FCOE_WILLING</entry><entry align="left">no</entry><entry align="left">FCOE flags.<emphasis role="bold"> Example: </emphasis>DCB_APP_FCOE_ENABLE=yes DCB_APP_FCOE_ADVERTISE=yes</entry></row><row><entry align="left">app-fcoe-priority</entry><entry align="left">DCB_APP_FCOE_PRIORITY</entry><entry align="left"/><entry align="left">Priority of FCoE frames.<emphasis role="bold"> @@ -284,7 +288,7 @@ Example: </emphasis>IPV6_DEFAULTGW=abbe::1</entry></row><row><entry align="left" Example: </emphasis>IPV6_PRIVACY=rfc3041 IPV6_PRIVACY_PREFER_PUBLIC_IP=yes<emphasis role="bold"> -Allowed values: </emphasis>IPV6_PRIVACY: no, yes (rfc3041 or rfc4941); IPV6_PRIVACY_PREFER_PUBLIC_IP: yes, no</entry></row></tbody></tgroup></table><table><title>team-port setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">config</entry><entry align="left">TEAM_PORT_CONFIG</entry><entry align="left"/><entry align="left">Team port configuration in JSON. See man teamd.conf for details.</entry></row></tbody></tgroup></table><table><title>team setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">config</entry><entry align="left">TEAM_CONFIG</entry><entry align="left"/><entry align="left">Team configuration in JSON. See man teamd.conf for details.</entry></row></tbody></tgroup></table><table><title>vlan setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">parent</entry><entry align="left">DEVICE or PHYSDEV</entry><entry align="left"/><entry align="left">Parent interface of the VLAN.</entry></row><row><entry align="left">id</entry><entry align="left">VLAN_ID or DEVICE</entry><entry align="left"/><entry align="left">VLAN identifier.</entry></row><row><entry align="left">flags</entry><entry align="left">VLAN_FLAGS, REORDER_HDR</entry><entry align="left"/><entry align="left">Parent interface of the VLAN.<emphasis role="bold"> +Allowed values: </emphasis>IPV6_PRIVACY: no, yes (rfc3041 or rfc4941); IPV6_PRIVACY_PREFER_PUBLIC_IP: yes, no</entry></row></tbody></tgroup></table><table><title>team-port setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">config</entry><entry align="left">TEAM_PORT_CONFIG</entry><entry align="left"/><entry align="left">Team port configuration in JSON. See man teamd.conf for details.</entry></row></tbody></tgroup></table><table><title>team setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">config</entry><entry align="left">TEAM_CONFIG</entry><entry align="left"/><entry align="left">Team configuration in JSON. See man teamd.conf for details.</entry></row></tbody></tgroup></table><table><title>vlan setting</title><tgroup cols="4"><thead><row><entry>Property</entry><entry>Ifcfg-rh Variable</entry><entry>Default</entry><entry>Description</entry></row></thead><tbody><row><entry align="left">parent</entry><entry align="left">DEVICE or PHYSDEV</entry><entry align="left"/><entry align="left">Parent interface of the VLAN.</entry></row><row><entry align="left">id</entry><entry align="left">VLAN_ID or DEVICE</entry><entry align="left"/><entry align="left">VLAN identifier.</entry></row><row><entry align="left">flags</entry><entry align="left">VLAN_FLAGS, REORDER_HDR</entry><entry align="left"/><entry align="left">VLAN flags.<emphasis role="bold"> Allowed values: </emphasis>"GVRP", "LOOSE_BINDING" for VLAN_FLAGS; 0 or 1 for REORDER_HDR</entry></row><row><entry align="left">ingress-property-map</entry><entry align="left">VLAN_INGRESS_PRIORITY_MAP</entry><entry align="left"/><entry align="left">Ingress priority mapping.<emphasis role="bold"> diff --git a/man/nm-settings-keyfile.5 b/man/nm-settings-keyfile.5 index 1343bc157..613670728 100644 --- a/man/nm-settings-keyfile.5 +++ b/man/nm-settings-keyfile.5 @@ -2,12 +2,12 @@ .\" Title: nm-settings-keyfile .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 14 July 2015 +.\" Date: 27 August 2015 .\" Manual: Configuration -.\" Source: NetworkManager 1.0.4 +.\" Source: NetworkManager 1.0.6 .\" Language: English .\" -.TH "NM\-SETTINGS\-KEYFIL" "5" "" "NetworkManager 1\&.0\&.4" "Configuration" +.TH "NM\-SETTINGS\-KEYFIL" "5" "" "NetworkManager 1\&.0\&.6" "Configuration" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/man/nm-settings-keyfile.xml b/man/nm-settings-keyfile.xml index 2ab07314c..cd6e0443f 100644 --- a/man/nm-settings-keyfile.xml +++ b/man/nm-settings-keyfile.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> -<refentry id="nm-settings-keyfile"><refentryinfo><date>14 July 2015</date></refentryinfo><refmeta><refentrytitle>nm-settings-keyfile</refentrytitle><manvolnum>5</manvolnum><refmiscinfo class="source">NetworkManager</refmiscinfo><refmiscinfo class="manual">Configuration</refmiscinfo><refmiscinfo class="version">1.0.4</refmiscinfo></refmeta><refnamediv><refname>nm-settings-keyfile</refname><refpurpose>Description of <emphasis>keyfile</emphasis> settings plugin</refpurpose></refnamediv><refsect1><title>DESCRIPTION</title><para> +<refentry id="nm-settings-keyfile"><refentryinfo><date>27 August 2015</date></refentryinfo><refmeta><refentrytitle>nm-settings-keyfile</refentrytitle><manvolnum>5</manvolnum><refmiscinfo class="source">NetworkManager</refmiscinfo><refmiscinfo class="manual">Configuration</refmiscinfo><refmiscinfo class="version">1.0.6</refmiscinfo></refmeta><refnamediv><refname>nm-settings-keyfile</refname><refpurpose>Description of <emphasis>keyfile</emphasis> settings plugin</refpurpose></refnamediv><refsect1><title>DESCRIPTION</title><para> NetworkManager is based on the concept of connection profiles that contain network configuration (see <citerefentry><refentrytitle>nm-settings</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details). The profiles can be stored in various formats. NetworkManager uses plugins for reading and writing diff --git a/man/nm-settings.5 b/man/nm-settings.5 index 35b24d153..144c9ab9a 100644 --- a/man/nm-settings.5 +++ b/man/nm-settings.5 @@ -2,12 +2,12 @@ .\" Title: nm-settings .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 14 July 2015 +.\" Date: 27 August 2015 .\" Manual: Configuration -.\" Source: NetworkManager 1.0.4 +.\" Source: NetworkManager 1.0.6 .\" Language: English .\" -.TH "NM\-SETTINGS" "5" "" "NetworkManager 1\&.0\&.4" "Configuration" +.TH "NM\-SETTINGS" "5" "" "NetworkManager 1\&.0\&.6" "Configuration" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -889,6 +889,7 @@ l l l l l l l l l l l l l l l l +l l l l l l l l. T{ autoconnect @@ -954,6 +955,15 @@ T}:T{ Interface name of the master device or UUID of the master connection\&. T} T{ +metered +T}:T{ +NMMetered (int32) +T}:T{ +\ \& +T}:T{ +Whether the connection is metered\&. +T} +T{ name T}:T{ string @@ -2601,6 +2611,8 @@ l l l l l l l l l l l l l l l l +l l l l +l l l l l l l l. T{ auto\-negotiate @@ -2710,6 +2722,24 @@ T}:T{ T}:T{ If non\-zero, request that the device use only the specified speed\&. In Mbit/s, ie 100 == 100Mbit/s\&. T} +T{ +wake\-on\-lan +T}:T{ +uint32 +T}:T{ +1 +T}:T{ +The NMSettingWiredWakeOnLan options to enable\&. Not all devices support all options\&. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40)\&. +T} +T{ +wake\-on\-lan\-password +T}:T{ +string +T}:T{ +\ \& +T}:T{ +If specified, the password used with magic\-packet\-based Wake\-on\-LAN, represented as an Ethernet MAC address\&. If NULL, no password will be required\&. +T} .TE .sp 1 .sp diff --git a/man/nm-settings.xml b/man/nm-settings.xml index d289d2d3e..ae274a0d4 100644 --- a/man/nm-settings.xml +++ b/man/nm-settings.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> -<refentry id="nm-settings"><refentryinfo><date>14 July 2015</date></refentryinfo><refmeta><refentrytitle>nm-settings</refentrytitle><manvolnum>5</manvolnum><refmiscinfo class="source">NetworkManager</refmiscinfo><refmiscinfo class="manual">Configuration</refmiscinfo><refmiscinfo class="version">1.0.4</refmiscinfo></refmeta><refnamediv><refname>nm-settings</refname><refpurpose>Description of settings and properties of NetworkManager connection profiles</refpurpose></refnamediv><refsect1><title>DESCRIPTION</title><para> +<refentry id="nm-settings"><refentryinfo><date>27 August 2015</date></refentryinfo><refmeta><refentrytitle>nm-settings</refentrytitle><manvolnum>5</manvolnum><refmiscinfo class="source">NetworkManager</refmiscinfo><refmiscinfo class="manual">Configuration</refmiscinfo><refmiscinfo class="version">1.0.6</refmiscinfo></refmeta><refnamediv><refname>nm-settings</refname><refpurpose>Description of settings and properties of NetworkManager connection profiles</refpurpose></refnamediv><refsect1><title>DESCRIPTION</title><para> NetworkManager is based on a concept of connection profiles, sometimes referred to as connections only. These connection profiles contain a network configuration. When NetworkManager activates a connection profile on a network device the configuration will @@ -120,6 +120,7 @@ <row><entry align="left">id</entry><entry align="left">string</entry><entry align="left"/><entry>A human readable unique identifier for the connection, like "Work Wi-Fi" or "T-Mobile 3G".</entry></row> <row><entry align="left">interface-name</entry><entry align="left">string</entry><entry align="left"/><entry>The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface.</entry></row> <row><entry align="left">master</entry><entry align="left">string</entry><entry align="left"/><entry>Interface name of the master device or UUID of the master connection.</entry></row> + <row><entry align="left">metered</entry><entry align="left">NMMetered (int32)</entry><entry align="left"/><entry>Whether the connection is metered.</entry></row> <row><entry align="left">name</entry><entry align="left">string</entry><entry align="left">connection</entry><entry>The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example "ppp" or "wireless" or "wired".</entry></row> <row><entry align="left">permissions</entry><entry align="left">array of string</entry><entry align="left">[]</entry><entry>An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection. Otherwise a user is allowed to access this connection if and only if they are in this list. Each entry is of the form "[type]:[id]:[reserved]"; for example, "user:dcbw:blah". At this time only the "user" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the ":" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8.</entry></row> <row><entry align="left">read-only</entry><entry align="left">boolean</entry><entry align="left">FALSE</entry><entry>FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified.</entry></row> @@ -295,6 +296,8 @@ <row><entry align="left">s390-options</entry><entry align="left">dict of string to string</entry><entry align="left">{}</entry><entry>Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include "portno", "layer2", "portname", "protocol", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]).</entry></row> <row><entry align="left">s390-subchannels</entry><entry align="left">array of string</entry><entry align="left">[]</entry><entry>Identifies specific subchannels that this network device uses for communication with z/VM or s390 host. Like the "mac-address" property for non-z/VM devices, this property can be used to ensure this connection only applies to the network device that uses these subchannels. The list should contain exactly 3 strings, and each string may only be composed of hexadecimal characters and the period (.) character.</entry></row> <row><entry align="left">speed</entry><entry align="left">uint32</entry><entry align="left">0</entry><entry>If non-zero, request that the device use only the specified speed. In Mbit/s, ie 100 == 100Mbit/s.</entry></row> + <row><entry align="left">wake-on-lan</entry><entry align="left">uint32</entry><entry align="left">1</entry><entry>The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40).</entry></row> + <row><entry align="left">wake-on-lan-password</entry><entry align="left">string</entry><entry align="left"/><entry>If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required.</entry></row> </tbody></tgroup></table> <table><title>802-11-wireless setting</title><tgroup cols="4"><thead><row><entry>Key Name</entry><entry>Value Type</entry><entry>Default Value</entry><entry>Value Description</entry></row></thead><tbody> <row><entry align="left">band</entry><entry align="left">string</entry><entry align="left"/><entry>802.11 frequency band of the network. One of "a" for 5GHz 802.11a or "bg" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network to the specific band, i.e. if "a" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible. This setting depends on specific driver capability and may not work with all drivers.</entry></row> diff --git a/man/nmcli.1.in b/man/nmcli.1.in index 335b65117..6df844de9 100644 --- a/man/nmcli.1.in +++ b/man/nmcli.1.in @@ -21,7 +21,7 @@ .\" .\" Copyright 2010 - 2014 Red Hat, Inc. .\" -.TH NMCLI "1" "3 December 2014" +.TH NMCLI "1" "12 August 2015" .SH NAME nmcli \- command\(hyline tool for controlling NetworkManager @@ -756,7 +756,8 @@ List available Wi\(hyFi access points. The \fIifname\fP and \fIbssid\fP options can be used to list APs for a particular interface or with a specific BSSID, respectively. .TP -.B wifi connect <(B)SSID> [password <password>] [wep\-key\-type key|phrase] [ifname <ifname>] [bssid <BSSID>] [name <name>] [private yes|no] +.B wifi connect <(B)SSID> [password <password>] [wep\-key\-type key|phrase] [ifname <ifname>] [bssid <BSSID>] [name <name>] +.B [private yes|no] [hidden yes|no] .br Connect to a Wi\(hyFi network specified by SSID or BSSID. The command creates a new connection and then activates it on a device. This is a command\(hyline counterpart @@ -784,13 +785,20 @@ Available options are: .IP \fIprivate\fP 13 \(en if set to \fByes\fP, the connection will only be visible to the user who created it. Otherwise the connection is system\(hywide, which is the default. +.IP \fIhidden\fP 13 +\(en set to \fByes\fP when connecting for the first time to an AP not broadcasting its SSID. +Otherwise the SSID would not be found and the connection attempt would fail. .RE .TP -.B wifi rescan [[ifname] <ifname>] +.B wifi rescan [ifname <ifname>] [[ssid <SSID>] ...] .br Request that \fINetworkManager\fP immediately re-scan for available access points. NetworkManager scans Wi\(hyFi networks periodically, but in some cases it can be -useful to start scanning manually (e.g. after resuming the computer). +useful to start scanning manually (e.g. after resuming the computer). By using +\fIssid\fP, it is possible to scan for a specific SSID, which is useful for APs +with hidden SSIDs. You can provide multiple \fIssid\fP parameters in order to +scan more SSIDs. +.br This command does not show the APs, use 'nmcli device wifi list' for that. .TP .B wimax [list [ifname <ifname>] [nsp <name>]] diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 4f8424944..63741dc3d 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -2169,15 +2169,15 @@ nm_utils_cmp_connection_by_autoconnect_priority (NMConnection **a, NMConnection /**************************************************************************/ static gint64 monotonic_timestamp_offset_sec; +static int monotonic_timestamp_clock_mode = 0; static void monotonic_timestamp_get (struct timespec *tp) { - static int clock_mode = 0; - gboolean first_time = FALSE; + int clock_mode = 0; int err = 0; - switch (clock_mode) { + switch (monotonic_timestamp_clock_mode) { case 0: /* the clock is not yet initialized (first run) */ err = clock_gettime (CLOCK_BOOTTIME, tp); @@ -2186,7 +2186,6 @@ monotonic_timestamp_get (struct timespec *tp) err = clock_gettime (CLOCK_MONOTONIC, tp); } else clock_mode = 1; - first_time = TRUE; break; case 1: /* default, return CLOCK_BOOTTIME */ @@ -2202,7 +2201,7 @@ monotonic_timestamp_get (struct timespec *tp) g_assert (err == 0); (void)err; g_assert (tp->tv_nsec >= 0 && tp->tv_nsec < NM_UTILS_NS_PER_SECOND); - if (G_LIKELY (!first_time)) + if (G_LIKELY (clock_mode == 0)) return; /* Calculate an offset for the time stamp. @@ -2219,6 +2218,7 @@ monotonic_timestamp_get (struct timespec *tp) * wraps (~68 years). **/ monotonic_timestamp_offset_sec = (- ((gint64) tp->tv_sec)) + 1; + monotonic_timestamp_clock_mode = clock_mode; if (nm_logging_enabled (LOGL_DEBUG, LOGD_CORE)) { time_t now = time (NULL); @@ -2532,11 +2532,15 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base, if (print_header) { GError *err_verify = NULL; + const char *path = nm_connection_get_path (connection); - if (diff_base) - nm_log (level, domain, "%sconnection '%s' (%p/%s < %p/%s):", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base)); - else - nm_log (level, domain, "%sconnection '%s' (%p/%s):", prefix, name, connection, G_OBJECT_TYPE_NAME (connection)); + if (diff_base) { + nm_log (level, domain, "%sconnection '%s' (%p/%s < %p/%s)%s%s%s:", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base), + NM_PRINT_FMT_QUOTED (path, " [", path, "]", "")); + } else { + nm_log (level, domain, "%sconnection '%s' (%p/%s):%s%s%s", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), + NM_PRINT_FMT_QUOTED (path, " [", path, "]", "")); + } print_header = FALSE; if (!nm_connection_verify (connection, &err_verify)) { @@ -2583,6 +2587,49 @@ out: g_array_free (sorted_hashes, TRUE); } +/** + * nm_utils_monotonic_timestamp_as_boottime: + * @timestamp: the monotonic-timestamp that should be converted into CLOCK_BOOTTIME. + * @timestamp_ns_per_tick: How many nano seconds make one unit of @timestamp? E.g. if + * @timestamp is in unit seconds, pass %NM_UTILS_NS_PER_SECOND; @timestamp in nano + * seconds, pass 1; @timestamp in milli seconds, pass %NM_UTILS_NS_PER_SECOND/1000; etc. + * + * Returns: the monotonic-timestamp as CLOCK_BOOTTIME, as returned by clock_gettime(). + * The unit is the same as the passed in @timestamp basd on @timestamp_ns_per_tick. + * E.g. if you passed @timestamp in as seconds, it will return boottime in seconds. + * If @timestamp is a non-positive, it returns -1. Note that a (valid) monotonic-timestamp + * is always positive. + * + * On older kernels that don't support CLOCK_BOOTTIME, the returned time is instead CLOCK_MONOTONIC. + **/ +gint64 +nm_utils_monotonic_timestamp_as_boottime (gint64 timestamp, gint64 timestamp_ns_per_tick) +{ + gint64 offset; + + /* only support ns-per-tick being a multiple of 10. */ + g_return_val_if_fail (timestamp_ns_per_tick == 1 + || (timestamp_ns_per_tick > 0 && + timestamp_ns_per_tick <= NM_UTILS_NS_PER_SECOND && + timestamp_ns_per_tick % 10 == 0), + -1); + + /* Check that the timestamp is in a valid range. */ + g_return_val_if_fail (timestamp >= 0, -1); + + /* if the caller didn't yet ever fetch a monotonic-timestamp, he cannot pass any meaningful + * value (because he has no idea what these timestamps would be). That would be a bug. */ + g_return_val_if_fail (monotonic_timestamp_clock_mode != 0, -1); + + /* calculate the offset of monotonic-timestamp to boottime. offset_s is <= 1. */ + offset = monotonic_timestamp_offset_sec * (NM_UTILS_NS_PER_SECOND / timestamp_ns_per_tick); + + /* check for overflow. */ + g_return_val_if_fail (offset > 0 || timestamp < G_MAXINT64 + offset, G_MAXINT64); + + return timestamp - offset; +} + #define IPV6_PROPERTY_DIR "/proc/sys/net/ipv6/conf/" #define IPV4_PROPERTY_DIR "/proc/sys/net/ipv4/conf/" @@ -2638,28 +2685,35 @@ nm_utils_ip4_property_path (const char *ifname, const char *property) return _get_property_path (ifname, property, FALSE); } -const char * -ASSERT_VALID_PATH_COMPONENT (const char *name) +gboolean +nm_utils_is_valid_path_component (const char *name) { const char *n; if (name == NULL || name[0] == '\0') - goto fail; + return FALSE; if (name[0] == '.') { if (name[1] == '\0') - goto fail; + return FALSE; if (name[1] == '.' && name[2] == '\0') - goto fail; + return FALSE; } n = name; do { if (*n == '/') - goto fail; + return FALSE; } while (*(++n) != '\0'); - return name; -fail: + return TRUE; +} + +const char * +ASSERT_VALID_PATH_COMPONENT (const char *name) +{ + if (G_LIKELY (nm_utils_is_valid_path_component (name))) + return name; + nm_log_err (LOGD_CORE, "Failed asserting path component: %s%s%s", NM_PRINT_FMT_QUOTED (name, "\"", name, "\"", "(null)")); g_error ("FATAL: Failed asserting path component: %s%s%s", diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h index 1864547f5..70f62d47e 100644 --- a/src/NetworkManagerUtils.h +++ b/src/NetworkManagerUtils.h @@ -161,7 +161,9 @@ gint64 nm_utils_get_monotonic_timestamp_ns (void); gint64 nm_utils_get_monotonic_timestamp_us (void); gint64 nm_utils_get_monotonic_timestamp_ms (void); gint32 nm_utils_get_monotonic_timestamp_s (void); +gint64 nm_utils_monotonic_timestamp_as_boottime (gint64 timestamp, gint64 timestamp_ticks_per_ns); +gboolean nm_utils_is_valid_path_component (const char *name); const char *ASSERT_VALID_PATH_COMPONENT (const char *name); const char *nm_utils_ip6_property_path (const char *ifname, const char *property); const char *nm_utils_ip4_property_path (const char *ifname, const char *property); diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index af2cb8f26..beb86e11e 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -53,6 +53,7 @@ #include "nm-device-factory.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" +#include "gsystem-local-alloc.h" #include "nm-device-ethernet-glue.h" @@ -66,6 +67,7 @@ G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) #define WIRED_SECRETS_TRIES "wired-secrets-tries" #define PPPOE_RECONNECT_DELAY 7 +#define PPPOE_ENCAP_OVERHEAD 8 /* 2 bytes for PPP, 6 for PPPoE */ static NMSetting *device_get_setting (NMDevice *device, GType setting_type); @@ -1174,6 +1176,40 @@ dcb_carrier_changed (NMDevice *device, GParamSpec *pspec, gpointer unused) /****************************************************************/ +static gboolean +wake_on_lan_enable (NMDevice *device) +{ + NMSettingWiredWakeOnLan wol; + NMSettingWired *s_wired; + const char *password = NULL; + gs_free char *value = NULL; + + s_wired = (NMSettingWired *) device_get_setting (device, NM_TYPE_SETTING_WIRED); + if (s_wired) { + wol = nm_setting_wired_get_wake_on_lan (s_wired); + password = nm_setting_wired_get_wake_on_lan_password (s_wired); + if (wol != NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) + goto found; + } + + value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, + "ethernet.wake-on-lan", + device); + if (value) { + wol = _nm_utils_ascii_str_to_int64 (value, 10, + NM_SETTING_WIRED_WAKE_ON_LAN_NONE, + NM_SETTING_WIRED_WAKE_ON_LAN_ALL, + NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT); + if (wol != NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) + goto found; + } + wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; +found: + return nmp_utils_ethtool_set_wake_on_lan (nm_device_get_iface (device), wol, password); +} + +/****************************************************************/ + static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { @@ -1206,6 +1242,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) } } + wake_on_lan_enable (device); + /* DCB and FCoE setup */ s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB); if (s_dcb) { @@ -1231,6 +1269,28 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) ret = NM_ACT_STAGE_RETURN_POSTPONE; } + /* PPPoE setup */ + if (nm_connection_is_type (nm_device_get_connection (device), + NM_SETTING_PPPOE_SETTING_NAME)) { + NMSettingPpp *s_ppp; + + s_ppp = (NMSettingPpp *) device_get_setting (device, NM_TYPE_SETTING_PPP); + if (s_ppp) { + guint32 mtu = 0, mru = 0, mxu; + + mtu = nm_setting_ppp_get_mtu (s_ppp); + mru = nm_setting_ppp_get_mru (s_ppp); + mxu = mru > mtu ? mru : mtu; + if (mxu) { + _LOGD (LOGD_PPP, "set MTU to %u (PPP interface MRU %u, MTU %u)", + mxu + PPPOE_ENCAP_OVERHEAD, mru, mtu); + nm_platform_link_set_mtu (NM_PLATFORM_GET, + nm_device_get_ifindex (device), + mxu + PPPOE_ENCAP_OVERHEAD); + } + } + } + return ret; } diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 2e2483c0c..2d519f611 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -313,7 +313,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, NM_DEVICE_PLATFORM_DEVICE, plink, NM_DEVICE_TYPE_DESC, "InfiniBand", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND, - NM_DEVICE_INFINIBAND_IS_PARTITION, (plink->parent > 0), + NM_DEVICE_INFINIBAND_IS_PARTITION, (plink->parent > 0 || plink->parent == NM_PLATFORM_LINK_OTHER_NETNS), NULL); } diff --git a/src/devices/nm-device-logging.h b/src/devices/nm-device-logging.h index acca32e55..f3b76ee8f 100644 --- a/src/devices/nm-device-logging.h +++ b/src/devices/nm-device-logging.h @@ -31,16 +31,12 @@ _nm_device_log_self_to_device (t *self) \ return (NMDevice *) self; \ } -#define _LOG(level, domain, ...) \ +#undef _NMLOG_ENABLED +#define _NMLOG_ENABLED(level, domain) ( nm_logging_enabled ((level), (domain)) ) +#define _NMLOG(level, domain, ...) \ nm_log_obj ((level), (domain), (self), \ "(%s): " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ (self) ? str_if_set (nm_device_get_iface (_nm_device_log_self_to_device (self)), "(null)") : "(none)" \ _NM_UTILS_MACRO_REST(__VA_ARGS__)) -#define _LOGT(domain, ...) _LOG (LOGL_TRACE, domain, __VA_ARGS__) -#define _LOGD(domain, ...) _LOG (LOGL_DEBUG, domain, __VA_ARGS__) -#define _LOGI(domain, ...) _LOG (LOGL_INFO, domain, __VA_ARGS__) -#define _LOGW(domain, ...) _LOG (LOGL_WARN, domain, __VA_ARGS__) -#define _LOGE(domain, ...) _LOG (LOGL_ERR, domain, __VA_ARGS__) - #endif /* __NETWORKMANAGER_DEVICE_LOGGING_H__ */ diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 0bfe3fe9f..2a815cfdd 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -114,7 +114,10 @@ get_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_PARENT: - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex); + if (priv->props.parent_ifindex > 0) + parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex); + else + parent = NULL; g_value_set_boxed (value, parent ? nm_device_get_path (parent) : "/"); break; case PROP_MODE: diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 158e7de5b..e523e6bb6 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -181,7 +181,8 @@ component_added (NMDevice *device, GObject *component) return FALSE; } - if (nm_device_get_ifindex (added_device) != parent_ifindex) + if ( parent_ifindex <= 0 + || nm_device_get_ifindex (added_device) != parent_ifindex) return FALSE; nm_device_vlan_set_parent (self, added_device, FALSE); @@ -356,23 +357,28 @@ update_connection (NMDevice *device, NMConnection *connection) if (vlan_id != nm_setting_vlan_get_id (s_vlan)) g_object_set (s_vlan, NM_SETTING_VLAN_ID, priv->vlan_id, NULL); - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex); - g_assert (parent); + if (parent_ifindex != NM_PLATFORM_LINK_OTHER_NETNS) + parent = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex); + else + parent = NULL; nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent, FALSE); /* Update parent in the connection; default to parent's interface name */ - new_parent = nm_device_get_iface (parent); - setting_parent = nm_setting_vlan_get_parent (s_vlan); - if (setting_parent && nm_utils_is_uuid (setting_parent)) { - NMConnection *parent_connection; - - /* Don't change a parent specified by UUID if it's still valid */ - parent_connection = nm_connection_provider_get_connection_by_uuid (nm_connection_provider_get (), setting_parent); - if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection)) - new_parent = NULL; - } - if (new_parent) - g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, new_parent, NULL); + if (parent) { + new_parent = nm_device_get_iface (parent); + setting_parent = nm_setting_vlan_get_parent (s_vlan); + if (setting_parent && nm_utils_is_uuid (setting_parent)) { + NMConnection *parent_connection; + + /* Don't change a parent specified by UUID if it's still valid */ + parent_connection = nm_connection_provider_get_connection_by_uuid (nm_connection_provider_get (), setting_parent); + if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection)) + new_parent = NULL; + } + if (new_parent) + g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, new_parent, NULL); + } else + g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, NULL, NULL); } static NMActStageReturn @@ -628,7 +634,10 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, "VLAN parent ifindex unknown"); return NULL; } - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex); + if (parent_ifindex > 0) + parent = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex); + else + parent = NULL; device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN, NM_DEVICE_PLATFORM_DEVICE, plink, diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c5d4c2039..58895821d 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -75,6 +75,10 @@ _LOG_DECLARE_SELF (NMDevice); static void impl_device_disconnect (NMDevice *self, DBusGMethodInvocation *context); static void impl_device_delete (NMDevice *self, DBusGMethodInvocation *context); static void ip_check_ping_watch_cb (GPid pid, gint status, gpointer user_data); +static gboolean ip_config_valid (NMDeviceState state); +static void nm_device_update_metered (NMDevice *self); +static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection, NMDeviceStateReason *reason); +static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason); #include "nm-device-glue.h" @@ -128,6 +132,7 @@ enum { PROP_MASTER, PROP_HW_ADDRESS, PROP_HAS_PENDING_ACTION, + PROP_METERED, LAST_PROP }; @@ -269,18 +274,20 @@ typedef struct { struct { gboolean v4_has; gboolean v4_is_assumed; - gboolean v4_configure_first_time; NMPlatformIP4Route v4; gboolean v6_has; gboolean v6_is_assumed; - gboolean v6_configure_first_time; NMPlatformIP6Route v6; } default_route; + gboolean v4_commit_first_time; + gboolean v6_commit_first_time; + /* DHCPv4 tracking */ NMDhcpClient * dhcp4_client; gulong dhcp4_state_sigid; NMDhcp4Config * dhcp4_config; + guint dhcp4_restart_id; NMIP4Config * vpn4_config; /* routes added by a VPN which uses this device */ guint arp_round2_id; @@ -325,6 +332,9 @@ typedef struct { NMDhcp6Config * dhcp6_config; /* IP6 config from DHCP */ NMIP6Config * dhcp6_ip6_config; + /* Event ID of the current IP6 config from DHCP */ + char * dhcp6_event_id; + guint dhcp6_restart_id; /* allow autoconnect feature */ gboolean autoconnect; @@ -338,6 +348,8 @@ typedef struct { gboolean is_master; GSList * slaves; /* list of SlaveInfo */ + NMMetered metered; + NMConnectionProvider *con_provider; } NMDevicePrivate; @@ -687,6 +699,21 @@ nm_device_get_device_type (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->type; } +/** + * nm_device_get_metered: + * @setting: the #NMDevice + * + * Returns: the #NMDevice:metered property of the device. + * + * Since: 1.0.6 + **/ +NMMetered +nm_device_get_metered (NMDevice *self) +{ + g_return_val_if_fail (NM_IS_DEVICE (self), NM_METERED_UNKNOWN); + + return NM_DEVICE_GET_PRIVATE (self)->metered; +} /** * nm_device_get_priority(): @@ -735,14 +762,14 @@ nm_device_get_priority (NMDevice *self) return 400; case NM_DEVICE_TYPE_BRIDGE: return 425; - case NM_DEVICE_TYPE_MODEM: - return 450; - case NM_DEVICE_TYPE_BT: - return 550; case NM_DEVICE_TYPE_WIFI: return 600; case NM_DEVICE_TYPE_OLPC_MESH: return 650; + case NM_DEVICE_TYPE_MODEM: + return 700; + case NM_DEVICE_TYPE_BT: + return 750; case NM_DEVICE_TYPE_GENERIC: return 950; case NM_DEVICE_TYPE_UNKNOWN: @@ -3181,6 +3208,8 @@ dhcp4_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + nm_clear_g_source (&priv->dhcp4_restart_id); + if (priv->dhcp4_client) { /* Stop any ongoing DHCP transaction on this device */ if (priv->dhcp4_state_sigid) { @@ -3218,6 +3247,8 @@ ip4_config_merge_and_apply (NMDevice *self, guint32 gateway; gboolean connection_has_default_route, connection_is_never_default; gboolean routes_full_sync; + gboolean ignore_auto_routes = FALSE; + gboolean ignore_auto_dns = FALSE; /* Merge all the configs into the composite config */ if (config) { @@ -3225,44 +3256,45 @@ ip4_config_merge_and_apply (NMDevice *self, priv->dev_ip4_config = g_object_ref (config); } + /* Apply ignore-auto-routes and ignore-auto-dns settings */ + connection = nm_device_get_connection (self); + if (connection) { + NMSettingIPConfig *s_ip4 = nm_connection_get_setting_ip4_config (connection); + + if (s_ip4) { + ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip4); + ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip4); + } + } + composite = nm_ip4_config_new (); if (commit) ensure_con_ip4_config (self); - if (priv->dev_ip4_config) - nm_ip4_config_merge (composite, priv->dev_ip4_config); + if (priv->dev_ip4_config) { + nm_ip4_config_merge (composite, priv->dev_ip4_config, + (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) + | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0)); + } if (priv->vpn4_config) - nm_ip4_config_merge (composite, priv->vpn4_config); + nm_ip4_config_merge (composite, priv->vpn4_config, NM_IP_CONFIG_MERGE_DEFAULT); if (priv->ext_ip4_config) - nm_ip4_config_merge (composite, priv->ext_ip4_config); + nm_ip4_config_merge (composite, priv->ext_ip4_config, NM_IP_CONFIG_MERGE_DEFAULT); /* Merge WWAN config *last* to ensure modem-given settings overwrite * any external stuff set by pppd or other scripts. */ - if (priv->wwan_ip4_config) - nm_ip4_config_merge (composite, priv->wwan_ip4_config); - - /* Apply ignore-auto-routes and ignore-auto-dns settings */ - connection = nm_device_get_connection (self); - if (connection) { - NMSettingIPConfig *s_ip4 = nm_connection_get_setting_ip4_config (connection); - - if (s_ip4) { - if (nm_setting_ip_config_get_ignore_auto_routes (s_ip4)) - nm_ip4_config_reset_routes (composite); - if (nm_setting_ip_config_get_ignore_auto_dns (s_ip4)) { - nm_ip4_config_reset_nameservers (composite); - nm_ip4_config_reset_domains (composite); - nm_ip4_config_reset_searches (composite); - } - } + if (priv->wwan_ip4_config) { + nm_ip4_config_merge (composite, priv->wwan_ip4_config, + (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) + | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0)); } /* Merge user overrides into the composite config. For assumed connections, * con_ip4_config is empty. */ if (priv->con_ip4_config) - nm_ip4_config_merge (composite, priv->con_ip4_config); + nm_ip4_config_merge (composite, priv->con_ip4_config, NM_IP_CONFIG_MERGE_DEFAULT); /* Add the default route. @@ -3282,21 +3314,26 @@ ip4_config_merge_and_apply (NMDevice *self, priv->default_route.v4_has = FALSE; priv->default_route.v4_is_assumed = TRUE; - routes_full_sync = commit - && priv->default_route.v4_configure_first_time - && !nm_device_uses_assumed_connection (self); - if (!commit) { /* during a non-commit event, we always pickup whatever is configured. */ goto END_ADD_DEFAULT_ROUTE; } + if (nm_device_uses_generated_assumed_connection (self)) { + /* a generate-assumed-connection always detects the default route from platform */ + goto END_ADD_DEFAULT_ROUTE; + } + + /* At this point, we treat assumed and non-assumed connections alike. + * For assumed connections we do that because we still manage RA and DHCP + * leases for them, so we must extend/update the default route on commits. + */ + connection_has_default_route = nm_default_route_manager_ip4_connection_has_default_route (nm_default_route_manager_get (), connection, &connection_is_never_default); - if ( !priv->default_route.v4_configure_first_time - && !nm_device_uses_assumed_connection (self) + if ( !priv->v4_commit_first_time && connection_is_never_default) { /* If the connection is explicitly configured as never-default, we enforce the (absense of the) * default-route only once. That allows the user to configure a connection as never-default, @@ -3304,14 +3341,8 @@ ip4_config_merge_and_apply (NMDevice *self, goto END_ADD_DEFAULT_ROUTE; } - /* At this point, we treat assumed and non-assumed connections alike. - * For assumed connections we do that because we still manage RA and DHCP - * leases for them, so we must extend/update the default route on commits. - */ - /* we are about to commit (for a non-assumed connection). Enforce whatever we have * configured. */ - priv->default_route.v4_configure_first_time = FALSE; priv->default_route.v4_is_assumed = FALSE; if (!connection_has_default_route) @@ -3323,7 +3354,7 @@ ip4_config_merge_and_apply (NMDevice *self, } gateway = nm_ip4_config_get_gateway (composite); - if ( !gateway + if ( !nm_ip4_config_has_gateway (composite) && nm_device_get_device_type (self) != NM_DEVICE_TYPE_MODEM) goto END_ADD_DEFAULT_ROUTE; @@ -3365,8 +3396,15 @@ END_ADD_DEFAULT_ROUTE: NM_DEVICE_GET_CLASS (self)->ip4_config_pre_commit (self, composite); } + routes_full_sync = commit + && priv->v4_commit_first_time + && !nm_device_uses_assumed_connection (self); + success = nm_device_set_ip4_config (self, composite, default_route_metric, commit, routes_full_sync, out_reason); g_object_unref (composite); + + if (commit) + priv->v4_commit_first_time = FALSE; return success; } @@ -3391,12 +3429,44 @@ dhcp4_lease_change (NMDevice *self, NMIP4Config *config) } } +static gboolean +dhcp4_restart_cb (gpointer user_data) +{ + NMDevice *self = user_data; + NMDevicePrivate *priv; + NMDeviceStateReason reason; + NMConnection *connection; + + g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + + priv = NM_DEVICE_GET_PRIVATE (self); + priv->dhcp4_restart_id = 0; + connection = nm_device_get_connection (self); + + if (dhcp4_start (self, connection, &reason) == NM_ACT_STAGE_RETURN_FAILURE) + priv->dhcp4_restart_id = g_timeout_add_seconds (120, dhcp4_restart_cb, self); + + return FALSE; +} + static void dhcp4_fail (NMDevice *self, gboolean timeout) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE); + + /* Don't fail if there are static addresses configured on + * the device, instead retry after some time. + */ + if ( priv->ip4_state == IP_DONE + && priv->con_ip4_config + && nm_ip4_config_get_num_addresses (priv->con_ip4_config) > 0) { + _LOGI (LOGD_DHCP4, "Scheduling DHCPv4 restart because device has IP addresses"); + priv->dhcp4_restart_id = g_timeout_add_seconds (120, dhcp4_restart_cb, self); + return; + } + if (timeout || (priv->ip4_state == IP_CONF)) nm_device_activate_schedule_ip4_config_timeout (self); else if (priv->ip4_state == IP_DONE) @@ -3426,6 +3496,7 @@ dhcp4_state_changed (NMDhcpClient *client, NMDhcpState state, NMIP4Config *ip4_config, GHashTable *options, + const char *event_id, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); @@ -3450,8 +3521,10 @@ dhcp4_state_changed (NMDhcpClient *client, if (priv->ip4_state == IP_CONF) nm_device_activate_schedule_ip4_config_result (self, ip4_config); - else if (priv->ip4_state == IP_DONE) + else if (priv->ip4_state == IP_DONE) { dhcp4_lease_change (self, ip4_config); + nm_device_update_metered (self); + } break; case NM_DHCP_STATE_TIMEOUT: dhcp4_fail (self, TRUE); @@ -3802,6 +3875,9 @@ dhcp6_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release) priv->dhcp6_mode = NM_RDISC_DHCP_LEVEL_NONE; g_clear_object (&priv->dhcp6_ip6_config); + g_clear_pointer (&priv->dhcp6_event_id, g_free); + + nm_clear_g_source (&priv->dhcp6_restart_id); if (priv->dhcp6_client) { if (priv->dhcp6_state_sigid) { @@ -3837,6 +3913,19 @@ ip6_config_merge_and_apply (NMDevice *self, const struct in6_addr *gateway; gboolean connection_has_default_route, connection_is_never_default; gboolean routes_full_sync; + gboolean ignore_auto_routes = FALSE; + gboolean ignore_auto_dns = FALSE; + + /* Apply ignore-auto-routes and ignore-auto-dns settings */ + connection = nm_device_get_connection (self); + if (connection) { + NMSettingIPConfig *s_ip6 = nm_connection_get_setting_ip6_config (connection); + + if (s_ip6) { + ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip6); + ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip6); + } + } /* If no config was passed in, create a new one */ composite = nm_ip6_config_new (); @@ -3845,41 +3934,34 @@ ip6_config_merge_and_apply (NMDevice *self, ensure_con_ip6_config (self); /* Merge all the IP configs into the composite config */ - if (priv->ac_ip6_config) - nm_ip6_config_merge (composite, priv->ac_ip6_config); - if (priv->dhcp6_ip6_config) - nm_ip6_config_merge (composite, priv->dhcp6_ip6_config); + if (priv->ac_ip6_config) { + nm_ip6_config_merge (composite, priv->ac_ip6_config, + (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) + | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0)); + } + if (priv->dhcp6_ip6_config) { + nm_ip6_config_merge (composite, priv->dhcp6_ip6_config, + (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) + | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0)); + } if (priv->vpn6_config) - nm_ip6_config_merge (composite, priv->vpn6_config); + nm_ip6_config_merge (composite, priv->vpn6_config, NM_IP_CONFIG_MERGE_DEFAULT); if (priv->ext_ip6_config) - nm_ip6_config_merge (composite, priv->ext_ip6_config); + nm_ip6_config_merge (composite, priv->ext_ip6_config, NM_IP_CONFIG_MERGE_DEFAULT); /* Merge WWAN config *last* to ensure modem-given settings overwrite * any external stuff set by pppd or other scripts. */ - if (priv->wwan_ip6_config) - nm_ip6_config_merge (composite, priv->wwan_ip6_config); - - /* Apply ignore-auto-routes and ignore-auto-dns settings */ - connection = nm_device_get_connection (self); - if (connection) { - NMSettingIPConfig *s_ip6 = nm_connection_get_setting_ip6_config (connection); - - if (s_ip6) { - if (nm_setting_ip_config_get_ignore_auto_routes (s_ip6)) - nm_ip6_config_reset_routes (composite); - if (nm_setting_ip_config_get_ignore_auto_dns (s_ip6)) { - nm_ip6_config_reset_nameservers (composite); - nm_ip6_config_reset_domains (composite); - nm_ip6_config_reset_searches (composite); - } - } + if (priv->wwan_ip6_config) { + nm_ip6_config_merge (composite, priv->wwan_ip6_config, + (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) + | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0)); } /* Merge user overrides into the composite config. For assumed connections, * con_ip6_config is empty. */ if (priv->con_ip6_config) - nm_ip6_config_merge (composite, priv->con_ip6_config); + nm_ip6_config_merge (composite, priv->con_ip6_config, NM_IP_CONFIG_MERGE_DEFAULT); /* Add the default route. * @@ -3898,21 +3980,26 @@ ip6_config_merge_and_apply (NMDevice *self, priv->default_route.v6_has = FALSE; priv->default_route.v6_is_assumed = TRUE; - routes_full_sync = commit - && priv->default_route.v6_configure_first_time - && !nm_device_uses_assumed_connection (self); - if (!commit) { /* during a non-commit event, we always pickup whatever is configured. */ goto END_ADD_DEFAULT_ROUTE; } + if (nm_device_uses_generated_assumed_connection (self)) { + /* a generate-assumed-connection always detects the default route from platform */ + goto END_ADD_DEFAULT_ROUTE; + } + + /* At this point, we treat assumed and non-assumed connections alike. + * For assumed connections we do that because we still manage RA and DHCP + * leases for them, so we must extend/update the default route on commits. + */ + connection_has_default_route = nm_default_route_manager_ip6_connection_has_default_route (nm_default_route_manager_get (), connection, &connection_is_never_default); - if ( !priv->default_route.v6_configure_first_time - && !nm_device_uses_assumed_connection (self) + if ( !priv->v6_commit_first_time && connection_is_never_default) { /* If the connection is explicitly configured as never-default, we enforce the (absence of the) * default-route only once. That allows the user to configure a connection as never-default, @@ -3920,14 +4007,8 @@ ip6_config_merge_and_apply (NMDevice *self, goto END_ADD_DEFAULT_ROUTE; } - /* At this point, we treat assumed and non-assumed connections alike. - * For assumed connections we do that because we still manage RA and DHCP - * leases for them, so we must extend/update the default route on commits. - */ - /* we are about to commit (for a non-assumed connection). Enforce whatever we have * configured. */ - priv->default_route.v6_configure_first_time = FALSE; priv->default_route.v6_is_assumed = FALSE; if (!connection_has_default_route) @@ -3984,8 +4065,14 @@ END_ADD_DEFAULT_ROUTE: NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit (self, composite); } + routes_full_sync = commit + && priv->v6_commit_first_time + && !nm_device_uses_assumed_connection (self); + success = nm_device_set_ip6_config (self, composite, commit, routes_full_sync, out_reason); g_object_unref (composite); + if (commit) + priv->v6_commit_first_time = FALSE; return success; } @@ -4017,6 +4104,24 @@ dhcp6_lease_change (NMDevice *self) } } +static gboolean +dhcp6_restart_cb (gpointer user_data) +{ + NMDevice *self = user_data; + NMDevicePrivate *priv; + NMDeviceStateReason reason; + + g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + + priv = NM_DEVICE_GET_PRIVATE (self); + priv->dhcp6_restart_id = 0; + + if (!dhcp6_start (self, FALSE, &reason)) + priv->dhcp6_restart_id = g_timeout_add_seconds (120, dhcp6_restart_cb, self); + + return FALSE; +} + static void dhcp6_fail (NMDevice *self, gboolean timeout) { @@ -4025,6 +4130,17 @@ dhcp6_fail (NMDevice *self, gboolean timeout) dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE); if (priv->dhcp6_mode == NM_RDISC_DHCP_LEVEL_MANAGED) { + /* Don't fail if there are static addresses configured on + * the device, instead retry after some time. + */ + if ( priv->ip6_state == IP_DONE + && priv->con_ip6_config + && nm_ip6_config_get_num_addresses (priv->con_ip6_config)) { + _LOGI (LOGD_DHCP6, "Scheduling DHCPv6 restart because device has IP addresses"); + priv->dhcp6_restart_id = g_timeout_add_seconds (120, dhcp6_restart_cb, self); + return; + } + if (timeout || (priv->ip6_state == IP_CONF)) nm_device_activate_schedule_ip6_config_timeout (self); else if (priv->ip6_state == IP_DONE) @@ -4074,10 +4190,12 @@ dhcp6_state_changed (NMDhcpClient *client, NMDhcpState state, NMIP6Config *ip6_config, GHashTable *options, + const char *event_id, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + guint i; g_return_if_fail (nm_dhcp_client_get_ipv6 (client) == TRUE); g_return_if_fail (!ip6_config || NM_IS_IP6_CONFIG (ip6_config)); @@ -4086,10 +4204,27 @@ dhcp6_state_changed (NMDhcpClient *client, switch (state) { case NM_DHCP_STATE_BOUND: - g_clear_object (&priv->dhcp6_ip6_config); - if (ip6_config) { - priv->dhcp6_ip6_config = g_object_ref (ip6_config); - dhcp6_update_config (self, priv->dhcp6_config, options); + /* If the server sends multiple IPv6 addresses, we receive a state + * changed event for each of them. Use the event ID to merge IPv6 + * addresses from the same transaction into a single configuration. + */ + if ( ip6_config + && event_id + && priv->dhcp6_event_id + && !strcmp (event_id, priv->dhcp6_event_id)) { + for (i = 0; i < nm_ip6_config_get_num_addresses (ip6_config); i++) { + nm_ip6_config_add_address (priv->dhcp6_ip6_config, + nm_ip6_config_get_address (ip6_config, i)); + } + } else { + g_clear_object (&priv->dhcp6_ip6_config); + g_clear_pointer (&priv->dhcp6_event_id, g_free); + if (ip6_config) { + priv->dhcp6_ip6_config = g_object_ref (ip6_config); + priv->dhcp6_event_id = g_strdup (event_id); + dhcp6_update_config (self, priv->dhcp6_config, options); + g_object_notify (G_OBJECT (self), NM_DEVICE_DHCP6_CONFIG); + } } if (priv->ip6_state == IP_CONF) { @@ -4182,6 +4317,7 @@ dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason) g_warn_if_fail (priv->dhcp6_ip6_config == NULL); g_clear_object (&priv->dhcp6_ip6_config); + g_clear_pointer (&priv->dhcp6_event_id, g_free); connection = nm_device_get_connection (self); g_assert (connection); @@ -4437,7 +4573,7 @@ static void nm_device_set_mtu (NMDevice *self, guint32 mtu) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - int ifindex = nm_device_get_ifindex (self); + int ifindex = nm_device_get_ip_ifindex (self); if (mtu) priv->mtu = mtu; @@ -4446,7 +4582,7 @@ nm_device_set_mtu (NMDevice *self, guint32 mtu) if (priv->ip6_mtu) nm_device_ipv6_set_mtu (self, priv->ip6_mtu); - if (priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex)) + if (priv->mtu && priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex)) nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu); } @@ -4459,20 +4595,20 @@ nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu) priv->ip6_mtu = mtu ?: plat_mtu; - if (priv->ip6_mtu && priv->mtu < priv->ip6_mtu) { - _LOGW (LOGD_DEVICE | LOGD_IP6, "Lowering IPv6 MTU (%d) to match device MTU (%d)", + if (priv->ip6_mtu && priv->mtu && priv->mtu < priv->ip6_mtu) { + _LOGI (LOGD_DEVICE | LOGD_IP6, "Lowering IPv6 MTU (%d) to match device MTU (%d)", priv->ip6_mtu, priv->mtu); priv->ip6_mtu = priv->mtu; } - if (priv->ip6_mtu < 1280) { - _LOGW (LOGD_DEVICE | LOGD_IP6, "IPv6 MTU (%d) smaller than 1280, adjusting", + if (priv->ip6_mtu && priv->ip6_mtu < 1280) { + _LOGI (LOGD_DEVICE | LOGD_IP6, "IPv6 MTU (%d) smaller than 1280, adjusting", priv->ip6_mtu); priv->ip6_mtu = 1280; } - if (priv->mtu < priv->ip6_mtu) { - _LOGW (LOGD_DEVICE | LOGD_IP6, "Raising device MTU (%d) to match IPv6 MTU (%d)", + if (priv->ip6_mtu && priv->mtu && priv->mtu < priv->ip6_mtu) { + _LOGI (LOGD_DEVICE | LOGD_IP6, "Raising device MTU (%d) to match IPv6 MTU (%d)", priv->mtu, priv->ip6_mtu); nm_device_set_mtu (self, priv->ip6_mtu); } @@ -5010,11 +5146,6 @@ act_stage3_ip6_config_start (NMDevice *self, ret = NM_ACT_STAGE_RETURN_POSTPONE; } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0) { ret = linklocal6_start (self); - if (ret == NM_ACT_STAGE_RETURN_FINISH) { - /* New blank config; LL address is already in priv->ext_ip6_config */ - *out_config = nm_ip6_config_new (); - g_assert (*out_config); - } } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) { priv->dhcp6_mode = NM_RDISC_DHCP_LEVEL_MANAGED; if (!dhcp6_start (self, TRUE, reason)) { @@ -5903,26 +6034,19 @@ static void _update_ip4_address (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - struct ifreq req; - guint32 new_address; - int fd; - - g_return_if_fail (self != NULL); + guint32 addr; - fd = socket (PF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - _LOGE (LOGD_IP4, "couldn't open control socket."); - return; - } + g_return_if_fail (NM_IS_DEVICE (self)); - memset (&req, 0, sizeof (struct ifreq)); - strncpy (req.ifr_name, nm_device_get_ip_iface (self), IFNAMSIZ); - if (ioctl (fd, SIOCGIFADDR, &req) == 0) { - new_address = ((struct sockaddr_in *)(&req.ifr_addr))->sin_addr.s_addr; - if (new_address != priv->ip4_address) - priv->ip4_address = new_address; + if ( priv->ip4_config + && ip_config_valid (priv->state) + && nm_ip4_config_get_num_addresses (priv->ip4_config)) { + addr = nm_ip4_config_get_address (priv->ip4_config, 0)->address; + if (addr != priv->ip4_address) { + priv->ip4_address = addr; + g_object_notify (G_OBJECT (self), NM_DEVICE_IP4_ADDRESS); + } } - close (fd); } gboolean @@ -7497,6 +7621,59 @@ nm_device_set_dhcp_anycast_address (NMDevice *self, const char *addr) priv->dhcp_anycast_address = g_strdup (addr); } +static void +nm_device_update_metered (NMDevice *self) +{ +#define NM_METERED_INVALID ((NMMetered) -1) + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMSettingConnection *setting; + NMMetered conn_value, value = NM_METERED_INVALID; + NMConnection *connection = NULL; + NMDeviceState state; + + g_return_if_fail (NM_IS_DEVICE (self)); + + state = nm_device_get_state (self); + if ( state <= NM_DEVICE_STATE_DISCONNECTED + || state > NM_DEVICE_STATE_ACTIVATED) + value = NM_METERED_UNKNOWN; + + if (value == NM_METERED_INVALID) { + connection = nm_device_get_connection (self); + if (connection) { + setting = nm_connection_get_setting_connection (connection); + if (setting) { + conn_value = nm_setting_connection_get_metered (setting); + if (conn_value != NM_METERED_UNKNOWN) + value = conn_value; + } + } + } + + /* Try to guess a value using the metered flag in IP configuration */ + if (value == NM_METERED_INVALID) { + if ( priv->ip4_config + && priv->ip4_state == IP_DONE + && nm_ip4_config_get_metered (priv->ip4_config)) + value = NM_METERED_GUESS_YES; + } + + /* Otherwise look at connection type */ + if (value == NM_METERED_INVALID) { + if ( nm_connection_is_type (connection, NM_SETTING_GSM_SETTING_NAME) + || nm_connection_is_type (connection, NM_SETTING_CDMA_SETTING_NAME)) + value = NM_METERED_GUESS_YES; + else + value = NM_METERED_GUESS_NO; + } + + if (value != priv->metered) { + _LOGD (LOGD_DEVICE, "set metered value %d", value); + priv->metered = value; + g_object_notify (G_OBJECT (self), NM_DEVICE_METERED); + } +} + /** * nm_device_check_connection_available(): * @self: the #NMDevice @@ -7856,10 +8033,11 @@ _cleanup_generic_post (NMDevice *self, CleanupType cleanup_type) priv->default_route.v4_has = FALSE; priv->default_route.v4_is_assumed = TRUE; - priv->default_route.v4_configure_first_time = TRUE; priv->default_route.v6_has = FALSE; priv->default_route.v6_is_assumed = TRUE; - priv->default_route.v6_configure_first_time = TRUE; + + priv->v4_commit_first_time = TRUE; + priv->v6_commit_first_time = TRUE; nm_default_route_manager_ip4_update_default_route (nm_default_route_manager_get (), self); nm_default_route_manager_ip6_update_default_route (nm_default_route_manager_get (), self); @@ -7943,9 +8121,11 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean nm_device_master_release_slaves (self); /* slave: mark no longer enslaved */ - g_clear_object (&priv->master); - priv->enslaved = FALSE; - g_object_notify (G_OBJECT (self), NM_DEVICE_MASTER); + if (nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) <= 0) { + g_clear_object (&priv->master); + priv->enslaved = FALSE; + g_object_notify (G_OBJECT (self), NM_DEVICE_MASTER); + } /* Take out any entries in the routing table and any IP address the device had. */ ifindex = nm_device_get_ip_ifindex (self); @@ -7954,6 +8134,7 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean nm_platform_address_flush (NM_PLATFORM_GET, ifindex); } + nm_device_update_metered (self); _cleanup_generic_post (self, cleanup_type); } @@ -8426,6 +8607,7 @@ _set_state_full (NMDevice *self, break; case NM_DEVICE_STATE_ACTIVATED: _LOGI (LOGD_DEVICE, "Activation: successful, device activated."); + nm_device_update_metered (self); nm_dispatcher_call (DISPATCHER_ACTION_UP, nm_act_request_get_connection (req), self, NULL, NULL, NULL); break; case NM_DEVICE_STATE_FAILED: @@ -8799,9 +8981,10 @@ nm_device_init (NMDevice *self) priv->ip6_saved_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); priv->default_route.v4_is_assumed = TRUE; - priv->default_route.v4_configure_first_time = TRUE; priv->default_route.v6_is_assumed = TRUE; - priv->default_route.v6_configure_first_time = TRUE; + + priv->v4_commit_first_time = TRUE; + priv->v6_commit_first_time = TRUE; } static GObject* @@ -9298,6 +9481,9 @@ get_property (GObject *object, guint prop_id, case PROP_HAS_PENDING_ACTION: g_value_set_boolean (value, nm_device_has_pending_action (self)); break; + case PROP_METERED: + g_value_set_uint (value, priv->metered); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -9561,6 +9747,20 @@ nm_device_class_init (NMDeviceClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMDevice:metered: + * + * Whether the connection is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_uint (NM_DEVICE_METERED, "", "", + 0, G_MAXUINT32, NM_METERED_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /* Signals */ signals[STATE_CHANGED] = g_signal_new ("state-changed", diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index f1dab9bf2..e9d5b9488 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -58,6 +58,7 @@ #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id" #define NM_DEVICE_MTU "mtu" #define NM_DEVICE_HW_ADDRESS "hw-address" +#define NM_DEVICE_METERED "metered" #define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */ #define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */ @@ -74,7 +75,6 @@ #define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate" #define NM_DEVICE_RECHECK_ASSUME "recheck-assume" - G_BEGIN_DECLS #define NM_TYPE_DEVICE (nm_device_get_type ()) @@ -281,6 +281,7 @@ const char * nm_device_get_driver_version (NMDevice *dev); const char * nm_device_get_type_desc (NMDevice *dev); const char * nm_device_get_type_description (NMDevice *dev); NMDeviceType nm_device_get_device_type (NMDevice *dev); +NMMetered nm_device_get_metered (NMDevice *dev); int nm_device_get_priority (NMDevice *dev); guint32 nm_device_get_ip4_route_metric (NMDevice *dev); diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 23750f357..09b2dd7d7 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -40,6 +40,7 @@ #include "nm-enum-types.h" #include "nm-team-enum-types.h" #include "nm-core-internal.h" +#include "nm-ip4-config.h" #include "gsystem-local-alloc.h" #include "nm-device-team-glue.h" @@ -565,6 +566,25 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) } static void +ip4_config_pre_commit (NMDevice *self, NMIP4Config *config) +{ + NMConnection *connection; + NMSettingWired *s_wired; + guint32 mtu; + + connection = nm_device_get_connection (self); + g_assert (connection); + s_wired = nm_connection_get_setting_wired (connection); + + if (s_wired) { + /* MTU override */ + mtu = nm_setting_wired_get_mtu (s_wired); + if (mtu) + nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); + } +} + +static void deactivate (NMDevice *device) { NMDeviceTeam *self = NM_DEVICE_TEAM (device); @@ -813,6 +833,7 @@ nm_device_team_class_init (NMDeviceTeamClass *klass) parent_class->master_update_slave_connection = master_update_slave_connection; parent_class->act_stage1_prepare = act_stage1_prepare; + parent_class->ip4_config_pre_commit = ip4_config_pre_commit; parent_class->deactivate = deactivate; parent_class->enslave_slave = enslave_slave; parent_class->release_slave = release_slave; diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 2e116f87d..dde743b1d 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -55,6 +55,7 @@ #include "nm-dbus-glib-types.h" #include "nm-wifi-enum-types.h" #include "nm-connection-provider.h" +#include "gsystem-local-alloc.h" static gboolean impl_device_get_access_points (NMDeviceWifi *device, @@ -178,7 +179,7 @@ static void supplicant_iface_notify_scanning_cb (NMSupplicantInterface * iface, static void schedule_scanlist_cull (NMDeviceWifi *self); -static gboolean request_wireless_scan (gpointer user_data); +static void request_wireless_scan (NMDeviceWifi *self, GHashTable *scan_options); static void remove_access_point (NMDeviceWifi *device, NMAccessPoint *ap); @@ -753,7 +754,7 @@ deactivate (NMDevice *device) /* Ensure we trigger a scan after deactivating a Hotspot */ if (old_mode == NM_802_11_MODE_AP) { cancel_pending_scan (self); - request_wireless_scan (self); + request_wireless_scan (self, NULL); } } @@ -1253,6 +1254,7 @@ request_scan_cb (NMDevice *device, { NMDeviceWifi *self = NM_DEVICE_WIFI (device); GError *local = NULL; + gs_unref_hashtable GHashTable *new_scan_options = user_data; if (error) { dbus_g_method_return_error (context, error); @@ -1269,7 +1271,7 @@ request_scan_cb (NMDevice *device, } cancel_pending_scan (self); - request_wireless_scan (self); + request_wireless_scan (self, new_scan_options); dbus_g_method_return (context); } @@ -1316,7 +1318,7 @@ impl_device_request_scan (NMDeviceWifi *self, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE, request_scan_cb, - NULL); + options ? g_hash_table_ref (options) : NULL); return; error: @@ -1482,23 +1484,31 @@ build_hidden_probe_list (NMDeviceWifi *self) return ssids; } -static gboolean -request_wireless_scan (gpointer user_data) +static void +request_wireless_scan (NMDeviceWifi *self, GHashTable *scan_options) { - NMDeviceWifi *self = NM_DEVICE_WIFI (user_data); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); gboolean backoff = FALSE; GPtrArray *ssids = NULL; if (priv->requested_scan) { /* There's already a scan in progress */ - return FALSE; + return; } if (check_scanning_allowed (self)) { _LOGD (LOGD_WIFI_SCAN, "scanning requested"); - ssids = build_hidden_probe_list (self); + if (scan_options && g_hash_table_size (scan_options)) { + GValue *val = g_hash_table_lookup (scan_options, "ssids"); + + if (val && G_VALUE_HOLDS (val, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR)) + ssids = g_ptr_array_ref (g_value_get_boxed (val)); + else + _LOGD (LOGD_WIFI_SCAN, "ignoring invalid scan options"); + } + if (!ssids) + ssids = build_hidden_probe_list (self); if (nm_logging_enabled (LOGL_DEBUG, LOGD_WIFI_SCAN)) { if (ssids) { @@ -1533,9 +1543,14 @@ request_wireless_scan (gpointer user_data) priv->pending_scan_id = 0; schedule_scan (self, backoff); - return FALSE; } +static gboolean +request_wireless_scan_periodic (gpointer user_data) +{ + request_wireless_scan (user_data, NULL); + return FALSE; +} /* * schedule_scan @@ -1563,7 +1578,7 @@ schedule_scan (NMDeviceWifi *self, gboolean backoff) factor = 1; priv->pending_scan_id = g_timeout_add_seconds (next_scan, - request_wireless_scan, + request_wireless_scan_periodic, self); priv->scheduled_scan_time = now + priv->scan_interval; @@ -3072,7 +3087,7 @@ device_state_changed (NMDevice *device, /* Kick off a scan to get latest results */ priv->scan_interval = SCAN_INTERVAL_MIN; cancel_pending_scan (self); - request_wireless_scan (self); + request_wireless_scan (self, NULL); break; default: break; diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index d70dd9a6d..1485f4c10 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -79,6 +79,7 @@ enum { PROP_MODE, PROP_MAX_BITRATE, PROP_STRENGTH, + PROP_LAST_SEEN, LAST_PROP }; @@ -195,6 +196,12 @@ get_property (GObject *object, guint prop_id, case PROP_STRENGTH: g_value_set_schar (value, priv->strength); break; + case PROP_LAST_SEEN: + g_value_set_int (value, + priv->last_seen > 0 + ? (gint) nm_utils_monotonic_timestamp_as_boottime (priv->last_seen, NM_UTILS_NS_PER_SECOND) + : -1); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -294,6 +301,13 @@ nm_ap_class_init (NMAccessPointClass *ap_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property + (object_class, PROP_LAST_SEEN, + g_param_spec_int (NM_AP_LAST_SEEN, "", "", + -1, G_MAXINT, -1, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (ap_class), &dbus_glib_nm_access_point_object_info); @@ -1056,7 +1070,7 @@ void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast) gint32 nm_ap_get_last_seen (const NMAccessPoint *ap) { - g_return_val_if_fail (NM_IS_AP (ap), FALSE); + g_return_val_if_fail (NM_IS_AP (ap), 0); return NM_AP_GET_PRIVATE (ap)->last_seen; } @@ -1064,9 +1078,16 @@ nm_ap_get_last_seen (const NMAccessPoint *ap) void nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen) { + NMAccessPointPrivate *priv; + g_return_if_fail (NM_IS_AP (ap)); - NM_AP_GET_PRIVATE (ap)->last_seen = last_seen; + priv = NM_AP_GET_PRIVATE (ap); + + if (priv->last_seen != last_seen) { + priv->last_seen = last_seen; + g_object_notify (G_OBJECT (ap), NM_AP_LAST_SEEN); + } } gboolean diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h index 8ad9acb71..67d307692 100644 --- a/src/devices/wifi/nm-wifi-ap.h +++ b/src/devices/wifi/nm-wifi-ap.h @@ -43,6 +43,7 @@ #define NM_AP_MODE "mode" #define NM_AP_MAX_BITRATE "max-bitrate" #define NM_AP_STRENGTH "strength" +#define NM_AP_LAST_SEEN "last-seen" typedef struct { GObject parent; diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index eb3173307..7f5d5a28c 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -36,6 +36,7 @@ #include "nm-dhcp-client.h" #include "nm-dhcp-utils.h" #include "nm-platform.h" +#include "gsystem-local-alloc.h" typedef struct { char * iface; @@ -284,6 +285,7 @@ nm_dhcp_client_set_state (NMDhcpClient *self, GHashTable *options) { NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + gs_free char *event_id = NULL; if (new_state >= NM_DHCP_STATE_BOUND) timeout_cleanup (self); @@ -308,19 +310,30 @@ nm_dhcp_client_set_state (NMDhcpClient *self, if ((priv->state == new_state) && (new_state != NM_DHCP_STATE_BOUND)) return; + if (priv->ipv6 && new_state == NM_DHCP_STATE_BOUND) { + char *start, *iaid; + + iaid = g_hash_table_lookup (options, "iaid"); + start = g_hash_table_lookup (options, "life_starts"); + if (iaid && start) + event_id = g_strdup_printf ("%s|%s", iaid, start); + } + nm_log_info (priv->ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, - "(%s): DHCPv%c state changed %s -> %s", + "(%s): DHCPv%c state changed %s -> %s%s%s%s", priv->iface, priv->ipv6 ? '6' : '4', state_to_string (priv->state), - state_to_string (new_state)); + state_to_string (new_state), + NM_PRINT_FMT_QUOTED (event_id, ", event ID=\"", event_id, "\"", "")); priv->state = new_state; g_signal_emit (G_OBJECT (self), signals[SIGNAL_STATE_CHANGED], 0, new_state, ip_config, - options); + options, + event_id); } static gboolean @@ -977,6 +990,6 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMDhcpClientClass, state_changed), NULL, NULL, NULL, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_OBJECT, G_TYPE_HASH_TABLE); + G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_OBJECT, G_TYPE_HASH_TABLE, G_TYPE_STRING); } diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index f936f45c5..20ddefc32 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -184,6 +184,7 @@ static void client_state_changed (NMDhcpClient *client, NMDhcpState state, GObject *ip_config, GHashTable *options, + const char *event_id, NMDhcpManager *self); static void @@ -204,6 +205,7 @@ client_state_changed (NMDhcpClient *client, NMDhcpState state, GObject *ip_config, GHashTable *options, + const char *event_id, NMDhcpManager *self) { if (state >= NM_DHCP_STATE_TIMEOUT) diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c index 12dc03cc8..2bd0d72ff 100644 --- a/src/dhcp-manager/nm-dhcp-systemd.c +++ b/src/dhcp-manager/nm-dhcp-systemd.c @@ -224,6 +224,8 @@ lease_to_ip4_config (sd_dhcp_lease *lease, guint16 mtu; int r, num; guint64 end_time; + uint8_t *data; + gboolean metered = FALSE; g_return_val_if_fail (lease != NULL, NULL); @@ -355,6 +357,11 @@ lease_to_ip4_config (sd_dhcp_lease *lease, g_string_free (l, TRUE); } + num = sd_dhcp_lease_get_vendor_specific (lease, &data); + if (num > 0) + metered = !!memmem (data, num, "ANDROID_METERED", STRLEN ("ANDROID_METERED")); + nm_ip4_config_set_metered (ip4_config, metered); + return ip4_config; } diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c index 8cd4359ab..ab7f26d5f 100644 --- a/src/dhcp-manager/nm-dhcp-utils.c +++ b/src/dhcp-manager/nm-dhcp-utils.c @@ -575,6 +575,9 @@ nm_dhcp_utils_ip4_config_from_options (const char *iface, g_strfreev (nis); } + str = g_hash_table_lookup (options, "vendor_encapsulated_options"); + nm_ip4_config_set_metered (ip4_config, str && strstr (str, "ANDROID_METERED")); + return ip4_config; error: diff --git a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-lease-internal.h b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-lease-internal.h index 9e184ac4b..71f7f143b 100644 --- a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-lease-internal.h +++ b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-lease-internal.h @@ -72,6 +72,8 @@ struct sd_dhcp_lease { char *root_path; uint8_t *client_id; size_t client_id_len; + uint8_t *vendor_specific; + size_t vendor_specific_size; }; int dhcp_lease_new(sd_dhcp_lease **ret); diff --git a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-protocol.h b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-protocol.h index abca9422c..aa37e9b0b 100644 --- a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-protocol.h +++ b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-protocol.h @@ -125,6 +125,7 @@ enum { DHCP_OPTION_BROADCAST = 28, DHCP_OPTION_STATIC_ROUTE = 33, DHCP_OPTION_NTP_SERVER = 42, + DHCP_OPTION_VENDOR_SPECIFIC = 43, DHCP_OPTION_REQUESTED_IP_ADDRESS = 50, DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51, DHCP_OPTION_OVERLOAD = 52, diff --git a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c index 2d13d503e..0b5048a66 100644 --- a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c @@ -191,6 +191,19 @@ int sd_dhcp_lease_get_routes(sd_dhcp_lease *lease, struct sd_dhcp_route **routes return 0; } +int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, uint8_t **data) { + assert_return(lease, -EINVAL); + assert_return(data, -EINVAL); + + if (lease->vendor_specific) { + *data = lease->vendor_specific; + return lease->vendor_specific_size; + } else + return -ENOENT; + + return 0; +} + sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease) { if (lease) assert_se(REFCNT_INC(lease->n_ref) >= 2); @@ -286,6 +299,24 @@ static int lease_parse_string(const uint8_t *option, size_t len, char **ret) { return 0; } +static int lease_parse_binary(const uint8_t *option, size_t len, uint8_t **ret) { + assert (option); + assert (ret); + + if (len >= 1) { + uint8_t *data; + + data = memdup(option, len); + if (!data) + return -errno; + + free(*ret); + *ret = data; + } + + return 0; +} + static int lease_parse_in_addrs_aux(const uint8_t *option, size_t len, struct in_addr **ret, size_t *ret_size, size_t mult) { assert(option); assert(ret); @@ -568,6 +599,14 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option, return r; break; + + case DHCP_OPTION_VENDOR_SPECIFIC: + r = lease_parse_binary(option, len, &lease->vendor_specific); + if (r < 0) + return r; + lease->vendor_specific_size = len; + + break; } return 0; @@ -595,6 +634,7 @@ int sd_dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) { const uint8_t *client_id; size_t client_id_len; const char *string; + uint8_t *data; uint16_t mtu; struct sd_dhcp_route *routes; int r; @@ -667,6 +707,18 @@ int sd_dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) { if (r >= 0) serialize_dhcp_routes(f, "ROUTES", routes, r); + r = sd_dhcp_lease_get_vendor_specific(lease, &data); + if (r >= 0) { + _cleanup_free_ char *option_hex = NULL; + + option_hex = hexmem(data, r); + if (!option_hex) { + r = -ENOMEM; + goto finish; + } + fprintf(f, "VENDOR_SPECIFIC=%s\n", option_hex); + } + r = sd_dhcp_lease_get_client_id(lease, &client_id, &client_id_len); if (r >= 0) { _cleanup_free_ char *client_id_hex = NULL; diff --git a/src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h b/src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h index 4296b91d8..079a1bb34 100644 --- a/src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h +++ b/src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h @@ -45,6 +45,7 @@ int sd_dhcp_lease_get_domainname(sd_dhcp_lease *lease, const char **domainname); int sd_dhcp_lease_get_hostname(sd_dhcp_lease *lease, const char **hostname); int sd_dhcp_lease_get_root_path(sd_dhcp_lease *lease, const char **root_path); int sd_dhcp_lease_get_routes(sd_dhcp_lease *lease, struct sd_dhcp_route **routesgn); +int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, uint8_t **data); int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const uint8_t **client_id, size_t *client_id_len); diff --git a/src/dhcp-manager/tests/test-dhcp-utils.c b/src/dhcp-manager/tests/test-dhcp-utils.c index 53688a5b1..618188dfd 100644 --- a/src/dhcp-manager/tests/test-dhcp-utils.c +++ b/src/dhcp-manager/tests/test-dhcp-utils.c @@ -72,7 +72,7 @@ static void test_generic_options (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; const NMPlatformIP4Route *route; guint32 tmp; @@ -147,7 +147,7 @@ static void test_wins_options (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; guint32 tmp; const char *expected_wins1 = "63.12.199.5"; @@ -176,6 +176,31 @@ test_wins_options (void) } static void +test_vendor_option_metered (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + static const Option data[] = { + { "vendor_encapsulated_options", "ANDROID_METERED" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0); + g_assert (ip4_config); + g_assert (nm_ip4_config_get_metered (ip4_config) == FALSE); + g_hash_table_destroy (options); + g_clear_object (&ip4_config); + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0); + g_assert (ip4_config); + g_assert (nm_ip4_config_get_metered (ip4_config) == TRUE); + g_hash_table_destroy (options); +} + +static void ip4_test_route (NMIP4Config *ip4_config, guint route_num, const char *expected_dest, @@ -208,7 +233,7 @@ static void test_classless_static_routes_1 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_route2_dest = "10.0.0.0"; @@ -236,7 +261,7 @@ static void test_classless_static_routes_2 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_route2_dest = "10.0.0.0"; @@ -264,7 +289,7 @@ static void test_fedora_dhclient_classless_static_routes (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "129.210.177.128"; const char *expected_route1_gw = "192.168.0.113"; const char *expected_route2_dest = "2.0.0.0"; @@ -296,7 +321,7 @@ static void test_dhclient_invalid_classless_routes_1 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; static const Option data[] = { @@ -325,7 +350,7 @@ static void test_dhcpcd_invalid_classless_routes_1 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "10.1.1.5"; const char *expected_route1_gw = "10.1.1.1"; const char *expected_route2_dest = "100.99.88.56"; @@ -359,7 +384,7 @@ static void test_dhclient_invalid_classless_routes_2 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "10.1.1.5"; const char *expected_route1_gw = "10.1.1.1"; const char *expected_route2_dest = "100.99.88.56"; @@ -392,7 +417,7 @@ static void test_dhcpcd_invalid_classless_routes_2 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "10.1.1.5"; const char *expected_route1_gw = "10.1.1.1"; const char *expected_route2_dest = "100.99.88.56"; @@ -427,7 +452,7 @@ static void test_dhclient_invalid_classless_routes_3 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; static const Option data[] = { @@ -455,7 +480,7 @@ static void test_dhcpcd_invalid_classless_routes_3 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; static Option data[] = { @@ -483,7 +508,7 @@ static void test_dhclient_gw_in_classless_routes (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_gateway = "192.2.3.4"; @@ -511,7 +536,7 @@ static void test_dhcpcd_gw_in_classless_routes (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_gateway = "192.2.3.4"; @@ -539,7 +564,7 @@ static void test_escaped_domain_searches (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_search0 = "host1"; const char *expected_search1 = "host2"; const char *expected_search2 = "host3"; @@ -566,7 +591,7 @@ static void test_invalid_escaped_domain_searches (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; static const Option data[] = { { "domain_search", "host1\\aahost2\\032host3" }, { NULL, NULL } @@ -591,7 +616,7 @@ static void test_ip4_missing_prefix (const char *ip, guint32 expected_prefix) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; options = fill_table (generic_options, NULL); @@ -631,7 +656,7 @@ static void test_ip4_prefix_classless (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; /* Ensure that the missing-subnet-mask handler doesn't mangle classless @@ -716,6 +741,7 @@ int main (int argc, char **argv) g_test_add_func ("/dhcp/ip4-missing-prefix-8", test_ip4_missing_prefix_8); g_test_add_func ("/dhcp/ip4-prefix-classless", test_ip4_prefix_classless); g_test_add_func ("/dhcp/client-id-from-string", test_client_id_from_string); + g_test_add_func ("/dhcp/vendor-option-metered", test_vendor_option_metered); return g_test_run (); } diff --git a/src/main.c b/src/main.c index dfc307b5d..495262efd 100644 --- a/src/main.c +++ b/src/main.c @@ -476,13 +476,7 @@ main (int argc, char *argv[]) net_enabled, wifi_enabled, wwan_enabled, - wimax_enabled, - &error); - if (manager == NULL) { - nm_log_err (LOGD_CORE, "failed to initialize the network manager: %s", - error && error->message ? error->message : "(unknown)"); - goto done; - } + wimax_enabled); /* Initialize the supplicant manager */ sup_mgr = nm_supplicant_manager_get (); diff --git a/src/nm-access-point-glue.h b/src/nm-access-point-glue.h index ad4d59164..39b22cc27 100644 --- a/src/nm-access-point-glue.h +++ b/src/nm-access-point-glue.h @@ -68,6 +68,6 @@ const DBusGObjectInfo dbus_glib_nm_access_point_object_info = { 1, 0, "\0", "org.freedesktop.NetworkManager.AccessPoint\0PropertiesChanged\0\0", -"org.freedesktop.NetworkManager.AccessPoint\0Flags\0flags\0read\0org.freedesktop.NetworkManager.AccessPoint\0WpaFlags\0wpa_flags\0read\0org.freedesktop.NetworkManager.AccessPoint\0RsnFlags\0rsn_flags\0read\0org.freedesktop.NetworkManager.AccessPoint\0Ssid\0ssid\0read\0org.freedesktop.NetworkManager.AccessPoint\0Frequency\0frequency\0read\0org.freedesktop.NetworkManager.AccessPoint\0HwAddress\0hw_address\0read\0org.freedesktop.NetworkManager.AccessPoint\0Mode\0mode\0read\0org.freedesktop.NetworkManager.AccessPoint\0MaxBitrate\0max_bitrate\0read\0org.freedesktop.NetworkManager.AccessPoint\0Strength\0strength\0read\0\0" +"org.freedesktop.NetworkManager.AccessPoint\0Flags\0flags\0read\0org.freedesktop.NetworkManager.AccessPoint\0WpaFlags\0wpa_flags\0read\0org.freedesktop.NetworkManager.AccessPoint\0RsnFlags\0rsn_flags\0read\0org.freedesktop.NetworkManager.AccessPoint\0Ssid\0ssid\0read\0org.freedesktop.NetworkManager.AccessPoint\0Frequency\0frequency\0read\0org.freedesktop.NetworkManager.AccessPoint\0HwAddress\0hw_address\0read\0org.freedesktop.NetworkManager.AccessPoint\0Mode\0mode\0read\0org.freedesktop.NetworkManager.AccessPoint\0MaxBitrate\0max_bitrate\0read\0org.freedesktop.NetworkManager.AccessPoint\0Strength\0strength\0read\0org.freedesktop.NetworkManager.AccessPoint\0LastSeen\0last_seen\0read\0\0" }; diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index d40d571e8..3a8e6cf58 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -100,6 +100,7 @@ enum { enum { DEVICE_CHANGED, + DEVICE_METERED_CHANGED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -109,6 +110,29 @@ static void _device_cleanup (NMActiveConnection *self); /****************************************************************/ +#define _NMLOG_DOMAIN LOGD_DEVICE +#define _NMLOG_PREFIX_NAME "active-connection" +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ + char __prefix[128]; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ + const void *const __self = (self); \ + \ + if (__self) { \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \ + __p_prefix = __prefix; \ + } \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ + "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +/****************************************************************/ + static const char * state_to_string (NMActiveConnectionState state) { @@ -401,6 +425,18 @@ device_master_changed (GObject *object, } } +static void +device_metered_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + NMActiveConnection *self = (NMActiveConnection *) user_data; + NMDevice *device = NM_DEVICE (object); + + g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self)); + g_signal_emit (self, signals[DEVICE_METERED_CHANGED], 0, nm_device_get_metered (device)); +} + gboolean nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device) { @@ -427,6 +463,8 @@ nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device) G_CALLBACK (device_state_changed), self); g_signal_connect (device, "notify::master", G_CALLBACK (device_master_changed), self); + g_signal_connect (device, "notify::" NM_DEVICE_METERED, + G_CALLBACK (device_metered_changed), self); if (!priv->assumed) { priv->pending_activation_id = g_strdup_printf ("activation::%p", (void *)self); @@ -473,15 +511,15 @@ check_master_ready (NMActiveConnection *self) NMActiveConnectionState master_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; if (priv->state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) { - nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (not activating)", self); + _LOGD ("not signalling master-ready (not activating)"); return; } if (!priv->master) { - nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (no master)", self); + _LOGD ("not signalling master-ready (no master)"); return; } if (priv->master_ready) { - nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (already signaled)", self); + _LOGD ("not signalling master-ready (already signaled)"); return; } @@ -491,12 +529,12 @@ check_master_ready (NMActiveConnection *self) * or higher states. */ master_state = nm_active_connection_get_state (priv->master); - nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)", - self, priv->master, state_to_string (master_state), master_state); + _LOGD ("master ActiveConnection [%p] state now '%s' (%d)", + priv->master, state_to_string (master_state), master_state); if ( master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING || master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { - nm_log_dbg (LOGD_DEVICE, "(%p): signalling master-ready", self); + _LOGD ("signalling master-ready"); priv->master_ready = TRUE; g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_INT_MASTER_READY); @@ -520,8 +558,8 @@ master_state_cb (NMActiveConnection *master, check_master_ready (self); - nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)", - self, master, state_to_string (master_state), master_state); + _LOGD ("master ActiveConnection [%p] state now '%s' (%d)", + master, state_to_string (master_state), master_state); if ( master_state >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING && !priv->master_ready) { @@ -558,8 +596,8 @@ nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *m g_return_if_fail (priv->device != nm_active_connection_get_device (master)); } - nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection is [%p] %s", - self, master, nm_active_connection_get_id (master)); + _LOGD ("master ActiveConnection is [%p] %s", + master, nm_active_connection_get_id (master)); priv->master = g_object_ref (master); g_signal_connect (priv->master, @@ -838,6 +876,7 @@ _device_cleanup (NMActiveConnection *self) if (priv->device) { g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_state_changed), self); g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_master_changed), self); + g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_metered_changed), self); } if (priv->pending_activation_id) { @@ -1043,6 +1082,14 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class) NULL, NULL, NULL, G_TYPE_NONE, 2, NM_TYPE_DEVICE, NM_TYPE_DEVICE); + signals[DEVICE_METERED_CHANGED] = + g_signal_new (NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMActiveConnectionClass, device_metered_changed), + NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_UINT); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (ac_class), &dbus_glib_nm_active_connection_object_info); diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h index 710cfeed9..4db5e6ff5 100644 --- a/src/nm-active-connection.h +++ b/src/nm-active-connection.h @@ -57,7 +57,8 @@ #define NM_ACTIVE_CONNECTION_INT_MASTER_READY "int-master-ready" /* Internal signals*/ -#define NM_ACTIVE_CONNECTION_DEVICE_CHANGED "device-changed" +#define NM_ACTIVE_CONNECTION_DEVICE_CHANGED "device-changed" +#define NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED "device-metered-changed" struct _NMActiveConnection { GObject parent; @@ -78,6 +79,9 @@ typedef struct { void (*device_changed) (NMActiveConnection *connection, NMDevice *new_device, NMDevice *old_device); + + void (*device_metered_changed) (NMActiveConnection *connection, + NMMetered new_value); } NMActiveConnectionClass; GType nm_active_connection_get_type (void); diff --git a/src/nm-auth-manager.c b/src/nm-auth-manager.c index 8bd167eff..09a5791f0 100644 --- a/src/nm-auth-manager.c +++ b/src/nm-auth-manager.c @@ -30,27 +30,21 @@ #define POLKIT_INTERFACE "org.freedesktop.PolicyKit1.Authority" -#define _LOG_DEFAULT_DOMAIN LOGD_CORE - -#define _LOG(level, domain, ...) \ +#define _NMLOG_PREFIX_NAME "auth" +#define _NMLOG_DOMAIN LOGD_CORE +#define _NMLOG(level, ...) \ G_STMT_START { \ - if (nm_logging_enabled ((level), (domain))) { \ - char __prefix[30] = "auth"; \ + if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \ + char __prefix[30] = _NMLOG_PREFIX_NAME; \ \ if ((self) != singleton_instance) \ - g_snprintf (__prefix, sizeof (__prefix), "auth[%p]", (self)); \ - _nm_log ((level), (domain), 0, \ + g_snprintf (__prefix, sizeof (__prefix), ""_NMLOG_PREFIX_NAME"[%p]", (self)); \ + _nm_log ((level), (_NMLOG_DOMAIN), 0, \ "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ } \ } G_STMT_END -#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGI(...) _LOG (LOGL_INFO, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGW(...) _LOG (LOGL_WARN, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGE(...) _LOG (LOGL_ERR, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) - - enum { PROP_0, PROP_POLKIT_ENABLED, diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index 81ac8f9de..e7e52caec 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -36,24 +36,15 @@ G_DEFINE_TYPE (NMConnectivity, nm_connectivity, G_TYPE_OBJECT) #define NM_CONNECTIVITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONNECTIVITY, NMConnectivityPrivate)) - -#define _LOG_DEFAULT_DOMAIN LOGD_CONCHECK - -#define _LOG(level, domain, ...) \ +#define _NMLOG_DOMAIN LOGD_CONCHECK +#define _NMLOG(level, ...) \ G_STMT_START { \ - nm_log ((level), (domain), \ + nm_log ((level), (_NMLOG_DOMAIN), \ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ "connectivity: " \ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ } G_STMT_END -#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGI(...) _LOG (LOGL_INFO, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGW(...) _LOG (LOGL_WARN, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGE(...) _LOG (LOGL_ERR, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) - - typedef struct { char *uri; char *response; @@ -151,25 +142,31 @@ nm_connectivity_check_cb (SoupSession *session, SoupMessage *msg, gpointer user_ goto done; } - /* Check headers; if we find the NM-specific one we're done */ - nm_header = soup_message_headers_get_one (msg->response_headers, "X-NetworkManager-Status"); - if (g_strcmp0 (nm_header, "online") == 0) { - _LOGD ("check for uri '%s' with Status header successful.", uri); - new_state = NM_CONNECTIVITY_FULL; - } else if (msg->status_code == SOUP_STATUS_OK) { - /* check response */ - if (msg->response_body->data && g_str_has_prefix (msg->response_body->data, response)) { - _LOGD ("check for uri '%s' successful.", uri); + if (msg->status_code == 511) { + _LOGD ("check for uri '%s' returned status '%d %s'; captive portal present.", + uri, msg->status_code, msg->reason_phrase); + new_state = NM_CONNECTIVITY_PORTAL; + } else { + /* Check headers; if we find the NM-specific one we're done */ + nm_header = soup_message_headers_get_one (msg->response_headers, "X-NetworkManager-Status"); + if (g_strcmp0 (nm_header, "online") == 0) { + _LOGD ("check for uri '%s' with Status header successful.", uri); new_state = NM_CONNECTIVITY_FULL; + } else if (msg->status_code == SOUP_STATUS_OK) { + /* check response */ + if (msg->response_body->data && g_str_has_prefix (msg->response_body->data, response)) { + _LOGD ("check for uri '%s' successful.", uri); + new_state = NM_CONNECTIVITY_FULL; + } else { + _LOGI ("check for uri '%s' did not match expected response '%s'; assuming captive portal.", + uri, response); + new_state = NM_CONNECTIVITY_PORTAL; + } } else { - _LOGI ("check for uri '%s' did not match expected response '%s'; assuming captive portal.", - uri, response); + _LOGI ("check for uri '%s' returned status '%d %s'; assuming captive portal.", + uri, msg->status_code, msg->reason_phrase); new_state = NM_CONNECTIVITY_PORTAL; } - } else { - _LOGI ("check for uri '%s' returned status '%d %s'; assuming captive portal.", - uri, msg->status_code, msg->reason_phrase); - new_state = NM_CONNECTIVITY_PORTAL; } done: @@ -365,12 +362,14 @@ set_property (GObject *object, guint property_id, NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE (self); const char *uri, *response; guint interval; + gboolean changed; switch (property_id) { case PROP_URI: uri = g_value_get_string (value); if (uri && !*uri) uri = NULL; + changed = g_strcmp0 (uri, priv->uri) != 0; #if WITH_CONCHECK if (uri) { SoupURI *soup_uri = soup_uri_new (uri); @@ -379,11 +378,14 @@ set_property (GObject *object, guint property_id, _LOGE ("invalid uri '%s' for connectivity check.", uri); uri = NULL; } + if (uri && soup_uri && changed && + soup_uri_get_scheme(soup_uri) == SOUP_URI_SCHEME_HTTPS) + _LOGW ("use of HTTPS for connectivity checking is not reliable and is discouraged (URI: %s)", uri); if (soup_uri) soup_uri_free (soup_uri); } #endif - if (g_strcmp0 (uri, priv->uri) != 0) { + if (changed) { g_free (priv->uri); priv->uri = g_strdup (uri); _reschedule_periodic_checks (self, TRUE); diff --git a/src/nm-default-route-manager.c b/src/nm-default-route-manager.c index fbb07ce3f..96a8c8556 100644 --- a/src/nm-default-route-manager.c +++ b/src/nm-default-route-manager.c @@ -21,10 +21,9 @@ #include "config.h" -#include "nm-default-route-manager.h" - -#include "string.h" +#include <string.h> +#include "nm-default-route-manager.h" #include "nm-logging.h" #include "nm-device.h" #include "nm-vpn-connection.h" @@ -62,7 +61,17 @@ G_DEFINE_TYPE (NMDefaultRouteManager, nm_default_route_manager, G_TYPE_OBJECT) NM_DEFINE_SINGLETON_GETTER (NMDefaultRouteManager, nm_default_route_manager_get, NM_TYPE_DEFAULT_ROUTE_MANAGER); -#define _LOG(level, addr_family, ...) \ +#define _NMLOG_PREFIX_NAME "default-route" +#undef _NMLOG_ENABLED +#define _NMLOG_ENABLED(level, addr_family) \ + ({ \ + const int __addr_family = (addr_family); \ + const NMLogLevel __level = (level); \ + const NMLogDomain __domain = __addr_family == AF_INET ? LOGD_IP4 : (__addr_family == AF_INET6 ? LOGD_IP6 : LOGD_IP); \ + \ + nm_logging_enabled (__level, __domain); \ + }) +#define _NMLOG(level, addr_family, ...) \ G_STMT_START { \ const int __addr_family = (addr_family); \ const NMLogLevel __level = (level); \ @@ -70,23 +79,18 @@ NM_DEFINE_SINGLETON_GETTER (NMDefaultRouteManager, nm_default_route_manager_get, \ if (nm_logging_enabled (__level, __domain)) { \ char __ch = __addr_family == AF_INET ? '4' : (__addr_family == AF_INET6 ? '6' : '-'); \ - char __prefix[30] = "default-route"; \ + char __prefix[30] = _NMLOG_PREFIX_NAME; \ \ if ((self) != singleton_instance) \ - g_snprintf (__prefix, sizeof (__prefix), "default-route%c[%p]", __ch, (self)); \ + g_snprintf (__prefix, sizeof (__prefix), ""_NMLOG_PREFIX_NAME"%c[%p]", __ch, (self)); \ else \ - __prefix[STRLEN ("default-route")] = __ch; \ + __prefix[STRLEN (_NMLOG_PREFIX_NAME)] = __ch; \ _nm_log (__level, __domain, 0, \ "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ } \ } G_STMT_END -#define _LOGD(addr_family, ...) _LOG (LOGL_DEBUG, addr_family, __VA_ARGS__) -#define _LOGI(addr_family, ...) _LOG (LOGL_INFO , addr_family, __VA_ARGS__) -#define _LOGW(addr_family, ...) _LOG (LOGL_WARN , addr_family, __VA_ARGS__) -#define _LOGE(addr_family, ...) _LOG (LOGL_ERR , addr_family, __VA_ARGS__) - #define LOG_ENTRY_FMT "entry[%u/%s:%p:%s:%c:%csync]" #define LOG_ENTRY_ARGS(entry_idx, entry) \ (entry_idx), \ @@ -1290,7 +1294,9 @@ _resync_idle_reschedule (NMDefaultRouteManager *self) g_source_remove (priv->resync.idle_handle); else _LOGD (0, "resync: schedule on idle"); - priv->resync.idle_handle = g_idle_add ((GSourceFunc) _resync_idle_now, self); + /* Schedule this at low priority so that on an external change to platform + * a NMDevice has a chance to picks up the changes first. */ + priv->resync.idle_handle = g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) _resync_idle_now, self, NULL); } else if (!priv->resync.idle_handle) { priv->resync.idle_handle = g_timeout_add (priv->resync.backoff_wait_time_ms, (GSourceFunc) _resync_idle_now, self); _LOGD (0, "resync: schedule in %u.%03u seconds (%u)", priv->resync.backoff_wait_time_ms/1000, diff --git a/src/nm-device-glue.h b/src/nm-device-glue.h index a740b7a77..c511c84c4 100644 --- a/src/nm-device-glue.h +++ b/src/nm-device-glue.h @@ -74,6 +74,6 @@ const DBusGObjectInfo dbus_glib_nm_device_object_info = { 1, 2, "org.freedesktop.NetworkManager.Device\0Disconnect\0A\0\0org.freedesktop.NetworkManager.Device\0Delete\0A\0\0\0", "org.freedesktop.NetworkManager.Device\0StateChanged\0\0", -"org.freedesktop.NetworkManager.Device\0Udi\0udi\0read\0org.freedesktop.NetworkManager.Device\0Interface\0interface\0read\0org.freedesktop.NetworkManager.Device\0IpInterface\0ip_interface\0read\0org.freedesktop.NetworkManager.Device\0Driver\0driver\0read\0org.freedesktop.NetworkManager.Device\0DriverVersion\0driver_version\0read\0org.freedesktop.NetworkManager.Device\0FirmwareVersion\0firmware_version\0read\0org.freedesktop.NetworkManager.Device\0Capabilities\0capabilities\0read\0org.freedesktop.NetworkManager.Device\0Ip4Address\0ip4_address\0read\0org.freedesktop.NetworkManager.Device\0State\0state\0read\0org.freedesktop.NetworkManager.Device\0StateReason\0state_reason\0read\0org.freedesktop.NetworkManager.Device\0ActiveConnection\0active_connection\0read\0org.freedesktop.NetworkManager.Device\0Ip4Config\0ip4_config\0read\0org.freedesktop.NetworkManager.Device\0Dhcp4Config\0dhcp4_config\0read\0org.freedesktop.NetworkManager.Device\0Ip6Config\0ip6_config\0read\0org.freedesktop.NetworkManager.Device\0Dhcp6Config\0dhcp6_config\0read\0org.freedesktop.NetworkManager.Device\0Managed\0managed\0read\0org.freedesktop.NetworkManager.Device\0Autoconnect\0autoconnect\0readwrite\0org.freedesktop.NetworkManager.Device\0FirmwareMissing\0firmware_missing\0read\0org.freedesktop.NetworkManager.Device\0DeviceType\0device_type\0read\0org.freedesktop.NetworkManager.Device\0AvailableConnections\0available_connections\0read\0org.freedesktop.NetworkManager.Device\0PhysicalPortId\0physical_port_id\0read\0org.freedesktop.NetworkManager.Device\0Mtu\0mtu\0read\0\0" +"org.freedesktop.NetworkManager.Device\0Udi\0udi\0read\0org.freedesktop.NetworkManager.Device\0Interface\0interface\0read\0org.freedesktop.NetworkManager.Device\0IpInterface\0ip_interface\0read\0org.freedesktop.NetworkManager.Device\0Driver\0driver\0read\0org.freedesktop.NetworkManager.Device\0DriverVersion\0driver_version\0read\0org.freedesktop.NetworkManager.Device\0FirmwareVersion\0firmware_version\0read\0org.freedesktop.NetworkManager.Device\0Capabilities\0capabilities\0read\0org.freedesktop.NetworkManager.Device\0Ip4Address\0ip4_address\0read\0org.freedesktop.NetworkManager.Device\0State\0state\0read\0org.freedesktop.NetworkManager.Device\0StateReason\0state_reason\0read\0org.freedesktop.NetworkManager.Device\0ActiveConnection\0active_connection\0read\0org.freedesktop.NetworkManager.Device\0Ip4Config\0ip4_config\0read\0org.freedesktop.NetworkManager.Device\0Dhcp4Config\0dhcp4_config\0read\0org.freedesktop.NetworkManager.Device\0Ip6Config\0ip6_config\0read\0org.freedesktop.NetworkManager.Device\0Dhcp6Config\0dhcp6_config\0read\0org.freedesktop.NetworkManager.Device\0Managed\0managed\0read\0org.freedesktop.NetworkManager.Device\0Autoconnect\0autoconnect\0readwrite\0org.freedesktop.NetworkManager.Device\0FirmwareMissing\0firmware_missing\0read\0org.freedesktop.NetworkManager.Device\0DeviceType\0device_type\0read\0org.freedesktop.NetworkManager.Device\0AvailableConnections\0available_connections\0read\0org.freedesktop.NetworkManager.Device\0PhysicalPortId\0physical_port_id\0read\0org.freedesktop.NetworkManager.Device\0Mtu\0mtu\0read\0org.freedesktop.NetworkManager.Device\0Metered\0metered\0read\0\0" }; diff --git a/src/nm-enum-types.c b/src/nm-enum-types.c index f92158d32..1ff959708 100644 --- a/src/nm-enum-types.c +++ b/src/nm-enum-types.c @@ -741,6 +741,26 @@ nm_pobject_type_get_type (void) return g_define_type_id__volatile; } GType +nm_ip_config_merge_flags_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GFlagsValue values[] = { + { NM_IP_CONFIG_MERGE_DEFAULT, "NM_IP_CONFIG_MERGE_DEFAULT", "default" }, + { NM_IP_CONFIG_MERGE_NO_ROUTES, "NM_IP_CONFIG_MERGE_NO_ROUTES", "no-routes" }, + { NM_IP_CONFIG_MERGE_NO_DNS, "NM_IP_CONFIG_MERGE_NO_DNS", "no-dns" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_flags_register_static (g_intern_static_string ("NMIPConfigMergeFlags"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType nm_match_spec_match_type_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; diff --git a/src/nm-enum-types.h b/src/nm-enum-types.h index 86f17f040..0997211e1 100644 --- a/src/nm-enum-types.h +++ b/src/nm-enum-types.h @@ -64,6 +64,8 @@ GType nm_link_type_get_type (void) G_GNUC_CONST; #define NM_TYPE_LINK_TYPE (nm_link_type_get_type ()) GType nm_pobject_type_get_type (void) G_GNUC_CONST; #define NM_TYPE_POBJECT_TYPE (nm_pobject_type_get_type ()) +GType nm_ip_config_merge_flags_get_type (void) G_GNUC_CONST; +#define NM_TYPE_IP_CONFIG_MERGE_FLAGS (nm_ip_config_merge_flags_get_type ()) GType nm_match_spec_match_type_get_type (void) G_GNUC_CONST; #define NM_TYPE_MATCH_SPEC_MATCH_TYPE (nm_match_spec_match_type_get_type ()) GType nm_utils_test_flags_get_type (void) G_GNUC_CONST; diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 2192f36ba..18966c579 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -87,6 +87,7 @@ dhcp4_state_changed (NMDhcpClient *client, NMDhcpState state, NMIP4Config *ip4_config, GHashTable *options, + const char *event_id, gpointer user_data) { static NMIP4Config *last_config = NULL; @@ -103,7 +104,7 @@ dhcp4_state_changed (NMDhcpClient *client, if (last_config) nm_ip4_config_subtract (existing, last_config); - nm_ip4_config_merge (existing, ip4_config); + nm_ip4_config_merge (existing, ip4_config, NM_IP_CONFIG_MERGE_DEFAULT); if (!nm_ip4_config_commit (existing, ifindex, TRUE, global_opt.priority_v4)) nm_log_warn (LOGD_DHCP4, "(%s): failed to apply DHCPv4 config", global_opt.ifname); @@ -240,7 +241,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da if (last_config) nm_ip6_config_subtract (existing, last_config); - nm_ip6_config_merge (existing, ip6_config); + nm_ip6_config_merge (existing, ip6_config, NM_IP_CONFIG_MERGE_DEFAULT); if (!nm_ip6_config_commit (existing, ifindex, TRUE)) nm_log_warn (LOGD_IP6, "(%s): failed to apply IPv6 config", global_opt.ifname); diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index db8c4b43e..5918f3dcb 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -35,6 +35,7 @@ #include "nm-core-internal.h" #include "nm-route-manager.h" #include "gsystem-local-alloc.h" +#include "nm-macros-internal.h" G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, G_TYPE_OBJECT) @@ -45,6 +46,7 @@ typedef struct { gboolean never_default; guint32 gateway; + gboolean has_gateway; GArray *addresses; GArray *routes; GArray *nameservers; @@ -56,6 +58,8 @@ typedef struct { GArray *wins; guint32 mtu; NMIPConfigSource mtu_source; + gint64 route_metric; + gboolean metered; } NMIP4ConfigPrivate; /* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */ @@ -185,7 +189,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) guint i; guint32 lowest_metric = G_MAXUINT32; guint32 old_gateway = 0; - gboolean has_gateway = FALSE; + gboolean old_has_gateway = FALSE; /* Slaves have no IP configuration */ if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0) @@ -202,6 +206,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) /* Extract gateway from default route */ old_gateway = priv->gateway; + old_has_gateway = priv->has_gateway; for (i = 0; i < priv->routes->len; ) { const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i); @@ -210,7 +215,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) priv->gateway = route->gateway; lowest_metric = route->metric; } - has_gateway = TRUE; + priv->has_gateway = TRUE; /* Remove the default route from the list */ g_array_remove_index_fast (priv->routes, i); continue; @@ -218,10 +223,14 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) i++; } + /* we detect the route metric based on the default route. All non-default + * routes have their route metrics explicitly set. */ + priv->route_metric = priv->has_gateway ? (gint64) lowest_metric : (gint64) -1; + /* If there is a host route to the gateway, ignore that route. It is * automatically added by NetworkManager when needed. */ - if (has_gateway) { + if (priv->has_gateway) { for (i = 0; i < priv->routes->len; i++) { const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i); @@ -237,7 +246,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) /* If the interface has the default route, and has IPv4 addresses, capture * nameservers from /etc/resolv.conf. */ - if (priv->addresses->len && has_gateway && capture_resolv_conf) { + if (priv->addresses->len && priv->has_gateway && capture_resolv_conf) { if (nm_ip4_config_capture_resolv_conf (priv->nameservers, NULL)) _NOTIFY (config, PROP_NAMESERVERS); } @@ -247,7 +256,8 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) _NOTIFY (config, PROP_ROUTE_DATA); _NOTIFY (config, PROP_ADDRESSES); _NOTIFY (config, PROP_ROUTES); - if (priv->gateway != old_gateway) + if ( priv->gateway != old_gateway + || priv->has_gateway != old_has_gateway) _NOTIFY (config, PROP_GATEWAY); return config; @@ -335,6 +345,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, guint32 default_route_metric) { + NMIP4ConfigPrivate *priv; guint naddresses, nroutes, nnameservers, nsearches; int i; @@ -343,6 +354,8 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting)); + priv = NM_IP4_CONFIG_GET_PRIVATE (config); + g_object_freeze_notify (G_OBJECT (config)); naddresses = nm_setting_ip_config_get_num_addresses (setting); @@ -362,6 +375,9 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu nm_ip4_config_set_gateway (config, gateway); } + if (priv->route_metric == -1) + priv->route_metric = nm_setting_ip_config_get_route_metric (setting); + /* Addresses */ for (i = 0; i < naddresses; i++) { NMIPAddress *s_addr = nm_setting_ip_config_get_address (setting, i); @@ -430,6 +446,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config) guint naddresses, nroutes, nnameservers, nsearches; const char *method = NULL; int i; + gint64 route_metric; s_ip4 = NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new ()); @@ -445,6 +462,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config) nroutes = nm_ip4_config_get_num_routes (config); nnameservers = nm_ip4_config_get_num_nameservers (config); nsearches = nm_ip4_config_get_num_searches (config); + route_metric = nm_ip4_config_get_route_metric (config); /* Addresses */ for (i = 0; i < naddresses; i++) { @@ -470,7 +488,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config) } /* Gateway */ - if ( gateway + if ( nm_ip4_config_has_gateway (config) && nm_setting_ip_config_get_num_addresses (s_ip4) > 0) { g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, nm_utils_inet4_ntop (gateway, NULL), @@ -480,7 +498,11 @@ nm_ip4_config_create_setting (const NMIP4Config *config) /* Use 'disabled' if the method wasn't previously set */ if (!method) method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, method, NULL); + + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_METHOD, method, + NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) route_metric, + NULL); /* Routes */ for (i = 0; i < nroutes; i++) { @@ -521,13 +543,17 @@ nm_ip4_config_create_setting (const NMIP4Config *config) /******************************************************************/ void -nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src) +nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFlags merge_flags) { + NMIP4ConfigPrivate *dst_priv, *src_priv; guint32 i; g_return_if_fail (src != NULL); g_return_if_fail (dst != NULL); + dst_priv = NM_IP4_CONFIG_GET_PRIVATE (dst); + src_priv = NM_IP4_CONFIG_GET_PRIVATE (src); + g_object_freeze_notify (G_OBJECT (dst)); /* addresses */ @@ -535,24 +561,37 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src) nm_ip4_config_add_address (dst, nm_ip4_config_get_address (src, i)); /* nameservers */ - for (i = 0; i < nm_ip4_config_get_num_nameservers (src); i++) - nm_ip4_config_add_nameserver (dst, nm_ip4_config_get_nameserver (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { + for (i = 0; i < nm_ip4_config_get_num_nameservers (src); i++) + nm_ip4_config_add_nameserver (dst, nm_ip4_config_get_nameserver (src, i)); + } /* default gateway */ - if (nm_ip4_config_get_gateway (src)) + if (nm_ip4_config_has_gateway (src)) nm_ip4_config_set_gateway (dst, nm_ip4_config_get_gateway (src)); /* routes */ - for (i = 0; i < nm_ip4_config_get_num_routes (src); i++) - nm_ip4_config_add_route (dst, nm_ip4_config_get_route (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_ROUTES)) { + for (i = 0; i < nm_ip4_config_get_num_routes (src); i++) + nm_ip4_config_add_route (dst, nm_ip4_config_get_route (src, i)); + } + + if (dst_priv->route_metric == -1) + dst_priv->route_metric = src_priv->route_metric; + else if (src_priv->route_metric != -1) + dst_priv->route_metric = MIN (dst_priv->route_metric, src_priv->route_metric); /* domains */ - for (i = 0; i < nm_ip4_config_get_num_domains (src); i++) - nm_ip4_config_add_domain (dst, nm_ip4_config_get_domain (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { + for (i = 0; i < nm_ip4_config_get_num_domains (src); i++) + nm_ip4_config_add_domain (dst, nm_ip4_config_get_domain (src, i)); + } /* dns searches */ - for (i = 0; i < nm_ip4_config_get_num_searches (src); i++) - nm_ip4_config_add_search (dst, nm_ip4_config_get_search (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { + for (i = 0; i < nm_ip4_config_get_num_searches (src); i++) + nm_ip4_config_add_search (dst, nm_ip4_config_get_search (src, i)); + } /* MSS */ if (nm_ip4_config_get_mss (src)) @@ -564,15 +603,23 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src) nm_ip4_config_get_mtu_source (src)); /* NIS */ - for (i = 0; i < nm_ip4_config_get_num_nis_servers (src); i++) - nm_ip4_config_add_nis_server (dst, nm_ip4_config_get_nis_server (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { + for (i = 0; i < nm_ip4_config_get_num_nis_servers (src); i++) + nm_ip4_config_add_nis_server (dst, nm_ip4_config_get_nis_server (src, i)); - if (nm_ip4_config_get_nis_domain (src)) - nm_ip4_config_set_nis_domain (dst, nm_ip4_config_get_nis_domain (src)); + if (nm_ip4_config_get_nis_domain (src)) + nm_ip4_config_set_nis_domain (dst, nm_ip4_config_get_nis_domain (src)); + } /* WINS */ - for (i = 0; i < nm_ip4_config_get_num_wins (src); i++) - nm_ip4_config_add_wins (dst, nm_ip4_config_get_wins (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { + for (i = 0; i < nm_ip4_config_get_num_wins (src); i++) + nm_ip4_config_add_wins (dst, nm_ip4_config_get_wins (src, i)); + } + + /* metered flag */ + nm_ip4_config_set_metered (dst, nm_ip4_config_get_metered (dst) || + nm_ip4_config_get_metered (src)); g_object_thaw_notify (G_OBJECT (dst)); } @@ -721,11 +768,14 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src) } /* default gateway */ - if (nm_ip4_config_get_gateway (src) == nm_ip4_config_get_gateway (dst)) - nm_ip4_config_set_gateway (dst, 0); + if ( (nm_ip4_config_has_gateway (src) == nm_ip4_config_has_gateway (dst)) + && (nm_ip4_config_get_gateway (src) == nm_ip4_config_get_gateway (dst))) + nm_ip4_config_unset_gateway (dst); if (!nm_ip4_config_get_num_addresses (dst)) - nm_ip4_config_set_gateway (dst, 0); + nm_ip4_config_unset_gateway (dst); + + /* ignore route_metric */ /* routes */ for (i = 0; i < nm_ip4_config_get_num_routes (src); i++) { @@ -796,12 +846,15 @@ nm_ip4_config_intersect (NMIP4Config *dst, const NMIP4Config *src) i++; } + /* ignore route_metric */ /* ignore nameservers */ /* default gateway */ if ( !nm_ip4_config_get_num_addresses (dst) - || (nm_ip4_config_get_gateway (src) != nm_ip4_config_get_gateway (dst))) - nm_ip4_config_set_gateway (dst, 0); + || (nm_ip4_config_has_gateway (src) != nm_ip4_config_has_gateway (dst)) + || (nm_ip4_config_get_gateway (src) != nm_ip4_config_get_gateway (dst))) { + nm_ip4_config_unset_gateway (dst); + } /* routes */ for (i = 0; i < nm_ip4_config_get_num_routes (dst); ) { @@ -867,11 +920,17 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev } /* default gateway */ - if (src_priv->gateway != dst_priv->gateway) { + if ( src_priv->gateway != dst_priv->gateway + || src_priv->has_gateway != dst_priv->has_gateway) { nm_ip4_config_set_gateway (dst, src_priv->gateway); has_relevant_changes = TRUE; } + if (src_priv->route_metric != dst_priv->route_metric) { + dst_priv->route_metric = src_priv->route_metric; + has_minor_changes = TRUE; + } + /* addresses */ num = nm_ip4_config_get_num_addresses (src); are_equal = num == nm_ip4_config_get_num_addresses (dst); @@ -1028,6 +1087,12 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev has_minor_changes = TRUE; } + /* metered */ + if (src_priv->metered != dst_priv->metered) { + dst_priv->metered = src_priv->metered; + has_minor_changes = TRUE; + } + /* config_equal does not compare *all* the fields, therefore, we might have has_minor_changes * regardless of config_equal. But config_equal must correspond to has_relevant_changes. */ g_assert (config_equal == !has_relevant_changes); @@ -1059,8 +1124,10 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail) g_message (" a: %s", nm_platform_ip4_address_to_string (nm_ip4_config_get_address (config, i))); /* default gateway */ - tmp = nm_ip4_config_get_gateway (config); - g_message (" gw: %s", nm_utils_inet4_ntop (tmp, NULL)); + if (nm_ip4_config_has_gateway (config)) { + tmp = nm_ip4_config_get_gateway (config); + g_message (" gw: %s", nm_utils_inet4_ntop (tmp, NULL)); + } /* nameservers */ for (i = 0; i < nm_ip4_config_get_num_nameservers (config); i++) { @@ -1098,6 +1165,7 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail) } g_message (" n-dflt: %d", nm_ip4_config_get_never_default (config)); + g_message (" mtrd: %d", (int) nm_ip4_config_get_metered (config)); } gboolean @@ -1139,12 +1207,33 @@ nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (priv->gateway != gateway) { + if (priv->gateway != gateway || !priv->has_gateway) { priv->gateway = gateway; + priv->has_gateway = TRUE; _NOTIFY (config, PROP_GATEWAY); } } +void +nm_ip4_config_unset_gateway (NMIP4Config *config) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + + if (priv->has_gateway) { + priv->gateway = 0; + priv->has_gateway = FALSE; + _NOTIFY (config, PROP_GATEWAY); + } +} + +gboolean +nm_ip4_config_has_gateway (const NMIP4Config *config) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + + return priv->has_gateway; +} + guint32 nm_ip4_config_get_gateway (const NMIP4Config *config) { @@ -1153,6 +1242,14 @@ nm_ip4_config_get_gateway (const NMIP4Config *config) return priv->gateway; } +gint64 +nm_ip4_config_get_route_metric (const NMIP4Config *config) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + + return priv->route_metric; +} + /******************************************************************/ void @@ -1744,6 +1841,24 @@ nm_ip4_config_get_mtu_source (const NMIP4Config *config) /******************************************************************/ +void +nm_ip4_config_set_metered (NMIP4Config *config, gboolean metered) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + + priv->metered = !!metered; +} + +gboolean +nm_ip4_config_get_metered (const NMIP4Config *config) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + + return priv->metered; +} + +/******************************************************************/ + static inline void hash_u32 (GChecksum *sum, guint32 n) { @@ -1760,6 +1875,7 @@ nm_ip4_config_hash (const NMIP4Config *config, GChecksum *sum, gboolean dns_only g_return_if_fail (sum); if (!dns_only) { + hash_u32 (sum, nm_ip4_config_has_gateway (config)); hash_u32 (sum, nm_ip4_config_get_gateway (config)); for (i = 0; i < nm_ip4_config_get_num_addresses (config); i++) { @@ -1856,6 +1972,7 @@ nm_ip4_config_init (NMIP4Config *config) priv->searches = g_ptr_array_new_with_free_func (g_free); priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32)); priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32)); + priv->route_metric = -1; } static void @@ -2020,7 +2137,7 @@ get_property (GObject *object, guint prop_id, } break; case PROP_GATEWAY: - if (priv->gateway) + if (priv->has_gateway) g_value_set_string (value, nm_utils_inet4_ntop (priv->gateway, NULL)); else g_value_set_string (value, NULL); diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h index 463675244..cb3038aab 100644 --- a/src/nm-ip4-config.h +++ b/src/nm-ip4-config.h @@ -69,7 +69,7 @@ void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *settin NMSetting *nm_ip4_config_create_setting (const NMIP4Config *config); /* Utility functions */ -void nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src); +void nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFlags merge_flags); void nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src); void nm_ip4_config_intersect (NMIP4Config *dst, const NMIP4Config *src); gboolean nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes); @@ -80,7 +80,10 @@ void nm_ip4_config_dump (const NMIP4Config *config, const char *detail); void nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default); gboolean nm_ip4_config_get_never_default (const NMIP4Config *config); void nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway); +void nm_ip4_config_unset_gateway (NMIP4Config *config); +gboolean nm_ip4_config_has_gateway (const NMIP4Config *config); guint32 nm_ip4_config_get_gateway (const NMIP4Config *config); +gint64 nm_ip4_config_get_route_metric (const NMIP4Config *config); /* Addresses */ void nm_ip4_config_reset_addresses (NMIP4Config *config); @@ -146,6 +149,10 @@ void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu, NMIPConfigSource s guint32 nm_ip4_config_get_mtu (const NMIP4Config *config); NMIPConfigSource nm_ip4_config_get_mtu_source (const NMIP4Config *config); +/* Metered */ +void nm_ip4_config_set_metered (NMIP4Config *config, gboolean metered); +gboolean nm_ip4_config_get_metered (const NMIP4Config *config); + void nm_ip4_config_hash (const NMIP4Config *config, GChecksum *sum, gboolean dns_only); gboolean nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b); diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 48aeb64ae..9647268d0 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -34,6 +34,7 @@ #include "nm-ip6-config-glue.h" #include "nm-route-manager.h" #include "NetworkManagerUtils.h" +#include "nm-macros-internal.h" G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, G_TYPE_OBJECT) @@ -50,6 +51,7 @@ typedef struct { GPtrArray *domains; GPtrArray *searches; guint32 mss; + gint64 route_metric; } NMIP6ConfigPrivate; @@ -329,6 +331,10 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co i++; } + /* we detect the route metric based on the default route. All non-default + * routes have their route metrics explicitly set. */ + priv->route_metric = has_gateway ? (gint64) lowest_metric : (gint64) -1; + /* If there is a host route to the gateway, ignore that route. It is * automatically added by NetworkManager when needed. */ @@ -408,6 +414,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_fu void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, guint32 default_route_metric) { + NMIP6ConfigPrivate *priv; guint naddresses, nroutes, nnameservers, nsearches; const char *gateway_str; int i; @@ -417,6 +424,8 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting)); + priv = NM_IP6_CONFIG_GET_PRIVATE (config); + naddresses = nm_setting_ip_config_get_num_addresses (setting); nroutes = nm_setting_ip_config_get_num_routes (setting); nnameservers = nm_setting_ip_config_get_num_dns (setting); @@ -437,6 +446,9 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu nm_ip6_config_set_gateway (config, &gateway); } + if (priv->route_metric == -1) + priv->route_metric = nm_setting_ip_config_get_route_metric (setting); + /* Addresses */ for (i = 0; i < naddresses; i++) { NMIPAddress *s_addr = nm_setting_ip_config_get_address (setting, i); @@ -500,6 +512,7 @@ nm_ip6_config_create_setting (const NMIP6Config *config) guint naddresses, nroutes, nnameservers, nsearches; const char *method = NULL; int i; + gint64 route_metric; s_ip6 = NM_SETTING_IP_CONFIG (nm_setting_ip6_config_new ()); @@ -515,6 +528,7 @@ nm_ip6_config_create_setting (const NMIP6Config *config) nroutes = nm_ip6_config_get_num_routes (config); nnameservers = nm_ip6_config_get_num_nameservers (config); nsearches = nm_ip6_config_get_num_searches (config); + route_metric = nm_ip6_config_get_route_metric (config); /* Addresses */ for (i = 0; i < naddresses; i++) { @@ -554,7 +568,11 @@ nm_ip6_config_create_setting (const NMIP6Config *config) /* Use 'ignore' if the method wasn't previously set */ if (!method) method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, method, NULL); + + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, method, + NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) route_metric, + NULL); /* Routes */ for (i = 0; i < nroutes; i++) { @@ -599,13 +617,17 @@ nm_ip6_config_create_setting (const NMIP6Config *config) /******************************************************************/ void -nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src) +nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFlags merge_flags) { + NMIP6ConfigPrivate *dst_priv, *src_priv; guint32 i; g_return_if_fail (src != NULL); g_return_if_fail (dst != NULL); + dst_priv = NM_IP6_CONFIG_GET_PRIVATE (dst); + src_priv = NM_IP6_CONFIG_GET_PRIVATE (src); + g_object_freeze_notify (G_OBJECT (dst)); /* addresses */ @@ -621,16 +643,27 @@ nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src) nm_ip6_config_set_gateway (dst, nm_ip6_config_get_gateway (src)); /* routes */ - for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) - nm_ip6_config_add_route (dst, nm_ip6_config_get_route (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_ROUTES)) { + for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) + nm_ip6_config_add_route (dst, nm_ip6_config_get_route (src, i)); + } + + if (dst_priv->route_metric == -1) + dst_priv->route_metric = src_priv->route_metric; + else if (src_priv->route_metric != -1) + dst_priv->route_metric = MIN (dst_priv->route_metric, src_priv->route_metric); /* domains */ - for (i = 0; i < nm_ip6_config_get_num_domains (src); i++) - nm_ip6_config_add_domain (dst, nm_ip6_config_get_domain (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { + for (i = 0; i < nm_ip6_config_get_num_domains (src); i++) + nm_ip6_config_add_domain (dst, nm_ip6_config_get_domain (src, i)); + } /* dns searches */ - for (i = 0; i < nm_ip6_config_get_num_searches (src); i++) - nm_ip6_config_add_search (dst, nm_ip6_config_get_search (src, i)); + if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { + for (i = 0; i < nm_ip6_config_get_num_searches (src); i++) + nm_ip6_config_add_search (dst, nm_ip6_config_get_search (src, i)); + } if (nm_ip6_config_get_mss (src)) nm_ip6_config_set_mss (dst, nm_ip6_config_get_mss (src)); @@ -776,6 +809,8 @@ nm_ip6_config_subtract (NMIP6Config *dst, const NMIP6Config *src) if (!nm_ip6_config_get_num_addresses (dst)) nm_ip6_config_set_gateway (dst, NULL); + /* ignore route_metric */ + /* routes */ for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) { idx = _routes_get_index (dst, nm_ip6_config_get_route (src, i)); @@ -824,6 +859,7 @@ nm_ip6_config_intersect (NMIP6Config *dst, const NMIP6Config *src) i++; } + /* ignore route_metric */ /* ignore nameservers */ /* default gateway */ @@ -902,6 +938,11 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev has_relevant_changes = TRUE; } + if (src_priv->route_metric != dst_priv->route_metric) { + dst_priv->route_metric = src_priv->route_metric; + has_minor_changes = TRUE; + } + /* addresses */ num = nm_ip6_config_get_num_addresses (src); are_equal = num == nm_ip6_config_get_num_addresses (dst); @@ -1112,6 +1153,14 @@ nm_ip6_config_get_gateway (const NMIP6Config *config) return IN6_IS_ADDR_UNSPECIFIED (&priv->gateway) ? NULL : &priv->gateway; } +gint64 +nm_ip6_config_get_route_metric (const NMIP6Config *config) +{ + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); + + return priv->route_metric; +} + /******************************************************************/ void @@ -1672,6 +1721,7 @@ nm_ip6_config_init (NMIP6Config *config) priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr)); priv->domains = g_ptr_array_new_with_free_func (g_free); priv->searches = g_ptr_array_new_with_free_func (g_free); + priv->route_metric = -1; } static void diff --git a/src/nm-ip6-config.h b/src/nm-ip6-config.h index 66f15888c..279f89a70 100644 --- a/src/nm-ip6-config.h +++ b/src/nm-ip6-config.h @@ -69,7 +69,7 @@ void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *settin NMSetting *nm_ip6_config_create_setting (const NMIP6Config *config); /* Utility functions */ -void nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src); +void nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFlags merge_flags); void nm_ip6_config_subtract (NMIP6Config *dst, const NMIP6Config *src); void nm_ip6_config_intersect (NMIP6Config *dst, const NMIP6Config *src); gboolean nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relevant_changes); @@ -81,6 +81,7 @@ void nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_defaul gboolean nm_ip6_config_get_never_default (const NMIP6Config *config); void nm_ip6_config_set_gateway (NMIP6Config *config, const struct in6_addr *); const struct in6_addr *nm_ip6_config_get_gateway (const NMIP6Config *config); +gint64 nm_ip6_config_get_route_metric (const NMIP6Config *config); /* Addresses */ void nm_ip6_config_reset_addresses (NMIP6Config *config); diff --git a/src/nm-logging.h b/src/nm-logging.h index 82a4e71f4..402180626 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -167,4 +167,35 @@ gboolean nm_logging_setup (const char *level, void nm_logging_syslog_openlog (gboolean debug); void nm_logging_syslog_closelog (void); +/*****************************************************************************/ + +/* This is the default definition of _NMLOG_ENABLED(). Special implementations + * might want to undef this and redefine it. */ +#define _NMLOG_ENABLED(level) ( nm_logging_enabled ((level), (_NMLOG_DOMAIN)) ) + +#define _LOGt(...) _NMLOG (LOGL_TRACE, __VA_ARGS__) +#define _LOGD(...) _NMLOG (LOGL_DEBUG, __VA_ARGS__) +#define _LOGI(...) _NMLOG (LOGL_INFO , __VA_ARGS__) +#define _LOGW(...) _NMLOG (LOGL_WARN , __VA_ARGS__) +#define _LOGE(...) _NMLOG (LOGL_ERR , __VA_ARGS__) + +#define _LOGt_ENABLED(...) _NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOGD_ENABLED(...) _NMLOG_ENABLED (LOGL_DEBUG, ##__VA_ARGS__) +#define _LOGI_ENABLED(...) _NMLOG_ENABLED (LOGL_INFO , ##__VA_ARGS__) +#define _LOGW_ENABLED(...) _NMLOG_ENABLED (LOGL_WARN , ##__VA_ARGS__) +#define _LOGE_ENABLED(...) _NMLOG_ENABLED (LOGL_ERR , ##__VA_ARGS__) + +/* _LOGt() and _LOGT() both log with level TRACE, but the latter is disabled by default, + * unless building with --with-more-logging. */ +#ifdef NM_MORE_LOGGING +#define _LOGT_ENABLED(...) _NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOGT(...) _NMLOG (LOGL_TRACE, __VA_ARGS__) +#else +/* still call the logging macros to get compile time checks, but they will be optimize out. */ +#define _LOGT_ENABLED(...) ( FALSE && (_NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__)) ) +#define _LOGT(...) G_STMT_START { if (FALSE) { _NMLOG (LOGL_TRACE, __VA_ARGS__); } } G_STMT_END +#endif + +/*****************************************************************************/ + #endif /* __NETWORKMANAGER_LOGGING_H__ */ diff --git a/src/nm-manager-glue.h b/src/nm-manager-glue.h index d907f4d24..f7840c9f8 100644 --- a/src/nm-manager-glue.h +++ b/src/nm-manager-glue.h @@ -411,6 +411,6 @@ const DBusGObjectInfo dbus_glib_nm_manager_object_info = { 1, 12, "org.freedesktop.NetworkManager\0GetDevices\0S\0devices\0O\0F\0N\0ao\0\0org.freedesktop.NetworkManager\0GetDeviceByIpIface\0S\0iface\0I\0s\0device\0O\0F\0N\0o\0\0org.freedesktop.NetworkManager\0ActivateConnection\0A\0connection\0I\0o\0device\0I\0o\0specific_object\0I\0o\0active_connection\0O\0F\0N\0o\0\0org.freedesktop.NetworkManager\0AddAndActivateConnection\0A\0connection\0I\0a{sa{sv}}\0device\0I\0o\0specific_object\0I\0o\0path\0O\0F\0N\0o\0active_connection\0O\0F\0N\0o\0\0org.freedesktop.NetworkManager\0DeactivateConnection\0A\0active_connection\0I\0o\0\0org.freedesktop.NetworkManager\0Sleep\0A\0sleep\0I\0b\0\0org.freedesktop.NetworkManager\0Enable\0A\0enable\0I\0b\0\0org.freedesktop.NetworkManager\0GetPermissions\0A\0permissions\0O\0F\0N\0a{ss}\0\0org.freedesktop.NetworkManager\0SetLogging\0A\0level\0I\0s\0domains\0I\0s\0\0org.freedesktop.NetworkManager\0GetLogging\0S\0level\0O\0F\0N\0s\0domains\0O\0F\0N\0s\0\0org.freedesktop.NetworkManager\0CheckConnectivity\0A\0connectivity\0O\0F\0N\0u\0\0org.freedesktop.NetworkManager\0state\0S\0state\0O\0F\0N\0u\0\0\0", "org.freedesktop.NetworkManager\0CheckPermissions\0org.freedesktop.NetworkManager\0StateChanged\0org.freedesktop.NetworkManager\0PropertiesChanged\0org.freedesktop.NetworkManager\0DeviceAdded\0org.freedesktop.NetworkManager\0DeviceRemoved\0\0", -"org.freedesktop.NetworkManager\0Devices\0devices\0read\0org.freedesktop.NetworkManager\0NetworkingEnabled\0networking_enabled\0read\0org.freedesktop.NetworkManager\0WirelessEnabled\0wireless_enabled\0readwrite\0org.freedesktop.NetworkManager\0WirelessHardwareEnabled\0wireless_hardware_enabled\0read\0org.freedesktop.NetworkManager\0WwanEnabled\0wwan_enabled\0readwrite\0org.freedesktop.NetworkManager\0WwanHardwareEnabled\0wwan_hardware_enabled\0read\0org.freedesktop.NetworkManager\0WimaxEnabled\0wimax_enabled\0readwrite\0org.freedesktop.NetworkManager\0WimaxHardwareEnabled\0wimax_hardware_enabled\0read\0org.freedesktop.NetworkManager\0ActiveConnections\0active_connections\0read\0org.freedesktop.NetworkManager\0PrimaryConnection\0primary_connection\0read\0org.freedesktop.NetworkManager\0PrimaryConnectionType\0primary_connection_type\0read\0org.freedesktop.NetworkManager\0ActivatingConnection\0activating_connection\0read\0org.freedesktop.NetworkManager\0Startup\0startup\0read\0org.freedesktop.NetworkManager\0Version\0version\0read\0org.freedesktop.NetworkManager\0State\0state\0read\0org.freedesktop.NetworkManager\0Connectivity\0connectivity\0read\0\0" +"org.freedesktop.NetworkManager\0Devices\0devices\0read\0org.freedesktop.NetworkManager\0NetworkingEnabled\0networking_enabled\0read\0org.freedesktop.NetworkManager\0WirelessEnabled\0wireless_enabled\0readwrite\0org.freedesktop.NetworkManager\0WirelessHardwareEnabled\0wireless_hardware_enabled\0read\0org.freedesktop.NetworkManager\0WwanEnabled\0wwan_enabled\0readwrite\0org.freedesktop.NetworkManager\0WwanHardwareEnabled\0wwan_hardware_enabled\0read\0org.freedesktop.NetworkManager\0WimaxEnabled\0wimax_enabled\0readwrite\0org.freedesktop.NetworkManager\0WimaxHardwareEnabled\0wimax_hardware_enabled\0read\0org.freedesktop.NetworkManager\0ActiveConnections\0active_connections\0read\0org.freedesktop.NetworkManager\0PrimaryConnection\0primary_connection\0read\0org.freedesktop.NetworkManager\0PrimaryConnectionType\0primary_connection_type\0read\0org.freedesktop.NetworkManager\0Metered\0metered\0read\0org.freedesktop.NetworkManager\0ActivatingConnection\0activating_connection\0read\0org.freedesktop.NetworkManager\0Startup\0startup\0read\0org.freedesktop.NetworkManager\0Version\0version\0read\0org.freedesktop.NetworkManager\0State\0state\0read\0org.freedesktop.NetworkManager\0Connectivity\0connectivity\0read\0\0" }; diff --git a/src/nm-manager.c b/src/nm-manager.c index 080cdb8b2..34ec0819d 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -161,6 +161,7 @@ typedef struct { guint ac_cleanup_id; NMActiveConnection *primary_connection; NMActiveConnection *activating_connection; + NMMetered metered; GSList *devices; NMState state; @@ -170,7 +171,6 @@ typedef struct { NMPolicy *policy; NMDBusManager *dbus_mgr; - gboolean prop_filter_added; NMRfkillManager *rfkill_mgr; NMSettings *settings; @@ -194,6 +194,7 @@ typedef struct { guint timestamp_update_id; gboolean startup; + gboolean devices_inited; } NMManagerPrivate; #define NM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MANAGER, NMManagerPrivate)) @@ -233,6 +234,7 @@ enum { PROP_PRIMARY_CONNECTION_TYPE, PROP_ACTIVATING_CONNECTION, PROP_DEVICES, + PROP_METERED, /* Not exported */ PROP_HOSTNAME, @@ -658,6 +660,30 @@ find_best_device_state (NMManager *manager) } static void +nm_manager_update_metered (NMManager *manager) +{ + NMManagerPrivate *priv; + NMDevice *device; + NMMetered value = NM_METERED_UNKNOWN; + + g_return_if_fail (NM_IS_MANAGER (manager)); + priv = NM_MANAGER_GET_PRIVATE (manager); + + if (priv->primary_connection) { + device = nm_active_connection_get_device (priv->primary_connection); + if (device) + value = nm_device_get_metered (device); + } + + if (value != priv->metered) { + priv->metered = value; + nm_log_dbg (LOGD_CORE, "New manager metered value: %d", + (int) priv->metered); + g_object_notify (G_OBJECT (manager), NM_MANAGER_METERED); + } +} + +static void nm_manager_update_state (NMManager *manager) { NMManagerPrivate *priv; @@ -718,6 +744,9 @@ check_if_startup_complete (NMManager *self) if (!priv->startup) return; + if (!priv->devices_inited) + return; + if (!nm_settings_get_startup_complete (priv->settings)) { nm_log_dbg (LOGD_CORE, "check_if_startup_complete returns FALSE because of NMSettings"); return; @@ -1159,18 +1188,26 @@ system_hostname_changed_cb (NMSettings *settings, char *hostname; hostname = nm_settings_get_hostname (priv->settings); + + /* nm_settings_get_hostname() does not return an empty hostname. */ + nm_assert (!hostname || *hostname); + if (!hostname && !priv->hostname) return; - if (hostname && priv->hostname && !strcmp (hostname, priv->hostname)) + if (hostname && priv->hostname && !strcmp (hostname, priv->hostname)) { + g_free (hostname); return; + } + + /* realloc, to free possibly trailing data after NUL. */ + if (hostname) + hostname = g_realloc (hostname, strlen (hostname) + 1); g_free (priv->hostname); - priv->hostname = (hostname && strlen (hostname)) ? g_strdup (hostname) : NULL; + priv->hostname = hostname; g_object_notify (G_OBJECT (self), NM_MANAGER_HOSTNAME); nm_dhcp_manager_set_default_hostname (nm_dhcp_manager_get (), priv->hostname); - - g_free (hostname); } /*******************************************************************/ @@ -4173,6 +4210,8 @@ nm_manager_start (NMManager *self) */ system_create_virtual_devices (self); + priv->devices_inited = TRUE; + check_if_startup_complete (self); } @@ -4260,6 +4299,14 @@ firmware_dir_changed (GFileMonitor *monitor, } static void +connection_metered_changed (GObject *object, + NMMetered metered, + gpointer user_data) +{ + nm_manager_update_metered (NM_MANAGER (user_data)); +} + +static void policy_default_device_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { NMManager *self = NM_MANAGER (user_data); @@ -4281,11 +4328,23 @@ policy_default_device_changed (GObject *object, GParamSpec *pspec, gpointer user ac = NULL; if (ac != priv->primary_connection) { - g_clear_object (&priv->primary_connection); + if (priv->primary_connection) { + g_signal_handlers_disconnect_by_func (priv->primary_connection, + G_CALLBACK (connection_metered_changed), + self); + g_clear_object (&priv->primary_connection); + } + priv->primary_connection = ac ? g_object_ref (ac) : NULL; + + if (priv->primary_connection) { + g_signal_connect (priv->primary_connection, NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED, + G_CALLBACK (connection_metered_changed), self); + } nm_log_dbg (LOGD_CORE, "PrimaryConnection now %s", ac ? nm_active_connection_get_id (ac) : "(none)"); g_object_notify (G_OBJECT (self), NM_MANAGER_PRIMARY_CONNECTION); g_object_notify (G_OBJECT (self), NM_MANAGER_PRIMARY_CONNECTION_TYPE); + nm_manager_update_metered (self); } } @@ -4625,17 +4684,13 @@ dbus_connection_changed_cb (NMDBusManager *dbus_mgr, gpointer user_data) { NMManager *self = NM_MANAGER (user_data); - gboolean success = FALSE; + gboolean success; if (dbus_connection) { - /* Register property filter on new connection; there's no reason this - * should fail except out-of-memory or program error; if it does fail - * then there's no Manager property access control, which is bad. - */ + /* Only fails on ENOMEM */ success = dbus_connection_add_filter (dbus_connection, prop_filter, self, NULL); g_assert (success); } - NM_MANAGER_GET_PRIVATE (self)->prop_filter_added = success; } /**********************************************************************/ @@ -4663,11 +4718,9 @@ nm_manager_new (NMSettings *settings, gboolean initial_net_enabled, gboolean initial_wifi_enabled, gboolean initial_wwan_enabled, - gboolean initial_wimax_enabled, - GError **error) + gboolean initial_wimax_enabled) { NMManagerPrivate *priv; - DBusGConnection *bus; DBusConnection *dbus_connection; NMConfigData *config_data; @@ -4680,16 +4733,14 @@ nm_manager_new (NMSettings *settings, priv = NM_MANAGER_GET_PRIVATE (singleton); - bus = nm_dbus_manager_get_connection (priv->dbus_mgr); - if (!bus) { - g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, - "Failed to initialize D-Bus connection"); - g_object_unref (singleton); - return NULL; - } + dbus_connection = nm_dbus_manager_get_dbus_connection (priv->dbus_mgr); + if (dbus_connection) { + gboolean success; - dbus_connection = dbus_g_connection_get_connection (bus); - g_assert (dbus_connection); + /* Only fails on ENOMEM */ + success = dbus_connection_add_filter (dbus_connection, prop_filter, singleton, NULL); + g_assert (success); + } priv->policy = nm_policy_new (singleton, settings); g_signal_connect (priv->policy, "notify::" NM_POLICY_DEFAULT_IP4_DEVICE, @@ -4714,14 +4765,6 @@ nm_manager_new (NMSettings *settings, g_signal_connect (priv->connectivity, "notify::" NM_CONNECTIVITY_STATE, G_CALLBACK (connectivity_changed), singleton); - if (!dbus_connection_add_filter (dbus_connection, prop_filter, singleton, NULL)) { - g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, - "Failed to register DBus connection filter"); - g_object_unref (singleton); - return NULL; - } - priv->prop_filter_added = TRUE; - priv->settings = g_object_ref (settings); g_signal_connect (priv->settings, "notify::" NM_SETTINGS_STARTUP_COMPLETE, G_CALLBACK (settings_startup_complete_changed), singleton); @@ -4879,6 +4922,8 @@ nm_manager_init (NMManager *manager) /* Update timestamps in active connections */ priv->timestamp_update_id = g_timeout_add_seconds (300, (GSourceFunc) periodic_update_active_connection_timestamps, manager); + + priv->metered = NM_METERED_UNKNOWN; } static void @@ -4963,6 +5008,9 @@ get_property (GObject *object, guint prop_id, } g_value_take_boxed (value, array); break; + case PROP_METERED: + g_value_set_uint (value, priv->metered); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -5013,7 +5061,6 @@ dispose (GObject *object) { NMManager *manager = NM_MANAGER (object); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); - DBusGConnection *bus; DBusConnection *dbus_connection; g_slist_free_full (priv->auth_chains, (GDestroyNotify) nm_auth_chain_unref); @@ -5059,14 +5106,9 @@ dispose (GObject *object) /* Unregister property filter */ if (priv->dbus_mgr) { - bus = nm_dbus_manager_get_connection (priv->dbus_mgr); - if (bus) { - dbus_connection = dbus_g_connection_get_connection (bus); - if (dbus_connection && priv->prop_filter_added) { - dbus_connection_remove_filter (dbus_connection, prop_filter, manager); - priv->prop_filter_added = FALSE; - } - } + dbus_connection = nm_dbus_manager_get_dbus_connection (priv->dbus_mgr); + if (dbus_connection) + dbus_connection_remove_filter (dbus_connection, prop_filter, manager); g_signal_handlers_disconnect_by_func (priv->dbus_mgr, dbus_connection_changed_cb, manager); priv->dbus_mgr = NULL; } @@ -5238,6 +5280,20 @@ nm_manager_class_init (NMManagerClass *manager_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMManager:metered: + * + * Whether the connectivity is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_uint (NM_MANAGER_METERED, "", "", + 0, G_MAXUINT32, NM_METERED_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /* signals */ signals[DEVICE_ADDED] = g_signal_new ("device-added", diff --git a/src/nm-manager.h b/src/nm-manager.h index 3b00e8053..711bcce82 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -51,6 +51,7 @@ #define NM_MANAGER_PRIMARY_CONNECTION_TYPE "primary-connection-type" #define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection" #define NM_MANAGER_DEVICES "devices" +#define NM_MANAGER_METERED "metered" /* Not exported */ #define NM_MANAGER_HOSTNAME "hostname" @@ -83,8 +84,7 @@ NMManager * nm_manager_new (NMSettings *settings, gboolean initial_net_enabled, gboolean initial_wifi_enabled, gboolean initial_wwan_enabled, - gboolean initial_wimax_enabled, - GError **error); + gboolean initial_wimax_enabled); NMManager * nm_manager_get (void); diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c index 5ee6c8654..b392fc176 100644 --- a/src/nm-route-manager.c +++ b/src/nm-route-manager.c @@ -18,10 +18,10 @@ * Copyright (C) 2015 Red Hat, Inc. */ -#include <string.h> - #include "config.h" +#include <string.h> + #include "nm-route-manager.h" #include "nm-platform.h" #include "nmp-object.h" @@ -112,9 +112,17 @@ static const VTableIP vtable_v4, vtable_v6; /*********************************************************************************************/ -#define _LOG_PREFIX_NAME "route-mgr" - -#define _LOG(level, addr_family, ...) \ +#define _NMLOG_PREFIX_NAME "route-mgr" +#undef _NMLOG_ENABLED +#define _NMLOG_ENABLED(level, addr_family) \ + ({ \ + const int __addr_family = (addr_family); \ + const NMLogLevel __level = (level); \ + const NMLogDomain __domain = __addr_family == AF_INET ? LOGD_IP4 : (__addr_family == AF_INET6 ? LOGD_IP6 : LOGD_IP); \ + \ + nm_logging_enabled (__level, __domain); \ + }) +#define _NMLOG(level, addr_family, ...) \ G_STMT_START { \ const int __addr_family = (addr_family); \ const NMLogLevel __level = (level); \ @@ -122,38 +130,17 @@ static const VTableIP vtable_v4, vtable_v6; \ if (nm_logging_enabled (__level, __domain)) { \ char __ch = __addr_family == AF_INET ? '4' : (__addr_family == AF_INET6 ? '6' : '-'); \ - char __prefix[30] = _LOG_PREFIX_NAME; \ + char __prefix[30] = _NMLOG_PREFIX_NAME; \ \ if ((self) != singleton_instance) \ - g_snprintf (__prefix, sizeof (__prefix), "%s%c[%p]", _LOG_PREFIX_NAME, __ch, (self)); \ + g_snprintf (__prefix, sizeof (__prefix), "%s%c[%p]", _NMLOG_PREFIX_NAME, __ch, (self)); \ else \ - __prefix[STRLEN (_LOG_PREFIX_NAME)] = __ch; \ + __prefix[STRLEN (_NMLOG_PREFIX_NAME)] = __ch; \ _nm_log ((level), (__domain), 0, \ "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ } \ } G_STMT_END -#define _LOG_LEVEL_ENABLED(level, addr_family) \ - ({ \ - const int __addr_family = (addr_family); \ - const NMLogLevel __level = (level); \ - const NMLogDomain __domain = __addr_family == AF_INET ? LOGD_IP4 : (__addr_family == AF_INET6 ? LOGD_IP6 : LOGD_IP); \ - \ - nm_logging_enabled (__level, __domain); \ - }) - -#ifdef NM_MORE_LOGGING -#define _LOGT_ENABLED(addr_family) _LOG_LEVEL_ENABLED (LOGL_TRACE, addr_family) -#define _LOGT(addr_family, ...) _LOG (LOGL_TRACE, addr_family, __VA_ARGS__) -#else -#define _LOGT_ENABLED(addr_family) (FALSE && _LOG_LEVEL_ENABLED (LOGL_TRACE, addr_family)) -#define _LOGT(addr_family, ...) G_STMT_START { if (FALSE) { _LOG (LOGL_TRACE, addr_family, __VA_ARGS__); } } G_STMT_END -#endif - -#define _LOGD(addr_family, ...) _LOG (LOGL_DEBUG, addr_family, __VA_ARGS__) -#define _LOGI(addr_family, ...) _LOG (LOGL_INFO , addr_family, __VA_ARGS__) -#define _LOGW(addr_family, ...) _LOG (LOGL_WARN , addr_family, __VA_ARGS__) -#define _LOGE(addr_family, ...) _LOG (LOGL_ERR , addr_family, __VA_ARGS__) /*********************************************************************************************/ diff --git a/src/nm-types.h b/src/nm-types.h index 1a002ac3f..5806e15db 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -127,6 +127,12 @@ typedef enum { NMP_OBJECT_TYPE_MAX = __NMP_OBJECT_TYPE_LAST - 1, } NMPObjectType; +typedef enum { + NM_IP_CONFIG_MERGE_DEFAULT = 0, + NM_IP_CONFIG_MERGE_NO_ROUTES = (1LL << 0), + NM_IP_CONFIG_MERGE_NO_DNS = (1LL << 1), +} NMIPConfigMergeFlags; + /* settings */ typedef struct _NMAgentManager NMAgentManager; typedef struct _NMSecretAgent NMSecretAgent; diff --git a/src/org.freedesktop.NetworkManager.conf b/src/org.freedesktop.NetworkManager.conf index 0f1019b90..afbcc720e 100644 --- a/src/org.freedesktop.NetworkManager.conf +++ b/src/org.freedesktop.NetworkManager.conf @@ -25,6 +25,8 @@ <allow send_destination="org.freedesktop.NetworkManager.vpnc"/> <allow send_destination="org.freedesktop.NetworkManager.ssh"/> <allow send_destination="org.freedesktop.NetworkManager.iodine"/> + <allow send_destination="org.freedesktop.NetworkManager.l2tp"/> + <allow send_destination="org.freedesktop.NetworkManager.libreswan"/> </policy> <policy context="default"> <deny own="org.freedesktop.NetworkManager"/> diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 80757f4ef..cd0a4e074 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -67,8 +67,9 @@ /*********************************************************************************************/ -#define _LOG_DOMAIN LOGD_PLATFORM -#define _LOG_PREFIX_NAME "platform-linux" +#define _NMLOG_DOMAIN LOGD_PLATFORM +#define _NMLOG_PREFIX_NAME "platform-linux" +#define _NMLOG(level, ...) _LOG(level, _NMLOG_DOMAIN, platform, __VA_ARGS__) #define _LOG(level, domain, self, ...) \ G_STMT_START { \ @@ -77,11 +78,11 @@ \ if (nm_logging_enabled (__level, __domain)) { \ char __prefix[32]; \ - const char *__p_prefix = _LOG_PREFIX_NAME; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ const void *const __self = (self); \ \ if (__self && __self != nm_platform_try_get ()) { \ - g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _LOG_PREFIX_NAME, __self); \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \ __p_prefix = __prefix; \ } \ _nm_log (__level, __domain, 0, \ @@ -89,25 +90,12 @@ __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ } \ } G_STMT_END -#define _LOG_LEVEL_ENABLED(level, domain) \ - ( nm_logging_enabled ((level), (domain)) ) -#ifdef NM_MORE_LOGGING -#define _LOGT_ENABLED() _LOG_LEVEL_ENABLED (LOGL_TRACE, _LOG_DOMAIN) -#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DOMAIN, platform, __VA_ARGS__) -#else -#define _LOGT_ENABLED() FALSE -#define _LOGT(...) G_STMT_START { if (FALSE) { _LOG (LOGL_TRACE, _LOG_DOMAIN, platform, __VA_ARGS__); } } G_STMT_END -#endif - -#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, platform, __VA_ARGS__) -#define _LOGI(...) _LOG (LOGL_INFO , _LOG_DOMAIN, platform, __VA_ARGS__) -#define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, platform, __VA_ARGS__) -#define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, platform, __VA_ARGS__) - -#define debug(...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, NULL, __VA_ARGS__) -#define warning(...) _LOG (LOGL_WARN , _LOG_DOMAIN, NULL, __VA_ARGS__) -#define error(...) _LOG (LOGL_ERR , _LOG_DOMAIN, NULL, __VA_ARGS__) +#define trace(...) _LOG (LOGL_TRACE, _NMLOG_DOMAIN, NULL, __VA_ARGS__) +#define debug(...) _LOG (LOGL_DEBUG, _NMLOG_DOMAIN, NULL, __VA_ARGS__) +#define info(...) _LOG (LOGL_INFO, _NMLOG_DOMAIN, NULL, __VA_ARGS__) +#define warning(...) _LOG (LOGL_WARN , _NMLOG_DOMAIN, NULL, __VA_ARGS__) +#define error(...) _LOG (LOGL_ERR , _NMLOG_DOMAIN, NULL, __VA_ARGS__) /****************************************************************** * Forward declarations and enums @@ -150,8 +138,10 @@ static NMPCacheOpsType cache_remove_netlink (NMPlatform *platform, const NMPObje struct libnl_vtable { void *handle; + void *handle_route; int (*f_nl_has_capability) (int capability); + int (*f_rtnl_link_get_link_netnsid) (const struct rtnl_link *link, gint32 *out_link_netnsid); }; static int @@ -160,24 +150,25 @@ _nl_f_nl_has_capability (int capability) return FALSE; } -static struct libnl_vtable * +static const struct libnl_vtable * _nl_get_vtable (void) { static struct libnl_vtable vtable; if (G_UNLIKELY (!vtable.f_nl_has_capability)) { - void *handle; - - handle = dlopen ("libnl-3.so.200", RTLD_LAZY | RTLD_NOLOAD); - if (handle) { - vtable.handle = handle; - vtable.f_nl_has_capability = dlsym (handle, "nl_has_capability"); + vtable.handle = dlopen ("libnl-3.so.200", RTLD_LAZY | RTLD_NOLOAD); + if (vtable.handle) { + vtable.f_nl_has_capability = dlsym (vtable.handle, "nl_has_capability"); + } + vtable.handle_route = dlopen ("libnl-route-3.so.200", RTLD_LAZY | RTLD_NOLOAD); + if (vtable.handle_route) { + vtable.f_rtnl_link_get_link_netnsid = dlsym (vtable.handle_route, "rtnl_link_get_link_netnsid"); } if (!vtable.f_nl_has_capability) vtable.f_nl_has_capability = &_nl_f_nl_has_capability; - g_return_val_if_fail (vtable.handle, &vtable); + trace ("libnl: rtnl_link_get_link_netnsid() %s", vtable.f_rtnl_link_get_link_netnsid ? "supported" : "not supported"); } return &vtable; @@ -189,6 +180,26 @@ _nl_has_capability (int capability) return (_nl_get_vtable ()->f_nl_has_capability) (capability); } +static int +_rtnl_link_get_link_netnsid (const struct rtnl_link *link, gint32 *out_link_netnsid) +{ + const struct libnl_vtable *vtable; + + g_return_val_if_fail (link, -NLE_INVAL); + g_return_val_if_fail (out_link_netnsid, -NLE_INVAL); + + vtable = _nl_get_vtable (); + return vtable->f_rtnl_link_get_link_netnsid + ? vtable->f_rtnl_link_get_link_netnsid (link, out_link_netnsid) + : -NLE_OPNOTSUPP; +} + +gboolean +nm_platform_check_support_libnl_link_netnsid (void) +{ + return !!(_nl_get_vtable ()->f_rtnl_link_get_link_netnsid); +} + /* Automatic deallocation of local variables */ #define auto_nl_object __attribute__((cleanup(_nl_auto_nl_object))) static void @@ -994,6 +1005,7 @@ _nmp_vt_cmd_plobj_init_from_nl_link (NMPlatform *platform, NMPlatformObject *_ob gboolean completed_from_cache_val = FALSE; gboolean *completed_from_cache = complete_from_cache ? &completed_from_cache_val : NULL; const NMPObject *link_cached = NULL; + int parent; nm_assert (memcmp (obj, ((char [sizeof (NMPObjectLink)]) { 0 }), sizeof (NMPObjectLink)) == 0); @@ -1013,7 +1025,15 @@ _nmp_vt_cmd_plobj_init_from_nl_link (NMPlatform *platform, NMPlatformObject *_ob obj->flags = rtnl_link_get_flags (nlo); obj->connected = NM_FLAGS_HAS (obj->flags, IFF_LOWER_UP); obj->master = rtnl_link_get_master (nlo); - obj->parent = rtnl_link_get_link (nlo); + parent = rtnl_link_get_link (nlo); + if (parent > 0) { + gint32 link_netnsid; + + if (_rtnl_link_get_link_netnsid (nlo, &link_netnsid) == 0) + obj->parent = NM_PLATFORM_LINK_OTHER_NETNS; + else + obj->parent = parent; + } obj->mtu = rtnl_link_get_mtu (nlo); obj->arptype = rtnl_link_get_arptype (nlo); @@ -2306,11 +2326,25 @@ event_notification (struct nl_msg *msg, gpointer user_data) if (_support_user_ipv6ll_still_undecided() && msghdr->nlmsg_type == RTM_NEWLINK) _support_user_ipv6ll_detect ((struct rtnl_link *) nlo); - obj = nmp_object_from_nl (platform, nlo, FALSE, TRUE); + switch (msghdr->nlmsg_type) { + case RTM_DELADDR: + case RTM_DELLINK: + case RTM_DELROUTE: + /* The event notifies about a deleted object. We don't need to initialize all the + * fields of the nmp-object. Shortcut nmp_object_from_nl(). */ + obj = nmp_object_from_nl (platform, nlo, TRUE, TRUE); + _LOGD ("event-notification: %s, seq %u: %s", + _nl_nlmsg_type_to_str (msghdr->nlmsg_type, buf_nlmsg_type, sizeof (buf_nlmsg_type)), + msghdr->nlmsg_seq, nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_ID, NULL, 0)); + break; + default: + obj = nmp_object_from_nl (platform, nlo, FALSE, TRUE); + _LOGD ("event-notification: %s, seq %u: %s", + _nl_nlmsg_type_to_str (msghdr->nlmsg_type, buf_nlmsg_type, sizeof (buf_nlmsg_type)), + msghdr->nlmsg_seq, nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0)); + break; + } - _LOGD ("event-notification: %s, seq %u: %s", - _nl_nlmsg_type_to_str (msghdr->nlmsg_type, buf_nlmsg_type, sizeof (buf_nlmsg_type)), - msghdr->nlmsg_seq, nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0)); if (obj) { auto_nmp_obj NMPObject *obj_cache = NULL; @@ -4549,7 +4583,7 @@ event_handler_read_netlink_one (NMPlatform *platform) debug ("Uncritical failure to retrieve incoming events: %s (%d)", nl_geterror (nle), nle); break; case -NLE_NOMEM: - warning ("Too many netlink events. Need to resynchronize platform cache"); + info ("Too many netlink events. Need to resynchronize platform cache"); /* Drain the event queue, we've lost events and are out of sync anyway and we'd * like to free up some space. We'll read in the status synchronously. */ _nl_sock_flush_data (priv->nlh_event); diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index d3c62bddc..b7f0947ef 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -33,6 +33,7 @@ #include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-logging.h" +#include "nm-setting-wired.h" /****************************************************************** @@ -48,8 +49,14 @@ ethtool_get (const char *name, gpointer edata) if (!name || !*name) return FALSE; + if (!nmp_utils_device_exists (name)) + return FALSE; + + /* nmp_utils_device_exists() already errors out if @name is invalid. */ + nm_assert (strlen (name) < IFNAMSIZ); + memset (&ifr, 0, sizeof (ifr)); - strncpy (ifr.ifr_name, name, IFNAMSIZ); + strcpy (ifr.ifr_name, name); ifr.ifr_data = edata; fd = socket (PF_INET, SOCK_DGRAM, 0); @@ -255,6 +262,43 @@ nmp_utils_ethtool_get_link_speed (const char *ifname, guint32 *out_speed) return TRUE; } +gboolean +nmp_utils_ethtool_set_wake_on_lan (const char *ifname, + NMSettingWiredWakeOnLan wol, + const char *wol_password) +{ + struct ethtool_wolinfo wol_info = { }; + + nm_log_dbg (LOGD_PLATFORM, "setting Wake-on-LAN options 0x%x, password '%s'", + (unsigned int) wol, wol_password); + + wol_info.cmd = ETHTOOL_SWOL; + wol_info.wolopts = 0; + + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_PHY)) + wol_info.wolopts |= WAKE_PHY; + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST)) + wol_info.wolopts |= WAKE_UCAST; + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST)) + wol_info.wolopts |= WAKE_MCAST; + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST)) + wol_info.wolopts |= WAKE_BCAST; + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ARP)) + wol_info.wolopts |= WAKE_ARP; + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) + wol_info.wolopts |= WAKE_MAGIC; + + if (wol_password) { + if (!nm_utils_hwaddr_aton (wol_password, wol_info.sopass, ETH_ALEN)) { + nm_log_dbg (LOGD_PLATFORM, "couldn't parse Wake-on-LAN password '%s'", wol_password); + return FALSE; + } + wol_info.wolopts |= WAKE_MAGICSECURE; + } + + return ethtool_get (ifname, &wol_info); +} + /****************************************************************** * mii ******************************************************************/ @@ -270,6 +314,9 @@ nmp_utils_mii_supports_carrier_detect (const char *ifname) if (!ifname) return FALSE; + if (!nmp_utils_device_exists (ifname)) + return FALSE; + fd = socket (PF_INET, SOCK_DGRAM, 0); if (fd < 0) { nm_log_err (LOGD_PLATFORM, "mii: couldn't open control socket (%s)", ifname); @@ -433,4 +480,17 @@ nmp_utils_lifetime_get (guint32 timestamp, return TRUE; } +gboolean +nmp_utils_device_exists (const char *name) +{ +#define SYS_CLASS_NET "/sys/class/net/" + char sysdir[STRLEN (SYS_CLASS_NET) + IFNAMSIZ] = SYS_CLASS_NET; + if ( !name + || strlen (name) >= IFNAMSIZ + || !nm_utils_is_valid_path_component (name)) + g_return_val_if_reached (FALSE); + + strcpy (&sysdir[STRLEN (SYS_CLASS_NET)], name); + return g_file_test (sysdir, G_FILE_TEST_EXISTS); +} diff --git a/src/platform/nm-platform-utils.h b/src/platform/nm-platform-utils.h index 557de8440..3769a8e19 100644 --- a/src/platform/nm-platform-utils.h +++ b/src/platform/nm-platform-utils.h @@ -26,6 +26,7 @@ #include <gudev/gudev.h> #include "nm-platform.h" +#include "nm-setting-wired.h" const char *nmp_utils_ethtool_get_driver (const char *ifname); @@ -33,6 +34,9 @@ gboolean nmp_utils_ethtool_supports_carrier_detect (const char *ifname); gboolean nmp_utils_ethtool_supports_vlans (const char *ifname); int nmp_utils_ethtool_get_peer_ifindex (const char *ifname); gboolean nmp_utils_ethtool_get_wake_on_lan (const char *ifname); +gboolean nmp_utils_ethtool_set_wake_on_lan (const char *ifname, NMSettingWiredWakeOnLan wol, + const char *wol_password); + gboolean nmp_utils_ethtool_get_link_speed (const char *ifname, guint32 *out_speed); gboolean nmp_utils_ethtool_get_driver_info (const char *ifname, @@ -63,4 +67,6 @@ gboolean nmp_utils_lifetime_get (guint32 timestamp, guint32 *out_lifetime, guint32 *out_preferred); +gboolean nmp_utils_device_exists (const char *name); + #endif /* __NM_PLATFORM_UTILS_H__ */ diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index b6d87ff95..fcb5b0611 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -43,43 +43,26 @@ G_STATIC_ASSERT (sizeof ( ((NMPlatformLink *) NULL)->addr.data ) == NM_UTILS_HWADDR_LEN_MAX); -#define _LOG_DOMAIN LOGD_PLATFORM -#define _LOG_PREFIX_NAME "platform" - -#define _LOG(level, domain, self, ...) \ +#define _NMLOG_DOMAIN LOGD_PLATFORM +#define _NMLOG_PREFIX_NAME "platform" +#define _NMLOG(level, ...) \ G_STMT_START { \ const NMLogLevel __level = (level); \ - const NMLogDomain __domain = (domain); \ \ - if (nm_logging_enabled (__level, __domain)) { \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ char __prefix[32]; \ - const char *__p_prefix = _LOG_PREFIX_NAME; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ const void *const __self = (self); \ \ if (__self && __self != nm_platform_try_get ()) { \ - g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _LOG_PREFIX_NAME, __self); \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \ __p_prefix = __prefix; \ } \ - _nm_log (__level, __domain, 0, \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ } \ } G_STMT_END -#define _LOG_LEVEL_ENABLED(level, domain) \ - ( nm_logging_enabled ((level), (domain)) ) - -#ifdef NM_MORE_LOGGING -#define _LOGT_ENABLED() _LOG_LEVEL_ENABLED (LOGL_TRACE, _LOG_DOMAIN) -#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__) -#else -#define _LOGT_ENABLED() FALSE -#define _LOGT(...) G_STMT_START { if (FALSE) { _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__); } } G_STMT_END -#endif - -#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, self, __VA_ARGS__) -#define _LOGI(...) _LOG (LOGL_INFO , _LOG_DOMAIN, self, __VA_ARGS__) -#define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, self, __VA_ARGS__) -#define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, self, __VA_ARGS__) #define NM_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PLATFORM, NMPlatformPrivate)) @@ -464,9 +447,12 @@ nm_platform_link_get_all (NMPlatform *self) g_warn_if_fail (g_hash_table_contains (unseen, GINT_TO_POINTER (item->master))); } if (item->parent != 0) { - g_warn_if_fail (item->parent > 0); - g_warn_if_fail (item->parent != item->ifindex); - g_warn_if_fail (g_hash_table_contains (unseen, GINT_TO_POINTER (item->parent))); + if (item->parent != NM_PLATFORM_LINK_OTHER_NETNS) { + g_warn_if_fail (item->parent > 0); + g_warn_if_fail (item->parent != item->ifindex); + g_warn_if_fail ( !nm_platform_check_support_libnl_link_netnsid () + || g_hash_table_contains (unseen, GINT_TO_POINTER (item->parent))); + } } } #endif @@ -1873,7 +1859,7 @@ nm_platform_ip4_address_add (NMPlatform *self, g_return_val_if_fail (klass->ip4_address_add, FALSE); g_return_val_if_fail (!label || strlen (label) < sizeof (((NMPlatformIP4Address *) NULL)->label), FALSE); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) { + if (_LOGD_ENABLED ()) { NMPlatformIP4Address addr = { 0 }; addr.ifindex = ifindex; @@ -1909,7 +1895,7 @@ nm_platform_ip6_address_add (NMPlatform *self, g_return_val_if_fail (preferred <= lifetime, FALSE); g_return_val_if_fail (klass->ip6_address_add, FALSE); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) { + if (_LOGD_ENABLED ()) { NMPlatformIP6Address addr = { 0 }; addr.ifindex = ifindex; @@ -2190,7 +2176,7 @@ nm_platform_ip4_route_add (NMPlatform *self, g_return_val_if_fail (0 <= plen && plen <= 32, FALSE); g_return_val_if_fail (klass->ip4_route_add, FALSE); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) { + if (_LOGD_ENABLED ()) { NMPlatformIP4Route route = { 0 }; route.ifindex = ifindex; @@ -2218,7 +2204,7 @@ nm_platform_ip6_route_add (NMPlatform *self, g_return_val_if_fail (0 <= plen && plen <= 128, FALSE); g_return_val_if_fail (klass->ip6_route_add, FALSE); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) { + if (_LOGD_ENABLED ()) { NMPlatformIP6Route route = { 0 }; route.ifindex = ifindex; @@ -2372,8 +2358,10 @@ nm_platform_link_to_string (const NMPlatformLink *link) else master[0] = 0; - if (link->parent) - g_snprintf (parent, sizeof (master), "@%d", link->parent); + if (link->parent > 0) + g_snprintf (parent, sizeof (parent), "@%d", link->parent); + else if (link->parent == NM_PLATFORM_LINK_OTHER_NETNS) + g_strlcpy (parent, "@other-netns", sizeof (parent)); else parent[0] = 0; diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 4d2541950..3219dd5a7 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -87,6 +87,8 @@ typedef enum { _NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL, } NMPlatformReason; +#define NM_PLATFORM_LINK_OTHER_NETNS (-1) + #define __NMPlatformObject_COMMON \ int ifindex; \ ; @@ -105,6 +107,10 @@ struct _NMPlatformLink { gboolean initialized; int master; + + /* rtnl_link_get_link(), IFLA_LINK. + * If IFLA_LINK_NETNSID indicates that the parent is in another namespace, + * this field be set to (negative) NM_PLATFORM_LINK_OTHER_NETNS. */ int parent; /* rtnl_link_get_arptype(), ifinfomsg.ifi_type. */ @@ -734,6 +740,7 @@ int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4R int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b); gboolean nm_platform_check_support_libnl_extended_ifa_flags (void); +gboolean nm_platform_check_support_libnl_link_netnsid (void); gboolean nm_platform_check_support_kernel_extended_ifa_flags (NMPlatform *self); gboolean nm_platform_check_support_user_ipv6ll (NMPlatform *self); diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index 51684b93c..7fe2d7d3b 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -18,10 +18,11 @@ * Copyright (C) 2015 Red Hat, Inc. */ -#include "nmp-object.h" +#include "config.h" #include <unistd.h> +#include "nmp-object.h" #include "nm-platform-utils.h" #include "NetworkManagerUtils.h" #include "nm-utils.h" @@ -29,38 +30,21 @@ /*********************************************************************************************/ -#define _LOG_DOMAIN LOGD_PLATFORM - -#define _LOG(level, domain, obj, ...) \ +#define _NMLOG_DOMAIN LOGD_PLATFORM +#define _NMLOG(level, obj, ...) \ G_STMT_START { \ const NMLogLevel __level = (level); \ - const NMLogDomain __domain = (domain); \ \ - if (nm_logging_enabled (__level, __domain)) { \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ const NMPObject *const __obj = (obj); \ \ - _nm_log (__level, __domain, 0, \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ "nmp-object[%p/%s]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ __obj, \ (__obj ? NMP_OBJECT_GET_CLASS (__obj)->obj_type_name : "???") \ _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ } \ } G_STMT_END -#define _LOG_LEVEL_ENABLED(level, domain) \ - ( nm_logging_enabled ((level), (domain)) ) - -#ifdef NM_MORE_LOGGING -#define _LOGT_ENABLED() _LOG_LEVEL_ENABLED (LOGL_TRACE, _LOG_DOMAIN) -#define _LOGT(obj, ...) _LOG (LOGL_TRACE, _LOG_DOMAIN, obj, __VA_ARGS__) -#else -#define _LOGT_ENABLED() FALSE -#define _LOGT(obj, ...) G_STMT_START { if (FALSE) { _LOG (LOGL_TRACE, _LOG_DOMAIN, obj, __VA_ARGS__); } } G_STMT_END -#endif - -#define _LOGD(obj, ...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, obj, __VA_ARGS__) -#define _LOGI(obj, ...) _LOG (LOGL_INFO , _LOG_DOMAIN, obj, __VA_ARGS__) -#define _LOGW(obj, ...) _LOG (LOGL_WARN , _LOG_DOMAIN, obj, __VA_ARGS__) -#define _LOGE(obj, ...) _LOG (LOGL_ERR , _LOG_DOMAIN, obj, __VA_ARGS__) /*********************************************************************************************/ diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index dc7b83975..ce371b752 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -231,10 +231,7 @@ test_slave (int master, int type, SignalData *master_changed) g_assert (nm_platform_link_release (NM_PLATFORM_GET, master, ifindex)); g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); accept_signals (link_changed, 1, 3); - if (link_type != NM_LINK_TYPE_TEAM) - accept_signals (master_changed, 1, 2); - else - accept_signals (master_changed, 1, 1); + accept_signals (master_changed, 1, 2); ensure_no_signal (master_changed); diff --git a/src/platform/wifi/wifi-utils-wext.c b/src/platform/wifi/wifi-utils-wext.c index 8428010ac..470b73d1c 100644 --- a/src/platform/wifi/wifi-utils-wext.c +++ b/src/platform/wifi/wifi-utils-wext.c @@ -34,6 +34,7 @@ #include "wifi-utils-wext.h" #include "nm-logging.h" #include "nm-utils.h" +#include "nm-platform-utils.h" /* Hacks necessary to #include wireless.h; yay for WEXT */ #ifndef __user @@ -670,6 +671,9 @@ wifi_wext_is_wifi (const char *iface) struct iwreq iwr; gboolean is_wifi = FALSE; + if (!nmp_utils_device_exists (iface)) + return FALSE; + fd = socket (PF_INET, SOCK_DGRAM, 0); if (fd >= 0) { strncpy (iwr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 0f67a2162..da5384c0d 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -38,32 +38,57 @@ #include "nm-properties-changed-signal.h" #include "nm-core-internal.h" #include "nm-glib-compat.h" +#include "gsystem-local-alloc.h" #define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps" #define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids" -static void impl_settings_connection_get_settings (NMSettingsConnection *connection, +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG_PREFIX_NAME "settings-connection" +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ + char __prefix[128]; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ + const void *const __self = (self); \ + \ + if (__self) { \ + const char *__uuid = nm_connection_get_uuid ((NMConnection *) __self); \ + \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, __self, __uuid ? "," : "", __uuid ? __uuid : ""); \ + __p_prefix = __prefix; \ + } \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ + "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + + +static void impl_settings_connection_get_settings (NMSettingsConnection *self, DBusGMethodInvocation *context); -static void impl_settings_connection_update (NMSettingsConnection *connection, +static void impl_settings_connection_update (NMSettingsConnection *self, GHashTable *new_settings, DBusGMethodInvocation *context); -static void impl_settings_connection_update_unsaved (NMSettingsConnection *connection, +static void impl_settings_connection_update_unsaved (NMSettingsConnection *self, GHashTable *new_settings, DBusGMethodInvocation *context); -static void impl_settings_connection_save (NMSettingsConnection *connection, +static void impl_settings_connection_save (NMSettingsConnection *self, DBusGMethodInvocation *context); -static void impl_settings_connection_delete (NMSettingsConnection *connection, +static void impl_settings_connection_delete (NMSettingsConnection *self, DBusGMethodInvocation *context); -static void impl_settings_connection_get_secrets (NMSettingsConnection *connection, +static void impl_settings_connection_get_secrets (NMSettingsConnection *self, const gchar *setting_name, DBusGMethodInvocation *context); -static void impl_settings_connection_clear_secrets (NMSettingsConnection *connection, +static void impl_settings_connection_clear_secrets (NMSettingsConnection *self, DBusGMethodInvocation *context); #include "nm-settings-connection-glue.h" @@ -146,7 +171,7 @@ typedef gboolean (*ForEachSecretFunc) (GHashTableIter *iter, gpointer user_data); static void -for_each_secret (NMConnection *connection, +for_each_secret (NMConnection *self, GHashTable *secrets, gboolean remove_non_secrets, ForEachSecretFunc callback, @@ -189,7 +214,7 @@ for_each_secret (NMConnection *connection, * from the connection data, since flags aren't secrets. What we're * iterating here is just the secrets, not a whole connection. */ - setting = nm_connection_get_setting_by_name (connection, setting_name); + setting = nm_connection_get_setting_by_name (self, setting_name); if (setting == NULL) continue; @@ -488,6 +513,9 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self, nm_utils_log_connection_diff (new_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ "); nm_connection_replace_settings_from_connection (NM_CONNECTION (self), new_connection); + + _LOGD ("replace settings from connection %p (%s)", new_connection, nm_connection_get_id (NM_CONNECTION (self))); + nm_settings_connection_set_flags (self, NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED, FALSE); @@ -526,7 +554,7 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self, } static void -ignore_cb (NMSettingsConnection *connection, +ignore_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { @@ -583,49 +611,49 @@ commit_changes (NMSettingsConnection *self, } void -nm_settings_connection_commit_changes (NMSettingsConnection *connection, +nm_settings_connection_commit_changes (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data) { - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); - if (NM_SETTINGS_CONNECTION_GET_CLASS (connection)->commit_changes) { - NM_SETTINGS_CONNECTION_GET_CLASS (connection)->commit_changes (connection, - callback ? callback : ignore_cb, - user_data); + if (NM_SETTINGS_CONNECTION_GET_CLASS (self)->commit_changes) { + NM_SETTINGS_CONNECTION_GET_CLASS (self)->commit_changes (self, + callback ? callback : ignore_cb, + user_data); } else { GError *error = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s: %s:%d commit_changes() unimplemented", __func__, __FILE__, __LINE__); if (callback) - callback (connection, error, user_data); + callback (self, error, user_data); g_error_free (error); } } void -nm_settings_connection_delete (NMSettingsConnection *connection, +nm_settings_connection_delete (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data) { - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); - if (NM_SETTINGS_CONNECTION_GET_CLASS (connection)->delete) { - NM_SETTINGS_CONNECTION_GET_CLASS (connection)->delete (connection, - callback ? callback : ignore_cb, - user_data); + if (NM_SETTINGS_CONNECTION_GET_CLASS (self)->delete) { + NM_SETTINGS_CONNECTION_GET_CLASS (self)->delete (self, + callback ? callback : ignore_cb, + user_data); } else { GError *error = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__); if (callback) - callback (connection, error, user_data); + callback (self, error, user_data); g_error_free (error); } } static void -remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) +remove_entry_from_db (NMSettingsConnection *self, const char* db_name) { GKeyFile *key_file; const char *db_file; @@ -644,7 +672,7 @@ remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) gsize len; GError *error = NULL; - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); g_key_file_remove_key (key_file, db_name, connection_uuid, NULL); data = g_key_file_to_data (key_file, &len, &error); @@ -653,7 +681,7 @@ remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) g_free (data); } if (error) { - nm_log_warn (LOGD_SETTINGS, "error writing %s file '%s': %s", db_name, db_file, error->message); + _LOGW ("error writing %s file '%s': %s", db_name, db_file, error->message); g_error_free (error); } } @@ -661,39 +689,39 @@ remove_entry_from_db (NMSettingsConnection *connection, const char* db_name) } static void -do_delete (NMSettingsConnection *connection, +do_delete (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); NMConnection *for_agents; - g_object_ref (connection); - set_visible (connection, FALSE); + g_object_ref (self); + set_visible (self, FALSE); /* Tell agents to remove secrets for this connection */ - for_agents = nm_simple_connection_new_clone (NM_CONNECTION (connection)); + for_agents = nm_simple_connection_new_clone (NM_CONNECTION (self)); nm_connection_clear_secrets (for_agents); nm_agent_manager_delete_secrets (priv->agent_mgr, for_agents); g_object_unref (for_agents); /* Remove timestamp from timestamps database file */ - remove_entry_from_db (connection, "timestamps"); + remove_entry_from_db (self, "timestamps"); /* Remove connection from seen-bssids database file */ - remove_entry_from_db (connection, "seen-bssids"); + remove_entry_from_db (self, "seen-bssids"); - nm_settings_connection_signal_remove (connection); + nm_settings_connection_signal_remove (self); - callback (connection, NULL, user_data); + callback (self, NULL, user_data); - g_object_unref (connection); + g_object_unref (self); } /**************************************************************/ static gboolean -supports_secrets (NMSettingsConnection *connection, const char *setting_name) +supports_secrets (NMSettingsConnection *self, const char *setting_name) { /* All secrets supported */ return TRUE; @@ -734,13 +762,13 @@ has_system_owned_secrets (GHashTableIter *iter, } static void -new_secrets_commit_cb (NMSettingsConnection *connection, +new_secrets_commit_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { if (error) { - nm_log_warn (LOGD_SETTINGS, "Error saving new secrets to backing storage: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + _LOGW ("Error saving new secrets to backing storage: (%d) %s", + error->code, error->message ? error->message : "(unknown)"); } } @@ -767,12 +795,11 @@ agent_secrets_done_cb (NMAgentManager *manager, gboolean agent_had_system = FALSE; if (error) { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets request error: (%d) %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - error->code, - error->message ? error->message : "(unknown)"); + _LOGD ("(%s:%u) secrets request error: (%d) %s", + setting_name, + call_id, + error->code, + error->message ? error->message : "(unknown)"); callback (self, call_id, NULL, setting_name, error, callback_data); return; @@ -789,11 +816,10 @@ agent_secrets_done_cb (NMAgentManager *manager, g_assert (secrets); if (agent_dbus_owner) { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets returned from agent %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - agent_dbus_owner); + _LOGD ("(%s:%u) secrets returned from agent %s", + setting_name, + call_id, + agent_dbus_owner); /* If the agent returned any system-owned secrets (initial connect and no * secrets given when the connection was created, or something like that) @@ -807,36 +833,32 @@ agent_secrets_done_cb (NMAgentManager *manager, /* No user interaction was allowed when requesting secrets; the * agent is being bad. Remove system-owned secrets. */ - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) interaction forbidden but agent %s returned system secrets", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - agent_dbus_owner); + _LOGD ("(%s:%u) interaction forbidden but agent %s returned system secrets", + setting_name, + call_id, + agent_dbus_owner); for_each_secret (NM_CONNECTION (self), secrets, FALSE, clear_nonagent_secrets, NULL); } else if (agent_has_modify == FALSE) { /* Agent didn't successfully authenticate; clear system-owned secrets * from the secrets the agent returned. */ - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) agent failed to authenticate but provided system secrets", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) agent failed to authenticate but provided system secrets", + setting_name, + call_id); for_each_secret (NM_CONNECTION (self), secrets, FALSE, clear_nonagent_secrets, NULL); } } } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) existing secrets returned", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) existing secrets returned", + setting_name, + call_id); } - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets request completed", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) secrets request completed", + setting_name, + call_id); /* If no user interaction was allowed, make sure that no "unsaved" secrets * came back. Unsaved secrets by definition require user interaction. @@ -869,34 +891,30 @@ agent_secrets_done_cb (NMAgentManager *manager, * nothing has changed, since agent-owned secrets don't get saved here. */ if (agent_had_system) { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) saving new secrets to backing storage", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) saving new secrets to backing storage", + setting_name, + call_id); nm_settings_connection_commit_changes (self, new_secrets_commit_cb, NULL); } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) new agent secrets processed", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id); + _LOGD ("(%s:%u) new agent secrets processed", + setting_name, + call_id); } } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) failed to update with agent secrets: (%d) %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + _LOGD ("(%s:%u) failed to update with agent secrets: (%d) %s", + setting_name, + call_id, + local ? local->code : -1, + (local && local->message) ? local->message : "(unknown)"); } g_variant_unref (secrets_dict); } else { - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) failed to update with existing secrets: (%d) %s", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + _LOGD ("(%s:%u) failed to update with existing secrets: (%d) %s", + setting_name, + call_id, + local ? local->code : -1, + (local && local->message) ? local->message : "(unknown)"); } callback (self, call_id, agent_username, setting_name, local, callback_data); @@ -907,7 +925,7 @@ agent_secrets_done_cb (NMAgentManager *manager, /** * nm_settings_connection_get_secrets: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @subject: the #NMAuthSubject originating the request * @setting_name: the setting to return secrets for * @flags: flags to modify the secrets request @@ -935,7 +953,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self, GVariant *existing_secrets; GHashTable *existing_secrets_hash; guint32 call_id = 0; - char *joined_hints = NULL; + gs_free char *joined_hints = NULL; /* Use priv->secrets to work around the fact that nm_connection_clear_secrets() * will clear secrets on this object's settings. @@ -973,17 +991,11 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self, if (existing_secrets) g_variant_unref (existing_secrets); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_SETTINGS)) { - if (hints) - joined_hints = g_strjoinv (",", (char **) hints); - nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets requested flags 0x%X hints '%s'", - nm_connection_get_uuid (NM_CONNECTION (self)), - setting_name, - call_id, - flags, - joined_hints ? joined_hints : "(none)"); - g_free (joined_hints); - } + _LOGD ("(%s:%u) secrets requested flags 0x%X hints '%s'", + setting_name, + call_id, + flags, + (hints && hints[0]) ? (joined_hints = g_strjoinv (",", (char **) hints)) : "(none)"); return call_id; } @@ -994,9 +1006,8 @@ nm_settings_connection_cancel_secrets (NMSettingsConnection *self, { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - nm_log_dbg (LOGD_SETTINGS, "(%s:%u) secrets canceled", - nm_connection_get_uuid (NM_CONNECTION (self)), - call_id); + _LOGD ("(%u) secrets canceled", + call_id); priv->reqs = g_slist_remove (priv->reqs, GUINT_TO_POINTER (call_id)); nm_agent_manager_cancel_secrets (priv->agent_mgr, call_id); @@ -1004,7 +1015,7 @@ nm_settings_connection_cancel_secrets (NMSettingsConnection *self, /**** User authorization **************************************/ -typedef void (*AuthCallback) (NMSettingsConnection *connection, +typedef void (*AuthCallback) (NMSettingsConnection *self, DBusGMethodInvocation *context, NMAuthSubject *subject, GError *error, @@ -1136,13 +1147,13 @@ auth_start (NMSettingsConnection *self, /**** DBus method handlers ************************************/ static gboolean -check_writable (NMConnection *connection, GError **error) +check_writable (NMConnection *self, GError **error) { NMSettingConnection *s_con; - g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); + g_return_val_if_fail (NM_IS_CONNECTION (self), FALSE); - s_con = nm_connection_get_setting_connection (connection); + s_con = nm_connection_get_setting_connection (self); if (!s_con) { g_set_error_literal (error, NM_SETTINGS_ERROR, @@ -1272,11 +1283,11 @@ has_some_secrets_cb (NMSetting *setting, } static gboolean -any_secrets_present (NMConnection *connection) +any_secrets_present (NMConnection *self) { gboolean has_secrets = FALSE; - nm_connection_for_each_setting_value (connection, has_some_secrets_cb, &has_secrets); + nm_connection_for_each_setting_value (self, has_some_secrets_cb, &has_secrets); return has_secrets; } @@ -1515,7 +1526,7 @@ impl_settings_connection_save (NMSettingsConnection *self, } static void -con_delete_cb (NMSettingsConnection *connection, +con_delete_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { @@ -1528,7 +1539,7 @@ con_delete_cb (NMSettingsConnection *connection, } static void -delete_auth_cb (NMSettingsConnection *self, +delete_auth_cb (NMSettingsConnection *self, DBusGMethodInvocation *context, NMAuthSubject *subject, GError *error, @@ -1543,7 +1554,7 @@ delete_auth_cb (NMSettingsConnection *self, } static const char * -get_modify_permission_basic (NMSettingsConnection *connection) +get_modify_permission_basic (NMSettingsConnection *self) { NMSettingConnection *s_con; @@ -1551,7 +1562,7 @@ get_modify_permission_basic (NMSettingsConnection *connection) * we use the 'modify.own' permission instead of 'modify.system'. If the * request affects more than just the caller, require 'modify.system'. */ - s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); + s_con = nm_connection_get_setting_connection (NM_CONNECTION (self)); g_assert (s_con); if (nm_setting_connection_get_num_permissions (s_con) == 1) return NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN; @@ -1692,7 +1703,7 @@ clear_secrets_cb (NMSettingsConnection *self, } static void -dbus_clear_secrets_auth_cb (NMSettingsConnection *self, +dbus_clear_secrets_auth_cb (NMSettingsConnection *self, DBusGMethodInvocation *context, NMAuthSubject *subject, GError *error, @@ -1815,7 +1826,7 @@ nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConn /** * nm_settings_connection_get_timestamp: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @out_timestamp: the connection's timestamp * * Returns the time (in seconds since the Unix epoch) when the connection @@ -1824,19 +1835,19 @@ nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConn * Returns: %TRUE if the timestamp has ever been set, otherwise %FALSE. **/ gboolean -nm_settings_connection_get_timestamp (NMSettingsConnection *connection, +nm_settings_connection_get_timestamp (NMSettingsConnection *self, guint64 *out_timestamp) { - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), FALSE); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE); if (out_timestamp) - *out_timestamp = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->timestamp; - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->timestamp_set; + *out_timestamp = NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->timestamp; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->timestamp_set; } /** * nm_settings_connection_update_timestamp: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @timestamp: timestamp to set into the connection and to store into * the timestamps database * @flush_to_disk: if %TRUE, commit timestamp update to persistent storage @@ -1844,18 +1855,18 @@ nm_settings_connection_get_timestamp (NMSettingsConnection *connection, * Updates the connection and timestamps database with the provided timestamp. **/ void -nm_settings_connection_update_timestamp (NMSettingsConnection *connection, +nm_settings_connection_update_timestamp (NMSettingsConnection *self, guint64 timestamp, gboolean flush_to_disk) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; GKeyFile *timestamps_file; char *data, *tmp; gsize len; GError *error = NULL; - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); /* Update timestamp in private storage */ priv->timestamp = timestamp; @@ -1868,11 +1879,11 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, timestamps_file = g_key_file_new (); if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) { if (!(error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT)) - nm_log_warn (LOGD_SETTINGS, "error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); + _LOGW ("error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); g_clear_error (&error); } - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); tmp = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp); g_key_file_set_value (timestamps_file, "timestamps", connection_uuid, tmp); g_free (tmp); @@ -1883,7 +1894,7 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, g_free (data); } if (error) { - nm_log_warn (LOGD_SETTINGS, "error saving timestamp to file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); + _LOGW ("error saving timestamp to file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); g_error_free (error); } g_key_file_free (timestamps_file); @@ -1891,27 +1902,27 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, /** * nm_settings_connection_read_and_fill_timestamp: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * * Retrieves timestamp of the connection's last usage from database file and * stores it into the connection private data. **/ void -nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection) +nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; guint64 timestamp = 0; GKeyFile *timestamps_file; GError *err = NULL; char *tmp_str; - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); /* Get timestamp from database file */ timestamps_file = g_key_file_new (); g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL); - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); tmp_str = g_key_file_get_value (timestamps_file, "timestamps", connection_uuid, &err); if (tmp_str) { timestamp = g_ascii_strtoull (tmp_str, NULL, 10); @@ -1923,8 +1934,8 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection priv->timestamp = timestamp; priv->timestamp_set = TRUE; } else { - nm_log_dbg (LOGD_SETTINGS, "failed to read connection timestamp for '%s': (%d) %s", - connection_uuid, err->code, err->message); + _LOGD ("failed to read connection timestamp: (%d) %s", + err->code, err->message); g_clear_error (&err); } g_key_file_free (timestamps_file); @@ -1932,7 +1943,7 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection /** * nm_settings_connection_get_seen_bssids: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * * Returns current list of seen BSSIDs for the connection. * @@ -1940,14 +1951,14 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection * The caller is responsible for freeing the list, but not the content. **/ char ** -nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection) +nm_settings_connection_get_seen_bssids (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); GHashTableIter iter; char **bssids, *bssid; int i; - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), NULL); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NULL); bssids = g_new (char *, g_hash_table_size (priv->seen_bssids) + 1); @@ -1962,34 +1973,34 @@ nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection) /** * nm_settings_connection_has_seen_bssid: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @bssid: the BSSID to check the seen BSSID list for * * Returns: %TRUE if the given @bssid is in the seen BSSIDs list **/ gboolean -nm_settings_connection_has_seen_bssid (NMSettingsConnection *connection, +nm_settings_connection_has_seen_bssid (NMSettingsConnection *self, const char *bssid) { - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), FALSE); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE); g_return_val_if_fail (bssid != NULL, FALSE); - return !!g_hash_table_lookup (NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->seen_bssids, bssid); + return !!g_hash_table_lookup (NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->seen_bssids, bssid); } /** * nm_settings_connection_add_seen_bssid: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * @seen_bssid: BSSID to set into the connection and to store into * the seen-bssids database * * Updates the connection and seen-bssids database with the provided BSSID. **/ void -nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, +nm_settings_connection_add_seen_bssid (NMSettingsConnection *self, const char *seen_bssid) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; GKeyFile *seen_bssids_file; char *data, *bssid_str; @@ -2020,13 +2031,13 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, g_key_file_set_list_separator (seen_bssids_file, ','); if (!g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) { if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) { - nm_log_warn (LOGD_SETTINGS, "error parsing seen-bssids file '%s': %s", - SETTINGS_SEEN_BSSIDS_FILE, error->message); + _LOGW ("error parsing seen-bssids file '%s': %s", + SETTINGS_SEEN_BSSIDS_FILE, error->message); } g_clear_error (&error); } - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); g_key_file_set_string_list (seen_bssids_file, "seen-bssids", connection_uuid, list, n); g_free (list); @@ -2038,23 +2049,23 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, g_key_file_free (seen_bssids_file); if (error) { - nm_log_warn (LOGD_SETTINGS, "error saving seen-bssids to file '%s': %s", - SETTINGS_SEEN_BSSIDS_FILE, error->message); + _LOGW ("error saving seen-bssids to file '%s': %s", + SETTINGS_SEEN_BSSIDS_FILE, error->message); g_error_free (error); } } /** * nm_settings_connection_read_and_fill_seen_bssids: - * @connection: the #NMSettingsConnection + * @self: the #NMSettingsConnection * * Retrieves seen BSSIDs of the connection from database file and stores then into the * connection private data. **/ void -nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connection) +nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); const char *connection_uuid; GKeyFile *seen_bssids_file; char **tmp_strv = NULL; @@ -2065,7 +2076,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connecti seen_bssids_file = g_key_file_new (); g_key_file_set_list_separator (seen_bssids_file, ','); if (g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL)) { - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); + connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); tmp_strv = g_key_file_get_string_list (seen_bssids_file, "seen-bssids", connection_uuid, &len, NULL); } g_key_file_free (seen_bssids_file); @@ -2082,7 +2093,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connecti * seen-bssids list from the deprecated seen-bssids property of the * wifi setting. */ - s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (connection)); + s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (self)); if (s_wifi) { len = nm_setting_wireless_get_num_seen_bssids (s_wifi); for (i = 0; i < len; i++) { @@ -2098,16 +2109,16 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connecti #define AUTOCONNECT_RESET_RETRIES_TIMER 300 int -nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *connection) +nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_retries; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_retries; } void -nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection, +nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self, int retries) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); priv->autoconnect_retries = retries; if (retries) @@ -2117,34 +2128,34 @@ nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection } void -nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *connection) +nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *self) { - nm_settings_connection_set_autoconnect_retries (connection, AUTOCONNECT_RETRIES_DEFAULT); + nm_settings_connection_set_autoconnect_retries (self, AUTOCONNECT_RETRIES_DEFAULT); } gint32 -nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *connection) +nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_retry_time; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_retry_time; } NMDeviceStateReason -nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *connection) +nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_blocked_reason; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason; } void -nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *connection, +nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self, NMDeviceStateReason reason) { - NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_blocked_reason = reason; + NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_blocked_reason = reason; } gboolean -nm_settings_connection_can_autoconnect (NMSettingsConnection *connection) +nm_settings_connection_can_autoconnect (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); NMSettingConnection *s_con; const char *permission; @@ -2153,13 +2164,13 @@ nm_settings_connection_can_autoconnect (NMSettingsConnection *connection) || priv->autoconnect_blocked_reason != NM_DEVICE_STATE_REASON_NONE) return FALSE; - s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); + s_con = nm_connection_get_setting_connection (NM_CONNECTION (self)); if (!nm_setting_connection_get_autoconnect (s_con)) return FALSE; - permission = nm_utils_get_shared_wifi_permission (NM_CONNECTION (connection)); + permission = nm_utils_get_shared_wifi_permission (NM_CONNECTION (self)); if (permission) { - if (nm_settings_connection_check_permission (connection, permission) == FALSE) + if (nm_settings_connection_check_permission (self, permission) == FALSE) return FALSE; } @@ -2168,89 +2179,89 @@ nm_settings_connection_can_autoconnect (NMSettingsConnection *connection) /** * nm_settings_connection_get_nm_generated: - * @connection: an #NMSettingsConnection + * @self: an #NMSettingsConnection * - * Gets the "nm-generated" flag on @connection. + * Gets the "nm-generated" flag on @self. * * A connection is "nm-generated" if it was generated by * nm_device_generate_connection() and has not been modified or * saved by the user since then. */ gboolean -nm_settings_connection_get_nm_generated (NMSettingsConnection *connection) +nm_settings_connection_get_nm_generated (NMSettingsConnection *self) { - return NM_FLAGS_HAS (nm_settings_connection_get_flags (connection), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED); + return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED); } /** * nm_settings_connection_get_nm_generated_assumed: - * @connection: an #NMSettingsConnection + * @self: an #NMSettingsConnection * - * Gets the "nm-generated-assumed" flag on @connection. + * Gets the "nm-generated-assumed" flag on @self. * * The connection is a generated connection especially * generated for connection assumption. */ gboolean -nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *connection) +nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *self) { - return NM_FLAGS_HAS (nm_settings_connection_get_flags (connection), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED); + return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED); } gboolean -nm_settings_connection_get_ready (NMSettingsConnection *connection) +nm_settings_connection_get_ready (NMSettingsConnection *self) { - return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->ready; + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->ready; } void -nm_settings_connection_set_ready (NMSettingsConnection *connection, +nm_settings_connection_set_ready (NMSettingsConnection *self, gboolean ready) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); ready = !!ready; if (priv->ready != ready) { priv->ready = ready; - g_object_notify (G_OBJECT (connection), NM_SETTINGS_CONNECTION_READY); + g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTION_READY); } } /** * nm_settings_connection_set_filename: - * @connection: an #NMSettingsConnection - * @filename: @connection's filename + * @self: an #NMSettingsConnection + * @filename: @self's filename * - * Called by a backend to sets the filename that @connection is read + * Called by a backend to sets the filename that @self is read * from/written to. */ void -nm_settings_connection_set_filename (NMSettingsConnection *connection, +nm_settings_connection_set_filename (NMSettingsConnection *self, const char *filename) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); if (g_strcmp0 (filename, priv->filename) != 0) { g_free (priv->filename); priv->filename = g_strdup (filename); - g_object_notify (G_OBJECT (connection), NM_SETTINGS_CONNECTION_FILENAME); + g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTION_FILENAME); } } /** * nm_settings_connection_get_filename: - * @connection: an #NMSettingsConnection + * @self: an #NMSettingsConnection * - * Gets the filename that @connection was read from/written to. This may be - * %NULL if @connection is unsaved, or if it is associated with a backend that + * Gets the filename that @self was read from/written to. This may be + * %NULL if @self is unsaved, or if it is associated with a backend that * does not store each connection in a separate file. * - * Returns: @connection's filename. + * Returns: @self's filename. */ const char * -nm_settings_connection_get_filename (NMSettingsConnection *connection) +nm_settings_connection_get_filename (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); return priv->filename; } @@ -2283,12 +2294,24 @@ nm_settings_connection_init (NMSettingsConnection *self) } static void +constructed (GObject *object) +{ + NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object); + + _LOGD ("constructed (%s)", G_OBJECT_TYPE_NAME (self)); + + G_OBJECT_CLASS (nm_settings_connection_parent_class)->constructed (object); +} + +static void dispose (GObject *object) { NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object); NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); GSList *iter; + _LOGD ("disposing"); + if (priv->updated_idle_id) { g_source_remove (priv->updated_idle_id); priv->updated_idle_id = 0; @@ -2389,6 +2412,7 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) g_type_class_add_private (class, sizeof (NMSettingsConnectionPrivate)); /* Virtual methods */ + object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; @@ -2439,7 +2463,7 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) /* Signals */ /* Emitted when the connection is changed for any reason */ - signals[UPDATED] = + signals[UPDATED] = g_signal_new (NM_SETTINGS_CONNECTION_UPDATED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_FIRST, diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 49661f38c..512112f03 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -81,11 +81,11 @@ typedef enum typedef struct _NMSettingsConnectionClass NMSettingsConnectionClass; -typedef void (*NMSettingsConnectionCommitFunc) (NMSettingsConnection *connection, +typedef void (*NMSettingsConnectionCommitFunc) (NMSettingsConnection *self, GError *error, gpointer user_data); -typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *connection, +typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *self, GError *error, gpointer user_data); @@ -97,26 +97,26 @@ struct _NMSettingsConnectionClass { GObjectClass parent; /* virtual methods */ - void (*replace_and_commit) (NMSettingsConnection *connection, + void (*replace_and_commit) (NMSettingsConnection *self, NMConnection *new_connection, NMSettingsConnectionCommitFunc callback, gpointer user_data); - void (*commit_changes) (NMSettingsConnection *connection, + void (*commit_changes) (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data); - void (*delete) (NMSettingsConnection *connection, + void (*delete) (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data); - gboolean (*supports_secrets) (NMSettingsConnection *connection, + gboolean (*supports_secrets) (NMSettingsConnection *self, const char *setting_name); }; GType nm_settings_connection_get_type (void); -void nm_settings_connection_commit_changes (NMSettingsConnection *connection, +void nm_settings_connection_commit_changes (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data); @@ -131,18 +131,18 @@ void nm_settings_connection_replace_and_commit (NMSettingsConnection *self, NMSettingsConnectionCommitFunc callback, gpointer user_data); -void nm_settings_connection_delete (NMSettingsConnection *connection, +void nm_settings_connection_delete (NMSettingsConnection *self, NMSettingsConnectionDeleteFunc callback, gpointer user_data); -typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *connection, +typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *self, guint32 call_id, const char *agent_username, const char *setting_name, GError *error, gpointer user_data); -guint32 nm_settings_connection_get_secrets (NMSettingsConnection *connection, +guint32 nm_settings_connection_get_secrets (NMSettingsConnection *self, NMAuthSubject *subject, const char *setting_name, NMSecretAgentGetSecretsFlags flags, @@ -151,7 +151,7 @@ guint32 nm_settings_connection_get_secrets (NMSettingsConnection *connection, gpointer callback_data, GError **error); -void nm_settings_connection_cancel_secrets (NMSettingsConnection *connection, +void nm_settings_connection_cancel_secrets (NMSettingsConnection *self, guint32 call_id); gboolean nm_settings_connection_is_visible (NMSettingsConnection *self); @@ -165,52 +165,52 @@ void nm_settings_connection_signal_remove (NMSettingsConnection *self); gboolean nm_settings_connection_get_unsaved (NMSettingsConnection *self); -NMSettingsConnectionFlags nm_settings_connection_get_flags (NMSettingsConnection *connection); -NMSettingsConnectionFlags nm_settings_connection_set_flags (NMSettingsConnection *connection, NMSettingsConnectionFlags flags, gboolean set); -NMSettingsConnectionFlags nm_settings_connection_set_flags_all (NMSettingsConnection *connection, NMSettingsConnectionFlags flags); +NMSettingsConnectionFlags nm_settings_connection_get_flags (NMSettingsConnection *self); +NMSettingsConnectionFlags nm_settings_connection_set_flags (NMSettingsConnection *self, NMSettingsConnectionFlags flags, gboolean set); +NMSettingsConnectionFlags nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConnectionFlags flags); -gboolean nm_settings_connection_get_timestamp (NMSettingsConnection *connection, +gboolean nm_settings_connection_get_timestamp (NMSettingsConnection *self, guint64 *out_timestamp); -void nm_settings_connection_update_timestamp (NMSettingsConnection *connection, +void nm_settings_connection_update_timestamp (NMSettingsConnection *self, guint64 timestamp, gboolean flush_to_disk); -void nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection); +void nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *self); -char **nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection); +char **nm_settings_connection_get_seen_bssids (NMSettingsConnection *self); -gboolean nm_settings_connection_has_seen_bssid (NMSettingsConnection *connection, +gboolean nm_settings_connection_has_seen_bssid (NMSettingsConnection *self, const char *bssid); -void nm_settings_connection_add_seen_bssid (NMSettingsConnection *connection, +void nm_settings_connection_add_seen_bssid (NMSettingsConnection *self, const char *seen_bssid); -void nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *connection); +void nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self); -int nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *connection); -void nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection, +int nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self); +void nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self, int retries); -void nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *connection); +void nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *self); -gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *connection); +gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *self); -NMDeviceStateReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *connection); -void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *connection, +NMDeviceStateReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *self); +void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *self, NMDeviceStateReason reason); -gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *connection); +gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *self); -gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *connection); -gboolean nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *connection); +gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *self); +gboolean nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *self); -gboolean nm_settings_connection_get_ready (NMSettingsConnection *connection); -void nm_settings_connection_set_ready (NMSettingsConnection *connection, +gboolean nm_settings_connection_get_ready (NMSettingsConnection *self); +void nm_settings_connection_set_ready (NMSettingsConnection *self, gboolean ready); -void nm_settings_connection_set_filename (NMSettingsConnection *connection, +void nm_settings_connection_set_filename (NMSettingsConnection *self, const char *filename); -const char *nm_settings_connection_get_filename (NMSettingsConnection *connection); +const char *nm_settings_connection_get_filename (NMSettingsConnection *self); G_END_DECLS diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index a18920c68..9499d8ce6 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -67,6 +67,8 @@ typedef struct { gulong devtimeout_link_changed_handler; guint devtimeout_timeout_id; + + NMInotifyHelper *inotify_helper; } NMIfcfgConnectionPrivate; enum { @@ -84,6 +86,14 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +static NMInotifyHelper * +_get_inotify_helper (NMIfcfgConnectionPrivate *priv) +{ + if (!priv->inotify_helper) + priv->inotify_helper = g_object_ref (nm_inotify_helper_get ()); + return priv->inotify_helper; +} + static gboolean devtimeout_ready (gpointer user_data) { @@ -149,6 +159,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self) const char *ifname; const char *filename; guint devtimeout; + const NMPlatformLink *pllink; s_con = nm_connection_get_setting_connection (NM_CONNECTION (self)); @@ -160,11 +171,13 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self) filename = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self)); if (!filename) return; - devtimeout = devtimeout_from_file (filename); - if (!devtimeout) + + pllink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, ifname); + if (pllink && pllink->initialized) return; - if (nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname) != 0) + devtimeout = devtimeout_from_file (filename); + if (!devtimeout) return; /* ONBOOT=yes, DEVICE and DEVTIMEOUT are set, but device is not present */ @@ -261,7 +274,7 @@ path_watch_stop (NMIfcfgConnection *self) NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); NMInotifyHelper *ih; - ih = nm_inotify_helper_get (); + ih = _get_inotify_helper (priv); if (priv->ih_event_id) { g_signal_handler_disconnect (ih, priv->ih_event_id); @@ -315,7 +328,9 @@ filename_changed (GObject *object, priv->route6file = utils_get_route6_path (ifcfg_path); if (nm_config_get_monitor_connection_files (nm_config_get ())) { - NMInotifyHelper *ih = nm_inotify_helper_get (); + NMInotifyHelper *ih; + + ih = _get_inotify_helper (priv); priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (files_changed_cb), self); priv->file_wd = nm_inotify_helper_add_watch (ih, ifcfg_path); @@ -509,6 +524,8 @@ dispose (GObject *object) priv->devtimeout_timeout_id = 0; } + g_clear_object (&priv->inotify_helper); + G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object); } diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index 1a3f791a4..526cdafea 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -42,7 +42,7 @@ #include <selinux/selinux.h> #endif -#include <nm-setting-connection.h> +#include "nm-setting-connection.h" #include "common.h" #include "nm-dbus-glib-types.h" @@ -64,22 +64,15 @@ #define DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1" -#define _LOG_DEFAULT_DOMAIN LOGD_SETTINGS - -#define _LOG(level, domain, ...) \ +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG(level, ...) \ G_STMT_START { \ - nm_log ((level), (domain), \ + nm_log ((level), (_NMLOG_DOMAIN), \ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ "ifcfg-rh: " \ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ } G_STMT_END -#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGI(...) _LOG (LOGL_INFO, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGW(...) _LOG (LOGL_WARN, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) -#define _LOGE(...) _LOG (LOGL_ERR, _LOG_DEFAULT_DOMAIN, __VA_ARGS__) - #define ERR_GET_MSG(err) (((err) && (err)->message) ? (err)->message : "(unknown)") diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index ec8741677..72123e669 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -250,6 +250,15 @@ make_connection_setting (const char *file, g_free (value); } + switch (svTrueValue (ifcfg, "CONNECTION_METERED", -1)) { + case TRUE: + g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_YES, NULL); + break; + case FALSE: + g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_NO, NULL); + break; + } + return NM_SETTING (s_con); } @@ -3492,6 +3501,80 @@ wireless_connection_from_ifcfg (const char *file, return connection; } +static void +parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value) +{ + NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; + gboolean use_password = FALSE; + char **words, **iter, *flag; + + if (!value || !value[0]) + return; + + words = g_strsplit_set (value, " ", 0); + iter = words; + + while (iter[0]) { + if (g_str_equal (iter[0], "wol") && iter[1] && *iter[1]) { + for (flag = iter[1]; *flag; flag++) { + switch (*flag) { + case 'p': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY; + break; + case 'u': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST; + break; + case 'm': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST; + break; + case 'b': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST; + break; + case 'a': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_ARP; + break; + case 'g': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; + break; + case 's': + use_password = TRUE; + break; + case 'd': + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; + use_password = FALSE; + break; + default: + PARSE_WARNING ("unrecognized Wake-on-LAN option '%c'", *flag); + } + } + + if (!NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) + use_password = FALSE; + + g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, NULL); + iter += 2; + continue; + } + + if (g_str_equal (iter[0], "sopass") && iter[1] && *iter[1]) { + if (use_password) { + if (nm_utils_hwaddr_valid (iter[1], ETH_ALEN)) + g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, iter[1], NULL); + else + PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", iter[1]); + } else + PARSE_WARNING ("Wake-on-LAN password not expected"); + iter += 2; + continue; + } + + /* Silently skip unknown options */ + iter++; + } + + g_strfreev (words); +} + static NMSetting * make_wired_setting (shvarFile *ifcfg, const char *file, @@ -3627,6 +3710,10 @@ make_wired_setting (shvarFile *ifcfg, g_free (value); } + value = svGetValue (ifcfg, "ETHTOOL_OPTS", FALSE); + parse_ethtool_options (ifcfg, s_wired, value); + g_free (value); + return (NMSetting *) s_wired; error: diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 4a5ca1d18..283aa8261 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -303,11 +303,11 @@ svGetValueFull (shvarFile *s, const char *key, gboolean verbatim) * return FALSE if <key> resolves to any non-truth value (e.g. "no", "n", "false") * return <default> otherwise */ -gboolean -svTrueValue (shvarFile *s, const char *key, gboolean def) +gint +svTrueValue (shvarFile *s, const char *key, gint def) { char *tmp; - gboolean returnValue = def; + gint returnValue = def; tmp = svGetValue (s, key, FALSE); if (!tmp) diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index 4902541b0..de7a35855 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -62,7 +62,7 @@ char *svGetValueFull (shvarFile *s, const char *key, gboolean verbatim); * return FALSE if <key> resolves to any non-truth value (e.g. "no", "n", "false") * return <def> otherwise */ -gboolean svTrueValue (shvarFile *s, const char *key, gboolean def); +gint svTrueValue (shvarFile *s, const char *key, gint def); gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback); diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index a20a78d9a..7b5aaf171 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -123,7 +123,8 @@ EXTRA_DIST = \ ifcfg-test-team-master \ ifcfg-test-team-port \ ifcfg-test-team-port-empty-config \ - ifcfg-test-vlan-trailing-spaces + ifcfg-test-vlan-trailing-spaces \ + ifcfg-test-wired-wake-on-lan # make target dependencies can't have colons in their names, which ends up # meaning that we can't add the alias files to EXTRA_DIST diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in index ef06c5ef3..2435434d5 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in @@ -518,7 +518,8 @@ EXTRA_DIST = \ ifcfg-test-team-master \ ifcfg-test-team-port \ ifcfg-test-team-port-empty-config \ - ifcfg-test-vlan-trailing-spaces + ifcfg-test-vlan-trailing-spaces \ + ifcfg-test-wired-wake-on-lan # make target dependencies can't have colons in their names, which ends up diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-wake-on-lan b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-wake-on-lan new file mode 100644 index 000000000..1dfc9a433 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-wake-on-lan @@ -0,0 +1,22 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +ONBOOT=yes +USERCTL=yes +MTU=1492 +NM_CONTROLLED=yes +DNS1=4.2.2.1 +DNS2=4.2.2.2 +IPADDR=192.168.1.5 +NETMASK=255.255.255.0 +GATEWAY=192.168.1.1 +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR=dead:beaf::1 +IPV6ADDR_SECONDARIES="dead:beaf::2/56" +DNS3=1:2:3:4::a +DNS4=1:2:3:4::b +RES_OPTIONS= +ETHTOOL_OPTS="speed 100 duplex full wol apgs sopass 00:11:22:33:44:55 autoneg off" diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index d2fb6867c..f2f85d3c1 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -5104,6 +5104,43 @@ test_read_wifi_wep_eap_ttls_chap (void) } static void +test_read_wired_wake_on_lan (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + gboolean success; + GError *error = NULL; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-wake-on-lan", + NULL, TYPE_WIRELESS, NULL, &error); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + g_assert_cmpint (nm_setting_wired_get_wake_on_lan (s_wired), + ==, + NM_SETTING_WIRED_WAKE_ON_LAN_ARP | + NM_SETTING_WIRED_WAKE_ON_LAN_PHY | + NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC); + + g_assert_cmpstr (nm_setting_wired_get_wake_on_lan_password (s_wired), + ==, + "00:11:22:33:44:55"); + + g_object_unref (connection); +} + +static void test_read_wifi_hidden (void) { NMConnection *connection; @@ -5218,6 +5255,90 @@ test_write_wifi_hidden (void) } static void +test_write_wired_wake_on_lan (void) +{ + NMConnection *connection, *reread; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingWiredWakeOnLan wol; + char *uuid, *testfile = NULL, *val; + gboolean success; + GError *error = NULL; + shvarFile *f; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Write Wired Wake-on-LAN", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wired setting */ + s_wired = (NMSettingWired *) nm_setting_wired_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + wol = NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST | + NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST | + NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; + + g_object_set (s_wired, + NM_SETTING_WIRED_WAKE_ON_LAN, wol, + NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, "00:00:00:11:22:33", + NULL); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert_no_error (error); + g_assert (success); + + f = svOpenFile (testfile, &error); + g_assert_no_error (error); + g_assert (f); + + /* re-read the file to check that the key was written. */ + val = svGetValue (f, "ETHTOOL_OPTS", FALSE); + g_assert (val); + g_assert (strstr (val, "wol")); + g_assert (strstr (val, "sopass 00:00:00:11:22:33")); + g_free (val); + svCloseFile (f); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (testfile, NULL, TYPE_ETHERNET, + NULL, &error); + unlink (testfile); + g_assert_no_error (error); + g_assert (reread); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + g_assert (success); + + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + g_free (testfile); + g_object_unref (connection); + g_object_unref (reread); +} + +static void test_read_wifi_band_a (void) { NMConnection *connection; @@ -6405,7 +6526,7 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) g_assert (addr6); /* assert that the gateway was written and reloaded as expected */ - if (!gateway6 || !strcmp (gateway6, "::")) { + if (!gateway6) { g_assert (nm_setting_ip_config_get_gateway (s_ip6) == NULL); g_assert (written_ifcfg_gateway == NULL); } else { @@ -12551,6 +12672,7 @@ int main (int argc, char **argv) test_read_vlan_only_vlan_id (); test_read_vlan_only_device (); g_test_add_func (TPATH "vlan/physdev", test_read_vlan_physdev); + g_test_add_func (TPATH "wired/read-wake-on-lan", test_read_wired_wake_on_lan); test_write_wired_static (); test_write_wired_static_ip6_only (); @@ -12565,6 +12687,7 @@ int main (int argc, char **argv) test_write_wired_8021x_tls (NM_SETTING_802_1X_CK_SCHEME_BLOB, NM_SETTING_SECRET_FLAG_NONE); test_write_wired_aliases (); g_test_add_func (TPATH "ipv4/write-static-addresses-GATEWAY", test_write_gateway); + g_test_add_func (TPATH "wired/write-wake-on-lan", test_write_wired_wake_on_lan); test_write_wifi_open (); test_write_wifi_open_hex_ssid (); test_write_wifi_wep (); diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 52bf51d18..69b7d64ac 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -42,6 +42,8 @@ #include <nm-setting-team-port.h> #include "nm-core-internal.h" #include <nm-utils.h> +#include "nm-core-internal.h" +#include "nm-macros-internal.h" #include "nm-logging.h" #include "gsystem-local-alloc.h" @@ -1048,6 +1050,8 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) const char *const *s390_subchannels; GString *str; const char * const *macaddr_blacklist; + NMSettingWiredWakeOnLan wol; + const char *wol_password; s_wired = nm_connection_get_setting_wired (connection); if (!s_wired) { @@ -1131,6 +1135,37 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_string_free (str, TRUE); } + wol = nm_setting_wired_get_wake_on_lan (s_wired); + wol_password = nm_setting_wired_get_wake_on_lan_password (s_wired); + if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) + svSetValue (ifcfg, "ETHTOOL_OPTS", NULL, FALSE); + else { + str = g_string_sized_new (30); + g_string_append (str, "wol "); + + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_PHY)) + g_string_append (str, "p"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST)) + g_string_append (str, "u"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST)) + g_string_append (str, "m"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST)) + g_string_append (str, "b"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ARP)) + g_string_append (str, "a"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) + g_string_append (str, "g"); + + if (!NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ALL)) + g_string_append (str, "d"); + + if (wol_password && NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) + g_string_append_printf (str, "s sopass %s", wol_password); + + svSetValue (ifcfg, "ETHTOOL_OPTS", str->str, FALSE); + g_string_free (str, TRUE); + } + svSetValue (ifcfg, "TYPE", TYPE_ETHERNET, FALSE); return TRUE; @@ -1159,11 +1194,42 @@ vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap ma } static gboolean +write_wired_for_virtual (NMConnection *connection, shvarFile *ifcfg) +{ + NMSettingWired *s_wired; + gboolean has_wired = FALSE; + + s_wired = nm_connection_get_setting_wired (connection); + if (s_wired) { + const char *device_mac, *cloned_mac; + char *tmp; + guint32 mtu; + + has_wired = TRUE; + + device_mac = nm_setting_wired_get_mac_address (s_wired); + if (device_mac) + svSetValue (ifcfg, "HWADDR", device_mac, FALSE); + + cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); + if (cloned_mac) + svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); + + mtu = nm_setting_wired_get_mtu (s_wired); + if (mtu) { + tmp = g_strdup_printf ("%u", mtu); + svSetValue (ifcfg, "MTU", tmp, FALSE); + g_free (tmp); + } + } + return has_wired; +} + +static gboolean write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) { NMSettingVlan *s_vlan; NMSettingConnection *s_con; - NMSettingWired *s_wired; char *tmp; guint32 vlan_flags = 0; @@ -1217,34 +1283,13 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, svSetValue (ifcfg, "MACADDR", NULL, FALSE); svSetValue (ifcfg, "MTU", NULL, FALSE); - s_wired = nm_connection_get_setting_wired (connection); - if (s_wired) { - const char *device_mac, *cloned_mac; - guint32 mtu; - - *wired = TRUE; - - device_mac = nm_setting_wired_get_mac_address (s_wired); - if (device_mac) - svSetValue (ifcfg, "HWADDR", device_mac, FALSE); - - cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) - svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); - - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) { - tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); - g_free (tmp); - } - } + *wired = write_wired_for_virtual (connection, ifcfg); return TRUE; } static gboolean -write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) { NMSettingBond *s_bond; const char *iface; @@ -1292,11 +1337,13 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro svSetValue (ifcfg, "TYPE", TYPE_BOND, FALSE); svSetValue (ifcfg, "BONDING_MASTER", "yes", FALSE); + *wired = write_wired_for_virtual (connection, ifcfg); + return TRUE; } static gboolean -write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) { NMSettingTeam *s_team; const char *iface; @@ -1321,6 +1368,8 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (ifcfg, "TEAM_CONFIG", config, FALSE); svSetValue (ifcfg, "DEVICETYPE", TYPE_TEAM, FALSE); + *wired = write_wired_for_virtual (connection, ifcfg); + return TRUE; } @@ -1764,6 +1813,17 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) svSetValue (ifcfg, "GATEWAY_PING_TIMEOUT", tmp, FALSE); g_free (tmp); } + + switch (nm_setting_connection_get_metered (s_con)) { + case NM_METERED_YES: + svSetValue (ifcfg, "CONNECTION_METERED", "yes", FALSE); + break; + case NM_METERED_NO: + svSetValue (ifcfg, "CONNECTION_METERED", "no", FALSE); + break; + default: + svSetValue (ifcfg, "CONNECTION_METERED", NULL, FALSE); + } } static gboolean @@ -2564,10 +2624,10 @@ write_connection (NMConnection *connection, if (!write_infiniband_setting (connection, ifcfg, error)) goto out; } else if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME)) { - if (!write_bonding_setting (connection, ifcfg, error)) + if (!write_bonding_setting (connection, ifcfg, &wired, error)) goto out; } else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME)) { - if (!write_team_setting (connection, ifcfg, error)) + if (!write_team_setting (connection, ifcfg, &wired, error)) goto out; } else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)) { if (!write_bridge_setting (connection, ifcfg, error)) diff --git a/src/supplicant-manager/nm-supplicant-config.c b/src/supplicant-manager/nm-supplicant-config.c index b78a24d03..c4c725c14 100644 --- a/src/supplicant-manager/nm-supplicant-config.c +++ b/src/supplicant-manager/nm-supplicant-config.c @@ -308,12 +308,32 @@ nm_supplicant_config_get_blobs (NMSupplicantConfig * self) return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->blobs; } -#define TWO_GHZ_FREQS "2412,2417,2422,2427,2432,2437,2442,2447,2452,2457,2462,2467,2472,2484" -#define FIVE_GHZ_FREQS "4915,4920,4925,4935,4940,4945,4960,4980,5035,5040,5045,5055,5060,5080," \ - "5170,5180,5190,5200,5210,5220,5230,5240,5260,5280,5300,5320,5500," \ - "5520,5540,5560,5580,5600,5620,5640,5660,5680,5700,5745,5765,5785," \ - "5805,5825" - +static const char * +wifi_freqs_to_string (gboolean bg_band) +{ + static const char *str_2ghz = NULL; + static const char *str_5ghz = NULL; + const char *str; + + str = bg_band ? str_2ghz : str_5ghz; + + if (G_UNLIKELY (str == NULL)) { + GString *tmp; + const guint *freqs; + int i; + + freqs = bg_band ? nm_utils_wifi_2ghz_freqs () : nm_utils_wifi_5ghz_freqs (); + tmp = g_string_sized_new (bg_band ? 70 : 225); + for (i = 0; freqs[i]; i++) + g_string_append_printf (tmp, i == 0 ? "%d" : " %d", freqs[i]); + str = g_string_free (tmp, FALSE); + if (bg_band) + str_2ghz = str; + else + str_5ghz = str; + } + return str; +} gboolean nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self, @@ -323,6 +343,7 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self, NMSupplicantConfigPrivate *priv; gboolean is_adhoc, is_ap; const char *mode, *band; + guint32 channel; GBytes *ssid; const char *bssid; @@ -393,22 +414,35 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self, } band = nm_setting_wireless_get_band (setting); + channel = nm_setting_wireless_get_channel (setting); if (band) { - const char *freqs = NULL; + if (channel) { + guint32 freq; + char *str_freq; + + freq = nm_utils_wifi_channel_to_freq (channel, band); + str_freq = g_strdup_printf ("%u", freq); + if (!nm_supplicant_config_add_option (self, "freq_list", str_freq, -1, FALSE)) { + g_free (str_freq); + nm_log_warn (LOGD_SUPPLICANT, "Error adding frequency list to supplicant config."); + return FALSE; + } + g_free (str_freq); + } else { + const char *freqs = NULL; - if (!strcmp (band, "a")) - freqs = FIVE_GHZ_FREQS; - else if (!strcmp (band, "bg")) - freqs = TWO_GHZ_FREQS; + if (!strcmp (band, "a")) + freqs = wifi_freqs_to_string (FALSE); + else if (!strcmp (band, "bg")) + freqs = wifi_freqs_to_string (TRUE); - if (freqs && !nm_supplicant_config_add_option (self, "freq_list", freqs, strlen (freqs), FALSE)) { - nm_log_warn (LOGD_SUPPLICANT, "Error adding frequency list/band to supplicant config."); - return FALSE; + if (freqs && !nm_supplicant_config_add_option (self, "freq_list", freqs, strlen (freqs), FALSE)) { + nm_log_warn (LOGD_SUPPLICANT, "Error adding frequency list/band to supplicant config."); + return FALSE; + } } } - // FIXME: channel config item - return TRUE; } diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c index e9775a199..66bab2e39 100644 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ b/src/supplicant-manager/nm-supplicant-interface.c @@ -1093,8 +1093,14 @@ scan_request_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - if (error) - nm_log_warn (LOGD_SUPPLICANT, "Could not get scan request result: %s", error->message); + if (error) { + if (_nm_dbus_error_has_name (error, "fi.w1.wpa_supplicant1.Interface.ScanError")) + nm_log_dbg (LOGD_SUPPLICANT, "Could not get scan request result: %s", error->message); + else { + g_dbus_error_strip_remote_error (error); + nm_log_warn (LOGD_SUPPLICANT, "Could not get scan request result: %s", error->message); + } + } g_signal_emit (NM_SUPPLICANT_INTERFACE (user_data), signals[SCAN_DONE], 0, error ? FALSE : TRUE); } diff --git a/src/tests/config/nm-test-device.c b/src/tests/config/nm-test-device.c index b5f65ded6..681f49660 100644 --- a/src/tests/config/nm-test-device.c +++ b/src/tests/config/nm-test-device.c @@ -26,10 +26,10 @@ #include "nm-device-private.h" #include "nm-utils.h" -static GObjectClass *g_object_class; - G_DEFINE_TYPE (NMTestDevice, nm_test_device, NM_TYPE_DEVICE) +#define PARENT_CLASS (G_OBJECT_CLASS (g_type_class_peek_parent (nm_test_device_parent_class))) + static void nm_test_device_init (NMTestDevice *self) { @@ -44,21 +44,21 @@ constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params) { - return g_object_class->constructor (type, - n_construct_params, - construct_params); + return PARENT_CLASS->constructor (type, + n_construct_params, + construct_params); } static void constructed (GObject *object) { - g_object_class->constructed (object); + PARENT_CLASS->constructed (object); } static void dispose (GObject *object) { - g_object_class->dispose (object); + PARENT_CLASS->dispose (object); } static NMDeviceCapabilities @@ -73,8 +73,6 @@ nm_test_device_class_init (NMTestDeviceClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_object_class = g_type_class_peek (G_TYPE_OBJECT); - object_class->constructor = constructor; object_class->constructed = constructed; object_class->dispose = dispose; diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index bb52bde20..fe76e3fad 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -35,6 +35,42 @@ /*******************************************/ +static void +test_nm_utils_monotonic_timestamp_as_boottime (void) +{ + gint64 timestamp_ns_per_tick, now, now_boottime, now_boottime_2, now_boottime_3; + struct timespec tp; + clockid_t clockid; + guint i; + + if (clock_gettime (CLOCK_BOOTTIME, &tp) != 0 && errno == EINVAL) + clockid = CLOCK_MONOTONIC; + else + clockid = CLOCK_BOOTTIME; + + for (i = 0; i < 10; i++) { + + if (clock_gettime (clockid, &tp) != 0) + g_assert_not_reached (); + now_boottime = ( ((gint64) tp.tv_sec) * NM_UTILS_NS_PER_SECOND ) + ((gint64) tp.tv_nsec); + + now = nm_utils_get_monotonic_timestamp_ns (); + + now_boottime_2 = nm_utils_monotonic_timestamp_as_boottime (now, 1); + g_assert_cmpint (now_boottime_2, >=, 0); + g_assert_cmpint (now_boottime_2, >=, now_boottime); + g_assert_cmpint (now_boottime_2 - now_boottime, <=, NM_UTILS_NS_PER_SECOND / 1000); + + for (timestamp_ns_per_tick = 1; timestamp_ns_per_tick <= NM_UTILS_NS_PER_SECOND; timestamp_ns_per_tick *= 10) { + now_boottime_3 = nm_utils_monotonic_timestamp_as_boottime (now / timestamp_ns_per_tick, timestamp_ns_per_tick); + + g_assert_cmpint (now_boottime_2 / timestamp_ns_per_tick, ==, now_boottime_3); + } + } +} + +/*******************************************/ + struct test_nm_utils_kill_child_async_data { GMainLoop *loop; @@ -385,7 +421,7 @@ _remove_at_indexes_init_random_idx (GArray *idx, guint array_len, guint idx_len) } static void -test_nm_utils_array_remove_at_indexes () +test_nm_utils_array_remove_at_indexes (void) { gs_unref_array GArray *idx = NULL, *array = NULL; gs_unref_hashtable GHashTable *unique = NULL; @@ -822,6 +858,7 @@ main (int argc, char **argv) { nmtst_init_assert_logging (&argc, &argv, "DEBUG", "DEFAULT"); + g_test_add_func ("/general/nm_utils_monotonic_timestamp_as_boottime", test_nm_utils_monotonic_timestamp_as_boottime); g_test_add_func ("/general/nm_utils_kill_child", test_nm_utils_kill_child); g_test_add_func ("/general/nm_ethernet_address_is_valid", test_nm_ethernet_address_is_valid); g_test_add_func ("/general/nm_multi_index", test_nm_multi_index); diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index c8bdc75fb..235cfd426 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -316,12 +316,12 @@ test_merge_subtract_mss_mtu (void) nm_ip4_config_set_mss (cfg3, expected_mss3); nm_ip4_config_set_mtu (cfg3, expected_mtu3, NM_IP_CONFIG_SOURCE_UNKNOWN); - nm_ip4_config_merge (cfg1, cfg2); + nm_ip4_config_merge (cfg1, cfg2, NM_IP_CONFIG_MERGE_DEFAULT); /* ensure MSS and MTU are in cfg1 */ g_assert_cmpuint (nm_ip4_config_get_mss (cfg1), ==, expected_mss2); g_assert_cmpuint (nm_ip4_config_get_mtu (cfg1), ==, expected_mtu2); - nm_ip4_config_merge (cfg1, cfg3); + nm_ip4_config_merge (cfg1, cfg3, NM_IP_CONFIG_MERGE_DEFAULT); /* ensure again the MSS and MTU in cfg1 got overriden */ g_assert_cmpuint (nm_ip4_config_get_mss (cfg1), ==, expected_mss3); g_assert_cmpuint (nm_ip4_config_get_mtu (cfg1), ==, expected_mtu3); diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c index 0164930d6..9046bf88b 100644 --- a/src/tests/test-route-manager.c +++ b/src/tests/test-route-manager.c @@ -377,7 +377,7 @@ setup_dev0_ip6 (int ifindex) /* Add an address so that a route to the gateway below gets added. */ nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, - *nmtst_inet6_from_string ("2001:db8:8086::2"), + *nmtst_inet6_from_string ("2001:db8:8086::666"), in6addr_any, 64, 3600, diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 795a81873..c34155efa 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -932,11 +932,11 @@ apply_parent_device_config (NMVpnConnection *connection) * vpn-config. Instead we tell NMDefaultRouteManager directly about the * default route. */ if (vpn4_parent_config) { - nm_ip4_config_merge (vpn4_parent_config, priv->ip4_config); + nm_ip4_config_merge (vpn4_parent_config, priv->ip4_config, NM_IP_CONFIG_MERGE_DEFAULT); nm_ip4_config_set_gateway (vpn4_parent_config, 0); } if (vpn6_parent_config) { - nm_ip6_config_merge (vpn6_parent_config, priv->ip6_config); + nm_ip6_config_merge (vpn6_parent_config, priv->ip6_config, NM_IP_CONFIG_MERGE_DEFAULT); nm_ip6_config_set_gateway (vpn6_parent_config, NULL); } } |