Commit Graph

46 Commits

Author SHA1 Message Date
Dan Williams
24c1523b51 dhcp: pass individual options to DHCP instead of NMSettingIPxConfig 2014-07-22 14:39:19 -05:00
Dan Williams
5b4be27f4a dhcp: consolidate and simplify DHCP options tests
Previously the tests required that a NMDHCPClient object was
created, but all that's really being tested is the DHCP option
parsing and that doesn't need a client object now that the
option parsing has been split out.

Also, the options test wasn't in src/dhcp-manager/, so put it there.

Lastly, the test ran for both dhclient and dhcpcd, but the code
executed for both cases was the same, so there's no reason to keep
running the test for both clients.
2014-07-22 14:39:19 -05:00
Dan Williams
37b6fc1c85 dhcp: pass ifindex to DHCP clients 2014-07-22 14:33:39 -05:00
Dan Winship
722c90343b core: set route metrics earlier
Instead of creating most routes with metric 0 and then fixing them
just before applying them, create the routes with the correct metric
in the first place (so that NMIP4Config and NMIP6Config don't have to
try to guess whether "metric 0" means "unset" or "actually metric 0").
2014-06-06 10:23:28 -04:00
Dan Williams
b732240026 core: remove the HostnameProvider interface
It's only used to keep the DHCPManager up-to-date with hostname changes,
and that can be accomplished in much less code by just having NMManager
set a hostname on the DHCPManager itself.
2014-05-09 15:33:32 -05:00
Dan Williams
d336a78a0e core: don't ref/unref the DHCP manager
It's a singleton anyway, so no need to ref/unref it.  Just use it.
2014-05-09 15:33:32 -05: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
e2fa51cd67 dhcp: rename get_lease_config -> get_lease_ip_configs
Since dhcpcd doesn't implement this function yet, just remove the
stub implementation.
2013-11-08 16:46:43 -06:00
Martin Pitt
fd4709fa27 core: add option for running from the build tree
Add hidden command line option --run-from-build-dir; with that, helpers
like nm-avahi-autoipd.action and nm-dhcp-helper will be called from the
build tree instead of libexecdir, which allows testing without having to
install first.

Helper paths are now stored in global variables instead of macros, and
get modified with that new option.

https://bugzilla.gnome.org/show_bug.cgi?id=698752
2013-05-22 16:17:23 +02:00
Dan Winship
213a3a4d2e core: don't pass config data to NMDHCPManager and NMDnsManager
Rather than passing specific bits of data to NMDHCPManager and
NMDnsManager, just let them call nm_config_get() and then get the data
themselves.

Also, remove the GError argument from nm_dhcp_manager_new(), since the
function never returned NULL. This in turn means there is no longer
any need for a distinction between nm_dhcp_manager_new() and
nm_dhcp_manager_get(), so remove the former.
2013-04-03 10:23:48 -04:00
Dan Williams
c4e519bd78 dhcp: pass device hardware address to DHCP
Gets used for stuff like the interface DUID for DHCPv6.
2013-01-29 10:07:54 -06:00
Pavel Šimerda
20d4125cfc dhcp: store NetworkManager-specific dhclient leases in /var/lib/NetworkManager/
DHCP lease file names are built by NetworkManager and contain connection UUID
which makes them NM-specific. Their new location belongs to NetworkManager and
doesn't have to be guessed. With no guessing, we don't need distribution-specific
conditionals.

Note: This change may require modifications to the selinux policy. But after all
these files actually belong to NetworkManager as well as the instance of dhclient
that uses them.
2012-11-16 15:27:22 -06:00
Jiří Klimeš
edb85e9720 core: fix NM_IS_*_CLASS(klass) macros
The argument is 'klass' not 'obj'.
2012-07-27 13:15:54 +02:00
Dan Winship
54ef8f3224 Fix names of error enum values
When NM was registering all of its enum types by hand, it was using
NamesLikeThis rather than the default names-like-this for the "nick"
values. When we switched to using glib-mkenums, this resulted in
dbus-glib using different strings for the D-Bus error names, causing
compatibility problems.

Fix this by using glib-mkenums annotations to manually fix all the
enum values back to what they were before. (This can't be done in a
more automated way, because the old names aren't 100% consistent. Eg,
"UNKNOWN" frequently becomes "UnknownError" rather than just
"Unknown".)
2012-03-12 15:29:52 -04:00
Dan Winship
839eab5564 Use glib-mkenums to generate enum types
Rather than generating enum classes by hand (and complaining in each
file that "this should really be standard"), use glib-mkenums.

Unfortunately, we need a very new version of glib-mkenums in order to
deal with NM's naming conventions and to fix a few other bugs, so just
import that into the source tree temporarily.

Also, to simplify the use of glib-mkenums, import Makefile.glib from
https://bugzilla.gnome.org/654395.

To avoid having to run glib-mkenums for every subdirectory of src/,
add a new "generated" directory, and put the generated enums files
there.

Finally, use Makefile.glib for marshallers too, and generate separate
ones for libnm-glib and NetworkManager.
2012-02-15 11:42:15 -05:00
Dan Williams
78dd4fc9f2 dhcp: make client selection more forgiving
If your distributor forgot to set up the client path for you, this
makes NM look in the right places and allows you to use either client
if it's installed, no matter what NM was configured with.
2010-03-23 14:22:10 -07:00
Jiří Klimeš
bfe58b26fb trivial: replace NetworkManager.c occurence after renaming to main.c 2010-03-03 09:57:28 +01:00
Dan Williams
35c4b97d7d dhcp6: first stab at autoconf otherconf/managed mode support 2010-01-27 16:20:09 -08:00
Dan Williams
fe62e59c7e dhcp: add DHCPv6 functionality 2010-01-13 16:51:20 -08:00
Dan Williams
81f23ea383 dhcp: actually use runtime-selected DHCP client 2010-01-12 23:07:44 -08:00
Dan Williams
702836b42f dhcp: allow runtime DHCP client selection via config file 2010-01-12 22:55:24 -08:00
Dan Williams
1806235049 dhcp: convert dhcp backends to classes 2010-01-12 22:09:28 -08:00
Dan Williams
d997785db3 dhcp6: genericize DHCP client tracking
Since the same interface could be used for both	DHCPv4 and DHCPv6 we
can't just use 'iface' for tracking DHCP client lease changes.  Instead
use a generated client ID, and track DHCP events based on the client's
PID instead of interface name.
2010-01-08 17:16:05 -08:00
Dan Williams
3ee1eb7a6c dhcp6: add dhclient ipv6 states 2010-01-08 15:22:11 -08:00
Dan Williams
f2eb3dea65 core: base infrastructure for connection assumption
Figure out what connections can be assumed when a device is added,
and on shutdown don't blow away connections that can be assumed on
NM restart.
2009-08-03 17:15:03 -04:00
Daniel Drake
3fe8d0eed4 core: allow devices to specify a DHCP anycast address
Relevant only for OLPC at this point; the mesh device uses it to
target DHCP requests at a pre-defined mesh portal anycast address.
2009-07-15 13:53:49 -04:00
Dan Williams
756bc70402 dhcp: (dhclient) use per-connection leasefiles and don't delete on deactivate
So that leases are actually useful...
2009-05-03 00:51:09 -04:00
Tambet Ingo
41bc6e167b Implement sending current host name to DHCP server. 2009-03-20 14:44:49 +02:00
Dan Williams
68ca77cdb5 dhcp: always clean up DHCP client watch callback when stopping DHCP
Also fix a bug where failure to start the DHCP client wouldn't be
handled.
2009-02-18 09:57:33 -05:00
Przemysław Grzegorczyk
bac45aa0d5 clean up glib includes (bgo #564376)
Only <glib.h> and <gtk/gtk.h> need to be included.
2009-01-19 00:16:40 -05:00
Dan Williams
f2e8870338 dhcp: handle classless static routes (bgo #567246)
Based on patches by Johan Bilien <jobi@via.ecp.fr>,
nick loeve <trickie@gmail.com>, and Roy Marples <roy@marples.name>
with significant changes for dhclient formatting and test cases.

Note that dhclient needs help before it can actually parse
classless static routes by adding the following to the
dhclient.conf file:

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
2009-01-18 23:19:09 -05:00
Dan Williams
525171d0d0 update license headers
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4257 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-04 22:30:08 +00:00
Dan Williams
7466136be2 2008-08-27 Dan Williams <dcbw@redhat.com>
Ensure zombie children get cleaned up.  To get notifications when children
	die abnormally, g_spawn_async() requires G_SPAWN_DO_NOT_REAP_CHILD, but
	that requires calling waitpid() yourself if you've removed the child watch
	handler before the process has actually died, which NM needs to do in a few
	places.  So ensure that everything uses G_SPAWN_DO_NOT_REAP_CHILD and also
	cleans up after the child when required.  Should fix problems trying to
	activate mobile broadband connections after a previous failure.

	* src/dhcp-manager/nm-dhcp-dhclient.c
	  src/dhcp-manager/nm-dhcp-dhcpcd.c
		- Use G_SPAWN_DO_NOT_REAP_CHILD

	* src/dhcp-manager/nm-dhcp-manager.c
		- (nm_dhcp_device_destroy): ensure child is cleaned up
		- (nm_dhcp_client_stop, nm_dhcp_manager_cancel_transaction_real): always
			block on child quitting, since the non-blocking functionality was
			never actually used

	* src/dnsmasq-manager/nm-dnsmasq-manager.c
		- (dm_watch_cb): child is already reaped here
		- (ensure_killed, nm_dnsmasq_manager_stop): block until child is dead

	* src/nm-device.c
		- (aipd_cleanup): block until child is dead

	* src/named-manager/nm-named-manager.c
		- (run_netconfig): don't use G_SPAWN_DO_NOT_REAP_CHILD if we aren't
			event bothering to watch the child

	* src/ppp-manager/nm-ppp-manager.c
		- (ppp_watch_cb): child is already reaped here
		- (ensure_killed, nm_ppp_manager_stop): block until child is dead

	* src/vpn-manager/nm-vpn-service.c
		- (vpn_service_watch_cb): child is already reaped here
		- (nm_vpn_service_daemon_exec): use G_SPAWN_DO_NOT_REAP_CHILD so that
			status of the child is actually tracked
		- (ensure_killed, finalize): block until child is dead



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4020 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-27 17:22:32 +00:00
Dan Williams
edda4463bc 2008-07-17 Dan Williams <dcbw@redhat.com>
* introspection/Makefile.am
	  introspection/nm-device.xml
	  introspection/nm-dhcp4-config.xml
		- Add bits for the DHCP4Config property of the device, and the DHCP4Config
			itself
	* src/nm-device-interface.c
	  src/nm-device-interface.h
		- Add the DHCP4Config property

	* src/nm-device.c
		- Keep track of DHCP4 options via a new DHCP4Config property and notify
			D-Bus clients when it changes

	* src/nm-dhcp4-config.c
	  src/nm-dhcp4-config.h
		- Simple object to store DHCP4 options, export them over D-Bus, and
			notify when they change

	* src/dhcp-manager/nm-dhcp-manager.c
	  src/dhcp-manager/nm-dhcp-manager.h
		- (nm_dhcp_manager_set_dhcp4_config, copy_dhcp4_config_option): copy and
			filter server-returned DHCP options into an NMDHCP4Config object



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3829 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-17 17:04:13 +00:00
Dan Williams
87e7e74e13 2008-07-16 Dan Williams <dcbw@redhat.com>
Patch from Roy Marples <roy@marples.name>

	* configure.in
		- Add --with-dhcp-client option

	* src/dhcp-manager/Makefile.am
		- pass DHCP_CLIENT_PATH on compile line

	* src/dhcp-manager/nm-dhcp-manager.c
	  src/dhcp-manager/nm-dhcp-manager.h
		- Genericize for both dhcpcd and dhclient

	* src/dhcp-manager/nm-dhcp-dhclient.c
		- Move dhclient stuff out to it's own file from nm-dhcp-manager.c

	* src/dhcp-manager/nm-dhcp-dhcpcd.c
		- Implement support for dhcpcd too



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3823 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-16 20:39:58 +00:00
Dan Williams
794c1880f2 2008-07-03 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip4-config.h
		- Add properties for DHCP Client Identifier and DHCP Hostname

	* src/dhcp-manager/nm-dhcp-manager.c
	  src/dhcp-manager/nm-dhcp-manager.h
		- (nm_dhcp_manager_begin_transaction): take the connection's ip4-config
			setting as an argument to pass on to the dhclient config file
			creation function
		- (nm_dhcp_manager_cancel_transaction_real): remove dhclient config when
			DHCP is torn down
		- (dhclient_run): punt config file handling to create_dhclient_config()
		- (create_dhclient_config): create an interface-specific dhclient
			config file since there may need to be interface-specific options
			passed to dhclient
		- (merge_dhclient_config): merge normal distro dhclient config file and
			add options from the connection
		- (nm_dhcp_device_new): generate the interface specific dhclient
			config file path once
		- (nm_dhcp_device_destroy): handle partially initialized objects; free
			dhclient config file path

	* src/nm-device.c
		- (real_act_stage3_ip_config_start): pass ip4-config, if any, to the
			DHCP manager when starting DHCP



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3805 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-03 16:22:17 +00:00
Dan Williams
b0cf66eda8 2008-06-26 Dan Williams <dcbw@redhat.com>
* Update FSF address in license headers (Michael Biebl <biebl@debian.org>)



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3775 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-06-26 18:31:52 +00:00
Dan Williams
93f08e2f11 2007-08-14 Dan Williams <dcbw@redhat.com>
* callouts/Makefile.am
	  src/dhcp-manager/nm-dhcp-manager.c
	  src/dhcp-manager/nm-dhcp-manager.h
	  src/dhcp-manager/Makefile.am
		- Change install location of nm-dhcp-client.action to ${prefix}/libexec



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2682 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-14 18:35:38 +00:00
Dan Williams
ab43fbb376 2007-08-12 Dan Williams <dcbw@redhat.com>
Kill dhcdbd until it's dead, dead, dead.  Based on a patch from
	Robert Frank <rfrank@redhat.com>

	* src/dhcp-manager/nm-dhcp-manager.c
	  src/dhcp-manager/nm-dhcp-manager.c
	  src/nm-device.c
		- Spawn and communicate with dhclient directly, through means of a
		custom dhclient callout script.  Process callout D-Bus signals
		with dbus-glib instead of hand-rolled dbus.  DHCP timeouts are now
		sent via gobject signals rather than being driven by the dhcp manager
		directly.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2666 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-12 22:41:16 +00:00
Tambet Ingo
1bbdd977e3 2007-02-05 Tambet Ingo <tambet@ximian.com>
* src/dhcp-manager/nm-dhcp-marshal-main.c: Add.

	* src/dhcp-manager/nm-dhcp-marshal.list: Add.

	* src/dhcp-manager/nm-dhcp-manager.c:
	* src/dhcp-manager/nm-dhcp-manager.h:
		- Convert it to GObject since we need to signal state changes.
		- Remove all references to other NM classes, this class is one
		  of the lowest classes in our hierarchy.
		- One less class to use NMActRequest.
		- Make it singleton, one less user of NMData.
		- Remove a couple of sleep() calls.
		- Convert a bunch of low-level dbus API calls to dbus-glib calls.
		  One less class to use the NM's custom tailored signal handlig.

	* Makefile.am: Generate marshallers, add them to build.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2283 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-02-05 09:42:19 +00:00
Dan Williams
0df1e42c39 2007-01-04 Dan Williams <dcbw@redhat.com>
Threading removal related cleanups:

	- Use the glib default main context.  Remove the device main context
		member from NMDevice, and the main_context member from NMData.  Change
		all the idle and timeout scheduler functions to use plain
		g_idle_add() and g_timeout_add().

	- As a side-effect of the first change, nm_dbus_manager_get() no longer
		takes an argument; fix that up too.

	- Remove all locking, which is useless since we no longer use threads.  For
		example, nm_get_device_by_iface_locked() has been removed.  The global
		device list lock, the AP List lock, and all static locks in
		NetworkManagerPolicy.c have been removed.  The locking utility functions
		in NetworkManagerUtils.c have also been removed.

	- Other cleanups in spacing and code style



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2205 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-01-04 12:06:26 +00:00
Dan Williams
84678fc9fe 2006-10-13 Dan Williams <dcbw@redhat.com>
* Huge DBus refactor:
		- Create a "DBus Manager" object which manages the connection and
		sends signals on NameOwnerChanged and connection/disconnection events,
		handles reconnection to the bus if NM gets kicked off, and abstracts
		signal handling
		- Remove DBusConnection members from places where they are no
		longer needed due to the refactor, like the dbus-connection
		property of the named manager, and from NMData
		- Reformats a bunch of the code to gnome style
		(8-space tabs, braces on same line as statement, 80-col width).
		Consider it open season to reformat any bits to gnome style.
		style that aren't already.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2061 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-10-13 19:41:47 +00:00
Robert Love
1b3aea6b02 2006-03-06 Robert Love <rml@novell.com>
* src/dhcp-manager/nm-dhcp-manager.c: Use preprocessor defines and not
	  open-coded integer constants.  Add state_to_string() to map a given
	  state to a textual description, and provide that when notifying of
	  state change.
	* src/dhcp-manager/nm-dhcp-manager.h: Provide defines for the dhcdbd
	  states, copied and cleaned up from dhcdbd.d.  Ideally, we would use
	  this header directly, but it is currently not installed on most
	  systems.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1559 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 20:21:19 +00:00
Dan Williams
aff2d6bdcf 2006-1-1 Dan Williams <dcbw@redhat.com>
* src/nm-activation-request.c
		- Change dhcp_state member of the NMActRequest structure
			from guint8 to guint32

	* src/dhcp-manager/nm-dhcp-manager.[ch]
		- (nm_dhcp_manager_get_state_for_device): return guint32 rather
			than guint8 to match the dbus argument.  Turns out we were
			overwriting memory since we were passing in only a guint8


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1245 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-01 22:22:39 +00:00
Dan Williams
4ed4b491fa 2005-12-31 Dan Williams <dcbw@redhat.com>
* refactor NMDevice into a GObject-based framework with separate
		objects for wired and wireless.  The following files are no
		longer used but should stick around for a bit so we don't
		loose code through the cracks:
			NetworkManagerDevice.c
			NetworkManagerDevice.h
			NetworkManagerWireless.c
			NetworkManagerWireless.h

	The intent here is to allow each device type to manage its own
	connection & activation life-cycle, ie to allow wireless devices
	to interface with wpa_supplicant, etc.  There's a fair bit of
	encapsulation breakage right now that should gradually get pulled
	back into each device, along with things like periodic property
	updates and link probing.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1244 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-12-31 08:21:24 +00:00
Dan Williams
567b5e3d31 2005-05-03 Dan Williams <dcbw@redhat.com>
* Kill dhcpcd.  We now use "dhcdbd", a dbus daemon that controls dhclient.
	  This means that NetworkManager shouldn't have DHCP issues anymore.  It also
	  means you need dhcdbd, which you can get here (get the latest one):

		http://people.redhat.com/jvdias/dhcdbd/

	  Technically NetworkManager can use any DHCP daemon that uses the same DBUS
	  interface as dhcdbd.

	* Rewrite device activation to facilitate the new DHCP infrastructure and
	  future improvements.  Its now "activation request" based, ie there is a single
	  activation request composed of the device, access point, and other info which
	  follows the entire activation process.  There are 5 stages of the activation
	  process which correspond to:

		1) Device preparation
		2) Device configuration (bring it up, set ESSID/Key/etc)
		3) IP Config Start (fire off DHCP if we're using it)
		4) IP Config Get (grab config from DHCP or static config files)
		5) IP Config Commit (set device's IP address, DNS, etc)

	  Note that there is no longer a "scanning" step, since the access point must
	  be known _before_ activation starts.  If the access point drops out or does
	  not exist for some reason, the entire activation process fails and must be
	  restarted for a different access point or device.

	Patch from Bill Moss:
	* gnome/applet/applet.c
		- Fix type of vpn_failure dialog -> vpn_banner dialog


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@597 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-05-03 20:41:36 +00:00