Commit Graph

55 Commits

Author SHA1 Message Date
Thomas Haller
6399170ff3 libnm: add function nm_utils_file_search_in_paths()
We now also use a similar function in VPN plugins. It makes
sense to provide a generic implementation in libnm.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 11:07:42 +01:00
Thomas Haller
ac4fafe7a4 platform: assert against the maximum length of link_get_address()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-23 12:42:45 -05:00
Dan Winship
cb7e1893e7 libnm-util, libnm-glib: standardize copyright/license headers
- Remove list of authors from files that had them; these serve no
  purpose except to quickly get out of date (and were only used in
  libnm-util and not libnm-glib anyway).

- Just say "Copyright", not "(C) Copyright" or "Copyright (C)"

- Put copyright statement after the license, not before

- Remove "NetworkManager - Network link manager" from the few files
  that contained it, and "libnm_glib -- Access network status &
  information from glib applications" from the many files that
  contained it.

- Remove vim modeline from nm-device-olpc-mesh.[ch], add emacs modeline
  to files that were missing it.
2014-07-15 09:44:54 -04:00
Jiří Klimeš
810e934892 libnm-util: add nm_utils_rsa_key_encrypt_aes() encrypting RSA key with AES 2014-05-12 10:46:41 +02:00
Dan Winship
4a5e2ced08 libnm-util: add nm_utils_check_virtual_device_compatibility()
Add a function encoding the logic of what virtual types support what
slave/parent types, so clients don't need to encode it themselves.
2014-03-06 09:37:20 -05:00
Dan Winship
9c4d86ee80 libnm-util, libnm-glib: add versioned deprecation/availability macros
Add versioned NM_DEPRECATED_IN_* and NM_AVAILABLE_IN_* macros, and tag
new/deprecated functions accordingly. (All currently-deprecated
functions are assumed to have been deprecated in 0.9.10.)

Add NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED macros which
can be set to determine which versions will cause warnings.

With the current settings, external consumers of the
libnm-util/libnm-glib APIs will have MIN_REQUIRED and MAX_ALLOWED both
set to NM_VERSION_0_9_8 by default, meaning they will get warnings
about functions added in 0.9.10. NM internally sets
NM_VERSION_MAX_ALLOWED to NM_VERSION_NEXT_STABLE to ensure that it is
always allowed to use all APIs.
2014-02-13 11:24:37 -05:00
Thomas Haller
41f8114359 libnm-util: add nm_utils_inet[46]_ntop functions
https://bugzilla.gnome.org/show_bug.cgi?id=711684

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 17:21:21 +01:00
Dan Winship
9a73db17d5 libnm-util: add nm_utils_hwaddr_valid() 2013-06-13 15:52:51 -03:00
Dan Winship
82ac7da754 libnm-util: add hwaddr functions that take length rather than type
Add nm_utils_hwaddr_ntoa_len() and nm_utils_hwaddr_aton_len(), which
take a length rather than a type, which is generally more convenient,
and also necessary if you might be encountering devices of unknown
types.
2013-06-11 09:27:45 -03:00
Jiří Klimeš
2109f41cc6 libnm-util: consolidate hex-string <-> bin conversion functions
and move them to libnm-util's nm-utils.s so that they are easily available.
2013-03-28 16:59:58 +01:00
Jiří Klimeš
bf610255a1 libnm-util: move verify_wep_key() and verify_wpa_psk() to nm-utils.c
and rename them to nm_utils_wep_key_valid(), nm_utils_wpa_psk_valid().
They are general functions and can also be used elsewere usefully.
2013-02-06 13:29:58 +01:00
Dan Williams
e6bdb8bc55 libnm-util: add methods for AP-mode security filtering
Add a helper like nm_utils_security_valid() except for access point
mode.  We can't use nm_utils_security_valid() without changing the
arguments, hence the new function.  Plus in AP mode all you care about
are the device capabilities, not AP flags since the device *is*
the AP.
2012-10-17 14:07:37 -05:00
Dan Winship
74b6b9c768 libnm-util: move nm_utils_is_uuid() here
This is useful outside the daemon too, so move it into libnm-utils.
2012-09-26 12:14:37 -04:00
Thomas Graf
b46508b5c6 libnm-util: move dev_valid_name() to libnm-util and make it public
The bridging code needs it as well.
2012-08-29 17:46:54 -05:00
Jiří Klimeš
00297f49fb libnm-util: add nm_utils_file_is_pkcs12() for checking PKCS#12 file format 2012-07-16 14:59:59 +02: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
1f8090fb58 libnm-util: add nm_utils_hwaddr_type()
Returns the address type given the length.
2011-12-02 13:09:16 -06:00
Dan Winship
2510c617ec libnm-util: add ether_ntoa/ether_aton-like utility methods
nm_utils_hwaddr_ntoa() and nm_utils_hwaddr_aton() are like
ether_ntoa()/ether_aton(), but handle IPoIB too.

nm_utils_hwaddr_atoba() is like _aton() but returns a GByteArray,
since that's what's wanted in many places.

Also remove nm_ether_ntop() and replace uses of it with
nm_utils_hwaddr_ntoa().
2011-11-17 13:37:08 -06:00
Dan Williams
2a5617c22b docs: update documentation for nm_utils_security_valid() 2011-08-22 20:33:07 -05:00
Jiří Klimeš
a70d87d84e trivial: put all prototypes inside G_BEGIN_DECLS and G_END_DECLS 2011-05-31 14:06:13 +02:00
Dan Williams
4ae83f2d93 libnm-util: remove unused #include 2011-05-09 13:34:21 -05:00
Dan Williams
eab5851145 libnm-util: remove nm_warning/nm_info/nm_error macros
Clients need to do their own logging using glib or whatever; these
macros while somewhat helpful were not flexible and are not a
substitute for actual logging in the client.  g_warning, g_message,
and g_error are more suitable anyway.
2011-02-23 11:42:04 -06:00
Dan Williams
7ef0f0fc64 trivial: fix up spacing in nm-utils.h 2011-02-23 11:31:25 -06:00
Dan Williams
b599e3e5dc libnm-util: simplify nm_utils_ssid_to_utf8()
It's always used with a GByteArray anyway, as are most
functions in nm-utils.h.  Even better, we can skip the
memcpy since it turns out to be pointless.
2011-02-23 11:24:58 -06:00
Jiří Klimeš
12d26643e9 libnm-util: add nm_utils_wifi_* functions to handle frequencies/channels 2010-05-31 15:32:13 +02:00
Jiří Klimeš
5110fa7811 libnm-{util|glib}: fix headers to be C++ compatible - C_BEGIN_DECLS/C_END_DECLS (rh #592783) 2010-05-18 10:14:59 +02:00
Jirka Klimes
0f0daf7852 core: determine classful IPv4 prefix if no DHCP netmask is provided (bgo #603098) 2010-02-25 16:52:10 -08:00
Dan Williams
8c35e96b60 libnm-util: add nm_utils_rsa_key_encrypt() and fix crypto padding mixups
To be backwards compatible clients need to handle both paths to private
keys and the decrypted private key data, which is what used to get passed
in the private-key and phase2-private-key attributes of the 802.1x setting.
When moving a connection around between system-settings and user-settings,
if the private key is decrypted data, the settings service needs to store
that decrypted data somewhere so that the key can be sent to NM during
the connection process.

But we don't want to store the decrypted private key data, so we have to
re-encrypt it (possibly generating a private key password if one wasn't
sent with the decrypted data) and save it to disk, then send NM a path
to that private key during connection.

To help clients do this, and so that they don't have to carry around
multiple crypto implementations depending on whether they want to use
NSS or gnutls/gcrypt, add a helper to libnm-util.

Furthermore, I misunderstood a bunch of stuff with crypto padding when
writing the encrypt/decrypt functions long ago, so fix that up.  Don't
return padding as part of the decrypted data, and make sure to verify
the padding's expected lengths and values when decrypting.  Many thanks
to Nalin Dahyabhai for pointing me in the right direction.
2009-09-15 16:01:50 -07:00
Dan Winship
90bd1ad5cd Install and fix up libnm-util IPv6 config stuff 2009-07-29 21:34:19 -04:00
Dan Williams
ad4d2baec9 Documentation updates
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4333 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-24 16:55:37 +00:00
Dan Williams
2328650d2e Documentation fixes
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4328 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-23 22:55:03 +00:00
Dan Williams
1f5394567d 2008-11-20 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- More documentation updates



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4321 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 21:07:03 +00:00
Dan Williams
3bc8b0ca57 2008-11-20 Dan Williams <dcbw@redhat.com>
* libnm-util/Makefile.am
	  libnm-util/nm-utils-private.h
		- New header for internal utils private functions

	* libnm-util/libnm-util.ver
	  libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- Document some functions
		- (nm_utils_string_in_list, nm_utils_string_list_contains,
		   nm_utils_string_slist_validate): un-export, only used within
			libnm-util or of limited use in general, and very easy to
			re-implement by apps if needed

	* libnm-util/nm-setting-8021x.c
	  libnm-util/nm-setting-wired.c
	  libnm-util/nm-setting-wireless-security.c
	  libnm-util/nm-setting-wireless.c
		- Update for private nm_utils_string_* functions



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4319 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-20 20:17:01 +00:00
Dan Williams
567396ad6d 2008-10-30 Dan Williams <dcbw@redhat.com>
* libnm-util/libnm-util.ver
	  libnm-util/nm-setting-ip6-config.c
	  libnm-util/nm-setting-ip6-config.h
	  libnm-util/Makefile.am
		- Make properties private and add accessor functions
		- Hide IPv6 stuff from public API, it's incomplete and completely unused

	* libnm-util/nm-connection.c
	  libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- Ignore IPv6 stuff for now



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4240 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-10-30 19:39:51 +00:00
Dan Williams
796829ce62 2008-09-08 Dan Williams <dcbw@redhat.com>
Patch from Alexander Sack <asac@ubuntu.com>

	* libnm-util/crypto_gnutls.c
	  libnm-util/crypto_nss.c
		- (crypto_init, crypto_deinit): just use a boolean instead of a refcount

	* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
	  libnm-util/libnm-util.ver
		- (nm_utils_init): initialize libnm-util
		- (nm_utils_deinit): de-initialize libnm-util and clean up resources

	* libnm-util/nm-setting-8021x.c
		- (nm_setting_802_1x_class_init): init libnm-util when needed



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4047 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-08 18:35:21 +00:00
Dan Williams
81f8f39920 2008-08-26 Dan Williams <dcbw@redhat.com>
Add connection UUIDs, since connection names can be changed, and since
	old-style connection IDs could change over the life of the connection.  The
	UUID should be assigned at connection creation time, be stable for a given
	connection, and should be unique among all connections for a given settings
	service.

	* configure.in
	  libnm-util/Makefile.am
		- Require libuuid

	* introspection/nm-exported-connection.xml
		- Remove "GetID" method

	* libnm-glib/nm-dbus-connection.c
	  libnm-glib/nm-settings.c
	  libnm-glib/nm-settings.h
		- Remove id-related stuff

	* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
	  libnm-util/libnm-util.ver
		- (nm_utils_uuid_generate, nm_utils_uuid_generate_from_string): Add
			utility functions to generate UUIDs

	* libnm-util/nm-setting-connection.c
	  libnm-util/nm-setting-connection.h
		- Add 'uuid' member to the connection setting
		- (verify): require valid 'uuid' for a valid connection

	* system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
	  system-settings/plugins/ifcfg-fedora/reader.c
	  system-settings/plugins/ifcfg-suse/nm-suse-connection.c
	  system-settings/plugins/ifcfg-suse/parser.c
	  system-settings/plugins/keyfile/nm-keyfile-connection.c
	  system-settings/src/main.c
		- Remove id-related stuff
		- Give connections UUIDs where needed



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4013 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-27 02:57:21 +00:00
Dan Williams
0b4d557319 2008-08-18 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- (nm_utils_garray_to_string): remove; NM was the only user and doesn't
			export anything that needs to be converted with this function

	* src/dhcp-manager/nm-dhcp-manager.c
		- (garray_to_string): convert a byte array to a UTF-8 string with
			minimal validation; the DHCP client sends it in ASCII anyway
		- (get_option, copy_option): use garray_to_string()



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3985 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-18 21:24:31 +00:00
Dan Williams
2c31b5499b 2008-08-06 Dan Williams <dcbw@redhat.com>
* libnm-glib/nm-ip4-config.c
	  libnm-glib/nm-ip4-config.h
		- Add 'routes' property

	* libnm-util/nm-setting-vpn.c
	  libnm-util/nm-setting-vpn.h
		- Remove 'routes' property

	* libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip4-config.h
		- 'ignore-dhcp-dns' renamed to 'ignore-auto-dns'
		- Add 'ignore-auto-routes' property
		- 'routes' exposed over D-Bus is now an array of array of uint (4) to 
			accomodate route metrics
		- 'routes' exposed in C is now a list of NMSettingIP4Route structures

	* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- Add helpers for marshalling IP4 routes

	* src/NetworkManagerUtils.c
		- (nm_utils_merge_ip4_config): handle property renames and new route
			structure

	* src/NetworkManagerSystem.c
		- (nm_system_device_set_ip4_route, nm_system_device_set_from_ip4_config,
		   nm_system_vpn_device_set_from_ip4_config): respect route metrics

	* src/dhcp-manager/nm-dhcp-manager.c
		- (nm_dhcp_manager_get_ip4_config): handle new route structure

	* system-settings/plugins/ifcfg-fedora/reader.c
	  system-settings/plugins/ifcfg-fedora/writer.c
		- Handle routes separately from addresses now that routes have a different
			format

	* introspection/nm-ip4-config.xml
	  src/nm-ip4-config.c
	  src/nm-ip4-config.h
		- Rename internal routing functions
		- 'static-routes' renamed to 'routes'



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3898 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-06 22:23:48 +00:00
Dan Williams
281791ac77 2008-07-27 Dan Williams <dcbw@redhat.com>
* libnm-util/*
		- Relicense to LGPLv2+



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3859 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-27 20:03:46 +00:00
Dan Williams
06efa3f7b1 2008-07-17 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c
		- (string_to_utf8): general function for conversion to UTF-8 assisted
			by locale
		- (nm_utils_ssid_to_utf8): use string_to_utf8()
		- (nm_utils_garray_to_string): ensure returned string is UTF-8 safe



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3830 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-17 17:15:38 +00:00
Dan Williams
e1e4100f76 2008-07-07 Dan Williams <dcbw@redhat.com>
Convert to using IPv4 prefixes instead of netmasks.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3812 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-07-07 18:57:37 +00:00
Dan Williams
5a516abc4b 2008-06-26 Dan Williams <dcbw@redhat.com>
Patch from David Cantrell <dcantrell@redhat.com> and me

	* include/nm-dbus-glib-types.h
		- Add IP6 address types

	* libnm-util/Makefile.am
	  libnm-util/nm-setting-ip6-config.c
	  libnm-util/nm-setting-ip6-config.h
		- Add IP6 settings object

	* libnm-util/nm-connection.c
		- (register_default_settings): register ip6 settings object

	* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- (nm_utils_ip6_addresses_from_gvalue, nm_utils_ip6_addresses_to_gvalue,
		   nm_utils_ip6_dns_from_gvalue, nm_utils_ip6_dns_to_gvalue): add
			ip6 address conversion functions



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3778 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-06-26 21:30:33 +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
4f421ef874 Fix syntax errors with enums in pedantic mode (Will Stephenson)
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3664 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-13 16:57:01 +00:00
Dan Williams
3cbc245395 2008-05-06 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- (nm_utils_ip4_addresses_from_gvalue,
		   nm_utils_ip4_addresses_to_gvalue): new functions



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3636 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:41:08 +00:00
Dan Williams
529a246913 2008-03-04 Dan Williams <dcbw@redhat.com>
Patch from Michael Biebl <biebl@debian.org>

	* NetworkManager.pc.in
		- doesn't actually depend on dbus-1

	* libnm-util/nm-utils.h
		- remove unused #include <dbus/dbus.h>

	* libnm-glib/libnm_glib.pc.in
		- depends on glib and dbus-glib



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3374 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-04 21:59:24 +00:00
Dan Williams
43395ebab6 Remove old prototype
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3240 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-01-18 02:53:09 +00:00
Dan Williams
773c82f9d1 2007-12-27 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- (nm_utils_security_valid): add 'adhoc' argument and handle security
			for adhoc networks



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3195 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-12-27 07:17:50 +00:00
Tambet Ingo
6b79d40a76 2007-11-07 Tambet Ingo <tambet@gmail.com>
Rework NMSetting structures: Move each setting to it's own file.
        Convert to GObject. Remove home grown setting types and use
GTypes.
        Use GObject property introspection for hash conversion,
enumerating
        properties, etc.

        * libnm-util/nm-setting-connection.[ch]
        * libnm-util/nm-setting-ip4-config.[ch]
        * libnm-util/nm-setting-ppp.[ch]
        * libnm-util/nm-setting-vpn.[ch]
        * libnm-util/nm-setting-vpn-properties.[ch]
        * libnm-util/nm-setting-wired.[ch]
        * libnm-util/nm-setting-wireless.[ch]
        * libnm-util/nm-setting-wireless-security.[ch]

        New files, each containing a setting.

        * libnm-util/nm-setting-template.[ch]: A template for creating
        * new
        settings. To use it, just replace 'template' with the new
setting
        name, and you're half-way done.

        * libnm-util/nm-setting.c: Convert to GObject and use GObject
        introspection instead of internal types and tables.

        * libnm-util/nm-connection.c: Adapt the new NMSetting work.

        * libnm-util/nm-param-spec-specialized.[ch]: Implement. Handles
        GValue types defined by dbus-glib for composed types like
collections,
        structures and maps.

        * src/*: The API of NMSetting and NMConnection changed a bit:
        * Getting
        a setting from connection takes the setting type now. Also,
since
        the settings are in multiple files, include relevant settings.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3068 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-11-07 16:06:43 +00:00
Dan Williams
f1409ba595 2007-10-23 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- (nm_utils_ap_security_compatible): common function for checking
			whether a specific AP is compatible with an NMConnection



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3001 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-10-23 10:54:37 +00:00