1. 19 Nov, 2014 2 commits
    • Lubomir Rintel's avatar
      libnm-core: Add missing type cast · c30379e0
      Lubomir Rintel authored
      Fixes testing on 32-bit arches:
      (./test-general:29331): GLib-GObject-WARNING **: g_object_set_valist: object class `NMSettingConnection' has no property named `$?\xff\xff\x89t$0\x89|$4\xe8\u001c\x98\xff\xff\x85\xc0tM\x83\xf8\xfft3\x8dT$(\xc7D$\u0008'
      /bin/sh: line 5: 29331 Trace/breakpoint trap   ${dir}$tst
      FAIL: test-general
      Fixes: 093a3c88
    • Jiří Klimeš's avatar
      libnm-core: add NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP flag · 093a3c88
      Jiří Klimeš authored
      for ignoring timestamp when comparing settings or connections.
  2. 15 Nov, 2014 1 commit
    • Dan Winship's avatar
      libnm-core: change how new and legacy properties are serialized · c785a7df
      Dan Winship authored
      Although libnm filters out properties received from the daemon that it
      doesn't understand, there may be other clients that do not. In
      particular, a client might call GetSettings() on a connection, update
      the ipv4.addresses property in the returned dictionary, and then pass
      the dictionary to Update(). In that case, the updated dictionary would
      contain ipv4.address-data, but it would not reflect the changes the
      client intended to make.
      Fix this by changing the daemon side to prefer the legacy properties
      to the new ones if both are set, and changing the client side to not
      send the legacy properties (since we don't support new clients talking
      to old servers anyway).
  3. 13 Nov, 2014 1 commit
    • Dan Winship's avatar
      all: consistently include config.h · 3bfb163a
      Dan Winship authored
      config.h should be included from every .c file, and it should be
      included before any other include. Fix that.
      (As a side effect of how I did this, this also changes us to
      consistently use "config.h" rather than <config.h>. To the extent that
      it matters [which is not much], quotes are more correct anyway, since
      we're talking about a file in our own build tree, not a system
  4. 07 Nov, 2014 8 commits
    • Dan Williams's avatar
      libnm,core: enhance nm_utils_hexstr2bin() · 22762324
      Dan Williams authored
      Make the type return GBytes since most in-tree users want that.
      Allow the function to accept many more formats as valid hex, including
      bytes delimited by ':' and a leading '0x'.
    • Thomas Haller's avatar
    • Dan Winship's avatar
      libnm-core: don't serialize empty address-labels · ff608c24
      Dan Winship authored
      If no address in an NMSettingIP4Config has a label, then don't bother
      serializing an array of empty strings.
    • Dan Winship's avatar
      libnm-core, libnm, core: add AddressData and RouteData properties · d16905df
      Dan Winship authored
      Add AddressData and RouteData properties to NMSettingIPConfig and
      NMIP[46]Config. These are like the existing "addresses" and "routes"
      properties, but using strings and containing additional attributes,
      like NMIPAddress and NMIPRoute.
      This only affects the D-Bus representations; there are no API changes
      to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
      additional information is just added to the existing 'addresses' and
      'routes' properties.
      NMSettingIP4Config and NMSettingIP6Config now always generate both
      old-style data ('addresses', 'address-labels', 'routes') and new-style
      data ('address-data', 'gateway', 'route-data') when serializing to
      D-Bus, for backward compatibility. When deserializing, they will fill
      in the 'addresses' and 'routes' properties from the new-style data if
      it is present (ignoring the old-style data), or from the old-style
      data if the new-style isn't present.
      The daemon-side NMIP4Config and NMIP6Config always emit changes for
      both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
      libnm-side classes initially listen for changes on both properties,
      but start ignoring the 'Addresses' and 'Routes' properties once they
      know the daemon is also providing 'AddressData' and 'RouteData'.
    • Dan Winship's avatar
      libnm-core: add NMSettingIPConfig:gateway, drop NMIPAddress:gateway · f17699f4
      Dan Winship authored
      The gateway is a global property of the IPv4/IPv6 configuration, not
      an attribute of any particular address. So represent it as such in the
      API; remove the gateway from NMIPAddress, and add it to
      Behind the scenes, the gateway is still serialized along with the
      first address in NMSettingIPConfig:addresses, and is deserialized from
      that if the settings dictionary doesn't contain a 'gateway' key.
      Adjust nmcli's interactive mode to prompt for IP addresses and gateway
      separately. (Patch partly from Jirka Klimeš.)
    • Dan Winship's avatar
      libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classes · 3f30c6f1
      Dan Winship authored
      Split a base NMSettingIPConfig class out of NMSettingIP4Config and
      NMSettingIP6Config, and update things accordingly.
      Further simplifications of now-redundant IPv4-vs-IPv6 code are
      possible, and should happen in the future.
    • Dan Winship's avatar
      libnm-core: add NMIPAddress/NMIPRoute attributes, use for labels · 39709fdc
      Dan Winship authored
      Add key-value attributes to NMIPAddress and NMIPRoute, and use them to
      store IPv4 address labels. Demote NMSettingIP4Config:address-labels to
      a D-Bus-only property, and arrange for :addresses setter to read the
      labels out of that property when creating the addresses.
    • Dan Winship's avatar
      libnm-core, all: merge IPv4 and IPv6 address/route types · 21c8a6b2
      Dan Winship authored
      Merge NMIP4Address and NMIP6Address into NMIPAddress, and NMIP4Route
      and NMIP6Route into NMIPRoute. The new types represent IP addresses as
      strings, rather than in binary, and so are address-family agnostic.
  5. 29 Oct, 2014 1 commit
  6. 28 Oct, 2014 4 commits
    • Dan Winship's avatar
      libnm-core: make nm_setting_verify() take an NMConnection · 9e5c7d91
      Dan Winship authored
      nm_setting_verify() took a GSList of other NMSettings, but really it
      would just be simpler all around to pass the NMConnection instead...
      This means that several formerly NMSetting-branded functions that
      operated on lists-of-settings now get replaced with
      NMConnection-branded functions instead.
    • Dan Winship's avatar
      libnm-core: add nm-core-types.h, remove cross-includes · b1087908
      Dan Winship authored
      Add nm-core-types.h, typedefing all of the GObject types in
      libnm-core; this is needed so that nm-setting.h can reference
      NMConnection in addition to nm-connection.h referencing NMSetting.
      Removing the cross-includes from the various headers causes lots of
      fallout elsewhere. (In particular, nm-utils.h used to include
      nm-connection.h, which included every setting header, so any file that
      included nm-utils.h automatically got most of the rest of libnm-core
      without needing to pay attention to specifics.) Fix this up by
      including nm-core-internal.h from those files that are now missing
    • Dan Winship's avatar
      libnm-core: canonicalize hardware addresses in settings · b084ad7f
      Dan Winship authored
      Convert hardware addresses to canonical form (uppercase, leading
      zeros, colons) when setting them on/adding them to NMSetting
    • Dan Winship's avatar
      libnm-core: add nm_utils_hwaddr_canonical() · 61e489a7
      Dan Winship authored
      Add a helper function for converting hardware addresses to canonical
  7. 22 Oct, 2014 2 commits
    • Dan Winship's avatar
      libnm-core: merge NMSetting*Error into NMConnectionError · 2d8e7bd2
      Dan Winship authored
      Each setting type was defining its own error type, but most of them
      had exactly the same three errors ("unknown", "missing property", and
      "invalid property"), and none of the other values was of much use
      programmatically anyway.
      So, this commit merges NMSettingError, NMSettingAdslError, etc, all
      into NMConnectionError. (The reason for merging into NMConnectionError
      rather than NMSettingError is that we also already have
      "NMSettingsError", for errors related to the settings service, so
      "NMConnectionError" is a less-confusable name for settings/connection
      errors than "NMSettingError".)
      Also, make sure that all of the affected error messages are localized,
      and (where appropriate) prefix them with the relevant property name.
      Renamed error codes:
      Remapped error codes:
      Dropped error codes (were previously defined but unused):
    • Dan Winship's avatar
      libnm-core: clean up NMConnectionError · aeb3d093
      Dan Winship authored
      following GError best practices.
      NMSettingConnection") with a more generic
      NM_CONNECTION_ERROR_MISSING_SETTING. Use that new code in a few places
      that had previously been using NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
      which was supposed to mean "the setting that you asked about doesn't
      exist", not "the connection is invalid because it's missing a required
      Clarify that NM_CONNECTION_ERROR_INVALID_SETTING can be used for any
      "invalid or inappropriate NMSetting", not just a "conflicting" one.
      (But fix a case in nm_connection_update_secrets() that was returning
      INVALID_SETTING when it should have been return-if-failing instead.)
      For both MISSING_SETTING and INVALID_SETTING, always prefix the error
      message with "setting-name: ", just like we do with the various
      NMSetting MISSING_PROPERTY and INVALID_PROPERTY errors. And make sure
      that the error message is marked for localization.
      pointless; it was only used in the case where connection.type was the
      name of a valid setting type that is not a base setting type. Instead,
      connection.type in this case (which is what the code already did when
      connection.type was completely unrecognized).
  8. 12 Oct, 2014 1 commit
  9. 03 Oct, 2014 2 commits
    • Dan Winship's avatar
      libnm-core: make NMSettingSerial:parity an enum · a91e6090
      Dan Winship authored
      NMSettingSerial:parity was defined as a char-typed property that could
      have the (case-sensitive!) values 'n', 'E', or 'o'. This is zany. Add
      an NMSettingSerialParity enum, and use that instead.
    • Dan Winship's avatar
      libnm: make use of GParamSpecFlags and GParamSpecEnum · fcfb4b40
      Dan Winship authored
      Make enum- and flags-valued properties use GParamSpecEnum and
      GParamSpecFlags, for better introspectability/bindability.
      This requires no changes outside libnm-core/libnm since the expected
      data size is still the same with g_object_get()/g_object_set(), and
      GLib will internally convert between int/uint and enum/flags GValues
      when using g_object_get_property()/g_object_set_property().
  10. 22 Sep, 2014 1 commit
    • Thomas Haller's avatar
      libnm-core: fix crash in update-secrets when trying to clear all settings... · 85566e46
      Thomas Haller authored
      libnm-core: fix crash in update-secrets when trying to clear all settings without providing a connection variant
      When the caller wants to clear all settings (thus providing
      @setting_name NULL), a NM_VARIANT_TYPE_CONNECTION variant is
      expected. This would lead to a crash when constructing the
      @Error literal due to uninitialized @key.
      Clang also warns:
          Making all in .
          make[4]: Entering directory `./NetworkManager/libnm-core'
            CC       nm-connection.lo
          ../libnm-core/nm-connection.c:1016:25: error: variable 'key' is uninitialized when used here [-Werror,-Wuninitialized]
          ../libnm-core/nm-connection.c:962:17: note: initialize the variable 'key' to silence this warning
                  const char *key;
                                  = NULL
          1 error generated.
      Fixes: acf86f68Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
  11. 18 Sep, 2014 2 commits
    • Dan Winship's avatar
      libnm-core: update tests to be fully variant-based · 16871ebc
      Dan Winship authored
      Use nmtst_variant_editor() to rewrite the libnm-core tests to work
      entirely in connection dictionaries, not connection hash tables.
    • Dan Winship's avatar
      libnm-core: change connection hash tables to variants in API · acf86f68
      Dan Winship authored
      In preparation for porting to GDBus, make nm_connection_to_dbus(),
      etc, represent connections as GVariants of type 'a{sa{sv}}' rather
      than as GHashTables-of-GHashTables-of-GValues.
      This means we're constantly converting back and forth internally, but
      this is just a stepping stone on the way to the full GDBus port, and
      all of that code will go away again later.
  12. 17 Sep, 2014 2 commits
    • Dan Winship's avatar
      libnm-core: fix up connection deserialize/copy/replace semantics · ad8b1309
      Dan Winship authored
      libnm-util's connection deserializing/copying/replacing functions have
      odd semantics where sometimes they both modify a connection AND return
      an error. libnm-core tried to improve things by guaranteeing that the
      connection would not be modified if the new settings were invalid, but
      this ended up breaking a bunch of places that needed to be able to
      work with invalid connections. So re-fix the functions by reverting
      back to the old semantics, but having return values that clearly
      distinguish whether the connection was modified or not.
      For comparison:
        - nm_connection_new_from_hash() / nm_simple_connection_new_from_dbus():
            - libnm-util: returns a valid connection or NULL.
            - OLD libnm-core: returned a valid connection or NULL.
            - NEW libnm-core: returns a valid connection or NULL.
        - nm_connection_duplicate() / nm_simple_connection_new_clone():
            - libnm-util: always succeeds, whether or not the connection is
            - OLD libnm-core: returned a valid connection or NULL
            - NEW libnm-core: always succeeds, whether or not the connection
              is valid.
          - nm_connection_replace_settings_from_connection():
            - libnm-util: always replaces the settings, but returns FALSE if
              the connection is now invalid.
            - OLD libnm-core: either replaced the settings and returned TRUE
              (if the settings were valid), or else left the connection
              unchanged and returned FALSE (if not).
            - NEW libnm-core: always replaces the settings, and has no
              return value. (The modified connection is valid if and only if
              the replaced-from connection was valid; just like with the
              libnm-util version.)
          - nm_connection_replace_settings():
            - libnm-util: returns TRUE if the new settings are valid, or
              FALSE if either (a) the new settings could not be deserialized
              and the connection is unchanged, or (b) the new settings were
              deserialized, and the connection was updated, but is now not
            - OLD libnm-core: either replaced the settings and returned TRUE
              (if the settings were valid), or else left the connection
              unchanged and returned FALSE (if not).
            - NEW libnm-core: returns TRUE if the connection was updated
              (whether or not it is valid), or FALSE if the new settings
              could not be deserialized and the connection is unchanged.
    • Dan Winship's avatar
      libnm-core: drop the ability to verify settings from property overrides · c4716508
      Dan Winship authored
      It needs to be possible to deserialize a connection hash into an
      invalid NMConnection; in particular, AddAndActivateConnection()
      explicitly allows this.
      Previously, the SetFunc and NotSetFunc passed to
      _nm_setting_class_override_property() could return a verification
      error immediately, but this functionality has to go away if we're
      going to be able to deserialize invalid connections.
      That functionality was only used in the handling of invalid virtual
      interface names; reorganize how that code works so that
      NMSettingConnection does all of the verification itself. (The code to
      make sure that it returned the "correct" error domain in that case
      turned out to be irrelevant, since the setting error domains don't get
      serialized over D-Bus correctly anyway.)
  13. 05 Sep, 2014 1 commit
  14. 04 Sep, 2014 12 commits
    • Dan Winship's avatar
      libnm-core: change DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES · c43f8890
      Dan Winship authored
      Change all DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES, and
      update corresponding APIs. Notably, this means they are now refcounted
      rather than being copied.
      Update the rest of NM for the changes. The daemon still converts SSIDs
      to GByteArrays internally, because changing it to use GBytes has lots
      of trickle-down effects. It can possibly be changed later.
    • Dan Winship's avatar
      libnm-core: replace GByteArray with pointer + length in some APIs · 3fbabde4
      Dan Winship authored
      APIs that take arbitrary data should take it in the form of a pointer
      and length, not a GByteArray, so that you can use them regardless of
      what format you have the data in (GByteArray, GBytes, plain array,
    • Dan Winship's avatar
      libnm-core: improve NMSettingIP4Config / NMSettingIP6Config property types · 98375657
      Dan Winship authored
      Make the :addresses and :routes properties be GPtrArrays of
      NMIP4Address, etc, rather than just reflecting the D-Bus data.
      Make the :dns properties be arrays of strings rather than arrays of
      binary IP addresses (and update the corresponding APIs as well).
    • Dan Winship's avatar
      libnm-core: change list-of-string and array-of-string properties to G_TYPE_STRV · 6a4127cf
      Dan Winship authored
      properties to G_TYPE_STRV, and update everything accordingly.
      (This doesn't actually require using
      _nm_setting_class_transform_property(); dbus-glib is happy to transform
      between 'as' and G_TYPE_STRV.)
    • Dan Winship's avatar
      libnm-core: change all mac-address properties to G_TYPE_STRING · 3a54d050
      Dan Winship authored
      Make all mac-address properties (including NMSettingBluetooth:bdaddr,
      NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be
      strings, using _nm_setting_class_transform_property() to handle
      translating to/from binary form when dealing with D-Bus.
      Update everything accordingly for the change, and also add a test for
      transformed setting properties to test-general.
    • Dan Winship's avatar
      libnm-core: drop NMParamSpecSpecialized, add nm_property_compare() · ca9938f4
      Dan Winship authored
      NMParamSpecSpecialized existed basically to provide a version of
      GParamSpecBoxed that could compare dbus-glib-valued properties
      However, g_param_values_cmp() was only used by NM directly in one
      place (NMSetting's compare_property()), and we don't actually need to
      indirect through GParamSpec there; we could just call
      NMParamSpecSpecialized's value-comparison function directly.
      So, change all NMParamSpecSpecialized properties to GParamSpecBoxed,
      rename the _gvalues_compare() function it used to
      "nm_property_compare()", and use that from NMSetting.
      (g_param_values_cmp() also gets used internally by
      g_param_value_defaults(), but all NMParamSpecSpecialized properties
      have a default value of NULL, so GParamSpecBoxed's pointer-equality
      check will do the job just fine there.)
    • Dan Winship's avatar
      libnm-core: fix up the new property-comparison test program · 99e1699d
      Dan Winship authored
      Make the formerly-nm-param-spec-specialized test compile (fix use of
      inet_pton), and pass (include the mandatory "gateway" element in the
      IPv6 addresses), make it use gtestutils and g_assert (so it actually
      fails when it fails), and test a few more cases.
    • Dan Winship's avatar
    • Dan Winship's avatar
      libnm-core: drop :interface-name properties on virtual NMSetting types · 6217c1e7
      Dan Winship authored
      Remove the virtual :interface-name properties and their getters, and
      use property overrides to do backward-compat handling when
      Now when constructing an NMConnection from a hash, if the virtual
      property is set and the NMSettingConnection property isn't, then the
      override for NMSettingConnection:interface-name will set that property
      to the value of the virtual interface-name. And when converting an
      NMConnection to a hash, the overrides for the virtual properties will
      return the value of NMSettingConnection:interface-name.
    • Dan Winship's avatar
      all: stop using virtual interface-name properties · ab26964c
      Dan Winship authored
      The virtual :interface-name properties (eg,
      NMDeviceBond:interface-name) are deprecated in favor of
      NMSettingConnection:interface-name, and nm_connection_verify() ensures
      that their values are kept in sync. So (a) there is no need to set
      those properties when we can just set
      NMSettingConnection:interface-name instead, and (b) we can replace any
      calls to the setting-specific get_interface_name() methods with
      nm_connection_get_interface_name() or
    • Dan Winship's avatar
      libnm-core: drop previously-deprecated NMSetting properties · a5ac95ca
      Dan Winship authored
      Drop the NMSetting properties that were marked deprecated in
      libnm-util in 0.9.10, but use nm_setting_class_add_dbus_property() to
      deal with them appropriately when serializing/deserializing.
    • Dan Winship's avatar
      libnm-core: add dbus-only properties to NMSettingClass · 002b19f4
      Dan Winship authored
      Add _nm_setting_class_add_dbus_only_property(), for declaring
      properties that appear in the D-Bus serialization, but which don't
      correspond to GObject properties.
      Since some property overrides will require examining settings other
      than the setting that they are on (eg, the value of
      802-11-wireless.security depends on whether an
      NMSettingWirelessSecurity setting is present, and
      NMSettingConnection:interface-name might sometimes be set from, eg,
      bond.interface-name), we also update _nm_setting_to_dbus() to take the
      full NMConnection as an argument, and _nm_setting_new_from_dbus() to
      take the full connection hash.
      Additionally, with some deprecated properties, we'll want to validate
      them on construction, but we don't need to keep the value around after
      that. So allow _nm_setting_new_from_dbus() to return a verification
      error directly, so we don't need to store the value until the verify()