Commit Graph

42 Commits

Author SHA1 Message Date
Thomas Haller
3eb1d5e902 core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.

The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Jiří Klimeš
816ac9ee70 libnm-util: prefix errors with 'setting.property' instead of 'property' only 2013-06-13 10:05:18 +02:00
Dan Winship
43617d4c1d libnm-util: deprecate nm_utils_slist_free(), use g_slist_free_full() 2013-05-29 17:13:30 -03:00
Dan Williams
f6064e7b74 libnm-util: implement connection changed signal
Emitted whenever settings are added or removed from the connection,
and whenever any property of any setting in the connection is changed.
2013-05-28 12:26:55 -05:00
Jiří Klimeš
ced61dfc7f libnm-util: add access functions for 'mac-address-blacklist' to wired/wireless
nm_setting_wire(d/less)_get_num_mac_blacklist_items()
nm_setting_wire(d/less)_get_mac_blacklist_item()
nm_setting_wire(d/less)_add_mac_blacklist_item()
nm_setting_wire(d/less)_remove_mac_blacklist_item()
2013-05-07 19:38:31 +02:00
Martin Pitt
57a9fb3c89 Use %NULL macro in doc strings
Mass-converted "NULL" to "%NULL" in docstrings with

  find -name '*.c'| xargs sed -i '/^ \*.*[^%]NULL/ s/NULL\b/%NULL/g'
2013-04-19 10:08:17 -04:00
Dan Winship
5fec30d98e Revert :carrier-detect properties and associated code
Ignoring carrier is generally something you want at the machine level
(eg, for a server), not at the connection level.
2013-04-03 10:23:49 -04:00
Jiří Klimeš
d7d2015dfd libnm-util: add nm_setting_wired_get_valid_s390_options() 2013-03-19 08:59:50 +01:00
Jiří Klimeš
cc1de4676e libnm-util: fix documentation of add(remove)_s390_option() 2013-03-18 18:11:29 +01:00
Jiří Klimeš
df142a5dc4 libnm-util: make property verification errors more descriptive
- fix g_set_error()/g_set_error_literal() usage
- make the error messages translatable
- use g_prefix_error() to prepend property name
2013-03-13 17:47:11 +01:00
Dan Williams
0f5b91ad2e libnm-util: fix leak of s390 subchannels
==23089== 7,293 (1,248 direct, 6,045 indirect) bytes in 39 blocks are definitely lost in loss record 5,100 of 5,123
==23089==    at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==23089==    by 0x39B905488E: g_malloc (gmem.c:159)
==23089==    by 0x39B9068CA1: g_slice_alloc (gslice.c:1003)
==23089==    by 0x39B9024E90: g_ptr_array_sized_new (garray.c:884)
==23089==    by 0x31FB81B3FC: ptrarray_copy (dbus-gvalue-utils.c:1047)
==23089==    by 0x31FB81845C: proxy_value_copy (dbus-gtype-specialized.c:446)
==23089==    by 0x39B980F51E: g_boxed_copy (gboxed.c:359)
==23089==    by 0x31FC03134C: set_property (nm-setting-wired.c:619)
==23089==    by 0x39B9819972: g_object_set_property (gobject.c:1352)
==23089==    by 0x31FC01A9A7: nm_setting_enumerate_values (nm-setting.c:589)
==23089==    by 0x31FC01AA81: nm_setting_duplicate (nm-setting.c:264)
==23089==    by 0x31FC01633B: duplicate_cb (nm-connection.c:1182)
2013-03-08 09:27:51 -06:00
Dan Williams
47d8db57b5 trivial: plug some memory leaks
(review+ danw)
2013-02-25 16:07:03 +01:00
Jiří Klimeš
2fef987980 libnm-util: add the detailed description of carrier-detect to blurb as well
So that we have the description in generated html documentation and nm-settings
manual page.
2013-02-18 15:57:12 +01:00
Dan Winship
5266e25e2b libnm-utils: add :carrier-detect properties
For settings corresponding to devices that have a :carrier property
(ie bond, bridge, infiniband, vlan, and wired), add a :carrier-detect
property specifying how that affects the connection:

  yes: The connection can only be activated when the device
      has carrier, and will be deactivated if the device loses
      carrier (for more than 4 seconds).
  no: The connection ignores carrier on the device; it can be
      activated when there is no carrier, and stays activated
      when carrier is lost.
  on-activate: The connection can only be activated when the
      device has carrier, but it will not be deactivated if the
      device loses carrier.

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:38 -05:00
Dan Williams
38e3819b4e libnm-util: clean up setting registration
Make setting type registration less icky; instead of having the
connection register all the settings, have the settings themselves
register that information at library load time.  Putting this sort
of thing in G_DEFINE_TYPE_WITH_CODE is apparently more standard
than the home-rolled stuff we had before.  Also document the
priority stuff so when adding new settings, people know what
priority to use.

(cleanups by jklimes)
2012-10-29 15:12:58 -05: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
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
ea3f60add4 libnm-util: fix up some GObject introspection annotations 2011-07-05 17:34:48 -05:00
Dan Williams
853b6f117f docs: update Wired setting documentation 2011-07-05 16:54:07 -05:00
Jiří Klimeš
a6733c8b4f core: add MAC address blacklisting feature for WiFi and ethernet connections
"mac-address-blacklist" property is added to the ethernet and WiFi connections.
It is the MAC addresses list of devices on which the connection won't be
activated.

Original patch (NM_0_8 branch) from Thomas Bechtold <thomasbechtold@jpberlin.de>
2011-06-30 16:46:26 +02:00
Karsten Hopp
38d3f0b181 libnm-util: fix s390 CTC nettype and whitelist ctcprot option (bgo #647578) (rh #641986) 2011-04-12 15:38:08 -05:00
Jiří Klimeš
707e2c84a3 doc: trivial fix in documentation of 's390-subchannels' property 2010-08-06 11:36:11 +02:00
Dan Williams
16bccfd672 core: handle s390 options more cleanly
There are so many... so handle them as a table of key/value pairs
instead of having separate functions for each one.  At the moment
nothing but subchannels is used internally, but this allows plugins
to preserve options that NM doesn't care about when reading/writing
system configuration.
2010-06-29 00:37:14 -07:00
Dan Williams
fd10f97d98 libnm-util: fix default s390 property values 2010-06-25 20:08:09 -07:00
Dan Williams
ac9d2804bd Merge remote branch 'origin/master' into zvm 2010-06-25 19:57:30 -07:00
Dan Williams
66319f616c libnm-util: add more necessary s390 properties 2010-06-24 11:59:40 -07:00
Jiří Klimeš
1b49f941a6 core: MAC address spoofing/cloning (rh #447827) (bgo #553771)
This commit implements MAC cloning feature in NetworkManager. To support that,
'PermHwAddress' property is added into *.Device.Wired and *.Device.Wireless
interfaces. The permanent MAC address is obtained when creating the device, and
is used for 'locking' connections to the device. If a cloned MAC is specified
in connection to be activated, the MAC is set to the interface in stage1. While
disconecting, the permanent MAC is set back to the interface.
2010-06-22 14:21:25 +02:00
Dan Williams
0b41797b49 s390: replace 'zvm' with s390
ZVM isn't the right terminology here.  s390 is.
2010-06-17 21:24:14 -07:00
Dan Williams
9c45b52f38 libnm-util: add wired setting property for z/VM subchannel (rh #591533)
On s390 and z-Series, the hypervisor assigns the MAC address, so we
need to use subchannels to uniquely identify the device instead of
using the MAC address.
2010-05-26 15:31:01 -07:00
Dan Williams
0539c2b6d2 doc: document wired setting properties 2009-11-11 14:07:42 -08:00
Dan Williams
b61b199776 libnm-util: flag properties with G_PARAM_CONSTRUCT so default values get set
This caused the 'autoconnect' property of NMSettingConnection to not
get updated in some cases (as when a system setting plugin noticed a
change to autoconnect=true and emitted the Updated signal, which wouldn't
contain the new value).  Add a testcase for setting default values too.
2009-02-01 20:18:21 -05: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
c438326110 2008-10-27 Dan Williams <dcbw@redhat.com>
Patch from Tambet Ingo <tambet@gmail.com>

	* libnm-util/nm-setting.h
	  libnm-util/nm-setting.c
		- Make properties private and add accessor functions

	* libnm-util/nm-connection.c
	  libnm-util/nm-setting-8021x.c
	  libnm-util/nm-setting-cdma.c
	  libnm-util/nm-setting-connection.c
	  libnm-util/nm-setting-gsm.c
	  libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip6-config.c
	  libnm-util/nm-setting-ppp.c
	  libnm-util/nm-setting-pppoe.c
	  libnm-util/nm-setting-serial.c
	  libnm-util/nm-setting-template.c
	  libnm-util/nm-setting-vpn.c
	  libnm-util/nm-setting-wired.c
	  libnm-util/nm-setting-wireless-security.c
	  libnm-util/nm-setting-wireless.c
	  system-settings/plugins/keyfile/reader.c
	  system-settings/plugins/keyfile/writer.c
		- Use setting accessors



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4228 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-10-27 17:36:18 +00:00
Dan Williams
fff2e85bd6 2008-10-26 Dan Williams <dcbw@redhat.com>
Patch from Tambet Ingo <tambet@gmail.com>

	* libnm-util/libnm-util.ver
	  libnm-util/nm-setting-wired.c
	  libnm-util/nm-setting-wired.h
		- Make properties private and add accessor functions

	* src/nm-device-ethernet.c
	  system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
	  system-settings/plugins/ifcfg-suse/parser.c
	  system-settings/src/main.c
		- Use those accessors



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4215 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-10-26 17:02:05 +00:00
Michael Biebl
d7940bcb9b Rename private nm_* functions to _nm_*
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4012 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-26 09:34:31 +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
05e9de9402 2008-06-12 Dan Williams <dcbw@redhat.com>
Add a GError argument to nm_connection_verify() and nm_setting_verify(),
	and add error enums to each NMSetting subclass.  Each NMSetting subclass now
	returns a descriptive GError when verification fails.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3751 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-06-12 23:58:08 +00:00
Tambet Ingo
252ab39a71 2008-04-10 Tambet Ingo <tambet@gmail.com>
* libnm-util/nm-setting-wired.c (get_property): Fix a typo.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3552 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-10 14:56:12 +00:00
Dan Williams
b285600adc Use ETH_ALEN
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3524 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-02 17:34:22 +00:00
Dan Williams
316abd62fd 2008-02-20 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-connection.c
	  libnm-util/nm-connection.h
		- (nm_connection_compare): accept compare flags and pass them to the
			setting compare function

	* libnm-util/nm-setting.c
	  libnm-util/nm-setting.h
		- (nm_setting_compare): accept compare flags; ignore properties that are
			marked fuzzy

	* libnm-util/nm-setting-connection.c
	  libnm-util/nm-setting-wireless.c
	  libnm-util/nm-setting-ppp.c
	  libnm-util/nm-setting-wired.c
		- Mark some setting properties as ignorable when doing a fuzzy compare

	* src/nm-device.c
		- (device_activation_precheck): use exact compare



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3336 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-02-21 04:34:34 +00:00
Dan Williams
7932f43718 Set default values on construct
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3185 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-12-23 06:39:16 +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