summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)AuthorFilesLines
2018-08-28examples: make 10-ifcfg-rh-routes.sh self-containedBeniamino Galvani1-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
2018-07-11all: don't use gchar/gshort/gint/glong but C typesThomas Haller2-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[@]}"
2018-06-29examples/python: drop nmex.pyLubomir Rintel1-72/+0
It's not an example and not actually used. https://github.com/NetworkManager/NetworkManager/pull/141
2018-06-28examples/qt/meson: drop dbus-glib dependencyLubomir Rintel1-1/+0
It's not actually required. (cherry picked from commit 22813fdc6005fa3ed0ecddfdb21fefd4bea616c3)
2018-06-15examples/python: utilize nm_utils_get_timestamp_msec()Lubomir Rintel1-3/+1
2018-06-15Revert "example/python: avoid falling back to CLOCK_MONOTONIC"Lubomir Rintel1-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.
2018-06-14example/python: avoid falling back to CLOCK_MONOTONICLubomir Rintel1-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.
2018-06-12examples: add ipv4.dhcp-client-id and ipv6.dhcp-duid to 30-anon.conf exampleThomas Haller1-6/+31
2018-05-10all: use the elvis operator wherever possibleLubomir Rintel1-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.
2018-04-30all: remove consecutive empty linesBeniamino Galvani4-4/+0
Normalize coding style by removing consecutive empty lines from C sources and headers. https://github.com/NetworkManager/NetworkManager/pull/108
2018-04-04libnm: rework checkpoint APIThomas Haller1-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.
2018-04-04examples: improve checkpoint.py for python/giThomas Haller1-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
2018-04-04examples: add python utils for examplesThomas Haller1-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.
2018-04-04checkpoint: generate GIR information for NMCheckpointCreateFlagsThomas Haller1-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.
2018-02-07all: drop trailing spacesThomas Haller5-7/+7
2018-02-07all: replace non-leading tabs with spacesThomas Haller2-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.
2018-01-23version: drop NM_VERSION_MAX_ALLOWED defines for internal buildThomas Haller1-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.
2018-01-23version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLEThomas Haller1-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".
2018-01-18all: require glib 2.40Lubomir Rintel8-40/+0
RHEL 7.1 and Ubuntu 14.04 LTS both have this. https://bugzilla.gnome.org/show_bug.cgi?id=792323
2018-01-10meson: Improve dependency systemIñigo Martínez1-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.
2017-12-18build: use template files for enum types' sources generationIñigo Martínez1-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
2017-12-13build: add initial support for meson build systemIñigo Martínez2-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
2017-12-05examples: add python/gi example nm-connection-update-stable-id.pyThomas Haller1-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.
2017-12-04python: make dbus, gi examples, and debug-helper.py python3 readyYifan J24-99/+99
https://bugzilla.gnome.org/show_bug.cgi?id=791121
2017-11-09examples: add checkpoint example using python gobject-introspectionBeniamino Galvani1-0/+130
2017-11-06examples: add python example using VPN import codeThomas Haller1-0/+74
Show how to load and use the VPN plugins from python.
2017-11-06examples/js: add a javascript exampleLubomir Rintel1-0/+184
Converted from python/gi/get_ip.py.
2017-09-21examples: linker requires that library dependencies follow useLucas Rangit Magasweran8-8/+8
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-05-06examples: add setting-user-data.pyThomas Haller1-0/+246
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 447c766f526ec8bc4f5aa109a5e261cf060d1042)
2017-03-29build: declare build dependencies requiring "nm-core-enum-types.h"Thomas Haller3-1/+12
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 68ab166f3894834af9473d42f5dab72e0ed15394)
2017-03-17device: add spec "driver:" to match devicesThomas Haller1-0/+11
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-09include: use double-quotes to include our own headersThomas Haller3-6/+4
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-01-09example: add example configuration snippet '30-anon.conf'Thomas Haller1-0/+55
2016-12-12examples: add DNS example with python and GObject introspectionBeniamino Galvani1-0/+63
2016-11-16examples/python: fix "import gi" in exampleThomas Haller1-0/+2
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-10-21build: merge "examples/Makefile.am" into toplevel MakefileThomas Haller10-64/+0
2016-10-21build: merge "examples/C/qt/Makefile.am" into toplevel MakefileThomas Haller3-52/+0
2016-10-21build: merge "examples/C/glib/Makefile.am" into toplevel MakefileThomas Haller2-56/+1
2016-09-26checkpoint: make python example accept multiple devices and timeoutBeniamino Galvani1-22/+34
Add a timeout parameter and allow passing multiple interfaces to make the script more useful for testing purposes.
2016-08-17checkpoint: add python D-Bus exampleBeniamino Galvani1-0/+63
2016-04-20examples: fix crash in add-connection-libnmBeniamino Galvani1-1/+1
Reported-by: Ali Nematollahi <alirezan1@gmail.com>
2016-03-31man: fix typo in NetworkManager.conf manual and 10-ifcfg-rh-routes.sh commentThomas Haller1-1/+1
2016-03-26docs: replace spec.html with docbook D-Bus API referenceLubomir Rintel1-1/+1
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-02Fix missing commas in list-devices devtypes dict.Adrian Likins1-5/+5
2016-02-23device: add new NMDeviceType NM_DEVICE_TYPE_VETHThomas Haller3-0/+3
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23examples: add missing device-types to examplesThomas Haller3-1/+13
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-19all: cleanup includes and let "nm-default.h" include "config.h"Thomas Haller8-16/+0
- 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-01-28examples: avoid compile errors around NM versioningDan Williams1-1/+2
2016-01-08contrib/rpm: install pre-up dispatcher script "10-ifcfg-rh-routes.sh" as no-waitThomas Haller1-0/+3
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.
2015-12-24build: rename directory "include" to "shared"Thomas Haller1-2/+2
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".