Commit Graph

32 Commits

Author SHA1 Message Date
Thomas Haller
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship
3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00
Thomas Haller
b8b1a01d96 build: rename file "include/nm-utils-internal.h" to "nm-macros-internal.h"
We already have "nm-utils*.h" and "NetworkManagerUtils.h" headers. Rename
"include/nm-utils-internal.h" to "nm-macros-internal.h". I think that
name is better, because this file is header-only, internal, and
repository-wide.

Also, it will never contain non-header-only declarations because
there is no backing object file under "include/".
It will only contain macros and inline functions.
2015-06-01 14:47:08 +02:00
Dan Williams
677cee0f23 dhclient: use fqdn.fqdn for server DDNS updates
dhclient only supports fqdn.fqdn for server DDNS updates with
DHCPv6.  And even though the underlying DHCP options that fqdn.fqdn
controls allow non-qualified hostnames on the wire, dhclient does
not.  So we must require a fully-qualified name for DHCPv6.

Second, while no-client-updates seems like it should be "off", doing
that apparently makes dhclient set the "O" flag to 1 which appears to
be a bug, and results in the server not doing the DDNS update.  So
we must stop setting that option too.

Found by: Alexander Groß
2015-02-27 10:05:56 -06:00
Dan Williams
84f54f0a5f core: pass ifindex as parameter to nm_ip4_config_new() 2015-02-27 16:50:09 +01:00
Thomas Haller
422fbf48b9 all: move STRLEN() macro to global header nm-utils-internal.h
https://bugzilla.gnome.org/show_bug.cgi?id=741651
2014-12-18 17:36:57 +01:00
Dan Winship
3bfb163a74 all: consistently include config.h
config.h should be included from every .c file, and it should be
included before any other include. Fix that.

(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
2014-11-13 17:18:42 -05:00
Dan Williams
e43174f368 dhcp: preserve DHCPv4 client ID for later use
If we can, read the existing client ID from the leasefile and preserve
it for later use.
2014-11-07 12:18:32 -06: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
Thomas Haller
7afdd9c979 dhclient: allow single hex digits in hexadecimal dhcp_client_id
When checking whether the dhcp-client-identifier is a hex string,
we expected pairs of hexadecimal digits separated by colon.
Relax this check to also allow single hex digits.

https://bugzilla.gnome.org/show_bug.cgi?id=737727

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-27 16:45:57 +01:00
Lubomir Rintel
33866e4030 core: Move NMPlatformSource to nm-types.h
...and rename it while at it. It's going to be useful outside nm-platform,
to weight MTU options from various sources.
2014-10-20 12:41:50 +02:00
Dan Winship
3a54d05098 libnm-core: change all mac-address properties to G_TYPE_STRING
Make all mac-address properties (including NMSettingBluetooth:bdaddr,
NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be
strings, using _nm_setting_class_transform_property() to handle
translating to/from binary form when dealing with D-Bus.

Update everything accordingly for the change, and also add a test for
transformed setting properties to test-general.
2014-09-04 09:20:10 -04:00
Dan Winship
b28f6526c2 core: fill in nm-types.h, clean out other headers
Clean up some of the cross-includes between headers (which made it so
that, eg, if you included NetworkManagerUtils.h in a test program, you
would need to build the test with -I$(top_srcdir)/src/platform, and if
you included nm-device.h you'd need $(POLKIT_CFLAGS)) by moving all
GObject struct definitions for src/ and src/settings/ into nm-types.h
(which already existed to solve the NMDevice/NMActRequest circular
references).

Update various .c files to explicitly include the headers they used to
get implicitly, and remove some now-unnecessary -I options from
Makefiles.
2014-07-23 10:56:26 -04:00
Thomas Schäfer
bcd554724e dhcp: let dhclient handle requesting the 'server-id' option
Always requesting this appears to cause some devices to ignore
DHCP requests, like the ZTE 823D, ZTEMF93E, Alcatel W800Z.
dhclient probably knows better than NM when to request the
server's ID, so leave that up to dhclient.  We don't do anything
interesting with it anyway.
2014-07-17 15:53:04 -05:00
Thomas Haller
6723745fe0 dhcp: nm_dhcp_dhclient_read_lease_ip_configs() must anchor the address lifetime at *now*
nm_dhcp_dhclient_read_lease_ip_configs() calculates the remaining time
until the address expires. It must anchor the lifetimes by setting the
@timestamp to nm_utils_get_monotonic_timestamp_s().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-19 22:13:48 +02:00
Thomas Haller
325d89fc85 dhcp: refactor not to pass on NMSettingIP4Config objects
These settings are mostly unused. Do not pass them when starting the client,
instead only pass the argument that is actually used (dhcp_client_id).

This simplifies the code later, when we delay starting of DHCP6 clients --
because there is no need to clone the setting.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-11 11:31:34 +02:00
Thomas Haller
d14ffbdb9c dhcp: refactor dhcp code to use @dhcp_anycast_addr as #GByteArray type
At a later point, we will have to make a copy of @dhcp_anycast_addr to start
the client asynchronously. Although the length of the guint8 array *should*
always be 6 byte (being a MAC address), it's nicer to just pass on the
GByteArray instance instead, which knows how many byte are actually
set.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-11 11:30:57 +02:00
Dan Williams
067db6f8d7 core/platform: add address/route sources (rh#1005416, bgo#722843)
Tag addresses and routes with their source.  We'll use this later to do
(or not do) operations based on where the item came from.

One thing to note is that when synchronizing items with the kernel, all
items are read as source=KERNEL even when they originally came from
NetworkManager, since the kernel has no way of providing this source
information.  This requires the source 'priority', which
nm_ip*_config_add_address() and nm_ip*_config_add_route() must respect
to ensure that NM-owned routes don't have their source overwritten
when merging various IP configs in ip*_config_merge_and_apply().

Also of note is that memcmp() can no longer be used to compare
addresses/routes in nm-platform.c, but this had problems before
anyway with ifindex, so that workaround from nm_platform_ip4_route_sync()
can be removed.

https://bugzilla.gnome.org/show_bug.cgi?id=722843
https://bugzilla.redhat.com/show_bug.cgi?id=1005416
2014-01-24 09:42:52 -06:00
Dan Williams
048052cb6e dhcp: make dhclient lease parsing code testable 2013-11-08 16:46:43 -06:00
Dan Winship
68f12b4e9c settings: make connections always have s_ip4 and s_ip6
Make sure that all connections returned from NMSettings or created via
AddAndActivateConnection have an NMSettingIP4Config and an
NMSettingIP6Config, with non-NULL methods, and get rid of
now-unnecessary checks for those.

Also move the slaves-can't-have-IP-config checks into the
platform-independent code as well. This also gets rid of spurious
"ignoring IP4/IP6 configuration" warnings in ifcfg-rh when reading a
slave ifcfg file.

Partly based on a patch from Pavel.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
2013-10-11 12:24:34 -04:00
Jiří Klimeš
1ef19f377b dhcp: string vs. byte-array of dhcp-client-identifier (rh #999503)
Distinguish properly between ASCII strings and byte arrays for
dhcp-client-identifier. Else dhclient refuses to parse the configuration
file.
2013-09-06 11:20:00 -05:00
Jiří Klimeš
a96053fe13 dhclient: also request 'static-routes' option from DHCP server (rh #922558)
DHCP server won't send 'Static Route' option to the client if it is not
explicitly requested.
2013-03-20 10:00:42 +01:00
Dan Williams
97990135f1 dhcp: ensure any dhclient script from dhclient.conf is ignored
The config file can specify a dhclient script, which gets used instead
of what NM passes on the command-line.  Make sure that script gets
ignored in the final dhclient config, because the script NM passes
is the script that needs to be used to pass data back to NM.  People
may have old dhclient.conf files lying around that get picked up and
we don't want any script specified there to interfere.
2013-02-27 17:17:11 +01:00
Dan Williams
62a940ab7b dhclient: save DUID to dhclient leasefiles when required
The DUID is supposed to be machine-wide, so if we're writing a new
leasefile, save the default DUID to it.  If we haven't saved a
persistent DUID yet, do that to.
2013-01-29 10:18:42 -06:00
Mathieu Trudel-Lapierre
ab4bc03de2 dhclient: read DUID from leasefiles 2013-01-29 10:18:42 -06:00
Dan Williams
dc518cf86b dhcp: add generic DUID infrastructure
Add infrastructure for generating DUID-LLT from a given device MAC and
passing it around to the DHCP client implementations.

Thanks to Mathieu Trudel-Lapierre for bug fixes in the
unescaping code, which were merged into this commit.
2013-01-29 10:16:45 -06:00
Gene Czarcinski
90b99522d7 dhcp: fix DHCPv6 to support server-side dynamic DNS (bgo #684242)
This patch makes DHCPv6 support more or less equivalent to that
one of IPv4 DHCP.

(dcbw: fix some formatting, rearrange code so it's less convoluted,
fix up writing hostname to ifcfg files)
2012-11-16 17:26:19 -06:00
Dan Winship
6878d20ac4 all: Don't use ctype.h macros
The ctype macros (eg, isalnum(), tolower()) are locale-dependent. Use
glib's ASCII-only versions instead.

Also, replace isascii() with g_ascii_isprint(), since isascii()
accepts control characters, which isn't what the code wanted in any of
the places where it was using it.
2012-09-26 12:14:37 -04:00
Jiří Klimeš
74d962e8c4 trivial: spacing fix 2012-03-05 13:19:47 +01:00
Jiří Klimeš
5737573314 dhclient: only send hostname without domain as host-name option (rh #694758) 2011-05-13 11:44:22 +02:00
Dan Williams
e079f25a2b dhclient: explicitly request WPAD option (bgo #368423) 2010-12-17 23:09:20 -06:00
Dan Williams
297e3c6463 dhclient: split out dhclient config merging and add testcases 2010-12-17 23:09:20 -06:00