Commit Graph

25 Commits

Author SHA1 Message Date
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
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
ec8468e47d libnm: add NM_IP_ADDRESS_ATTRIBUTE_LABEL define
There is only one supported attribute for addresses. The "lable".
Give it a #define.
2017-12-18 12:14:50 +01:00
Thomas Haller
0ed49717ab all: support route-attribute "onlink" for IPv4
Kernel doesn't support it for IPv6.

This is especially useful, if you combine static routes
with DHCP. In that case, you might want to get the device-route
to the gateway automatically, but add a static-route for it.
2017-11-13 11:35:44 +01:00
Thomas Haller
cc1ee1d286 all: rework configuring route table support by adding "route-table" setting
We added "ipv4.route-table-sync" and "ipv6.route-table-sync" to not change
behavior for users that configured policy routing outside of NetworkManager,
for example, via a dispatcher script. Users had to explicitly opt-in
for NetworkManager to fully manage all routing tables.

These settings were awkward. Replace them with new settings "ipv4.route-table"
and "ipv6.route-table". Note that this commit breaks API/ABI on the unstable
development branch by removing recently added API.

As before, a connection will have no route-table set by default. This
has the meaning that policy-routing is not enabled and only the main table
will be fully synced. Once the user sets a table, we recognize that and
NetworkManager manages all routing tables.

The new route-table setting has other important uses: analog to
"ipv4.route-metric", it is the default that applies to all routes.
Currently it only works for static routes, not DHCP, SLAAC,
default-route, etc. That will be implemented later.

For static routes, each route still can explicitly set a table, and
overwrite the per-connection setting in "ipv4.route-table" and
"ipv6.route-table".
2017-10-09 22:05:36 +02:00
Thomas Haller
f83e6b9743 libnm: add nm_ip_route_equal_full() function
Expose previously internal function nm_ip_route_equal_full(). It's
just useful API.

However, add a @cmp_flags argument, so that in the future we could
extend it.
2017-09-27 18:58:53 +02:00
Thomas Haller
5b0f895e19 libnm,core: add TABLE attribute for routes settings
https://bugzilla.redhat.com/show_bug.cgi?id=1436531
2017-09-26 19:39:36 +02:00
Thomas Haller
c71f26bf92 libnm,cli: add IP setting "route-table-sync" 2017-09-26 19:39:36 +02:00
Beniamino Galvani
80dfb8cdab core,libnm-core: use same route attribute names of iproute2
Users are probably more familiar with iproute2 route option names than
kernel ones.

Fixes: 54e58eb96b
2017-03-22 12:04:25 +01:00
Beniamino Galvani
54e58eb96b libnm-core: define known route attribute names and validation function
This adds definition of a set of known route option attributes to
libnm-core and helper functions.

nm_ip_route_attribute_validate() performs the validation of the
attribute type and, in case of a formatted string attribute, of its
content.

nm_ip_route_get_variant_attribute_spec() returns the attribute format
specifier to be passed to nm_utils_parse_variant_attributes(). Since
at the moment NMIPRoute is the only user of NMVariantAttributeSpec and
the type is opaque to users of the library, the struct is extended to
carry some other data useful for validation.
2017-03-06 15:20:25 +01:00
Beniamino Galvani
bdd0e7fec0 libnm-core: add dns-priority to NMSettingIPConfig 2016-05-12 17:13:50 +02:00
Beniamino Galvani
f1d23c32c3 docs: libnm: add doc comment to types
This is required to add objects in the "Types and Values" section and
in the API index. Later, we may want to add useful content in those
empty comments.
2016-05-05 17:01:57 +02:00
Beniamino Galvani
d6d42e0825 libnm-core: add 'use-vc' DNS option
The option forces the use of TCP for DNS resolutions.
2016-04-03 23:08:38 +02:00
Beniamino Galvani
206e074863 libnm,core,cli: move dhcp-timeout property to generic NMSettingIPConfig
The property applies to both IPv4 and IPv6 and so it should not be in
NMSettingIP4Config but in the base class.
2016-02-16 11:37:26 +01:00
Jiří Klimeš
31ea5a99cb libnm: add NMSettingIPConfig 'dad-timeout' property
The property is used to control duplicate address detection:
 * -1 means default value
 * 0 means no DAD is performed
 * > 0 means timeout (in milliseconds) for arping responses

[bgalvani: moved setting from NMSettingIP4Config]
2016-01-20 11:53:47 +01:00
Thomas Haller
a8dd1b5358 libnm: make dns-options support an "undefined" default value
We want to distinguish between "no-options/empty" and "unset/default".
The latter can be interpreted by NM to use a default set of options.
2015-06-05 12:26:48 +02:00
Thomas Haller
533f9fa2d2 libnm: move internal dns-option helpers to "nm-core-internal.h"
"nm-utils-private.h" should not be used outside of libnm-core/.
core/ should only use public API or "nm-core-internal.h".

Also, "nm-setting-ip-config.h" is a public header and should
not contain internal defines. Move them to "nm-core-internal.h"
too.

Fixes: 019943bb5d
2015-05-20 12:42:14 +02:00
Beniamino Galvani
8d9776997b libnm-core/trivial: rename 'i' function argument to 'idx' 2015-05-13 17:15:34 +02:00
Beniamino Galvani
019943bb5d libnm-core: add dns-options property to NMSettingIPConfig 2015-05-13 17:15:34 +02:00
Thomas Haller
ce7fc351db libnm: add NMSettingIPConfig:route-metric
https://bugzilla.gnome.org/show_bug.cgi?id=735512
https://bugzilla.redhat.com/show_bug.cgi?id=663730

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Dan Winship
e374923bbe all: allow route metrics to be "0"
Change NMIPRoute to use "-1" for "default", so that "0" is a valid
metric. Update everything for that.
2014-11-07 07:49:41 -05:00
Dan Winship
f17699f4e3 libnm-core: add NMSettingIPConfig:gateway, drop NMIPAddress:gateway
The gateway is a global property of the IPv4/IPv6 configuration, not
an attribute of any particular address. So represent it as such in the
API; remove the gateway from NMIPAddress, and add it to
NMSettingIPConfig.

Behind the scenes, the gateway is still serialized along with the
first address in NMSettingIPConfig:addresses, and is deserialized from
that if the settings dictionary doesn't contain a 'gateway' key.

Adjust nmcli's interactive mode to prompt for IP addresses and gateway
separately. (Patch partly from Jirka Klimeš.)
2014-11-07 07:49:40 -05:00
Dan Winship
3f30c6f1c2 libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classes
Split a base NMSettingIPConfig class out of NMSettingIP4Config and
NMSettingIP6Config, and update things accordingly.

Further simplifications of now-redundant IPv4-vs-IPv6 code are
possible, and should happen in the future.
2014-11-07 07:49:40 -05:00
Dan Winship
39709fdc2e libnm-core: add NMIPAddress/NMIPRoute attributes, use for labels
Add key-value attributes to NMIPAddress and NMIPRoute, and use them to
store IPv4 address labels. Demote NMSettingIP4Config:address-labels to
a D-Bus-only property, and arrange for :addresses setter to read the
labels out of that property when creating the addresses.
2014-11-07 07:49:40 -05:00
Dan Winship
21c8a6b20e libnm-core, all: merge IPv4 and IPv6 address/route types
Merge NMIP4Address and NMIP6Address into NMIPAddress, and NMIP4Route
and NMIP6Route into NMIPRoute. The new types represent IP addresses as
strings, rather than in binary, and so are address-family agnostic.
2014-11-07 07:49:40 -05:00