1. 19 Dec, 2018 3 commits
    • Thomas Haller's avatar
      all: don't use static buffer for nm_utils_inet*_ntop() · a51c09dc
      Thomas Haller authored
      While nm_utils_inet*_ntop() accepts a %NULL buffer to fallback
      to a static buffer, don't do that.
      I find the possibility of using a static buffer here error prone
      and something that should be avoided. There is of course the downside,
      that in some cases it requires an additional line of code to allocate
      the buffer on the stack as auto-variable.
    • Thomas Haller's avatar
      core: implement nm_utils_ip4_netmask_to_prefix() via __builtin_ctz() · e442e388
      Thomas Haller authored
      Taken from systemd's in4_addr_netmask_to_prefixlen().
      Yes, this adds the requirement that "int" is 32 bits. But systemd
      already has the same requirement in u32ctz(), hence we anyway cannot
      build on other architectures. If that is ever necessary, it's easy
      to adjust.
    • Aleksander Morgado's avatar
      settings,gsm: deprecate and stop using 'number' property · 6ed21e83
      Aleksander Morgado authored
      The 'number' property in GSM settings is a legacy thing that comes
      from when ModemManager used user-provided numbers, if any, to connect
      3GPP modems.
      Since ModemManager 1.0, this property is completely unused for 3GPP
      modems, and so it doesn't make sense to use it in the NetworkManager
      settings. Ofono does not use it either.
      For AT+PPP-based 3GPP modems, the 'number' to call to establish the
      data connection is decided by ModemManager itself, e.g. for standard
      GSM/UMTS/LTE modems it will connect a given predefined PDP context,
      and for other modems like Iridium it will have the number to call
      hardcoded in the plugin itself.
  2. 31 Oct, 2018 4 commits
    • Thomas Haller's avatar
      libnm: add nm_utils_uuid_is_null() helper · 01239e99
      Thomas Haller authored
    • Thomas Haller's avatar
      libnm: add support for SHA1 based version 5 UUIDs · 070a4d93
      Thomas Haller authored
      The entire point of using version 3/5 UUIDs is to generate
      stable UUIDs based on a string. It's usually important that
      we don't change the UUID generation algorithm later on.
      Since we didn't have a version 5 implementation, we would always
      resort to the MD5 based version 3. Version 5 is recommended by RFC 4122:
         o  Choose either MD5 [4] or SHA-1 [8] as the hash algorithm; If
            backward compatibility is not an issue, SHA-1 is preferred.
      Add a version 5 implementation so we can use it in the future.
      All test values are generated with python's uuid module or OSSP uuid.
    • Thomas Haller's avatar
      libnm/tests: add more tests for generating UUIDs · 2ce5347e
      Thomas Haller authored
      The expected values are checked with python's uuid module
      and OSSP uuid.
    • Thomas Haller's avatar
      libnm/trivial: rename uuid type VARIANT3 to VERSION3 · c150b0fa
      Thomas Haller authored
      In RFC 4122, this is called "version 3", not "variant 3". While for
      UUIDs there is also a concept of "variants", that is something else.
      Fix naming.
  3. 19 Sep, 2018 1 commit
  4. 06 Sep, 2018 1 commit
  5. 30 Aug, 2018 2 commits
  6. 22 Aug, 2018 1 commit
    • Thomas Haller's avatar
      shared: add nm_utils_buf_utf8safe_escape() util · 57c371e3
      Thomas Haller authored
      We already have nm_utils_str_utf8safe_escape() to convert a
      NUL termianted string to an UTF-8 string. nm_utils_str_utf8safe_escape()
      operates under the assumption, that the input strig is already valid UTF-8
      and returns the input string verbatim. That way, in the common expected
      cases, the string just looks like a regular UTF-8 string.
      However, in case there are invalid UTF-8 sequences (or a backslash
      escape characters), the function will use backslash escaping to encode
      the input string as a valid UTF-8 sequence. Note that the escaped
      sequence, can be reverted to the original non-UTF-8 string via
      An example, where this is useful are file names or interface names.
      Which are not in a defined encoding, but NUL terminated and commonly ASCII or
      UTF-8 encoded.
      Extend this, to also handle not NUL terminated buffers. The same
      applies, except that the process cannot be reverted via g_strcompress()
      -- because the NUL character cannot be unescaped.
      This will be useful to escape a Wi-Fi SSID. Commonly we expect the SSID
      to be in UTF-8/ASCII encoding and we want to print it verbatim. Only
      if that is not the case, we fallback to backslash escaping. However, the
      orginal value can be fully recovered via unescape(). The difference
      between an SSID and a filename is, that the former can contain '\0'
  7. 11 Aug, 2018 2 commits
  8. 10 Aug, 2018 3 commits
    • Thomas Haller's avatar
      libnm, cli, ifcfg-rh: add NMSettingEthtool setting · df30651b
      Thomas Haller authored
      Note that in NetworkManager API (D-Bus, libnm, and nmcli),
      the features are called "feature-xyz". The "feature-" prefix
      is used, because NMSettingEthtool possibly will gain support
      for options that are not only -K|--offload|--features, for
      example -C|--coalesce.
      The "xzy" suffix is either how ethtool utility calls the feature
      ("tso", "rx"). Or, if ethtool utility specifies no alias for that
      feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
      If possible, we prefer ethtool utility's naming.
      Also note, how the features "feature-sg", "feature-tso", and
      "feature-tx" actually refer to multiple underlying kernel features
      at once. This too follows what ethtool utility does.
      The functionality is not yet implemented server-side.
    • Thomas Haller's avatar
    • Thomas Haller's avatar
  9. 08 Aug, 2018 1 commit
    • Thomas Haller's avatar
      all: add connection.multi-connect property for wildcard profiles · 55ae6923
      Thomas Haller authored
      Add a new option that allows to activate a profile multiple times
      (at the same time). Previoulsy, all profiles were implicitly
      NM_SETTING_CONNECTION_MULTI_CONNECT_SINGLE, meaning, that activating
      a profile that is already active will deactivate it first.
      This will make more sense, as we also add more match-options how
      profiles can be restricted to particular devices. We already have
      connection.type, connection.interface-name, and (ethernet|wifi).mac-address
      to restrict a profile to particular devices. For example, it is however
      not possible to specify a wildcard like "eth*" to match a profile to
      a set of devices by interface-name. That is another missing feature,
      and once we extend the matching capabilities, it makes more sense to
      activate a profile multiple times.
      See also https://bugzilla.redhat.com/show_bug.cgi?id=997998, which
      previously changed that a connection is restricted to a single activation
      at a time. This work relaxes that again.
      This only adds the new property, it is not used nor implemented yet.
  10. 24 Jul, 2018 1 commit
  11. 11 Jul, 2018 1 commit
    • Thomas Haller's avatar
      all: don't use gchar/gshort/gint/glong but C types · e1c7a2b5
      Thomas Haller authored
      We commonly don't use the glib typedefs for char/short/int/long,
      but their C types directly.
          $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
      One could argue that using the glib typedefs is preferable in
      public API (of our glib based libnm library) or where it clearly
      is related to glib, like during
        g_object_set (obj, PROPERTY, (gint) value, NULL);
      However, that argument does not seem strong, because in practice we don't
      follow that argument today, and seldomly use the glib typedefs.
      Also, the style guide for this would be hard to formalize, because
      "using them where clearly related to a glib" is a very loose suggestion.
      Also note that glib typedefs will always just be typedefs of the
      underlying C types. There is no danger of glib changing the meaning
      of these typedefs (because that would be a major API break of glib).
      A simple style guide is instead: don't use these typedefs.
      No manual actions, I only ran the bash script:
        FILES=($(git ls-files '*.[hc]'))
        sed -i \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>  /\1   /g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
  12. 26 Jun, 2018 1 commit
  13. 29 May, 2018 3 commits
  14. 26 May, 2018 1 commit
  15. 30 Apr, 2018 1 commit
  16. 18 Jan, 2018 1 commit
  17. 09 Jan, 2018 1 commit
  18. 08 Jan, 2018 1 commit
    • Thomas Haller's avatar
      tests: use NMTST_EXPECT*() macros · 25ade397
      Thomas Haller authored
      Tests are commonly created via copy&paste. Hence, it's
      better to express a certain concept explicitly via a function
      or macro. This way, the implementation of the concept can be
      adjusted at one place, without requiring to change all the callers.
      Also, the macro is shorter, and brevity is better for tests
      so it's easier to understand what the test does. Without being
      bothered by noise from the redundant information.
      Also, the macro knows better which message to expect. For example,
      messages inside "src" are prepended by nm-logging.c with a level
      and a timestamp. The expect macro is aware of that and tests for it
        #define NMTST_EXPECT_NM_ERROR(msg)      NMTST_EXPECT_NM (G_LOG_LEVEL_MESSAGE, "*<error> [*] "msg)
      This again allows the caller to ignore this prefix, but still assert
      more strictly.
  19. 03 Jan, 2018 1 commit
  20. 18 Dec, 2017 2 commits
  21. 15 Dec, 2017 3 commits
  22. 08 Dec, 2017 1 commit
    • Thomas Haller's avatar
      Revert "Makefile: rework team compilation flags" · b1c65d32
      Thomas Haller authored
      I don't think we should do this.
      - renamining/dropping configure options is still an annoyance,
        because it requires to different ./configure options depending
        on the version. The rename from --enable-teamctl to --enable-team
        might be theoretically nice, but more annoying then helpful.
      - There is no strict dependency between --enable-team and
        --enable-json-validation. At most, one could argue that
        when enabling the team plugin (--enable-teamctl), then
        libnm must also be build with --enable-json-validation.
        But in fact, the team plugin will happily work with a
        libnm that doesn't link against libjansson.
        That is --enable-teamctl --disable-json-validation will work
        in practice just fine.
        On the other hand, libnm is a client library to create connection
        profiles, fully supporting team profiles also makes sense if the
        actual plugin is not installed (or build). Thus, --disable-teamctl
        --enable-json-validation certainly makes sense.
      At this point, one might ask whether libnm is even still complete without
      libjansson. Maybe libnm should *require* --enable-json-validation.
      But that is not what the patch was doing, and it would also need
      some careful consideration before doing so.
      This reverts commit 9d5cd7ea.
  23. 07 Dec, 2017 1 commit
    • Francesco Giudici's avatar
      Makefile: rework team compilation flags · 9d5cd7ea
      Francesco Giudici authored
      Rename the team functionality enablement from 'teamdctl' to 'team'.
      Force jansson lib requirement for team functionality: NetworkManager
      requires the teamd daemon to manage team. As teamd depends upon jansson
      lib, adding jansson requirement for teaming support in NetworkManager
      seems reasonable.
      Remove the jansson_validation flag, as the only generic json function in
      nmcli (not related to team) was the one to check if a string was in json
      format. Anyway, that function is used for team checks only. So, move
      also json validation functions under the WITH_TEAM flag.
  24. 28 Nov, 2017 1 commit
    • Thomas Haller's avatar
      c-list: re-import latest version of c-list.h from upstream · b6efac9e
      Thomas Haller authored
      Most notably, it renames
        c_list_unlink_init() -> c_list_unlink()
        c_list_unlink() -> c_list_unlink_stale()
        $ sed -e 's/\<c_list_unlink\>/c_list_unlink_old/g' \
              -e 's/\<c_list_unlink_init\>/c_list_unlink/g' \
              -e 's/\<c_list_unlink_old\>/c_list_unlink_stale/g' \
              $(git grep -l c_list_unlink -- ':(exclude)shared/nm-utils/c-list.h') \
  25. 16 Nov, 2017 2 commits
    • Thomas Haller's avatar
      all: use nm_str_hash() instead of g_str_hash() · a6be2f4a
      Thomas Haller authored
      We also do this for libnm and libnm-core, where it causes visible changes
      in behavior. But if somebody would rely on the hashing implementation
      for hash tables, it would be seriously flawed.
    • Thomas Haller's avatar
      all: include "nm-utils/nm-hash-utils.h" by default · 3ee8de20
      Thomas Haller authored
      Next we will use siphash24() instead of the glib version g_direct_hash() or
      g_str_hash(). Hence, the "nm-utils/nm-hash-utils.h" header becomes very
      fundamental and will be needed basically everywhere.
      Instead of requiring the users to include them, let it be included via
      "nm-default.h" header.