summaryrefslogtreecommitdiff
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* all: SPDX header conversionLubomir Rintel2019-09-1066-918/+66
| | | | | $ find * -type f |xargs perl contrib/scripts/spdx.pl $ git rm contrib/scripts/spdx.pl
* examples: improve usage/synposis for nm-update2.py and nm-add-connection2.pyThomas Haller2019-08-082-4/+14
|
* example: print WireGuard parameters in nm-wg-set example scriptThomas Haller2019-07-311-0/+12
| | | | (cherry picked from commit e966f4b272331fcf99914ee2c1a980074a01ed94)
* examples: add examples/python/gi/nm-update2.py example scriptThomas Haller2019-07-251-0/+155
| | | | This is useful for manually testing Update2() D-Bus API.
* examples: add examples/python/gi/nm-add-connection2.py example scriptth/settings-add2-and-update2-optionsThomas Haller2019-07-251-0/+156
| | | | This is useful for manually testing AddConnection2() D-Bus API.
* all: drop vim file variables from source filesThomas Haller2019-06-1133-33/+0
| | | | sed '1,3 { /^\(#\|--\) *vim:/d }; 1 { /^\/\* *vim:.*\*\/$/ d}' -i $(git grep -l 'vim:')
* all: drop emacs file variables from source filesThomas Haller2019-06-1150-50/+0
| | | | | | | | | | | | | | | | | | | | | | 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.
* examples: use '\n' line endings in "examples/C/qt/add-connection-wired.cpp"Thomas Haller2019-06-111-76/+76
| | | | | | | | | | Find with: git ls-files -z | xargs -0 file | grep with\ CRLF Fix with: dos2unix examples/C/qt/add-connection-wired.cpp
* gitignore: merge gitignore filesThomas Haller2019-05-191-2/+0
| | | | | | | | | 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.
* build/meson: rename "nm_core_dep" to "libnm_core_dep"Thomas Haller2019-04-181-1/+1
| | | | | | | The library is called "libnm_core". So the dependency should be called "libnm_core_dep", like in all other cases. (cherry picked from commit c27ad37c278461fd783b6db56844683ab3088345)
* examples: drop rtl drivers from the mac address change blacklistLubomir Rintel2019-04-081-2/+2
| | | | | | | | | | 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.
* examples: don't set "ethernet.cloned-mac-address" in ↵Thomas Haller2019-04-081-6/+5
| | | | | | | "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.
* examples: blacklist drivers "wl" and "8188eu" in "31-mac-addr-change.conf" ↵Thomas Haller2019-04-051-4/+8
| | | | | | | | | | | | | | | | | | | | 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] https://github.com/lwfinger/rtl8188eu/blob/9a56f32c2a46be5b81f0eedf49ad44ea8f10bfae/dkms.conf
* all: codespell fixesLubomir Rintel2019-03-111-1/+1
| | | | | | | Codespel run with the same arguments as described in commit 58510ed56679 ('docs: misc. typos pt2'). (cherry picked from commit bf0c4e6ac2855088e3962693886bb6ab71856f7b)
* libnm: change nm_wireguard_peer_set_endpoint() API to allow validationThomas Haller2019-03-071-1/+1
| | | | | | | | This is an API break since 1.16-rc1. Similar to previous commit. (cherry picked from commit 8ae9aa2428c10aafb837c692fb39bfd04ef4235c)
* libnm: change nm_wireguard_peer_set_public_key() API to allow validationThomas Haller2019-03-071-1/+1
| | | | | | | | This is an API break since 1.16-rc1. Similar to previous commit. (cherry picked from commit 7962653918fbfd66b549d389a1cb2cf96ae0d3eb)
* libnm: change nm_wireguard_peer_set_preshared_key() API to allow validationThomas Haller2019-03-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 d7bc1750c1bcc5082528d1f277e09454b2cbf1c2)
* examples: fix handling secrets in nm-wg-setThomas Haller2019-02-261-2/+17
| | | | | | | | | | | | | | 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 6aa9e52bd88670f10861e402a8c61c282a1e97c2)
* examples: improve hints about existing WireGuard profiles in nm-wg-setThomas Haller2019-02-261-6/+21
| | | | (cherry picked from commit b5a458c5ffeec091cc60abbabaed4d1a49952872)
* examples: add python example script "nm-wg-set" for modifying WireGuard profileThomas Haller2019-02-221-0/+423
| | | | | | | | 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.
* build: meson: Add trailing commasIñigo Martínez2018-12-202-6/+6
| | | | | | | 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
* examples: fix wrong example configuration in "31-mac-addr-change.conf"Thomas Haller2018-12-101-1/+6
| | | | Fixes: b869d9cc0dda4fe5300f5ec5b5a090199ecd4e3e
* all: say Wi-Fi instead of "wifi" or "WiFi"Lubomir Rintel2018-11-294-6/+6
| | | | | | | | 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.
* dispatcher: fix shellcheck warningsBeniamino Galvani2018-10-061-2/+2
| | | | | | | 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
* docs: misc. typosluz.paz2018-09-157-7/+7
| | | | | | Found via `codespell -q 3 --skip="*.po"` https://github.com/NetworkManager/NetworkManager/pull/203
* examples: make 10-ifcfg-rh-routes.sh self-containedBeniamino Galvani2018-08-281-9/+97
| | | | | | | | | | 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
* all: don't use gchar/gshort/gint/glong but C typesThomas Haller2018-07-112-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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[@]}"
* examples/python: drop nmex.pyLubomir Rintel2018-06-291-72/+0
| | | | | | It's not an example and not actually used. https://github.com/NetworkManager/NetworkManager/pull/141
* examples/qt/meson: drop dbus-glib dependencyLubomir Rintel2018-06-281-1/+0
| | | | | | It's not actually required. (cherry picked from commit 22813fdc6005fa3ed0ecddfdb21fefd4bea616c3)
* examples/python: utilize nm_utils_get_timestamp_msec()Lubomir Rintel2018-06-151-3/+1
|
* Revert "example/python: avoid falling back to CLOCK_MONOTONIC"Lubomir Rintel2018-06-151-2/+12
| | | | | | | | | | | | | | | | | | | 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 119e828dbeeeab134e83890b18d0b7a0c1838786.
* example/python: avoid falling back to CLOCK_MONOTONICLubomir Rintel2018-06-141-12/+2
| | | | | | | 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.
* examples: add ipv4.dhcp-client-id and ipv6.dhcp-duid to 30-anon.conf exampleth/dhcp-client-idThomas Haller2018-06-121-6/+31
|
* all: use the elvis operator wherever possibleLubomir Rintel2018-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | 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.
* all: remove consecutive empty linesBeniamino Galvani2018-04-304-4/+0
| | | | | | | Normalize coding style by removing consecutive empty lines from C sources and headers. https://github.com/NetworkManager/NetworkManager/pull/108
* libnm: rework checkpoint APIThomas Haller2018-04-041-25/+30
| | | | | | | | | | | | | | | | | | | | | | 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.
* examples: improve checkpoint.py for python/giThomas Haller2018-04-041-49/+100
| | | | | | | | - 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
* examples: add python utils for examplesThomas Haller2018-04-041-0/+72
| | | | | | | | | | | | | 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.
* checkpoint: generate GIR information for NMCheckpointCreateFlagsThomas Haller2018-04-041-0/+1
| | | | | | | 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.
* all: drop trailing spacesThomas Haller2018-02-075-7/+7
|
* all: replace non-leading tabs with spacesThomas Haller2018-02-072-3/+3
| | | | | | 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.
* version: drop NM_VERSION_MAX_ALLOWED defines for internal buildThomas Haller2018-01-231-1/+0
| | | | | | 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.
* version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLEThomas Haller2018-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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".
* all: require glib 2.40lr/glib-2-40Lubomir Rintel2018-01-188-40/+0
| | | | | | RHEL 7.1 and Ubuntu 14.04 LTS both have this. https://bugzilla.gnome.org/show_bug.cgi?id=792323
* meson: Improve dependency systemIñigo Martínez2018-01-101-18/+11
| | | | | | | | | | | | | | | | | | | | 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.
* build: use template files for enum types' sources generationIñigo Martínez2017-12-181-2/+2
| | | | | | | | | | 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
* build: add initial support for meson build systemIñigo Martínez2017-12-132-0/+74
| | | | | | | | | | 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
* examples: add python/gi example nm-connection-update-stable-id.pyThomas Haller2017-12-051-0/+116
| | | | | | The example script touches the stable-id of a connection. It does so blocking autoconnect, and was originally written to test that functionality.
* python: make dbus, gi examples, and debug-helper.py python3 readyYifan J2017-12-0424-99/+99
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=791121
* examples: add checkpoint example using python gobject-introspectionBeniamino Galvani2017-11-091-0/+130
|