Commit graph

319 commits

Author SHA1 Message Date
Thomas Haller a9e6774670
example: add python gi example for keyfile handling 2020-10-28 14:30:49 +01:00
Thomas Haller 88071abb43
all: unify comment style for SPDX-License-Identifier tag
Our coding style recommends C style comments (/* */) instead of C++
(//). Also, systemd (which we partly fork) uses C style comments for
the SPDX-License-Identifier.

Unify the style.

  $ sed -i '1 s#// SPDX-License-Identifier: \([^ ]\+\)$#/* SPDX-License-Identifier: \1 */#' -- $(git ls-files -- '*.[hc]' '*.[hc]pp')
2020-09-29 16:50:53 +02:00
Thomas Haller 740b092fda
format: replace tabs for indentation in code comments
sed -i \
     -e 's/^'$'\t'' \*/     */g' \
     -e 's/^'$'\t\t'' \*/         */g' \
     -e 's/^'$'\t\t\t'' \*/             */g' \
     -e 's/^'$'\t\t\t\t'' \*/                 */g' \
     -e 's/^'$'\t\t\t\t\t'' \*/                     */g' \
     -e 's/^'$'\t\t\t\t\t\t'' \*/                         */g' \
     -e 's/^'$'\t\t\t\t\t\t\t'' \*/                             */g' \
     $(git ls-files -- '*.[hc]')
2020-09-28 16:07:52 +02:00
Antonio Cardace 328fb90f3e
all: reformat all with new clang-format style
Run:

    ./contrib/scripts/nm-code-format.sh -i
    ./contrib/scripts/nm-code-format.sh -i

Yes, it needs to run twice because the first run doesn't yet produce the
final result.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 16:07:51 +02:00
Sayed Shah 7baf615eaa
all: changes from python 2 syntax to python3 and removing dead code
There were python 2 methods that are not used anymore so now
it's in python 3. Added helper fuctions so that the code is more clear

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/540
2020-08-03 18:37:43 +02:00
Thomas Haller 1acd64b7a2
examples: run python black on "examples/python/gi/nm-wg-set"
black by default only considers files that have a ".py" extension.
2020-07-02 17:37:12 +02:00
Sayed Shah be822b52e6
all: reformat python files with python black
Part of !537.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/537
2020-06-15 16:40:38 +02:00
Thomas Haller 64331d6085
examples: remove unused code from "examples/python/dbus/vpn.py"
lgtm.com says "The value assigned to local variable all_connections is never used".
Just drop the entire statement. It's not right there.
2020-05-07 13:58:16 +02:00
Thomas Haller 8ad448444a
examples: avoid "x == None" checks in python examples
lgmt.com says "Testing for None should use the is operator".
2020-05-07 13:58:15 +02:00
Thomas Haller c7d0a86050
examples: avoid "except" for BaseException in examples
lgtm.com flags this as "Except block directly handles BaseException".
2020-05-07 13:58:14 +02:00
Thomas Haller 5c08981356
examples: avoid non-thread-safe localtime() function example
Just to silence the warning on lgtm.com.
2020-05-07 13:58:13 +02:00
Thomas Haller 41a7a26259
examples: remove unused imports from python examples 2020-05-07 13:58:13 +02:00
Thomas Haller a5614dc469
examples: remove unused assignment in "examples/python/gi/wifi-p2p.py"
lgtm.com warns about this.
2020-05-07 13:58:12 +02:00
Beniamino Galvani 2c4d19c1dc examples: add Wi-Fi P2P example
Add a python example using GObject introspection that shows how to
scan for Wi-Fi P2P peers and connect to one of them.
2020-04-27 15:54:28 +02:00
David Drinn 4e73d71518 examples: fix copy/paste comment error from another script
https://github.com/NetworkManager/NetworkManager/pull/361
2020-04-11 15:38:46 +02:00
Iñigo Martínez 648155e4a1 license: Add license using SPDX identifiers to meson build files
License is missing in meson build files. This has been added using
SPDX identifiers and licensed under LGPL-2.1+.
2020-02-17 13:16:57 +01:00
Beniamino Galvani e397582cca libnm: export interface flags
Add libnm support for the new InterfaceFlags property of NMDevice.
2019-11-22 10:18:26 +01:00
Thomas Haller c6d53c5500 dispatcher: avoid "dirname" and "basename" calls in "10-ifcfg-rh-routes.sh" script
The script is run for every dispatcher event. Most of the events are not
actually relevant, and we just need to determine that there is nothing
to do and quit.

Avoid calling "dirname" and "basename".

The supported ifcfg-file has a very specific form. We can just check
(and parse) it in one got regular expression in bash.
2019-10-04 12:38:16 +02:00
Thomas Haller babd1f314e dispatcher: move return-early checks in "10-ifcfg-rh-routes.sh" first
A shell script is executed line-by-line. Note that for most dispatcher
events, "10-ifcfg-rh-routes.sh" has nothing to do and will just quit.
Move those checks earlier, to avoid bash executing the code that won't
be needed most of the time.
2019-10-04 12:37:50 +02:00
Thomas Haller 3b69f02164 all: unify format of our Copyright source code comments
```bash

readarray -d '' FILES < <(
  git ls-files -z \
    ':(exclude)po' \
    ':(exclude)shared/c-rbtree' \
    ':(exclude)shared/c-list' \
    ':(exclude)shared/c-siphash' \
    ':(exclude)shared/c-stdaux' \
    ':(exclude)shared/n-acd' \
    ':(exclude)shared/n-dhcp4' \
    ':(exclude)src/systemd/src' \
    ':(exclude)shared/systemd/src' \
    ':(exclude)m4' \
    ':(exclude)COPYING*'
  )

sed \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[-–] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C1pyright#\5 - \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[,] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C2pyright#\5, \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C3pyright#\5#\7/' \
  -e 's/^Copyright \(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/C4pyright#\1#\3/' \
  -i \
  "${FILES[@]}"

echo ">>> untouched Copyright lines"
git grep Copyright "${FILES[@]}"

echo ">>> Copyright lines with unusual extra"
git grep '\<C[0-9]pyright#' "${FILES[@]}" | grep -i reserved

sed \
  -e 's/\<C[0-9]pyright#\([^#]*\)#\(.*\)$/Copyright (C) \1 \2/' \
  -i \
  "${FILES[@]}"

```

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/298
2019-10-02 17:03:52 +02:00
Iñigo Martínez 700f6f6b5f meson: Improve Qt examples
Qt dependencies have been moved to the main build file where the
rest of dependencies are located. This makes it easier to find them.

The included directories has also reviewed and removed the
unnecessary ones.
2019-10-01 09:49:33 +02:00
Iñigo Martínez caf470f788 meson: Improve targets involving libnm library
The targets that involve the use of the `libnm` library have been
improved by applying a set of changes:

- Generated enum sources variable `libnm_enum` has been renamed to
  `libnm_enum_sources` to clearly specify what it is holding.
- Indentation in the `libnm` build and test files has been fixed.
- Set of objects used in targets have been grouped together.
2019-10-01 09:49:33 +02:00
Iñigo Martínez f427f4771e meson: Improve the libnm-core build file
The `libnm-core` build file has been improved by applying a set of
changes:

- Indentation has been fixed to be consistent.
- Library variable names have been changed to `lib{name}` pattern
  following their filename pattern.
- `shared` prefix has been removed from all variables using it.
- Dependencies have been reviewed to store the necessary data.
- The use of the libraries and dependencies created in this file
  has been reviewed through the entire source code. This has
  required the addition or the removal of different libraries and
  dependencies in different targets.
- Some files used directly with the `files` function have been moved
  to their nearest path build file because meson stores their full
  path seamessly and they can be used anywhere later.
2019-10-01 09:49:33 +02:00
Iñigo Martínez 70a34c54fe meson: Use dependency for nm-default header
The `nm-default.h` header is used widely in the code by many
targets. This header includes different headers and needs different
libraries depending the compilation flags.

A new set of `*nm_default_dep` dependencies have been created to
ease the inclusion of different directorires and libraries.

This allows cleaner build files and avoiding linking unnecessary
libraries so this has been applied allowing the removal of some
dependencies involving the linking of unnecessary libraries.
2019-10-01 09:49:33 +02:00
Thomas Haller abff46cacf all: manually drop code comments with file description 2019-10-01 07:50:52 +02:00
Lubomir Rintel 24028a2246 all: SPDX header conversion
$ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
2019-09-10 11:19:56 +02:00
Thomas Haller 041a952297 examples: improve usage/synposis for nm-update2.py and nm-add-connection2.py 2019-08-08 10:53:03 +02:00
Thomas Haller 815acb9996 example: print WireGuard parameters in nm-wg-set example script
(cherry picked from commit e966f4b272)
2019-07-31 10:44:38 +02:00
Thomas Haller 10353a996f examples: add examples/python/gi/nm-update2.py example script
This is useful for manually testing Update2() D-Bus API.
2019-07-25 22:02:00 +02:00
Thomas Haller 360d26e27c examples: add examples/python/gi/nm-add-connection2.py example script
This is useful for manually testing AddConnection2() D-Bus API.
2019-07-25 15:26:49 +02:00
Thomas Haller 3c47285f4a all: drop vim file variables from source files
sed '1,3 { /^\(#\|--\) *vim:/d }; 1 { /^\/\* *vim:.*\*\/$/ d}' -i $(git grep -l 'vim:')
2019-06-11 10:08:07 +02:00
Thomas Haller c0e075c902 all: drop emacs file variables from source files
We no longer add these. If you use Emacs, configure it yourself.

Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.

No manual changes, just ran commands:

    F=($(git grep -l -e '-\*-'))
    sed '1 { /\/\* *-\*-  *[mM]ode.*\*\/$/d }'     -i "${F[@]}"
    sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"

Check remaining lines with:

    git grep -e '-\*-'

The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
2019-06-11 10:04:00 +02:00
Thomas Haller d3db21ddaf examples: use '\n' line endings in "examples/C/qt/add-connection-wired.cpp"
Find with:

  git ls-files -z | xargs -0 file | grep with\ CRLF

Fix with:

  dos2unix examples/C/qt/add-connection-wired.cpp
2019-06-11 09:58:50 +02:00
Thomas Haller 1da7dfc408 gitignore: merge gitignore files
For the most part, we only have one main .gitignore file.

There were a few nested files, merge them into the main file.

I find it better to have only one gitignore file, otherwise the
list of ignored files is spread out through the working directory.
2019-05-19 14:41:21 +02:00
Thomas Haller e7836cd151 build/meson: rename "nm_core_dep" to "libnm_core_dep"
The library is called "libnm_core". So the dependency should be called
"libnm_core_dep", like in all other cases.

(cherry picked from commit c27ad37c27)
2019-04-18 20:13:49 +02:00
Lubomir Rintel a4a6a6b6ee examples: drop rtl drivers from the mac address change blacklist
Just in case anyone uses this file as-is; I believe that these drivers
don't need to be in a blacklist. There's a good chance they either work
or we can detect failure to change a MAC address on runtime and act
accordingly.

Blacklisting the driver gives the driver maintainers no chance to fix
the behavior and we are not able to log a warning on failure.
2019-04-08 10:10:25 +02:00
Thomas Haller ce7a631ae6 examples: don't set "ethernet.cloned-mac-address" in "10-no-wifi-scan-rand-mac-address.conf"
These are workarounds for Wi-Fi drivers. Don't set the unrelated
"ethernet.cloned-mac-address" property.
2019-04-08 09:49:05 +02:00
Thomas Haller 78d9bd62ff examples: blacklist drivers "wl" and "8188eu" in "31-mac-addr-change.conf" for "wifi.scan-rand-mac-address"
These drivers work bad with changing the MAC address.

See [1], [2], [3] for reports about failures with "wl" driver.

[3] also blacklists driver "8188eu". While we already blacklist "r8188eu",
it seems that some installations use the alternative name "8188eu" [4].

"wpasupplicant" package on Ubuntu 18.04 (bionic) provides the file
"/usr/lib/NetworkManager/conf.d/no-mac-addr-change.conf", which
blacklists the same drivers. See also bug [3] which added the file.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1695696
[2] https://bugzilla.gnome.org/show_bug.cgi?id=777523#c27
[3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833507
[4] 9a56f32c2a/dkms.conf
2019-04-05 16:13:32 +02:00
Lubomir Rintel 4251f4e476 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').

(cherry picked from commit bf0c4e6ac2)
2019-03-11 12:03:46 +01:00
Thomas Haller f617d5e8b4 libnm: change nm_wireguard_peer_set_endpoint() API to allow validation
This is an API break since 1.16-rc1.

Similar to previous commit.

(cherry picked from commit 8ae9aa2428)
2019-03-07 22:22:39 +01:00
Thomas Haller 6452d2d0e5 libnm: change nm_wireguard_peer_set_public_key() API to allow validation
This is an API break since 1.16-rc1.

Similar to previous commit.

(cherry picked from commit 7962653918)
2019-03-07 22:22:39 +01:00
Thomas Haller 7682826229 libnm: change nm_wireguard_peer_set_preshared_key() API to allow validation
This is an API break since 1.16-rc1.

The functions like _nm_utils_wireguard_decode_key() are internal API
and not accessible to a libnm user. Maybe this should be public API,
but for now it is not.

That makes it cumbersome for a client to validate the setting. The client
could only reimplement the validation (bad) or go ahead and set invalid
value.

When setting an invalid value, the user can afterwards detect it via
nm_wireguard_peer_is_valid(), but at that point, it's not clear which
exact property is invalid.

First I wanted to keep the API conservative and not promissing too much.
For example, not promising to do any validation when setting the key.
However, libnm indeed validates the key at the time of setting it
instead of doing lazy validation later. This makes sense, so we can
keep this promise and just expose the validation result to the caller.

Another downside of this is that the API just got more complicated.
But it not provides a validation API, that we previously did not have.

(cherry picked from commit d7bc1750c1)
2019-03-07 22:22:39 +01:00
Thomas Haller 4c8ff6f220 examples: fix handling secrets in nm-wg-set
When setting any secrets via D-Bus' Update2 call, then
it assumes that all settings are reset. That means, when
we modify any secrets in the client, we need to first load
them all.

Anyway, load always all secrets, then we can also print them
in the get output.

Honor WG_HIDE_KEYS like `wg` does.

(cherry picked from commit 6aa9e52bd8)
2019-02-26 09:40:57 +01:00
Thomas Haller 8b4247d31d examples: improve hints about existing WireGuard profiles in nm-wg-set
(cherry picked from commit b5a458c5ff)
2019-02-26 09:40:56 +01:00
Thomas Haller debd022a6d examples: add python example script "nm-wg-set" for modifying WireGuard profile
Use the script to test how GObject introspection with libnm's WireGuard
support works.

Also, since support for WireGuard peers is not yet implemented in nmcli
(or other clients), this script is rather useful.
2019-02-22 11:00:11 +01:00
Iñigo Martínez 35171b3c3f build: meson: Add trailing commas
Add missing trailing commas that avoids getting noise when another
file/parameter is added and eases reviewing changes[0].

[0] https://gitlab.gnome.org/GNOME/dconf/merge_requests/11#note_291585
2018-12-20 13:50:34 +01:00
Thomas Haller 6cf183a0e1 examples: fix wrong example configuration in "31-mac-addr-change.conf"
Fixes: b869d9cc0d
2018-12-10 15:21:44 +01:00
Lubomir Rintel b385ad0159 all: say Wi-Fi instead of "wifi" or "WiFi"
Correct the spelling across the *entire* tree, including translations,
comments, etc. It's easier that way.

Even the places where it's not exposed to the user, such as tests, so
that we learn how is it spelled correctly.
2018-11-29 17:53:35 +01:00
Beniamino Galvani 9e43821e17 dispatcher: fix shellcheck warnings
Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
And likewise, prefer [ p ] || [ q ] over [ p -o q ].

https://github.com/koalaman/shellcheck/wiki/SC2166
2018-10-06 10:03:48 +02:00
luz.paz f985b6944a docs: misc. typos
Found via `codespell -q 3 --skip="*.po"`

https://github.com/NetworkManager/NetworkManager/pull/203
2018-09-15 09:08:03 +02:00
Beniamino Galvani 357edff198 examples: make 10-ifcfg-rh-routes.sh self-contained
Don't call the 'if{up,down}-routes' scripts because in next Fedora
versions network scripts will be deprecated and will not be present in
the default installation.

Instead, just copy and adapt the code from those scripts.

https://bugzilla.redhat.com/show_bug.cgi?id=1618419
2018-08-28 18:56:56 +02:00
Thomas Haller e1c7a2b5d0 all: don't use gchar/gshort/gint/glong but C types
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
    587
    $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
    21114

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' \
      "${FILES[@]}"
2018-07-11 12:02:06 +02:00
Lubomir Rintel 59ccf5dc89 examples/python: drop nmex.py
It's not an example and not actually used.

https://github.com/NetworkManager/NetworkManager/pull/141
2018-06-29 20:05:39 +02:00
Lubomir Rintel 79fe82753d examples/qt/meson: drop dbus-glib dependency
It's not actually required.

(cherry picked from commit 22813fdc60)
2018-06-28 20:41:12 +02:00
Lubomir Rintel 1b6127d1bc examples/python: utilize nm_utils_get_timestamp_msec() 2018-06-15 16:23:30 +02:00
Lubomir Rintel 9c0db98094 Revert "example/python: avoid falling back to CLOCK_MONOTONIC"
This breaks client tests on avery old kernel (2.6.32, RHEL 6).

  Traceback (most recent call last):
    File "./clients/tests/test-client.py", line 699, in setUp
      self.srv = NMStubServer(self._testMethodName)
    File "./clients/tests/test-client.py", line 309, in __init__
      start = nmex.nm_boot_time_ns()
    File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 54, in nm_boot_time_ns
      return sys_clock_gettime_ns(CLOCK_BOOTTIME)
    File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 50, in sys_clock_gettime_ns
      return _sys_clock_gettime_ns(clock_id)
    File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 39, in f
      raise OSError(errno_, os.strerror(errno_))
  OSError: [Errno 22] Invalid argument

This reverts commit 119e828dbe.
2018-06-15 08:36:22 +02:00
Lubomir Rintel 119e828dbe example/python: avoid falling back to CLOCK_MONOTONIC
According to the D-Bus API specification we return CLOCK_BOOTTIME only.
We don't support kernels too old to have it -- the fall back to
CLOCK_MONOTONIC is only there to be able to run unit tests on RHEL 6
kernel and will eventually go away.
2018-06-14 17:30:06 +02:00
Thomas Haller fd878d8261 examples: add ipv4.dhcp-client-id and ipv6.dhcp-duid to 30-anon.conf example 2018-06-12 14:45:40 +02:00
Lubomir Rintel e69d386975 all: use the elvis operator wherever possible
Coccinelle:

  @@
  expression a, b;
  @@
  -a ? a : b
  +a ?: b

Applied with:

  spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .

With some manual adjustments on spots that Cocci didn't catch for
reasons unknown.

Thanks to the marvelous effort of the GNU compiler developer we can now
spare a couple of bits that could be used for more important things,
like this commit message. Standards commitees yet have to catch up.
2018-05-10 14:36:58 +02:00
Beniamino Galvani 1b5925ce88 all: remove consecutive empty lines
Normalize coding style by removing consecutive empty lines from C
sources and headers.

https://github.com/NetworkManager/NetworkManager/pull/108
2018-04-30 16:24:52 +02:00
Thomas Haller 735dc41bd0 libnm: rework checkpoint API
The libnm API fir checkpoints was only introduced with 1.11. It
is not yet stable, so there is still time to adjust it. Note that
this changes API/ABI of the development branch.

Changes:

- we only add async variants of the checkpoint functions. I believe
  that synchronous D-Bus methods are fundamentally flawed, because
  they mess up the ordering of events.
  Rename the async functions by removing the "_async" suffix. This
  matches glib style, for which the async form is also not specially
  marked.

- for function that refere to a particular checkpoint (rollback and
  destroy), accept the D-Bus path as string, instead of an NMCheckpoint
  instance. This form is more flexible, because it allows to use
  the function without having a NMCheckpoint instance at hand. On the
  other hand, if one has a NMCheckpoint instance, he can trivially
  obtain the path to make the call.
2018-04-04 14:02:13 +02:00
Thomas Haller 2a30bef856 examples: improve checkpoint.py for python/gi
- make python2 and python3 compatible
- support Checkpoint create flags (requires recent libnm for GI
  of flags)
- support adjust-rollback-timeout command
- print elapsed time in show output
2018-04-04 14:02:13 +02:00
Thomas Haller d14b9b8215 examples: add python utils for examples
We need common operations from the python scripts.
For example, to print the boot-time.

Move such utils to a separate nmex.py file ("ex" for
example). This file should contain helper functions that
are pure python (or, if the have requirements, load them
only on demand, so that examples that need those have
additional dependencies). It should also be simple to extract
individual helpers from nmex, so that the user can take an
example, merge parts of nmex.py in, and modify it to his needs.
2018-04-04 14:02:13 +02:00
Thomas Haller ab8312a18e checkpoint: generate GIR information for NMCheckpointCreateFlags
Note that this changes API for checkpoint_create_async() in Python
via GIR. Previously it would require an integer argument, now a flags
argument. But this API is still unstable, it will be introduced with
1.12.
2018-04-04 14:02:13 +02:00
Thomas Haller 28da0154fc all: drop trailing spaces 2018-02-07 13:32:04 +01:00
Thomas Haller e4839accf5 all: replace non-leading tabs with spaces
We commonly only allow tabs at the beginning of a line, not
afterwards. The reason for this style is so that the code
looks formated right with tabstop=4 and tabstop=8.
2018-02-07 13:32:04 +01:00
Thomas Haller 9ef17869b5 version: drop NM_VERSION_MAX_ALLOWED defines for internal build
It already defaults to the right value. We only need to define
NM_VERSION_MIN_REQUIRED, so that parts of our internal build
can make use of deprecated API.
2018-01-23 10:50:34 +01:00
Thomas Haller 8a040c6883 version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLE
We don't need to have two version defines "CUR" and "NEXT".

The main purpose of these macros (if not their only), is to
make NM_AVAILABLE_IN_* and NM_DEPRECATED_IN_* macros work.

1) At the precise commit of a release, "CUR" and "NEXT" must be identical,
because whenever the user configures NM_VERSION_MIN_REQUIRED and
NM_VERSION_MAX_ALLOWED, then they both compare against the current
version, at which point "CUR" == "NEXT".

2) Every other commit aside the release, is a development version that leads
up the the next coming release. But as far as versioning is concerned, such
a development version should be treated like that future release. It's unstable
API and it may or may not be close to later API of the release. But
we shall treat it as that version. Hence, also in this case, we want to
set both "NM_VERSION_CUR_STABLE" and again NEXT to the future version.

This makes NM_VERSION_NEXT_STABLE redundant.

Previously, the separation between current and next version would for
example allow that NM_VERSION_CUR_STABLE is the previously release
stable API, and NM_VERSION_NEXT_STABLE is the version of the next upcoming
stable API. So, we could allow "examples" to make use of development
API, but other(?) internal code still restrict to unstable API. But it's
unclear which other code would want to avoid current development.

Also, the points 1) and 2) were badly understood. Note that for our
previousy releases, we usually didn't bump the macros at the stable
release (and if we did, we didn't set them to be the same). While using
two macros might be more powerful, it is hard to grok and easy to
forget to bump the macros a the right time. One macro shall suffice.

All this also means, that *immediately* after making a new release, we shall
bump the version number in `configure.ac` and "NM_VERSION_CUR_STABLE".
2018-01-23 10:50:34 +01:00
Lubomir Rintel 8a46b25cfa all: require glib 2.40
RHEL 7.1 and Ubuntu 14.04 LTS both have this.

https://bugzilla.gnome.org/show_bug.cgi?id=792323
2018-01-18 11:45:36 +01:00
Iñigo Martínez 5e16bcf268 meson: Improve dependency system
Some targets are missing dependencies on some generated sources in
the meson port. These makes the build to fail due to missing source
files on a highly parallelized build.

These dependencies have been resolved by taking advantage of meson's
internal dependencies which can be used to pass source files,
include directories, libraries and compiler flags.

One of such internal dependencies called `core_dep` was already in
use. However, in order to avoid any confusion with another new
internal dependency called `nm_core_dep`, which is used to include
directories and source files from the `libnm-core` directory, the
`core_dep` dependency has been renamed to `nm_dep`.

These changes have allowed minimizing the build details which are
inherited by using those dependencies. The parallelized build has
also been improved.
2018-01-10 12:20:17 +01:00
Iñigo Martínez 0735b35dd0 build: use template files for enum types' sources generation
Source files for enum types are generated by passing segments of the
source code of the files to the `glib-mkenums` command.

This patch removes those parameters where source code is used from
meson build files by moving those segmeents to template files.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00057.html
2017-12-18 11:25:06 +01:00
Iñigo Martínez 03637ad8b5 build: add initial support for meson build system
meson is a build system focused on speed an ease of use, which
helps speeding up the software development. This patch adds meson
support along autotools.

[thaller@redhat.com: rebased patch and adjusted for iwd support]

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00022.html
2017-12-13 15:48:50 +01:00
Thomas Haller 8388f4ea1d examples: add python/gi example nm-connection-update-stable-id.py
The example script touches the stable-id of a connection.
It does so blocking autoconnect, and was originally written
to test that functionality.
2017-12-05 19:57:24 +01:00
Yifan J 797d9c4403 python: make dbus, gi examples, and debug-helper.py python3 ready
https://bugzilla.gnome.org/show_bug.cgi?id=791121
2017-12-04 11:21:40 +01:00
Beniamino Galvani 77d3b1555e examples: add checkpoint example using python gobject-introspection 2017-11-09 10:12:30 +01:00
Thomas Haller f4458dd157 examples: add python example using VPN import code
Show how to load and use the VPN plugins from python.
2017-11-06 18:37:05 +01:00
Lubomir Rintel d529641756 examples/js: add a javascript example
Converted from python/gi/get_ip.py.
2017-11-06 11:47:05 +01:00
Lucas Rangit Magasweran 843ea77e93 examples: linker requires that library dependencies follow use
On modern distributions, ld runs with the '--as-needed' option
enabled by default, meaning library dependencies must come after
files that require them. Also, this allows indirect linking so the
build commands can be simplified.

The alternative is to add the '-Wl,--no-as-needed' gcc option or
use the top-level Makefile.

Tested on:
 * Ubuntu 16.04.3 with gcc Ubuntu 5.4.1-8ubuntu1
 * Fedora 24 with gcc Red Hat 6.1.1-3

Signed-off-by: Lucas Magasweran <lucas.magasweran@ieee.org>

https://mail.gnome.org/archives/networkmanager-list/2017-September/msg00022.html
https://mail.gnome.org/archives/networkmanager-list/2017-September/msg00023.html
https://mail.gnome.org/archives/networkmanager-list/2017-September/msg00025.html
2017-09-21 13:14:56 +02:00
Thomas Haller adcbcb15e5 examples: add setting-user-data.py
Add an example python script to show and set setting's
user-data. This is useful, as nmcli still doesn't support
user data.

(cherry picked from commit 447c766f52)
2017-05-06 14:53:09 +02:00
Thomas Haller 6198c2a5a4 build: declare build dependencies requiring "nm-core-enum-types.h"
cat <<-EOF > /tmp/glib-mkenums
	#!/bin/bash
	sleep 15 && /usr/bin/glib-mkenums "\$@"
	EOF

	chmod +x /tmp/glib-mkenums

	(export PATH="/tmp:$PATH" &&
	 git clean -fdx &&
	 ./autogen.sh &&
	 make -j20 all-am)

(cherry picked from commit 68ab166f38)
2017-03-29 11:26:27 +02:00
Thomas Haller b869d9cc0d device: add spec "driver:" to match devices
Changing the MAC address of devices is known to fail with
certain drivers. Add a device-spec to allow disabling it
for for such devices.

Related: https://bugzilla.gnome.org/show_bug.cgi?id=777523
2017-03-17 17:40:00 +01:00
Thomas Haller 831286df30 include: use double-quotes to include our own headers
In practice, this should only matter when there are multiple
header files with the same name. That is something we try
to avoid already, by giving headers a distinct name.

When building NetworkManager itself, we clearly want to use
double-quotes for including our own headers.
But we also want to do that in our public headers. For example:

  ./a.c
    #include <stdio.h>
    #include <nm-1.h>
    void main() {
        printf ("INCLUDED %s/nm-2.h\n", SYMB);
    }

  ./1/nm-1.h
    #include <nm-2.h>

  ./1/nm-2.h
    #define SYMB "1"

  ./2/nm-2.h
    #define SYMB "2"

$ cc -I./2 -I./1 ./a.c
$ ./a.out
INCLUDED 2/nm-2.h

Exceptions to this are
  - headers in "shared/nm-utils" that include <NetworkManager.h>. These
    headers are copied into projects and hence used like headers owned by
    those projects.
  - examples/C
2017-03-09 14:12:35 +01:00
Thomas Haller 6fa069fad1 example: add example configuration snippet '30-anon.conf' 2017-01-09 14:50:33 +01:00
Beniamino Galvani 8af465d579 examples: add DNS example with python and GObject introspection 2016-12-12 22:06:24 +01:00
Thomas Haller 2837da9b30 examples/python: fix "import gi" in example
Otherwise there is a warning:

  from gi.repository import GLib, NM
  __main__:1: PyGIWarning: NM was imported without specifying a version first. Use gi.require_version(NM, 1.0) before import to ensure that the right version gets loaded.
2016-11-16 11:50:30 +01:00
Thomas Haller 351851cf27 build: merge "examples/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Thomas Haller b648772fc4 build: merge "examples/C/qt/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Thomas Haller 742d36c476 build: merge "examples/C/glib/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Beniamino Galvani 1ab616b59c checkpoint: make python example accept multiple devices and timeout
Add a timeout parameter and allow passing multiple interfaces to make
the script more useful for testing purposes.
2016-09-26 15:10:39 +02:00
Beniamino Galvani 048801add3 checkpoint: add python D-Bus example 2016-08-17 14:55:34 +02:00
Beniamino Galvani 76348adb8e examples: fix crash in add-connection-libnm
Reported-by: Ali Nematollahi <alirezan1@gmail.com>
2016-04-20 07:48:17 +02:00
Thomas Haller 05f17ace71 man: fix typo in NetworkManager.conf manual and 10-ifcfg-rh-routes.sh comment 2016-03-31 20:46:52 +02:00
Lubomir Rintel 3a2803b42c docs: replace spec.html with docbook D-Bus API reference
May use a lot of improvement (actually documenting the names and
objects that use the interfaces in question), but at least this looks a
lot better on developer.gnome.org.
2016-03-26 11:28:19 +01:00
Adrian Likins 6c59443ad5 Fix missing commas in list-devices devtypes dict. 2016-03-02 18:43:28 +01:00
Thomas Haller 1b00009169 device: add new NMDeviceType NM_DEVICE_TYPE_VETH
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 23:15:37 +01:00
Thomas Haller 71962881a8 examples: add missing device-types to examples
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 15:24:39 +01:00
Thomas Haller 8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Dan Williams 91f06323c7 examples: avoid compile errors around NM versioning 2016-01-28 12:27:14 -06:00
Thomas Haller bc7ad75d99 contrib/rpm: install pre-up dispatcher script "10-ifcfg-rh-routes.sh" as no-wait
The main reason to introduce the "no-wait.d" dispatcher directory was
"10-ifcfg-rh-routes.sh", which (as a pre-up script) delays activation.
We even extracted the script to a separate package on RHEL to avoid
delays by default.

Invoke the script via no-wait.d.
2016-01-08 14:27:18 +01:00
Thomas Haller db80ec05ab build: rename directory "include" to "shared"
Up to now, the "include" directory contained (only) header files that were
used project-wide by libs, core, clients, et al.

Since the directory now also contains a non-header file, the "include"
name is misleading. Instead of adding yet another directory that is
project-wide, with non-header-only content, rename the "include"
directory to "shared".
2015-12-24 11:42:37 +01:00