1. 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).
  2. 12 Oct, 2014 1 commit
  3. 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().
  4. 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.
  5. 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.)
  6. 04 Sep, 2014 11 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: 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 :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()
    • Dan Winship's avatar
      libnm-core: clean up nm_connection_replace_settings()'s semantics · 504c292d
      Dan Winship authored
      On failure, nm_connection_replace_settings() would leave the
      connection in an undefined state. Fix it so that either (a) the
      settings are replaced and the resulting connection is valid and we
      return TRUE, or (b) the connection is untouched and we return FALSE
      and an error. (And add a test case for this.)
    • Dan Winship's avatar
      libnm-core: rename NMConnection to/from_hash methods · 773d3f0a
      Dan Winship authored
      Rename nm_connection_to_hash() to nm_connection_to_dbus(), and
      nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In
      addition to clarifying that this is specifically the D-Bus
      serialization format, these names will also work better in the
      GDBus-based future where the serialization format is GVariant, not
      Also, move NMSettingHashFlags to nm-connection.h, and rename it
    • Dan Winship's avatar
      libnm-core: make the NMSetting hash methods private · c9653a9e
      Dan Winship authored
      Make nm_setting_to_hash() and nm_setting_new_from_hash() private, and
      remove the public nm_setting_update_secrets() wrapper around the
      existing private _nm_setting_update_secrets().
      These functions should really only be called from the corresponding
      NMConnection-level methods, and in particular, with certain
      compatibility properties in the future, we will need to consider the
      entire connection all at once when setting properties, so it won't
      make sense to serialize/deserialize a single setting in isolation.
  7. 22 Aug, 2014 6 commits
  8. 16 Aug, 2014 1 commit
    • Dan Winship's avatar
      libnm-core, libnm, core: make NMConnection an interface · e1ba13a4
      Dan Winship authored
      The fact that NMRemoteConnection has to be an NMConnection and
      therefore can't be an NMObject means that it needs to reimplement bits
      of NMObject functionality (and likewise NMObject needs some special
      magic to deal with it). Likewise, we will need a daemon-side
      equivalent of NMObject as part of the gdbus port, and we would want
      NMSettingsConnection to be able to inherit from this as well.
      Solve this problem by making NMConnection into an interface, and
      having NMRemoteConnection and NMSettingsConnection implement it. (We
      use some hacks to keep the GHashTable of NMSettings objects inside
      nm-connection.c rather than having to be implemented by the
      Since NMConnection is no longer an instantiable type, this adds
      NMSimpleConnection to replace the various non-D-Bus-based uses of
      NMConnection throughout the code. nm_connection_new() becomes
      nm_simple_connection_new(), nm_connection_new_from_hash() becomes
      nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
      becomes nm_simple_connection_new_clone().
  9. 07 Aug, 2014 3 commits
    • Dan Winship's avatar
      libnm-core, etc: add nm_utils_hwaddr_matches() · 44b9a870
      Dan Winship authored
      Add nm_utils_hwaddr_matches(), for comparing hardware addresses for
      equality, allowing either binary or ASCII hardware addresses to be
      passed, and handling the special rules for InfiniBand hardware
      addresses automatically. Update code to use it.
    • Dan Winship's avatar
      libnm-core: include ETH_ALEN/INFINIBAND_ALEN defines in nm-utils.h · 357efd26
      Dan Winship authored
      Include <linux/if_ether.h> and <linux/if_infiniband.h> from
      nm-utils.h, to get ETH_ALEN and INFINIBAND_ALEN, and remove those
      includes (as well as <net/ethernet.h> and <netinet/ether.h>, and
      various headers that had been included to get the ARPHRD_* constants)
      from other files where they're not needed now.
    • Dan Winship's avatar
      libnm-core, etc: drop type-based hwaddr funcs, port to length-based ones · 35f36ba4
      Dan Winship authored
      Drop the arptype-based nm_utils_hwaddr funcs, and rename the
      length-based ones to no longer have _len in their names. This also
      switches nm_utils_hwaddr_atoba() to using a length rather than an
      arptype, and adds a length argument to nm_utils_hwaddr_valid() (making
      nm_utils_hwaddr_valid() now a replacement for nm_utils_hwaddr_aton()
      in some places, where we were only using aton() to do validity
  10. 01 Aug, 2014 3 commits
    • Dan Winship's avatar
      libnm, core, cli, tui: fix the capitalization of various types · 3ac0f528
      Dan Winship authored
      GLib/Gtk have mostly settled on the convention that two-letter
      acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
      become initial-caps-only (eg, "Tcp").
      NM was inconsistent, with most long acronyms using initial caps only
      (Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
      PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
      three-or-more-letter-long acronyms (and update nmcli and nmtui for the
      libnm changes).
    • Dan Winship's avatar
      libnm: add libnm/libnm-core (part 2) · eedcf185
      Dan Winship authored
      This fixes up the code from the previous "clean" import, and adds
      build infrastructure.
      [There are two slightly orthogonal sets of changes in this patch.
      First, the files added in the previous commit were modified as followed:
        # Replace internal references to "libnm-util" and "libnm-glib" with "libnm"
        perl -pi -e 's/libnm-(util|glib)/libnm/;' libnm-core/*.[ch] libnm-core/tests/*.[ch] libnm/*.[ch] libnm/tests/*.[ch]
        # Fix includes of the enum-types files
        perl -pi -e 's/nm-utils-enum-types/nm-core-enum-types/;' libnm-core/*.[ch] libnm-core/tests/*.[ch] libnm/*.[ch] libnm/tests/*.[ch]
        perl -pi -e 's/nm-glib-enum-types/nm-enum-types/;' libnm/*.[ch] libnm/tests/*.[ch]
        # Fix some python example code
        perl -pi -e 's/import NMClient/import NM/;' -e 's/NMClient.Client\(\)/NM.Client()/;' libnm/nm-client.c
      Then, the build infrastructure was added (without further modifying
      any existing files in libnm-core or libnm.)
      Note: to regenerate libnm.ver after rebase:
        (head -2 libnm-util/libnm-util.ver; (grep -h '\s'nm_ libnm-util/libnm-util.ver libnm-glib/libnm-glib.ver | env LANG=C sort); tail -3 libnm-util/libnm-util.ver) > libnm/libnm.ver
    • Dan Winship's avatar
      libnm: add libnm/libnm-core (part 1) · d595f784
      Dan Winship authored
      This commit begins creating the new "libnm", which will replace
      libnm-util and libnm-glib.
      The main reason for the libnm-util/libnm-glib split is that the daemon
      needs to link to libnm-util (to get NMSettings, NMConnection, etc),
      but can't link to libnm-glib (because it uses many of the same type
      names as the NetworkManager daemon. eg, NMDevice). So the daemon links
      to only libnm-util, but basically all clients link to both.
      With libnm, there will be only a single client-visible library, and
      NetworkManager will internally link against a private "libnm-core"
      containing the parts that used to be in libnm-util.
      (The "libnm-core" parts still need to be in their own directory so
      that the daemon can see those header files without also seeing the
      ones in libnm/ that conflict with its own headers.)
      [This commit just copies the source code from libnm-util/ to
      libnm-core/, and libnm-glib/ to libnm/:
        mkdir -p libnm-core/tests/
        mkdir -p libnm/tests/
        cp libnm-util/*.[ch] libnm-util/nm-version.h.in libnm-core/
        rm -f libnm-core/nm-version.h libnm-core/nm-setting-template.[ch] libnm-core/nm-utils-enum-types.[ch]
        cp libnm-util/tests/*.[ch] libnm-core/tests/
        cp libnm-glib/*.[ch] libnm/
        rm -f libnm/libnm_glib.[ch] libnm/libnm-glib-test.c libnm/nm-glib-enum-types.[ch]
        cp libnm-glib/tests/*.[ch] libnm/tests/
  11. 15 Jul, 2014 1 commit
    • Dan Winship's avatar
      libnm-util, libnm-glib: standardize copyright/license headers · cb7e1893
      Dan Winship authored
      - Remove list of authors from files that had them; these serve no
        purpose except to quickly get out of date (and were only used in
        libnm-util and not libnm-glib anyway).
      - Just say "Copyright", not "(C) Copyright" or "Copyright (C)"
      - Put copyright statement after the license, not before
      - Remove "NetworkManager - Network link manager" from the few files
        that contained it, and "libnm_glib -- Access network status &
        information from glib applications" from the many files that
        contained it.
      - Remove vim modeline from nm-device-olpc-mesh.[ch], add emacs modeline
        to files that were missing it.
  12. 02 Jul, 2014 1 commit
  13. 30 Jun, 2014 2 commits
    • Thomas Haller's avatar
      libnm-util: normalize virtual_iface_name in NMSettings · 2deaa539
      Thomas Haller authored
      Some type-specific NMSetting implementations (bond, bridge, team, vlan)
      have their own 'interface-name' property. This property will be
      deprecated in favour of 'interface-name' in NMSettingConnection.
      Change verify() and normalize() to check that the redundant
      values match and repair/normalize the properties.
      Force the virtual interface name of the type-specific setting to be
      equal to NMSettingConnection:interface_name. This way, the depreacted
      field stays valid and backward compatible.
      NMSettingInfiniband is special, because it does not have a backing
      property for the interface name, although it implements
      get_virtual_iface_name(). To account for this, some special handling
      is needed in order not to change the behaviour of get_virtual_iface_name().
      Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
    • Thomas Haller's avatar
  14. 05 Jun, 2014 3 commits