diff options
Diffstat (limited to 'libnm-util')
54 files changed, 4053 insertions, 621 deletions
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am index 1327565a..4d3afc82 100644 --- a/libnm-util/Makefile.am +++ b/libnm-util/Makefile.am @@ -1,6 +1,8 @@ +include $(GLIB_MAKEFILE) + SUBDIRS=. tests -INCLUDES = -I${top_srcdir} -I${top_srcdir}/include +INCLUDES = -I${top_srcdir} -I${top_srcdir}/include -I${top_builddir}/include lib_LTLIBRARIES=libnm-util.la @@ -15,8 +17,11 @@ libnm_util_include_HEADERS = \ nm-setting.h \ nm-setting-8021x.h \ nm-setting-bluetooth.h \ + nm-setting-bond.h \ nm-setting-connection.h \ + nm-setting-infiniband.h \ nm-setting-ip4-config.h \ + nm-setting-vlan.h \ nm-setting-ip6-config.h \ nm-setting-ppp.h \ nm-setting-pppoe.h \ @@ -29,6 +34,7 @@ libnm_util_include_HEADERS = \ nm-setting-wireless.h \ nm-setting-wireless-security.h \ nm-setting-vpn.h \ + nm-utils-enum-types.h \ nm-utils.h libnm_util_la_private_headers = \ @@ -44,8 +50,11 @@ libnm_util_la_csources = \ nm-setting.c \ nm-setting-8021x.c \ nm-setting-bluetooth.c \ + nm-setting-bond.c \ nm-setting-connection.c \ + nm-setting-infiniband.c \ nm-setting-ip4-config.c \ + nm-setting-vlan.c \ nm-setting-ip6-config.c \ nm-setting-ppp.c \ nm-setting-pppoe.c \ @@ -58,18 +67,25 @@ libnm_util_la_csources = \ nm-setting-wireless.c \ nm-setting-wireless-security.c \ nm-setting-vpn.c \ + nm-utils-enum-types.c \ nm-utils.c libnm_util_la_SOURCES = \ $(libnm_util_la_csources) \ $(libnm_util_la_private_headers) +GLIB_GENERATED = nm-utils-enum-types.h nm-utils-enum-types.c +BUILT_SOURCES = $(GLIB_GENERATED) +nm_utils_enum_types_sources = $(libnm_util_include_HEADERS) +GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM +GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM + libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS) SYMBOL_VIS_FILE=$(srcdir)/libnm-util.ver libnm_util_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \ - -version-info "4:0:2" + -version-info "5:0:3" if WITH_GNUTLS libnm_util_la_SOURCES += crypto_gnutls.c diff --git a/libnm-util/Makefile.in b/libnm-util/Makefile.in index 69af0cfb..e17da224 100644 --- a/libnm-util/Makefile.in +++ b/libnm-util/Makefile.in @@ -105,20 +105,25 @@ libnm_util_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3) am__libnm_util_la_SOURCES_DIST = crypto.c nm-connection.c \ nm-param-spec-specialized.c nm-setting.c nm-setting-8021x.c \ - nm-setting-bluetooth.c nm-setting-connection.c \ - nm-setting-ip4-config.c nm-setting-ip6-config.c \ - nm-setting-ppp.c nm-setting-pppoe.c nm-setting-serial.c \ - nm-setting-gsm.c nm-setting-cdma.c nm-setting-olpc-mesh.c \ - nm-setting-wimax.c nm-setting-wired.c nm-setting-wireless.c \ - nm-setting-wireless-security.c nm-setting-vpn.c nm-utils.c \ - crypto.h nm-param-spec-specialized.h nm-utils-private.h \ + nm-setting-bluetooth.c nm-setting-bond.c \ + nm-setting-connection.c nm-setting-infiniband.c \ + nm-setting-ip4-config.c nm-setting-vlan.c \ + nm-setting-ip6-config.c nm-setting-ppp.c nm-setting-pppoe.c \ + nm-setting-serial.c nm-setting-gsm.c nm-setting-cdma.c \ + nm-setting-olpc-mesh.c nm-setting-wimax.c nm-setting-wired.c \ + nm-setting-wireless.c nm-setting-wireless-security.c \ + nm-setting-vpn.c nm-utils-enum-types.c nm-utils.c crypto.h \ + nm-param-spec-specialized.h nm-utils-private.h \ nm-setting-private.h crypto_gnutls.c crypto_nss.c am__objects_1 = libnm_util_la-crypto.lo libnm_util_la-nm-connection.lo \ libnm_util_la-nm-param-spec-specialized.lo \ libnm_util_la-nm-setting.lo libnm_util_la-nm-setting-8021x.lo \ libnm_util_la-nm-setting-bluetooth.lo \ + libnm_util_la-nm-setting-bond.lo \ libnm_util_la-nm-setting-connection.lo \ + libnm_util_la-nm-setting-infiniband.lo \ libnm_util_la-nm-setting-ip4-config.lo \ + libnm_util_la-nm-setting-vlan.lo \ libnm_util_la-nm-setting-ip6-config.lo \ libnm_util_la-nm-setting-ppp.lo \ libnm_util_la-nm-setting-pppoe.lo \ @@ -130,7 +135,8 @@ am__objects_1 = libnm_util_la-crypto.lo libnm_util_la-nm-connection.lo \ libnm_util_la-nm-setting-wired.lo \ libnm_util_la-nm-setting-wireless.lo \ libnm_util_la-nm-setting-wireless-security.lo \ - libnm_util_la-nm-setting-vpn.lo libnm_util_la-nm-utils.lo + libnm_util_la-nm-setting-vpn.lo \ + libnm_util_la-nm-utils-enum-types.lo libnm_util_la-nm-utils.lo am__objects_2 = @WITH_GNUTLS_TRUE@am__objects_3 = libnm_util_la-crypto_gnutls.lo @WITH_NSS_TRUE@am__objects_4 = libnm_util_la-crypto_nss.lo @@ -269,6 +275,8 @@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ +GLIB_MAKEFILE = @GLIB_MAKEFILE@ +GLIB_MKENUMS = @GLIB_MKENUMS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMSGFMT = @GMSGFMT@ @@ -323,11 +331,15 @@ LIBNL2_LIBS = @LIBNL2_LIBS@ LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_GENL3_CFLAGS = @LIBNL_GENL3_CFLAGS@ +LIBNL_GENL3_LIBS = @LIBNL_GENL3_LIBS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ +LIBSOUP_LIBS = @LIBSOUP_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -338,6 +350,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ @@ -377,6 +390,8 @@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ +SYSTEMD_LIBS = @SYSTEMD_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ @@ -441,7 +456,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = . tests -INCLUDES = -I${top_srcdir} -I${top_srcdir}/include +INCLUDES = -I${top_srcdir} -I${top_srcdir}/include -I${top_builddir}/include lib_LTLIBRARIES = libnm-util.la libnm_util_la_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS) $(UUID_CFLAGS) \ -DG_DISABLE_DEPRECATED $(am__append_2) $(am__append_5) @@ -450,8 +465,11 @@ libnm_util_include_HEADERS = \ nm-setting.h \ nm-setting-8021x.h \ nm-setting-bluetooth.h \ + nm-setting-bond.h \ nm-setting-connection.h \ + nm-setting-infiniband.h \ nm-setting-ip4-config.h \ + nm-setting-vlan.h \ nm-setting-ip6-config.h \ nm-setting-ppp.h \ nm-setting-pppoe.h \ @@ -464,6 +482,7 @@ libnm_util_include_HEADERS = \ nm-setting-wireless.h \ nm-setting-wireless-security.h \ nm-setting-vpn.h \ + nm-utils-enum-types.h \ nm-utils.h libnm_util_la_private_headers = \ @@ -479,8 +498,11 @@ libnm_util_la_csources = \ nm-setting.c \ nm-setting-8021x.c \ nm-setting-bluetooth.c \ + nm-setting-bond.c \ nm-setting-connection.c \ + nm-setting-infiniband.c \ nm-setting-ip4-config.c \ + nm-setting-vlan.c \ nm-setting-ip6-config.c \ nm-setting-ppp.c \ nm-setting-pppoe.c \ @@ -493,16 +515,22 @@ libnm_util_la_csources = \ nm-setting-wireless.c \ nm-setting-wireless-security.c \ nm-setting-vpn.c \ + nm-utils-enum-types.c \ nm-utils.c libnm_util_la_SOURCES = $(libnm_util_la_csources) \ $(libnm_util_la_private_headers) $(am__append_1) \ $(am__append_4) +GLIB_GENERATED = nm-utils-enum-types.h nm-utils-enum-types.c +BUILT_SOURCES = $(GLIB_GENERATED) +nm_utils_enum_types_sources = $(libnm_util_include_HEADERS) +GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM +GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS) \ $(am__append_3) $(am__append_6) SYMBOL_VIS_FILE = $(srcdir)/libnm-util.ver libnm_util_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \ - -version-info "4:0:2" + -version-info "5:0:3" libnm_util_includedir = $(includedir)/NetworkManager @@ -534,7 +562,8 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) @HAVE_INTROSPECTION_TRUE@gir_DATA = $(INTROSPECTION_GIRS) @HAVE_INTROSPECTION_TRUE@typelibdir = $(libdir)/girepository-1.0 @HAVE_INTROSPECTION_TRUE@typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) -all: all-recursive +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj @@ -628,21 +657,25 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-param-spec-specialized.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-8021x.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-bluetooth.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-bond.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-cdma.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-gsm.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-infiniband.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-ip4-config.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-ip6-config.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-olpc-mesh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-ppp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-pppoe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-serial.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-vlan.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-vpn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-wimax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-wired.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-wireless-security.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting-wireless.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-setting.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-utils-enum-types.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnm_util_la-nm-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_crypto_la-crypto.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_crypto_la-crypto_gnutls.Plo@am__quote@ @@ -723,6 +756,14 @@ libnm_util_la-nm-setting-bluetooth.lo: nm-setting-bluetooth.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-setting-bluetooth.lo `test -f 'nm-setting-bluetooth.c' || echo '$(srcdir)/'`nm-setting-bluetooth.c +libnm_util_la-nm-setting-bond.lo: nm-setting-bond.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-setting-bond.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-setting-bond.Tpo -c -o libnm_util_la-nm-setting-bond.lo `test -f 'nm-setting-bond.c' || echo '$(srcdir)/'`nm-setting-bond.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-setting-bond.Tpo $(DEPDIR)/libnm_util_la-nm-setting-bond.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-setting-bond.c' object='libnm_util_la-nm-setting-bond.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-setting-bond.lo `test -f 'nm-setting-bond.c' || echo '$(srcdir)/'`nm-setting-bond.c + libnm_util_la-nm-setting-connection.lo: nm-setting-connection.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-setting-connection.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-setting-connection.Tpo -c -o libnm_util_la-nm-setting-connection.lo `test -f 'nm-setting-connection.c' || echo '$(srcdir)/'`nm-setting-connection.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-setting-connection.Tpo $(DEPDIR)/libnm_util_la-nm-setting-connection.Plo @@ -731,6 +772,14 @@ libnm_util_la-nm-setting-connection.lo: nm-setting-connection.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-setting-connection.lo `test -f 'nm-setting-connection.c' || echo '$(srcdir)/'`nm-setting-connection.c +libnm_util_la-nm-setting-infiniband.lo: nm-setting-infiniband.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-setting-infiniband.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-setting-infiniband.Tpo -c -o libnm_util_la-nm-setting-infiniband.lo `test -f 'nm-setting-infiniband.c' || echo '$(srcdir)/'`nm-setting-infiniband.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-setting-infiniband.Tpo $(DEPDIR)/libnm_util_la-nm-setting-infiniband.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-setting-infiniband.c' object='libnm_util_la-nm-setting-infiniband.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-setting-infiniband.lo `test -f 'nm-setting-infiniband.c' || echo '$(srcdir)/'`nm-setting-infiniband.c + libnm_util_la-nm-setting-ip4-config.lo: nm-setting-ip4-config.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-setting-ip4-config.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-setting-ip4-config.Tpo -c -o libnm_util_la-nm-setting-ip4-config.lo `test -f 'nm-setting-ip4-config.c' || echo '$(srcdir)/'`nm-setting-ip4-config.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-setting-ip4-config.Tpo $(DEPDIR)/libnm_util_la-nm-setting-ip4-config.Plo @@ -739,6 +788,14 @@ libnm_util_la-nm-setting-ip4-config.lo: nm-setting-ip4-config.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-setting-ip4-config.lo `test -f 'nm-setting-ip4-config.c' || echo '$(srcdir)/'`nm-setting-ip4-config.c +libnm_util_la-nm-setting-vlan.lo: nm-setting-vlan.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-setting-vlan.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-setting-vlan.Tpo -c -o libnm_util_la-nm-setting-vlan.lo `test -f 'nm-setting-vlan.c' || echo '$(srcdir)/'`nm-setting-vlan.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-setting-vlan.Tpo $(DEPDIR)/libnm_util_la-nm-setting-vlan.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-setting-vlan.c' object='libnm_util_la-nm-setting-vlan.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-setting-vlan.lo `test -f 'nm-setting-vlan.c' || echo '$(srcdir)/'`nm-setting-vlan.c + libnm_util_la-nm-setting-ip6-config.lo: nm-setting-ip6-config.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-setting-ip6-config.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-setting-ip6-config.Tpo -c -o libnm_util_la-nm-setting-ip6-config.lo `test -f 'nm-setting-ip6-config.c' || echo '$(srcdir)/'`nm-setting-ip6-config.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-setting-ip6-config.Tpo $(DEPDIR)/libnm_util_la-nm-setting-ip6-config.Plo @@ -835,6 +892,14 @@ libnm_util_la-nm-setting-vpn.lo: nm-setting-vpn.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-setting-vpn.lo `test -f 'nm-setting-vpn.c' || echo '$(srcdir)/'`nm-setting-vpn.c +libnm_util_la-nm-utils-enum-types.lo: nm-utils-enum-types.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-utils-enum-types.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-utils-enum-types.Tpo -c -o libnm_util_la-nm-utils-enum-types.lo `test -f 'nm-utils-enum-types.c' || echo '$(srcdir)/'`nm-utils-enum-types.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-utils-enum-types.Tpo $(DEPDIR)/libnm_util_la-nm-utils-enum-types.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-utils-enum-types.c' object='libnm_util_la-nm-utils-enum-types.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnm_util_la-nm-utils-enum-types.lo `test -f 'nm-utils-enum-types.c' || echo '$(srcdir)/'`nm-utils-enum-types.c + libnm_util_la-nm-utils.lo: nm-utils.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnm_util_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnm_util_la-nm-utils.lo -MD -MP -MF $(DEPDIR)/libnm_util_la-nm-utils.Tpo -c -o libnm_util_la-nm-utils.lo `test -f 'nm-utils.c' || echo '$(srcdir)/'`nm-utils.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnm_util_la-nm-utils.Tpo $(DEPDIR)/libnm_util_la-nm-utils.Plo @@ -1165,14 +1230,16 @@ distdir: $(DISTFILES) @WITH_TESTS_FALSE@check-local: check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-local -check: check-recursive +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(girdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(typelibdir)" "$(DESTDIR)$(libnm_util_includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-recursive +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive @@ -1199,6 +1266,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-recursive clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ @@ -1273,8 +1341,9 @@ uninstall-am: uninstall-girDATA uninstall-libLTLIBRARIES \ uninstall-libnm_util_includeHEADERS uninstall-pkgconfigDATA \ uninstall-typelibDATA -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) check-am \ - ctags-recursive install-am install-strip tags-recursive +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ + check-am ctags-recursive install install-am install-strip \ + tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am check-local clean clean-generic \ @@ -1296,6 +1365,7 @@ uninstall-am: uninstall-girDATA uninstall-libLTLIBRARIES \ uninstall-libnm_util_includeHEADERS uninstall-pkgconfigDATA \ uninstall-typelibDATA +include $(GLIB_MAKEFILE) -include $(INTROSPECTION_MAKEFILE) diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index 53c2482e..eb3f1f32 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -16,15 +16,19 @@ global: nm_connection_get_setting; nm_connection_get_setting_802_1x; nm_connection_get_setting_bluetooth; + nm_connection_get_setting_bond; nm_connection_get_setting_by_name; nm_connection_get_setting_cdma; nm_connection_get_setting_connection; nm_connection_get_setting_gsm; + nm_connection_get_setting_infiniband; nm_connection_get_setting_ip4_config; nm_connection_get_setting_ip6_config; nm_connection_get_setting_olpc_mesh; nm_connection_get_setting_ppp; nm_connection_get_setting_pppoe; + nm_connection_get_setting_serial; + nm_connection_get_setting_vlan; nm_connection_get_setting_vpn; nm_connection_get_setting_wimax; nm_connection_get_setting_wired; @@ -32,6 +36,7 @@ global: nm_connection_get_setting_wireless_security; nm_connection_get_type; nm_connection_get_uuid; + nm_connection_get_virtual_iface_name; nm_connection_is_type; nm_connection_lookup_setting_type; nm_connection_lookup_setting_type_by_quark; @@ -99,6 +104,8 @@ global: nm_setting_802_1x_add_altsubject_match; nm_setting_802_1x_add_eap_method; nm_setting_802_1x_add_phase2_altsubject_match; + nm_setting_802_1x_ck_format_get_type; + nm_setting_802_1x_ck_scheme_get_type; nm_setting_802_1x_clear_altsubject_matches; nm_setting_802_1x_clear_eap_methods; nm_setting_802_1x_clear_phase2_altsubject_matches; @@ -118,8 +125,11 @@ global: nm_setting_802_1x_get_num_altsubject_matches; nm_setting_802_1x_get_num_eap_methods; nm_setting_802_1x_get_num_phase2_altsubject_matches; + nm_setting_802_1x_get_pac_file; nm_setting_802_1x_get_password; nm_setting_802_1x_get_password_flags; + nm_setting_802_1x_get_password_raw; + nm_setting_802_1x_get_password_raw_flags; nm_setting_802_1x_get_phase1_fast_provisioning; nm_setting_802_1x_get_phase1_peaplabel; nm_setting_802_1x_get_phase1_peapver; @@ -167,6 +177,18 @@ global: nm_setting_bluetooth_get_connection_type; nm_setting_bluetooth_get_type; nm_setting_bluetooth_new; + nm_setting_bond_add_option; + nm_setting_bond_error_get_type; + nm_setting_bond_error_quark; + nm_setting_bond_get_interface_name; + nm_setting_bond_get_num_options; + nm_setting_bond_get_option; + nm_setting_bond_get_option_by_name; + nm_setting_bond_get_option_default; + nm_setting_bond_get_type; + nm_setting_bond_get_valid_options; + nm_setting_bond_new; + nm_setting_bond_remove_option; nm_setting_cdma_error_get_type; nm_setting_cdma_error_quark; nm_setting_cdma_get_number; @@ -178,22 +200,28 @@ global: nm_setting_clear_secrets; nm_setting_clear_secrets_with_flags; nm_setting_compare; + nm_setting_compare_flags_get_type; nm_setting_connection_add_permission; nm_setting_connection_error_get_type; nm_setting_connection_error_quark; nm_setting_connection_get_autoconnect; nm_setting_connection_get_connection_type; nm_setting_connection_get_id; + nm_setting_connection_get_master; nm_setting_connection_get_num_permissions; nm_setting_connection_get_permission; nm_setting_connection_get_read_only; + nm_setting_connection_get_slave_type; nm_setting_connection_get_timestamp; nm_setting_connection_get_type; nm_setting_connection_get_uuid; + nm_setting_connection_get_zone; + nm_setting_connection_is_slave_type; nm_setting_connection_new; nm_setting_connection_permissions_user_allowed; nm_setting_connection_remove_permission; nm_setting_diff; + nm_setting_diff_result_get_type; nm_setting_duplicate; nm_setting_enumerate_values; nm_setting_error_get_type; @@ -201,6 +229,7 @@ global: nm_setting_get_name; nm_setting_get_secret_flags; nm_setting_get_type; + nm_setting_get_virtual_iface_name; nm_setting_gsm_error_get_type; nm_setting_gsm_error_quark; nm_setting_gsm_get_allowed_bands; @@ -215,7 +244,17 @@ global: nm_setting_gsm_get_pin_flags; nm_setting_gsm_get_type; nm_setting_gsm_get_username; + nm_setting_gsm_network_band_get_type; + nm_setting_gsm_network_type_get_type; nm_setting_gsm_new; + nm_setting_hash_flags_get_type; + nm_setting_infiniband_error_get_type; + nm_setting_infiniband_error_quark; + nm_setting_infiniband_get_mac_address; + nm_setting_infiniband_get_mtu; + nm_setting_infiniband_get_transport_mode; + nm_setting_infiniband_get_type; + nm_setting_infiniband_new; nm_setting_ip4_config_add_address; nm_setting_ip4_config_add_dns; nm_setting_ip4_config_add_dns_search; @@ -263,6 +302,7 @@ global: nm_setting_ip6_config_get_dns_search; nm_setting_ip6_config_get_ignore_auto_dns; nm_setting_ip6_config_get_ignore_auto_routes; + nm_setting_ip6_config_get_ip6_privacy; nm_setting_ip6_config_get_may_fail; nm_setting_ip6_config_get_method; nm_setting_ip6_config_get_never_default; @@ -273,6 +313,7 @@ global: nm_setting_ip6_config_get_route; nm_setting_ip6_config_get_type; nm_setting_ip6_config_new; + nm_setting_ip6_config_privacy_get_type; nm_setting_ip6_config_remove_address; nm_setting_ip6_config_remove_dns; nm_setting_ip6_config_remove_dns_search; @@ -316,6 +357,7 @@ global: nm_setting_pppoe_get_type; nm_setting_pppoe_get_username; nm_setting_pppoe_new; + nm_setting_secret_flags_get_type; nm_setting_serial_error_get_type; nm_setting_serial_error_quark; nm_setting_serial_get_baud; @@ -330,6 +372,20 @@ global: nm_setting_to_string; nm_setting_update_secrets; nm_setting_verify; + nm_setting_vlan_add_priority; + nm_setting_vlan_add_priority_str; + nm_setting_vlan_clear_priorities; + nm_setting_vlan_error_get_type; + nm_setting_vlan_error_quark; + nm_setting_vlan_get_flags; + nm_setting_vlan_get_id; + nm_setting_vlan_get_interface_name; + nm_setting_vlan_get_num_priorities; + nm_setting_vlan_get_parent; + nm_setting_vlan_get_priority; + nm_setting_vlan_get_type; + nm_setting_vlan_new; + nm_setting_vlan_remove_priority; nm_setting_vpn_add_data_item; nm_setting_vpn_add_secret; nm_setting_vpn_error_get_type; @@ -337,6 +393,8 @@ global: nm_setting_vpn_foreach_data_item; nm_setting_vpn_foreach_secret; nm_setting_vpn_get_data_item; + nm_setting_vpn_get_num_data_items; + nm_setting_vpn_get_num_secrets; nm_setting_vpn_get_secret; nm_setting_vpn_get_service_type; nm_setting_vpn_get_type; @@ -423,6 +481,11 @@ global: nm_utils_deinit; nm_utils_escape_ssid; nm_utils_gvalue_hash_dup; + nm_utils_hwaddr_atoba; + nm_utils_hwaddr_aton; + nm_utils_hwaddr_len; + nm_utils_hwaddr_ntoa; + nm_utils_hwaddr_type; nm_utils_init; nm_utils_ip4_addresses_from_gvalue; nm_utils_ip4_addresses_to_gvalue; @@ -440,6 +503,7 @@ global: nm_utils_is_empty_ssid; nm_utils_rsa_key_encrypt; nm_utils_same_ssid; + nm_utils_security_type_get_type; nm_utils_security_valid; nm_utils_slist_free; nm_utils_ssid_to_utf8; @@ -449,6 +513,9 @@ global: nm_utils_wifi_find_next_channel; nm_utils_wifi_freq_to_channel; nm_utils_wifi_is_channel_valid; + nm_vlan_flags_get_type; + nm_vlan_priority_map_get_type; + nm_wep_key_type_get_type; local: *; }; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index cdc3b81f..13099998 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -34,6 +34,7 @@ #include "nm-setting-8021x.h" #include "nm-setting-bluetooth.h" #include "nm-setting-connection.h" +#include "nm-setting-infiniband.h" #include "nm-setting-ip4-config.h" #include "nm-setting-ip6-config.h" #include "nm-setting-ppp.h" @@ -42,9 +43,11 @@ #include "nm-setting-wired.h" #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" +#include "nm-setting-serial.h" #include "nm-setting-vpn.h" #include "nm-setting-olpc-mesh.h" - +#include "nm-setting-bond.h" +#include "nm-setting-vlan.h" #include "nm-setting-serial.h" #include "nm-setting-gsm.h" #include "nm-setting-cdma.h" @@ -86,27 +89,6 @@ nm_connection_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_connection_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (NM_CONNECTION_ERROR_UNKNOWN, "UnknownError"), - ENUM_ENTRY (NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, "ConnectionSettingNotFound"), - ENUM_ENTRY (NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, "ConnectionTypeInvalid"), - ENUM_ENTRY (NM_CONNECTION_ERROR_SETTING_NOT_FOUND, "SettingNotFound"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMConnectionError", values); - } - return etype; -} - typedef struct { GHashTable *settings; @@ -135,7 +117,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; static GHashTable *registered_settings = NULL; -#define DEFAULT_MAP_SIZE 16 +#define DEFAULT_MAP_SIZE 19 static struct SettingInfo { const char *name; @@ -242,6 +224,21 @@ register_default_settings (void) NM_SETTING_WIMAX_ERROR, 1, TRUE); + register_one_setting (NM_SETTING_BOND_SETTING_NAME, + NM_TYPE_SETTING_BOND, + NM_SETTING_BOND_ERROR, + 1, TRUE); + + register_one_setting (NM_SETTING_INFINIBAND_SETTING_NAME, + NM_TYPE_SETTING_INFINIBAND, + NM_SETTING_INFINIBAND_ERROR, + 1, TRUE); + + register_one_setting (NM_SETTING_VLAN_SETTING_NAME, + NM_TYPE_SETTING_VLAN, + NM_SETTING_VLAN_ERROR, + 1, TRUE); + register_one_setting (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_TYPE_SETTING_WIRELESS_SECURITY, NM_SETTING_WIRELESS_SECURITY_ERROR, @@ -483,6 +480,33 @@ nm_connection_get_setting_by_name (NMConnection *connection, const char *name) return type ? nm_connection_get_setting (connection, type) : NULL; } +/** + * nm_connection_get_type_setting: + * @connection: a #NMConnection + * + * Returns: (transfer none): the #NMSetting of the connection base type + */ +static NMSetting * +nm_connection_get_type_setting (NMConnection *connection) +{ + NMSettingConnection *s_con; + const char *type; + NMSetting *base; + + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + type = nm_setting_connection_get_connection_type (s_con); + g_assert (type); + + base = nm_connection_get_setting_by_name (connection, type); + g_assert (base); + + return base; +} + static gboolean validate_permissions_type (GHashTable *hash, GError **error) { @@ -709,7 +733,7 @@ gboolean nm_connection_verify (NMConnection *connection, GError **error) { NMConnectionPrivate *priv; - NMSetting *s_con; + NMSettingConnection *s_con; GHashTableIter iter; gpointer value; GSList *all_settings = NULL; @@ -731,7 +755,7 @@ nm_connection_verify (NMConnection *connection, GError **error) priv = NM_CONNECTION_GET_PRIVATE (connection); /* First, make sure there's at least 'connection' setting */ - s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); + s_con = nm_connection_get_setting_connection (connection); if (!s_con) { g_set_error_literal (error, NM_CONNECTION_ERROR, @@ -757,7 +781,7 @@ nm_connection_verify (NMConnection *connection, GError **error) /* Now make sure the given 'type' setting can actually be the base setting * of the connection. Can't have type=ppp for example. */ - ctype = nm_setting_connection_get_connection_type (NM_SETTING_CONNECTION (s_con)); + ctype = nm_setting_connection_get_connection_type (s_con); if (!ctype) { g_set_error_literal (error, NM_CONNECTION_ERROR, @@ -1176,6 +1200,30 @@ nm_connection_get_path (NMConnection *connection) } /** + * nm_connection_get_virtual_iface_name: + * @connection: The #NMConnection + * + * Returns the name of the virtual kernel interface which the connection + * needs to use if specified in the settings. This function abstracts all + * connection types which require this functionality. For all other + * connection types, this function will return NULL. + * + * Returns: Name of the kernel interface or NULL + */ +const char * +nm_connection_get_virtual_iface_name (NMConnection *connection) +{ + NMSetting *base; + + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + base = nm_connection_get_type_setting (connection); + g_assert (base); + + return nm_setting_get_virtual_iface_name (base); +} + +/** * nm_connection_new: * * Creates a new #NMConnection object with no #NMSetting objects. @@ -1274,7 +1322,7 @@ nm_connection_get_uuid (NMConnection *connection) g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); - s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); + s_con = nm_connection_get_setting_connection (connection); g_return_val_if_fail (s_con != NULL, NULL); return nm_setting_connection_get_uuid (s_con); @@ -1296,7 +1344,7 @@ nm_connection_get_id (NMConnection *connection) g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); - s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); + s_con = nm_connection_get_setting_connection (connection); g_return_val_if_fail (s_con != NULL, NULL); return nm_setting_connection_get_id (s_con); @@ -1339,6 +1387,23 @@ nm_connection_get_setting_bluetooth (NMConnection *connection) } /** + * nm_connection_get_setting_bond: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingBond the connection might contain. + * + * Returns: (transfer none): an #NMSettingBond if the connection contains one, otherwise NULL + **/ +NMSettingBond * +nm_connection_get_setting_bond (NMConnection *connection) +{ + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + return (NMSettingBond *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BOND); +} + +/** * nm_connection_get_setting_cdma: * @connection: the #NMConnection * @@ -1390,6 +1455,23 @@ nm_connection_get_setting_gsm (NMConnection *connection) } /** + * nm_connection_get_setting_infiniband: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingInfiniband the connection might contain. + * + * Returns: (transfer none): an #NMSettingInfiniband if the connection contains one, otherwise NULL + **/ +NMSettingInfiniband * +nm_connection_get_setting_infiniband (NMConnection *connection) +{ + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + return (NMSettingInfiniband *) nm_connection_get_setting (connection, NM_TYPE_SETTING_INFINIBAND); +} + +/** * nm_connection_get_setting_ip4_config: * @connection: the #NMConnection * @@ -1475,6 +1557,23 @@ nm_connection_get_setting_pppoe (NMConnection *connection) } /** + * nm_connection_get_setting_serial: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingSerial the connection might contain. + * + * Returns: (transfer none): an #NMSettingSerial if the connection contains one, otherwise NULL + **/ +NMSettingSerial * +nm_connection_get_setting_serial (NMConnection *connection) +{ + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + return (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL); +} + +/** * nm_connection_get_setting_vpn: * @connection: the #NMConnection * @@ -1559,6 +1658,23 @@ nm_connection_get_setting_wireless_security (NMConnection *connection) return (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); } +/** + * nm_connection_get_setting_vlan: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingVlan the connection might contain. + * + * Returns: (transfer none): an #NMSettingVlan if the connection contains one, otherwise NULL + **/ +NMSettingVlan * +nm_connection_get_setting_vlan (NMConnection *connection) +{ + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + return (NMSettingVlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VLAN); +} + /*************************************************************/ static void diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 069dc84c..6df74f57 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -32,19 +32,23 @@ #include <nm-setting-8021x.h> #include <nm-setting-bluetooth.h> +#include <nm-setting-bond.h> #include <nm-setting-cdma.h> #include <nm-setting-connection.h> #include <nm-setting-gsm.h> +#include <nm-setting-infiniband.h> #include <nm-setting-ip4-config.h> #include <nm-setting-ip6-config.h> #include <nm-setting-olpc-mesh.h> #include <nm-setting-ppp.h> #include <nm-setting-pppoe.h> +#include <nm-setting-serial.h> #include <nm-setting-vpn.h> #include <nm-setting-wimax.h> #include <nm-setting-wired.h> #include <nm-setting-wireless.h> #include <nm-setting-wireless-security.h> +#include <nm-setting-vlan.h> G_BEGIN_DECLS @@ -74,15 +78,12 @@ G_BEGIN_DECLS **/ typedef enum { - NM_CONNECTION_ERROR_UNKNOWN = 0, - NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, - NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, - NM_CONNECTION_ERROR_SETTING_NOT_FOUND + NM_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, /*< nick=ConnectionSettingNotFound >*/ + NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, /*< nick=ConnectionTypeInvalid >*/ + NM_CONNECTION_ERROR_SETTING_NOT_FOUND /*< nick=SettingNotFound >*/ } NMConnectionError; -#define NM_TYPE_CONNECTION_ERROR (nm_connection_error_get_type ()) -GType nm_connection_error_get_type (void); - #define NM_CONNECTION_ERROR nm_connection_error_quark () GQuark nm_connection_error_quark (void); @@ -161,6 +162,8 @@ void nm_connection_set_path (NMConnection *connection, const char * nm_connection_get_path (NMConnection *connection); +const char * nm_connection_get_virtual_iface_name (NMConnection *connection); + gboolean nm_connection_is_type (NMConnection *connection, const char *type); void nm_connection_for_each_setting_value (NMConnection *connection, @@ -183,19 +186,23 @@ const char * nm_connection_get_id (NMConnection *connection); NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection); NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection); +NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection); NMSettingCdma * nm_connection_get_setting_cdma (NMConnection *connection); NMSettingConnection * nm_connection_get_setting_connection (NMConnection *connection); NMSettingGsm * nm_connection_get_setting_gsm (NMConnection *connection); +NMSettingInfiniband * nm_connection_get_setting_infiniband (NMConnection *connection); NMSettingIP4Config * nm_connection_get_setting_ip4_config (NMConnection *connection); NMSettingIP6Config * nm_connection_get_setting_ip6_config (NMConnection *connection); NMSettingOlpcMesh * nm_connection_get_setting_olpc_mesh (NMConnection *connection); NMSettingPPP * nm_connection_get_setting_ppp (NMConnection *connection); NMSettingPPPOE * nm_connection_get_setting_pppoe (NMConnection *connection); +NMSettingSerial * nm_connection_get_setting_serial (NMConnection *connection); NMSettingVPN * nm_connection_get_setting_vpn (NMConnection *connection); NMSettingWimax * nm_connection_get_setting_wimax (NMConnection *connection); NMSettingWired * nm_connection_get_setting_wired (NMConnection *connection); NMSettingWireless * nm_connection_get_setting_wireless (NMConnection *connection); NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security (NMConnection *connection); +NMSettingVlan * nm_connection_get_setting_vlan (NMConnection *connection); G_END_DECLS diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c index 07fdcc21..28c0d3f9 100644 --- a/libnm-util/nm-setting-8021x.c +++ b/libnm-util/nm-setting-8021x.c @@ -19,7 +19,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2011 Red Hat, Inc. + * (C) Copyright 2007 - 2012 Red Hat, Inc. * (C) Copyright 2007 - 2008 Novell, Inc. */ @@ -82,30 +82,6 @@ nm_setting_802_1x_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_802_1x_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_802_1X_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, "MissingProperty"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSetting8021xError", values); - } - return etype; -} - - G_DEFINE_TYPE (NMSetting8021x, nm_setting_802_1x, NM_TYPE_SETTING) #define NM_SETTING_802_1X_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_802_1X, NMSetting8021xPrivate)) @@ -114,6 +90,7 @@ typedef struct { GSList *eap; /* GSList of strings */ char *identity; char *anonymous_identity; + char *pac_file; GByteArray *ca_cert; char *ca_path; char *subject_match; @@ -131,6 +108,8 @@ typedef struct { GByteArray *phase2_client_cert; char *password; NMSettingSecretFlags password_flags; + GByteArray *password_raw; + NMSettingSecretFlags password_raw_flags; char *pin; NMSettingSecretFlags pin_flags; GByteArray *private_key; @@ -147,6 +126,7 @@ enum { PROP_EAP, PROP_IDENTITY, PROP_ANONYMOUS_IDENTITY, + PROP_PAC_FILE, PROP_CA_CERT, PROP_CA_PATH, PROP_SUBJECT_MATCH, @@ -164,6 +144,8 @@ enum { PROP_PHASE2_CLIENT_CERT, PROP_PASSWORD, PROP_PASSWORD_FLAGS, + PROP_PASSWORD_RAW, + PROP_PASSWORD_RAW_FLAGS, PROP_PRIVATE_KEY, PROP_PRIVATE_KEY_PASSWORD, PROP_PRIVATE_KEY_PASSWORD_FLAGS, @@ -341,6 +323,22 @@ nm_setting_802_1x_get_anonymous_identity (NMSetting8021x *setting) } /** + * nm_setting_802_1x_get_pac_file: + * @setting: the #NMSetting8021x + * + * Returns the file containing PAC credentials used by EAP-FAST method. + * + * Returns: the PAC file + **/ +const char * +nm_setting_802_1x_get_pac_file (NMSetting8021x *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL); + + return NM_SETTING_802_1X_GET_PRIVATE (setting)->pac_file; +} + +/** * nm_setting_802_1x_get_ca_path: * @setting: the #NMSetting8021x * @@ -1423,6 +1421,37 @@ nm_setting_802_1x_get_password_flags (NMSetting8021x *setting) } /** + * nm_setting_802_1x_get_password_raw: + * @setting: the #NMSetting8021x + * + * Returns: the password used by the authentication method as a + * UTF-8-encoded array of bytes, as specified by the + * #NMSetting8021x:password-raw property + **/ +const GByteArray * +nm_setting_802_1x_get_password_raw (NMSetting8021x *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL); + + return NM_SETTING_802_1X_GET_PRIVATE (setting)->password_raw; +} + +/** + * nm_setting_802_1x_get_password_raw_flags: + * @setting: the #NMSetting8021x + * + * Returns: the #NMSettingSecretFlags pertaining to the + * #NMSetting8021x:password-raw + **/ +NMSettingSecretFlags +nm_setting_802_1x_get_password_raw_flags (NMSetting8021x *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_SECRET_FLAG_NONE); + + return NM_SETTING_802_1X_GET_PRIVATE (setting)->password_raw_flags; +} + +/** * nm_setting_802_1x_get_pin: * @setting: the #NMSetting8021x * @@ -2001,8 +2030,11 @@ need_secrets_password (NMSetting8021x *self, { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self); - if (!priv->password || !strlen (priv->password)) + if ( (!priv->password || !strlen (priv->password)) + && (!priv->password_raw || !priv->password_raw->len)) { g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD); + g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD_RAW); + } } static void @@ -2542,6 +2574,8 @@ finalize (GObject *object) g_free (priv->phase2_ca_path); g_free (priv->phase2_subject_match); g_free (priv->password); + if (priv->password_raw) + g_byte_array_free (priv->password_raw, TRUE); nm_utils_slist_free (priv->eap, g_free); nm_utils_slist_free (priv->altsubject_matches, g_free); @@ -2604,6 +2638,10 @@ set_property (GObject *object, guint prop_id, g_free (priv->anonymous_identity); priv->anonymous_identity = g_value_dup_string (value); break; + case PROP_PAC_FILE: + g_free (priv->pac_file); + priv->pac_file = g_value_dup_string (value); + break; case PROP_CA_CERT: if (priv->ca_cert) { g_byte_array_free (priv->ca_cert, TRUE); @@ -2703,6 +2741,14 @@ set_property (GObject *object, guint prop_id, case PROP_PASSWORD_FLAGS: priv->password_flags = g_value_get_uint (value); break; + case PROP_PASSWORD_RAW: + if (priv->password_raw) + g_byte_array_free (priv->password_raw, TRUE); + priv->password_raw = g_value_dup_boxed (value); + break; + case PROP_PASSWORD_RAW_FLAGS: + priv->password_raw_flags = g_value_get_uint (value); + break; case PROP_PRIVATE_KEY: if (priv->private_key) { g_byte_array_free (priv->private_key, TRUE); @@ -2767,6 +2813,9 @@ get_property (GObject *object, guint prop_id, case PROP_ANONYMOUS_IDENTITY: g_value_set_string (value, priv->anonymous_identity); break; + case PROP_PAC_FILE: + g_value_set_string (value, priv->pac_file); + break; case PROP_CA_CERT: g_value_set_boxed (value, priv->ca_cert); break; @@ -2818,6 +2867,12 @@ get_property (GObject *object, guint prop_id, case PROP_PASSWORD_FLAGS: g_value_set_uint (value, priv->password_flags); break; + case PROP_PASSWORD_RAW: + g_value_set_boxed (value, priv->password_raw); + break; + case PROP_PASSWORD_RAW_FLAGS: + g_value_set_uint (value, priv->password_raw_flags); + break; case PROP_PRIVATE_KEY: g_value_set_boxed (value, priv->private_key); break; @@ -2921,6 +2976,19 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class) G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); /** + * NMSetting8021x:pac-file: + * + * UTF-8 encoded file path containing PAC for EAP-FAST. + **/ + g_object_class_install_property + (object_class, PROP_PAC_FILE, + g_param_spec_string (NM_SETTING_802_1X_PAC_FILE, + "PAC file", + "UTF-8 encoded file path containing PAC for EAP-FAST.", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); + + /** * NMSetting8021x:ca-cert: * * Contains the CA certificate if used by the EAP method specified in the @@ -3274,7 +3342,9 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class) /** * NMSetting8021x:password: * - * Password used for EAP authentication methods. + * Password used for EAP authentication methods. If both + * #NMSetting8021x:password and #NMSetting8021x:password-raw are + * specified, #NMSetting8021x:password is preferred. **/ g_object_class_install_property (object_class, PROP_PASSWORD, @@ -3299,6 +3369,36 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class) G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); /** + * NMSetting8021x:password-raw: + * + * Password used for EAP authentication methods delivered as a + * UTF-8-encoded array of bytes. If both #NMSetting8021x:password + * and #NMSetting8021x:password-raw are specified, + * #NMSetting8021x:password is preferred. + **/ + g_object_class_install_property + (object_class, PROP_PASSWORD_RAW, + _nm_param_spec_specialized (NM_SETTING_802_1X_PASSWORD_RAW, + "Password byte array", + "Password used for EAP authentication methods as a byte array", + DBUS_TYPE_G_UCHAR_ARRAY, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET)); + + /** + * NMSetting8021x:password-raw-flags: + * + * Flags indicating how to handle #NMSetting8021x:password-raw:. + **/ + g_object_class_install_property (object_class, PROP_PASSWORD_RAW_FLAGS, + g_param_spec_uint (NM_SETTING_802_1X_PASSWORD_RAW_FLAGS, + "Password byte array Flags", + "Flags indicating how to handle the 802.1x password byte array.", + NM_SETTING_SECRET_FLAG_NONE, + NM_SETTING_SECRET_FLAGS_ALL, + NM_SETTING_SECRET_FLAG_NONE, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); + + /** * NMSetting8021x:private-key: * * Contains the private key if the #NMSetting8021x:eap property is set to diff --git a/libnm-util/nm-setting-8021x.h b/libnm-util/nm-setting-8021x.h index a6016aea..eaca344d 100644 --- a/libnm-util/nm-setting-8021x.h +++ b/libnm-util/nm-setting-8021x.h @@ -19,7 +19,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2011 Red Hat, Inc. + * (C) Copyright 2007 - 2012 Red Hat, Inc. * (C) Copyright 2007 - 2008 Novell, Inc. */ @@ -42,7 +42,7 @@ G_BEGIN_DECLS * #NMSetting8021xCKFormat values indicate the general type of a certificate * or private key */ -typedef enum { +typedef enum { /*< underscore_name=nm_setting_802_1x_ck_format >*/ NM_SETTING_802_1X_CK_FORMAT_UNKNOWN = 0, NM_SETTING_802_1X_CK_FORMAT_X509, NM_SETTING_802_1X_CK_FORMAT_RAW_KEY, @@ -62,7 +62,7 @@ typedef enum { * stored in the setting properties, either as a blob of the item's data, or as * a path to a certificate or private key file on the filesystem */ -typedef enum { +typedef enum { /*< underscore_name=nm_setting_802_1x_ck_scheme >*/ NM_SETTING_802_1X_CK_SCHEME_UNKNOWN = 0, NM_SETTING_802_1X_CK_SCHEME_BLOB, NM_SETTING_802_1X_CK_SCHEME_PATH @@ -85,15 +85,12 @@ typedef enum { * @NM_SETTING_802_1X_ERROR_MISSING_PROPERTY: the property was missing and is * required */ -typedef enum { - NM_SETTING_802_1X_ERROR_UNKNOWN = 0, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY +typedef enum { /*< underscore_name=nm_setting_802_1x_error >*/ + NM_SETTING_802_1X_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_802_1X_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ } NMSetting8021xError; -#define NM_TYPE_SETTING_802_1X_ERROR (nm_setting_802_1x_error_get_type ()) -GType nm_setting_802_1x_error_get_type (void); - #define NM_SETTING_802_1X_ERROR nm_setting_802_1x_error_quark () GQuark nm_setting_802_1x_error_quark (void); @@ -101,6 +98,7 @@ GQuark nm_setting_802_1x_error_quark (void); #define NM_SETTING_802_1X_EAP "eap" #define NM_SETTING_802_1X_IDENTITY "identity" #define NM_SETTING_802_1X_ANONYMOUS_IDENTITY "anonymous-identity" +#define NM_SETTING_802_1X_PAC_FILE "pac-file" #define NM_SETTING_802_1X_CA_CERT "ca-cert" #define NM_SETTING_802_1X_CA_PATH "ca-path" #define NM_SETTING_802_1X_SUBJECT_MATCH "subject-match" @@ -118,6 +116,8 @@ GQuark nm_setting_802_1x_error_quark (void); #define NM_SETTING_802_1X_PHASE2_CLIENT_CERT "phase2-client-cert" #define NM_SETTING_802_1X_PASSWORD "password" #define NM_SETTING_802_1X_PASSWORD_FLAGS "password-flags" +#define NM_SETTING_802_1X_PASSWORD_RAW "password-raw" +#define NM_SETTING_802_1X_PASSWORD_RAW_FLAGS "password-raw-flags" #define NM_SETTING_802_1X_PRIVATE_KEY "private-key" #define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD "private-key-password" #define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS "private-key-password-flags" @@ -176,6 +176,8 @@ const char * nm_setting_802_1x_get_identity (NMSetting8 const char * nm_setting_802_1x_get_anonymous_identity (NMSetting8021x *setting); +const char * nm_setting_802_1x_get_pac_file (NMSetting8021x *setting); + gboolean nm_setting_802_1x_get_system_ca_certs (NMSetting8021x *setting); const char * nm_setting_802_1x_get_ca_path (NMSetting8021x *setting); const char * nm_setting_802_1x_get_phase2_ca_path (NMSetting8021x *setting); @@ -250,6 +252,8 @@ gboolean nm_setting_802_1x_set_phase2_client_cert (NMSett const char * nm_setting_802_1x_get_password (NMSetting8021x *setting); NMSettingSecretFlags nm_setting_802_1x_get_password_flags (NMSetting8021x *setting); +const GByteArray * nm_setting_802_1x_get_password_raw (NMSetting8021x *setting); +NMSettingSecretFlags nm_setting_802_1x_get_password_raw_flags (NMSetting8021x *setting); const char * nm_setting_802_1x_get_pin (NMSetting8021x *setting); NMSettingSecretFlags nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting); diff --git a/libnm-util/nm-setting-bluetooth.c b/libnm-util/nm-setting-bluetooth.c index 1b1178b2..6a2fed74 100644 --- a/libnm-util/nm-setting-bluetooth.c +++ b/libnm-util/nm-setting-bluetooth.c @@ -62,27 +62,6 @@ nm_setting_bluetooth_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_bluetooth_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (NM_SETTING_BLUETOOTH_ERROR_UNKNOWN, "UnknownError"), - ENUM_ENTRY (NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, "InvalidProperty"), - ENUM_ENTRY (NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, "MissingProperty"), - ENUM_ENTRY (NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND, "TypeSettingNotFound"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingBluetoothError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-bluetooth.h b/libnm-util/nm-setting-bluetooth.h index a17a72bf..d76da8db 100644 --- a/libnm-util/nm-setting-bluetooth.h +++ b/libnm-util/nm-setting-bluetooth.h @@ -51,15 +51,12 @@ G_BEGIN_DECLS * must also contain an #NMSettingGsm or #NMSettingCdma as appropriate */ typedef enum { - NM_SETTING_BLUETOOTH_ERROR_UNKNOWN = 0, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, - NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, - NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND, + NM_SETTING_BLUETOOTH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND, /*< nick=TypeSettingNotFound >*/ } NMSettingBluetoothError; -#define NM_TYPE_SETTING_BLUETOOTH_ERROR (nm_setting_bluetooth_error_get_type ()) -GType nm_setting_bluetooth_error_get_type (void); - #define NM_SETTING_BLUETOOTH_ERROR nm_setting_bluetooth_error_quark () GQuark nm_setting_bluetooth_error_quark (void); diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c new file mode 100644 index 00000000..9f9f4389 --- /dev/null +++ b/libnm-util/nm-setting-bond.c @@ -0,0 +1,663 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * Thomas Graf <tgraf@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 - 2012 Red Hat, Inc. + */ + +#include <string.h> +#include <ctype.h> +#include <stdlib.h> +#include <dbus/dbus-glib.h> + +#include "nm-setting-bond.h" +#include "nm-param-spec-specialized.h" +#include "nm-utils.h" +#include "nm-utils-private.h" +#include "nm-dbus-glib-types.h" + +/** + * SECTION:nm-setting-bond + * @short_description: Describes connection properties for bonds + * @include: nm-setting-bond.h + * + * The #NMSettingBond object is a #NMSetting subclass that describes properties + * necessary for bond connections. + **/ + +/** + * nm_setting_bond_error_quark: + * + * Registers an error quark for #NMSettingBond if necessary. + * + * Returns: the error quark used for #NMSettingBond errors. + **/ +GQuark +nm_setting_bond_error_quark (void) +{ + static GQuark quark; + + if (G_UNLIKELY (!quark)) + quark = g_quark_from_static_string ("nm-setting-bond-error-quark"); + return quark; +} + + +G_DEFINE_TYPE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING) + +#define NM_SETTING_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BOND, NMSettingBondPrivate)) + +typedef struct { + char *interface_name; + GHashTable *options; +} NMSettingBondPrivate; + +enum { + PROP_0, + PROP_INTERFACE_NAME, + PROP_OPTIONS, + LAST_PROP +}; + +typedef struct { + const char *opt; + const char *val; +} BondDefault; + +static const BondDefault defaults[] = { + { NM_SETTING_BOND_OPTION_MODE, "balance-rr" }, + { NM_SETTING_BOND_OPTION_MIIMON, "100" }, + { NM_SETTING_BOND_OPTION_DOWNDELAY, "0" }, + { NM_SETTING_BOND_OPTION_UPDELAY, "0" }, + { NM_SETTING_BOND_OPTION_ARP_INTERVAL, "0" }, + { NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "" }, +}; + +/** + * nm_setting_bond_new: + * + * Creates a new #NMSettingBond object with default values. + * + * Returns: (transfer full): the new empty #NMSettingBond object + **/ +NMSetting * +nm_setting_bond_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_BOND, NULL); +} + +/** + * nm_setting_bond_get_interface_name + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:interface-name property of the setting + **/ +const char * +nm_setting_bond_get_interface_name (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->interface_name; +} + +/** + * nm_setting_bond_get_num_options: + * @setting: the #NMSettingBond + * + * Returns the number of options that should be set for this bond when it + * is activated. This can be used to retrieve each option individually + * using nm_setting_bond_get_option(). + * + * Returns: the number of bonding options + **/ +guint32 +nm_setting_bond_get_num_options (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return g_hash_table_size (NM_SETTING_BOND_GET_PRIVATE (setting)->options); +} + +/** + * nm_setting_bond_get_option: + * @setting: the #NMSettingBond + * @idx: index of the desired option, from 0 to + * nm_setting_bond_get_num_options() - 1 + * @out_name: (out): on return, the name of the bonding option; this + * value is owned by the setting and should not be modified + * @out_value: (out): on return, the value of the name of the bonding + * option; this value is owned by the setting and should not be modified + * + * Given an index, return the value of the bonding option at that index. Indexes + * are *not* guaranteed to be static across modifications to options done by + * nm_setting_bond_add_option() and nm_setting_bond_remove_option(), + * and should not be used to refer to options except for short periods of time + * such as during option iteration. + * + * Returns: %TRUE on success if the index was valid and an option was found, + * %FALSE if the index was invalid (ie, greater than the number of options + * currently held by the setting) + **/ +gboolean +nm_setting_bond_get_option (NMSettingBond *setting, + guint32 idx, + const char **out_name, + const char **out_value) +{ + NMSettingBondPrivate *priv; + GList *keys; + const char *_key = NULL, *_value = NULL; + + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE); + + priv = NM_SETTING_BOND_GET_PRIVATE (setting); + + if (idx >= nm_setting_bond_get_num_options (setting)) + return FALSE; + + keys = g_hash_table_get_keys (priv->options); + _key = g_list_nth_data (keys, idx); + _value = g_hash_table_lookup (priv->options, _key); + + if (out_name) + *out_name = _key; + if (out_value) + *out_value = _value; + + g_list_free (keys); + return TRUE; +} + +static gboolean +validate_option (const char *name) +{ + guint i; + + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (name[0] != '\0', FALSE); + + for (i = 0; i < G_N_ELEMENTS (defaults); i++) { + if (g_strcmp0 (defaults[i].opt, name) == 0) + return TRUE; + } + return FALSE; +} + +/** + * nm_setting_bond_get_option_by_name: + * @setting: the #NMSettingBond + * @name: the option name for which to retrieve the value + * + * Returns the value associated with the bonding option specified by + * @name, if it exists. + * + * Returns: the value, or %NULL if the key/value pair was never added to the + * setting; the value is owned by the setting and must not be modified + **/ +const char * +nm_setting_bond_get_option_by_name (NMSettingBond *setting, + const char *name) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL); + g_return_val_if_fail (validate_option (name), NULL); + + return g_hash_table_lookup (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name); +} + +/** + * nm_setting_bond_add_option: + * @setting: the #NMSettingBond + * @name: name for the option + * @value: value for the option + * + * Add an option to the table. The option is compared to an internal list + * of allowed options. Option names may contain only alphanumeric characters + * (ie [a-zA-Z0-9]). Adding a new name replaces any existing name/value pair + * that may already exist. + * + * Returns: %TRUE if the option was valid and was added to the internal option + * list, %FALSE if it was not. + **/ +gboolean nm_setting_bond_add_option (NMSettingBond *setting, + const char *name, + const char *value) +{ + NMSettingBondPrivate *priv; + size_t value_len; + + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE); + g_return_val_if_fail (validate_option (name), FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + priv = NM_SETTING_BOND_GET_PRIVATE (setting); + + value_len = strlen (value); + g_return_val_if_fail (value_len > 0 && value_len < 200, FALSE); + + g_hash_table_insert (priv->options, g_strdup (name), g_strdup (value)); + + if (!strcmp (name, NM_SETTING_BOND_OPTION_MIIMON)) { + g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL); + g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); + } else if (!strcmp (name, NM_SETTING_BOND_OPTION_ARP_INTERVAL)) + g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_MIIMON); + + return TRUE; +} + +/** + * nm_setting_bond_remove_option: + * @setting: the #NMSettingBond + * @name: name of the option to remove + * + * Remove the bonding option referenced by @name from the internal option + * list. + * + * Returns: %TRUE if the option was found and removed from the internal option + * list, %FALSE if it was not. + **/ +gboolean +nm_setting_bond_remove_option (NMSettingBond *setting, + const char *name) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE); + g_return_val_if_fail (validate_option (name), FALSE); + + return g_hash_table_remove (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name); +} + +/** + * nm_setting_bond_get_valid_options: + * @setting: the #NMSettingBond + * + * Returns a list of valid bond options. + * + * Returns: a NULL-terminated array of strings of valid bond options. + **/ +const char ** +nm_setting_bond_get_valid_options (NMSettingBond *setting) +{ + static const char *array[G_N_ELEMENTS (defaults) + 1] = { NULL }; + int i; + + /* initialize the array once */ + if (G_UNLIKELY (array[0] == NULL)) { + for (i = 0; i < G_N_ELEMENTS (defaults); i++) + array[i] = defaults[i].opt; + array[i] = NULL; + } + return array; +} + +/** + * nm_setting_bond_get_option_default: + * @setting: the #NMSettingBond + * @name: the name of the option + * + * Returns: the value of the bond option if not overridden by an entry in + * the #NMSettingBond:options property. + **/ +const char * +nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name) +{ + guint i; + + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL); + g_return_val_if_fail (validate_option (name), NULL); + + for (i = 0; i < G_N_ELEMENTS (defaults); i++) { + if (g_strcmp0 (defaults[i].opt, name) == 0) + return defaults[i].val; + } + /* Any option that passes validate_option() should also be found in defaults */ + g_assert_not_reached (); +} + +/* + * This function is a 1:1 copy of the kernel's + * dev_valid_name() in net/core/dev.c + */ +static gboolean +dev_valid_name(const char *name) +{ + if (*name == '\0') + return FALSE; + + if (strlen (name) >= 16) + return FALSE; + + if (!strcmp (name, ".") || !strcmp (name, "..")) + return FALSE; + + while (*name) { + if (*name == '/' || isspace (*name)) + return FALSE; + name++; + } + + return TRUE; +} + +static gint +find_setting_by_name (gconstpointer a, gconstpointer b) +{ + NMSetting *setting = NM_SETTING (a); + const char *str = (const char *) b; + + return strcmp (nm_setting_get_name (setting), str); +} + +static gboolean +verify (NMSetting *setting, GSList *all_settings, GError **error) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting); + GHashTableIter iter; + const char *key, *value; + const char *valid_modes[] = { "balance-rr", + "active-backup", + "balance-xor", + "broadcast", + "802.3ad", + "balance-tlb", + "balance-alb", + NULL }; + int miimon = 0, arp_interval = 0; + const char *arp_ip_target = NULL; + + if (!priv->interface_name || !strlen(priv->interface_name)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_MISSING_PROPERTY, + NM_SETTING_BOND_INTERFACE_NAME); + return FALSE; + } + + if (!dev_valid_name (priv->interface_name)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_PROPERTY, + NM_SETTING_BOND_INTERFACE_NAME); + return FALSE; + } + + g_hash_table_iter_init (&iter, priv->options); + while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) { + if ( !validate_option (key) + || !value[0] + || (strlen (value) > 200) + || strchr (value, ' ')) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + key); + return FALSE; + } + } + + value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MIIMON); + if (value) + miimon = atoi (value); + value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL); + if (value) + arp_interval = atoi (value); + + /* Can only set one of miimon and arp_interval */ + if (miimon > 0 && arp_interval > 0) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_ARP_INTERVAL); + } + + value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE); + if (!value) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_MISSING_OPTION, + NM_SETTING_BOND_OPTION_MODE); + return FALSE; + } + if (!_nm_utils_string_in_list (value, valid_modes)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_MODE); + return FALSE; + } + + /* Make sure mode is compatible with other settings */ + if ( strcmp (value, "balance-alb") == 0 + || strcmp (value, "balance-tlb") == 0) { + if (arp_interval > 0) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_ARP_INTERVAL); + } + } + if (g_slist_find_custom (all_settings, NM_SETTING_INFINIBAND_SETTING_NAME, find_setting_by_name)) { + if (strcmp (value, "active-backup") != 0) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_MODE); + return FALSE; + } + } + + if (miimon == 0) { + /* updelay and downdelay can only be used with miimon */ + if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_UPDELAY)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_UPDELAY); + return FALSE; + } + if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_DOWNDELAY); + return FALSE; + } + } + + /* arp_ip_target can only be used with arp_interval, and must + * contain a comma-separated list of IPv4 addresses. + */ + arp_ip_target = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); + if (arp_interval > 0) { + char **addrs; + guint32 addr; + int i; + + if (!arp_ip_target) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_MISSING_OPTION, + NM_SETTING_BOND_OPTION_ARP_IP_TARGET); + return FALSE; + } + + addrs = g_strsplit (arp_ip_target, ",", -1); + if (!addrs[0]) { + g_strfreev (addrs); + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_ARP_IP_TARGET); + return FALSE; + } + + for (i = 0; addrs[i]; i++) { + if (!inet_pton (AF_INET, addrs[i], &addr)) { + g_strfreev (addrs); + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_ARP_IP_TARGET); + return FALSE; + } + } + g_strfreev (addrs); + } else { + if (arp_ip_target) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_SETTING_BOND_OPTION_ARP_IP_TARGET); + return FALSE; + } + } + + return TRUE; +} + +static const char * +get_virtual_iface_name (NMSetting *setting) +{ + NMSettingBond *self = NM_SETTING_BOND (setting); + + return nm_setting_bond_get_interface_name (self); +} + +static void +nm_setting_bond_init (NMSettingBond *setting) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting); + + g_object_set (setting, NM_SETTING_NAME, NM_SETTING_BOND_SETTING_NAME, + NULL); + + priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + + /* Default values: */ + nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr"); + nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MIIMON, "100"); +} + +static void +finalize (GObject *object) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object); + + g_free (priv->interface_name); + g_hash_table_destroy (priv->options); + + G_OBJECT_CLASS (nm_setting_bond_parent_class)->finalize (object); +} + +static void +copy_hash (gpointer key, gpointer value, gpointer user_data) +{ + g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value)); +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object); + GHashTable *new_hash; + + switch (prop_id) { + case PROP_INTERFACE_NAME: + priv->interface_name = g_value_dup_string (value); + break; + case PROP_OPTIONS: + /* Must make a deep copy of the hash table here... */ + g_hash_table_remove_all (priv->options); + new_hash = g_value_get_boxed (value); + if (new_hash) + g_hash_table_foreach (new_hash, copy_hash, priv->options); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object); + NMSettingBond *setting = NM_SETTING_BOND (object); + + switch (prop_id) { + case PROP_INTERFACE_NAME: + g_value_set_string (value, nm_setting_bond_get_interface_name (setting)); + break; + case PROP_OPTIONS: + g_value_set_boxed (value, priv->options); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_setting_bond_class_init (NMSettingBondClass *setting_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (setting_class); + NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class); + + g_type_class_add_private (setting_class, sizeof (NMSettingBondPrivate)); + + /* virtual methods */ + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->finalize = finalize; + parent_class->verify = verify; + parent_class->get_virtual_iface_name = get_virtual_iface_name; + + /* Properties */ + /** + * NMSettingBond:interface-name: + * + * The name of the virtual in-kernel bonding network interface + **/ + g_object_class_install_property + (object_class, PROP_INTERFACE_NAME, + g_param_spec_string (NM_SETTING_BOND_INTERFACE_NAME, + "InterfaceName", + "The name of the virtual in-kernel bonding network interface", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingBond:options: + * + * Dictionary of key/value pairs of bonding options. Both keys + * and values must be strings. Option names must contain only + * alphanumeric characters (ie, [a-zA-Z0-9]). + **/ + g_object_class_install_property + (object_class, PROP_OPTIONS, + _nm_param_spec_specialized (NM_SETTING_BOND_OPTIONS, + "Options", + "Dictionary of key/value pairs of bonding " + "options. Both keys and values must be " + "strings. Option names must contain only " + "alphanumeric characters (ie, [a-zA-Z0-9]).", + DBUS_TYPE_G_MAP_OF_STRING, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); +} diff --git a/libnm-util/nm-setting-bond.h b/libnm-util/nm-setting-bond.h new file mode 100644 index 00000000..9d494d3d --- /dev/null +++ b/libnm-util/nm-setting-bond.h @@ -0,0 +1,107 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * Thomas Graf <tgraf@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 - 2012 Red Hat, Inc. + */ + +#ifndef NM_SETTING_BOND_H +#define NM_SETTING_BOND_H + +#include <nm-setting.h> + +G_BEGIN_DECLS + +#define NM_TYPE_SETTING_BOND (nm_setting_bond_get_type ()) +#define NM_SETTING_BOND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BOND, NMSettingBond)) +#define NM_SETTING_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BOND, NMSettingBondClass)) +#define NM_IS_SETTING_BOND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BOND)) +#define NM_IS_SETTING_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING_BOND)) +#define NM_SETTING_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BOND, NMSettingBondClass)) + +#define NM_SETTING_BOND_SETTING_NAME "bond" + +/** + * NMSettingBondError: + * @NM_SETTING_BOND_ERROR_UNKNOWN: unknown or unclassified error + * @NM_SETTING_BOND_ERROR_INVALID_PROPERTY: the property was invalid + * @NM_SETTING_BOND_ERROR_MISSING_PROPERTY: the property was missing and is + * required + */ +typedef enum { + NM_SETTING_BOND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_BOND_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_BOND_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_BOND_ERROR_INVALID_OPTION, /*< nick=InvalidOption >*/ + NM_SETTING_BOND_ERROR_MISSING_OPTION, /*< nick=MissingOption >*/ +} NMSettingBondError; + +#define NM_SETTING_BOND_ERROR nm_setting_bond_error_quark () +GQuark nm_setting_bond_error_quark (void); + +#define NM_SETTING_BOND_INTERFACE_NAME "interface-name" +#define NM_SETTING_BOND_OPTIONS "options" + +/* Valid options for the 'options' property */ +#define NM_SETTING_BOND_OPTION_MODE "mode" +#define NM_SETTING_BOND_OPTION_MIIMON "miimon" +#define NM_SETTING_BOND_OPTION_DOWNDELAY "downdelay" +#define NM_SETTING_BOND_OPTION_UPDELAY "updelay" +#define NM_SETTING_BOND_OPTION_ARP_INTERVAL "arp_interval" +#define NM_SETTING_BOND_OPTION_ARP_IP_TARGET "arp_ip_target" + +typedef struct { + NMSetting parent; +} NMSettingBond; + +typedef struct { + NMSettingClass parent; + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); +} NMSettingBondClass; + +GType nm_setting_bond_get_type (void); + +NMSetting * nm_setting_bond_new (void); +const char * nm_setting_bond_get_interface_name (NMSettingBond *setting); +guint32 nm_setting_bond_get_num_options (NMSettingBond *setting); +gboolean nm_setting_bond_get_option (NMSettingBond *setting, + guint32 idx, + const char **out_name, + const char **out_value); +const char * nm_setting_bond_get_option_by_name (NMSettingBond *setting, + const char *name); +gboolean nm_setting_bond_add_option (NMSettingBond *setting, + const char *name, + const char *value); +gboolean nm_setting_bond_remove_option (NMSettingBond *setting, + const char *name); + +const char **nm_setting_bond_get_valid_options (NMSettingBond *setting); + +const char * nm_setting_bond_get_option_default (NMSettingBond *setting, + const char *name); + +G_END_DECLS + +#endif /* NM_SETTING_BOND_H */ diff --git a/libnm-util/nm-setting-cdma.c b/libnm-util/nm-setting-cdma.c index cb5b27e8..43bf93b1 100644 --- a/libnm-util/nm-setting-cdma.c +++ b/libnm-util/nm-setting-cdma.c @@ -53,31 +53,6 @@ nm_setting_cdma_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_cdma_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_CDMA_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The required serial setting is missing (DEPRECATED) */ - ENUM_ENTRY (NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING, "MissingSerialSetting"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingCdmaError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingCdma, nm_setting_cdma, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-cdma.h b/libnm-util/nm-setting-cdma.h index d0a5de4c..a9491efb 100644 --- a/libnm-util/nm-setting-cdma.h +++ b/libnm-util/nm-setting-cdma.h @@ -49,15 +49,12 @@ G_BEGIN_DECLS * is missing in the connection */ typedef enum { - NM_SETTING_CDMA_ERROR_UNKNOWN = 0, - NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, - NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, - NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING + NM_SETTING_CDMA_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING /*< nick=MissingSerialSetting >*/ } NMSettingCdmaError; -#define NM_TYPE_SETTING_CDMA_ERROR (nm_setting_cdma_error_get_type ()) -GType nm_setting_cdma_error_get_type (void); - #define NM_SETTING_CDMA_ERROR nm_setting_cdma_error_quark () GQuark nm_setting_cdma_error_quark (void); diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index e9030b10..94ca9112 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -58,27 +58,6 @@ nm_setting_connection_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_connection_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (NM_SETTING_CONNECTION_ERROR_UNKNOWN, "UnknownError"), - ENUM_ENTRY (NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, "InvalidProperty"), - ENUM_ENTRY (NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, "MissingProperty"), - ENUM_ENTRY (NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, "TypeSettingNotFound"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingConnectionError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingConnection, nm_setting_connection, NM_TYPE_SETTING) @@ -97,10 +76,13 @@ typedef struct { char *id; char *uuid; char *type; + char *master; + char *slave_type; GSList *permissions; /* list of Permission structs */ gboolean autoconnect; guint64 timestamp; gboolean read_only; + char *zone; } NMSettingConnectionPrivate; enum { @@ -112,6 +94,9 @@ enum { PROP_AUTOCONNECT, PROP_TIMESTAMP, PROP_READ_ONLY, + PROP_ZONE, + PROP_MASTER, + PROP_SLAVE_TYPE, LAST_PROP }; @@ -478,6 +463,72 @@ nm_setting_connection_get_read_only (NMSettingConnection *setting) return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->read_only; } +/** + * nm_setting_connection_get_zone: + * @setting: the #NMSettingConnection + * + * Returns the #NMSettingConnection:zone property of the connection. + * + * Returns: the trust level of a connection + **/ +const char * +nm_setting_connection_get_zone (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->zone; +} + +/** + * nm_setting_connection_get_master: + * @setting: the #NMSettingConnection + * + * Returns the #NMSettingConnection:master property of the connection. + * + * Returns: interface name of the master device or UUID of the master + * connection. + */ +const char * +nm_setting_connection_get_master (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->master; +} + +/** + * nm_setting_connection_get_slave_type: + * @setting: the #NMSettingConnection + * + * Returns the #NMSettingConnection:slave-type property of the connection. + * + * Returns: the type of slave this connection is, if any + */ +const char * +nm_setting_connection_get_slave_type (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->slave_type; +} + +/** + * nm_setting_connection_is_slave_type: + * @setting: the #NMSettingConnection + * @type: the setting name (ie #NM_SETTING_BOND_SETTING_NAME) to be matched + * against @setting's slave type + * + * Returns: TRUE if connection is of the given slave @type + */ +gboolean +nm_setting_connection_is_slave_type (NMSettingConnection *setting, + const char *type) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE); + + return !g_strcmp0 (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->slave_type, type); +} + static gint find_setting_by_name (gconstpointer a, gconstpointer b) { @@ -550,6 +601,14 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } + if (priv->zone && !priv->zone[0]) { + g_set_error (error, + NM_SETTING_CONNECTION_ERROR, + NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_SETTING_CONNECTION_TYPE); + return FALSE; + } + /* Make sure the corresponding 'type' item is present */ if (all_settings && !g_slist_find_custom (all_settings, priv->type, find_setting_by_name)) { g_set_error (error, @@ -559,6 +618,46 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } + /* + * Bonding: Slaves are not allowed to have any IP configuration. + */ + if (priv->slave_type && all_settings && + !strcmp(priv->slave_type, NM_SETTING_BOND_SETTING_NAME)) { + GSList *list; + + list = g_slist_find_custom (all_settings, NM_SETTING_IP4_CONFIG_SETTING_NAME, + find_setting_by_name); + if (list) { + NMSettingIP4Config *s_ip4 = g_slist_nth_data (list, 0); + g_assert (s_ip4); + + if (strcmp (nm_setting_ip4_config_get_method (s_ip4), + NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { + g_set_error (error, + NM_SETTING_CONNECTION_ERROR, + NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, + "No IP configuration allowed for bonding slave"); + return FALSE; + } + } + + list = g_slist_find_custom (all_settings, NM_SETTING_IP6_CONFIG_SETTING_NAME, + find_setting_by_name); + if (list) { + NMSettingIP6Config *s_ip6 = g_slist_nth_data (list, 0); + g_assert (s_ip6); + + if (strcmp (nm_setting_ip6_config_get_method (s_ip6), + NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + g_set_error (error, + NM_SETTING_CONNECTION_ERROR, + NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, + "No IPv6 configuration allowed for bonding slave"); + return FALSE; + } + } + } + return TRUE; } @@ -591,6 +690,9 @@ finalize (GObject *object) g_free (priv->id); g_free (priv->uuid); g_free (priv->type); + g_free (priv->zone); + g_free (priv->master); + g_free (priv->slave_type); nm_utils_slist_free (priv->permissions, (GDestroyNotify) permission_free); G_OBJECT_CLASS (nm_setting_connection_parent_class)->finalize (object); @@ -644,6 +746,18 @@ set_property (GObject *object, guint prop_id, case PROP_READ_ONLY: priv->read_only = g_value_get_boolean (value); break; + case PROP_ZONE: + g_free (priv->zone); + priv->zone = g_value_dup_string (value); + break; + case PROP_MASTER: + g_free (priv->master); + priv->master = g_value_dup_string (value); + break; + case PROP_SLAVE_TYPE: + g_free (priv->slave_type); + priv->slave_type = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -689,6 +803,15 @@ get_property (GObject *object, guint prop_id, case PROP_READ_ONLY: g_value_set_boolean (value, nm_setting_connection_get_read_only (setting)); break; + case PROP_ZONE: + g_value_set_string (value, nm_setting_connection_get_zone (setting)); + break; + case PROP_MASTER: + g_value_set_string (value, nm_setting_connection_get_master (setting)); + break; + case PROP_SLAVE_TYPE: + g_value_set_string (value, nm_setting_connection_get_slave_type (setting)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -876,4 +999,55 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) "cannot yet write updated connections back out.", FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); + + /** + * NMSettingConnection:zone: + * + * The trust level of a the connection. + * Free form case-insensitive string (for example "Home", "Work", "Public"). + * NULL or unspecified zone means the connection will be placed in the + * default zone as defined by the firewall. + **/ + g_object_class_install_property + (object_class, PROP_ZONE, + g_param_spec_string (NM_SETTING_CONNECTION_ZONE, + "Zone", + "The trust level of a the connection." + "Free form case-insensitive string (for example " + "\"Home\", \"Work\", \"Public\"). NULL or " + "unspecified zone means the connection will be " + "placed in the default zone as defined by the " + "firewall.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); + + /** + * NMSettingConnection:master: + * + * Interface name of the master device or UUID of the master connection. + **/ + g_object_class_install_property + (object_class, PROP_MASTER, + g_param_spec_string (NM_SETTING_CONNECTION_MASTER, + "Master", + "Interface name of the master device or UUID of " + "the master connection", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); + + /** + * NMSettingConnection:slave-type: + * + * Setting name describing the type of slave device (ie + * #NM_SETTING_BOND_SETTING_NAME) or NULL if this connection is not a slave. + **/ + g_object_class_install_property + (object_class, PROP_SLAVE_TYPE, + g_param_spec_string (NM_SETTING_CONNECTION_SLAVE_TYPE, + "Slave-Type", + "Setting name describing the type of slave " + "this connection is (ie, 'bond') or NULL if this " + "connection is not a slave.", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); } diff --git a/libnm-util/nm-setting-connection.h b/libnm-util/nm-setting-connection.h index 1ec5bf12..19874845 100644 --- a/libnm-util/nm-setting-connection.h +++ b/libnm-util/nm-setting-connection.h @@ -49,6 +49,8 @@ G_BEGIN_DECLS * @NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND: the #NMSetting object * referenced by the setting name contained in the * #NMSettingConnection:type property was not present in the #NMConnection + * @NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED: ip configuration is not + * allowed to be present. * * Describes errors that may result from operations involving a * #NMSettingConnection. @@ -56,15 +58,13 @@ G_BEGIN_DECLS **/ typedef enum { - NM_SETTING_CONNECTION_ERROR_UNKNOWN = 0, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, - NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND + NM_SETTING_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, /*< nick=TypeSettingNotFound >*/ + NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, /*< nick=IpConfigNotAllowed >*/ } NMSettingConnectionError; -#define NM_TYPE_SETTING_CONNECTION_ERROR (nm_setting_connection_error_get_type ()) -GType nm_setting_connection_error_get_type (void); - #define NM_SETTING_CONNECTION_ERROR nm_setting_connection_error_quark () GQuark nm_setting_connection_error_quark (void); @@ -75,6 +75,16 @@ GQuark nm_setting_connection_error_quark (void); #define NM_SETTING_CONNECTION_TIMESTAMP "timestamp" #define NM_SETTING_CONNECTION_READ_ONLY "read-only" #define NM_SETTING_CONNECTION_PERMISSIONS "permissions" +#define NM_SETTING_CONNECTION_ZONE "zone" +#define NM_SETTING_CONNECTION_MASTER "master" +#define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type" + +/* Well-known zone names */ +#define NM_SETTING_CONNECTION_ZONE_TRUSTED "trusted" +#define NM_SETTING_CONNECTION_ZONE_HOME "home" +#define NM_SETTING_CONNECTION_ZONE_WORK "work" +#define NM_SETTING_CONNECTION_ZONE_PUBLIC "public" +#define NM_SETTING_CONNECTION_ZONE_BLOCK "block" /** * NMSettingConnection: @@ -112,6 +122,7 @@ gboolean nm_setting_connection_get_permission (NMSettingConnection *set const char **out_ptype, const char **out_pitem, const char **out_detail); +const char *nm_setting_connection_get_zone (NMSettingConnection *setting); gboolean nm_setting_connection_permissions_user_allowed (NMSettingConnection *setting, const char *uname); gboolean nm_setting_connection_add_permission (NMSettingConnection *setting, const char *ptype, @@ -119,6 +130,10 @@ gboolean nm_setting_connection_add_permission (NMSettingConnection *set const char *detail); void nm_setting_connection_remove_permission (NMSettingConnection *setting, guint32 idx); +const char *nm_setting_connection_get_master (NMSettingConnection *setting); +gboolean nm_setting_connection_is_slave_type (NMSettingConnection *setting, + const char *type); +const char *nm_setting_connection_get_slave_type (NMSettingConnection *setting); G_END_DECLS diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c index 80d3fd31..2264d008 100644 --- a/libnm-util/nm-setting-gsm.c +++ b/libnm-util/nm-setting-gsm.c @@ -56,31 +56,6 @@ nm_setting_gsm_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_gsm_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_GSM_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_GSM_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_GSM_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The required serial setting is missing (DEPRECATED) */ - ENUM_ENTRY (NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING, "MissingSerialSetting"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingGsmError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING) @@ -292,13 +267,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) { NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting); - if (!priv->number) { - g_set_error (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_MISSING_PROPERTY, - NM_SETTING_GSM_NUMBER); - return FALSE; - } else if (!strlen (priv->number)) { + if (priv->number && !priv->number[0]) { g_set_error (error, NM_SETTING_GSM_ERROR, NM_SETTING_GSM_ERROR_INVALID_PROPERTY, diff --git a/libnm-util/nm-setting-gsm.h b/libnm-util/nm-setting-gsm.h index 6459a4ab..af3efc2c 100644 --- a/libnm-util/nm-setting-gsm.h +++ b/libnm-util/nm-setting-gsm.h @@ -49,15 +49,12 @@ G_BEGIN_DECLS * is missing in the connection */ typedef enum { - NM_SETTING_GSM_ERROR_UNKNOWN = 0, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, - NM_SETTING_GSM_ERROR_MISSING_PROPERTY, - NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING + NM_SETTING_GSM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_GSM_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_GSM_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING /*< nick=MissingSerialSetting >*/ } NMSettingGsmError; -#define NM_TYPE_SETTING_GSM_ERROR (nm_setting_gsm_error_get_type ()) -GType nm_setting_gsm_error_get_type (void); - #define NM_SETTING_GSM_ERROR nm_setting_gsm_error_quark () GQuark nm_setting_gsm_error_quark (void); diff --git a/libnm-util/nm-setting-infiniband.c b/libnm-util/nm-setting-infiniband.c new file mode 100644 index 00000000..dbef5b8a --- /dev/null +++ b/libnm-util/nm-setting-infiniband.c @@ -0,0 +1,291 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2011 Red Hat, Inc. + */ + +#include <dbus/dbus-glib.h> +#include <linux/if_infiniband.h> + +#include "nm-setting-infiniband.h" +#include "nm-param-spec-specialized.h" +#include "nm-utils-private.h" + +/** + * SECTION:nm-setting-infiniband + * @short_description: Describes connection properties for IP-over-InfiniBand networks + * @include: nm-setting-infiniband.h + * + * The #NMSettingInfiniband object is a #NMSetting subclass that describes properties + * necessary for connection to IP-over-InfiniBand networks. + **/ + +/** + * nm_setting_infiniband_error_quark: + * + * Registers an error quark for #NMSettingInfiniband if necessary. + * + * Returns: the error quark used for #NMSettingInfiniband errors. + **/ +GQuark +nm_setting_infiniband_error_quark (void) +{ + static GQuark quark; + + if (G_UNLIKELY (!quark)) + quark = g_quark_from_static_string ("nm-setting-infiniband-error-quark"); + return quark; +} + +G_DEFINE_TYPE (NMSettingInfiniband, nm_setting_infiniband, NM_TYPE_SETTING) + +#define NM_SETTING_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandPrivate)) + +typedef struct { + GByteArray *mac_address; + char *transport_mode; + guint32 mtu; +} NMSettingInfinibandPrivate; + +enum { + PROP_0, + PROP_MAC_ADDRESS, + PROP_MTU, + PROP_TRANSPORT_MODE, + + LAST_PROP +}; + +/** + * nm_setting_infiniband_new: + * + * Creates a new #NMSettingInfiniband object with default values. + * + * Returns: (transfer full): the new empty #NMSettingInfiniband object + **/ +NMSetting * +nm_setting_infiniband_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_INFINIBAND, NULL); +} + +/** + * nm_setting_infiniband_get_mac_address: + * @setting: the #NMSettingInfiniband + * + * Returns: the #NMSettingInfiniband:mac-address property of the setting + **/ +const GByteArray * +nm_setting_infiniband_get_mac_address (NMSettingInfiniband *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), NULL); + + return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->mac_address; +} + +/** + * nm_setting_infiniband_get_mtu: + * @setting: the #NMSettingInfiniband + * + * Returns: the #NMSettingInfiniband:mtu property of the setting + **/ +guint32 +nm_setting_infiniband_get_mtu (NMSettingInfiniband *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), 0); + + return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->mtu; +} + +/** + * nm_setting_infiniband_get_transport_mode: + * @setting: the #NMSettingInfiniband + * + * Returns the transport mode for this device. Either 'datagram' or + * 'connected'. + * + * Returns: the IPoIB transport mode + **/ +const char * +nm_setting_infiniband_get_transport_mode (NMSettingInfiniband *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), NULL); + + return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->transport_mode; +} + + +static gboolean +verify (NMSetting *setting, GSList *all_settings, GError **error) +{ + NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (setting); + + if (priv->mac_address && priv->mac_address->len != INFINIBAND_ALEN) { + g_set_error (error, + NM_SETTING_INFINIBAND_ERROR, + NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_SETTING_INFINIBAND_MAC_ADDRESS); + return FALSE; + } + + if (!g_strcmp0 (priv->transport_mode, "datagram")) { + if (priv->mtu > 2044) + priv->mtu = 2044; + } else if (!g_strcmp0 (priv->transport_mode, "connected")) { + if (priv->mtu > 65520) + priv->mtu = 65520; + } else { + g_set_error (error, + NM_SETTING_INFINIBAND_ERROR, + NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_SETTING_INFINIBAND_TRANSPORT_MODE); + return FALSE; + } + + return TRUE; +} + +static void +nm_setting_infiniband_init (NMSettingInfiniband *setting) +{ + g_object_set (setting, NM_SETTING_NAME, NM_SETTING_INFINIBAND_SETTING_NAME, NULL); +} + +static void +finalize (GObject *object) +{ + NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (object); + + g_free (priv->transport_mode); + if (priv->mac_address) + g_byte_array_free (priv->mac_address, TRUE); + + G_OBJECT_CLASS (nm_setting_infiniband_parent_class)->finalize (object); +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_MAC_ADDRESS: + if (priv->mac_address) + g_byte_array_free (priv->mac_address, TRUE); + priv->mac_address = g_value_dup_boxed (value); + break; + case PROP_MTU: + priv->mtu = g_value_get_uint (value); + break; + case PROP_TRANSPORT_MODE: + g_free (priv->transport_mode); + priv->transport_mode = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMSettingInfiniband *setting = NM_SETTING_INFINIBAND (object); + + switch (prop_id) { + case PROP_MAC_ADDRESS: + g_value_set_boxed (value, nm_setting_infiniband_get_mac_address (setting)); + break; + case PROP_MTU: + g_value_set_uint (value, nm_setting_infiniband_get_mtu (setting)); + break; + case PROP_TRANSPORT_MODE: + g_value_set_string (value, nm_setting_infiniband_get_transport_mode (setting)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (setting_class); + NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class); + + g_type_class_add_private (setting_class, sizeof (NMSettingInfinibandPrivate)); + + /* virtual methods */ + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->finalize = finalize; + parent_class->verify = verify; + + /* Properties */ + /** + * NMSettingInfiniband:mac-address: + * + * If specified, this connection will only apply to the IPoIB + * device whose permanent MAC address matches. This property does + * not change the MAC address of the device (i.e. MAC spoofing). + **/ + g_object_class_install_property + (object_class, PROP_MAC_ADDRESS, + _nm_param_spec_specialized (NM_SETTING_INFINIBAND_MAC_ADDRESS, + "Device MAC Address", + "If specified, this connection will only apply to " + "the IPoIB device whose permanent MAC address matches. " + "This property does not change the MAC address " + "of the device (i.e. MAC spoofing).", + DBUS_TYPE_G_UCHAR_ARRAY, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingInfiniband:mtu: + * + * If non-zero, only transmit packets of the specified size or smaller, + * breaking larger packets up into multiple frames. + **/ + g_object_class_install_property + (object_class, PROP_MTU, + g_param_spec_uint (NM_SETTING_INFINIBAND_MTU, + "MTU", + "If non-zero, only transmit packets of the specified " + "size or smaller, breaking larger packets up into " + "multiple frames.", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); + + /** + * NMSettingInfiniband:transport-mode: + * + * The IP-over-InfiniBand transport mode. Either 'datagram' or + * 'connected'. + **/ + g_object_class_install_property + (object_class, PROP_TRANSPORT_MODE, + g_param_spec_string (NM_SETTING_INFINIBAND_TRANSPORT_MODE, + "Transport Mode", + "The IPoIB transport mode. Either 'datagram' or 'connected'.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); +} + diff --git a/libnm-util/nm-setting-infiniband.h b/libnm-util/nm-setting-infiniband.h new file mode 100644 index 00000000..dc8e8ad0 --- /dev/null +++ b/libnm-util/nm-setting-infiniband.h @@ -0,0 +1,81 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2011 Red Hat, Inc. + */ + +#ifndef NM_SETTING_INFINIBAND_H +#define NM_SETTING_INFINIBAND_H + +#include <nm-setting.h> + +G_BEGIN_DECLS + +#define NM_TYPE_SETTING_INFINIBAND (nm_setting_infiniband_get_type ()) +#define NM_SETTING_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_INFINIBAND, NMSettingInfiniband)) +#define NM_SETTING_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandClass)) +#define NM_IS_SETTING_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_INFINIBAND)) +#define NM_IS_SETTING_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING_INFINIBAND)) +#define NM_SETTING_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandClass)) + +#define NM_SETTING_INFINIBAND_SETTING_NAME "infiniband" + +/** + * NMSettingInfinibandError: + * @NM_SETTING_INFINIBAND_ERROR_UNKNOWN: unknown or unclassified error + * @NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY: the property was invalid + * @NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY: the property was missing and is + * required + */ +typedef enum { + NM_SETTING_INFINIBAND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ +} NMSettingInfinibandError; + +#define NM_SETTING_INFINIBAND_ERROR nm_setting_infiniband_error_quark () +GQuark nm_setting_infiniband_error_quark (void); + +#define NM_SETTING_INFINIBAND_MAC_ADDRESS "mac-address" +#define NM_SETTING_INFINIBAND_MTU "mtu" +#define NM_SETTING_INFINIBAND_TRANSPORT_MODE "transport-mode" + +typedef struct { + NMSetting parent; +} NMSettingInfiniband; + +typedef struct { + NMSettingClass parent; + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); +} NMSettingInfinibandClass; + +GType nm_setting_infiniband_get_type (void); + +NMSetting * nm_setting_infiniband_new (void); +const GByteArray *nm_setting_infiniband_get_mac_address (NMSettingInfiniband *setting); +guint32 nm_setting_infiniband_get_mtu (NMSettingInfiniband *setting); +const char * nm_setting_infiniband_get_transport_mode (NMSettingInfiniband *setting); + +G_END_DECLS + +#endif /* NM_SETTING_INFINIBAND_H */ diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c index 6b164ea8..54cf0364 100644 --- a/libnm-util/nm-setting-ip4-config.c +++ b/libnm-util/nm-setting-ip4-config.c @@ -57,31 +57,6 @@ nm_setting_ip4_config_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_ip4_config_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The specified property was not allowed in combination with the current 'method' */ - ENUM_ENTRY (NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, "NotAllowedForMethod"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingIP4ConfigError", values); - } - return etype; -} - #if GLIB_CHECK_VERSION(2,26,0) G_DEFINE_BOXED_TYPE (NMIP4Address, nm_ip4_address, nm_ip4_address_dup, nm_ip4_address_unref) G_DEFINE_BOXED_TYPE (NMIP4Route, nm_ip4_route, nm_ip4_route_dup, nm_ip4_route_unref) @@ -1256,7 +1231,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class) "this property to TRUE allows the overall network " "configuration to succeed if IPv4 configuration " "fails but IPv6 configuration completes successfully.", - FALSE, + TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); } diff --git a/libnm-util/nm-setting-ip4-config.h b/libnm-util/nm-setting-ip4-config.h index 76dcf37a..52fa54e1 100644 --- a/libnm-util/nm-setting-ip4-config.h +++ b/libnm-util/nm-setting-ip4-config.h @@ -49,15 +49,12 @@ G_BEGIN_DECLS * not valid with the given IP4 method */ typedef enum { - NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN = 0, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, - NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, - NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD + NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD /*< nick=NotAllowedForMethod >*/ } NMSettingIP4ConfigError; -#define NM_TYPE_SETTING_IP4_CONFIG_ERROR (nm_setting_ip4_config_error_get_type ()) -GType nm_setting_ip4_config_error_get_type (void); - #define NM_SETTING_IP4_CONFIG_ERROR nm_setting_ip4_config_error_quark () GQuark nm_setting_ip4_config_error_quark (void); diff --git a/libnm-util/nm-setting-ip6-config.c b/libnm-util/nm-setting-ip6-config.c index 4dc8f46c..45e3e635 100644 --- a/libnm-util/nm-setting-ip6-config.c +++ b/libnm-util/nm-setting-ip6-config.c @@ -19,7 +19,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2010 Red Hat, Inc. + * (C) Copyright 2007 - 2012 Red Hat, Inc. */ #include <string.h> @@ -56,31 +56,6 @@ nm_setting_ip6_config_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_ip6_config_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The specified property was not allowed in combination with the current 'method' */ - ENUM_ENTRY (NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, "NotAllowedForMethod"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingIP6ConfigError", values); - } - return etype; -} - #if GLIB_CHECK_VERSION(2,26,0) G_DEFINE_BOXED_TYPE (NMIP6Address, nm_ip6_address, nm_ip6_address_dup, nm_ip6_address_unref) G_DEFINE_BOXED_TYPE (NMIP6Route, nm_ip6_route, nm_ip6_route_dup, nm_ip6_route_unref) @@ -100,6 +75,7 @@ typedef struct { gboolean ignore_auto_dns; gboolean never_default; gboolean may_fail; + NMSettingIP6ConfigPrivacy ip6_privacy; } NMSettingIP6ConfigPrivate; @@ -114,6 +90,7 @@ enum { PROP_IGNORE_AUTO_DNS, PROP_NEVER_DEFAULT, PROP_MAY_FAIL, + PROP_IP6_PRIVACY, LAST_PROP }; @@ -642,6 +619,23 @@ nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting) return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->may_fail; } +/** + * nm_setting_ip6_config_get_ip6_privacy: + * @setting: the #NMSettingIP6Config + * + * Returns the value contained in the #NMSettingIP6Config:ip6-privacy + * property. + * + * Returns: IPv6 Privacy Extensions configuration value (#NMSettingIP6ConfigPrivacy). + **/ +NMSettingIP6ConfigPrivacy +nm_setting_ip6_config_get_ip6_privacy (NMSettingIP6Config *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE); + + return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->ip6_privacy; +} + static gboolean verify (NMSetting *setting, GSList *all_settings, GError **error) { @@ -764,6 +758,9 @@ set_property (GObject *object, guint prop_id, case PROP_MAY_FAIL: priv->may_fail = g_value_get_boolean (value); break; + case PROP_IP6_PRIVACY: + priv->ip6_privacy = g_value_get_int (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -804,6 +801,9 @@ get_property (GObject *object, guint prop_id, case PROP_MAY_FAIL: g_value_set_boolean (value, priv->may_fail); break; + case PROP_IP6_PRIVACY: + g_value_set_int (value, priv->ip6_privacy); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1058,6 +1058,35 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class) "fails but IPv4 configuration completes successfully.", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingIP6Config:ip6-privacy: + * + * Configure IPv6 Privacy Extensions for SLAAC, described in RFC4941. + * If enabled, it makes the kernel generate a temporary IPv6 address + * in addition to the public one generated from MAC address via + * modified EUI-64. This enhances privacy, but could cause problems + * in some applications, on the other hand. The permitted values + * are: 0: disabled, 1: enabled (prefer public address), + * 2: enabled (prefer temporary addresses). + **/ + g_object_class_install_property + (object_class, PROP_IP6_PRIVACY, + g_param_spec_int (NM_SETTING_IP6_CONFIG_IP6_PRIVACY, + "Configure IPv6 Privacy", + "Configure IPv6 Privacy Extensions for SLAAC, described " + "in RFC4941. If enabled, it makes the kernel generate " + "a temporary IPv6 address in addition to the public one " + "generated from MAC address via modified EUI-64. This " + "enhances privacy, but could cause problems in some " + "applications, on the other hand. The permitted values " + "are: 0: disabled, 1: enabled (prefer public address), " + "2: enabled (prefer temporary addresses).", + NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, + NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + } /********************************************************************/ diff --git a/libnm-util/nm-setting-ip6-config.h b/libnm-util/nm-setting-ip6-config.h index 6b8fe5c4..55b48b2d 100644 --- a/libnm-util/nm-setting-ip6-config.h +++ b/libnm-util/nm-setting-ip6-config.h @@ -19,7 +19,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2010 Red Hat, Inc. + * (C) Copyright 2007 - 2012 Red Hat, Inc. */ #ifndef NM_SETTING_IP6_CONFIG_H @@ -50,15 +50,12 @@ G_BEGIN_DECLS * not valid with the given IPv6 method */ typedef enum { - NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN = 0, - NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, - NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, - NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD + NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD /*< nick=NotAllowedForMethod >*/ } NMSettingIP6ConfigError; -#define NM_TYPE_SETTING_IP6_CONFIG_ERROR (nm_setting_ip6_config_error_get_type ()) -GType nm_setting_ip6_config_error_get_type (void); - #define NM_SETTING_IP6_CONFIG_ERROR nm_setting_ip6_config_error_quark () GQuark nm_setting_ip6_config_error_quark (void); @@ -71,6 +68,7 @@ GQuark nm_setting_ip6_config_error_quark (void); #define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns" #define NM_SETTING_IP6_CONFIG_NEVER_DEFAULT "never-default" #define NM_SETTING_IP6_CONFIG_MAY_FAIL "may-fail" +#define NM_SETTING_IP6_CONFIG_IP6_PRIVACY "ip6-privacy" /** * NM_SETTING_IP6_CONFIG_METHOD_IGNORE: @@ -126,6 +124,25 @@ GQuark nm_setting_ip6_config_error_quark (void); */ #define NM_SETTING_IP6_CONFIG_METHOD_SHARED "shared" +/** + * NMSettingIP6ConfigPrivacy: + * @NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN: unknown or no value specified + * @NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: IPv6 Privacy Extensions are disabled + * @NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: IPv6 Privacy Extensions + * are enabled, but public addresses are preferred over temporary addresses + * @NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: IPv6 Privacy Extensions + * are enabled and temporary addresses are preferred over public addresses + * + * #NMSettingIP6ConfigPrivacy values indicate if and how IPv6 Privacy + * Extensions are used (RFC4941). + */ +typedef enum { + NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN = -1, + NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED = 0, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR = 1, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR = 2 +} NMSettingIP6ConfigPrivacy; + typedef struct NMIP6Address NMIP6Address; @@ -224,6 +241,7 @@ gboolean nm_setting_ip6_config_get_ignore_auto_routes (NMSettingIP gboolean nm_setting_ip6_config_get_ignore_auto_dns (NMSettingIP6Config *setting); gboolean nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting); gboolean nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting); +NMSettingIP6ConfigPrivacy nm_setting_ip6_config_get_ip6_privacy (NMSettingIP6Config *setting); G_END_DECLS diff --git a/libnm-util/nm-setting-olpc-mesh.c b/libnm-util/nm-setting-olpc-mesh.c index 1653bb07..96770e4f 100644 --- a/libnm-util/nm-setting-olpc-mesh.c +++ b/libnm-util/nm-setting-olpc-mesh.c @@ -46,29 +46,6 @@ nm_setting_olpc_mesh_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_olpc_mesh_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_OLPC_MESH_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY, "MissingProperty"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingOlpcMeshError", values); - } - return etype; -} - static void nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting); G_DEFINE_TYPE (NMSettingOlpcMesh, nm_setting_olpc_mesh, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-olpc-mesh.h b/libnm-util/nm-setting-olpc-mesh.h index 84abd126..d6940401 100644 --- a/libnm-util/nm-setting-olpc-mesh.h +++ b/libnm-util/nm-setting-olpc-mesh.h @@ -43,14 +43,11 @@ G_BEGIN_DECLS typedef enum { - NM_SETTING_OLPC_MESH_ERROR_UNKNOWN = 0, - NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, - NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY + NM_SETTING_OLPC_MESH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ } NMSettingOlpcMeshError; -#define NM_TYPE_SETTING_OLPC_MESH_ERROR (nm_setting_olpc_mesh_error_get_type ()) -GType nm_setting_olpc_mesh_error_get_type (void); - #define NM_SETTING_OLPC_MESH_ERROR nm_setting_olpc_mesh_error_quark () GQuark nm_setting_olpc_mesh_error_quark (void); diff --git a/libnm-util/nm-setting-ppp.c b/libnm-util/nm-setting-ppp.c index 89338131..6b1fd5ac 100644 --- a/libnm-util/nm-setting-ppp.c +++ b/libnm-util/nm-setting-ppp.c @@ -53,31 +53,6 @@ nm_setting_ppp_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_ppp_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_PPP_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_PPP_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_PPP_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The 'require-mppe' option is not allowed in conjunction with the specified authentication. */ - ENUM_ENTRY (NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED, "RequireMPPENotAllowed"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingPPPError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingPPP, nm_setting_ppp, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-ppp.h b/libnm-util/nm-setting-ppp.h index 7a6e4e47..072dd23c 100644 --- a/libnm-util/nm-setting-ppp.h +++ b/libnm-util/nm-setting-ppp.h @@ -49,15 +49,12 @@ G_BEGIN_DECLS * with other setting configuration parameters */ typedef enum { - NM_SETTING_PPP_ERROR_UNKNOWN = 0, - NM_SETTING_PPP_ERROR_INVALID_PROPERTY, - NM_SETTING_PPP_ERROR_MISSING_PROPERTY, - NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED + NM_SETTING_PPP_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_PPP_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_PPP_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED /*< nick=RequireMPPENotAllowed >*/ } NMSettingPPPError; -#define NM_TYPE_SETTING_PPP_ERROR (nm_setting_ppp_error_get_type ()) -GType nm_setting_ppp_error_get_type (void); - #define NM_SETTING_PPP_ERROR nm_setting_ppp_error_quark () GQuark nm_setting_ppp_error_quark (void); diff --git a/libnm-util/nm-setting-pppoe.c b/libnm-util/nm-setting-pppoe.c index 4a9b8a22..e25c0926 100644 --- a/libnm-util/nm-setting-pppoe.c +++ b/libnm-util/nm-setting-pppoe.c @@ -55,31 +55,6 @@ nm_setting_pppoe_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_pppoe_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_PPPOE_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The required PPP setting is missing */ - ENUM_ENTRY (NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING, "MissingPPPSetting"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingPPPOEError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingPPPOE, nm_setting_pppoe, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-pppoe.h b/libnm-util/nm-setting-pppoe.h index aef6bd68..087e9902 100644 --- a/libnm-util/nm-setting-pppoe.h +++ b/libnm-util/nm-setting-pppoe.h @@ -49,15 +49,12 @@ G_BEGIN_DECLS * did not contain a required PPP setting for PPP related options */ typedef enum { - NM_SETTING_PPPOE_ERROR_UNKNOWN = 0, - NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, - NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY, - NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING + NM_SETTING_PPPOE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING /*< nick=MissingPPPSetting >*/ } NMSettingPPPOEError; -#define NM_TYPE_SETTING_PPPOE_ERROR (nm_setting_pppoe_error_get_type ()) -GType nm_setting_pppoe_error_get_type (void); - #define NM_SETTING_PPPOE_ERROR nm_setting_pppoe_error_quark () GQuark nm_setting_pppoe_error_quark (void); diff --git a/libnm-util/nm-setting-serial.c b/libnm-util/nm-setting-serial.c index 24e6253e..44f14986 100644 --- a/libnm-util/nm-setting-serial.c +++ b/libnm-util/nm-setting-serial.c @@ -56,31 +56,6 @@ nm_setting_serial_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_serial_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_SERIAL_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The required PPP setting is missing (DEPRECATED) */ - ENUM_ENTRY (NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING, "MissingPPPSetting"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingSerialError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingSerial, nm_setting_serial, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-serial.h b/libnm-util/nm-setting-serial.h index 9562950c..8c2a79b9 100644 --- a/libnm-util/nm-setting-serial.h +++ b/libnm-util/nm-setting-serial.h @@ -49,15 +49,12 @@ G_BEGIN_DECLS * setting requires the connection to contain an #NMSettingPPP setting */ typedef enum { - NM_SETTING_SERIAL_ERROR_UNKNOWN = 0, - NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY, - NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY, - NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING + NM_SETTING_SERIAL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING /*< nick=MissingPPPSetting >*/ } NMSettingSerialError; -#define NM_TYPE_SETTING_SERIAL_ERROR (nm_setting_serial_error_get_type ()) -GType nm_setting_serial_error_get_type (void); - #define NM_SETTING_SERIAL_ERROR nm_setting_serial_error_quark () GQuark nm_setting_serial_error_quark (void); diff --git a/libnm-util/nm-setting-vlan.c b/libnm-util/nm-setting-vlan.c new file mode 100644 index 00000000..71760dca --- /dev/null +++ b/libnm-util/nm-setting-vlan.c @@ -0,0 +1,728 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * Weiping Pan <wpan@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 Red Hat, Inc. + */ + +#include <dbus/dbus-glib.h> +#include "nm-setting-vlan.h" +#include "nm-param-spec-specialized.h" +#include "nm-utils.h" +#include "nm-dbus-glib-types.h" +#include "nm-setting-connection.h" + +/** + * SECTION:nm-setting-vlan + * @short_description: Describes connection properties for VLAN interfaces + * @include: nm-setting-vlan.h + * + * The #NMSettingVlan object is a #NMSetting subclass that describes properties + * necessary for connection to VLAN interfaces. + **/ + +/** + * nm_setting_vlan_error_quark: + * + * Registers an error quark for #NMSettingVlan if necessary. + * + * Returns: the error quark used for #NMSettingVlan errors. + **/ +GQuark +nm_setting_vlan_error_quark (void) +{ + static GQuark quark; + + if (G_UNLIKELY (!quark)) + quark = g_quark_from_static_string ("nm-setting-vlan-error-quark"); + return quark; +} + +G_DEFINE_TYPE (NMSettingVlan, nm_setting_vlan, NM_TYPE_SETTING) + +#define NM_SETTING_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VLAN, NMSettingVlanPrivate)) + +typedef struct { + char *iface_name; + char *parent; + guint32 id; + guint32 flags; + GSList *ingress_priority_map; + GSList *egress_priority_map; +} NMSettingVlanPrivate; + +enum { + PROP_0, + PROP_IFACE_NAME, + PROP_PARENT, + PROP_ID, + PROP_FLAGS, + PROP_INGRESS_PRIORITY_MAP, + PROP_EGRESS_PRIORITY_MAP, + LAST_PROP +}; + +#define MAX_SKB_PRIO G_MAXUINT32 +#define MAX_8021P_PRIO 7 /* Max 802.1p priority */ + +typedef struct { + guint32 from; + guint32 to; +} PriorityMap; + +/** + * nm_setting_vlan_new: + * Creates a new #NMSettingVlan object with default values. + * + * Returns: (transfer full): the new empty #NMSettingVlan object + **/ +NMSetting * +nm_setting_vlan_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_VLAN, NULL); +} + +/** + * nm_setting_vlan_get_interface_name: + * @setting: the #NMSettingVlan + * + * Returns: the #NMSettingVlan:interface_name property of the setting + **/ +const char * +nm_setting_vlan_get_interface_name (NMSettingVlan *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), NULL); + return NM_SETTING_VLAN_GET_PRIVATE (setting)->iface_name; +} + +/** + * nm_setting_vlan_get_parent: + * @setting: the #NMSettingVlan + * + * Returns: the #NMSettingVlan:parent property of the setting + **/ +const char * +nm_setting_vlan_get_parent (NMSettingVlan *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), NULL); + return NM_SETTING_VLAN_GET_PRIVATE (setting)->parent; +} + +/** + * nm_setting_vlan_get_id: + * @setting: the #NMSettingVlan + * + * Returns: the #NMSettingVlan:id property of the setting + **/ +guint32 +nm_setting_vlan_get_id (NMSettingVlan *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), 0); + return NM_SETTING_VLAN_GET_PRIVATE (setting)->id; +} + +/** + * nm_setting_vlan_get_flags: + * @setting: the #NMSettingVlan + * + * Returns: the #NMSettingVlan:flags property of the setting + **/ +guint32 +nm_setting_vlan_get_flags (NMSettingVlan *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), 0); + return NM_SETTING_VLAN_GET_PRIVATE (setting)->flags; +} + +static guint32 +get_max_prio (NMVlanPriorityMap map, gboolean from) +{ + if (map == NM_VLAN_INGRESS_MAP) + return from ? MAX_8021P_PRIO : MAX_SKB_PRIO; + else if (map == NM_VLAN_EGRESS_MAP) + return from ? MAX_SKB_PRIO : MAX_8021P_PRIO; + g_assert_not_reached (); +} + +static PriorityMap * +priority_map_new_from_str (NMVlanPriorityMap map, const char *str) +{ + PriorityMap *p = NULL; + gchar **t = NULL; + guint32 len; + guint64 from, to; + + g_return_val_if_fail (str && str[0], NULL); + + t = g_strsplit (str, ":", 0); + len = g_strv_length (t); + if (len == 2) { + from = g_ascii_strtoull (t[0], NULL, 10); + to = g_ascii_strtoull (t[1], NULL, 10); + + if ((from <= get_max_prio (map, TRUE)) && (to <= get_max_prio (map, FALSE))) { + p = g_malloc0 (sizeof (PriorityMap)); + p->from = from; + p->to = to; + } + } else { + /* Warn */ + g_warn_if_fail (len == 2); + } + + g_strfreev (t); + return p; +} + +static void +priority_map_free (PriorityMap *map) +{ + g_return_if_fail (map != NULL); + g_free (map); +} + +static GSList * +get_map (NMSettingVlan *self, NMVlanPriorityMap map) +{ + if (map == NM_VLAN_INGRESS_MAP) + return NM_SETTING_VLAN_GET_PRIVATE (self)->ingress_priority_map; + else if (map == NM_VLAN_EGRESS_MAP) + return NM_SETTING_VLAN_GET_PRIVATE (self)->egress_priority_map; + g_assert_not_reached (); + return NULL; +} + +static void +set_map (NMSettingVlan *self, NMVlanPriorityMap map, GSList *list) +{ + if (map == NM_VLAN_INGRESS_MAP) + NM_SETTING_VLAN_GET_PRIVATE (self)->ingress_priority_map = list; + else if (map == NM_VLAN_EGRESS_MAP) + NM_SETTING_VLAN_GET_PRIVATE (self)->egress_priority_map = list; + else + g_assert_not_reached (); +} + +/** + * nm_setting_vlan_add_priority_str + * @setting: the #NMSettingVlan + * @map: the type of priority map + * @str: the string which contains a priority map, like "3:7" + * + * Adds a priority map entry into either the #NMSettingVlan:ingress_priority_map + * or the #NMSettingVlan:egress_priority_map properties. The priority map maps + * the Linux SKB priorities to 802.1p priorities. + * + * Returns: TRUE if the entry was successfully added to the list, or it + * overwrote the old value, FALSE if error + */ +gboolean +nm_setting_vlan_add_priority_str (NMSettingVlan *setting, + NMVlanPriorityMap map, + const char *str) +{ + NMSettingVlanPrivate *priv = NULL; + GSList *list = NULL, *iter = NULL; + PriorityMap *item = NULL; + + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE); + g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE); + g_return_val_if_fail (str && str[0], FALSE); + + priv = NM_SETTING_VLAN_GET_PRIVATE (setting); + list = get_map (setting, map); + + item = priority_map_new_from_str (map, str); + g_return_val_if_fail (item != NULL, FALSE); + + /* Duplicates get replaced */ + for (iter = list; iter; iter = g_slist_next (iter)) { + PriorityMap *p = iter->data; + + if (p->from == item->from) { + p->to = item->to; + g_free (item); + return TRUE; + } + } + + set_map (setting, map, g_slist_append (list, item)); + return TRUE; +} + +/** + * nm_setting_vlan_get_num_priorities: + * @map: the type of priority map + * @setting: the #NMSettingVlan + * + * Returns the number of entires in the + * #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map + * properties of this setting. + * + * Returns: return the number of ingress/egress priority entries, -1 if error + **/ +gint32 +nm_setting_vlan_get_num_priorities (NMSettingVlan *setting, NMVlanPriorityMap map) +{ + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), -1); + g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, -1); + + return g_slist_length (get_map (setting, map)); +} + +/** + * nm_setting_vlan_get_priority: + * @map: the type of priority map + * @setting: the #NMSettingVlan + * @idx: the zero-based index of the ingress/egress priority map entry + * @out_from: (out): on return the value of the priority map's 'from' item + * @out_to: (out): on return the value of priority map's 'to' item + * + * Retrieve one of the entries of the #NMSettingVlan:ingress_priority_map + * or #NMSettingVlan:egress_priority_map properties of this setting. + * + * Returns: %TRUE if a priority map was returned, %FALSE if error + **/ +gboolean +nm_setting_vlan_get_priority (NMSettingVlan *setting, + NMVlanPriorityMap map, + guint32 idx, + guint32 *out_from, + guint32 *out_to) +{ + GSList *list = NULL; + PriorityMap *item = NULL; + + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE); + g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE); + g_return_val_if_fail (out_from != NULL, FALSE); + g_return_val_if_fail (out_to != NULL, FALSE); + + list = get_map (setting, map); + g_return_val_if_fail (idx < g_slist_length (list), FALSE); + + item = g_slist_nth_data (list, idx); + g_assert (item); + *out_from = item->from; + *out_to = item->to; + return TRUE; +} + +/** + * nm_setting_vlan_add_priority: + * @map: the type of priority map + * @setting: the #NMSettingVlan + * @from: the priority to map to @to + * @to: the priority to map @from to + * + * Adds a priority mapping to the #NMSettingVlan:ingress_priority_map or + * #NMSettingVlan:egress_priority_map properties of the setting. If @from is + * already in the given priority map, this function will overwrite the + * existing entry with the new @to. + * + * If @map is #NM_VLAN_INGRESS_MAP then @from is the incoming 802.1q VLAN + * Priority Code Point (PCP) value, and @to is the Linux SKB priority value. + * + * If @map is #NM_VLAN_EGRESS_MAP then @from is the Linux SKB priority value and + * @to is the outgoing 802.1q VLAN Priority Code Point (PCP) value. + * + * Returns: TRUE if the new priority mapping was successfully added to the + * list, FALSE if error + */ +gboolean +nm_setting_vlan_add_priority (NMSettingVlan *setting, + NMVlanPriorityMap map, + guint32 from, + guint32 to) +{ + GSList *list = NULL, *iter = NULL; + PriorityMap *item; + + g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE); + g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE); + + list = get_map (setting, map); + for (iter = list; iter; iter = g_slist_next (iter)) { + item = iter->data; + if (item->from == from) { + item->to = to; + return TRUE; + } + } + + item = g_malloc0 (sizeof (PriorityMap)); + item->from = from; + item->to = to; + set_map (setting, map, g_slist_append (list, item)); + + return TRUE; +} + +/** + * nm_setting_vlan_remove_priority: + * @map: the type of priority map + * @setting: the #NMSettingVlan + * @idx: the zero-based index of the priority map to remove + * + * Removes the priority map at index @idx from the + * #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map + * properties. + */ +void +nm_setting_vlan_remove_priority (NMSettingVlan *setting, + NMVlanPriorityMap map, + guint32 idx) +{ + GSList *list = NULL, *item = NULL; + + g_return_if_fail (NM_IS_SETTING_VLAN (setting)); + g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP); + + list = get_map (setting, map); + g_return_if_fail (idx < g_slist_length (list)); + + item = g_slist_nth_data (list, idx); + priority_map_free ((PriorityMap *) item); + set_map (setting, map, g_slist_delete_link (list, item)); +} + +/** + * nm_setting_vlan_clear_priorities: + * @map: the type of priority map + * @setting: the #NMSettingVlan + * + * Clear all the entires from #NMSettingVlan:ingress_priority_map or + * #NMSettingVlan:egress_priority_map properties. + */ +void +nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map) +{ + GSList *list = NULL; + + g_return_if_fail (NM_IS_SETTING_VLAN (setting)); + g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP); + + list = get_map (setting, map); + nm_utils_slist_free (list, g_free); + set_map (setting, map, NULL); +} + +/*********************************************************************/ + +static void +nm_setting_vlan_init (NMSettingVlan *setting) +{ + g_object_set (setting, NM_SETTING_NAME, NM_SETTING_VLAN_SETTING_NAME, NULL); +} + +static gboolean +verify (NMSetting *setting, GSList *all_settings, GError **error) +{ + NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); + + if (priv->iface_name && !priv->iface_name[0]) { + g_set_error (error, + NM_SETTING_VLAN_ERROR, + NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, + NM_SETTING_VLAN_INTERFACE_NAME); + return FALSE; + } + + if (priv->parent && !priv->parent[0]) { + g_set_error (error, + NM_SETTING_VLAN_ERROR, + NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, + NM_SETTING_VLAN_PARENT); + return FALSE; + } + + if (priv->id > 4095) { + g_set_error (error, + NM_SETTING_VLAN_ERROR, + NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, + NM_SETTING_VLAN_ID); + return FALSE; + } + + if (priv->flags & !(NM_VLAN_FLAG_REORDER_HEADERS | + NM_VLAN_FLAG_GVRP | + NM_VLAN_FLAG_LOOSE_BINDING)) { + g_set_error (error, + NM_SETTING_VLAN_ERROR, + NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, + NM_SETTING_VLAN_FLAGS); + return FALSE; + } + + return TRUE; +} + +static const char * +get_virtual_iface_name (NMSetting *setting) +{ + return nm_setting_vlan_get_interface_name (NM_SETTING_VLAN (setting)); +} + +static GSList * +priority_stringlist_to_maplist (NMVlanPriorityMap map, GSList *strlist) +{ + GSList *list = NULL, *iter; + + for (iter = strlist; iter; iter = g_slist_next (iter)) { + PriorityMap *item; + + item = priority_map_new_from_str (map, (const char *) iter->data); + if (item) + list = g_slist_prepend (list, item); + } + return g_slist_reverse (list); +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMSettingVlan *setting = NM_SETTING_VLAN (object); + NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); + + switch (prop_id) { + case PROP_IFACE_NAME: + g_free (priv->iface_name); + priv->iface_name = g_value_dup_string (value); + break; + case PROP_PARENT: + g_free (priv->parent); + priv->parent = g_value_dup_string (value); + break; + case PROP_ID: + priv->id = g_value_get_uint (value); + break; + case PROP_FLAGS: + priv->flags = g_value_get_uint (value); + break; + case PROP_INGRESS_PRIORITY_MAP: + nm_utils_slist_free (priv->ingress_priority_map, g_free); + priv->ingress_priority_map = + priority_stringlist_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value)); + break; + case PROP_EGRESS_PRIORITY_MAP: + nm_utils_slist_free (priv->egress_priority_map, g_free); + priv->egress_priority_map = + priority_stringlist_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GSList * +priority_maplist_to_stringlist (GSList *list) +{ + GSList *strlist = NULL, *iter; + + for (iter = list; iter; iter = g_slist_next (iter)) { + PriorityMap *item = iter->data; + + strlist = g_slist_prepend (strlist, g_strdup_printf ("%d:%d", item->from, item->to)); + } + return g_slist_reverse (strlist); +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMSettingVlan *setting = NM_SETTING_VLAN (object); + NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); + + switch (prop_id) { + case PROP_IFACE_NAME: + g_value_set_string (value, priv->iface_name); + break; + case PROP_PARENT: + g_value_set_string (value, priv->parent); + break; + case PROP_ID: + g_value_set_uint (value, priv->id); + break; + case PROP_FLAGS: + g_value_set_uint (value, priv->flags); + break; + case PROP_INGRESS_PRIORITY_MAP: + g_value_take_boxed (value, priority_maplist_to_stringlist (priv->ingress_priority_map)); + break; + case PROP_EGRESS_PRIORITY_MAP: + g_value_take_boxed (value, priority_maplist_to_stringlist (priv->egress_priority_map)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +finalize (GObject *object) +{ + NMSettingVlan *setting = NM_SETTING_VLAN (object); + NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); + + g_free (priv->iface_name); + g_free (priv->parent); + nm_utils_slist_free (priv->ingress_priority_map, g_free); + nm_utils_slist_free (priv->egress_priority_map, g_free); +} + +static void +nm_setting_vlan_class_init (NMSettingVlanClass *setting_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (setting_class); + NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class); + + g_type_class_add_private (setting_class, sizeof (NMSettingVlanPrivate)); + + /* virtual methods */ + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->finalize = finalize; + parent_class->verify = verify; + parent_class->get_virtual_iface_name = get_virtual_iface_name; + + /* Properties */ + + /** + * NMSettingVlan:interface-name: + * + * If given, specifies the kernel name of the VLAN interface. If not given, + * a default name will be constructed from the interface described by the + * parent interface and the #NMSettingVlan:id , ex 'eth2.1'. The parent + * interface may be given by the #NMSettingVlan:parent property or by a + * hardware address property, eg #NMSettingWired:mac-address or + * #NMSettingInfiniband:mac-address. + **/ + g_object_class_install_property + (object_class, PROP_IFACE_NAME, + g_param_spec_string (NM_SETTING_VLAN_INTERFACE_NAME, + "InterfaceName", + "If given, specifies the kernel name of the VLAN " + "interface. If not given, a default name will be " + "constructed from the interface described by the " + "parent interface and the 'id' property, ex " + "'eth2.1'. The parent interface may be given by " + "the 'parent' property or by a hardware address " + "property, eg the 'wired' or 'infiniband' " + "settings' 'mac-address' property.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingVlan:parent: + * + * If given, specifies the parent interface name or parent connection UUID + * from which this VLAN interface should be created. If this property is + * not specified, the connection must contain a hardware address in a + * hardware-specific setting, like #NMSettingWired:mac-address or + * #NMSettingInfiniband:mac-address. + **/ + g_object_class_install_property + (object_class, PROP_PARENT, + g_param_spec_string (NM_SETTING_VLAN_PARENT, + "Parent", + "If given, specifies the parent interface name or " + "parent connection UUID from which this VLAN " + "interface should be created. If this property is " + "not specified, the connection must contain a " + "hardware address in a hardware-specific setting, " + "like the 'wired' or 'infiniband' settings' " + "'mac-address' property.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingVlan:id: + * + * The VLAN identifier the interface created by this connection should be + * assigned. + **/ + g_object_class_install_property + (object_class, PROP_ID, + g_param_spec_uint (NM_SETTING_VLAN_ID, + "VLAN ID", + "The VLAN indentifier the interface created by " + "this connection should be assigned.", + 0, 4095, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingVlan:flags: + * + * One or more of %NMVlanFlags which control the behavior and features of + * the VLAN interface. + **/ + g_object_class_install_property + (object_class, PROP_FLAGS, + g_param_spec_uint (NM_SETTING_VLAN_FLAGS, + "VLAN flags", + "One or more flags which control the behavior and " + "features of the VLAN interface. Flags include " + "reordering of output packet headers (0x01), use " + "of the GVRP protocol (0x02), and loose binding " + "of the interface to its master device's operating " + "state (0x04).", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingVlan:ingress-priority-map: + * + * For incoming packets, a list of mappings from 802.1p priorities to Linux + * SKB priorities. The mapping is given in the format 'from:to' where both + * 'from' and 'to' are unsigned integers, ie '7:3'. + **/ + g_object_class_install_property + (object_class, PROP_INGRESS_PRIORITY_MAP, + _nm_param_spec_specialized (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, + "VLAN ingress priority mapping", + "For incoming packets, a list of mappings " + "from 802.1p priorities to Linux SKB " + "priorities. The mapping is given in the " + "format 'from:to' where both 'from' and " + "'to' are unsigned integers, ie '7:3'.", + DBUS_TYPE_G_LIST_OF_STRING, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingVlan:egress-priority-map: + * + * For outgoing packets, a list of mappings from Linux SKB priorities to + * 802.1p priorities. The mapping is given in the format 'from:to' + * where both 'from' and 'to' are unsigned integers, ie '7:3'. + **/ + g_object_class_install_property + (object_class, PROP_EGRESS_PRIORITY_MAP, + _nm_param_spec_specialized (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, + "VLAN egress priority mapping", + "For outgoing packets, a list of mappings " + "from Linux SKB priorities to 802.1p " + "priorities. The mapping is given in the " + "format 'from:to' where both 'from' and " + "'to' are unsigned integers, ie '7:3'.", + DBUS_TYPE_G_LIST_OF_STRING, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); +} diff --git a/libnm-util/nm-setting-vlan.h b/libnm-util/nm-setting-vlan.h new file mode 100644 index 00000000..18c7ed29 --- /dev/null +++ b/libnm-util/nm-setting-vlan.h @@ -0,0 +1,144 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * Weiping Pan <wpan@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 Red Hat, Inc. + */ + +#ifndef NM_SETTING_VLAN_H +#define NM_SETTING_VLAN_H + +#include "nm-setting.h" +#include <linux/if_vlan.h> + +G_BEGIN_DECLS + +#define NM_TYPE_SETTING_VLAN (nm_setting_vlan_get_type ()) +#define NM_SETTING_VLAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlan)) +#define NM_SETTING_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_VLANCONFIG, NMSettingVlanClass)) +#define NM_IS_SETTING_VLAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_VLAN)) +#define NM_IS_SETTING_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING_VLAN)) +#define NM_SETTING_VLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlanClass)) + +#define NM_SETTING_VLAN_SETTING_NAME "vlan" + +/** + * NMSettingVlanError: + * @NM_SETTING_VLAN_ERROR_UNKNOWN: unknown or unclassified error + * @NM_SETTING_VLAN_ERROR_INVALID_PROPERTY: the property was invalid + * @NM_SETTING_VLAN_ERROR_MISSING_PROPERTY: the property was missing and is + * required + */ +typedef enum { + NM_SETTING_VLAN_ERROR_UNKNOWN = 0, /*< nick=Unknown >*/ + NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_VLAN_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ +} NMSettingVlanError; + +#define NM_SETTING_VLAN_ERROR nm_setting_vlan_error_quark () +GQuark nm_setting_vlan_error_quark (void); + +#define NM_SETTING_VLAN_INTERFACE_NAME "interface-name" +#define NM_SETTING_VLAN_PARENT "parent" +#define NM_SETTING_VLAN_ID "id" +#define NM_SETTING_VLAN_FLAGS "flags" +#define NM_SETTING_VLAN_INGRESS_PRIORITY_MAP "ingress-priority-map" +#define NM_SETTING_VLAN_EGRESS_PRIORITY_MAP "egress-priority-map" + +typedef struct { + NMSetting parent; +} NMSettingVlan; + +typedef struct { + NMSettingClass parent; + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); +} NMSettingVlanClass; + +/** + * NMVlanPriorityMap: + * @NM_VLAN_INGRESS_MAP: map for incoming data + * @NM_VLAN_EGRESS_MAP: map for outgoing data + * + * A selector for traffic priority maps; these map Linux SKB priorities + * to 802.1p priorities used in VLANs. + **/ +typedef enum { + NM_VLAN_INGRESS_MAP, + NM_VLAN_EGRESS_MAP +} NMVlanPriorityMap; + +/** + * NMVlanFlags: + * @NM_VLAN_FLAG_REORDER_HEADERS: indicates that this interface should reorder + * outgoing packet headers to look more like a non-VLAN ethernet interface + * @NM_VLAN_FLAG_GVRP: indicates that this interface should use GVRP to register + * itself with it's switch + * @NM_VLAN_FLAG_LOOSE_BINDING: indicates that this interface's operating + * state is tied to the underlying network interface but other details + * (like routing) are not. + * + * #NMVlanFlags values control the behavior of the VLAN interface. + **/ +typedef enum { + NM_VLAN_FLAG_REORDER_HEADERS = 0x1, + NM_VLAN_FLAG_GVRP = 0x2, + NM_VLAN_FLAG_LOOSE_BINDING = 0x4, + + /* NOTE: if adding flags update nm-setting-vlan.c::verify() */ +} NMVlanFlags; + +GType nm_setting_vlan_get_type (void); +NMSetting *nm_setting_vlan_new (void); + +const char *nm_setting_vlan_get_interface_name (NMSettingVlan *setting); +const char *nm_setting_vlan_get_parent (NMSettingVlan *setting); +guint32 nm_setting_vlan_get_id (NMSettingVlan *setting); +guint32 nm_setting_vlan_get_flags (NMSettingVlan *setting); + +gint32 nm_setting_vlan_get_num_priorities (NMSettingVlan *setting, NMVlanPriorityMap map); + +gboolean nm_setting_vlan_get_priority (NMSettingVlan *setting, + NMVlanPriorityMap map, + guint32 idx, + guint32 *out_from, + guint32 *out_to); + +gboolean nm_setting_vlan_add_priority (NMSettingVlan *setting, + NMVlanPriorityMap map, + guint32 from, + guint32 to); + +void nm_setting_vlan_remove_priority (NMSettingVlan *setting, + NMVlanPriorityMap map, + guint32 idx); + +void nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map); + +gboolean nm_setting_vlan_add_priority_str (NMSettingVlan *setting, + NMVlanPriorityMap map, + const char *str); + +G_END_DECLS + +#endif /* NM_SETTING_VLAN_H */ diff --git a/libnm-util/nm-setting-vpn.c b/libnm-util/nm-setting-vpn.c index 755c1a45..d1fc8b76 100644 --- a/libnm-util/nm-setting-vpn.c +++ b/libnm-util/nm-setting-vpn.c @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2011 Red Hat, Inc. + * (C) Copyright 2007 - 2012 Red Hat, Inc. * (C) Copyright 2007 - 2008 Novell, Inc. */ @@ -63,29 +63,6 @@ nm_setting_vpn_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_vpn_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_VPN_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_VPN_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_VPN_ERROR_MISSING_PROPERTY, "MissingProperty"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingVpnError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingVPN, nm_setting_vpn, NM_TYPE_SETTING) @@ -174,6 +151,22 @@ nm_setting_vpn_get_user_name (NMSettingVPN *setting) } /** + * nm_setting_vpn_get_num_data_items: + * @setting: the #NMSettingVPN + * + * Gets number of key/value pairs of VPN configuration data. + * + * Returns: the number of VPN plugin specific configuration data items + **/ +guint32 +nm_setting_vpn_get_num_data_items (NMSettingVPN *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0); + + return g_hash_table_size (NM_SETTING_VPN_GET_PRIVATE (setting)->data); +} + +/** * nm_setting_vpn_add_data_item: * @setting: the #NMSettingVPN * @key: a name that uniquely identifies the given value @item @@ -284,6 +277,22 @@ nm_setting_vpn_foreach_data_item (NMSettingVPN *setting, } /** + * nm_setting_vpn_get_num_secrets: + * @setting: the #NMSettingVPN + * + * Gets number of VPN plugin specific secrets in the setting. + * + * Returns: the number of VPN plugin specific secrets + **/ +guint32 +nm_setting_vpn_get_num_secrets (NMSettingVPN *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0); + + return g_hash_table_size (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets); +} + +/** * nm_setting_vpn_add_secret: * @setting: the #NMSettingVPN * @key: a name that uniquely identifies the given secret @secret @@ -779,7 +788,7 @@ nm_setting_vpn_class_init (NMSettingVPNClass *setting_class) G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); /** - * NMSettinVPN:user-name: + * NMSettingVPN:user-name: * * If the VPN connection requires a user name for authentication, that name * should be provided here. If the connection is available to more than diff --git a/libnm-util/nm-setting-vpn.h b/libnm-util/nm-setting-vpn.h index 94fd650f..59068f88 100644 --- a/libnm-util/nm-setting-vpn.h +++ b/libnm-util/nm-setting-vpn.h @@ -47,14 +47,11 @@ G_BEGIN_DECLS * required */ typedef enum { - NM_SETTING_VPN_ERROR_UNKNOWN = 0, - NM_SETTING_VPN_ERROR_INVALID_PROPERTY, - NM_SETTING_VPN_ERROR_MISSING_PROPERTY, + NM_SETTING_VPN_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_VPN_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_VPN_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ } NMSettingVpnError; -#define NM_TYPE_SETTING_VPN_ERROR (nm_setting_vpn_error_get_type ()) -GType nm_setting_vpn_error_get_type (void); - #define NM_SETTING_VPN_ERROR nm_setting_vpn_error_quark () GQuark nm_setting_vpn_error_quark (void); @@ -92,6 +89,7 @@ NMSetting *nm_setting_vpn_new (void); const char *nm_setting_vpn_get_service_type (NMSettingVPN *setting); const char *nm_setting_vpn_get_user_name (NMSettingVPN *setting); +guint32 nm_setting_vpn_get_num_data_items (NMSettingVPN *setting); void nm_setting_vpn_add_data_item (NMSettingVPN *setting, const char *key, const char *item); @@ -103,6 +101,7 @@ void nm_setting_vpn_foreach_data_item (NMSettingVPN *setting, NMVPNIterFunc func, gpointer user_data); +guint32 nm_setting_vpn_get_num_secrets (NMSettingVPN *setting); void nm_setting_vpn_add_secret (NMSettingVPN *setting, const char *key, const char *secret); diff --git a/libnm-util/nm-setting-wimax.c b/libnm-util/nm-setting-wimax.c index 38a442f6..a099cad2 100644 --- a/libnm-util/nm-setting-wimax.c +++ b/libnm-util/nm-setting-wimax.c @@ -53,29 +53,6 @@ nm_setting_wimax_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_wimax_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_WIMAX_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY, "MissingProperty"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingWimaxError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingWimax, nm_setting_wimax, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-wimax.h b/libnm-util/nm-setting-wimax.h index 2462ac06..be3a47e5 100644 --- a/libnm-util/nm-setting-wimax.h +++ b/libnm-util/nm-setting-wimax.h @@ -43,14 +43,11 @@ G_BEGIN_DECLS * required */ typedef enum { - NM_SETTING_WIMAX_ERROR_UNKNOWN = 0, - NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, - NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY + NM_SETTING_WIMAX_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ } NMSettingWimaxError; -#define NM_TYPE_SETTING_WIMAX_ERROR (nm_setting_wimax_error_get_type ()) -GType nm_setting_wimax_error_get_type (void); - #define NM_SETTING_WIMAX_ERROR nm_setting_wimax_error_quark () GQuark nm_setting_wimax_error_quark (void); diff --git a/libnm-util/nm-setting-wired.c b/libnm-util/nm-setting-wired.c index d4e52e03..fb21711d 100644 --- a/libnm-util/nm-setting-wired.c +++ b/libnm-util/nm-setting-wired.c @@ -61,29 +61,6 @@ nm_setting_wired_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_wired_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_WIRED_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_WIRED_ERROR_MISSING_PROPERTY, "MissingProperty"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingWiredError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingWired, nm_setting_wired, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-wired.h b/libnm-util/nm-setting-wired.h index 36799fbe..0189785f 100644 --- a/libnm-util/nm-setting-wired.h +++ b/libnm-util/nm-setting-wired.h @@ -47,14 +47,11 @@ G_BEGIN_DECLS * required */ typedef enum { - NM_SETTING_WIRED_ERROR_UNKNOWN = 0, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, - NM_SETTING_WIRED_ERROR_MISSING_PROPERTY + NM_SETTING_WIRED_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_WIRED_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ } NMSettingWiredError; -#define NM_TYPE_SETTING_WIRED_ERROR (nm_setting_wired_error_get_type ()) -GType nm_setting_wired_error_get_type (void); - #define NM_SETTING_WIRED_ERROR nm_setting_wired_error_quark () GQuark nm_setting_wired_error_quark (void); diff --git a/libnm-util/nm-setting-wireless-security.c b/libnm-util/nm-setting-wireless-security.c index cb9a6081..98473120 100644 --- a/libnm-util/nm-setting-wireless-security.c +++ b/libnm-util/nm-setting-wireless-security.c @@ -75,37 +75,6 @@ nm_setting_wireless_security_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_wireless_security_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The required 802.1x setting is missing */ - ENUM_ENTRY (NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING, "Missing8021xSetting"), - /* The LEAP authentication algorithm requires use of 802.1x key management. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, "LEAPRequires8021x"), - /* The LEAP authentication algorithm requires a username. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, "LEAPRequiresUsername"), - /* Shared Key authentication can only be used with WEP encryption. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP, "SharedKeyRequiresWEP"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingWirelessSecurityError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-wireless-security.h b/libnm-util/nm-setting-wireless-security.h index 5f23893a..54dfcce8 100644 --- a/libnm-util/nm-setting-wireless-security.h +++ b/libnm-util/nm-setting-wireless-security.h @@ -56,18 +56,15 @@ G_BEGIN_DECLS * encryption protocol */ typedef enum { - NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN = 0, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY, - NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING, - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, - NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP + NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING, /*< nick=Missing8021xSetting >*/ + NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, /*< nick=LEAPRequires8021x >*/ + NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, /*< nick=LEAPRequiresUsername >*/ + NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP /*< nick=SharedKeyRequiresWEP >*/ } NMSettingWirelessSecurityError; -#define NM_TYPE_SETTING_WIRELESS_SECURITY_ERROR (nm_setting_wireless_security_error_get_type ()) -GType nm_setting_wireless_security_error_get_type (void); - #define NM_SETTING_WIRELESS_SECURITY_ERROR nm_setting_wireless_security_error_quark () GQuark nm_setting_wireless_security_error_quark (void); diff --git a/libnm-util/nm-setting-wireless.c b/libnm-util/nm-setting-wireless.c index 37ad07ab..31882516 100644 --- a/libnm-util/nm-setting-wireless.c +++ b/libnm-util/nm-setting-wireless.c @@ -28,8 +28,6 @@ #include <netinet/ether.h> #include <dbus/dbus-glib.h> -#include "wireless-helper.h" - #include "NetworkManager.h" #include "nm-setting-wireless.h" #include "nm-param-spec-specialized.h" @@ -63,33 +61,6 @@ nm_setting_wireless_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_wireless_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_ERROR_UNKNOWN, "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The required security setting is missing */ - ENUM_ENTRY (NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING, "MissingSecuritySetting"), - /* The 'channel' property requires a valid 'band' */ - ENUM_ENTRY (NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND, "ChannelRequiresBand"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingWirelessError", values); - } - return etype; -} - G_DEFINE_TYPE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING) diff --git a/libnm-util/nm-setting-wireless.h b/libnm-util/nm-setting-wireless.h index 746466be..3182f419 100644 --- a/libnm-util/nm-setting-wireless.h +++ b/libnm-util/nm-setting-wireless.h @@ -53,16 +53,13 @@ G_BEGIN_DECLS * set to a value that requires the #NMSettingWireless:band property to be set */ typedef enum { - NM_SETTING_WIRELESS_ERROR_UNKNOWN = 0, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, - NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY, - NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING, - NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND + NM_SETTING_WIRELESS_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ + NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING, /*< nick=MissingSecuritySetting >*/ + NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND /*< nick=ChannelRequiresBand >*/ } NMSettingWirelessError; -#define NM_TYPE_SETTING_WIRELESS_ERROR (nm_setting_wireless_error_get_type ()) -GType nm_setting_wireless_error_get_type (void); - #define NM_SETTING_WIRELESS_ERROR nm_setting_wireless_error_quark () GQuark nm_setting_wireless_error_quark (void); diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c index 2b3bdc58..21dab0ba 100644 --- a/libnm-util/nm-setting.c +++ b/libnm-util/nm-setting.c @@ -60,27 +60,6 @@ nm_setting_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_setting_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (NM_SETTING_ERROR_UNKNOWN, "UnknownError"), - ENUM_ENTRY (NM_SETTING_ERROR_PROPERTY_NOT_FOUND, "PropertyNotFound"), - ENUM_ENTRY (NM_SETTING_ERROR_PROPERTY_NOT_SECRET, "PropertyNotSecret"), - ENUM_ENTRY (NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, "PropertyTypeMismatch"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSettingError", values); - } - return etype; -} - G_DEFINE_ABSTRACT_TYPE (NMSetting, nm_setting, G_TYPE_OBJECT) #define NM_SETTING_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING, NMSettingPrivate)) @@ -992,6 +971,27 @@ nm_setting_to_string (NMSetting *setting) return g_string_free (string, FALSE); } +/** + * nm_setting_get_virtual_iface_name: + * @setting: the #NMSetting + * + * Returns the name of the virtual kernel interface which the connection + * needs to use if specified in the settings. + * + * Returns: Name of the virtual interface or %NULL if the setting does not + * support this feature + **/ +const char * +nm_setting_get_virtual_iface_name (NMSetting *setting) +{ + g_return_val_if_fail (NM_IS_SETTING (setting), NULL); + + if (NM_SETTING_GET_CLASS (setting)->get_virtual_iface_name) + return NM_SETTING_GET_CLASS (setting)->get_virtual_iface_name (setting); + + return NULL; +} + /*****************************************************************************/ static void diff --git a/libnm-util/nm-setting.h b/libnm-util/nm-setting.h index 3edf2a1f..6cc6ed3e 100644 --- a/libnm-util/nm-setting.h +++ b/libnm-util/nm-setting.h @@ -54,15 +54,12 @@ G_BEGIN_DECLS **/ typedef enum { - NM_SETTING_ERROR_UNKNOWN = 0, - NM_SETTING_ERROR_PROPERTY_NOT_FOUND, - NM_SETTING_ERROR_PROPERTY_NOT_SECRET, - NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH + NM_SETTING_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ + NM_SETTING_ERROR_PROPERTY_NOT_FOUND, /*< nick=PropertyNotFound >*/ + NM_SETTING_ERROR_PROPERTY_NOT_SECRET, /*< nick=PropertyNotSecret >*/ + NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH /*< nick=PropertyTypeMismatch >*/ } NMSettingError; -#define NM_TYPE_SETTING_ERROR (nm_setting_error_get_type ()) -GType nm_setting_error_get_type (void); - #define NM_SETTING_ERROR nm_setting_error_quark () GQuark nm_setting_error_quark (void); @@ -203,9 +200,10 @@ typedef struct { NMSettingClearSecretsWithFlagsFn func, gpointer user_data); + const char *(*get_virtual_iface_name) (NMSetting *setting); + /* Padding for future expansion */ void (*_reserved1) (void); - void (*_reserved2) (void); } NMSettingClass; /** @@ -308,6 +306,8 @@ gboolean nm_setting_set_secret_flags (NMSetting *setting, NMSettingSecretFlags flags, GError **error); +const char *nm_setting_get_virtual_iface_name (NMSetting *setting); + G_END_DECLS #endif /* NM_SETTING_H */ diff --git a/libnm-util/nm-utils-enum-types.c b/libnm-util/nm-utils-enum-types.c new file mode 100644 index 00000000..dcf51dee --- /dev/null +++ b/libnm-util/nm-utils-enum-types.c @@ -0,0 +1,759 @@ + + + +/* Generated by glib-mkenums. Do not edit */ + +#include "nm-utils-enum-types.h" + +#include "nm-connection.h" +#include "nm-setting.h" +#include "nm-setting-8021x.h" +#include "nm-setting-bluetooth.h" +#include "nm-setting-bond.h" +#include "nm-setting-connection.h" +#include "nm-setting-infiniband.h" +#include "nm-setting-ip4-config.h" +#include "nm-setting-vlan.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-ppp.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-serial.h" +#include "nm-setting-gsm.h" +#include "nm-setting-cdma.h" +#include "nm-setting-olpc-mesh.h" +#include "nm-setting-wimax.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-wireless-security.h" +#include "nm-setting-vpn.h" +#include "nm-utils.h" + +GType +nm_connection_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_CONNECTION_ERROR_UNKNOWN, "NM_CONNECTION_ERROR_UNKNOWN", "UnknownError" }, + { NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, "NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND", "ConnectionSettingNotFound" }, + { NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, "NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID", "ConnectionTypeInvalid" }, + { NM_CONNECTION_ERROR_SETTING_NOT_FOUND, "NM_CONNECTION_ERROR_SETTING_NOT_FOUND", "SettingNotFound" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMConnectionError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_ERROR_UNKNOWN, "NM_SETTING_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_ERROR_PROPERTY_NOT_FOUND, "NM_SETTING_ERROR_PROPERTY_NOT_FOUND", "PropertyNotFound" }, + { NM_SETTING_ERROR_PROPERTY_NOT_SECRET, "NM_SETTING_ERROR_PROPERTY_NOT_SECRET", "PropertyNotSecret" }, + { NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, "NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH", "PropertyTypeMismatch" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_secret_flags_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_SECRET_FLAG_NONE, "NM_SETTING_SECRET_FLAG_NONE", "none" }, + { NM_SETTING_SECRET_FLAG_AGENT_OWNED, "NM_SETTING_SECRET_FLAG_AGENT_OWNED", "agent-owned" }, + { NM_SETTING_SECRET_FLAG_NOT_SAVED, "NM_SETTING_SECRET_FLAG_NOT_SAVED", "not-saved" }, + { NM_SETTING_SECRET_FLAG_NOT_REQUIRED, "NM_SETTING_SECRET_FLAG_NOT_REQUIRED", "not-required" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingSecretFlags"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_compare_flags_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_COMPARE_FLAG_EXACT, "NM_SETTING_COMPARE_FLAG_EXACT", "exact" }, + { NM_SETTING_COMPARE_FLAG_FUZZY, "NM_SETTING_COMPARE_FLAG_FUZZY", "fuzzy" }, + { NM_SETTING_COMPARE_FLAG_IGNORE_ID, "NM_SETTING_COMPARE_FLAG_IGNORE_ID", "ignore-id" }, + { NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, "NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS", "ignore-secrets" }, + { NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS, "NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS", "ignore-agent-owned-secrets" }, + { NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS, "NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS", "ignore-not-saved-secrets" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingCompareFlags"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_hash_flags_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_HASH_FLAG_ALL, "NM_SETTING_HASH_FLAG_ALL", "all" }, + { NM_SETTING_HASH_FLAG_NO_SECRETS, "NM_SETTING_HASH_FLAG_NO_SECRETS", "no-secrets" }, + { NM_SETTING_HASH_FLAG_ONLY_SECRETS, "NM_SETTING_HASH_FLAG_ONLY_SECRETS", "only-secrets" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingHashFlags"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_diff_result_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_DIFF_RESULT_UNKNOWN, "NM_SETTING_DIFF_RESULT_UNKNOWN", "unknown" }, + { NM_SETTING_DIFF_RESULT_IN_A, "NM_SETTING_DIFF_RESULT_IN_A", "in-a" }, + { NM_SETTING_DIFF_RESULT_IN_B, "NM_SETTING_DIFF_RESULT_IN_B", "in-b" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingDiffResult"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_802_1x_ck_format_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, "NM_SETTING_802_1X_CK_FORMAT_UNKNOWN", "unknown" }, + { NM_SETTING_802_1X_CK_FORMAT_X509, "NM_SETTING_802_1X_CK_FORMAT_X509", "x509" }, + { NM_SETTING_802_1X_CK_FORMAT_RAW_KEY, "NM_SETTING_802_1X_CK_FORMAT_RAW_KEY", "raw-key" }, + { NM_SETTING_802_1X_CK_FORMAT_PKCS12, "NM_SETTING_802_1X_CK_FORMAT_PKCS12", "pkcs12" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSetting8021xCKFormat"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_802_1x_ck_scheme_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_802_1X_CK_SCHEME_UNKNOWN, "NM_SETTING_802_1X_CK_SCHEME_UNKNOWN", "unknown" }, + { NM_SETTING_802_1X_CK_SCHEME_BLOB, "NM_SETTING_802_1X_CK_SCHEME_BLOB", "blob" }, + { NM_SETTING_802_1X_CK_SCHEME_PATH, "NM_SETTING_802_1X_CK_SCHEME_PATH", "path" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSetting8021xCKScheme"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_802_1x_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_802_1X_ERROR_UNKNOWN, "NM_SETTING_802_1X_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, "NM_SETTING_802_1X_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, "NM_SETTING_802_1X_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSetting8021xError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_bluetooth_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_BLUETOOTH_ERROR_UNKNOWN, "NM_SETTING_BLUETOOTH_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, "NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, "NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND, "NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND", "TypeSettingNotFound" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingBluetoothError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_bond_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_BOND_ERROR_UNKNOWN, "NM_SETTING_BOND_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_BOND_ERROR_INVALID_PROPERTY, "NM_SETTING_BOND_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_BOND_ERROR_MISSING_PROPERTY, "NM_SETTING_BOND_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_BOND_ERROR_INVALID_OPTION, "NM_SETTING_BOND_ERROR_INVALID_OPTION", "InvalidOption" }, + { NM_SETTING_BOND_ERROR_MISSING_OPTION, "NM_SETTING_BOND_ERROR_MISSING_OPTION", "MissingOption" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingBondError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_connection_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_CONNECTION_ERROR_UNKNOWN, "NM_SETTING_CONNECTION_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, "NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, "NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, "NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND", "TypeSettingNotFound" }, + { NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, "NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED", "IpConfigNotAllowed" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingConnectionError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_infiniband_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_INFINIBAND_ERROR_UNKNOWN, "NM_SETTING_INFINIBAND_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, "NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY, "NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingInfinibandError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_ip4_config_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN, "NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, "NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, "NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, "NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD", "NotAllowedForMethod" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingIP4ConfigError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_vlan_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_VLAN_ERROR_UNKNOWN, "NM_SETTING_VLAN_ERROR_UNKNOWN", "Unknown" }, + { NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, "NM_SETTING_VLAN_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_VLAN_ERROR_MISSING_PROPERTY, "NM_SETTING_VLAN_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingVlanError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_vlan_priority_map_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_VLAN_INGRESS_MAP, "NM_VLAN_INGRESS_MAP", "ingress-map" }, + { NM_VLAN_EGRESS_MAP, "NM_VLAN_EGRESS_MAP", "egress-map" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMVlanPriorityMap"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_vlan_flags_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_VLAN_FLAG_REORDER_HEADERS, "NM_VLAN_FLAG_REORDER_HEADERS", "reorder-headers" }, + { NM_VLAN_FLAG_GVRP, "NM_VLAN_FLAG_GVRP", "gvrp" }, + { NM_VLAN_FLAG_LOOSE_BINDING, "NM_VLAN_FLAG_LOOSE_BINDING", "loose-binding" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMVlanFlags"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_ip6_config_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN, "NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, "NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, "NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, "NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD", "NotAllowedForMethod" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingIP6ConfigError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_ip6_config_privacy_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, "NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN", "unknown" }, + { NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED, "NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED", "disabled" }, + { NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR, "NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR", "prefer-public-addr" }, + { NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, "NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR", "prefer-temp-addr" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingIP6ConfigPrivacy"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_ppp_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_PPP_ERROR_UNKNOWN, "NM_SETTING_PPP_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_PPP_ERROR_INVALID_PROPERTY, "NM_SETTING_PPP_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_PPP_ERROR_MISSING_PROPERTY, "NM_SETTING_PPP_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED, "NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED", "RequireMPPENotAllowed" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingPPPError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_pppoe_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_PPPOE_ERROR_UNKNOWN, "NM_SETTING_PPPOE_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, "NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY, "NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING, "NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING", "MissingPPPSetting" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingPPPOEError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_serial_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_SERIAL_ERROR_UNKNOWN, "NM_SETTING_SERIAL_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY, "NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY, "NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING, "NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING", "MissingPPPSetting" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingSerialError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_gsm_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_GSM_ERROR_UNKNOWN, "NM_SETTING_GSM_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_GSM_ERROR_INVALID_PROPERTY, "NM_SETTING_GSM_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_GSM_ERROR_MISSING_PROPERTY, "NM_SETTING_GSM_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING, "NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING", "MissingSerialSetting" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingGsmError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_gsm_network_type_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_GSM_NETWORK_TYPE_ANY, "NM_SETTING_GSM_NETWORK_TYPE_ANY", "any" }, + { NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA, "NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA", "umts-hspa" }, + { NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE, "NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE", "gprs-edge" }, + { NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA, "NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA", "prefer-umts-hspa" }, + { NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE, "NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE", "prefer-gprs-edge" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingGsmNetworkType"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_gsm_network_band_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_GSM_BAND_UNKNOWN, "NM_SETTING_GSM_BAND_UNKNOWN", "unknown" }, + { NM_SETTING_GSM_BAND_ANY, "NM_SETTING_GSM_BAND_ANY", "any" }, + { NM_SETTING_GSM_BAND_EGSM, "NM_SETTING_GSM_BAND_EGSM", "egsm" }, + { NM_SETTING_GSM_BAND_DCS, "NM_SETTING_GSM_BAND_DCS", "dcs" }, + { NM_SETTING_GSM_BAND_PCS, "NM_SETTING_GSM_BAND_PCS", "pcs" }, + { NM_SETTING_GSM_BAND_G850, "NM_SETTING_GSM_BAND_G850", "g850" }, + { NM_SETTING_GSM_BAND_U2100, "NM_SETTING_GSM_BAND_U2100", "u2100" }, + { NM_SETTING_GSM_BAND_U1800, "NM_SETTING_GSM_BAND_U1800", "u1800" }, + { NM_SETTING_GSM_BAND_U17IV, "NM_SETTING_GSM_BAND_U17IV", "u17iv" }, + { NM_SETTING_GSM_BAND_U800, "NM_SETTING_GSM_BAND_U800", "u800" }, + { NM_SETTING_GSM_BAND_U850, "NM_SETTING_GSM_BAND_U850", "u850" }, + { NM_SETTING_GSM_BAND_U900, "NM_SETTING_GSM_BAND_U900", "u900" }, + { NM_SETTING_GSM_BAND_U17IX, "NM_SETTING_GSM_BAND_U17IX", "u17ix" }, + { NM_SETTING_GSM_BAND_U1900, "NM_SETTING_GSM_BAND_U1900", "u1900" }, + { NM_SETTING_GSM_BAND_U2600, "NM_SETTING_GSM_BAND_U2600", "u2600" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingGsmNetworkBand"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_cdma_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_CDMA_ERROR_UNKNOWN, "NM_SETTING_CDMA_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, "NM_SETTING_CDMA_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, "NM_SETTING_CDMA_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING, "NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING", "MissingSerialSetting" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingCdmaError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_olpc_mesh_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_OLPC_MESH_ERROR_UNKNOWN, "NM_SETTING_OLPC_MESH_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, "NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY, "NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingOlpcMeshError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_wimax_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_WIMAX_ERROR_UNKNOWN, "NM_SETTING_WIMAX_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, "NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY, "NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingWimaxError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_wired_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_WIRED_ERROR_UNKNOWN, "NM_SETTING_WIRED_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, "NM_SETTING_WIRED_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_WIRED_ERROR_MISSING_PROPERTY, "NM_SETTING_WIRED_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingWiredError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_wireless_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_WIRELESS_ERROR_UNKNOWN, "NM_SETTING_WIRELESS_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, "NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY, "NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING, "NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING", "MissingSecuritySetting" }, + { NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND, "NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND", "ChannelRequiresBand" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingWirelessError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_wireless_security_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN, "NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, "NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY, "NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING, "NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING", "Missing8021xSetting" }, + { NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, "NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X", "LEAPRequires8021x" }, + { NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, "NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME", "LEAPRequiresUsername" }, + { NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP, "NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP", "SharedKeyRequiresWEP" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingWirelessSecurityError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_wep_key_type_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_WEP_KEY_TYPE_UNKNOWN, "NM_WEP_KEY_TYPE_UNKNOWN", "unknown" }, + { NM_WEP_KEY_TYPE_KEY, "NM_WEP_KEY_TYPE_KEY", "key" }, + { NM_WEP_KEY_TYPE_PASSPHRASE, "NM_WEP_KEY_TYPE_PASSPHRASE", "passphrase" }, + { NM_WEP_KEY_TYPE_LAST, "NM_WEP_KEY_TYPE_LAST", "last" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMWepKeyType"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_setting_vpn_error_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_SETTING_VPN_ERROR_UNKNOWN, "NM_SETTING_VPN_ERROR_UNKNOWN", "UnknownError" }, + { NM_SETTING_VPN_ERROR_INVALID_PROPERTY, "NM_SETTING_VPN_ERROR_INVALID_PROPERTY", "InvalidProperty" }, + { NM_SETTING_VPN_ERROR_MISSING_PROPERTY, "NM_SETTING_VPN_ERROR_MISSING_PROPERTY", "MissingProperty" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMSettingVpnError"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType +nm_utils_security_type_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NMU_SEC_INVALID, "NMU_SEC_INVALID", "invalid" }, + { NMU_SEC_NONE, "NMU_SEC_NONE", "none" }, + { NMU_SEC_STATIC_WEP, "NMU_SEC_STATIC_WEP", "static-wep" }, + { NMU_SEC_LEAP, "NMU_SEC_LEAP", "leap" }, + { NMU_SEC_DYNAMIC_WEP, "NMU_SEC_DYNAMIC_WEP", "dynamic-wep" }, + { NMU_SEC_WPA_PSK, "NMU_SEC_WPA_PSK", "wpa-psk" }, + { NMU_SEC_WPA_ENTERPRISE, "NMU_SEC_WPA_ENTERPRISE", "wpa-enterprise" }, + { NMU_SEC_WPA2_PSK, "NMU_SEC_WPA2_PSK", "wpa2-psk" }, + { NMU_SEC_WPA2_ENTERPRISE, "NMU_SEC_WPA2_ENTERPRISE", "wpa2-enterprise" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMUtilsSecurityType"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + + + diff --git a/libnm-util/nm-utils-enum-types.h b/libnm-util/nm-utils-enum-types.h new file mode 100644 index 00000000..d3bcf049 --- /dev/null +++ b/libnm-util/nm-utils-enum-types.h @@ -0,0 +1,85 @@ + + + +/* Generated by glib-mkenums. Do not edit */ + +#ifndef __NM_UTILS_ENUM_TYPES_H__ +#define __NM_UTILS_ENUM_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS +GType nm_connection_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_CONNECTION_ERROR (nm_connection_error_get_type ()) +GType nm_setting_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_ERROR (nm_setting_error_get_type ()) +GType nm_setting_secret_flags_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_SECRET_FLAGS (nm_setting_secret_flags_get_type ()) +GType nm_setting_compare_flags_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_COMPARE_FLAGS (nm_setting_compare_flags_get_type ()) +GType nm_setting_hash_flags_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_HASH_FLAGS (nm_setting_hash_flags_get_type ()) +GType nm_setting_diff_result_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_DIFF_RESULT (nm_setting_diff_result_get_type ()) +GType nm_setting_802_1x_ck_format_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_802_1X_CK_FORMAT (nm_setting_802_1x_ck_format_get_type ()) +GType nm_setting_802_1x_ck_scheme_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_802_1X_CK_SCHEME (nm_setting_802_1x_ck_scheme_get_type ()) +GType nm_setting_802_1x_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_802_1X_ERROR (nm_setting_802_1x_error_get_type ()) +GType nm_setting_bluetooth_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_BLUETOOTH_ERROR (nm_setting_bluetooth_error_get_type ()) +GType nm_setting_bond_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_BOND_ERROR (nm_setting_bond_error_get_type ()) +GType nm_setting_connection_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_CONNECTION_ERROR (nm_setting_connection_error_get_type ()) +GType nm_setting_infiniband_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_INFINIBAND_ERROR (nm_setting_infiniband_error_get_type ()) +GType nm_setting_ip4_config_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_IP4_CONFIG_ERROR (nm_setting_ip4_config_error_get_type ()) +GType nm_setting_vlan_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_VLAN_ERROR (nm_setting_vlan_error_get_type ()) +GType nm_vlan_priority_map_get_type (void) G_GNUC_CONST; +#define NM_TYPE_VLAN_PRIORITY_MAP (nm_vlan_priority_map_get_type ()) +GType nm_vlan_flags_get_type (void) G_GNUC_CONST; +#define NM_TYPE_VLAN_FLAGS (nm_vlan_flags_get_type ()) +GType nm_setting_ip6_config_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_IP6_CONFIG_ERROR (nm_setting_ip6_config_error_get_type ()) +GType nm_setting_ip6_config_privacy_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_IP6_CONFIG_PRIVACY (nm_setting_ip6_config_privacy_get_type ()) +GType nm_setting_ppp_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_PPP_ERROR (nm_setting_ppp_error_get_type ()) +GType nm_setting_pppoe_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_PPPOE_ERROR (nm_setting_pppoe_error_get_type ()) +GType nm_setting_serial_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_SERIAL_ERROR (nm_setting_serial_error_get_type ()) +GType nm_setting_gsm_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_GSM_ERROR (nm_setting_gsm_error_get_type ()) +GType nm_setting_gsm_network_type_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_GSM_NETWORK_TYPE (nm_setting_gsm_network_type_get_type ()) +GType nm_setting_gsm_network_band_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_GSM_NETWORK_BAND (nm_setting_gsm_network_band_get_type ()) +GType nm_setting_cdma_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_CDMA_ERROR (nm_setting_cdma_error_get_type ()) +GType nm_setting_olpc_mesh_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_OLPC_MESH_ERROR (nm_setting_olpc_mesh_error_get_type ()) +GType nm_setting_wimax_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_WIMAX_ERROR (nm_setting_wimax_error_get_type ()) +GType nm_setting_wired_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_WIRED_ERROR (nm_setting_wired_error_get_type ()) +GType nm_setting_wireless_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_WIRELESS_ERROR (nm_setting_wireless_error_get_type ()) +GType nm_setting_wireless_security_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_WIRELESS_SECURITY_ERROR (nm_setting_wireless_security_error_get_type ()) +GType nm_wep_key_type_get_type (void) G_GNUC_CONST; +#define NM_TYPE_WEP_KEY_TYPE (nm_wep_key_type_get_type ()) +GType nm_setting_vpn_error_get_type (void) G_GNUC_CONST; +#define NM_TYPE_SETTING_VPN_ERROR (nm_setting_vpn_error_get_type ()) +GType nm_utils_security_type_get_type (void) G_GNUC_CONST; +#define NM_TYPE_UTILS_SECURITY_TYPE (nm_utils_security_type_get_type ()) +G_END_DECLS + +#endif /* __NM_UTILS_ENUM_TYPES_H__ */ + + + diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index 9d4418e4..a8806206 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -25,13 +25,14 @@ */ #include "config.h" +#include <ctype.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <arpa/inet.h> - -#include "wireless-helper.h" +#include <netinet/ether.h> +#include <linux/if_infiniband.h> #include <glib.h> #include <glib-object.h> @@ -360,6 +361,8 @@ nm_utils_is_empty_ssid (const guint8 * ssid, int len) return TRUE; } +#define ESSID_MAX_SIZE 32 + /** * nm_utils_escape_ssid: * @ssid: pointer to a buffer containing the SSID data @@ -376,7 +379,7 @@ nm_utils_is_empty_ssid (const guint8 * ssid, int len) const char * nm_utils_escape_ssid (const guint8 * ssid, guint32 len) { - static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; + static char escaped[ESSID_MAX_SIZE * 2 + 1]; const guint8 *s = ssid; char *d = escaped; @@ -385,7 +388,7 @@ nm_utils_escape_ssid (const guint8 * ssid, guint32 len) return escaped; } - len = MIN (len, (guint32) IW_ESSID_MAX_SIZE); + len = MIN (len, (guint32) ESSID_MAX_SIZE); while (len--) { if (*s == '\0') { *d++ = '\\'; @@ -534,6 +537,14 @@ _nm_utils_string_slist_validate (GSList *list, const char **valid_values) } static void +_nm_utils_convert_op_to_string (const GValue *src_value, GValue *dest_value) +{ + g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_OBJECT_PATH)); + + g_value_set_string (dest_value, (const char *) g_value_get_boxed (src_value)); +} + +static void _nm_utils_convert_strv_to_slist (const GValue *src_value, GValue *dest_value) { char **str; @@ -595,16 +606,11 @@ _nm_utils_convert_strv_to_string (const GValue *src_value, GValue *dest_value) } static void -_nm_utils_convert_string_array_to_string (const GValue *src_value, GValue *dest_value) +_string_array_to_string (const GPtrArray *strings, GValue *dest_value) { - GPtrArray *strings; GString *printable; int i; - g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_STRING)); - - strings = (GPtrArray *) g_value_get_boxed (src_value); - printable = g_string_new ("["); for (i = 0; strings && i < strings->len; i++) { if (i > 0) @@ -621,6 +627,28 @@ _nm_utils_convert_string_array_to_string (const GValue *src_value, GValue *dest_ } static void +_nm_utils_convert_string_array_to_string (const GValue *src_value, GValue *dest_value) +{ + const GPtrArray *strings; + + g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_STRING)); + + strings = (const GPtrArray *) g_value_get_boxed (src_value); + _string_array_to_string (strings, dest_value); +} + +static void +_nm_utils_convert_op_array_to_string (const GValue *src_value, GValue *dest_value) +{ + const GPtrArray *strings; + + g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)); + + strings = (const GPtrArray *) g_value_get_boxed (src_value); + _string_array_to_string (strings, dest_value); +} + +static void _nm_utils_convert_uint_array_to_string (const GValue *src_value, GValue *dest_value) { GArray *array; @@ -1079,6 +1107,9 @@ _nm_utils_register_value_transformations (void) static gboolean registered = FALSE; if (G_UNLIKELY (!registered)) { + g_value_register_transform_func (DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_STRING, + _nm_utils_convert_op_to_string); g_value_register_transform_func (G_TYPE_STRV, DBUS_TYPE_G_LIST_OF_STRING, _nm_utils_convert_strv_to_slist); @@ -1091,6 +1122,9 @@ _nm_utils_register_value_transformations (void) g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_STRING, G_TYPE_STRING, _nm_utils_convert_string_array_to_string); + g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, + G_TYPE_STRING, + _nm_utils_convert_op_array_to_string); g_value_register_transform_func (DBUS_TYPE_G_UINT_ARRAY, G_TYPE_STRING, _nm_utils_convert_uint_array_to_string); @@ -1209,6 +1243,8 @@ nm_utils_security_valid (NMUtilsSecurityType type, || ((type == NMU_SEC_LEAP) && !adhoc)) { if (wifi_caps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104)) return TRUE; + else + return FALSE; } } @@ -1249,6 +1285,8 @@ nm_utils_security_valid (NMUtilsSecurityType type, } break; case NMU_SEC_WPA_PSK: + if (adhoc) + return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */ if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA)) return FALSE; if (have_ap) { @@ -1275,6 +1313,8 @@ nm_utils_security_valid (NMUtilsSecurityType type, } break; case NMU_SEC_WPA2_PSK: + if (adhoc) + return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */ if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN)) return FALSE; if (have_ap) { @@ -2386,3 +2426,145 @@ nm_utils_wifi_is_channel_valid (guint32 channel, const char *band) return FALSE; } +/** + * nm_utils_hwaddr_len: + * @type: the type of address; either %ARPHRD_ETHER or %ARPHRD_INFINIBAND + * + * Returns the length in octets of a hardware address of type @type. + * + * Return value: the length + */ +int +nm_utils_hwaddr_len (int type) +{ + if (type == ARPHRD_ETHER) + return ETH_ALEN; + else if (type == ARPHRD_INFINIBAND) + return INFINIBAND_ALEN; + else + g_return_val_if_reached (-1); +} + +/** + * nm_utils_hwaddr_type: + * @len: the length of hardware address in bytes + * + * Returns the type (either %ARPHRD_ETHER or %ARPHRD_INFINIBAND) of the raw + * address given its length. + * + * Return value: the type, either %ARPHRD_ETHER or %ARPHRD_INFINIBAND, or -1 if + * the address length was not recognized + */ +int +nm_utils_hwaddr_type (int len) +{ + if (len == ETH_ALEN) + return ARPHRD_ETHER; + else if (len == INFINIBAND_ALEN) + return ARPHRD_INFINIBAND; + else + g_return_val_if_reached (-1); +} + +#define HEXVAL(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - 'A' + 10) + +/** + * nm_utils_hwaddr_aton: + * @asc: the ASCII representation of a hardware address + * @type: the type of address; either %ARPHRD_ETHER or %ARPHRD_INFINIBAND + * @buffer: buffer to store the result into + * + * Parses @asc and converts it to binary form in @buffer. See + * nm_utils_hwaddr_atoba() if you'd rather have the result in a + * #GByteArray. + * + * Return value: @buffer, or %NULL if @asc couldn't be parsed + */ +guint8 * +nm_utils_hwaddr_aton (const char *asc, int type, gpointer buffer) +{ + const char *in = asc; + guint8 *out = (guint8 *)buffer; + int left = nm_utils_hwaddr_len (type); + + while (left && *in) { + guint8 d1 = in[0], d2 = in[1]; + + if (!isxdigit (d1)) + return NULL; + + /* If there's no leading zero (ie "aa:b:cc") then fake it */ + if (d2 && isxdigit (d2)) { + *out++ = (HEXVAL (d1) << 4) + HEXVAL (d2); + in += 2; + } else { + /* Fake leading zero */ + *out++ = (HEXVAL ('0') << 4) + HEXVAL (d1); + in += 1; + } + + left--; + if (*in) { + if (*in != ':') + return NULL; + in++; + } + } + + if (left == 0 && !*in) + return buffer; + else + return NULL; +} + +/** + * nm_utils_hwaddr_atoba: + * @asc: the ASCII representation of a hardware address + * @type: the type of address; either %ARPHRD_ETHER or %ARPHRD_INFINIBAND + * + * Parses @asc and converts it to binary form in a #GByteArray. See + * nm_utils_hwaddr_aton() if you don't want a #GByteArray. + * + * Return value: (transfer full): a new #GByteArray, or %NULL if @asc couldn't + * be parsed + */ +GByteArray * +nm_utils_hwaddr_atoba (const char *asc, int type) +{ + GByteArray *ba; + int len = nm_utils_hwaddr_len (type); + + ba = g_byte_array_sized_new (len); + ba->len = len; + if (!nm_utils_hwaddr_aton (asc, type, ba->data)) { + g_byte_array_unref (ba); + return NULL; + } + + return ba; +} + +/** + * nm_utils_hwaddr_ntoa: + * @addr: a binary hardware address + * @type: the type of address; either %ARPHRD_ETHER or %ARPHRD_INFINIBAND + * + * Converts @addr to textual form. + * + * Return value: (transfer full): the textual form of @addr + */ +char * +nm_utils_hwaddr_ntoa (gconstpointer addr, int type) +{ + const guint8 *in = addr; + GString *out = g_string_new (NULL); + int left = nm_utils_hwaddr_len (type); + + while (left--) { + if (out->len) + g_string_append_c (out, ':'); + g_string_append_printf (out, "%02X", *in++); + } + + return g_string_free (out, FALSE); +} diff --git a/libnm-util/nm-utils.h b/libnm-util/nm-utils.h index 6a179268..7bc536ac 100644 --- a/libnm-util/nm-utils.h +++ b/libnm-util/nm-utils.h @@ -29,6 +29,7 @@ #include <glib.h> #include "nm-connection.h" +#include "nm-utils-enum-types.h" G_BEGIN_DECLS @@ -118,6 +119,21 @@ guint32 nm_utils_wifi_channel_to_freq (guint32 channel, const char *band); guint32 nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band); gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band); +/** + * NM_UTILS_HWADDR_LEN_MAX: + * + * The maximum length of a hardware address of a type known by + * nm_utils_hwaddr_len() or nm_utils_hwaddr_aton(). This can be used + * as the size of the buffer passed to nm_utils_hwaddr_aton(). + */ +#define NM_UTILS_HWADDR_LEN_MAX 20 /* INFINIBAND_ALEN */ + +int nm_utils_hwaddr_len (int type) G_GNUC_PURE; +int nm_utils_hwaddr_type (int len) G_GNUC_PURE; +char *nm_utils_hwaddr_ntoa (gconstpointer addr, int type); +GByteArray *nm_utils_hwaddr_atoba (const char *asc, int type); +guint8 *nm_utils_hwaddr_aton (const char *asc, int type, gpointer buffer); + G_END_DECLS #endif /* NM_UTILS_H */ diff --git a/libnm-util/tests/Makefile.am b/libnm-util/tests/Makefile.am index 1d737d1a..46a4d142 100644 --- a/libnm-util/tests/Makefile.am +++ b/libnm-util/tests/Makefile.am @@ -2,7 +2,9 @@ SUBDIRS=certs INCLUDES = \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/libnm-util + -I$(top_builddir)/include \ + -I$(top_srcdir)/libnm-util \ + -I$(top_builddir)/libnm-util noinst_PROGRAMS = \ test-settings-defaults \ diff --git a/libnm-util/tests/Makefile.in b/libnm-util/tests/Makefile.in index 26711238..10a1e20f 100644 --- a/libnm-util/tests/Makefile.in +++ b/libnm-util/tests/Makefile.in @@ -205,6 +205,8 @@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ +GLIB_MAKEFILE = @GLIB_MAKEFILE@ +GLIB_MKENUMS = @GLIB_MKENUMS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMSGFMT = @GMSGFMT@ @@ -259,11 +261,15 @@ LIBNL2_LIBS = @LIBNL2_LIBS@ LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_GENL3_CFLAGS = @LIBNL_GENL3_CFLAGS@ +LIBNL_GENL3_LIBS = @LIBNL_GENL3_LIBS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ +LIBSOUP_LIBS = @LIBSOUP_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -274,6 +280,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ @@ -313,6 +320,8 @@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ +SYSTEMD_LIBS = @SYSTEMD_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ @@ -379,7 +388,9 @@ top_srcdir = @top_srcdir@ SUBDIRS = certs INCLUDES = \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/libnm-util + -I$(top_builddir)/include \ + -I$(top_srcdir)/libnm-util \ + -I$(top_builddir)/libnm-util test_settings_defaults_SOURCES = \ test-settings-defaults.c diff --git a/libnm-util/tests/certs/Makefile.in b/libnm-util/tests/certs/Makefile.in index d7f48d21..17289f48 100644 --- a/libnm-util/tests/certs/Makefile.in +++ b/libnm-util/tests/certs/Makefile.in @@ -116,6 +116,8 @@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ +GLIB_MAKEFILE = @GLIB_MAKEFILE@ +GLIB_MKENUMS = @GLIB_MKENUMS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMSGFMT = @GMSGFMT@ @@ -170,11 +172,15 @@ LIBNL2_LIBS = @LIBNL2_LIBS@ LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_GENL3_CFLAGS = @LIBNL_GENL3_CFLAGS@ +LIBNL_GENL3_LIBS = @LIBNL_GENL3_LIBS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ +LIBSOUP_LIBS = @LIBSOUP_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -185,6 +191,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ @@ -224,6 +231,8 @@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ +SYSTEMD_LIBS = @SYSTEMD_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c index f2f7e8ff..1eed8887 100644 --- a/libnm-util/tests/test-general.c +++ b/libnm-util/tests/test-general.c @@ -22,6 +22,8 @@ #include <glib.h> #include <dbus/dbus-glib.h> #include <string.h> +#include <netinet/ether.h> +#include <linux/if_infiniband.h> #include "nm-test-helpers.h" #include <nm-utils.h> @@ -442,6 +444,26 @@ test_setting_gsm_apn_underscore (void) g_assert (success == TRUE); } +static void +test_setting_gsm_without_number (void) +{ + NMSettingGsm *s_gsm; + GError *error = NULL; + gboolean success; + + s_gsm = (NMSettingGsm *) nm_setting_gsm_new (); + g_assert (s_gsm); + + g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, NULL, NULL); + success = nm_setting_verify (NM_SETTING (s_gsm), NULL, &error); + g_assert_no_error (error); + g_assert (success == TRUE); + + g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "", NULL); + success = nm_setting_verify (NM_SETTING (s_gsm), NULL, &error); + g_assert_error (error, NM_SETTING_GSM_ERROR, NM_SETTING_GSM_ERROR_INVALID_PROPERTY); +} + static NMSettingWirelessSecurity * make_test_wsec_setting (const char *detail) { @@ -849,6 +871,9 @@ test_connection_diff_a_only (void) { NM_SETTING_CONNECTION_AUTOCONNECT, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_CONNECTION_READ_ONLY, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_CONNECTION_PERMISSIONS, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_CONNECTION_ZONE, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_CONNECTION_MASTER, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_DIFF_RESULT_IN_A }, { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN } } }, { NM_SETTING_WIRED_SETTING_NAME, { @@ -916,7 +941,7 @@ test_connection_diff_different (void) { NMConnection *a, *b; GHashTable *out_diffs = NULL; - NMSetting *s_ip4; + NMSettingIP4Config *s_ip4; gboolean same; const DiffSetting settings[] = { { NM_SETTING_IP4_CONFIG_SETTING_NAME, { @@ -927,7 +952,7 @@ test_connection_diff_different (void) a = new_test_connection (); b = nm_connection_duplicate (a); - s_ip4 = nm_connection_get_setting (a, NM_TYPE_SETTING_IP4_CONFIG); + s_ip4 = nm_connection_get_setting_ip4_config (a); g_assert (s_ip4); g_object_set (G_OBJECT (s_ip4), NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -968,7 +993,7 @@ test_connection_diff_no_secrets (void) b = nm_connection_duplicate (a); /* Add a secret to B */ - s_pppoe = nm_connection_get_setting (b, NM_TYPE_SETTING_PPPOE); + s_pppoe = NM_SETTING (nm_connection_get_setting_pppoe (b)); g_assert (s_pppoe); g_object_set (G_OBJECT (s_pppoe), NM_SETTING_PPPOE_PASSWORD, "secretpassword", @@ -1295,6 +1320,47 @@ test_setting_compare_vpn_secrets (NMSettingSecretFlags secret_flags, g_assert (success); } +static void +test_hwaddr_aton_ether_normal (void) +{ + guint8 buf[100]; + guint8 expected[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; + + g_assert (nm_utils_hwaddr_aton ("00:11:22:33:44:55", ARPHRD_ETHER, buf) != NULL); + g_assert (memcmp (buf, expected, sizeof (expected)) == 0); +} + +static void +test_hwaddr_aton_ib_normal (void) +{ + guint8 buf[100]; + const char *source = "00:11:22:33:44:55:66:77:88:99:01:12:23:34:45:56:67:78:89:90"; + guint8 expected[INFINIBAND_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, + 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, + 0x90 }; + + g_assert (nm_utils_hwaddr_aton (source, ARPHRD_INFINIBAND, buf) != NULL); + g_assert (memcmp (buf, expected, sizeof (expected)) == 0); +} + +static void +test_hwaddr_aton_no_leading_zeros (void) +{ + guint8 buf[100]; + guint8 expected[ETH_ALEN] = { 0x00, 0x1A, 0x2B, 0x03, 0x44, 0x05 }; + + g_assert (nm_utils_hwaddr_aton ("0:1a:2B:3:44:5", ARPHRD_ETHER, buf) != NULL); + g_assert (memcmp (buf, expected, sizeof (expected)) == 0); +} + +static void +test_hwaddr_aton_malformed (void) +{ + guint8 buf[100]; + + g_assert (nm_utils_hwaddr_aton ("0:1a:2B:3:a@%%", ARPHRD_ETHER, buf) == NULL); +} + int main (int argc, char **argv) { GError *error = NULL; @@ -1313,6 +1379,7 @@ int main (int argc, char **argv) test_setting_gsm_apn_spaces (); test_setting_gsm_apn_bad_chars (); test_setting_gsm_apn_underscore (); + test_setting_gsm_without_number (); test_setting_to_hash_all (); test_setting_to_hash_no_secrets (); test_setting_to_hash_only_secrets (); @@ -1336,6 +1403,11 @@ int main (int argc, char **argv) test_connection_good_base_types (); test_connection_bad_base_types (); + test_hwaddr_aton_ether_normal (); + test_hwaddr_aton_ib_normal (); + test_hwaddr_aton_no_leading_zeros (); + test_hwaddr_aton_malformed (); + base = g_path_get_basename (argv[0]); fprintf (stdout, "%s: SUCCESS\n", base); g_free (base); diff --git a/libnm-util/tests/test-secrets.c b/libnm-util/tests/test-secrets.c index 1fe3c438..0e859abc 100644 --- a/libnm-util/tests/test-secrets.c +++ b/libnm-util/tests/test-secrets.c @@ -527,7 +527,7 @@ test_update_secrets_wifi_single_setting (void) g_assert (success); /* Make sure the secret is now in the connection */ - s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); + s_wsec = nm_connection_get_setting_wireless_security (connection); g_assert (s_wsec); tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0); g_assert_cmpstr (tmp, ==, wepkey); @@ -563,7 +563,7 @@ test_update_secrets_wifi_full_hash (void) g_assert (success); /* Make sure the secret is now in the connection */ - s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); + s_wsec = nm_connection_get_setting_wireless_security (connection); g_assert (s_wsec); tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0); g_assert_cmpstr (tmp, ==, wepkey); |