mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 08:20:28 +01:00
libnm: Initial merge of "libnm" work (bgo #680675)
libnm is the new NetworkManager client library that will replace libnm-util/libnm-glib for NM 1.0. THIS API IS NOT YET STABLE. Don't use it yet.
This commit is contained in:
commit
4b54e4db80
344 changed files with 69655 additions and 1560 deletions
30
.gitignore
vendored
30
.gitignore
vendored
|
|
@ -114,6 +114,19 @@ valgrind-*.log
|
|||
/docs/libnm-util/libnm-util.types
|
||||
/docs/libnm-util/version.xml
|
||||
|
||||
/docs/libnm/*.stamp
|
||||
/docs/libnm/html/
|
||||
/docs/libnm/tmpl/
|
||||
/docs/libnm/xml/
|
||||
/docs/libnm/libnm-*.txt
|
||||
/docs/libnm/libnm.args
|
||||
/docs/libnm/libnm.hierarchy
|
||||
/docs/libnm/libnm.interfaces
|
||||
/docs/libnm/libnm.prerequisites
|
||||
/docs/libnm/libnm.signals
|
||||
/docs/libnm/libnm.types
|
||||
/docs/libnm/version.xml
|
||||
|
||||
/docs/api/version.xml
|
||||
/docs/api/settings-spec.html
|
||||
/docs/api/settings-spec.xml
|
||||
|
|
@ -133,11 +146,11 @@ valgrind-*.log
|
|||
/docs/api/NetworkManager.types
|
||||
|
||||
/examples/C/glib/add-connection-dbus-glib
|
||||
/examples/C/glib/add-connection-libnm-glib
|
||||
/examples/C/glib/add-connection-libnm
|
||||
/examples/C/glib/get-active-connections-dbus-glib
|
||||
/examples/C/glib/get-ap-info-libnm-glib
|
||||
/examples/C/glib/get-ap-info-libnm
|
||||
/examples/C/glib/list-connections-dbus-glib
|
||||
/examples/C/glib/list-connections-libnm-glib
|
||||
/examples/C/glib/list-connections-libnm
|
||||
/examples/C/glib/monitor-nm-running-GDBus
|
||||
/examples/C/glib/monitor-nm-running-dbus-glib
|
||||
/examples/C/glib/monitor-nm-state-GDBus
|
||||
|
|
@ -164,12 +177,23 @@ valgrind-*.log
|
|||
/src/supplicant-manager/tests/test-supplicant-config
|
||||
/src/dhcp-manager/nm-dhcp-helper
|
||||
/system-settings/src
|
||||
/libnm-core/nm-version.h
|
||||
/libnm-core/tests/test-crypto
|
||||
/libnm-core/tests/test-settings-defaults
|
||||
/libnm-core/tests/test-general
|
||||
/libnm-core/tests/test-need-secrets
|
||||
/libnm-core/tests/test-secrets
|
||||
/libnm-core/tests/test-setting-8021x
|
||||
/libnm-core/tests/test-setting-dcb
|
||||
/libnm/tests/test-nm-client
|
||||
/libnm/tests/test-remote-settings-client
|
||||
/libnm-util/nm-version.h
|
||||
/libnm-util/nm-setting-docs.xml
|
||||
/libnm-util/test-crypto
|
||||
/libnm-util/tests/test-crypto
|
||||
/libnm-util/tests/test-settings-defaults
|
||||
/libnm-util/tests/test-general
|
||||
/libnm-util/tests/test-libnm-linking
|
||||
/libnm-util/tests/test-need-secrets
|
||||
/libnm-util/tests/test-secrets
|
||||
/libnm-util/tests/test-setting-8021x
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ include $(GLIB_MAKEFILE)
|
|||
SUBDIRS = \
|
||||
. \
|
||||
include \
|
||||
libnm-core \
|
||||
libnm \
|
||||
libnm-util \
|
||||
libnm-glib \
|
||||
introspection \
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ SUBDIRS = . tests
|
|||
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_srcdir}/libnm-util \
|
||||
-I${top_builddir}/libnm-util \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-I${top_builddir}/libnm-core \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-DNETWORKMANAGER_COMPILATION \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
-DNMCONFDIR=\"$(nmconfdir)\" \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
|
|
@ -44,7 +45,7 @@ nm_dispatcher_SOURCES = \
|
|||
nm-dispatcher-utils.h
|
||||
|
||||
nm_dispatcher_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
|
|
@ -63,7 +64,7 @@ libtest_dispatcher_envp_la_CPPFLAGS = \
|
|||
$(AM_CPPFLAGS)
|
||||
|
||||
libtest_dispatcher_envp_la_LIBADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS)
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@
|
|||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#define NM_AVAHI_AUTOIPD_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd"
|
||||
#define NM_AVAHI_AUTOIPD_DBUS_IFACE "org.freedesktop.nm_avahi_autoipd"
|
||||
#define NM_AVAHI_AUTOIPD_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd"
|
||||
#define NM_AVAHI_AUTOIPD_DBUS_INTERFACE "org.freedesktop.nm_avahi_autoipd"
|
||||
|
||||
static DBusConnection *
|
||||
dbus_init (void)
|
||||
|
|
@ -113,7 +113,7 @@ main (int argc, char *argv[])
|
|||
if (connection == NULL)
|
||||
exit (1);
|
||||
|
||||
message = dbus_message_new_signal ("/", NM_AVAHI_AUTOIPD_DBUS_IFACE, "Event");
|
||||
message = dbus_message_new_signal ("/", NM_AVAHI_AUTOIPD_DBUS_INTERFACE, "Event");
|
||||
if (message == NULL) {
|
||||
fprintf (stderr, "Error: not enough memory to send autoip Event signal.\n");
|
||||
exit (1);
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
#define DISPATCHER_TYPE_RESULT (dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))
|
||||
#define DISPATCHER_TYPE_RESULT_ARRAY (dbus_g_type_get_collection ("GPtrArray", DISPATCHER_TYPE_RESULT))
|
||||
|
||||
#define NM_DISPATCHER_DBUS_SERVICE "org.freedesktop.nm_dispatcher"
|
||||
#define NM_DISPATCHER_DBUS_IFACE "org.freedesktop.nm_dispatcher"
|
||||
#define NM_DISPATCHER_DBUS_PATH "/org/freedesktop/nm_dispatcher"
|
||||
#define NM_DISPATCHER_DBUS_SERVICE "org.freedesktop.nm_dispatcher"
|
||||
#define NM_DISPATCHER_DBUS_INTERFACE "org.freedesktop.nm_dispatcher"
|
||||
#define NM_DISPATCHER_DBUS_PATH "/org/freedesktop/nm_dispatcher"
|
||||
|
||||
#define NMD_CONNECTION_PROPS_PATH "path"
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-dbus-interface.h>
|
||||
#include <nm-dbus-glib-types.h>
|
||||
#include <nm-connection.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ if ENABLE_TESTS
|
|||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I$(top_builddir)/libnm-util \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-I$(top_srcdir)/callouts \
|
||||
-DNETWORKMANAGER_COMPILATION \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
|
|
@ -18,7 +19,7 @@ test_dispatcher_envp_SOURCES = \
|
|||
test-dispatcher-envp.c
|
||||
|
||||
test_dispatcher_envp_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(top_builddir)/callouts/libtest-dispatcher-envp.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-dispatcher-api.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
||||
/*******************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
SUBDIRS = cli tui
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir} \
|
||||
-I${top_srcdir}/libnm-util \
|
||||
-I${top_builddir}/libnm-util \
|
||||
-I${top_srcdir}/libnm-glib \
|
||||
-I${top_builddir}/libnm-glib \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm \
|
||||
-I${top_builddir}/libnm \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
|
|
@ -20,7 +18,6 @@ nm_online_CPPFLAGS = \
|
|||
$(AM_CPPFLAGS)
|
||||
|
||||
nm_online_LDADD = \
|
||||
$(top_builddir)/libnm-glib/libnm-glib.la \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ AM_CPPFLAGS = \
|
|||
-I${top_srcdir} \
|
||||
-I${top_builddir} \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_srcdir}/libnm-util \
|
||||
-I${top_builddir}/libnm-util \
|
||||
-I${top_srcdir}/libnm-glib \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm \
|
||||
-I${top_builddir}/libnm \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\""nmcli"\" \
|
||||
|
|
@ -34,8 +35,7 @@ nmcli_LDADD = \
|
|||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(READLINE_LIBS) \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm-glib/libnm-glib.la
|
||||
$(top_builddir)/libnm/libnm.la
|
||||
|
||||
if BUILD_SETTING_DOCS
|
||||
settings-docs.c: settings-docs.xsl $(top_builddir)/libnm-util/nm-setting-docs.xml
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ print_ip6_config (NMIP6Config *cfg6,
|
|||
}
|
||||
|
||||
gboolean
|
||||
print_dhcp4_config (NMDHCP4Config *dhcp4,
|
||||
print_dhcp4_config (NMDhcp4Config *dhcp4,
|
||||
NmCli *nmc,
|
||||
const char *group_prefix,
|
||||
const char *one_field)
|
||||
|
|
@ -334,7 +334,7 @@ print_dhcp4_config (NMDHCP4Config *dhcp4,
|
|||
}
|
||||
|
||||
gboolean
|
||||
print_dhcp6_config (NMDHCP6Config *dhcp6,
|
||||
print_dhcp6_config (NMDhcp6Config *dhcp6,
|
||||
NmCli *nmc,
|
||||
const char *group_prefix,
|
||||
const char *one_field)
|
||||
|
|
@ -897,7 +897,7 @@ nmc_device_reason_to_string (NMDeviceStateReason reason)
|
|||
}
|
||||
|
||||
|
||||
/* Max priority values from libnm-util/nm-setting-vlan.c */
|
||||
/* Max priority values from libnm-core/nm-setting-vlan.c */
|
||||
#define MAX_SKB_PRIO G_MAXUINT32
|
||||
#define MAX_8021P_PRIO 7 /* Max 802.1p priority */
|
||||
|
||||
|
|
|
|||
|
|
@ -22,20 +22,12 @@
|
|||
#ifndef NMC_COMMON_H
|
||||
#define NMC_COMMON_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <nm-ip4-config.h>
|
||||
#include <nm-ip6-config.h>
|
||||
#include <nm-dhcp4-config.h>
|
||||
#include <nm-dhcp6-config.h>
|
||||
#include <nm-device.h>
|
||||
|
||||
#include "nmcli.h"
|
||||
|
||||
gboolean print_ip4_config (NMIP4Config *cfg4, NmCli *nmc, const char *group_prefix, const char *one_field);
|
||||
gboolean print_ip6_config (NMIP6Config *cfg6, NmCli *nmc, const char *group_prefix, const char *one_field);
|
||||
gboolean print_dhcp4_config (NMDHCP4Config *dhcp4, NmCli *nmc, const char *group_prefix, const char *one_field);
|
||||
gboolean print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix, const char *one_field);
|
||||
gboolean print_dhcp4_config (NMDhcp4Config *dhcp4, NmCli *nmc, const char *group_prefix, const char *one_field);
|
||||
gboolean print_dhcp6_config (NMDhcp6Config *dhcp6, NmCli *nmc, const char *group_prefix, const char *one_field);
|
||||
|
||||
NMIP4Address *nmc_parse_and_build_ip4_address (const char *ip_str, const char *gw_str, GError **error);
|
||||
NMIP6Address *nmc_parse_and_build_ip6_address (const char *ip_str, const char *gw_str, GError **error);
|
||||
|
|
|
|||
|
|
@ -33,25 +33,6 @@
|
|||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#include <nm-client.h>
|
||||
#include <nm-device-ethernet.h>
|
||||
#include <nm-device-adsl.h>
|
||||
#include <nm-device-wifi.h>
|
||||
#if WITH_WIMAX
|
||||
#include <nm-device-wimax.h>
|
||||
#endif
|
||||
#include <nm-device-modem.h>
|
||||
#include <nm-device-bt.h>
|
||||
#include <nm-device-olpc-mesh.h>
|
||||
#include <nm-device-infiniband.h>
|
||||
#include <nm-device-bond.h>
|
||||
#include <nm-device-team.h>
|
||||
#include <nm-device-bridge.h>
|
||||
#include <nm-device-vlan.h>
|
||||
#include <nm-remote-settings.h>
|
||||
#include <nm-vpn-connection.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "common.h"
|
||||
#include "settings.h"
|
||||
|
|
@ -567,7 +548,7 @@ active_connection_state_to_string (NMActiveConnectionState state)
|
|||
}
|
||||
|
||||
static const char *
|
||||
vpn_connection_state_to_string (NMVPNConnectionState state)
|
||||
vpn_connection_state_to_string (NMVpnConnectionState state)
|
||||
{
|
||||
switch (state) {
|
||||
case NM_VPN_CONNECTION_STATE_PREPARE:
|
||||
|
|
@ -1088,7 +1069,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
|
|||
/* DHCP4 */
|
||||
if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[2].name) == 0) {
|
||||
gboolean b1 = FALSE;
|
||||
NMDHCP4Config *dhcp4 = nm_active_connection_get_dhcp4_config (acon);
|
||||
NMDhcp4Config *dhcp4 = nm_active_connection_get_dhcp4_config (acon);
|
||||
|
||||
b1 = print_dhcp4_config (dhcp4, nmc, "DHCP4", group_fld);
|
||||
was_output = was_output || b1;
|
||||
|
|
@ -1106,7 +1087,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
|
|||
/* DHCP6 */
|
||||
if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[4].name) == 0) {
|
||||
gboolean b1 = FALSE;
|
||||
NMDHCP6Config *dhcp6 = nm_active_connection_get_dhcp6_config (acon);
|
||||
NMDhcp6Config *dhcp6 = nm_active_connection_get_dhcp6_config (acon);
|
||||
|
||||
b1 = print_dhcp6_config (dhcp6, nmc, "DHCP6", group_fld);
|
||||
was_output = was_output || b1;
|
||||
|
|
@ -1117,8 +1098,8 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
|
|||
strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[5].name) == 0) {
|
||||
NMConnection *con;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingVPN *s_vpn;
|
||||
NMVPNConnectionState vpn_state;
|
||||
NMSettingVpn *s_vpn;
|
||||
NMVpnConnectionState vpn_state;
|
||||
char *type_str, *banner_str, *vpn_state_str;
|
||||
const char *username = NULL;
|
||||
char **vpn_data_array = NULL;
|
||||
|
|
@ -1625,7 +1606,7 @@ find_device_for_connection (NmCli *nmc,
|
|||
}
|
||||
|
||||
static const char *
|
||||
vpn_connection_state_reason_to_string (NMVPNConnectionStateReason reason)
|
||||
vpn_connection_state_reason_to_string (NMVpnConnectionStateReason reason)
|
||||
{
|
||||
switch (reason) {
|
||||
case NM_VPN_CONNECTION_STATE_REASON_UNKNOWN:
|
||||
|
|
@ -1680,9 +1661,9 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin
|
|||
}
|
||||
|
||||
static void
|
||||
vpn_connection_state_cb (NMVPNConnection *vpn,
|
||||
NMVPNConnectionState state,
|
||||
NMVPNConnectionStateReason reason,
|
||||
vpn_connection_state_cb (NMVpnConnection *vpn,
|
||||
NMVpnConnectionState state,
|
||||
NMVpnConnectionStateReason reason,
|
||||
gpointer user_data)
|
||||
{
|
||||
NmCli *nmc = (NmCli *) user_data;
|
||||
|
|
@ -1752,7 +1733,7 @@ progress_device_cb (gpointer user_data)
|
|||
static gboolean
|
||||
progress_vpn_cb (gpointer user_data)
|
||||
{
|
||||
NMVPNConnection *vpn = (NMVPNConnection *) user_data;
|
||||
NMVpnConnection *vpn = (NMVpnConnection *) user_data;
|
||||
const char *str;
|
||||
|
||||
str = NM_IS_VPN_CONNECTION (vpn) ?
|
||||
|
|
@ -2220,7 +2201,7 @@ static const NameItem nmc_adsl_settings [] = {
|
|||
};
|
||||
|
||||
/* PPPoE is a base connection type from historical reasons.
|
||||
* See libnm-util/nm-setting.c:_nm_setting_is_base_type()
|
||||
* See libnm-core/nm-setting.c:_nm_setting_is_base_type()
|
||||
*/
|
||||
static const NameItem nmc_pppoe_settings [] = {
|
||||
{ NM_SETTING_CONNECTION_SETTING_NAME, NULL, NULL, TRUE },
|
||||
|
|
@ -3643,7 +3624,7 @@ complete_connection_by_type (NMConnection *connection,
|
|||
NMSettingInfiniband *s_infiniband;
|
||||
NMSettingWireless *s_wifi;
|
||||
NMSettingWimax *s_wimax;
|
||||
NMSettingPPPOE *s_pppoe;
|
||||
NMSettingPppoe *s_pppoe;
|
||||
NMSettingGsm *s_gsm;
|
||||
NMSettingCdma *s_cdma;
|
||||
NMSettingBluetooth *s_bt;
|
||||
|
|
@ -3653,7 +3634,7 @@ complete_connection_by_type (NMConnection *connection,
|
|||
NMSettingTeamPort *s_team_port;
|
||||
NMSettingBridge *s_bridge;
|
||||
NMSettingBridgePort *s_bridge_port;
|
||||
NMSettingVPN *s_vpn;
|
||||
NMSettingVpn *s_vpn;
|
||||
NMSettingOlpcMesh *s_olpc_mesh;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
|
@ -3968,7 +3949,7 @@ cleanup_wimax:
|
|||
goto cleanup_pppoe;
|
||||
|
||||
/* Add 'pppoe' setting */
|
||||
s_pppoe = (NMSettingPPPOE *) nm_setting_pppoe_new ();
|
||||
s_pppoe = (NMSettingPppoe *) nm_setting_pppoe_new ();
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_pppoe));
|
||||
g_object_set (s_pppoe, NM_SETTING_PPPOE_USERNAME, username, NULL);
|
||||
g_object_set (s_pppoe, NM_SETTING_PPPOE_PASSWORD, password, NULL);
|
||||
|
|
@ -4808,7 +4789,7 @@ cleanup_bridge_slave:
|
|||
do_questionnaire_vpn (&user);
|
||||
|
||||
/* Add 'vpn' setting */
|
||||
s_vpn = (NMSettingVPN *) nm_setting_vpn_new ();
|
||||
s_vpn = (NMSettingVpn *) nm_setting_vpn_new ();
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_vpn));
|
||||
|
||||
g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, service_type, NULL);
|
||||
|
|
@ -8645,6 +8626,7 @@ do_connections (NmCli *nmc, int argc, char **argv)
|
|||
{
|
||||
int i = 0;
|
||||
gboolean real_cmd = FALSE;
|
||||
GError *error = NULL;
|
||||
|
||||
if (argc == 0)
|
||||
real_cmd = TRUE;
|
||||
|
|
@ -8672,8 +8654,9 @@ do_connections (NmCli *nmc, int argc, char **argv)
|
|||
args_info.argv = argv;
|
||||
|
||||
/* get system settings */
|
||||
if (!(nmc->system_settings = nm_remote_settings_new (NULL))) {
|
||||
g_string_printf (nmc->return_text, _("Error: Could not get system settings."));
|
||||
if (!(nmc->system_settings = nm_remote_settings_new (NULL, &error))) {
|
||||
g_string_printf (nmc->return_text, _("Error: Could not get system settings: %s."), error->message);
|
||||
g_error_free (error);
|
||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||
nmc->should_wait = FALSE;
|
||||
return nmc->return_value;
|
||||
|
|
|
|||
|
|
@ -29,39 +29,6 @@
|
|||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <nm-client.h>
|
||||
#include <nm-device.h>
|
||||
#include <nm-device-ethernet.h>
|
||||
#include <nm-device-adsl.h>
|
||||
#include <nm-device-wifi.h>
|
||||
#include <nm-device-modem.h>
|
||||
#include <nm-device-bt.h>
|
||||
#include <nm-device-olpc-mesh.h>
|
||||
#if WITH_WIMAX
|
||||
#include <nm-device-wimax.h>
|
||||
#endif
|
||||
#include <nm-device-infiniband.h>
|
||||
#include <nm-device-bond.h>
|
||||
#include <nm-device-bridge.h>
|
||||
#include <nm-device-vlan.h>
|
||||
#include <nm-utils.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <nm-setting-ip6-config.h>
|
||||
#include <nm-vpn-connection.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-wired.h>
|
||||
#include <nm-setting-adsl.h>
|
||||
#include <nm-setting-pppoe.h>
|
||||
#include <nm-setting-wireless.h>
|
||||
#include <nm-setting-gsm.h>
|
||||
#include <nm-setting-cdma.h>
|
||||
#include <nm-setting-bluetooth.h>
|
||||
#include <nm-setting-olpc-mesh.h>
|
||||
#if WITH_WIMAX
|
||||
#include <nm-setting-wimax.h>
|
||||
#endif
|
||||
#include <nm-setting-infiniband.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "common.h"
|
||||
#include "devices.h"
|
||||
|
|
@ -742,8 +709,8 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
gboolean was_output = FALSE;
|
||||
NMIP4Config *cfg4;
|
||||
NMIP6Config *cfg6;
|
||||
NMDHCP4Config *dhcp4;
|
||||
NMDHCP6Config *dhcp6;
|
||||
NMDhcp4Config *dhcp4;
|
||||
NMDhcp6Config *dhcp6;
|
||||
const char *base_hdr = _("Device details");
|
||||
GPtrArray *fields_in_section = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <nm-client.h>
|
||||
#include <nm-setting-connection.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "network-manager.h"
|
||||
|
|
@ -611,8 +609,9 @@ do_general (NmCli *nmc, int argc, char **argv)
|
|||
}
|
||||
|
||||
/* get system settings */
|
||||
if (!(rem_settings = nm_remote_settings_new (NULL))) {
|
||||
g_string_printf (nmc->return_text, _("Error: Could not get system settings."));
|
||||
if (!(rem_settings = nm_remote_settings_new (NULL, &error))) {
|
||||
g_string_printf (nmc->return_text, _("Error: Could not get system settings: %s."), error->message);
|
||||
g_clear_error (&error);
|
||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||
goto finish;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <nm-client.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-remote-settings.h>
|
||||
|
||||
#include "nmcli.h"
|
||||
#include "utils.h"
|
||||
|
|
@ -394,10 +391,13 @@ setup_signals (void)
|
|||
static NMClient *
|
||||
nmc_get_client (NmCli *nmc)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!nmc->client) {
|
||||
nmc->client = nm_client_new ();
|
||||
nmc->client = nm_client_new (NULL, &error);
|
||||
if (!nmc->client) {
|
||||
g_critical (_("Error: Could not create NMClient object."));
|
||||
g_critical (_("Error: Could not create NMClient object: %s."), error->message);
|
||||
g_clear_error (&error);
|
||||
exit (NMC_RESULT_ERROR_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@
|
|||
#ifndef NMC_NMCLI_H
|
||||
#define NMC_NMCLI_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <nm-client.h>
|
||||
#include <nm-remote-settings.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
/* nmcli exit codes */
|
||||
typedef enum {
|
||||
|
|
@ -105,7 +102,7 @@ typedef enum {
|
|||
|
||||
/* NmCli - main structure */
|
||||
typedef struct _NmCli {
|
||||
NMClient *client; /* Pointer to NMClient of libnm-glib */
|
||||
NMClient *client; /* Pointer to NMClient of libnm */
|
||||
NMClient *(*get_client) (struct _NmCli *nmc); /* Pointer to function for creating NMClient */
|
||||
|
||||
NMCResultCode return_value; /* Return code of nmcli */
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <libnm-util/nm-utils.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "common.h"
|
||||
|
|
@ -421,11 +420,9 @@ NmcOutputField nmc_fields_setting_gsm[] = {
|
|||
SETTING_FIELD (NM_SETTING_GSM_PASSWORD_FLAGS, 20), /* 4 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_APN, 25), /* 5 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_NETWORK_ID, 12), /* 6 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_NETWORK_TYPE, 15), /* 7 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_ALLOWED_BANDS, 15), /* 8 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_PIN, 10), /* 9 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_PIN_FLAGS, 20), /* 10 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_HOME_ONLY, 10), /* 11 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_PIN, 10), /* 7 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_PIN_FLAGS, 20), /* 8 */
|
||||
SETTING_FIELD (NM_SETTING_GSM_HOME_ONLY, 10), /* 9 */
|
||||
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
|
||||
};
|
||||
#define NMC_FIELDS_SETTING_GSM_ALL "name"","\
|
||||
|
|
@ -435,8 +432,6 @@ NmcOutputField nmc_fields_setting_gsm[] = {
|
|||
NM_SETTING_GSM_PASSWORD_FLAGS","\
|
||||
NM_SETTING_GSM_APN","\
|
||||
NM_SETTING_GSM_NETWORK_ID","\
|
||||
NM_SETTING_GSM_NETWORK_TYPE","\
|
||||
NM_SETTING_GSM_ALLOWED_BANDS","\
|
||||
NM_SETTING_GSM_PIN","\
|
||||
NM_SETTING_GSM_PIN_FLAGS","\
|
||||
NM_SETTING_GSM_HOME_ONLY
|
||||
|
|
@ -692,56 +687,6 @@ byte_array_to_string (const GByteArray *array)
|
|||
return cert ? g_string_free (cert, FALSE) : NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
allowed_bands_to_string (guint32 bands)
|
||||
{
|
||||
GString *band_str;
|
||||
|
||||
if (bands == NM_SETTING_GSM_BAND_UNKNOWN)
|
||||
return g_strdup (_("0 (unknown)"));
|
||||
|
||||
band_str = g_string_new (NULL);
|
||||
g_string_printf (band_str, "%d (", bands);
|
||||
|
||||
if (bands & NM_SETTING_GSM_BAND_ANY)
|
||||
g_string_append (band_str, _("any, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_EGSM)
|
||||
g_string_append (band_str, _("900 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_DCS)
|
||||
g_string_append (band_str, _("1800 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_PCS)
|
||||
g_string_append (band_str, _("1900 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_G850)
|
||||
g_string_append (band_str, _("850 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U2100)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 2100 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U1800)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 1800 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U17IV)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 1700/2100 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U800)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 800 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U850)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 850 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U900)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 900 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U17IX)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 1700 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U1900)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 1900 MHz, "));
|
||||
if (bands & NM_SETTING_GSM_BAND_U2600)
|
||||
g_string_append (band_str, _("WCDMA 3GPP UMTS 2600 MHz, "));
|
||||
|
||||
if (band_str->str[band_str->len-1] == '(')
|
||||
g_string_append (band_str, _("unknown"));
|
||||
else
|
||||
g_string_truncate (band_str, band_str->len-2); /* chop off trailing ', ' */
|
||||
|
||||
g_string_append_c (band_str, ')');
|
||||
|
||||
return g_string_free (band_str, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
vlan_flags_to_string (guint32 flags)
|
||||
{
|
||||
|
|
@ -1245,17 +1190,6 @@ DEFINE_GETTER (nmc_property_gsm_get_password, NM_SETTING_GSM_PASSWORD)
|
|||
DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_password_flags, NM_SETTING_GSM_PASSWORD_FLAGS)
|
||||
DEFINE_GETTER (nmc_property_gsm_get_apn, NM_SETTING_GSM_APN)
|
||||
DEFINE_GETTER (nmc_property_gsm_get_network_id, NM_SETTING_GSM_NETWORK_ID)
|
||||
DEFINE_GETTER (nmc_property_gsm_get_network_type, NM_SETTING_GSM_NETWORK_TYPE)
|
||||
|
||||
static char *
|
||||
nmc_property_gsm_get_allowed_bands (NMSetting *setting)
|
||||
{
|
||||
NMSettingGsm *s_gsm = NM_SETTING_GSM (setting);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
return allowed_bands_to_string (nm_setting_gsm_get_allowed_bands (s_gsm));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
DEFINE_GETTER (nmc_property_gsm_get_pin, NM_SETTING_GSM_PIN)
|
||||
DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_pin_flags, NM_SETTING_GSM_PIN_FLAGS)
|
||||
DEFINE_GETTER (nmc_property_gsm_get_home_only, NM_SETTING_GSM_HOME_ONLY)
|
||||
|
|
@ -1410,7 +1344,7 @@ DEFINE_GETTER (nmc_property_vpn_get_user_name, NM_SETTING_VPN_USER_NAME)
|
|||
static char *
|
||||
nmc_property_vpn_get_data (NMSetting *setting)
|
||||
{
|
||||
NMSettingVPN *s_vpn = NM_SETTING_VPN (setting);
|
||||
NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
|
||||
GString *data_item_str;
|
||||
|
||||
data_item_str = g_string_new (NULL);
|
||||
|
|
@ -1422,7 +1356,7 @@ nmc_property_vpn_get_data (NMSetting *setting)
|
|||
static char *
|
||||
nmc_property_vpn_get_secrets (NMSetting *setting)
|
||||
{
|
||||
NMSettingVPN *s_vpn = NM_SETTING_VPN (setting);
|
||||
NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
|
||||
GString *secret_str;
|
||||
|
||||
secret_str = g_string_new (NULL);
|
||||
|
|
@ -2086,26 +2020,6 @@ nmc_property_set_string (NMSetting *setting, const char *prop, const char *val,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
{
|
||||
long val_int;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
if (!nmc_string_to_int (val, TRUE, G_MININT, G_MAXINT, &val_int)) {
|
||||
g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Validate the number according to the property spec */
|
||||
if (!validate_int (setting, prop, (gint) val_int, error))
|
||||
return FALSE;
|
||||
|
||||
g_object_set (setting, prop, val_int, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nmc_property_set_uint (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
{
|
||||
|
|
@ -2340,7 +2254,7 @@ nmc_property_con_set_uuid (NMSetting *setting, const char *prop, const char *val
|
|||
#endif
|
||||
|
||||
/* 'permissions' */
|
||||
/* define from libnm-util/nm-setting-connection.c */
|
||||
/* define from libnm-core/nm-setting-connection.c */
|
||||
#define PERM_USER_PREFIX "user:"
|
||||
|
||||
static gboolean
|
||||
|
|
@ -3826,7 +3740,7 @@ nmc_property_vlan_remove_egress_priority_map (NMSetting *setting,
|
|||
/* 'data' */
|
||||
DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data,
|
||||
NM_SETTING_VPN,
|
||||
NMSettingVPN,
|
||||
NMSettingVpn,
|
||||
nm_setting_vpn_add_data_item,
|
||||
NULL,
|
||||
NULL)
|
||||
|
|
@ -3837,7 +3751,7 @@ DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data,
|
|||
/* 'secrets' */
|
||||
DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets,
|
||||
NM_SETTING_VPN,
|
||||
NMSettingVPN,
|
||||
NMSettingVpn,
|
||||
nm_setting_vpn_add_secret,
|
||||
NULL,
|
||||
NULL)
|
||||
|
|
@ -3913,7 +3827,7 @@ nmc_property_wired_set_s390_subchannels (NMSetting *setting, const char *prop, c
|
|||
char **strv = NULL, **iter;
|
||||
GPtrArray *s390_subchannels;
|
||||
|
||||
//FIXME: both libnm-util and ifcfg-rh also allow two strings (3rd is optional)
|
||||
//FIXME: both libnm and ifcfg-rh also allow two strings (3rd is optional)
|
||||
strv = nmc_strsplit_set (val, " ,\t", 0);
|
||||
if (g_strv_length (strv) != 3) {
|
||||
g_set_error (error, 1, 0, _("'%s' is not valid; 3 strings should be provided"),
|
||||
|
|
@ -5285,20 +5199,6 @@ nmc_properties_init (void)
|
|||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
nmc_add_prop_funcs (GLUE (GSM, NETWORK_TYPE),
|
||||
nmc_property_gsm_get_network_type,
|
||||
nmc_property_set_int,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
nmc_add_prop_funcs (GLUE (GSM, ALLOWED_BANDS),
|
||||
nmc_property_gsm_get_allowed_bands,
|
||||
nmc_property_set_uint,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
nmc_property_out2in_cut_paren);
|
||||
nmc_add_prop_funcs (GLUE (GSM, PIN),
|
||||
nmc_property_gsm_get_pin,
|
||||
nmc_property_set_string,
|
||||
|
|
@ -6767,7 +6667,7 @@ setting_serial_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
|||
static gboolean
|
||||
setting_ppp_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
||||
{
|
||||
NMSettingPPP *s_ppp = NM_SETTING_PPP (setting);
|
||||
NMSettingPpp *s_ppp = NM_SETTING_PPP (setting);
|
||||
NmcOutputField *tmpl, *arr;
|
||||
size_t tmpl_len;
|
||||
|
||||
|
|
@ -6810,7 +6710,7 @@ setting_ppp_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
|||
static gboolean
|
||||
setting_pppoe_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
||||
{
|
||||
NMSettingPPPOE *s_pppoe = NM_SETTING_PPPOE (setting);
|
||||
NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting);
|
||||
NmcOutputField *tmpl, *arr;
|
||||
size_t tmpl_len;
|
||||
|
||||
|
|
@ -6860,11 +6760,9 @@ setting_gsm_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
|||
set_val_str (arr, 4, nmc_property_gsm_get_password_flags (setting));
|
||||
set_val_str (arr, 5, nmc_property_gsm_get_apn (setting));
|
||||
set_val_str (arr, 6, nmc_property_gsm_get_network_id (setting));
|
||||
set_val_str (arr, 7, nmc_property_gsm_get_network_type (setting));
|
||||
set_val_str (arr, 8, nmc_property_gsm_get_allowed_bands (setting));
|
||||
set_val_str (arr, 9, nmc_property_gsm_get_pin (setting));
|
||||
set_val_str (arr, 10, nmc_property_gsm_get_pin_flags (setting));
|
||||
set_val_str (arr, 11, nmc_property_gsm_get_home_only (setting));
|
||||
set_val_str (arr, 7, nmc_property_gsm_get_pin (setting));
|
||||
set_val_str (arr, 8, nmc_property_gsm_get_pin_flags (setting));
|
||||
set_val_str (arr, 9, nmc_property_gsm_get_home_only (setting));
|
||||
g_ptr_array_add (nmc->output_data, arr);
|
||||
|
||||
print_data (nmc); /* Print all data */
|
||||
|
|
@ -6959,7 +6857,7 @@ setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
|||
static gboolean
|
||||
setting_vpn_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
||||
{
|
||||
NMSettingVPN *s_vpn = NM_SETTING_VPN (setting);
|
||||
NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
|
||||
NmcOutputField *tmpl, *arr;
|
||||
size_t tmpl_len;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,30 +20,6 @@
|
|||
#ifndef NMC_SETTINGS_H
|
||||
#define NMC_SETTINGS_H
|
||||
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-wired.h>
|
||||
#include <nm-setting-adsl.h>
|
||||
#include <nm-setting-8021x.h>
|
||||
#include <nm-setting-wireless.h>
|
||||
#include <nm-setting-wireless-security.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <nm-setting-ip6-config.h>
|
||||
#include <nm-setting-serial.h>
|
||||
#include <nm-setting-ppp.h>
|
||||
#include <nm-setting-pppoe.h>
|
||||
#include <nm-setting-gsm.h>
|
||||
#include <nm-setting-cdma.h>
|
||||
#include <nm-setting-bluetooth.h>
|
||||
#include <nm-setting-olpc-mesh.h>
|
||||
#include <nm-setting-vpn.h>
|
||||
#include <nm-setting-wimax.h>
|
||||
#include <nm-setting-infiniband.h>
|
||||
#include <nm-setting-bond.h>
|
||||
#include <nm-setting-bridge.h>
|
||||
#include <nm-setting-bridge-port.h>
|
||||
#include <nm-setting-vlan.h>
|
||||
#include <nm-setting-dcb.h>
|
||||
|
||||
#include "nmcli.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
#ifndef NMC_UTILS_H
|
||||
#define NMC_UTILS_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "nmcli.h"
|
||||
|
||||
/* === Types === */
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-client.h"
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#define PROGRESS_STEPS 15
|
||||
#define WAIT_STARTUP_TAG "wait-startup"
|
||||
|
|
@ -143,6 +143,7 @@ main (int argc, char *argv[])
|
|||
NMState state = NM_STATE_UNKNOWN;
|
||||
GMainLoop *loop;
|
||||
gint64 remaining_ms;
|
||||
GError *error = NULL;
|
||||
|
||||
GOptionEntry options[] = {
|
||||
{"timeout", 't', 0, G_OPTION_ARG_INT, &t_secs, N_("Time to wait for a connection, in seconds (without the option, default value is 30)"), "<timeout>"},
|
||||
|
|
@ -191,9 +192,10 @@ main (int argc, char *argv[])
|
|||
g_type_init ();
|
||||
#endif
|
||||
|
||||
client = nm_client_new ();
|
||||
client = nm_client_new (NULL, &error);
|
||||
if (!client) {
|
||||
g_printerr (_("Error: Could not create NMClient object."));
|
||||
g_printerr (_("Error: Could not create NMClient object: %s."), error->message);
|
||||
g_error_free (error);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ SUBDIRS = newt .
|
|||
AM_CPPFLAGS= \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I$(top_builddir)/libnm-util \
|
||||
-I$(top_srcdir)/libnm-glib \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-I$(top_srcdir)/libnm \
|
||||
-I$(top_builddir)/libnm \
|
||||
-I$(srcdir)/newt \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(NEWT_CFLAGS) \
|
||||
|
|
@ -113,8 +114,7 @@ nmtui_SOURCES = \
|
|||
$(NULL)
|
||||
|
||||
nmtui_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm-glib/libnm-glib.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(builddir)/newt/libnmt-newt.a \
|
||||
$(GUDEV_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ nmt_newt_form_destroy (NmtNewtForm *form)
|
|||
|
||||
/* A "normal" newt program would call newtFormRun() to run newt's main loop
|
||||
* and process events. But we want to let GLib's main loop control the program
|
||||
* (eg, so libnm-glib can process D-Bus notifications). So we call this function
|
||||
* (eg, so libnm can process D-Bus notifications). So we call this function
|
||||
* to run a single iteration of newt's main loop (or rather, to run newt's
|
||||
* main loop for 1ms) whenever there are events for newt to process (redrawing
|
||||
* or keypresses).
|
||||
|
|
|
|||
|
|
@ -19,10 +19,7 @@
|
|||
#ifndef NM_EDITOR_BINDINGS_H
|
||||
#define NM_EDITOR_BINDINGS_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <nm-connection.h>
|
||||
#include <nm-setting-wireless-security.h>
|
||||
#include <nm-setting-vlan.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -28,16 +28,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include <nm-device-bond.h>
|
||||
#include <nm-device-bridge.h>
|
||||
#include <nm-device-team.h>
|
||||
#include <nm-device-ethernet.h>
|
||||
#include <nm-device-infiniband.h>
|
||||
#include <nm-device-team.h>
|
||||
#include <nm-device-vlan.h>
|
||||
#include <nm-device-wifi.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nm-editor-utils.h"
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
#ifndef NM_EDITOR_UTILS_H
|
||||
#define NM_EDITOR_UTILS_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <nm-remote-settings.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <nm-access-point.h>
|
||||
#include <nm-device-wifi.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmtui.h"
|
||||
#include "nmt-connect-connection-list.h"
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@
|
|||
#include <linux/if_arp.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <nm-device.h>
|
||||
#include <nm-device-infiniband.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmtui.h"
|
||||
#include "nmt-device-entry.h"
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@
|
|||
|
||||
#include "nmt-page-grid.h"
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <nm-device.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "nmt-newt.h"
|
||||
|
||||
#include <nm-remote-connection.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef NMT_EDITOR_PAGE_H
|
||||
#define NMT_EDITOR_PAGE_H
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-page-grid.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef NMT_EDITOR_H
|
||||
#define NMT_EDITOR_H
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-newt.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-mac-entry.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@
|
|||
#include <glib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <nm-device.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-page-main.h"
|
||||
#include "nmt-device-entry.h"
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@
|
|||
#include <glib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <nm-device-ethernet.h>
|
||||
|
||||
#include "nm-editor-bindings.h"
|
||||
|
||||
#include "nmt-page-vlan.h"
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "nmt-page-wifi.h"
|
||||
#include "nmt-mac-entry.h"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef NMT_ROUTE_EDITOR_H
|
||||
#define NMT_ROUTE_EDITOR_H
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-newt.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <nm-setting-ip6-config.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-route-entry.h"
|
||||
#include "nmt-ip-entry.h"
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@
|
|||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-utils-private.h>
|
||||
|
||||
#include "nmt-route-table.h"
|
||||
#include "nmt-route-entry.h"
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@
|
|||
#include <dbus/dbus-glib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "nmt-secret-agent.h"
|
||||
#include "nmt-newt.h"
|
||||
|
||||
|
|
@ -298,7 +296,7 @@ static gboolean
|
|||
add_pppoe_secrets (NmtSecretAgentRequest *request,
|
||||
GPtrArray *secrets)
|
||||
{
|
||||
NMSettingPPPOE *s_pppoe = nm_connection_get_setting_pppoe (request->connection);
|
||||
NMSettingPppoe *s_pppoe = nm_connection_get_setting_pppoe (request->connection);
|
||||
NmtSecretAgentSecret *secret;
|
||||
|
||||
secret = nmt_secret_agent_secret_new (_("Username"),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef NMT_SECRET_AGENT_H
|
||||
#define NMT_SECRET_AGENT_H
|
||||
|
||||
#include <nm-secret-agent.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <nm-remote-connection.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-slave-list.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "nmt-newt.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmtui.h"
|
||||
#include "nmtui-edit.h"
|
||||
|
|
|
|||
|
|
@ -33,10 +33,7 @@
|
|||
#include <glib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <nm-client.h>
|
||||
#include <nm-connection.h>
|
||||
#include <nm-remote-settings.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nmt-newt.h"
|
||||
#include "nm-editor-bindings.h"
|
||||
|
|
@ -246,13 +243,23 @@ main (int argc, char **argv)
|
|||
|
||||
nm_editor_bindings_init ();
|
||||
|
||||
nm_client = nm_client_new ();
|
||||
nm_client = nm_client_new (NULL, &error);
|
||||
if (!nm_client) {
|
||||
g_printerr (_("Could not contact NetworkManager: %s.\n"), error->message);
|
||||
g_error_free (error);
|
||||
exit (1);
|
||||
}
|
||||
if (!nm_client_get_manager_running (nm_client)) {
|
||||
g_printerr ("%s\n", _("NetworkManager is not running."));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
nm_settings = nm_remote_settings_new (NULL);
|
||||
nm_settings = nm_remote_settings_new (NULL, &error);
|
||||
if (!nm_settings) {
|
||||
g_printerr (_("Could not contact NetworkManager: %s.\n"), error->message);
|
||||
g_error_free (error);
|
||||
exit (1);
|
||||
}
|
||||
g_signal_connect (nm_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
|
||||
G_CALLBACK (connections_read), &got_connections);
|
||||
/* coverity[loop_condition] */
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
#ifndef NMTUI_H
|
||||
#define NMTUI_H
|
||||
|
||||
#include <nm-client.h>
|
||||
#include <nm-remote-settings.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* @short_description: VPN-related utilities
|
||||
*
|
||||
* This is copied directly from libnm-gtk and should probably
|
||||
* eventually move into libnm-glib.
|
||||
* eventually move into libnm.
|
||||
*
|
||||
* It is also currently unused in nmtui.
|
||||
*
|
||||
|
|
@ -274,7 +274,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
|
|||
GError *error = NULL;
|
||||
NMVpnPluginUiInterface *plugin;
|
||||
NMSettingConnection *s_con = NULL;
|
||||
NMSettingVPN *s_vpn = NULL;
|
||||
NMSettingVpn *s_vpn = NULL;
|
||||
const char *service_type;
|
||||
const char *id = NULL;
|
||||
gboolean success = FALSE;
|
||||
|
|
@ -363,7 +363,7 @@ vpn_export (NMConnection *connection)
|
|||
{
|
||||
GtkWidget *dialog;
|
||||
NMVpnPluginUiInterface *plugin;
|
||||
NMSettingVPN *s_vpn = NULL;
|
||||
NMSettingVpn *s_vpn = NULL;
|
||||
const char *service_type;
|
||||
const char *home_folder;
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ vpn_export (NMConnection *connection)
|
|||
gboolean
|
||||
vpn_supports_ipv6 (NMConnection *connection)
|
||||
{
|
||||
NMSettingVPN *s_vpn;
|
||||
NMSettingVpn *s_vpn;
|
||||
const char *service_type;
|
||||
NMVpnPluginUiInterface *plugin;
|
||||
guint32 capabilities;
|
||||
|
|
|
|||
|
|
@ -833,6 +833,13 @@ src/devices/team/Makefile
|
|||
src/devices/wifi/Makefile
|
||||
src/devices/wifi/tests/Makefile
|
||||
src/devices/wwan/Makefile
|
||||
libnm-core/nm-version.h
|
||||
libnm-core/Makefile
|
||||
libnm-core/tests/Makefile
|
||||
libnm/libnm.pc
|
||||
libnm/libnm-vpn.pc
|
||||
libnm/Makefile
|
||||
libnm/tests/Makefile
|
||||
libnm-util/libnm-util.pc
|
||||
libnm-util/nm-version.h
|
||||
libnm-util/Makefile
|
||||
|
|
@ -873,6 +880,8 @@ docs/libnm-glib/Makefile
|
|||
docs/libnm-glib/version.xml
|
||||
docs/libnm-util/Makefile
|
||||
docs/libnm-util/version.xml
|
||||
docs/libnm/Makefile
|
||||
docs/libnm/version.xml
|
||||
NetworkManager.pc
|
||||
examples/Makefile
|
||||
examples/shell/Makefile
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ Requires: glib2 >= %{glib2_version}
|
|||
Requires: iproute
|
||||
Requires: dhclient >= 12:4.1.0
|
||||
Requires: libnl3 >= %{libnl3_version}
|
||||
Requires: %{name}-glib%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: %{name}-libnm%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: ppp = %{ppp_version}
|
||||
Requires: avahi-autoipd
|
||||
Requires: dnsmasq
|
||||
|
|
@ -256,7 +256,7 @@ devices.
|
|||
|
||||
|
||||
%package devel
|
||||
Summary: Libraries and headers for adding NetworkManager support to applications
|
||||
Summary: Headers defining the NetworkManager D-Bus APIs
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{epoch}:%{version}-%{release}
|
||||
Requires: dbus-devel >= %{dbus_version}
|
||||
|
|
@ -269,18 +269,19 @@ from applications.
|
|||
|
||||
|
||||
%package glib
|
||||
Summary: Libraries for adding NetworkManager support to applications that use glib.
|
||||
Summary: Libraries for adding NetworkManager support to applications (old API).
|
||||
Group: Development/Libraries
|
||||
Requires: dbus >= %{dbus_version}
|
||||
Requires: dbus-glib >= %{dbus_glib_version}
|
||||
|
||||
%description glib
|
||||
This package contains the libraries that make it easier to use some NetworkManager
|
||||
functionality from applications that use glib.
|
||||
functionality from applications that use glib. This is the older NetworkManager API.
|
||||
See also NetworkManager-libnm.
|
||||
|
||||
|
||||
%package glib-devel
|
||||
Summary: Header files for adding NetworkManager support to applications that use glib.
|
||||
Summary: Header files for adding NetworkManager support to applications (old API).
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}-devel%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: %{name}-glib%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
|
|
@ -290,7 +291,36 @@ Requires: dbus-glib-devel >= %{dbus_glib_version}
|
|||
|
||||
%description glib-devel
|
||||
This package contains the header and pkg-config files for development applications using
|
||||
NetworkManager functionality from applications that use glib.
|
||||
NetworkManager functionality from applications that use glib. This is the older
|
||||
NetworkManager API. See also NetworkManager-libnm-devel.
|
||||
|
||||
|
||||
%package libnm
|
||||
Summary: Libraries for adding NetworkManager support to applications (new API).
|
||||
Group: Development/Libraries
|
||||
Requires: dbus >= %{dbus_version}
|
||||
Requires: dbus-glib >= %{dbus_glib_version}
|
||||
|
||||
%description libnm
|
||||
This package contains the libraries that make it easier to use some NetworkManager
|
||||
functionality from applications. This is the new NetworkManager API. See also
|
||||
NetworkManager-glib.
|
||||
|
||||
|
||||
%package libnm-devel
|
||||
Summary: Header files for adding NetworkManager support to applications (new API).
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}-devel%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: %{name}-libnm%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: glib2-devel
|
||||
Requires: pkgconfig
|
||||
Requires: dbus-glib-devel >= %{dbus_glib_version}
|
||||
|
||||
%description libnm-devel
|
||||
This package contains the header and pkg-config files for development applications using
|
||||
NetworkManager functionality from applications. This is the new NetworkManager API.
|
||||
See also NetworkManager-glib-devel.
|
||||
|
||||
|
||||
%package config-connectivity-fedora
|
||||
Summary: NetworkManager config file for connectivity checking via Fedora servers
|
||||
|
|
@ -319,7 +349,7 @@ deployments.
|
|||
Summary: NetworkManager curses-based UI
|
||||
Group: System Environment/Base
|
||||
Requires: %{name} = %{epoch}:%{version}-%{release}
|
||||
Requires: %{name}-glib%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: %{name}-libnm%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
|
||||
%description tui
|
||||
This adds a curses-based "TUI" (Text User Interface) to
|
||||
|
|
@ -585,6 +615,24 @@ fi
|
|||
%dir %{_datadir}/gtk-doc/html/libnm-util
|
||||
%{_datadir}/gtk-doc/html/libnm-util/*
|
||||
|
||||
%files libnm
|
||||
%defattr(-,root,root,0755)
|
||||
%{_libdir}/libnm.so.*
|
||||
%{_libdir}/libnm-vpn.so.*
|
||||
%{_libdir}/girepository-1.0/NM-1.0.typelib
|
||||
|
||||
%files libnm-devel
|
||||
%defattr(-,root,root,0755)
|
||||
%dir %{_includedir}/libnm
|
||||
%{_includedir}/libnm/*.h
|
||||
%{_libdir}/pkgconfig/libnm.pc
|
||||
%{_libdir}/pkgconfig/libnm-vpn.pc
|
||||
%{_libdir}/libnm.so
|
||||
%{_libdir}/libnm-vpn.so
|
||||
%{_datadir}/gir-1.0/NM-1.0.gir
|
||||
%dir %{_datadir}/gtk-doc/html/libnm
|
||||
%{_datadir}/gtk-doc/html/libnm/*
|
||||
|
||||
%files config-connectivity-fedora
|
||||
%defattr(-,root,root,0755)
|
||||
%dir %{_sysconfdir}/%{name}/conf.d
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
SUBDIRS = libnm-glib libnm-util api
|
||||
SUBDIRS = libnm-glib libnm-util libnm api
|
||||
|
||||
|
|
|
|||
84
docs/libnm/Makefile.am
Normal file
84
docs/libnm/Makefile.am
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
AUTOMAKE_OPTIONS = 1.6
|
||||
|
||||
# The name of the module
|
||||
DOC_MODULE=libnm
|
||||
|
||||
# The top-level SGML file.
|
||||
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml
|
||||
|
||||
# The directory containing the source code. Relative to $(srcdir).
|
||||
# gtk-doc will search all .c & .h files beneath here for inline comments
|
||||
# documenting functions and macros.
|
||||
DOC_SOURCE_DIR=$(top_srcdir)/libnm-core $(top_srcdir)/libnm
|
||||
|
||||
# Extra options to supply to gtkdoc-scan.
|
||||
SCAN_OPTIONS=--rebuild-types --rebuild-sections
|
||||
|
||||
# Extra options to supply to gtkdoc-scangobj.
|
||||
SCANGOBJ_OPTIONS=--type-init-func 'g_type_init();'
|
||||
|
||||
# Extra options to supply to gtkdoc-mkdb.
|
||||
MKDB_OPTIONS=--sgml-mode --output-format=xml
|
||||
|
||||
# Extra options to supply to gtkdoc-fixref.
|
||||
FIXXREF_OPTIONS=
|
||||
|
||||
# Used for dependencies.
|
||||
HFILE_GLOB=$(top_srcdir)/libnm-core/*.h $(top_srcdir)/libnm/*.h
|
||||
CFILE_GLOB=$(top_srcdir)/libnm-core/*.c $(top_srcdir)/libnm/*.c
|
||||
|
||||
# Header files to ignore when scanning.
|
||||
IGNORE_HFILES= \
|
||||
crypto.h \
|
||||
nm-dbus-helpers-private.h \
|
||||
nm-device-private.h \
|
||||
nm-object-cache.h \
|
||||
nm-object-private.h \
|
||||
nm-param-spec-dbus.h \
|
||||
nm-remote-connection-private.h \
|
||||
nm-secret-agent-glue.h \
|
||||
nm-setting-private.h \
|
||||
nm-types-private.h \
|
||||
nm-utils-private.h \
|
||||
nm-vpn-plugin-glue.h
|
||||
|
||||
# Images to copy into HTML directory.
|
||||
HTML_IMAGES = libnm.png
|
||||
|
||||
# Extra XML files that are included by $(DOC_MAIN_SGML_FILE).
|
||||
content_files = version.xml
|
||||
|
||||
# Other files to distribute.
|
||||
extra_files = libnm.png
|
||||
|
||||
|
||||
# CFLAGS and LDFLAGS for compiling scan program. Only needed
|
||||
# if $(DOC_MODULE).types is non-empty.
|
||||
GTKDOC_CFLAGS = \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-I$(top_srcdir)/libnm \
|
||||
-I$(top_builddir)/libnm \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
|
||||
GTKDOC_LIBS = \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(top_builddir)/libnm/libnm-vpn.la \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
|
||||
# include common portion ...
|
||||
include $(top_srcdir)/gtk-doc.make
|
||||
|
||||
EXTRA_DIST += version.xml.in
|
||||
|
||||
CLEANFILES += \
|
||||
libnm-sections.txt \
|
||||
libnm-overrides.txt \
|
||||
html/* \
|
||||
tmpl/* \
|
||||
xml/*
|
||||
|
||||
161
docs/libnm/libnm-docs.xml
Normal file
161
docs/libnm/libnm-docs.xml
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
|
||||
<!ENTITY version SYSTEM "version.xml">
|
||||
]>
|
||||
|
||||
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
|
||||
<bookinfo>
|
||||
<title>libnm Reference Manual</title>
|
||||
<releaseinfo>
|
||||
for libnm &version;
|
||||
The latest version of this documentation can be found on-line at
|
||||
<ulink role="online-location" url="https://developer.gnome.org/libnm/1.0/">https://developer.gnome.org/libnm/1.0/</ulink>.
|
||||
</releaseinfo>
|
||||
|
||||
<copyright>
|
||||
<year>2012-2014</year>
|
||||
<holder>The NetworkManager Authors</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the <citetitle>GNU Free
|
||||
Documentation License</citetitle>, Version 1.1 or any later
|
||||
version published by the Free Software Foundation with no
|
||||
Invariant Sections, no Front-Cover Texts, and no Back-Cover
|
||||
Texts. You may obtain a copy of the <citetitle>GNU Free
|
||||
Documentation License</citetitle> from the Free Software
|
||||
Foundation by visiting <ulink type="http"
|
||||
url="http://www.fsf.org">their Web site</ulink> or by writing
|
||||
to:
|
||||
|
||||
<address>
|
||||
The Free Software Foundation, Inc.,
|
||||
<street>51 Franklin Street</street> - Fifth Floor,
|
||||
<city>Boston</city>, <state>MA</state> <postcode>02110-1301</postcode>,
|
||||
<country>USA</country>
|
||||
</address>
|
||||
</para>
|
||||
</legalnotice>
|
||||
</bookinfo>
|
||||
|
||||
<chapter id="ref-overview">
|
||||
<title>Overview</title>
|
||||
<para>
|
||||
libnm maps fairly closely to the actual D-Bus API that NetworkManager
|
||||
provides, wrapping the remote D-Bus objects as native GObjects,
|
||||
mapping D-Bus signals and properties to GObject signals and properties,
|
||||
and providing helpful accessor and utility functions. However, unlike
|
||||
the old libnm-util/libnm-glib API, the mapping to the D-Bus API is not
|
||||
exact, and various inconveniences and historical anomolies of the D-Bus
|
||||
API are papered over.
|
||||
</para>
|
||||
<para>
|
||||
The following is a rough overview of the libnm object structure and
|
||||
how to use the various parts of it:
|
||||
<mediaobject id="libnm-overview">
|
||||
<imageobject>
|
||||
<imagedata fileref="libnm.png" format="PNG"/>
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
</para>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Client Object API Reference</title>
|
||||
<xi:include href="xml/nm-client.xml"/>
|
||||
<xi:include href="xml/nm-remote-settings.xml"/>
|
||||
<xi:include href="xml/nm-secret-agent.xml"/>
|
||||
<xi:include href="xml/nm-object.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Connection and Setting API Reference</title>
|
||||
<xi:include href="xml/nm-connection.xml"/>
|
||||
<xi:include href="xml/nm-setting.xml"/>
|
||||
<xi:include href="xml/nm-setting-connection.xml"/>
|
||||
<!-- begin alphabetical -->
|
||||
<xi:include href="xml/nm-setting-8021x.xml"/>
|
||||
<xi:include href="xml/nm-setting-adsl.xml"/>
|
||||
<xi:include href="xml/nm-setting-bluetooth.xml"/>
|
||||
<xi:include href="xml/nm-setting-bond.xml"/>
|
||||
<xi:include href="xml/nm-setting-bridge.xml"/>
|
||||
<xi:include href="xml/nm-setting-bridge-port.xml"/>
|
||||
<xi:include href="xml/nm-setting-cdma.xml"/>
|
||||
<xi:include href="xml/nm-setting-dcb.xml"/>
|
||||
<xi:include href="xml/nm-setting-generic.xml"/>
|
||||
<xi:include href="xml/nm-setting-gsm.xml"/>
|
||||
<xi:include href="xml/nm-setting-infiniband.xml"/>
|
||||
<xi:include href="xml/nm-setting-ip4-config.xml"/>
|
||||
<xi:include href="xml/nm-setting-ip6-config.xml"/>
|
||||
<xi:include href="xml/nm-setting-olpc-mesh.xml"/>
|
||||
<xi:include href="xml/nm-setting-ppp.xml"/>
|
||||
<xi:include href="xml/nm-setting-pppoe.xml"/>
|
||||
<xi:include href="xml/nm-setting-serial.xml"/>
|
||||
<xi:include href="xml/nm-setting-team.xml"/>
|
||||
<xi:include href="xml/nm-setting-team-port.xml"/>
|
||||
<xi:include href="xml/nm-setting-vlan.xml"/>
|
||||
<xi:include href="xml/nm-setting-vpn.xml"/>
|
||||
<xi:include href="xml/nm-setting-wimax.xml"/>
|
||||
<xi:include href="xml/nm-setting-wired.xml"/>
|
||||
<xi:include href="xml/nm-setting-wireless.xml"/>
|
||||
<xi:include href="xml/nm-setting-wireless-security.xml"/>
|
||||
<!-- end alphabetical -->
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Device and Runtime Configuration API Reference</title>
|
||||
<xi:include href="xml/nm-device.xml"/>
|
||||
<!-- begin alphabetical -->
|
||||
<xi:include href="xml/nm-device-adsl.xml"/>
|
||||
<xi:include href="xml/nm-device-bond.xml"/>
|
||||
<xi:include href="xml/nm-device-bridge.xml"/>
|
||||
<xi:include href="xml/nm-device-bt.xml"/>
|
||||
<xi:include href="xml/nm-device-ethernet.xml"/>
|
||||
<xi:include href="xml/nm-device-generic.xml"/>
|
||||
<xi:include href="xml/nm-device-infiniband.xml"/>
|
||||
<xi:include href="xml/nm-device-modem.xml"/>
|
||||
<xi:include href="xml/nm-device-olpc-mesh.xml"/>
|
||||
<xi:include href="xml/nm-device-team.xml"/>
|
||||
<xi:include href="xml/nm-device-vlan.xml"/>
|
||||
<xi:include href="xml/nm-device-wifi.xml"/>
|
||||
<xi:include href="xml/nm-device-wimax.xml"/>
|
||||
<!-- end alphabetical -->
|
||||
<xi:include href="xml/nm-active-connection.xml"/>
|
||||
<xi:include href="xml/nm-vpn-connection.xml"/>
|
||||
<xi:include href="xml/nm-remote-connection.xml"/>
|
||||
<xi:include href="xml/nm-access-point.xml"/>
|
||||
<xi:include href="xml/nm-wimax-nsp.xml"/>
|
||||
<xi:include href="xml/nm-ip4-config.xml"/>
|
||||
<xi:include href="xml/nm-ip6-config.xml"/>
|
||||
<xi:include href="xml/nm-dhcp4-config.xml"/>
|
||||
<xi:include href="xml/nm-dhcp6-config.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Utility API Reference</title>
|
||||
<xi:include href="xml/nm-utils.xml"/>
|
||||
<xi:include href="xml/nm-types.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>VPN Plugin API Reference </title>
|
||||
<xi:include href="xml/nm-vpn-plugin.xml"/>
|
||||
<xi:include href="xml/nm-vpn-plugin-ui-interface.xml"/>
|
||||
<xi:include href="xml/nm-vpn-plugin-utils.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter id="object-tree">
|
||||
<title>Object Hierarchy</title>
|
||||
<xi:include href="xml/tree_index.sgml"/>
|
||||
</chapter>
|
||||
<index id="api-index-full">
|
||||
<title>API Index</title>
|
||||
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
|
||||
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
||||
</book>
|
||||
|
||||
BIN
docs/libnm/libnm.png
Normal file
BIN
docs/libnm/libnm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
893
docs/libnm/libnm.svg
Normal file
893
docs/libnm/libnm.svg
Normal file
|
|
@ -0,0 +1,893 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="1052.3622"
|
||||
height="744.09448"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.1 r9760"
|
||||
sodipodi:docname="libnm-glib.svg">
|
||||
<defs
|
||||
id="defs4">
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path4069"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-2"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path4069-0"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.98994949"
|
||||
inkscape:cx="433.76249"
|
||||
inkscape:cy="491.18568"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1280"
|
||||
inkscape:window-height="739"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="26"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-308.2677)">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="283.85287"
|
||||
y="97.768028"
|
||||
id="text3783"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3787"
|
||||
x="283.85287"
|
||||
y="97.768028"></tspan></text>
|
||||
<flowRoot
|
||||
xml:space="preserve"
|
||||
id="flowRoot3789"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"><flowRegion
|
||||
id="flowRegion3791"><rect
|
||||
id="rect3793"
|
||||
width="139.40105"
|
||||
height="113.13708"
|
||||
x="265.6701"
|
||||
y="97.768028" /></flowRegion><flowPara
|
||||
id="flowPara3795"></flowPara></flowRoot> <flowRoot
|
||||
xml:space="preserve"
|
||||
id="flowRoot3797"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"><flowRegion
|
||||
id="flowRegion3799"><rect
|
||||
id="rect3801"
|
||||
width="208.09143"
|
||||
height="133.34013"
|
||||
x="273.75134"
|
||||
y="121.00153"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans" /></flowRegion><flowPara
|
||||
id="flowPara3803"></flowPara></flowRoot> <flowRoot
|
||||
xml:space="preserve"
|
||||
id="flowRoot3825"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"><flowRegion
|
||||
id="flowRegion3827"><rect
|
||||
id="rect3829"
|
||||
width="175.76654"
|
||||
height="41.416256"
|
||||
x="28.284271"
|
||||
y="88.676651" /></flowRegion><flowPara
|
||||
id="flowPara3831">Propr</flowPara></flowRoot> <g
|
||||
id="g5635"
|
||||
transform="translate(-64.649763,3.0507627)">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3755-0"
|
||||
y="341.21481"
|
||||
x="573.86121"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
y="341.21481"
|
||||
x="573.86121"
|
||||
id="tspan3757-1"
|
||||
sodipodi:role="line">NMClient</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3833-6"
|
||||
y="357.37726"
|
||||
x="529.33325"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
id="tspan3837-8"
|
||||
y="357.37726"
|
||||
x="529.33325"
|
||||
sodipodi:role="line">Base object; provides access to</tspan><tspan
|
||||
id="tspan4548"
|
||||
y="369.87726"
|
||||
x="529.33325"
|
||||
sodipodi:role="line">network device objects, active</tspan><tspan
|
||||
id="tspan4550"
|
||||
y="382.37726"
|
||||
x="529.33325"
|
||||
sodipodi:role="line">network connection objects and</tspan><tspan
|
||||
id="tspan4552"
|
||||
y="394.87726"
|
||||
x="529.33325"
|
||||
sodipodi:role="line">general network state information</tspan></text>
|
||||
</g>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="104.07935"
|
||||
y="372.52951"
|
||||
id="text3833-6-7"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
x="104.07935"
|
||||
y="372.52951"
|
||||
id="tspan4552-6" /></text>
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:2.85214233;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985"
|
||||
width="209.21587"
|
||||
height="312.09604"
|
||||
x="12.270507"
|
||||
y="319.61136" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="40.322777"
|
||||
y="344.24524"
|
||||
id="text3755"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757"
|
||||
x="40.322777"
|
||||
y="344.24524"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold">NMRemoteSettings</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="19.192902"
|
||||
y="360.40768"
|
||||
id="text3833"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.192902"
|
||||
y="360.40768"
|
||||
id="tspan3839">Retrieves, adds, and notifes of changes</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.192902"
|
||||
y="372.90768"
|
||||
id="tspan3837">to network configuration objects</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.192902"
|
||||
y="385.40768"
|
||||
id="tspan4682">(called NMRemoteConnections) </tspan></text>
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:1.13669348;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8"
|
||||
width="176.20061"
|
||||
height="82.832512"
|
||||
x="29.077385"
|
||||
y="403.84424" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
x="38.158276"
|
||||
y="424.04724"
|
||||
id="text3755-3"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8"
|
||||
x="38.158276"
|
||||
y="424.04724"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="36.03054"
|
||||
y="443.60046"
|
||||
id="text3833-0"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
x="36.03054"
|
||||
y="443.60046"
|
||||
id="tspan3837-7">The basic unit of network</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="36.03054"
|
||||
y="456.10046"
|
||||
id="tspan3873">configuration information,</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="36.03054"
|
||||
y="468.60046"
|
||||
id="tspan3875">contains all settings required to</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="36.03054"
|
||||
y="481.10046"
|
||||
id="tspan3877">connect to a specific network.</tspan></text>
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.68221813;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-4"
|
||||
width="176.20061"
|
||||
height="29.837376"
|
||||
x="28.067242"
|
||||
y="494.75793" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
x="37.148129"
|
||||
y="514.96094"
|
||||
id="text3755-3-9"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-0"
|
||||
x="37.148129"
|
||||
y="514.96094"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.68221813;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-4-6"
|
||||
width="176.20061"
|
||||
height="29.837376"
|
||||
x="28.06724"
|
||||
y="532.36725" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
x="37.148129"
|
||||
y="552.57025"
|
||||
id="text3755-3-9-3"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-0-8"
|
||||
x="37.148129"
|
||||
y="552.57025"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.68221813;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-4-8"
|
||||
width="176.20061"
|
||||
height="29.837376"
|
||||
x="28.067238"
|
||||
y="569.74286" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
x="37.148125"
|
||||
y="589.94586"
|
||||
id="text3755-3-9-6"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-0-6"
|
||||
x="37.148125"
|
||||
y="589.94586"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
|
||||
<g
|
||||
id="g5581">
|
||||
<path
|
||||
transform="translate(24,308.27784)"
|
||||
d="m 75.76144,306.19336 a 3.5355339,3.5355339 0 1 1 -7.071068,0 3.5355339,3.5355339 0 1 1 7.071068,0 z"
|
||||
sodipodi:ry="3.5355339"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:cx="72.225906"
|
||||
id="path4776"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
d="m 75.76144,306.19336 a 3.5355339,3.5355339 0 1 1 -7.071068,0 3.5355339,3.5355339 0 1 1 7.071068,0 z"
|
||||
sodipodi:ry="3.5355339"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:cx="72.225906"
|
||||
id="path4776-1"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
sodipodi:type="arc"
|
||||
transform="translate(44.950515,308.27784)" />
|
||||
<path
|
||||
d="m 75.76144,306.19336 a 3.5355339,3.5355339 0 1 1 -7.071068,0 3.5355339,3.5355339 0 1 1 7.071068,0 z"
|
||||
sodipodi:ry="3.5355339"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:cx="72.225906"
|
||||
id="path4776-1-4"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
sodipodi:type="arc"
|
||||
transform="translate(65.901025,308.27784)" />
|
||||
</g>
|
||||
<rect
|
||||
style="fill:none;stroke:#c30000;stroke-width:2.71445656;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-5"
|
||||
width="641.21594"
|
||||
height="454.62848"
|
||||
x="286.68472"
|
||||
y="321.29346" />
|
||||
<g
|
||||
id="g5644"
|
||||
transform="translate(348.50263,-5.0507629)">
|
||||
<rect
|
||||
y="466.47369"
|
||||
x="346.26532"
|
||||
height="68.182198"
|
||||
width="176.20061"
|
||||
id="rect2985-8-9"
|
||||
style="fill:none;stroke:#01003d;stroke-width:1.03128445;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3755-3-5"
|
||||
y="486.6767"
|
||||
x="400.8031"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
y="486.6767"
|
||||
x="400.8031"
|
||||
id="tspan3757-8-00"
|
||||
sodipodi:role="line">NMDevice</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3833-0-5"
|
||||
y="501.17917"
|
||||
x="353.21848"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
id="tspan3877-3"
|
||||
y="501.17917"
|
||||
x="353.21848"
|
||||
sodipodi:role="line">Represents a known network</tspan><tspan
|
||||
id="tspan5003"
|
||||
y="513.6792"
|
||||
x="353.21848"
|
||||
sodipodi:role="line">interface that may be used to</tspan><tspan
|
||||
id="tspan5005"
|
||||
y="526.1792"
|
||||
x="353.21848"
|
||||
sodipodi:role="line">connect to a network</tspan></text>
|
||||
</g>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="706.53918"
|
||||
y="144.96414"
|
||||
id="text5191"
|
||||
sodipodi:linespacing="125%"
|
||||
transform="matrix(0.91955281,0.39296645,-0.39296645,0.91955281,0,0)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan5193"
|
||||
x="706.53918"
|
||||
y="144.96414">nm_client_get_devices()</tspan></text>
|
||||
<g
|
||||
id="g5623"
|
||||
transform="translate(-419.9159,137.94419)">
|
||||
<rect
|
||||
y="447.99072"
|
||||
x="721.03192"
|
||||
height="96.526291"
|
||||
width="176.20061"
|
||||
id="rect2985-8-9-7"
|
||||
style="fill:none;stroke:#01003d;stroke-width:1.22705996;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3755-3-5-9"
|
||||
y="465.92065"
|
||||
x="740.21436"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
y="465.92065"
|
||||
x="740.21436"
|
||||
id="tspan3757-8-00-9"
|
||||
sodipodi:role="line">NMActiveConnection</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3833-0-5-2"
|
||||
y="478.42313"
|
||||
x="723.98505"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
id="tspan5005-7"
|
||||
y="478.42313"
|
||||
x="723.98505"
|
||||
sodipodi:role="line">Represents an active connection</tspan><tspan
|
||||
id="tspan5236"
|
||||
y="490.92313"
|
||||
x="723.98505"
|
||||
sodipodi:role="line">to a specific network, using</tspan><tspan
|
||||
id="tspan5238"
|
||||
y="503.42313"
|
||||
x="723.98505"
|
||||
sodipodi:role="line">settings from an</tspan><tspan
|
||||
id="tspan5240"
|
||||
y="515.9231"
|
||||
x="723.98505"
|
||||
sodipodi:role="line">NMRemoteConnection,and</tspan><tspan
|
||||
id="tspan5449"
|
||||
y="528.4231"
|
||||
x="723.98505"
|
||||
sodipodi:role="line">provided by on or more NMDevice</tspan><tspan
|
||||
id="tspan5451"
|
||||
y="540.9231"
|
||||
x="723.98505"
|
||||
sodipodi:role="line">objects.</tspan></text>
|
||||
</g>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="270.79764"
|
||||
y="722.53766"
|
||||
id="text5191-5"
|
||||
sodipodi:linespacing="125%"
|
||||
transform="matrix(0.94281033,-0.33332969,0.33332969,0.94281033,0,0)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan5193-8"
|
||||
x="270.79764"
|
||||
y="722.53766">nm_active_connection_get_devices()</tspan></text>
|
||||
<g
|
||||
id="g6720"
|
||||
transform="translate(-23.213166,-3.4365595)">
|
||||
<g
|
||||
transform="translate(320.19803,-24.89035)"
|
||||
id="g5561">
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-9-3-4"
|
||||
width="126.1828"
|
||||
height="26.245613"
|
||||
x="397.53818"
|
||||
y="597.80267" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="419.1745"
|
||||
y="615.39911"
|
||||
id="text3755-3-5-1-8"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-00-3-7"
|
||||
x="419.1745"
|
||||
y="615.39911"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMDeviceWifi</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(175.74622,-53.780741)"
|
||||
id="g5566">
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-9-3-5"
|
||||
width="126.1828"
|
||||
height="26.245613"
|
||||
x="541.98999"
|
||||
y="659.422" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="552.62244"
|
||||
y="677.01843"
|
||||
id="text3755-3-5-1-9"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
x="552.62244"
|
||||
y="677.01843"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
id="tspan5526">NMDeviceModem</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(390.90872,-24.082284)"
|
||||
id="g5571">
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-9-3-2"
|
||||
width="126.1828"
|
||||
height="26.245613"
|
||||
x="326.82748"
|
||||
y="662.45251" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="338.79584"
|
||||
y="680.04895"
|
||||
id="text3755-3-5-1-7"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-00-3-1"
|
||||
x="338.79584"
|
||||
y="680.04895"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMDeviceWimax</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(278.7818,-37.820326)"
|
||||
id="g5576">
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-9-3-7"
|
||||
width="126.1828"
|
||||
height="26.245613"
|
||||
x="438.95441"
|
||||
y="708.91949" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="442.65225"
|
||||
y="726.51593"
|
||||
id="text3755-3-5-1-0"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
x="442.65225"
|
||||
y="726.51593"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
id="tspan5552">NMDeviceBluetooth</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
id="g5581-7"
|
||||
transform="translate(663.65119,96.47973)">
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="path4776-10"
|
||||
sodipodi:cx="72.225906"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:ry="3.5355339"
|
||||
d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
|
||||
transform="translate(24,308.27784)" />
|
||||
<path
|
||||
transform="translate(44.950515,308.27784)"
|
||||
sodipodi:type="arc"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="path4776-1-0"
|
||||
sodipodi:cx="72.225906"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:ry="3.5355339"
|
||||
d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z" />
|
||||
<path
|
||||
transform="translate(65.901025,308.27784)"
|
||||
sodipodi:type="arc"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="path4776-1-4-7"
|
||||
sodipodi:cx="72.225906"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:ry="3.5355339"
|
||||
d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z" />
|
||||
</g>
|
||||
<g
|
||||
transform="translate(371.71582,-10.142135)"
|
||||
id="g5556">
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-9-3"
|
||||
width="126.1828"
|
||||
height="26.245613"
|
||||
x="346.02039"
|
||||
y="550.3255" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="352.6069"
|
||||
y="567.92194"
|
||||
id="text3755-3-5-1"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-00-3"
|
||||
x="352.6069"
|
||||
y="567.92194"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMDeviceEthernet</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
|
||||
d="M 553.56359,93.556243 699.43095,153.15523"
|
||||
id="path6047"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connector-curvature="3"
|
||||
inkscape:connection-end="#g5644"
|
||||
inkscape:connection-end-point="d4"
|
||||
transform="translate(0,308.2677)" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
|
||||
d="M 477.31663,294.89252 694.76795,218.28417"
|
||||
id="path6231"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connector-curvature="3"
|
||||
inkscape:connection-start="#g5623"
|
||||
inkscape:connection-start-point="d4"
|
||||
inkscape:connection-end="#g5644"
|
||||
inkscape:connection-end-point="d4"
|
||||
transform="translate(0,308.2677)" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
|
||||
d="M 537.40115,93.556243 419.9937,277.66721"
|
||||
id="path6415"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connector-curvature="3"
|
||||
inkscape:connection-end="#g5623"
|
||||
inkscape:connection-end-point="d4"
|
||||
transform="translate(0,308.2677)" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="-235.89041"
|
||||
y="662.71521"
|
||||
id="text5191-5-1"
|
||||
sodipodi:linespacing="125%"
|
||||
transform="matrix(0.53998594,-0.84167404,0.84167404,0.53998594,0,0)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan5193-8-5"
|
||||
x="-235.89041"
|
||||
y="662.71521">nm_client_get_active_connections()</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="824.3454"
|
||||
y="617.99652"
|
||||
id="text6932"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan6934"
|
||||
x="824.3454"
|
||||
y="617.99652">(Device subclasses)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="685.34247"
|
||||
y="161.22107"
|
||||
id="text5191-9"
|
||||
sodipodi:linespacing="125%"
|
||||
transform="matrix(0.91955281,0.39296645,-0.39296645,0.91955281,0,0)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan5193-1"
|
||||
x="685.34247"
|
||||
y="161.22107">Gets all known interfaces</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="251.42001"
|
||||
y="738.39777"
|
||||
id="text5191-5-5"
|
||||
sodipodi:linespacing="125%"
|
||||
transform="matrix(0.94354535,-0.33124338,0.33124338,0.94354535,0,0)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan5193-8-1"
|
||||
x="251.42001"
|
||||
y="738.39777">Gets interfaces used by this active connection</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="-227.90929"
|
||||
y="680.09265"
|
||||
id="text5191-5-1-7"
|
||||
sodipodi:linespacing="125%"
|
||||
transform="matrix(0.54025777,-0.84149958,0.84149958,0.54025777,0,0)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan5193-8-5-2"
|
||||
x="-227.90929"
|
||||
y="680.09265">Gets all active network connections</tspan></text>
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-2)"
|
||||
d="M 314.15744,683.6768 C 282.94516,704.65454 170.8596,719.38945 163.64471,598.82399"
|
||||
id="path7053"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="19.152279"
|
||||
y="706.91034"
|
||||
id="text7239"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7241"
|
||||
x="19.152279"
|
||||
y="706.91034">Retrieve the NMRemoteConnection that provides</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.152279"
|
||||
y="719.41034"
|
||||
id="tspan7243">configuration settings for the NMActiveConnection</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.152279"
|
||||
y="731.91034"
|
||||
id="tspan7245">by getting its object path with</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.152279"
|
||||
y="744.41034"
|
||||
id="tspan7247">nm_active_connection_get_connection() and then</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.152279"
|
||||
y="756.91034"
|
||||
id="tspan7249">passing the returned path to</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="19.152279"
|
||||
y="769.41034"
|
||||
id="tspan7251">nm_remote_settings_get_connection_by_path()</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="10.101524"
|
||||
y="653.3316"
|
||||
id="text7253"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7255"
|
||||
x="10.101524"
|
||||
y="653.3316">Network</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="10.101524"
|
||||
y="675.8316"
|
||||
id="tspan7278">Configuration</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="284.19009"
|
||||
y="798.65869"
|
||||
id="text7253-4"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7255-8"
|
||||
x="284.19009"
|
||||
y="798.65869">Network Control</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="701.04297"
|
||||
y="363.09201"
|
||||
id="text7239-7"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
x="701.04297"
|
||||
y="363.09201"
|
||||
id="tspan7251-6">Connect to a network by calling</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="701.04297"
|
||||
y="375.59201"
|
||||
id="tspan7336">nm_client_activate_connection() and</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="701.04297"
|
||||
y="388.09201"
|
||||
id="tspan7338">passing the NMDevice to use, along with</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="701.04297"
|
||||
y="400.59201"
|
||||
id="tspan7342">the NMRemoteConnection that contains</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="701.04297"
|
||||
y="413.09201"
|
||||
id="tspan7346">the settings that describe how to connect</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="701.04297"
|
||||
y="425.59201"
|
||||
id="tspan7350">to that network</tspan></text>
|
||||
<g
|
||||
id="g5623-9"
|
||||
transform="translate(-369.71587,253.62599)">
|
||||
<g
|
||||
id="g7418"
|
||||
transform="translate(-28.915799,-13.111678)">
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.57918203;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-9-7-5"
|
||||
width="155.24031"
|
||||
height="24.408838"
|
||||
x="721.03192"
|
||||
y="447.99072" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
x="725.99634"
|
||||
y="465.41437"
|
||||
id="text3755-3-5-9-3"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-00-9-0"
|
||||
x="725.99634"
|
||||
y="465.41437"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMActiveConnection</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(-28.915799,18.947049)"
|
||||
id="g7418-5">
|
||||
<rect
|
||||
style="fill:none;stroke:#01003d;stroke-width:0.57918203;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
id="rect2985-8-9-7-5-7"
|
||||
width="155.24031"
|
||||
height="24.408838"
|
||||
x="721.03192"
|
||||
y="447.99072" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
|
||||
x="725.99634"
|
||||
y="465.41437"
|
||||
id="text3755-3-5-9-3-7"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757-8-00-9-0-0"
|
||||
x="725.99634"
|
||||
y="465.41437"
|
||||
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMActiveConnection</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(282.84399,143.9366)"
|
||||
id="g5581-6">
|
||||
<path
|
||||
transform="translate(24,308.27784)"
|
||||
d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
|
||||
sodipodi:ry="3.5355339"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:cx="72.225906"
|
||||
id="path4776-6"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
|
||||
sodipodi:ry="3.5355339"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:cx="72.225906"
|
||||
id="path4776-1-2"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
sodipodi:type="arc"
|
||||
transform="translate(44.950515,308.27784)" />
|
||||
<path
|
||||
d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
|
||||
sodipodi:ry="3.5355339"
|
||||
sodipodi:rx="3.5355339"
|
||||
sodipodi:cy="306.19336"
|
||||
sodipodi:cx="72.225906"
|
||||
id="path4776-1-4-6"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
|
||||
sodipodi:type="arc"
|
||||
transform="translate(65.901025,308.27784)" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 46 KiB |
1
docs/libnm/version.xml.in
Normal file
1
docs/libnm/version.xml.in
Normal file
|
|
@ -0,0 +1 @@
|
|||
@VERSION@
|
||||
|
|
@ -1,58 +1,56 @@
|
|||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/libnm-util \
|
||||
-I${top_builddir}/libnm-util \
|
||||
-I${top_srcdir}/libnm-glib \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm \
|
||||
-I${top_builddir}/libnm \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
add-connection-dbus-glib \
|
||||
add-connection-libnm-glib \
|
||||
add-connection-libnm \
|
||||
get-active-connections-dbus-glib \
|
||||
list-connections-dbus-glib \
|
||||
list-connections-libnm-glib \
|
||||
get-ap-info-libnm-glib \
|
||||
list-connections-libnm \
|
||||
get-ap-info-libnm \
|
||||
monitor-nm-running-dbus-glib \
|
||||
monitor-nm-running-GDBus \
|
||||
monitor-nm-state-GDBus
|
||||
|
||||
add_connection_dbus_glib_SOURCES = add-connection-dbus-glib.c
|
||||
add_connection_dbus_glib_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
add_connection_libnm_glib_SOURCES = add-connection-libnm-glib.c
|
||||
add_connection_libnm_glib_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm-glib/libnm-glib.la \
|
||||
add_connection_libnm_SOURCES = add-connection-libnm.c
|
||||
add_connection_libnm_LDADD = \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
get_active_connections_dbus_glib_SOURCES = get-active-connections-dbus-glib.c
|
||||
get_active_connections_dbus_glib_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
list_connections_dbus_glib_SOURCES = list-connections-dbus-glib.c
|
||||
list_connections_dbus_glib_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
list_connections_libnm_glib_SOURCES = list-connections-libnm-glib.c
|
||||
list_connections_libnm_glib_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm-glib/libnm-glib.la \
|
||||
list_connections_libnm_SOURCES = list-connections-libnm.c
|
||||
list_connections_libnm_LDADD = \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
get_ap_info_libnm_glib_SOURCES = get-ap-info-libnm-glib.c
|
||||
get_ap_info_libnm_glib_LDADD = \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm-glib/libnm-glib.la \
|
||||
get_ap_info_libnm_SOURCES = get-ap-info-libnm.c
|
||||
get_ap_info_libnm_LDADD = \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
|
|
@ -71,11 +69,11 @@ monitor_nm_state_GDBus_LDADD = \
|
|||
|
||||
EXTRA_DIST = \
|
||||
add-connection-dbus-glib.c \
|
||||
add-connection-libnm-glib.c \
|
||||
add-connection-libnm.c \
|
||||
get-active-connections-dbus-glib.c \
|
||||
list-connections-dbus-glib.c \
|
||||
list-connections-libnm-glib.c \
|
||||
get-ap-info-libnm-glib.c \
|
||||
list-connections-libnm.c \
|
||||
get-ap-info-libnm.c \
|
||||
monitor-nm-running-dbus-glib.c \
|
||||
monitor-nm-running-GDBus.c \
|
||||
monitor-nm-state-GDBus.c
|
||||
|
|
|
|||
|
|
@ -19,22 +19,17 @@
|
|||
|
||||
/*
|
||||
* The example shows how to call AddConnection() D-Bus method to add
|
||||
* a connection to system settings service. It uses dbus-glib and libnm-util
|
||||
* a connection to system settings service. It uses dbus-glib and libnm
|
||||
* libraries.
|
||||
*
|
||||
* Compile with:
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` add-connection-glib.c -o add-connection-glib
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm` add-connection-glib.c -o add-connection-glib
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-wired.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
|
||||
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
|
||||
|
|
@ -110,11 +105,11 @@ int main (int argc, char *argv[])
|
|||
/* Get system bus */
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
|
||||
|
||||
/* Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h */
|
||||
/* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */
|
||||
proxy = dbus_g_proxy_new_for_name (bus,
|
||||
NM_DBUS_SERVICE,
|
||||
NM_DBUS_PATH_SETTINGS,
|
||||
NM_DBUS_IFACE_SETTINGS);
|
||||
NM_DBUS_INTERFACE_SETTINGS);
|
||||
|
||||
/* Add a connection */
|
||||
add_connection (proxy, "__Test connection__");
|
||||
|
|
|
|||
|
|
@ -18,23 +18,17 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* The example shows how to add a new connection using libnm-glib and libnm-util.
|
||||
* The example shows how to add a new connection using libnm.
|
||||
* Contrast this example with add-connection-dbus-glib.c, which is a bit lower
|
||||
* level and talks directly to NM using dbus-glib. This example is simpler
|
||||
* because libnm-glib handles much of the low-level stuff for you.
|
||||
* because libnm handles much of the low-level stuff for you.
|
||||
*
|
||||
* Compile with:
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` add-connection-libnm-glib.c -o add-connection-libnm-glib
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm` add-connection-libnm.c -o add-connection-libnm
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <nm-remote-settings.h>
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-wired.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <nm-utils.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
static void
|
||||
added_cb (NMRemoteSettings *settings,
|
||||
|
|
@ -106,9 +100,9 @@ add_connection (NMRemoteSettings *settings, GMainLoop *loop, const char *con_nam
|
|||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
DBusGConnection *bus;
|
||||
NMRemoteSettings *settings;
|
||||
GMainLoop *loop;
|
||||
GError *error = NULL;
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
||||
/* Initialize GType system */
|
||||
|
|
@ -117,11 +111,13 @@ int main (int argc, char *argv[])
|
|||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
/* Get system bus */
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
|
||||
|
||||
/* Create our proxy for NetworkManager's settings service */
|
||||
settings = nm_remote_settings_new (bus);
|
||||
settings = nm_remote_settings_new (NULL, &error);
|
||||
if (!settings) {
|
||||
g_message ("Error: Could not get system settings: %s.", error->message);
|
||||
g_error_free (error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Ask the settings service to add the new connection */
|
||||
if (add_connection (settings, loop, "__Test connection__")) {
|
||||
|
|
@ -132,7 +128,6 @@ int main (int argc, char *argv[])
|
|||
|
||||
/* Clean up */
|
||||
g_object_unref (settings);
|
||||
dbus_g_connection_unref (bus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -20,22 +20,17 @@
|
|||
/*
|
||||
* The example shows how to call the D-Bus properties interface to get the
|
||||
* list of currently active connections known to NetworkManager. It uses
|
||||
* dbus-glib and libnm-util libraries.
|
||||
* dbus-glib and libnm libraries.
|
||||
*
|
||||
* Compile with:
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` get-active-connections-dbus-glib.c -o get-active-connections-dbus-glib
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm` get-active-connections-dbus-glib.c -o get-active-connections-dbus-glib
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-wired.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
|
||||
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
|
||||
|
|
@ -55,7 +50,7 @@ print_connection (DBusGConnection *bus, const char *path)
|
|||
proxy = dbus_g_proxy_new_for_name (bus,
|
||||
NM_DBUS_SERVICE,
|
||||
path,
|
||||
NM_DBUS_IFACE_SETTINGS_CONNECTION);
|
||||
NM_DBUS_INTERFACE_SETTINGS_CONNECTION);
|
||||
g_assert (proxy);
|
||||
|
||||
/* Request the all the configuration of the Connection */
|
||||
|
|
@ -205,7 +200,7 @@ int main (int argc, char *argv[])
|
|||
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
|
||||
|
||||
/* Create a D-Bus proxy to get the object properties from the NM Manager
|
||||
* object. NM_DBUS_* defines are from NetworkManager.h.
|
||||
* object. NM_DBUS_* defines are from nm-dbus-interface.h.
|
||||
*/
|
||||
props_proxy = dbus_g_proxy_new_for_name (bus,
|
||||
NM_DBUS_SERVICE,
|
||||
|
|
|
|||
|
|
@ -18,11 +18,10 @@
|
|||
|
||||
/*
|
||||
* The example shows how to get info about APs visible by Wi-Fi devices
|
||||
* using libnm-glib (that wraps direct D-Bus calls).
|
||||
* The example uses dbus-glib, libnm-util and libnm-glib libraries.
|
||||
* using libnm (that wraps direct D-Bus calls).
|
||||
*
|
||||
* Compile with:
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util libnm-glib` get-ap-info-libnm-glib.c -o get-ap-info-libnm-glib
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm` get-ap-info-libnm.c -o get-ap-info-libnm
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
|
@ -30,12 +29,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nm-client.h>
|
||||
#include <nm-device.h>
|
||||
#include <nm-device-wifi.h>
|
||||
#include <nm-access-point.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
/* Convert flags to string */
|
||||
static char *
|
||||
|
|
@ -195,24 +189,21 @@ show_wifi_device_info (NMDevice *device)
|
|||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
DBusGConnection *bus;
|
||||
NMClient *client;
|
||||
const GPtrArray *devices;
|
||||
int i;
|
||||
GError *error = NULL;
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
||||
/* Initialize GType system */
|
||||
g_type_init ();
|
||||
#endif
|
||||
|
||||
/* Get system bus */
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
|
||||
|
||||
/* Get NMClient object */
|
||||
client = nm_client_new ();
|
||||
client = nm_client_new (NULL, &error);
|
||||
if (!client) {
|
||||
dbus_g_connection_unref (bus);
|
||||
g_message ("Error: Could not create NMClient.");
|
||||
g_message ("Error: Could not create NMClient: %s.", error->message);
|
||||
g_error_free (error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +218,6 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
g_object_unref (client);
|
||||
dbus_g_connection_unref (bus);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
/*
|
||||
* The example shows how to list connections from System Settings service using direct
|
||||
* D-Bus call of ListConnections method.
|
||||
* The example uses dbus-glib, libnm-util libraries.
|
||||
* The example uses dbus-glib libraries and libnm headers.
|
||||
*
|
||||
* Compile with:
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` list-connections-dbus.c -o list-connections-dbus
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1` `pkg-config --cflags libnm` list-connections-dbus.c -o list-connections-dbus
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
|
@ -30,7 +30,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
|
||||
|
||||
|
|
@ -75,11 +74,11 @@ int main (int argc, char *argv[])
|
|||
/* Get system bus */
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
|
||||
|
||||
/* Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h */
|
||||
/* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */
|
||||
proxy = dbus_g_proxy_new_for_name (bus,
|
||||
NM_DBUS_SERVICE,
|
||||
NM_DBUS_PATH_SETTINGS,
|
||||
NM_DBUS_IFACE_SETTINGS);
|
||||
NM_DBUS_INTERFACE_SETTINGS);
|
||||
|
||||
/* List connections of system settings service */
|
||||
list_connections (proxy);
|
||||
|
|
|
|||
|
|
@ -17,25 +17,19 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* The example shows how to list connections from System Settings service using libnm-glib
|
||||
* The example shows how to list connections from System Settings service using libnm
|
||||
* (that wraps direct D-Bus calls).
|
||||
* The example uses dbus-glib, libnm-util and libnm-glib libraries.
|
||||
*
|
||||
* Compile with:
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util libnm-glib` list-connections-libnm-glib.c -o list-connections-libnm-glib
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm` list-connections-libnm.c -o list-connections-libnm
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-utils.h>
|
||||
#include <nm-remote-settings.h>
|
||||
|
||||
|
||||
/* Global variables */
|
||||
|
|
@ -120,13 +114,14 @@ get_connections_cb (NMRemoteSettings *settings, gpointer user_data)
|
|||
static gboolean
|
||||
list_connections (gpointer data)
|
||||
{
|
||||
DBusGConnection *bus = (DBusGConnection *) data;
|
||||
NMRemoteSettings *settings;
|
||||
gboolean settings_running;
|
||||
GError *error = NULL;
|
||||
|
||||
/* Get system settings */
|
||||
if (!(settings = nm_remote_settings_new (bus))) {
|
||||
g_message ("Error: Could not get system settings.");
|
||||
if (!(settings = nm_remote_settings_new (NULL, &error))) {
|
||||
g_message ("Error: Could not get system settings: %s.", error->message);
|
||||
g_error_free (error);
|
||||
result = EXIT_FAILURE;
|
||||
g_main_loop_quit (loop);
|
||||
return FALSE;
|
||||
|
|
@ -21,18 +21,18 @@
|
|||
/*
|
||||
* This example monitors NM state via D-Bus "StateChanged" signal on
|
||||
* "org.freedesktop.NetworkManager" object.
|
||||
* It uses GDBus.
|
||||
* It uses GDBus and the libnm headers.
|
||||
|
||||
* You don't need to have NetworkManager devel package installed. You can just
|
||||
* grab NetworkManager.h and put it in the path.
|
||||
* grab nm-dbus-interface.h and put it in the path.
|
||||
*
|
||||
* Standalone compilation:
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 gio-2.0 NetworkManager` monitor-nm-state-GDBus.c -o monitor-nm-state-GDBus
|
||||
* gcc -Wall `pkg-config --libs --cflags glib-2.0 gio-2.0` `pkg-config --cflags libnm` monitor-nm-state-GDBus.c -o monitor-nm-state-GDBus
|
||||
*/
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-dbus-interface.h>
|
||||
|
||||
static const char *
|
||||
nm_state_to_string (NMState state)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/libnm-util \
|
||||
-I${top_builddir}/libnm-util \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-I${top_builddir}/libnm-core \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(QT_CFLAGS)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
|
||||
typedef QMap<QString, QMap<QString, QVariant> > Connection;
|
||||
Q_DECLARE_METATYPE(Connection)
|
||||
|
|
@ -68,7 +68,7 @@ int main() {
|
|||
QDBusInterface interface(
|
||||
NM_DBUS_SERVICE,
|
||||
NM_DBUS_PATH_SETTINGS,
|
||||
NM_DBUS_IFACE_SETTINGS,
|
||||
NM_DBUS_INTERFACE_SETTINGS,
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
addConnection(interface, "__Test connection__");
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
* It uses Qt and D-Bus libraries to do that.
|
||||
*
|
||||
* Standalone compilation:
|
||||
* g++ -Wall `pkg-config --libs --cflags NetworkManager QtCore QtDBus QtNetwork` change-ipv4-addresses.cpp -o change-ipv4-addresses
|
||||
* g++ -Wall `pkg-config --libs --cflags QtCore QtDBus QtNetwork` `pkg-config --cflags libnm` change-ipv4-addresses.cpp -o change-ipv4-addresses
|
||||
*
|
||||
* You don't need to have NetworkManager devel package installed; you can just
|
||||
* grab NetworkManager.h and put it in the path
|
||||
* grab nm-dbus-interface.h and put it in the path
|
||||
*/
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "arpa/inet.h"
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
|
||||
typedef QMap<QString, QMap<QString, QVariant> > Connection;
|
||||
Q_DECLARE_METATYPE(Connection)
|
||||
|
|
@ -61,7 +61,7 @@ const QString getConnection(const QString& connectionUuid, Connection *found_con
|
|||
QDBusInterface interface(
|
||||
NM_DBUS_SERVICE,
|
||||
NM_DBUS_PATH_SETTINGS,
|
||||
NM_DBUS_IFACE_SETTINGS,
|
||||
NM_DBUS_INTERFACE_SETTINGS,
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
// Get connection list and find the connection with 'connectionUuid'
|
||||
|
|
@ -71,7 +71,7 @@ const QString getConnection(const QString& connectionUuid, Connection *found_con
|
|||
ifaceForSettings = new QDBusInterface(
|
||||
NM_DBUS_SERVICE,
|
||||
connection.path(),
|
||||
NM_DBUS_IFACE_SETTINGS_CONNECTION,
|
||||
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
||||
QDBusConnection::systemBus());
|
||||
QDBusReply<Connection> result2 = ifaceForSettings->call("GetSettings");
|
||||
delete ifaceForSettings;
|
||||
|
|
@ -120,7 +120,7 @@ void changeConnection(const QString& uuid)
|
|||
QDBusInterface interface(
|
||||
NM_DBUS_SERVICE,
|
||||
conPath,
|
||||
NM_DBUS_IFACE_SETTINGS_CONNECTION,
|
||||
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
// Call Update() D-Bus method to update connection
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
|
||||
|
||||
void listConnections(QDBusInterface& interface) {
|
||||
|
|
@ -44,7 +44,7 @@ int main() {
|
|||
QDBusInterface interface(
|
||||
NM_DBUS_SERVICE,
|
||||
NM_DBUS_PATH_SETTINGS,
|
||||
NM_DBUS_IFACE_SETTINGS,
|
||||
NM_DBUS_INTERFACE_SETTINGS,
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
listConnections(interface);
|
||||
|
|
|
|||
|
|
@ -20,16 +20,14 @@
|
|||
|
||||
#
|
||||
# This example shows how to add a new NM connection profile.
|
||||
# The code uses libnm-util (NetworkManager) and libnm-glib (NMClient)
|
||||
# via GObject Introspection.
|
||||
# The code uses libnm (NM) via GObject Introspection.
|
||||
#
|
||||
# Documentation links:
|
||||
# https://developer.gnome.org/libnm-glib/0.9/
|
||||
# https://developer.gnome.org/libnm-util/0.9/
|
||||
# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html
|
||||
# https://developer.gnome.org/libnm/1.0/
|
||||
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
|
||||
#
|
||||
|
||||
from gi.repository import GLib, NetworkManager, NMClient
|
||||
from gi.repository import GLib, NM
|
||||
import sys, uuid
|
||||
|
||||
main_loop = None
|
||||
|
|
@ -39,19 +37,19 @@ def print_values(setting, key, value, flags, data):
|
|||
|
||||
# create an Ethernet connection and return it
|
||||
def create_profile(name):
|
||||
profile = NetworkManager.Connection.new()
|
||||
s_con = NetworkManager.SettingConnection.new()
|
||||
s_con.set_property(NetworkManager.SETTING_CONNECTION_ID, name)
|
||||
s_con.set_property(NetworkManager.SETTING_CONNECTION_UUID, str(uuid.uuid4()))
|
||||
s_con.set_property(NetworkManager.SETTING_CONNECTION_TYPE, "802-3-ethernet")
|
||||
profile = NM.Connection.new()
|
||||
s_con = NM.SettingConnection.new()
|
||||
s_con.set_property(NM.SETTING_CONNECTION_ID, name)
|
||||
s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4()))
|
||||
s_con.set_property(NM.SETTING_CONNECTION_TYPE, "802-3-ethernet")
|
||||
|
||||
s_wired = NetworkManager.SettingWired.new()
|
||||
s_wired = NM.SettingWired.new()
|
||||
|
||||
s_ip4 = NetworkManager.SettingIP4Config.new()
|
||||
s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, "auto")
|
||||
s_ip4 = NM.SettingIP4Config.new()
|
||||
s_ip4.set_property(NM.SETTING_IP4_CONFIG_METHOD, "auto")
|
||||
|
||||
s_ip6 = NetworkManager.SettingIP6Config.new()
|
||||
s_ip6.set_property(NetworkManager.SETTING_IP6_CONFIG_METHOD, "auto")
|
||||
s_ip6 = NM.SettingIP6Config.new()
|
||||
s_ip6.set_property(NM.SETTING_IP6_CONFIG_METHOD, "auto")
|
||||
|
||||
profile.add_setting(s_con)
|
||||
profile.add_setting(s_ip4)
|
||||
|
|
@ -86,7 +84,7 @@ if __name__ == "__main__":
|
|||
main_loop = GLib.MainLoop()
|
||||
|
||||
# create RemoteSettings object
|
||||
settings = NMClient.RemoteSettings.new(None);
|
||||
settings = NM.RemoteSettings.new(None);
|
||||
|
||||
# create a connection profile for NM
|
||||
con = create_profile(profile_name)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
|
||||
import sys
|
||||
from gi.repository import GLib, NetworkManager, NMClient
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
#
|
||||
# This example shows how to get NMIP4Config from NMDevice after it is activated.
|
||||
|
|
@ -51,7 +51,7 @@ if __name__ == "__main__":
|
|||
sys.exit('Usage: %s <interface>' % sys.argv[0])
|
||||
dev_iface = sys.argv[1]
|
||||
|
||||
c = NMClient.Client.new()
|
||||
c = NM.Client.new(None)
|
||||
dev = c.get_device_by_iface(dev_iface)
|
||||
if dev is None:
|
||||
sys.exit('Device \'%s\' not found' % dev_iface)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#
|
||||
|
||||
import sys
|
||||
from gi.repository import GLib, NetworkManager, NMClient
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
#
|
||||
# This example demonstrates how to get and change firewall zone in a
|
||||
|
|
@ -32,7 +32,7 @@ from gi.repository import GLib, NetworkManager, NMClient
|
|||
# If you used D-Bus calls, you would call GetSettings() and then Update().
|
||||
#
|
||||
# Links:
|
||||
# https://developer.gnome.org/libnm-glib/0.9/
|
||||
# https://developer.gnome.org/libnm/1.0/
|
||||
# https://wiki.gnome.org/GObjectIntrospection
|
||||
# https://wiki.gnome.org/PyGObject
|
||||
#
|
||||
|
|
@ -78,7 +78,7 @@ if __name__ == "__main__":
|
|||
sys.exit('Usage: %s <connection name or UUID> [new zone]' % sys.argv[0])
|
||||
|
||||
main_loop = GLib.MainLoop()
|
||||
settings = NMClient.RemoteSettings.new(None);
|
||||
settings = NM.RemoteSettings.new(None);
|
||||
|
||||
# Connections are read asynchronously, so we have to wait for the
|
||||
# 'settings' object to tell us that all connections have been read.
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
# This example lists currently active connections
|
||||
|
||||
from gi.repository import GLib, NMClient
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
if __name__ == "__main__":
|
||||
client = NMClient.Client.new()
|
||||
client = NM.Client.new(None)
|
||||
acons = client.get_active_connections()
|
||||
for ac in acons:
|
||||
print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type())
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
|
||||
import sys, socket, struct
|
||||
from gi.repository import GLib, NetworkManager, NMClient
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
#
|
||||
# This example shows how to get addresses, routes and DNS information
|
||||
|
|
@ -124,7 +124,7 @@ if __name__ == "__main__":
|
|||
sys.exit('Usage: %s <interface>' % sys.argv[0])
|
||||
dev_iface = sys.argv[1]
|
||||
|
||||
c = NMClient.Client.new()
|
||||
c = NM.Client.new(None)
|
||||
dev = c.get_device_by_iface(dev_iface)
|
||||
if dev is None:
|
||||
sys.exit('Device \'%s\' not found' % dev_iface)
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@
|
|||
# Copyright (C) 2012 Red Hat, Inc.
|
||||
#
|
||||
|
||||
from gi.repository import GLib, NetworkManager, NMClient
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
# This example asks settings service for all configured connections.
|
||||
# Unfortunately, at this time since libnm-glib still makes heavy use of
|
||||
# GValue and GHashTable (rather than GVariant), libnm-glib isn't fully
|
||||
# Unfortunately, at this time since libnm still makes heavy use of
|
||||
# GValue and GHashTable (rather than GVariant), libnm isn't fully
|
||||
# usable from GObject Introspection-ready languages. Most functions will
|
||||
# work fine, but e. g. nm_connection_to_hash() causes assertion failures.
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ def connections_read(settings):
|
|||
|
||||
if __name__ == "__main__":
|
||||
main_loop = GLib.MainLoop()
|
||||
settings = NMClient.RemoteSettings.new(None);
|
||||
settings = NM.RemoteSettings.new(None);
|
||||
|
||||
# connections are read asynchronously, so we need to wait for the
|
||||
# settings object to tell us that it's read all connections
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@
|
|||
# Copyright (C) 2013 Red Hat, Inc.
|
||||
#
|
||||
|
||||
from gi.repository import NetworkManager, NMClient
|
||||
from gi.repository import NM
|
||||
|
||||
#
|
||||
# This example lists Wi-Fi access points NetworkManager scanned on Wi-Fi devices.
|
||||
# It calls libnm-glib functions using GObject introspection.
|
||||
# It calls libnm functions using GObject introspection.
|
||||
#
|
||||
# Note the second line of the file: coding=utf-8
|
||||
# It is necessary because we use unicode characters and python would produce
|
||||
|
|
@ -57,16 +57,16 @@ def print_ap_info(ap):
|
|||
print "SSID: %s" % (ap.get_ssid())
|
||||
print "BSSID: %s" % (ap.get_bssid())
|
||||
print "Frequency: %s" % (frequency)
|
||||
print "Channel: %s" % (NetworkManager.utils_wifi_freq_to_channel(frequency))
|
||||
print "Channel: %s" % (NM.utils_wifi_freq_to_channel(frequency))
|
||||
print "Strength: %s %s%%" % (signal_bars[(clamp(strength-5, 0, 99)+24)/25], strength)
|
||||
print
|
||||
|
||||
if __name__ == "__main__":
|
||||
nmc = NMClient.Client.new()
|
||||
nmc = NM.Client.new(None)
|
||||
devs = nmc.get_devices()
|
||||
|
||||
for dev in devs:
|
||||
if dev.get_device_type() == NetworkManager.DeviceType.WIFI:
|
||||
if dev.get_device_type() == NM.DeviceType.WIFI:
|
||||
print_device_info(dev)
|
||||
for ap in dev.get_access_points():
|
||||
print_ap_info(ap)
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#
|
||||
# This example updates a connection's IPv4 method with the Update() method
|
||||
# using the libnm-glib GObject-based convenience APIs.
|
||||
# using the libnm GObject-based convenience APIs.
|
||||
#
|
||||
# Configuration settings are described at
|
||||
# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html
|
||||
#
|
||||
|
||||
from gi.repository import GLib, NetworkManager, NMClient
|
||||
from gi.repository import GLib, NM
|
||||
import sys, struct, socket
|
||||
|
||||
def ip_to_int(ip_string):
|
||||
|
|
@ -51,17 +51,17 @@ def connections_read_cb(settings, data):
|
|||
# add IPv4 setting if it doesn't yet exist
|
||||
s_ip4 = c.get_setting_ip4_config()
|
||||
if not s_ip4:
|
||||
s_ip4 = NetworkManager.SettingIP4Config.new()
|
||||
s_ip4 = NM.SettingIP4Config.new()
|
||||
c.add_setting(s_ip4)
|
||||
|
||||
# set the method and change properties
|
||||
s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, method)
|
||||
s_ip4.set_property(NM.SETTING_IP4_CONFIG_METHOD, method)
|
||||
if method == "auto":
|
||||
# remove addresses
|
||||
s_ip4.clear_addresses()
|
||||
elif method == "manual":
|
||||
# Add the static IP address, prefix, and (optional) gateway
|
||||
addr = NetworkManager.IP4Address.new()
|
||||
addr = NM.IP4Address.new()
|
||||
addr.set_address(ip_to_int(sys.argv[3]))
|
||||
addr.set_prefix(int(sys.argv[4]))
|
||||
if len(sys.argv) == 6:
|
||||
|
|
@ -89,7 +89,7 @@ if __name__ == "__main__":
|
|||
|
||||
# create RemoteSettings object and attach to the "connections-read" signal
|
||||
# to wait for connections to be loaded asynchronously
|
||||
settings = NMClient.RemoteSettings.new(None)
|
||||
settings = NM.RemoteSettings.new(None)
|
||||
settings.connect('connections-read', connections_read_cb, (sys.argv[1], method, sys.argv))
|
||||
|
||||
main_loop.run()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ EXTRA_DIST = \
|
|||
nm-glib-compat.h \
|
||||
nm-gvaluearray-compat.h \
|
||||
nm-test-utils.h \
|
||||
nm-settings-flags.h \
|
||||
nm-utils-internal.h
|
||||
|
||||
CLEANFILES=nm-version.h
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; 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_SETTINGS_FLAGS_H
|
||||
#define NM_SETTINGS_FLAGS_H
|
||||
|
||||
/* NOTE: these values should match the NM_SECRET_AGENT_GET_SECRETS_FLAGS in
|
||||
* the nm-secret-agent.xml introspection file; except ONLY_SYSTEM which is
|
||||
* internal to NM.
|
||||
*/
|
||||
typedef enum {
|
||||
NM_SETTINGS_GET_SECRETS_FLAG_NONE = 0x0,
|
||||
NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
|
||||
NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
|
||||
NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
|
||||
|
||||
/* Internal only to NM */
|
||||
NM_SETTINGS_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000
|
||||
} NMSettingsGetSecretsFlags;
|
||||
|
||||
#endif /* NM_SETTINGS_FLAGS_H */
|
||||
49
libnm-core/Makefile.am
Normal file
49
libnm-core/Makefile.am
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
include $(GLIB_MAKEFILE)
|
||||
|
||||
SUBDIRS = . tests
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/include \
|
||||
-DG_LOG_DOMAIN=\""libnm"\" \
|
||||
-DNETWORKMANAGER_COMPILATION \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
|
||||
noinst_LTLIBRARIES = libnm-core.la
|
||||
|
||||
# header/source defines are in Makefile.libnm-core, so they can be shared
|
||||
# with libnm/Makefile.am
|
||||
include Makefile.libnm-core
|
||||
|
||||
libnmincludedir = $(includedir)/libnm
|
||||
|
||||
libnminclude_HEADERS = $(libnm_core_headers)
|
||||
libnm_core_la_SOURCES = \
|
||||
$(libnm_core_sources) \
|
||||
$(libnm_core_private_headers)
|
||||
|
||||
GLIB_GENERATED = nm-core-enum-types.h nm-core-enum-types.c
|
||||
nm_core_enum_types_sources = $(notdir $(libnminclude_HEADERS))
|
||||
GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
|
||||
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
|
||||
|
||||
libnm_core_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(UUID_LIBS)
|
||||
|
||||
if WITH_GNUTLS
|
||||
AM_CPPFLAGS += $(LIBGCRYPT_CFLAGS) $(GNUTLS_CFLAGS)
|
||||
libnm_core_la_SOURCES += crypto_gnutls.c
|
||||
libnm_core_la_LIBADD += $(LIBGCRYPT_LIBS) $(GNUTLS_LIBS)
|
||||
endif
|
||||
|
||||
if WITH_NSS
|
||||
AM_CPPFLAGS += $(NSS_CFLAGS)
|
||||
libnm_core_la_SOURCES += crypto_nss.c
|
||||
libnm_core_la_LIBADD += $(NSS_LIBS)
|
||||
endif
|
||||
|
||||
BUILT_SOURCES = $(GLIB_GENERATED)
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
82
libnm-core/Makefile.libnm-core
Normal file
82
libnm-core/Makefile.libnm-core
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# In order for this to work correctly from both libnm-core/ and libnm/,
|
||||
# we have to specify full pathnames. (We can't just use $(addprefix) from
|
||||
# libnm/, because that's incompatible with the Makefile.introspection rules.)
|
||||
|
||||
core = $(top_srcdir)/libnm-core
|
||||
|
||||
libnm_core_headers = \
|
||||
$(core)/nm-connection.h \
|
||||
$(core)/nm-core-enum-types.h \
|
||||
$(core)/nm-dbus-interface.h \
|
||||
$(core)/nm-setting-8021x.h \
|
||||
$(core)/nm-setting-adsl.h \
|
||||
$(core)/nm-setting-bluetooth.h \
|
||||
$(core)/nm-setting-bond.h \
|
||||
$(core)/nm-setting-bridge-port.h \
|
||||
$(core)/nm-setting-bridge.h \
|
||||
$(core)/nm-setting-cdma.h \
|
||||
$(core)/nm-setting-connection.h \
|
||||
$(core)/nm-setting-dcb.h \
|
||||
$(core)/nm-setting-generic.h \
|
||||
$(core)/nm-setting-gsm.h \
|
||||
$(core)/nm-setting-infiniband.h \
|
||||
$(core)/nm-setting-ip4-config.h \
|
||||
$(core)/nm-setting-ip6-config.h \
|
||||
$(core)/nm-setting-olpc-mesh.h \
|
||||
$(core)/nm-setting-ppp.h \
|
||||
$(core)/nm-setting-pppoe.h \
|
||||
$(core)/nm-setting-serial.h \
|
||||
$(core)/nm-setting-team-port.h \
|
||||
$(core)/nm-setting-team.h \
|
||||
$(core)/nm-setting-vlan.h \
|
||||
$(core)/nm-setting-vpn.h \
|
||||
$(core)/nm-setting-wimax.h \
|
||||
$(core)/nm-setting-wired.h \
|
||||
$(core)/nm-setting-wireless-security.h \
|
||||
$(core)/nm-setting-wireless.h \
|
||||
$(core)/nm-setting.h \
|
||||
$(core)/nm-utils.h \
|
||||
$(core)/nm-version.h \
|
||||
$(core)/nm-vpn-dbus-interface.h
|
||||
|
||||
libnm_core_private_headers = \
|
||||
$(core)/crypto.h \
|
||||
$(core)/nm-param-spec-specialized.h \
|
||||
$(core)/nm-setting-private.h \
|
||||
$(core)/nm-utils-private.h
|
||||
|
||||
libnm_core_sources = \
|
||||
$(core)/crypto.c \
|
||||
$(core)/nm-connection.c \
|
||||
$(core)/nm-core-enum-types.c \
|
||||
$(core)/nm-param-spec-specialized.c \
|
||||
$(core)/nm-setting-8021x.c \
|
||||
$(core)/nm-setting-adsl.c \
|
||||
$(core)/nm-setting-bluetooth.c \
|
||||
$(core)/nm-setting-bond.c \
|
||||
$(core)/nm-setting-bridge-port.c \
|
||||
$(core)/nm-setting-bridge.c \
|
||||
$(core)/nm-setting-cdma.c \
|
||||
$(core)/nm-setting-connection.c \
|
||||
$(core)/nm-setting-dcb.c \
|
||||
$(core)/nm-setting-generic.c \
|
||||
$(core)/nm-setting-gsm.c \
|
||||
$(core)/nm-setting-infiniband.c \
|
||||
$(core)/nm-setting-ip4-config.c \
|
||||
$(core)/nm-setting-ip6-config.c \
|
||||
$(core)/nm-setting-olpc-mesh.c \
|
||||
$(core)/nm-setting-ppp.c \
|
||||
$(core)/nm-setting-pppoe.c \
|
||||
$(core)/nm-setting-serial.c \
|
||||
$(core)/nm-setting-team-port.c \
|
||||
$(core)/nm-setting-team.c \
|
||||
$(core)/nm-setting-vlan.c \
|
||||
$(core)/nm-setting-vpn.c \
|
||||
$(core)/nm-setting-wimax.c \
|
||||
$(core)/nm-setting-wired.c \
|
||||
$(core)/nm-setting-wireless-security.c \
|
||||
$(core)/nm-setting-wireless.c \
|
||||
$(core)/nm-setting.c \
|
||||
$(core)/nm-utils.c \
|
||||
$(core)/nm-value-transforms.c
|
||||
|
||||
749
libnm-core/crypto.c
Normal file
749
libnm-core/crypto.c
Normal file
|
|
@ -0,0 +1,749 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* Dan Williams <dcbw@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.
|
||||
*
|
||||
* Copyright 2007 - 2011 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
GQuark
|
||||
_nm_crypto_error_quark (void)
|
||||
{
|
||||
static GQuark quark;
|
||||
|
||||
if (G_UNLIKELY (!quark))
|
||||
quark = g_quark_from_static_string ("nm-crypto-error-quark");
|
||||
return quark;
|
||||
}
|
||||
|
||||
|
||||
#define PEM_RSA_KEY_BEGIN "-----BEGIN RSA PRIVATE KEY-----"
|
||||
#define PEM_RSA_KEY_END "-----END RSA PRIVATE KEY-----"
|
||||
|
||||
#define PEM_DSA_KEY_BEGIN "-----BEGIN DSA PRIVATE KEY-----"
|
||||
#define PEM_DSA_KEY_END "-----END DSA PRIVATE KEY-----"
|
||||
|
||||
#define PEM_CERT_BEGIN "-----BEGIN CERTIFICATE-----"
|
||||
#define PEM_CERT_END "-----END CERTIFICATE-----"
|
||||
|
||||
#define PEM_PKCS8_ENC_KEY_BEGIN "-----BEGIN ENCRYPTED PRIVATE KEY-----"
|
||||
#define PEM_PKCS8_ENC_KEY_END "-----END ENCRYPTED PRIVATE KEY-----"
|
||||
|
||||
#define PEM_PKCS8_DEC_KEY_BEGIN "-----BEGIN PRIVATE KEY-----"
|
||||
#define PEM_PKCS8_DEC_KEY_END "-----END PRIVATE KEY-----"
|
||||
|
||||
static gboolean
|
||||
find_tag (const char *tag,
|
||||
const GByteArray *array,
|
||||
gsize start_at,
|
||||
gsize *out_pos)
|
||||
{
|
||||
gsize i, taglen;
|
||||
gsize len = array->len - start_at;
|
||||
|
||||
g_return_val_if_fail (out_pos != NULL, FALSE);
|
||||
|
||||
taglen = strlen (tag);
|
||||
if (len >= taglen) {
|
||||
for (i = 0; i < len - taglen + 1; i++) {
|
||||
if (memcmp (array->data + start_at + i, tag, taglen) == 0) {
|
||||
*out_pos = start_at + i;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define DEK_INFO_TAG "DEK-Info: "
|
||||
#define PROC_TYPE_TAG "Proc-Type: "
|
||||
|
||||
static GByteArray *
|
||||
parse_old_openssl_key_file (const GByteArray *contents,
|
||||
int key_type,
|
||||
char **out_cipher,
|
||||
char **out_iv,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *bindata = NULL;
|
||||
char **lines = NULL;
|
||||
char **ln = NULL;
|
||||
gsize start = 0, end = 0;
|
||||
GString *str = NULL;
|
||||
int enc_tags = 0;
|
||||
char *iv = NULL;
|
||||
char *cipher = NULL;
|
||||
unsigned char *tmp = NULL;
|
||||
gsize tmp_len = 0;
|
||||
const char *start_tag;
|
||||
const char *end_tag;
|
||||
guint8 save_end = 0;
|
||||
|
||||
switch (key_type) {
|
||||
case NM_CRYPTO_KEY_TYPE_RSA:
|
||||
start_tag = PEM_RSA_KEY_BEGIN;
|
||||
end_tag = PEM_RSA_KEY_END;
|
||||
break;
|
||||
case NM_CRYPTO_KEY_TYPE_DSA:
|
||||
start_tag = PEM_DSA_KEY_BEGIN;
|
||||
end_tag = PEM_DSA_KEY_END;
|
||||
break;
|
||||
default:
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE,
|
||||
"Unknown key type %d",
|
||||
key_type);
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!find_tag (start_tag, contents, 0, &start))
|
||||
goto parse_error;
|
||||
|
||||
start += strlen (start_tag);
|
||||
if (!find_tag (end_tag, contents, start, &end)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("PEM key file had no end tag '%s'."),
|
||||
end_tag);
|
||||
goto parse_error;
|
||||
}
|
||||
|
||||
save_end = contents->data[end];
|
||||
contents->data[end] = '\0';
|
||||
lines = g_strsplit ((const char *) (contents->data + start), "\n", 0);
|
||||
contents->data[end] = save_end;
|
||||
|
||||
if (!lines || g_strv_length (lines) <= 1) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Doesn't look like a PEM private key file."));
|
||||
goto parse_error;
|
||||
}
|
||||
|
||||
str = g_string_new_len (NULL, end - start);
|
||||
for (ln = lines; *ln; ln++) {
|
||||
char *p = *ln;
|
||||
|
||||
/* Chug leading spaces */
|
||||
p = g_strstrip (p);
|
||||
if (!*p)
|
||||
continue;
|
||||
|
||||
if (!strncmp (p, PROC_TYPE_TAG, strlen (PROC_TYPE_TAG))) {
|
||||
if (enc_tags++ != 0) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Malformed PEM file: Proc-Type was not first tag."));
|
||||
goto parse_error;
|
||||
}
|
||||
|
||||
p += strlen (PROC_TYPE_TAG);
|
||||
if (strcmp (p, "4,ENCRYPTED")) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Malformed PEM file: unknown Proc-Type tag '%s'."),
|
||||
p);
|
||||
goto parse_error;
|
||||
}
|
||||
} else if (!strncmp (p, DEK_INFO_TAG, strlen (DEK_INFO_TAG))) {
|
||||
char *comma;
|
||||
|
||||
if (enc_tags++ != 1) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Malformed PEM file: DEK-Info was not the second tag."));
|
||||
goto parse_error;
|
||||
}
|
||||
|
||||
p += strlen (DEK_INFO_TAG);
|
||||
|
||||
/* Grab the IV first */
|
||||
comma = strchr (p, ',');
|
||||
if (!comma || (*(comma + 1) == '\0')) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Malformed PEM file: no IV found in DEK-Info tag."));
|
||||
goto parse_error;
|
||||
}
|
||||
*comma++ = '\0';
|
||||
if (!g_ascii_isxdigit (*comma)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Malformed PEM file: invalid format of IV in DEK-Info tag."));
|
||||
goto parse_error;
|
||||
}
|
||||
iv = g_strdup (comma);
|
||||
|
||||
/* Get the private key cipher */
|
||||
if (!strcasecmp (p, "DES-EDE3-CBC")) {
|
||||
cipher = g_strdup (p);
|
||||
} else if (!strcasecmp (p, "DES-CBC")) {
|
||||
cipher = g_strdup (p);
|
||||
} else if (!strcasecmp (p, "AES-128-CBC")) {
|
||||
cipher = g_strdup (p);
|
||||
} else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE,
|
||||
_("Malformed PEM file: unknown private key cipher '%s'."),
|
||||
p);
|
||||
goto parse_error;
|
||||
}
|
||||
} else {
|
||||
if ((enc_tags != 0) && (enc_tags != 2)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
"Malformed PEM file: both Proc-Type and DEK-Info tags are required.");
|
||||
goto parse_error;
|
||||
}
|
||||
g_string_append (str, p);
|
||||
}
|
||||
}
|
||||
|
||||
tmp = g_base64_decode (str->str, &tmp_len);
|
||||
if (tmp == NULL || !tmp_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_DECODE_FAILED,
|
||||
_("Could not decode private key."));
|
||||
goto parse_error;
|
||||
}
|
||||
g_string_free (str, TRUE);
|
||||
|
||||
if (lines)
|
||||
g_strfreev (lines);
|
||||
|
||||
bindata = g_byte_array_sized_new (tmp_len);
|
||||
g_byte_array_append (bindata, tmp, tmp_len);
|
||||
g_free (tmp);
|
||||
|
||||
*out_iv = iv;
|
||||
*out_cipher = cipher;
|
||||
return bindata;
|
||||
|
||||
parse_error:
|
||||
g_free (tmp);
|
||||
g_free (cipher);
|
||||
g_free (iv);
|
||||
if (str)
|
||||
g_string_free (str, TRUE);
|
||||
if (lines)
|
||||
g_strfreev (lines);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GByteArray *
|
||||
parse_pkcs8_key_file (const GByteArray *contents,
|
||||
gboolean *out_encrypted,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *key = NULL;
|
||||
gsize start = 0, end = 0;
|
||||
unsigned char *der = NULL;
|
||||
guint8 save_end;
|
||||
gsize length = 0;
|
||||
const char *start_tag = NULL, *end_tag = NULL;
|
||||
gboolean encrypted = FALSE;
|
||||
|
||||
/* Try encrypted first, decrypted next */
|
||||
if (find_tag (PEM_PKCS8_ENC_KEY_BEGIN, contents, 0, &start)) {
|
||||
start_tag = PEM_PKCS8_ENC_KEY_BEGIN;
|
||||
end_tag = PEM_PKCS8_ENC_KEY_END;
|
||||
encrypted = TRUE;
|
||||
} else if (find_tag (PEM_PKCS8_DEC_KEY_BEGIN, contents, 0, &start)) {
|
||||
start_tag = PEM_PKCS8_DEC_KEY_BEGIN;
|
||||
end_tag = PEM_PKCS8_DEC_KEY_END;
|
||||
encrypted = FALSE;
|
||||
} else {
|
||||
g_set_error_literal (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Failed to find expected PKCS#8 start tag."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
start += strlen (start_tag);
|
||||
if (!find_tag (end_tag, contents, start, &end)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Failed to find expected PKCS#8 end tag '%s'."),
|
||||
end_tag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* g_base64_decode() wants a NULL-terminated string */
|
||||
save_end = contents->data[end];
|
||||
contents->data[end] = '\0';
|
||||
der = g_base64_decode ((const char *) (contents->data + start), &length);
|
||||
contents->data[end] = save_end;
|
||||
|
||||
if (der && length) {
|
||||
key = g_byte_array_sized_new (length);
|
||||
g_byte_array_append (key, der, length);
|
||||
g_assert (key->len == length);
|
||||
*out_encrypted = encrypted;
|
||||
} else {
|
||||
g_set_error_literal (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_DECODE_FAILED,
|
||||
_("Failed to decode PKCS#8 private key."));
|
||||
}
|
||||
|
||||
g_free (der);
|
||||
return key;
|
||||
}
|
||||
|
||||
static GByteArray *
|
||||
file_to_g_byte_array (const char *filename, GError **error)
|
||||
{
|
||||
char *contents;
|
||||
GByteArray *array = NULL;
|
||||
gsize length = 0;
|
||||
|
||||
if (g_file_get_contents (filename, &contents, &length, error)) {
|
||||
array = g_byte_array_sized_new (length);
|
||||
g_byte_array_append (array, (guint8 *) contents, length);
|
||||
g_assert (array->len == length);
|
||||
g_free (contents);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a hex string into bytes.
|
||||
*/
|
||||
static char *
|
||||
convert_iv (const char *src,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
int num;
|
||||
int i;
|
||||
char conv[3];
|
||||
char *c;
|
||||
|
||||
g_return_val_if_fail (src != NULL, NULL);
|
||||
|
||||
num = strlen (src);
|
||||
if (num % 2) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_RAW_IV_INVALID,
|
||||
_("IV must be an even number of bytes in length."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
num /= 2;
|
||||
c = g_malloc0 (num + 1);
|
||||
|
||||
conv[2] = '\0';
|
||||
for (i = 0; i < num; i++) {
|
||||
conv[0] = src[(i * 2)];
|
||||
conv[1] = src[(i * 2) + 1];
|
||||
if (!g_ascii_isxdigit (conv[0]) || !g_ascii_isxdigit (conv[1])) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_RAW_IV_INVALID,
|
||||
_("IV contains non-hexadecimal digits."));
|
||||
goto error;
|
||||
}
|
||||
|
||||
c[i] = strtol(conv, NULL, 16);
|
||||
}
|
||||
*out_len = num;
|
||||
return c;
|
||||
|
||||
error:
|
||||
g_free (c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
make_des_aes_key (const char *cipher,
|
||||
const char *salt,
|
||||
const gsize salt_len,
|
||||
const char *password,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
char *key;
|
||||
guint32 digest_len;
|
||||
|
||||
g_return_val_if_fail (cipher != NULL, NULL);
|
||||
g_return_val_if_fail (salt != NULL, NULL);
|
||||
g_return_val_if_fail (salt_len >= 8, NULL);
|
||||
g_return_val_if_fail (password != NULL, NULL);
|
||||
g_return_val_if_fail (out_len != NULL, NULL);
|
||||
|
||||
if (!strcmp (cipher, "DES-EDE3-CBC"))
|
||||
digest_len = 24;
|
||||
else if (!strcmp (cipher, "DES-CBC"))
|
||||
digest_len = 8;
|
||||
else if (!strcmp (cipher, "AES-128-CBC"))
|
||||
digest_len = 16;
|
||||
else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_UNKNOWN_CIPHER,
|
||||
_("Private key cipher '%s' was unknown."),
|
||||
cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (password[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
key = g_malloc0 (digest_len + 1);
|
||||
|
||||
if (!crypto_md5_hash (salt,
|
||||
salt_len,
|
||||
password,
|
||||
strlen (password),
|
||||
key,
|
||||
digest_len,
|
||||
error))
|
||||
goto error;
|
||||
|
||||
*out_len = digest_len;
|
||||
return key;
|
||||
|
||||
error:
|
||||
if (key) {
|
||||
/* Don't leak stale key material */
|
||||
memset (key, 0, digest_len);
|
||||
g_free (key);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GByteArray *
|
||||
decrypt_key (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const char *iv,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
char *bin_iv = NULL;
|
||||
gsize bin_iv_len = 0;
|
||||
char *key = NULL;
|
||||
gsize key_len = 0;
|
||||
char *output = NULL;
|
||||
gsize decrypted_len = 0;
|
||||
GByteArray *decrypted = NULL;
|
||||
|
||||
g_return_val_if_fail (password != NULL, NULL);
|
||||
|
||||
bin_iv = convert_iv (iv, &bin_iv_len, error);
|
||||
if (!bin_iv)
|
||||
return NULL;
|
||||
|
||||
/* Convert the password and IV into a DES or AES key */
|
||||
key = make_des_aes_key (cipher, bin_iv, bin_iv_len, password, &key_len, error);
|
||||
if (!key || !key_len)
|
||||
goto out;
|
||||
|
||||
output = crypto_decrypt (cipher, key_type,
|
||||
data,
|
||||
bin_iv, bin_iv_len,
|
||||
key, key_len,
|
||||
&decrypted_len,
|
||||
error);
|
||||
if (output && decrypted_len) {
|
||||
decrypted = g_byte_array_sized_new (decrypted_len);
|
||||
g_byte_array_append (decrypted, (guint8 *) output, decrypted_len);
|
||||
}
|
||||
|
||||
out:
|
||||
/* Don't leak stale key material */
|
||||
if (key)
|
||||
memset (key, 0, key_len);
|
||||
g_free (output);
|
||||
g_free (key);
|
||||
g_free (bin_iv);
|
||||
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
GByteArray *
|
||||
crypto_decrypt_private_key_data (const GByteArray *contents,
|
||||
const char *password,
|
||||
NMCryptoKeyType *out_key_type,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *decrypted = NULL;
|
||||
NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_RSA;
|
||||
GByteArray *data;
|
||||
char *iv = NULL;
|
||||
char *cipher = NULL;
|
||||
|
||||
g_return_val_if_fail (contents != NULL, NULL);
|
||||
if (out_key_type)
|
||||
g_return_val_if_fail (*out_key_type == NM_CRYPTO_KEY_TYPE_UNKNOWN, NULL);
|
||||
|
||||
/* OpenSSL non-standard legacy PEM files */
|
||||
|
||||
/* Try RSA keys first */
|
||||
data = parse_old_openssl_key_file (contents, key_type, &cipher, &iv, error);
|
||||
if (!data) {
|
||||
g_clear_error (error);
|
||||
|
||||
/* DSA next */
|
||||
key_type = NM_CRYPTO_KEY_TYPE_DSA;
|
||||
data = parse_old_openssl_key_file (contents, key_type, &cipher, &iv, error);
|
||||
if (!data) {
|
||||
g_clear_error (error);
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Unable to determine private key type."));
|
||||
}
|
||||
}
|
||||
|
||||
if (data) {
|
||||
/* return the key type even if decryption failed */
|
||||
if (out_key_type)
|
||||
*out_key_type = key_type;
|
||||
|
||||
if (password) {
|
||||
decrypted = decrypt_key (cipher,
|
||||
key_type,
|
||||
data,
|
||||
iv,
|
||||
password,
|
||||
error);
|
||||
}
|
||||
g_byte_array_free (data, TRUE);
|
||||
}
|
||||
|
||||
g_free (cipher);
|
||||
g_free (iv);
|
||||
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
GByteArray *
|
||||
crypto_decrypt_private_key (const char *file,
|
||||
const char *password,
|
||||
NMCryptoKeyType *out_key_type,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *contents;
|
||||
GByteArray *key = NULL;
|
||||
|
||||
contents = file_to_g_byte_array (file, error);
|
||||
if (contents) {
|
||||
key = crypto_decrypt_private_key_data (contents, password, out_key_type, error);
|
||||
g_byte_array_free (contents, TRUE);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
static GByteArray *
|
||||
extract_pem_cert_data (GByteArray *contents, GError **error)
|
||||
{
|
||||
GByteArray *cert = NULL;
|
||||
gsize start = 0, end = 0;
|
||||
unsigned char *der = NULL;
|
||||
guint8 save_end;
|
||||
gsize length = 0;
|
||||
|
||||
if (!find_tag (PEM_CERT_BEGIN, contents, 0, &start)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("PEM certificate had no start tag '%s'."),
|
||||
PEM_CERT_BEGIN);
|
||||
goto done;
|
||||
}
|
||||
|
||||
start += strlen (PEM_CERT_BEGIN);
|
||||
if (!find_tag (PEM_CERT_END, contents, start, &end)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("PEM certificate had no end tag '%s'."),
|
||||
PEM_CERT_END);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* g_base64_decode() wants a NULL-terminated string */
|
||||
save_end = contents->data[end];
|
||||
contents->data[end] = '\0';
|
||||
der = g_base64_decode ((const char *) (contents->data + start), &length);
|
||||
contents->data[end] = save_end;
|
||||
|
||||
if (der && length) {
|
||||
cert = g_byte_array_sized_new (length);
|
||||
g_byte_array_append (cert, der, length);
|
||||
g_assert (cert->len == length);
|
||||
} else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_DECODE_FAILED,
|
||||
_("Failed to decode certificate."));
|
||||
}
|
||||
|
||||
done:
|
||||
g_free (der);
|
||||
return cert;
|
||||
}
|
||||
|
||||
GByteArray *
|
||||
crypto_load_and_verify_certificate (const char *file,
|
||||
NMCryptoFileFormat *out_file_format,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *array, *contents;
|
||||
|
||||
g_return_val_if_fail (file != NULL, NULL);
|
||||
g_return_val_if_fail (out_file_format != NULL, NULL);
|
||||
g_return_val_if_fail (*out_file_format == NM_CRYPTO_FILE_FORMAT_UNKNOWN, NULL);
|
||||
|
||||
contents = file_to_g_byte_array (file, error);
|
||||
if (!contents)
|
||||
return NULL;
|
||||
|
||||
/* Check for PKCS#12 */
|
||||
if (crypto_is_pkcs12_data (contents)) {
|
||||
*out_file_format = NM_CRYPTO_FILE_FORMAT_PKCS12;
|
||||
return contents;
|
||||
}
|
||||
|
||||
/* Check for plain DER format */
|
||||
if (contents->len > 2 && contents->data[0] == 0x30 && contents->data[1] == 0x82) {
|
||||
*out_file_format = crypto_verify_cert (contents->data, contents->len, error);
|
||||
} else {
|
||||
array = extract_pem_cert_data (contents, error);
|
||||
if (!array) {
|
||||
g_byte_array_free (contents, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*out_file_format = crypto_verify_cert (array->data, array->len, error);
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
|
||||
if (*out_file_format != NM_CRYPTO_FILE_FORMAT_X509) {
|
||||
g_byte_array_free (contents, TRUE);
|
||||
contents = NULL;
|
||||
}
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_is_pkcs12_data (const GByteArray *data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
success = crypto_verify_pkcs12 (data, NULL, &error);
|
||||
if (success == FALSE) {
|
||||
/* If the error was just a decryption error, then it's pkcs#12 */
|
||||
if (error) {
|
||||
if (g_error_matches (error, NM_CRYPTO_ERROR, NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED))
|
||||
success = TRUE;
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_is_pkcs12_file (const char *file, GError **error)
|
||||
{
|
||||
GByteArray *contents;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (file != NULL, FALSE);
|
||||
|
||||
contents = file_to_g_byte_array (file, error);
|
||||
if (contents) {
|
||||
success = crypto_is_pkcs12_data (contents);
|
||||
g_byte_array_free (contents, TRUE);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/* Verifies that a private key can be read, and if a password is given, that
|
||||
* the private key can be decrypted with that password.
|
||||
*/
|
||||
NMCryptoFileFormat
|
||||
crypto_verify_private_key_data (const GByteArray *contents,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *tmp;
|
||||
NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
NMCryptoKeyType ktype = NM_CRYPTO_KEY_TYPE_UNKNOWN;
|
||||
gboolean is_encrypted = FALSE;
|
||||
|
||||
g_return_val_if_fail (contents != NULL, FALSE);
|
||||
|
||||
/* Check for PKCS#12 first */
|
||||
if (crypto_is_pkcs12_data (contents)) {
|
||||
if (!password || crypto_verify_pkcs12 (contents, password, error))
|
||||
format = NM_CRYPTO_FILE_FORMAT_PKCS12;
|
||||
} else {
|
||||
/* Maybe it's PKCS#8 */
|
||||
tmp = parse_pkcs8_key_file (contents, &is_encrypted, error);
|
||||
if (tmp) {
|
||||
if (crypto_verify_pkcs8 (tmp, is_encrypted, password, error))
|
||||
format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
|
||||
} else {
|
||||
g_clear_error (error);
|
||||
|
||||
/* Or it's old-style OpenSSL */
|
||||
tmp = crypto_decrypt_private_key_data (contents, password, &ktype, error);
|
||||
if (tmp)
|
||||
format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
|
||||
else if (!password && (ktype != NM_CRYPTO_KEY_TYPE_UNKNOWN))
|
||||
format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
|
||||
}
|
||||
|
||||
if (tmp) {
|
||||
/* Don't leave decrypted key data around */
|
||||
memset (tmp->data, 0, tmp->len);
|
||||
g_byte_array_free (tmp, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
NMCryptoFileFormat
|
||||
crypto_verify_private_key (const char *filename,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *contents;
|
||||
NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
||||
contents = file_to_g_byte_array (filename, error);
|
||||
if (contents) {
|
||||
format = crypto_verify_private_key_data (contents, password, error);
|
||||
g_byte_array_free (contents, TRUE);
|
||||
}
|
||||
return format;
|
||||
}
|
||||
145
libnm-core/crypto.h
Normal file
145
libnm-core/crypto.h
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* Dan Williams <dcbw@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.
|
||||
*
|
||||
* Copyright 2007 - 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __CRYPTO_H__
|
||||
#define __CRYPTO_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#define MD5_HASH_LEN 20
|
||||
#define CIPHER_DES_EDE3_CBC "DES-EDE3-CBC"
|
||||
#define CIPHER_DES_CBC "DES-CBC"
|
||||
#define CIPHER_AES_CBC "AES-128-CBC"
|
||||
|
||||
enum {
|
||||
NM_CRYPTO_ERR_NONE = 0,
|
||||
NM_CRYPTO_ERR_INIT_FAILED,
|
||||
NM_CRYPTO_ERR_CANT_READ_FILE,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
|
||||
NM_CRYPTO_ERR_DECODE_FAILED,
|
||||
NM_CRYPTO_ERR_OUT_OF_MEMORY,
|
||||
NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE,
|
||||
NM_CRYPTO_ERR_UNKNOWN_CIPHER,
|
||||
NM_CRYPTO_ERR_RAW_IV_INVALID,
|
||||
NM_CRYPTO_ERR_MD5_INIT_FAILED,
|
||||
NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
NM_CRYPTO_ERR_INVALID_PASSWORD,
|
||||
NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED,
|
||||
NM_CRYPTO_ERR_RANDOMIZE_FAILED
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
NM_CRYPTO_KEY_TYPE_UNKNOWN = 0,
|
||||
NM_CRYPTO_KEY_TYPE_RSA,
|
||||
NM_CRYPTO_KEY_TYPE_DSA
|
||||
} NMCryptoKeyType;
|
||||
|
||||
typedef enum {
|
||||
NM_CRYPTO_FILE_FORMAT_UNKNOWN = 0,
|
||||
NM_CRYPTO_FILE_FORMAT_X509,
|
||||
NM_CRYPTO_FILE_FORMAT_RAW_KEY,
|
||||
NM_CRYPTO_FILE_FORMAT_PKCS12
|
||||
} NMCryptoFileFormat;
|
||||
|
||||
#define NM_CRYPTO_ERROR _nm_crypto_error_quark ()
|
||||
GQuark _nm_crypto_error_quark (void);
|
||||
|
||||
gboolean crypto_init (GError **error);
|
||||
|
||||
void crypto_deinit (void);
|
||||
|
||||
GByteArray *crypto_decrypt_private_key_data (const GByteArray *contents,
|
||||
const char *password,
|
||||
NMCryptoKeyType *out_key_type,
|
||||
GError **error);
|
||||
|
||||
GByteArray *crypto_decrypt_private_key (const char *file,
|
||||
const char *password,
|
||||
NMCryptoKeyType *out_key_type,
|
||||
GError **error);
|
||||
|
||||
GByteArray *crypto_load_and_verify_certificate (const char *file,
|
||||
NMCryptoFileFormat *out_file_format,
|
||||
GError **error);
|
||||
|
||||
gboolean crypto_is_pkcs12_file (const char *file, GError **error);
|
||||
|
||||
gboolean crypto_is_pkcs12_data (const GByteArray *data);
|
||||
|
||||
NMCryptoFileFormat crypto_verify_private_key_data (const GByteArray *contents,
|
||||
const char *password,
|
||||
GError **error);
|
||||
|
||||
NMCryptoFileFormat crypto_verify_private_key (const char *file,
|
||||
const char *password,
|
||||
GError **error);
|
||||
|
||||
/* Internal utils API bits for crypto providers */
|
||||
|
||||
gboolean crypto_md5_hash (const char *salt,
|
||||
const gsize salt_len,
|
||||
const char *password,
|
||||
gsize password_len,
|
||||
char *buffer,
|
||||
gsize buflen,
|
||||
GError **error);
|
||||
|
||||
char * crypto_decrypt (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
const gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error);
|
||||
|
||||
char * crypto_encrypt (const char *cipher,
|
||||
const GByteArray *data,
|
||||
const char *iv,
|
||||
gsize iv_len,
|
||||
const char *key,
|
||||
gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error);
|
||||
|
||||
gboolean crypto_randomize (void *buffer, gsize buffer_len, GError **error);
|
||||
|
||||
NMCryptoFileFormat crypto_verify_cert (const unsigned char *data,
|
||||
gsize len,
|
||||
GError **error);
|
||||
|
||||
gboolean crypto_verify_pkcs12 (const GByteArray *data,
|
||||
const char *password,
|
||||
GError **error);
|
||||
|
||||
gboolean crypto_verify_pkcs8 (const GByteArray *data,
|
||||
gboolean is_encrypted,
|
||||
const char *password,
|
||||
GError **error);
|
||||
|
||||
#endif /* __CRYPTO_H__ */
|
||||
493
libnm-core/crypto_gnutls.c
Normal file
493
libnm-core/crypto_gnutls.c
Normal file
|
|
@ -0,0 +1,493 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
|
||||
*
|
||||
* Dan Williams <dcbw@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.
|
||||
*
|
||||
* Copyright 2007 - 2009 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <gcrypt.h>
|
||||
#include <gnutls/gnutls.h>
|
||||
#include <gnutls/x509.h>
|
||||
#include <gnutls/pkcs12.h>
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
#define SALT_LEN 8
|
||||
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
gboolean
|
||||
crypto_init (GError **error)
|
||||
{
|
||||
if (initialized)
|
||||
return TRUE;
|
||||
|
||||
if (gnutls_global_init() != 0) {
|
||||
gnutls_global_deinit();
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_INIT_FAILED,
|
||||
"%s",
|
||||
_("Failed to initialize the crypto engine."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
initialized = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
crypto_deinit (void)
|
||||
{
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_md5_hash (const char *salt,
|
||||
const gsize salt_len,
|
||||
const char *password,
|
||||
gsize password_len,
|
||||
char *buffer,
|
||||
gsize buflen,
|
||||
GError **error)
|
||||
{
|
||||
gcry_md_hd_t ctx;
|
||||
gcry_error_t err;
|
||||
int nkey = buflen;
|
||||
const gsize digest_len = 16;
|
||||
int count = 0;
|
||||
char digest[MD5_HASH_LEN];
|
||||
char *p = buffer;
|
||||
|
||||
if (salt)
|
||||
g_return_val_if_fail (salt_len >= SALT_LEN, FALSE);
|
||||
|
||||
g_return_val_if_fail (password != NULL, FALSE);
|
||||
g_return_val_if_fail (password_len > 0, FALSE);
|
||||
g_return_val_if_fail (buffer != NULL, FALSE);
|
||||
g_return_val_if_fail (buflen > 0, FALSE);
|
||||
|
||||
err = gcry_md_open (&ctx, GCRY_MD_MD5, 0);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_MD5_INIT_FAILED,
|
||||
_("Failed to initialize the MD5 engine: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (nkey > 0) {
|
||||
int i = 0;
|
||||
|
||||
if (count++)
|
||||
gcry_md_write (ctx, digest, digest_len);
|
||||
gcry_md_write (ctx, password, password_len);
|
||||
if (salt)
|
||||
gcry_md_write (ctx, salt, SALT_LEN); /* Only use 8 bytes of salt */
|
||||
gcry_md_final (ctx);
|
||||
memcpy (digest, gcry_md_read (ctx, 0), digest_len);
|
||||
gcry_md_reset (ctx);
|
||||
|
||||
while (nkey && (i < digest_len)) {
|
||||
*(p++) = digest[i++];
|
||||
nkey--;
|
||||
}
|
||||
}
|
||||
|
||||
memset (digest, 0, sizeof (digest));
|
||||
gcry_md_close (ctx);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *
|
||||
crypto_decrypt (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
const gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
gcry_cipher_hd_t ctx;
|
||||
gcry_error_t err;
|
||||
int cipher_mech, i;
|
||||
char *output = NULL;
|
||||
gboolean success = FALSE;
|
||||
gsize pad_len, real_iv_len;
|
||||
|
||||
if (!strcmp (cipher, CIPHER_DES_EDE3_CBC)) {
|
||||
cipher_mech = GCRY_CIPHER_3DES;
|
||||
real_iv_len = SALT_LEN;
|
||||
} else if (!strcmp (cipher, CIPHER_DES_CBC)) {
|
||||
cipher_mech = GCRY_CIPHER_DES;
|
||||
real_iv_len = SALT_LEN;
|
||||
} else if (!strcmp (cipher, CIPHER_AES_CBC)) {
|
||||
cipher_mech = GCRY_CIPHER_AES;
|
||||
real_iv_len = 16;
|
||||
} else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_UNKNOWN_CIPHER,
|
||||
_("Private key cipher '%s' was unknown."),
|
||||
cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (iv_len < real_iv_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_RAW_IV_INVALID,
|
||||
_("Invalid IV length (must be at least %zd)."),
|
||||
real_iv_len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
output = g_malloc0 (data->len);
|
||||
|
||||
err = gcry_cipher_open (&ctx, cipher_mech, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
|
||||
_("Failed to initialize the decryption cipher context: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = gcry_cipher_setkey (ctx, key, key_len);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
|
||||
_("Failed to set symmetric key for decryption: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = gcry_cipher_setiv (ctx, iv, iv_len);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
|
||||
_("Failed to set IV for decryption: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = gcry_cipher_decrypt (ctx, output, data->len, data->data, data->len);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
pad_len = output[data->len - 1];
|
||||
|
||||
/* Check if the padding at the end of the decrypted data is valid */
|
||||
if (pad_len == 0 || pad_len > real_iv_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key: unexpected padding length."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Validate tail padding; last byte is the padding size, and all pad bytes
|
||||
* should contain the padding size.
|
||||
*/
|
||||
for (i = 1; i <= pad_len; ++i) {
|
||||
if (output[data->len - i] != pad_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key."));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
*out_len = data->len - pad_len;
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
if (!success) {
|
||||
if (output) {
|
||||
/* Don't expose key material */
|
||||
memset (output, 0, data->len);
|
||||
g_free (output);
|
||||
output = NULL;
|
||||
}
|
||||
}
|
||||
gcry_cipher_close (ctx);
|
||||
return output;
|
||||
}
|
||||
|
||||
char *
|
||||
crypto_encrypt (const char *cipher,
|
||||
const GByteArray *data,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
gcry_cipher_hd_t ctx;
|
||||
gcry_error_t err;
|
||||
int cipher_mech;
|
||||
char *output = NULL;
|
||||
gboolean success = FALSE;
|
||||
gsize padded_buf_len, pad_len, output_len;
|
||||
char *padded_buf = NULL;
|
||||
guint32 i;
|
||||
gsize salt_len;
|
||||
|
||||
if (!strcmp (cipher, CIPHER_DES_EDE3_CBC)) {
|
||||
cipher_mech = GCRY_CIPHER_3DES;
|
||||
salt_len = SALT_LEN;
|
||||
} else if (!strcmp (cipher, CIPHER_AES_CBC)) {
|
||||
cipher_mech = GCRY_CIPHER_AES;
|
||||
salt_len = iv_len;
|
||||
} else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_UNKNOWN_CIPHER,
|
||||
_("Private key cipher '%s' was unknown."),
|
||||
cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If data->len % ivlen == 0, then we add another complete block
|
||||
* onto the end so that the decrypter knows there's padding.
|
||||
*/
|
||||
pad_len = iv_len - (data->len % iv_len);
|
||||
output_len = padded_buf_len = data->len + pad_len;
|
||||
padded_buf = g_malloc0 (padded_buf_len);
|
||||
|
||||
memcpy (padded_buf, data->data, data->len);
|
||||
for (i = 0; i < pad_len; i++)
|
||||
padded_buf[data->len + i] = (guint8) (pad_len & 0xFF);
|
||||
|
||||
output = g_malloc0 (output_len);
|
||||
|
||||
err = gcry_cipher_open (&ctx, cipher_mech, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
|
||||
_("Failed to initialize the encryption cipher context: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = gcry_cipher_setkey (ctx, key, key_len);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
|
||||
_("Failed to set symmetric key for encryption: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* gcrypt only wants 8 bytes of the IV (same as the DES block length) */
|
||||
err = gcry_cipher_setiv (ctx, iv, salt_len);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
|
||||
_("Failed to set IV for encryption: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = gcry_cipher_encrypt (ctx, output, output_len, padded_buf, padded_buf_len);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to encrypt the data: %s / %s."),
|
||||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
|
||||
*out_len = output_len;
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
if (padded_buf) {
|
||||
memset (padded_buf, 0, padded_buf_len);
|
||||
g_free (padded_buf);
|
||||
padded_buf = NULL;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
if (output) {
|
||||
/* Don't expose key material */
|
||||
memset (output, 0, output_len);
|
||||
g_free (output);
|
||||
output = NULL;
|
||||
}
|
||||
}
|
||||
gcry_cipher_close (ctx);
|
||||
return output;
|
||||
}
|
||||
|
||||
NMCryptoFileFormat
|
||||
crypto_verify_cert (const unsigned char *data,
|
||||
gsize len,
|
||||
GError **error)
|
||||
{
|
||||
gnutls_x509_crt_t der;
|
||||
gnutls_datum_t dt;
|
||||
int err;
|
||||
|
||||
err = gnutls_x509_crt_init (&der);
|
||||
if (err < 0) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
|
||||
_("Error initializing certificate data: %s"),
|
||||
gnutls_strerror (err));
|
||||
return NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Try DER first */
|
||||
dt.data = (unsigned char *) data;
|
||||
dt.size = len;
|
||||
err = gnutls_x509_crt_import (der, &dt, GNUTLS_X509_FMT_DER);
|
||||
if (err == GNUTLS_E_SUCCESS) {
|
||||
gnutls_x509_crt_deinit (der);
|
||||
return NM_CRYPTO_FILE_FORMAT_X509;
|
||||
}
|
||||
|
||||
/* And PEM next */
|
||||
err = gnutls_x509_crt_import (der, &dt, GNUTLS_X509_FMT_PEM);
|
||||
gnutls_x509_crt_deinit (der);
|
||||
if (err == GNUTLS_E_SUCCESS)
|
||||
return NM_CRYPTO_FILE_FORMAT_X509;
|
||||
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
|
||||
_("Couldn't decode certificate: %s"),
|
||||
gnutls_strerror (err));
|
||||
return NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs12 (const GByteArray *data,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
gnutls_pkcs12_t p12;
|
||||
gnutls_datum_t dt;
|
||||
gboolean success = FALSE;
|
||||
int err;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
dt.data = (unsigned char *) data->data;
|
||||
dt.size = data->len;
|
||||
|
||||
err = gnutls_pkcs12_init (&p12);
|
||||
if (err < 0) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_DECODE_FAILED,
|
||||
_("Couldn't initialize PKCS#12 decoder: %s"),
|
||||
gnutls_strerror (err));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* DER first */
|
||||
err = gnutls_pkcs12_import (p12, &dt, GNUTLS_X509_FMT_DER, 0);
|
||||
if (err < 0) {
|
||||
/* PEM next */
|
||||
err = gnutls_pkcs12_import (p12, &dt, GNUTLS_X509_FMT_PEM, 0);
|
||||
if (err < 0) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Couldn't decode PKCS#12 file: %s"),
|
||||
gnutls_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
err = gnutls_pkcs12_verify_mac (p12, password);
|
||||
if (err == GNUTLS_E_SUCCESS)
|
||||
success = TRUE;
|
||||
else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Couldn't verify PKCS#12 file: %s"),
|
||||
gnutls_strerror (err));
|
||||
}
|
||||
|
||||
out:
|
||||
gnutls_pkcs12_deinit (p12);
|
||||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs8 (const GByteArray *data,
|
||||
gboolean is_encrypted,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
gnutls_x509_privkey_t p8;
|
||||
gnutls_datum_t dt;
|
||||
int err;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
dt.data = (unsigned char *) data->data;
|
||||
dt.size = data->len;
|
||||
|
||||
err = gnutls_x509_privkey_init (&p8);
|
||||
if (err < 0) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_DECODE_FAILED,
|
||||
_("Couldn't initialize PKCS#8 decoder: %s"),
|
||||
gnutls_strerror (err));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
err = gnutls_x509_privkey_import_pkcs8 (p8,
|
||||
&dt,
|
||||
GNUTLS_X509_FMT_DER,
|
||||
is_encrypted ? password : NULL,
|
||||
is_encrypted ? 0 : GNUTLS_PKCS_PLAIN);
|
||||
gnutls_x509_privkey_deinit (p8);
|
||||
|
||||
if (err < 0) {
|
||||
if (err == GNUTLS_E_UNKNOWN_CIPHER_TYPE) {
|
||||
/* HACK: gnutls doesn't support all the cipher types that openssl
|
||||
* can use with PKCS#8, so if we encounter one, we have to assume
|
||||
* the given password works. gnutls needs to unsuckify, apparently.
|
||||
* Specifically, by default openssl uses pbeWithMD5AndDES-CBC
|
||||
* which gnutls does not support.
|
||||
*/
|
||||
} else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Couldn't decode PKCS#8 file: %s"),
|
||||
gnutls_strerror (err));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_randomize (void *buffer, gsize buffer_len, GError **error)
|
||||
{
|
||||
gcry_randomize (buffer, buffer_len, GCRY_STRONG_RANDOM);
|
||||
return TRUE;
|
||||
}
|
||||
562
libnm-core/crypto_nss.c
Normal file
562
libnm-core/crypto_nss.c
Normal file
|
|
@ -0,0 +1,562 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* Dan Williams <dcbw@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.
|
||||
*
|
||||
* Copyright 2007 - 2009 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <prinit.h>
|
||||
#include <nss.h>
|
||||
#include <pk11pub.h>
|
||||
#include <pkcs11t.h>
|
||||
#include <cert.h>
|
||||
#include <prerror.h>
|
||||
#include <p12.h>
|
||||
#include <ciferfam.h>
|
||||
#include <p12plcy.h>
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
gboolean
|
||||
crypto_init (GError **error)
|
||||
{
|
||||
SECStatus ret;
|
||||
|
||||
if (initialized)
|
||||
return TRUE;
|
||||
|
||||
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 1);
|
||||
ret = NSS_NoDB_Init (NULL);
|
||||
if (ret != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_INIT_FAILED,
|
||||
_("Failed to initialize the crypto engine: %d."),
|
||||
PR_GetError ());
|
||||
PR_Cleanup ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SEC_PKCS12EnableCipher(PKCS12_RC4_40, 1);
|
||||
SEC_PKCS12EnableCipher(PKCS12_RC4_128, 1);
|
||||
SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_40, 1);
|
||||
SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_128, 1);
|
||||
SEC_PKCS12EnableCipher(PKCS12_DES_56, 1);
|
||||
SEC_PKCS12EnableCipher(PKCS12_DES_EDE3_168, 1);
|
||||
SEC_PKCS12SetPreferredCipher(PKCS12_DES_EDE3_168, 1);
|
||||
|
||||
initialized = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
crypto_deinit (void)
|
||||
{
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_md5_hash (const char *salt,
|
||||
const gsize salt_len,
|
||||
const char *password,
|
||||
gsize password_len,
|
||||
char *buffer,
|
||||
gsize buflen,
|
||||
GError **error)
|
||||
{
|
||||
PK11Context *ctx;
|
||||
int nkey = buflen;
|
||||
unsigned int digest_len;
|
||||
int count = 0;
|
||||
char digest[MD5_HASH_LEN];
|
||||
char *p = buffer;
|
||||
|
||||
if (salt)
|
||||
g_return_val_if_fail (salt_len >= 8, FALSE);
|
||||
|
||||
g_return_val_if_fail (password != NULL, FALSE);
|
||||
g_return_val_if_fail (password_len > 0, FALSE);
|
||||
g_return_val_if_fail (buffer != NULL, FALSE);
|
||||
g_return_val_if_fail (buflen > 0, FALSE);
|
||||
|
||||
ctx = PK11_CreateDigestContext (SEC_OID_MD5);
|
||||
if (!ctx) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_MD5_INIT_FAILED,
|
||||
_("Failed to initialize the MD5 context: %d."),
|
||||
PORT_GetError ());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (nkey > 0) {
|
||||
int i = 0;
|
||||
|
||||
PK11_DigestBegin (ctx);
|
||||
if (count++)
|
||||
PK11_DigestOp (ctx, (const unsigned char *) digest, digest_len);
|
||||
PK11_DigestOp (ctx, (const unsigned char *) password, password_len);
|
||||
if (salt)
|
||||
PK11_DigestOp (ctx, (const unsigned char *) salt, 8); /* Only use 8 bytes of salt */
|
||||
PK11_DigestFinal (ctx, (unsigned char *) digest, &digest_len, sizeof (digest));
|
||||
|
||||
while (nkey && (i < digest_len)) {
|
||||
*(p++) = digest[i++];
|
||||
nkey--;
|
||||
}
|
||||
}
|
||||
|
||||
memset (digest, 0, sizeof (digest));
|
||||
PK11_DestroyContext (ctx, PR_TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *
|
||||
crypto_decrypt (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
const gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
char *output = NULL;
|
||||
int decrypted_len = 0;
|
||||
CK_MECHANISM_TYPE cipher_mech;
|
||||
PK11SlotInfo *slot = NULL;
|
||||
SECItem key_item;
|
||||
PK11SymKey *sym_key = NULL;
|
||||
SECItem *sec_param = NULL;
|
||||
PK11Context *ctx = NULL;
|
||||
SECStatus s;
|
||||
gboolean success = FALSE;
|
||||
unsigned int pad_len = 0, extra = 0;
|
||||
guint32 i, real_iv_len = 0;
|
||||
|
||||
if (!strcmp (cipher, CIPHER_DES_EDE3_CBC)) {
|
||||
cipher_mech = CKM_DES3_CBC_PAD;
|
||||
real_iv_len = 8;
|
||||
} else if (!strcmp (cipher, CIPHER_DES_CBC)) {
|
||||
cipher_mech = CKM_DES_CBC_PAD;
|
||||
real_iv_len = 8;
|
||||
} else if (!strcmp (cipher, CIPHER_AES_CBC)) {
|
||||
cipher_mech = CKM_AES_CBC_PAD;
|
||||
real_iv_len = 16;
|
||||
} else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_UNKNOWN_CIPHER,
|
||||
_("Private key cipher '%s' was unknown."),
|
||||
cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (iv_len < real_iv_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_RAW_IV_INVALID,
|
||||
_("Invalid IV length (must be at least %d)."),
|
||||
real_iv_len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
output = g_malloc0 (data->len);
|
||||
|
||||
slot = PK11_GetBestSlot (cipher_mech, NULL);
|
||||
if (!slot) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
|
||||
_("Failed to initialize the decryption cipher slot."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
key_item.data = (unsigned char *) key;
|
||||
key_item.len = key_len;
|
||||
sym_key = PK11_ImportSymKey (slot, cipher_mech, PK11_OriginUnwrap, CKA_DECRYPT, &key_item, NULL);
|
||||
if (!sym_key) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
|
||||
_("Failed to set symmetric key for decryption."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
key_item.data = (unsigned char *) iv;
|
||||
key_item.len = real_iv_len;
|
||||
sec_param = PK11_ParamFromIV (cipher_mech, &key_item);
|
||||
if (!sec_param) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
|
||||
_("Failed to set IV for decryption."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
ctx = PK11_CreateContextBySymKey (cipher_mech, CKA_DECRYPT, sym_key, sec_param);
|
||||
if (!ctx) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
|
||||
_("Failed to initialize the decryption context."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
s = PK11_CipherOp (ctx,
|
||||
(unsigned char *) output,
|
||||
&decrypted_len,
|
||||
data->len,
|
||||
data->data,
|
||||
data->len);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key: %d."),
|
||||
PORT_GetError ());
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (decrypted_len > data->len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key: decrypted data too large."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
s = PK11_DigestFinal (ctx,
|
||||
(unsigned char *) (output + decrypted_len),
|
||||
&extra,
|
||||
data->len - decrypted_len);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to finalize decryption of the private key: %d."),
|
||||
PORT_GetError ());
|
||||
goto out;
|
||||
}
|
||||
decrypted_len += extra;
|
||||
pad_len = data->len - decrypted_len;
|
||||
|
||||
/* Check if the padding at the end of the decrypted data is valid */
|
||||
if (pad_len == 0 || pad_len > real_iv_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key: unexpected padding length."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Validate tail padding; last byte is the padding size, and all pad bytes
|
||||
* should contain the padding size.
|
||||
*/
|
||||
for (i = pad_len; i > 0; i--) {
|
||||
if (output[data->len - i] != pad_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key."));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
*out_len = decrypted_len;
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
if (ctx)
|
||||
PK11_DestroyContext (ctx, PR_TRUE);
|
||||
if (sym_key)
|
||||
PK11_FreeSymKey (sym_key);
|
||||
if (sec_param)
|
||||
SECITEM_FreeItem (sec_param, PR_TRUE);
|
||||
if (slot)
|
||||
PK11_FreeSlot (slot);
|
||||
|
||||
if (!success) {
|
||||
if (output) {
|
||||
/* Don't expose key material */
|
||||
memset (output, 0, data->len);
|
||||
g_free (output);
|
||||
output = NULL;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
char *
|
||||
crypto_encrypt (const char *cipher,
|
||||
const GByteArray *data,
|
||||
const char *iv,
|
||||
gsize iv_len,
|
||||
const char *key,
|
||||
gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
SECStatus ret;
|
||||
CK_MECHANISM_TYPE cipher_mech = CKM_DES3_CBC_PAD;
|
||||
PK11SlotInfo *slot = NULL;
|
||||
SECItem key_item = { .data = (unsigned char *) key, .len = key_len };
|
||||
SECItem iv_item = { .data = (unsigned char *) iv, .len = iv_len };
|
||||
PK11SymKey *sym_key = NULL;
|
||||
SECItem *sec_param = NULL;
|
||||
PK11Context *ctx = NULL;
|
||||
unsigned char *output, *padded_buf;
|
||||
gsize output_len;
|
||||
int encrypted_len = 0, i;
|
||||
gboolean success = FALSE;
|
||||
gsize padded_buf_len, pad_len;
|
||||
|
||||
if (!strcmp (cipher, CIPHER_DES_EDE3_CBC))
|
||||
cipher_mech = CKM_DES3_CBC_PAD;
|
||||
else if (!strcmp (cipher, CIPHER_AES_CBC))
|
||||
cipher_mech = CKM_AES_CBC_PAD;
|
||||
else {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_UNKNOWN_CIPHER,
|
||||
_("Private key cipher '%s' was unknown."),
|
||||
cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If data->len % ivlen == 0, then we add another complete block
|
||||
* onto the end so that the decrypter knows there's padding.
|
||||
*/
|
||||
pad_len = iv_len - (data->len % iv_len);
|
||||
output_len = padded_buf_len = data->len + pad_len;
|
||||
padded_buf = g_malloc0 (padded_buf_len);
|
||||
|
||||
memcpy (padded_buf, data->data, data->len);
|
||||
for (i = 0; i < pad_len; i++)
|
||||
padded_buf[data->len + i] = (guint8) (pad_len & 0xFF);
|
||||
|
||||
output = g_malloc0 (output_len);
|
||||
|
||||
slot = PK11_GetBestSlot (cipher_mech, NULL);
|
||||
if (!slot) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
|
||||
_("Failed to initialize the encryption cipher slot."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
sym_key = PK11_ImportSymKey (slot, cipher_mech, PK11_OriginUnwrap, CKA_ENCRYPT, &key_item, NULL);
|
||||
if (!sym_key) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
|
||||
_("Failed to set symmetric key for encryption."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
sec_param = PK11_ParamFromIV (cipher_mech, &iv_item);
|
||||
if (!sec_param) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
|
||||
_("Failed to set IV for encryption."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
ctx = PK11_CreateContextBySymKey (cipher_mech, CKA_ENCRYPT, sym_key, sec_param);
|
||||
if (!ctx) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
|
||||
_("Failed to initialize the encryption context."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = PK11_CipherOp (ctx, output, &encrypted_len, output_len, padded_buf, padded_buf_len);
|
||||
if (ret != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED,
|
||||
_("Failed to encrypt: %d."),
|
||||
PORT_GetError ());
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (encrypted_len != output_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED,
|
||||
_("Unexpected amount of data after encrypting."));
|
||||
goto out;
|
||||
}
|
||||
|
||||
*out_len = encrypted_len;
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
if (ctx)
|
||||
PK11_DestroyContext (ctx, PR_TRUE);
|
||||
if (sym_key)
|
||||
PK11_FreeSymKey (sym_key);
|
||||
if (sec_param)
|
||||
SECITEM_FreeItem (sec_param, PR_TRUE);
|
||||
if (slot)
|
||||
PK11_FreeSlot (slot);
|
||||
|
||||
memset (padded_buf, 0, padded_buf_len);
|
||||
g_free (padded_buf);
|
||||
|
||||
if (!success) {
|
||||
memset (output, 0, output_len);
|
||||
g_free (output);
|
||||
output = NULL;
|
||||
}
|
||||
return (char *) output;
|
||||
}
|
||||
|
||||
NMCryptoFileFormat
|
||||
crypto_verify_cert (const unsigned char *data,
|
||||
gsize len,
|
||||
GError **error)
|
||||
{
|
||||
CERTCertificate *cert;
|
||||
|
||||
/* Try DER/PEM first */
|
||||
cert = CERT_DecodeCertFromPackage ((char *) data, len);
|
||||
if (!cert) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
|
||||
_("Couldn't decode certificate: %d"),
|
||||
PORT_GetError());
|
||||
return NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
CERT_DestroyCertificate (cert);
|
||||
return NM_CRYPTO_FILE_FORMAT_X509;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs12 (const GByteArray *data,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
SEC_PKCS12DecoderContext *p12ctx = NULL;
|
||||
SECItem pw = { 0 };
|
||||
PK11SlotInfo *slot = NULL;
|
||||
SECStatus s;
|
||||
char *ucs2_password;
|
||||
glong ucs2_chars = 0;
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
guint16 *p;
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
|
||||
if (error)
|
||||
g_return_val_if_fail (*error == NULL, FALSE);
|
||||
|
||||
/* PKCS#12 passwords are apparently UCS2 BIG ENDIAN, and NSS doesn't do
|
||||
* any conversions for us.
|
||||
*/
|
||||
if (password && strlen (password)) {
|
||||
ucs2_password = (char *) g_utf8_to_utf16 (password, strlen (password), NULL, &ucs2_chars, NULL);
|
||||
if (!ucs2_password || !ucs2_chars) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_INVALID_PASSWORD,
|
||||
_("Couldn't convert password to UCS2: %d"),
|
||||
PORT_GetError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ucs2_chars *= 2; /* convert # UCS2 characters -> bytes */
|
||||
pw.data = PORT_ZAlloc(ucs2_chars + 2);
|
||||
memcpy (pw.data, ucs2_password, ucs2_chars);
|
||||
pw.len = ucs2_chars + 2; /* include terminating NULL */
|
||||
|
||||
memset (ucs2_password, 0, ucs2_chars);
|
||||
g_free (ucs2_password);
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
|
||||
*p = GUINT16_SWAP_LE_BE (*p);
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
} else {
|
||||
/* NULL password */
|
||||
pw.data = NULL;
|
||||
pw.len = 0;
|
||||
}
|
||||
|
||||
slot = PK11_GetInternalKeySlot();
|
||||
p12ctx = SEC_PKCS12DecoderStart (&pw, slot, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (!p12ctx) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_DECODE_FAILED,
|
||||
_("Couldn't initialize PKCS#12 decoder: %d"),
|
||||
PORT_GetError());
|
||||
goto error;
|
||||
}
|
||||
|
||||
s = SEC_PKCS12DecoderUpdate (p12ctx, data->data, data->len);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Couldn't decode PKCS#12 file: %d"),
|
||||
PORT_GetError());
|
||||
goto error;
|
||||
}
|
||||
|
||||
s = SEC_PKCS12DecoderVerify (p12ctx);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Couldn't verify PKCS#12 file: %d"),
|
||||
PORT_GetError());
|
||||
goto error;
|
||||
}
|
||||
|
||||
SEC_PKCS12DecoderFinish (p12ctx);
|
||||
SECITEM_ZfreeItem (&pw, PR_FALSE);
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
if (p12ctx)
|
||||
SEC_PKCS12DecoderFinish (p12ctx);
|
||||
|
||||
if (slot)
|
||||
PK11_FreeSlot(slot);
|
||||
|
||||
SECITEM_ZfreeItem (&pw, PR_FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs8 (const GByteArray *data,
|
||||
gboolean is_encrypted,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
/* NSS apparently doesn't do PKCS#8 natively, but you have to put the
|
||||
* PKCS#8 key into a PKCS#12 file and import that?? So until we figure
|
||||
* all that out, we can only assume the password is valid.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
crypto_randomize (void *buffer, gsize buffer_len, GError **error)
|
||||
{
|
||||
SECStatus s;
|
||||
|
||||
s = PK11_GenerateRandom (buffer, buffer_len);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error_literal (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_RANDOMIZE_FAILED,
|
||||
_("Could not generate random data."));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
2168
libnm-core/nm-connection.c
Normal file
2168
libnm-core/nm-connection.c
Normal file
File diff suppressed because it is too large
Load diff
254
libnm-core/nm-connection.h
Normal file
254
libnm-core/nm-connection.h
Normal file
|
|
@ -0,0 +1,254 @@
|
|||
/* -*- 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 2007 - 2013 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_CONNECTION_H
|
||||
#define NM_CONNECTION_H
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <nm-setting.h>
|
||||
|
||||
#include <nm-setting-8021x.h>
|
||||
#include <nm-setting-bluetooth.h>
|
||||
#include <nm-setting-bond.h>
|
||||
#include <nm-setting-team.h>
|
||||
#include <nm-setting-team-port.h>
|
||||
#include <nm-setting-bridge.h>
|
||||
#include <nm-setting-bridge-port.h>
|
||||
#include <nm-setting-cdma.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-dcb.h>
|
||||
#include <nm-setting-generic.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-adsl.h>
|
||||
#include <nm-setting-wireless.h>
|
||||
#include <nm-setting-wireless-security.h>
|
||||
#include <nm-setting-vlan.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_CONNECTION (nm_connection_get_type ())
|
||||
#define NM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION, NMConnection))
|
||||
#define NM_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CONNECTION, NMConnectionClass))
|
||||
#define NM_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION))
|
||||
#define NM_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CONNECTION))
|
||||
#define NM_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
|
||||
|
||||
/* Signals */
|
||||
#define NM_CONNECTION_SECRETS_UPDATED "secrets-updated"
|
||||
#define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
|
||||
#define NM_CONNECTION_CHANGED "changed"
|
||||
|
||||
/* Properties */
|
||||
#define NM_CONNECTION_PATH "path"
|
||||
|
||||
/**
|
||||
* NMConnectionError:
|
||||
* @NM_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error
|
||||
* @NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND: the #NMConnection object
|
||||
* did not contain the required #NMSettingConnection object, which must be
|
||||
* present for all connections
|
||||
* @NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID: the 'type' property of the
|
||||
* 'connection' setting did not point to a valid connection base type; ie
|
||||
* it was not a hardware-related setting like #NMSettingWired or
|
||||
* #NMSettingWireless.
|
||||
* @NM_CONNECTION_ERROR_SETTING_NOT_FOUND: the #NMConnection object
|
||||
* did not contain the specified #NMSetting object
|
||||
*@NM_CONNECTION_ERROR_INVALID_SETTING: the #NMConnection object contains
|
||||
* a conflicting setting object
|
||||
*
|
||||
* Describes errors that may result from operations involving a #NMConnection.
|
||||
*
|
||||
**/
|
||||
typedef enum
|
||||
{
|
||||
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 >*/
|
||||
NM_CONNECTION_ERROR_INVALID_SETTING, /*< nick=InvalidSetting >*/
|
||||
} NMConnectionError;
|
||||
|
||||
/*
|
||||
* NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method
|
||||
* when normalizing ip6 configuration. If omited, this defaults to
|
||||
* @NM_SETTING_IP6_CONFIG_METHOD_AUTO.
|
||||
*/
|
||||
#define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"
|
||||
|
||||
#define NM_CONNECTION_ERROR nm_connection_error_quark ()
|
||||
GQuark nm_connection_error_quark (void);
|
||||
|
||||
/**
|
||||
* NMConnection:
|
||||
*
|
||||
* The NMConnection struct contains only private data.
|
||||
* It should only be accessed through the functions described below.
|
||||
*/
|
||||
typedef struct {
|
||||
GObject parent;
|
||||
} NMConnection;
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
|
||||
/* Signals */
|
||||
void (*secrets_updated) (NMConnection *connection, const char * setting);
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[8];
|
||||
} NMConnectionClass;
|
||||
|
||||
GType nm_connection_get_type (void);
|
||||
|
||||
NMConnection *nm_connection_new (void);
|
||||
|
||||
NMConnection *nm_connection_new_from_hash (GHashTable *hash, GError **error);
|
||||
|
||||
NMConnection *nm_connection_duplicate (NMConnection *connection);
|
||||
|
||||
NMSetting *nm_connection_create_setting (const char *name);
|
||||
|
||||
void nm_connection_add_setting (NMConnection *connection,
|
||||
NMSetting *setting);
|
||||
|
||||
void nm_connection_remove_setting (NMConnection *connection,
|
||||
GType setting_type);
|
||||
|
||||
NMSetting *nm_connection_get_setting (NMConnection *connection,
|
||||
GType setting_type);
|
||||
|
||||
NMSetting *nm_connection_get_setting_by_name (NMConnection *connection,
|
||||
const char *name);
|
||||
|
||||
gboolean nm_connection_replace_settings (NMConnection *connection,
|
||||
GHashTable *new_settings,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_connection_replace_settings_from_connection (NMConnection *connection,
|
||||
NMConnection *new_connection,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_connection_compare (NMConnection *a,
|
||||
NMConnection *b,
|
||||
NMSettingCompareFlags flags);
|
||||
|
||||
gboolean nm_connection_diff (NMConnection *a,
|
||||
NMConnection *b,
|
||||
NMSettingCompareFlags flags,
|
||||
GHashTable **out_settings);
|
||||
|
||||
gboolean nm_connection_verify (NMConnection *connection, GError **error);
|
||||
gboolean nm_connection_normalize (NMConnection *connection,
|
||||
GHashTable *parameters,
|
||||
gboolean *modified,
|
||||
GError **error);
|
||||
|
||||
const char * nm_connection_need_secrets (NMConnection *connection,
|
||||
GPtrArray **hints);
|
||||
|
||||
void nm_connection_clear_secrets (NMConnection *connection);
|
||||
|
||||
void nm_connection_clear_secrets_with_flags (NMConnection *connection,
|
||||
NMSettingClearSecretsWithFlagsFn func,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean nm_connection_update_secrets (NMConnection *connection,
|
||||
const char *setting_name,
|
||||
GHashTable *secrets,
|
||||
GError **error);
|
||||
|
||||
void nm_connection_set_path (NMConnection *connection,
|
||||
const char *path);
|
||||
|
||||
const char * nm_connection_get_path (NMConnection *connection);
|
||||
|
||||
const char * nm_connection_get_virtual_iface_name (NMConnection *connection);
|
||||
|
||||
const char * nm_connection_get_interface_name (NMConnection *connection);
|
||||
|
||||
gboolean nm_connection_is_type (NMConnection *connection, const char *type);
|
||||
|
||||
void nm_connection_for_each_setting_value (NMConnection *connection,
|
||||
NMSettingValueIterFn func,
|
||||
gpointer user_data);
|
||||
|
||||
GHashTable *nm_connection_to_hash (NMConnection *connection,
|
||||
NMSettingHashFlags flags);
|
||||
|
||||
void nm_connection_dump (NMConnection *connection);
|
||||
|
||||
GType nm_connection_lookup_setting_type (const char *name);
|
||||
|
||||
GType nm_connection_lookup_setting_type_by_quark (GQuark error_quark);
|
||||
|
||||
/* Helpers */
|
||||
const char * nm_connection_get_uuid (NMConnection *connection);
|
||||
const char * nm_connection_get_id (NMConnection *connection);
|
||||
const char * nm_connection_get_connection_type (NMConnection *connection);
|
||||
|
||||
char * nm_connection_get_virtual_device_description (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);
|
||||
NMSettingTeam * nm_connection_get_setting_team (NMConnection *connection);
|
||||
NMSettingTeamPort * nm_connection_get_setting_team_port (NMConnection *connection);
|
||||
NMSettingBridge * nm_connection_get_setting_bridge (NMConnection *connection);
|
||||
NMSettingBridgePort * nm_connection_get_setting_bridge_port (NMConnection *connection);
|
||||
NMSettingCdma * nm_connection_get_setting_cdma (NMConnection *connection);
|
||||
NMSettingConnection * nm_connection_get_setting_connection (NMConnection *connection);
|
||||
NMSettingDcb * nm_connection_get_setting_dcb (NMConnection *connection);
|
||||
NMSettingGeneric * nm_connection_get_setting_generic (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);
|
||||
NMSettingAdsl * nm_connection_get_setting_adsl (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
|
||||
|
||||
#endif /* NM_CONNECTION_H */
|
||||
610
libnm-core/nm-dbus-interface.h
Normal file
610
libnm-core/nm-dbus-interface.h
Normal file
|
|
@ -0,0 +1,610 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2004 - 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Definitions related to NetworkManager's D-Bus interfaces.
|
||||
*
|
||||
* Note that although this header is installed as part of libnm, it is also
|
||||
* used by some external code that does not link to libnm.
|
||||
*/
|
||||
|
||||
#ifndef NM_DBUS_INTERFACE_H
|
||||
#define NM_DBUS_INTERFACE_H
|
||||
|
||||
#include "nm-version.h"
|
||||
|
||||
/*
|
||||
* dbus services details
|
||||
*/
|
||||
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
||||
|
||||
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
|
||||
#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
|
||||
#define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_ADSL NM_DBUS_INTERFACE_DEVICE ".Adsl"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_BLUETOOTH NM_DBUS_INTERFACE_DEVICE ".Bluetooth"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_OLPC_MESH NM_DBUS_INTERFACE_DEVICE ".OlpcMesh"
|
||||
#define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint"
|
||||
#define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_MODEM NM_DBUS_INTERFACE_DEVICE ".Modem"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_WIMAX NM_DBUS_INTERFACE_DEVICE ".WiMax"
|
||||
#define NM_DBUS_INTERFACE_WIMAX_NSP NM_DBUS_INTERFACE ".WiMax.Nsp"
|
||||
#define NM_DBUS_PATH_WIMAX_NSP NM_DBUS_PATH "/Nsp"
|
||||
#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
|
||||
#define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config"
|
||||
#define NM_DBUS_INTERFACE_DHCP4_CONFIG NM_DBUS_INTERFACE ".DHCP4Config"
|
||||
#define NM_DBUS_INTERFACE_IP6_CONFIG NM_DBUS_INTERFACE ".IP6Config"
|
||||
#define NM_DBUS_INTERFACE_DHCP6_CONFIG NM_DBUS_INTERFACE ".DHCP6Config"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_INFINIBAND NM_DBUS_INTERFACE_DEVICE ".Infiniband"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_BOND NM_DBUS_INTERFACE_DEVICE ".Bond"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_TEAM NM_DBUS_INTERFACE_DEVICE ".Team"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_VLAN NM_DBUS_INTERFACE_DEVICE ".Vlan"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_BRIDGE NM_DBUS_INTERFACE_DEVICE ".Bridge"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_GENERIC NM_DBUS_INTERFACE_DEVICE ".Generic"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_VETH NM_DBUS_INTERFACE_DEVICE ".Veth"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_TUN NM_DBUS_INTERFACE_DEVICE ".Tun"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_MACVLAN NM_DBUS_INTERFACE_DEVICE ".Macvlan"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_VXLAN NM_DBUS_INTERFACE_DEVICE ".Vxlan"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_GRE NM_DBUS_INTERFACE_DEVICE ".Gre"
|
||||
|
||||
|
||||
#define NM_DBUS_INTERFACE_SETTINGS "org.freedesktop.NetworkManager.Settings"
|
||||
#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
|
||||
|
||||
#define NM_DBUS_INTERFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManager.Settings.Connection"
|
||||
#define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManager/Settings/Connection"
|
||||
#define NM_DBUS_INTERFACE_SETTINGS_CONNECTION_SECRETS "org.freedesktop.NetworkManager.Settings.Connection.Secrets"
|
||||
|
||||
#define NM_DBUS_INTERFACE_AGENT_MANAGER NM_DBUS_INTERFACE ".AgentManager"
|
||||
#define NM_DBUS_PATH_AGENT_MANAGER "/org/freedesktop/NetworkManager/AgentManager"
|
||||
|
||||
#define NM_DBUS_INTERFACE_SECRET_AGENT NM_DBUS_INTERFACE ".SecretAgent"
|
||||
#define NM_DBUS_PATH_SECRET_AGENT "/org/freedesktop/NetworkManager/SecretAgent"
|
||||
|
||||
/**
|
||||
* NMState:
|
||||
* @NM_STATE_UNKNOWN: networking state is unknown
|
||||
* @NM_STATE_ASLEEP: networking is not enabled
|
||||
* @NM_STATE_DISCONNECTED: there is no active network connection
|
||||
* @NM_STATE_DISCONNECTING: network connections are being cleaned up
|
||||
* @NM_STATE_CONNECTING: a network connection is being started
|
||||
* @NM_STATE_CONNECTED_LOCAL: there is only local IPv4 and/or IPv6 connectivity
|
||||
* @NM_STATE_CONNECTED_SITE: there is only site-wide IPv4 and/or IPv6 connectivity
|
||||
* @NM_STATE_CONNECTED_GLOBAL: there is global IPv4 and/or IPv6 Internet connectivity
|
||||
*
|
||||
* #NMState values indicate the current overall networking state.
|
||||
*
|
||||
* (Corresponds to the NM_STATE type in nm-manager.xml.)
|
||||
**/
|
||||
typedef enum {
|
||||
NM_STATE_UNKNOWN = 0,
|
||||
NM_STATE_ASLEEP = 10,
|
||||
NM_STATE_DISCONNECTED = 20,
|
||||
NM_STATE_DISCONNECTING = 30,
|
||||
NM_STATE_CONNECTING = 40,
|
||||
NM_STATE_CONNECTED_LOCAL = 50,
|
||||
NM_STATE_CONNECTED_SITE = 60,
|
||||
NM_STATE_CONNECTED_GLOBAL = 70
|
||||
} NMState;
|
||||
|
||||
/**
|
||||
* NMConnectivityState:
|
||||
* @NM_CONNECTIVITY_UNKNOWN: Network connectivity is unknown.
|
||||
* @NM_CONNECTIVITY_NONE: The host is not connected to any network.
|
||||
* @NM_CONNECTIVITY_PORTAL: The host is behind a captive portal and
|
||||
* cannot reach the full Internet.
|
||||
* @NM_CONNECTIVITY_LIMITED: The host is connected to a network, but
|
||||
* does not appear to be able to reach the full Internet.
|
||||
* @NM_CONNECTIVITY_FULL: The host is connected to a network, and
|
||||
* appears to be able to reach the full Internet.
|
||||
*
|
||||
* (Corresponds to the NM_CONNECTIVITY type in nm-manager.xml.)
|
||||
*/
|
||||
typedef enum {
|
||||
NM_CONNECTIVITY_UNKNOWN,
|
||||
NM_CONNECTIVITY_NONE,
|
||||
NM_CONNECTIVITY_PORTAL,
|
||||
NM_CONNECTIVITY_LIMITED,
|
||||
NM_CONNECTIVITY_FULL
|
||||
} NMConnectivityState;
|
||||
|
||||
/**
|
||||
* NMDeviceType:
|
||||
* @NM_DEVICE_TYPE_UNKNOWN: unknown device
|
||||
* @NM_DEVICE_TYPE_GENERIC: generic support for unrecognized device types
|
||||
* @NM_DEVICE_TYPE_ETHERNET: a wired ethernet device
|
||||
* @NM_DEVICE_TYPE_WIFI: an 802.11 WiFi device
|
||||
* @NM_DEVICE_TYPE_UNUSED1: not used
|
||||
* @NM_DEVICE_TYPE_UNUSED2: not used
|
||||
* @NM_DEVICE_TYPE_BT: a Bluetooth device supporting PAN or DUN access protocols
|
||||
* @NM_DEVICE_TYPE_OLPC_MESH: an OLPC XO mesh networking device
|
||||
* @NM_DEVICE_TYPE_WIMAX: an 802.16e Mobile WiMAX broadband device
|
||||
* @NM_DEVICE_TYPE_MODEM: a modem supporting analog telephone, CDMA/EVDO,
|
||||
* GSM/UMTS, or LTE network access protocols
|
||||
* @NM_DEVICE_TYPE_INFINIBAND: an IP-over-InfiniBand device
|
||||
* @NM_DEVICE_TYPE_BOND: a bond master interface
|
||||
* @NM_DEVICE_TYPE_VLAN: an 802.1Q VLAN interface
|
||||
* @NM_DEVICE_TYPE_ADSL: ADSL modem
|
||||
* @NM_DEVICE_TYPE_BRIDGE: a bridge master interface
|
||||
* @NM_DEVICE_TYPE_TEAM: a team master interface
|
||||
*
|
||||
* #NMDeviceType values indicate the type of hardware represented by
|
||||
* an #NMDevice.
|
||||
*
|
||||
* (Corresponds to the NM_DEVICE_TYPE type in nm-device.xml.)
|
||||
**/
|
||||
typedef enum {
|
||||
NM_DEVICE_TYPE_UNKNOWN = 0,
|
||||
NM_DEVICE_TYPE_ETHERNET = 1,
|
||||
NM_DEVICE_TYPE_WIFI = 2,
|
||||
NM_DEVICE_TYPE_UNUSED1 = 3,
|
||||
NM_DEVICE_TYPE_UNUSED2 = 4,
|
||||
NM_DEVICE_TYPE_BT = 5, /* Bluetooth */
|
||||
NM_DEVICE_TYPE_OLPC_MESH = 6,
|
||||
NM_DEVICE_TYPE_WIMAX = 7,
|
||||
NM_DEVICE_TYPE_MODEM = 8,
|
||||
NM_DEVICE_TYPE_INFINIBAND = 9,
|
||||
NM_DEVICE_TYPE_BOND = 10,
|
||||
NM_DEVICE_TYPE_VLAN = 11,
|
||||
NM_DEVICE_TYPE_ADSL = 12,
|
||||
NM_DEVICE_TYPE_BRIDGE = 13,
|
||||
NM_DEVICE_TYPE_GENERIC = 14,
|
||||
NM_DEVICE_TYPE_TEAM = 15,
|
||||
} NMDeviceType;
|
||||
|
||||
/**
|
||||
* NMDeviceCapabilities:
|
||||
* @NM_DEVICE_CAP_NONE: device has no special capabilities
|
||||
* @NM_DEVICE_CAP_NM_SUPPORTED: NetworkManager supports this device
|
||||
* @NM_DEVICE_CAP_CARRIER_DETECT: this device can indicate carrier status
|
||||
* @NM_DEVICE_CAP_IS_SOFTWARE: this device is a software device
|
||||
*
|
||||
* General device capability flags.
|
||||
*
|
||||
* (Corresponds to the NM_DEVICE_CAP type in nm-device-wifi.xml.)
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_DEVICE_CAP_NONE = 0x00000000,
|
||||
NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001,
|
||||
NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002,
|
||||
NM_DEVICE_CAP_IS_SOFTWARE = 0x00000004,
|
||||
} NMDeviceCapabilities;
|
||||
|
||||
|
||||
/**
|
||||
* NMDeviceWifiCapabilities:
|
||||
* @NM_WIFI_DEVICE_CAP_NONE: device has no encryption/authentication capabilities
|
||||
* @NM_WIFI_DEVICE_CAP_CIPHER_WEP40: device supports 40/64-bit WEP encryption
|
||||
* @NM_WIFI_DEVICE_CAP_CIPHER_WEP104: device supports 104/128-bit WEP encryption
|
||||
* @NM_WIFI_DEVICE_CAP_CIPHER_TKIP: device supports TKIP encryption
|
||||
* @NM_WIFI_DEVICE_CAP_CIPHER_CCMP: device supports AES/CCMP encryption
|
||||
* @NM_WIFI_DEVICE_CAP_WPA: device supports WPA1 authentication
|
||||
* @NM_WIFI_DEVICE_CAP_RSN: device supports WPA2/RSN authentication
|
||||
* @NM_WIFI_DEVICE_CAP_AP: device supports Access Point mode
|
||||
* @NM_WIFI_DEVICE_CAP_ADHOC: device supports Ad-Hoc mode
|
||||
*
|
||||
* 802.11 specific device encryption and authentication capabilities.
|
||||
*
|
||||
* (Corresponds to the NM_802_11_DEVICE_CAP type in nm-device-wifi.xml.)
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_WIFI_DEVICE_CAP_NONE = 0x00000000,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_WEP40 = 0x00000001,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_WEP104 = 0x00000002,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_TKIP = 0x00000004,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_CCMP = 0x00000008,
|
||||
NM_WIFI_DEVICE_CAP_WPA = 0x00000010,
|
||||
NM_WIFI_DEVICE_CAP_RSN = 0x00000020,
|
||||
NM_WIFI_DEVICE_CAP_AP = 0x00000040,
|
||||
NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080
|
||||
} NMDeviceWifiCapabilities;
|
||||
|
||||
|
||||
/**
|
||||
* NM80211ApFlags:
|
||||
* @NM_802_11_AP_FLAGS_NONE: access point has no special capabilities
|
||||
* @NM_802_11_AP_FLAGS_PRIVACY: access point requires authentication and
|
||||
* encryption (usually means WEP)
|
||||
*
|
||||
* 802.11 access point flags.
|
||||
*
|
||||
* (Corresponds to the NM_802_11_AP_FLAGS type in nm-access-point.xml.)
|
||||
**/
|
||||
typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/
|
||||
NM_802_11_AP_FLAGS_NONE = 0x00000000,
|
||||
NM_802_11_AP_FLAGS_PRIVACY = 0x00000001
|
||||
} NM80211ApFlags;
|
||||
|
||||
/**
|
||||
* NM80211ApSecurityFlags:
|
||||
* @NM_802_11_AP_SEC_NONE: the access point has no special security requirements
|
||||
* @NM_802_11_AP_SEC_PAIR_WEP40: 40/64-bit WEP is supported for
|
||||
* pairwise/unicast encryption
|
||||
* @NM_802_11_AP_SEC_PAIR_WEP104: 104/128-bit WEP is supported for
|
||||
* pairwise/unicast encryption
|
||||
* @NM_802_11_AP_SEC_PAIR_TKIP: TKIP is supported for pairwise/unicast encryption
|
||||
* @NM_802_11_AP_SEC_PAIR_CCMP: AES/CCMP is supported for pairwise/unicast encryption
|
||||
* @NM_802_11_AP_SEC_GROUP_WEP40: 40/64-bit WEP is supported for group/broadcast
|
||||
* encryption
|
||||
* @NM_802_11_AP_SEC_GROUP_WEP104: 104/128-bit WEP is supported for
|
||||
* group/broadcast encryption
|
||||
* @NM_802_11_AP_SEC_GROUP_TKIP: TKIP is supported for group/broadcast encryption
|
||||
* @NM_802_11_AP_SEC_GROUP_CCMP: AES/CCMP is supported for group/broadcast
|
||||
* encryption
|
||||
* @NM_802_11_AP_SEC_KEY_MGMT_PSK: WPA/RSN Pre-Shared Key encryption is
|
||||
* supported
|
||||
* @NM_802_11_AP_SEC_KEY_MGMT_802_1X: 802.1x authentication and key management
|
||||
* is supported
|
||||
*
|
||||
* 802.11 access point security and authentication flags. These flags describe
|
||||
* the current security requirements of an access point as determined from the
|
||||
* access point's beacon.
|
||||
*
|
||||
* (Corresponds to the NM_802_11_AP_SEC type in nm-access-point.xml.)
|
||||
**/
|
||||
typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
|
||||
NM_802_11_AP_SEC_NONE = 0x00000000,
|
||||
NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001,
|
||||
NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002,
|
||||
NM_802_11_AP_SEC_PAIR_TKIP = 0x00000004,
|
||||
NM_802_11_AP_SEC_PAIR_CCMP = 0x00000008,
|
||||
NM_802_11_AP_SEC_GROUP_WEP40 = 0x00000010,
|
||||
NM_802_11_AP_SEC_GROUP_WEP104 = 0x00000020,
|
||||
NM_802_11_AP_SEC_GROUP_TKIP = 0x00000040,
|
||||
NM_802_11_AP_SEC_GROUP_CCMP = 0x00000080,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200
|
||||
} NM80211ApSecurityFlags;
|
||||
|
||||
/**
|
||||
* NM80211Mode:
|
||||
* @NM_802_11_MODE_UNKNOWN: the device or access point mode is unknown
|
||||
* @NM_802_11_MODE_ADHOC: for both devices and access point objects, indicates
|
||||
* the object is part of an Ad-Hoc 802.11 network without a central
|
||||
* coordinating access point.
|
||||
* @NM_802_11_MODE_INFRA: the device or access point is in infrastructure mode.
|
||||
* For devices, this indicates the device is an 802.11 client/station. For
|
||||
* access point objects, this indicates the object is an access point that
|
||||
* provides connectivity to clients.
|
||||
* @NM_802_11_MODE_AP: the device is an access point/hotspot. Not valid for
|
||||
* access point objects; used only for hotspot mode on the local machine.
|
||||
*
|
||||
* Indicates the 802.11 mode an access point or device is currently in.
|
||||
*
|
||||
* (Corresponds to the NM_802_11_MODE type in generic-types.xml.)
|
||||
**/
|
||||
typedef enum { /*< underscore_name=nm_802_11_mode >*/
|
||||
NM_802_11_MODE_UNKNOWN = 0,
|
||||
NM_802_11_MODE_ADHOC,
|
||||
NM_802_11_MODE_INFRA,
|
||||
NM_802_11_MODE_AP
|
||||
} NM80211Mode;
|
||||
|
||||
/**
|
||||
* NMBluetoothCapabilities:
|
||||
* @NM_BT_CAPABILITY_NONE: device has no usable capabilities
|
||||
* @NM_BT_CAPABILITY_DUN: device provides Dial-Up Networking capability
|
||||
* @NM_BT_CAPABILITY_NAP: device provides Network Access Point capability
|
||||
*
|
||||
* #NMBluetoothCapabilities values indicate the usable capabilities of a
|
||||
* Bluetooth device.
|
||||
*
|
||||
* (Corresponds to the NM_BT_CAPABILITY type in nm-device-bt.xml.)
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_BT_CAPABILITY_NONE = 0x00000000,
|
||||
NM_BT_CAPABILITY_DUN = 0x00000001,
|
||||
NM_BT_CAPABILITY_NAP = 0x00000002,
|
||||
} NMBluetoothCapabilities;
|
||||
|
||||
/**
|
||||
* NMDeviceModemCapabilities:
|
||||
* @NM_DEVICE_MODEM_CAPABILITY_NONE: modem has no usable capabilities
|
||||
* @NM_DEVICE_MODEM_CAPABILITY_POTS: modem uses the analog wired telephone
|
||||
* network and is not a wireless/cellular device
|
||||
* @NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO: modem supports at least one of CDMA
|
||||
* 1xRTT, EVDO revision 0, EVDO revision A, or EVDO revision B
|
||||
* @NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS: modem supports at least one of GSM,
|
||||
* GPRS, EDGE, UMTS, HSDPA, HSUPA, or HSPA+ packet switched data capability
|
||||
* @NM_DEVICE_MODEM_CAPABILITY_LTE: modem has LTE data capability
|
||||
*
|
||||
* #NMDeviceModemCapabilities values indicate the generic radio access
|
||||
* technology families a modem device supports. For more information on the
|
||||
* specific access technologies the device supports use the ModemManager D-Bus
|
||||
* API.
|
||||
*
|
||||
* (Corresponds to the NM_DEVICE_MODEM_CAPABILITY type in nm-device-modem.xml.)
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000,
|
||||
NM_DEVICE_MODEM_CAPABILITY_POTS = 0x00000001,
|
||||
NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002,
|
||||
NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004,
|
||||
NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008,
|
||||
} NMDeviceModemCapabilities;
|
||||
|
||||
|
||||
/**
|
||||
* NMDeviceState:
|
||||
* @NM_DEVICE_STATE_UNKNOWN: the device's state is unknown
|
||||
* @NM_DEVICE_STATE_UNMANAGED: the device is recognized, but not managed by
|
||||
* NetworkManager
|
||||
* @NM_DEVICE_STATE_UNAVAILABLE: the device is managed by NetworkManager, but
|
||||
* is not available for use. Reasons may include the wireless switched off,
|
||||
* missing firmware, no ethernet carrier, missing supplicant or modem manager,
|
||||
* etc.
|
||||
* @NM_DEVICE_STATE_DISCONNECTED: the device can be activated, but is currently
|
||||
* idle and not connected to a network.
|
||||
* @NM_DEVICE_STATE_PREPARE: the device is preparing the connection to the
|
||||
* network. This may include operations like changing the MAC address,
|
||||
* setting physical link properties, and anything else required to connect
|
||||
* to the requested network.
|
||||
* @NM_DEVICE_STATE_CONFIG: the device is connecting to the requested network.
|
||||
* This may include operations like associating with the WiFi AP, dialing
|
||||
* the modem, connecting to the remote Bluetooth device, etc.
|
||||
* @NM_DEVICE_STATE_NEED_AUTH: the device requires more information to continue
|
||||
* connecting to the requested network. This includes secrets like WiFi
|
||||
* passphrases, login passwords, PIN codes, etc.
|
||||
* @NM_DEVICE_STATE_IP_CONFIG: the device is requesting IPv4 and/or IPv6
|
||||
* addresses and routing information from the network.
|
||||
* @NM_DEVICE_STATE_IP_CHECK: the device is checking whether further action is
|
||||
* required for the requested network connection. This may include checking
|
||||
* whether only local network access is available, whether a captive portal
|
||||
* is blocking access to the Internet, etc.
|
||||
* @NM_DEVICE_STATE_SECONDARIES: the device is waiting for a secondary
|
||||
* connection (like a VPN) which must activated before the device can be
|
||||
* activated
|
||||
* @NM_DEVICE_STATE_ACTIVATED: the device has a network connection, either local
|
||||
* or global.
|
||||
* @NM_DEVICE_STATE_DEACTIVATING: a disconnection from the current network
|
||||
* connection was requested, and the device is cleaning up resources used for
|
||||
* that connection. The network connection may still be valid.
|
||||
* @NM_DEVICE_STATE_FAILED: the device failed to connect to the requested
|
||||
* network and is cleaning up the connection request
|
||||
*
|
||||
* (Corresponds to the NM_DEVICE_STATE type in nm-device.xml.)
|
||||
**/
|
||||
typedef enum {
|
||||
NM_DEVICE_STATE_UNKNOWN = 0,
|
||||
NM_DEVICE_STATE_UNMANAGED = 10,
|
||||
NM_DEVICE_STATE_UNAVAILABLE = 20,
|
||||
NM_DEVICE_STATE_DISCONNECTED = 30,
|
||||
NM_DEVICE_STATE_PREPARE = 40,
|
||||
NM_DEVICE_STATE_CONFIG = 50,
|
||||
NM_DEVICE_STATE_NEED_AUTH = 60,
|
||||
NM_DEVICE_STATE_IP_CONFIG = 70,
|
||||
NM_DEVICE_STATE_IP_CHECK = 80,
|
||||
NM_DEVICE_STATE_SECONDARIES = 90,
|
||||
NM_DEVICE_STATE_ACTIVATED = 100,
|
||||
NM_DEVICE_STATE_DEACTIVATING = 110,
|
||||
NM_DEVICE_STATE_FAILED = 120
|
||||
} NMDeviceState;
|
||||
|
||||
|
||||
/**
|
||||
* NMDeviceStateReason:
|
||||
* @NM_DEVICE_STATE_REASON_NONE: No reason given
|
||||
* @NM_DEVICE_STATE_REASON_UNKNOWN: Unknown error
|
||||
* @NM_DEVICE_STATE_REASON_NOW_MANAGED: Device is now managed
|
||||
* @NM_DEVICE_STATE_REASON_NOW_UNMANAGED: Device is now unmanaged
|
||||
* @NM_DEVICE_STATE_REASON_CONFIG_FAILED: The device could not be readied for configuration
|
||||
* @NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE: IP configuration could not be reserved (no available address, timeout, etc)
|
||||
* @NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED: The IP config is no longer valid
|
||||
* @NM_DEVICE_STATE_REASON_NO_SECRETS: Secrets were required, but not provided
|
||||
* @NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT: 802.1x supplicant disconnected
|
||||
* @NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED: 802.1x supplicant configuration failed
|
||||
* @NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED: 802.1x supplicant failed
|
||||
* @NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT: 802.1x supplicant took too long to authenticate
|
||||
* @NM_DEVICE_STATE_REASON_PPP_START_FAILED: PPP service failed to start
|
||||
* @NM_DEVICE_STATE_REASON_PPP_DISCONNECT: PPP service disconnected
|
||||
* @NM_DEVICE_STATE_REASON_PPP_FAILED: PPP failed
|
||||
* @NM_DEVICE_STATE_REASON_DHCP_START_FAILED: DHCP client failed to start
|
||||
* @NM_DEVICE_STATE_REASON_DHCP_ERROR: DHCP client error
|
||||
* @NM_DEVICE_STATE_REASON_DHCP_FAILED: DHCP client failed
|
||||
* @NM_DEVICE_STATE_REASON_SHARED_START_FAILED: Shared connection service failed to start
|
||||
* @NM_DEVICE_STATE_REASON_SHARED_FAILED: Shared connection service failed
|
||||
* @NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED: AutoIP service failed to start
|
||||
* @NM_DEVICE_STATE_REASON_AUTOIP_ERROR: AutoIP service error
|
||||
* @NM_DEVICE_STATE_REASON_AUTOIP_FAILED: AutoIP service failed
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_BUSY: The line is busy
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE: No dial tone
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER: No carrier could be established
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT: The dialing request timed out
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED: The dialing attempt failed
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED: Modem initialization failed
|
||||
* @NM_DEVICE_STATE_REASON_GSM_APN_FAILED: Failed to select the specified APN
|
||||
* @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING: Not searching for networks
|
||||
* @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED: Network registration denied
|
||||
* @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT: Network registration timed out
|
||||
* @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED: Failed to register with the requested network
|
||||
* @NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED: PIN check failed
|
||||
* @NM_DEVICE_STATE_REASON_FIRMWARE_MISSING: Necessary firmware for the device may be missing
|
||||
* @NM_DEVICE_STATE_REASON_REMOVED: The device was removed
|
||||
* @NM_DEVICE_STATE_REASON_SLEEPING: NetworkManager went to sleep
|
||||
* @NM_DEVICE_STATE_REASON_CONNECTION_REMOVED: The device's active connection disappeared
|
||||
* @NM_DEVICE_STATE_REASON_USER_REQUESTED: Device disconnected by user or client
|
||||
* @NM_DEVICE_STATE_REASON_CARRIER: Carrier/link changed
|
||||
* @NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED: The device's existing connection was assumed
|
||||
* @NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE: The supplicant is now available
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND: The modem could not be found
|
||||
* @NM_DEVICE_STATE_REASON_BT_FAILED: The Bluetooth connection failed or timed out
|
||||
* @NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED: GSM Modem's SIM Card not inserted
|
||||
* @NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED: GSM Modem's SIM Pin required
|
||||
* @NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED: GSM Modem's SIM Puk required
|
||||
* @NM_DEVICE_STATE_REASON_GSM_SIM_WRONG: GSM Modem's SIM wrong
|
||||
* @NM_DEVICE_STATE_REASON_INFINIBAND_MODE: InfiniBand device does not support connected mode
|
||||
* @NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED: A dependency of the connection failed
|
||||
* @NM_DEVICE_STATE_REASON_BR2684_FAILED: Problem with the RFC 2684 Ethernet over ADSL bridge
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE: ModemManager not running
|
||||
* @NM_DEVICE_STATE_REASON_SSID_NOT_FOUND: The WiFi network could not be found
|
||||
* @NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED: A secondary connection of the base connection failed
|
||||
* @NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED: DCB or FCoE setup failed
|
||||
* @NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED: teamd control failed
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_FAILED: Modem failed or no longer available
|
||||
* @NM_DEVICE_STATE_REASON_MODEM_AVAILABLE: Modem now ready and available
|
||||
* @NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT: SIM PIN was incorrect
|
||||
*
|
||||
* Device state change reason codes
|
||||
*
|
||||
* (Corresponds to the NM_DEVICE_STATE_REASON type in nm-device.xml.)
|
||||
*/
|
||||
typedef enum {
|
||||
NM_DEVICE_STATE_REASON_NONE = 0,
|
||||
NM_DEVICE_STATE_REASON_UNKNOWN = 1,
|
||||
NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
|
||||
NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
|
||||
NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4,
|
||||
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5,
|
||||
NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6,
|
||||
NM_DEVICE_STATE_REASON_NO_SECRETS = 7,
|
||||
NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8,
|
||||
NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9,
|
||||
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10,
|
||||
NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11,
|
||||
NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12,
|
||||
NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13,
|
||||
NM_DEVICE_STATE_REASON_PPP_FAILED = 14,
|
||||
NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15,
|
||||
NM_DEVICE_STATE_REASON_DHCP_ERROR = 16,
|
||||
NM_DEVICE_STATE_REASON_DHCP_FAILED = 17,
|
||||
NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18,
|
||||
NM_DEVICE_STATE_REASON_SHARED_FAILED = 19,
|
||||
NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20,
|
||||
NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21,
|
||||
NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22,
|
||||
NM_DEVICE_STATE_REASON_MODEM_BUSY = 23,
|
||||
NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24,
|
||||
NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25,
|
||||
NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26,
|
||||
NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27,
|
||||
NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28,
|
||||
NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29,
|
||||
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30,
|
||||
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31,
|
||||
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32,
|
||||
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33,
|
||||
NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34,
|
||||
NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35,
|
||||
NM_DEVICE_STATE_REASON_REMOVED = 36,
|
||||
NM_DEVICE_STATE_REASON_SLEEPING = 37,
|
||||
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38,
|
||||
NM_DEVICE_STATE_REASON_USER_REQUESTED = 39,
|
||||
NM_DEVICE_STATE_REASON_CARRIER = 40,
|
||||
NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41,
|
||||
NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42,
|
||||
NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43,
|
||||
NM_DEVICE_STATE_REASON_BT_FAILED = 44,
|
||||
NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45,
|
||||
NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46,
|
||||
NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47,
|
||||
NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48,
|
||||
NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49,
|
||||
NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50,
|
||||
NM_DEVICE_STATE_REASON_BR2684_FAILED = 51,
|
||||
NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
|
||||
NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53,
|
||||
NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED = 54,
|
||||
NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED = 55,
|
||||
NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED = 56,
|
||||
NM_DEVICE_STATE_REASON_MODEM_FAILED = 57,
|
||||
NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58,
|
||||
NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59,
|
||||
|
||||
NM_DEVICE_STATE_REASON_LAST = 0xFFFF
|
||||
} NMDeviceStateReason;
|
||||
|
||||
|
||||
/**
|
||||
* NMActiveConnectionState:
|
||||
* @NM_ACTIVE_CONNECTION_STATE_UNKNOWN: the state of the connection is unknown
|
||||
* @NM_ACTIVE_CONNECTION_STATE_ACTIVATING: a network connection is being prepared
|
||||
* @NM_ACTIVE_CONNECTION_STATE_ACTIVATED: there is a connection to the network
|
||||
* @NM_ACTIVE_CONNECTION_STATE_DEACTIVATING: the network connection is being
|
||||
* torn down and cleaned up
|
||||
* @NM_ACTIVE_CONNECTION_STATE_DEACTIVATED: the network connection is disconnected
|
||||
* and will be removed
|
||||
*
|
||||
* #NMActiveConnectionState values indicate the state of a connection to a
|
||||
* specific network while it is starting, connected, or disconnecting from that
|
||||
* network.
|
||||
*
|
||||
* (Corresponds to the NM_ACTIVE_CONNECTION_STATE type in nm-active-connection.xml.)
|
||||
**/
|
||||
typedef enum {
|
||||
NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
|
||||
NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
|
||||
NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
|
||||
} NMActiveConnectionState;
|
||||
|
||||
/**
|
||||
* NMSecretAgentGetSecretsFlags:
|
||||
* @NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE: no special behavior; by default no
|
||||
* user interaction is allowed and requests for secrets are fulfilled from
|
||||
* persistent storage, or if no secrets are available an error is returned.
|
||||
* @NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION: allows the request to
|
||||
* interact with the user, possibly prompting via UI for secrets if any are
|
||||
* required, or if none are found in persistent storage.
|
||||
* @NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW: explicitly prompt for new
|
||||
* secrets from the user. This flag signals that NetworkManager thinks any
|
||||
* existing secrets are invalid or wrong. This flag implies that interaction
|
||||
* is allowed.
|
||||
* @NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED: set if the request was
|
||||
* initiated by user-requested action via the D-Bus interface, as opposed to
|
||||
* automatically initiated by NetworkManager in response to (for example) scan
|
||||
* results or carrier changes.
|
||||
* @NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM: (Internal flag, not part of
|
||||
* the D-Bus API.)
|
||||
*
|
||||
* #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request.
|
||||
*
|
||||
* (Corresponds to the NM_SECRET_AGENT_GET_SECRETS_FLAGS type in nm-secret-agent.xml.)
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
|
||||
|
||||
/* Internal to NM; not part of the D-Bus API */
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000
|
||||
} NMSecretAgentGetSecretsFlags;
|
||||
|
||||
/**
|
||||
* NMSecretAgentCapabilities:
|
||||
* @NM_SECRET_AGENT_CAPABILITY_NONE: the agent supports no special capabilities
|
||||
* @NM_SECRET_AGENT_CAPABILITY_VPN_HINTS: the agent supports passing hints to
|
||||
* VPN plugin authentication dialogs.
|
||||
* @NM_SECRET_AGENT_CAPABILITY_LAST: bounds checking value; should not be used.
|
||||
*
|
||||
* #NMSecretAgentCapabilities indicate various capabilities of the agent.
|
||||
*
|
||||
* (Corresponds to the NM_SECRET_AGENT_CAPABILITIES type in nm-secret-agent.xml.)
|
||||
*/
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SECRET_AGENT_CAPABILITY_NONE = 0x0,
|
||||
NM_SECRET_AGENT_CAPABILITY_VPN_HINTS = 0x1,
|
||||
|
||||
/* boundary value */
|
||||
NM_SECRET_AGENT_CAPABILITY_LAST = NM_SECRET_AGENT_CAPABILITY_VPN_HINTS
|
||||
} NMSecretAgentCapabilities;
|
||||
|
||||
#endif /* NM_DBUS_INTERFACE_H */
|
||||
972
libnm-core/nm-param-spec-specialized.c
Normal file
972
libnm-core/nm-param-spec-specialized.c
Normal file
|
|
@ -0,0 +1,972 @@
|
|||
/* -*- 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 2007 - 2011 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
struct _NMParamSpecSpecialized {
|
||||
GParamSpec parent;
|
||||
};
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <netinet/in.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
||||
/***********************************************************/
|
||||
/* _gvalues_compare */
|
||||
|
||||
static gint _gvalues_compare (const GValue *value1, const GValue *value2);
|
||||
|
||||
static gboolean
|
||||
type_is_fixed_size (GType type, gsize *tsize)
|
||||
{
|
||||
switch (type) {
|
||||
case G_TYPE_CHAR:
|
||||
if (tsize) *tsize = sizeof (char);
|
||||
return TRUE;
|
||||
case G_TYPE_UCHAR:
|
||||
if (tsize) *tsize = sizeof (guchar);
|
||||
return TRUE;
|
||||
case G_TYPE_BOOLEAN:
|
||||
if (tsize) *tsize = sizeof (gboolean);
|
||||
return TRUE;
|
||||
case G_TYPE_LONG:
|
||||
if (tsize) *tsize = sizeof (glong);
|
||||
return TRUE;
|
||||
case G_TYPE_ULONG:
|
||||
if (tsize) *tsize = sizeof (gulong);
|
||||
return TRUE;
|
||||
case G_TYPE_INT:
|
||||
if (tsize) *tsize = sizeof (gint);
|
||||
return TRUE;
|
||||
case G_TYPE_UINT:
|
||||
if (tsize) *tsize = sizeof (guint);
|
||||
return TRUE;
|
||||
case G_TYPE_INT64:
|
||||
if (tsize) *tsize = sizeof (gint64);
|
||||
return TRUE;
|
||||
case G_TYPE_UINT64:
|
||||
if (tsize) *tsize = sizeof (guint64);
|
||||
return TRUE;
|
||||
case G_TYPE_FLOAT:
|
||||
if (tsize) *tsize = sizeof (gfloat);
|
||||
return TRUE;
|
||||
case G_TYPE_DOUBLE:
|
||||
if (tsize) *tsize = sizeof (gdouble);
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#define FLOAT_FACTOR 0.00000001
|
||||
|
||||
static gint
|
||||
_gvalues_compare_fixed (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (G_VALUE_TYPE (value1)) {
|
||||
case G_TYPE_CHAR: {
|
||||
gchar val1 = g_value_get_schar (value1);
|
||||
gchar val2 = g_value_get_schar (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UCHAR: {
|
||||
guchar val1 = g_value_get_uchar (value1);
|
||||
guchar val2 = g_value_get_uchar (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_BOOLEAN: {
|
||||
gboolean val1 = g_value_get_boolean (value1);
|
||||
gboolean val2 = g_value_get_boolean (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_LONG: {
|
||||
glong val1 = g_value_get_long (value1);
|
||||
glong val2 = g_value_get_long (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_ULONG: {
|
||||
gulong val1 = g_value_get_ulong (value1);
|
||||
gulong val2 = g_value_get_ulong (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT: {
|
||||
gint val1 = g_value_get_int (value1);
|
||||
gint val2 = g_value_get_int (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT: {
|
||||
guint val1 = g_value_get_uint (value1);
|
||||
guint val2 = g_value_get_uint (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT64: {
|
||||
gint64 val1 = g_value_get_int64 (value1);
|
||||
gint64 val2 = g_value_get_int64 (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT64: {
|
||||
guint64 val1 = g_value_get_uint64 (value1);
|
||||
guint64 val2 = g_value_get_uint64 (value2);
|
||||
if (val1 != val2)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_FLOAT: {
|
||||
gfloat val1 = g_value_get_float (value1);
|
||||
gfloat val2 = g_value_get_float (value2);
|
||||
/* Can't use == or != here due to inexactness of FP */
|
||||
if (fabsf (val1 - val2) > FLOAT_FACTOR)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_DOUBLE: {
|
||||
gdouble val1 = g_value_get_double (value1);
|
||||
gdouble val2 = g_value_get_double (value2);
|
||||
if (fabs (val1 - val2) > FLOAT_FACTOR)
|
||||
ret = val1 < val2 ? -1 : val1 > val2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
g_warning ("Unhandled fixed size type '%s'", G_VALUE_TYPE_NAME (value1));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_string (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
const char *str1 = g_value_get_string (value1);
|
||||
const char *str2 = g_value_get_string (value2);
|
||||
|
||||
if (str1 == str2)
|
||||
return 0;
|
||||
|
||||
if (!str1)
|
||||
return 1;
|
||||
if (!str2)
|
||||
return -1;
|
||||
|
||||
return strcmp (str1, str2);
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_strv (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
char **strv1;
|
||||
char **strv2;
|
||||
gint ret;
|
||||
guint i = 0;
|
||||
|
||||
strv1 = (char **) g_value_get_boxed (value1);
|
||||
strv2 = (char **) g_value_get_boxed (value2);
|
||||
|
||||
while (strv1[i] && strv2[i]) {
|
||||
ret = strcmp (strv1[i], strv2[i]);
|
||||
if (ret)
|
||||
return ret;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (strv1[i] == NULL && strv2[i] == NULL)
|
||||
return 0;
|
||||
|
||||
if (strv1[i])
|
||||
return 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_gvalue_destroy (gpointer data)
|
||||
{
|
||||
GValue *value = (GValue *) data;
|
||||
|
||||
g_value_unset (value);
|
||||
g_slice_free (GValue, value);
|
||||
}
|
||||
|
||||
static GValue *
|
||||
_gvalue_dup (const GValue *value)
|
||||
{
|
||||
GValue *dup;
|
||||
|
||||
dup = g_slice_new0 (GValue);
|
||||
g_value_init (dup, G_VALUE_TYPE (value));
|
||||
g_value_copy (value, dup);
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
static void
|
||||
iterate_collection (const GValue *value, gpointer user_data)
|
||||
{
|
||||
GSList **list = (GSList **) user_data;
|
||||
|
||||
*list = g_slist_prepend (*list, _gvalue_dup (value));
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_collection (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
gint ret;
|
||||
guint len1;
|
||||
guint len2;
|
||||
GType value_type = dbus_g_type_get_collection_specialization (G_VALUE_TYPE (value1));
|
||||
gsize element_size = 0;
|
||||
|
||||
if (type_is_fixed_size (value_type, &element_size)) {
|
||||
gpointer data1 = NULL;
|
||||
gpointer data2 = NULL;
|
||||
|
||||
dbus_g_type_collection_get_fixed ((GValue *) value1, &data1, &len1);
|
||||
dbus_g_type_collection_get_fixed ((GValue *) value2, &data2, &len2);
|
||||
|
||||
if (len1 != len2)
|
||||
ret = len1 < len2 ? -1 : len1 > len2;
|
||||
else
|
||||
ret = memcmp (data1, data2, len1 * element_size);
|
||||
} else {
|
||||
GSList *list1 = NULL;
|
||||
GSList *list2 = NULL;
|
||||
|
||||
dbus_g_type_collection_value_iterate (value1, iterate_collection, &list1);
|
||||
len1 = g_slist_length (list1);
|
||||
dbus_g_type_collection_value_iterate (value2, iterate_collection, &list2);
|
||||
len2 = g_slist_length (list2);
|
||||
|
||||
if (len1 != len2)
|
||||
ret = len1 < len2 ? -1 : len1 > len2;
|
||||
else {
|
||||
GSList *iter1;
|
||||
GSList *iter2;
|
||||
|
||||
for (iter1 = list1, iter2 = list2, ret = 0;
|
||||
ret == 0 && iter1 && iter2;
|
||||
iter1 = iter1->next, iter2 = iter2->next)
|
||||
ret = _gvalues_compare ((GValue *) iter1->data, (GValue *) iter2->data);
|
||||
}
|
||||
|
||||
g_slist_free_full (list1, _gvalue_destroy);
|
||||
g_slist_free_full (list2, _gvalue_destroy);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
iterate_map (const GValue *key_val,
|
||||
const GValue *value_val,
|
||||
gpointer user_data)
|
||||
{
|
||||
GHashTable **hash = (GHashTable **) user_data;
|
||||
|
||||
g_hash_table_insert (*hash, g_value_dup_string (key_val), _gvalue_dup (value_val));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GHashTable *hash2;
|
||||
gint ret;
|
||||
} CompareMapInfo;
|
||||
|
||||
static void
|
||||
compare_one_map_item (gpointer key, gpointer val, gpointer user_data)
|
||||
{
|
||||
CompareMapInfo *info = (CompareMapInfo *) user_data;
|
||||
GValue *value2;
|
||||
|
||||
if (info->ret)
|
||||
return;
|
||||
|
||||
value2 = (GValue *) g_hash_table_lookup (info->hash2, key);
|
||||
if (value2)
|
||||
info->ret = _gvalues_compare ((GValue *) val, value2);
|
||||
else
|
||||
info->ret = 1;
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_map (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
GHashTable *hash1 = NULL;
|
||||
GHashTable *hash2 = NULL;
|
||||
guint len1;
|
||||
guint len2;
|
||||
gint ret = 0;
|
||||
|
||||
if (dbus_g_type_get_map_key_specialization (G_VALUE_TYPE (value1)) != G_TYPE_STRING) {
|
||||
g_warning ("Can not compare maps with '%s' for keys",
|
||||
g_type_name (dbus_g_type_get_map_key_specialization (G_VALUE_TYPE (value1))));
|
||||
return 0;
|
||||
}
|
||||
|
||||
hash1 = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, _gvalue_destroy);
|
||||
dbus_g_type_map_value_iterate (value1, iterate_map, &hash1);
|
||||
len1 = g_hash_table_size (hash1);
|
||||
|
||||
hash2 = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, _gvalue_destroy);
|
||||
dbus_g_type_map_value_iterate (value2, iterate_map, &hash2);
|
||||
len2 = g_hash_table_size (hash2);
|
||||
|
||||
if (len1 != len2)
|
||||
ret = len1 < len2 ? -1 : len1 > len2;
|
||||
else {
|
||||
CompareMapInfo info;
|
||||
|
||||
info.ret = 0;
|
||||
info.hash2 = hash2;
|
||||
g_hash_table_foreach (hash1, compare_one_map_item, &info);
|
||||
ret = info.ret;
|
||||
}
|
||||
|
||||
g_hash_table_destroy (hash1);
|
||||
g_hash_table_destroy (hash2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalue_ip6_address_compare (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
GValueArray *values1, *values2;
|
||||
GValue *tmp_val;
|
||||
GByteArray *addr1, *addr2;
|
||||
guint32 prefix1, prefix2;
|
||||
GByteArray *gw1, *gw2;
|
||||
gint ret = 0;
|
||||
int i;
|
||||
|
||||
/* IP6 addresses are GValueArrays (see nm-dbus-glib-types.h) */
|
||||
values1 = g_value_get_boxed (value1);
|
||||
values2 = g_value_get_boxed (value2);
|
||||
|
||||
/* Since they are NM IPv6 address structures, we expect both
|
||||
* to contain two elements as specified in nm-dbus-glib-types.h.
|
||||
*/
|
||||
g_return_val_if_fail (values1->n_values == 3, 0);
|
||||
g_return_val_if_fail (values2->n_values == 3, 0);
|
||||
|
||||
/* First struct IPv6 address */
|
||||
tmp_val = g_value_array_get_nth (values1, 0);
|
||||
addr1 = g_value_get_boxed (tmp_val);
|
||||
/* First struct IPv6 prefix */
|
||||
tmp_val = g_value_array_get_nth (values1, 1);
|
||||
prefix1 = g_value_get_uint (tmp_val);
|
||||
/* First struct IPv6 gateway */
|
||||
tmp_val = g_value_array_get_nth (values1, 2);
|
||||
gw1 = g_value_get_boxed (tmp_val);
|
||||
|
||||
/* Second struct IPv6 address */
|
||||
tmp_val = g_value_array_get_nth (values2, 0);
|
||||
addr2 = g_value_get_boxed (tmp_val);
|
||||
/* Second struct IPv6 prefix */
|
||||
tmp_val = g_value_array_get_nth (values2, 1);
|
||||
prefix2 = g_value_get_uint (tmp_val);
|
||||
/* Second struct IPv6 gateway */
|
||||
tmp_val = g_value_array_get_nth (values2, 2);
|
||||
gw2 = g_value_get_boxed (tmp_val);
|
||||
|
||||
/* Compare IPv6 addresses */
|
||||
if (prefix1 != prefix2)
|
||||
return prefix1 < prefix2 ? -1 : prefix1 > prefix2;
|
||||
|
||||
if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *)addr1->data, (struct in6_addr *)addr2->data)) {
|
||||
for (i = 0; ret == 0 && i < addr1->len; i++)
|
||||
ret = addr1->data[i] < addr2->data[i] ? -1 : addr1->data[i] > addr2->data[i];
|
||||
}
|
||||
|
||||
if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *) gw1->data, (struct in6_addr *) gw2->data)) {
|
||||
for (i = 0; ret == 0 && i < gw1->len; i++)
|
||||
ret = gw1->data[i] < gw2->data[i] ? -1 : gw1->data[i] > gw2->data[i];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalue_ip6_route_compare (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
GValueArray *values1, *values2;
|
||||
GValue *tmp_val;
|
||||
GByteArray *dest1, *dest2;
|
||||
GByteArray *next_hop1, *next_hop2;
|
||||
guint32 prefix1, prefix2;
|
||||
guint32 metric1, metric2;
|
||||
gint ret = 0;
|
||||
int i;
|
||||
|
||||
/* IP6 routes are GValueArrays (see nm-dbus-glib-types.h) */
|
||||
values1 = g_value_get_boxed (value1);
|
||||
values2 = g_value_get_boxed (value2);
|
||||
|
||||
/* Since they are NM IPv6 route structures, we expect both
|
||||
* to contain 4 elements as specified in nm-dbus-glib-types.h.
|
||||
*/
|
||||
g_return_val_if_fail (values1->n_values == 4, 0);
|
||||
g_return_val_if_fail (values2->n_values == 4, 0);
|
||||
|
||||
/* First struct IPv6 route */
|
||||
tmp_val = g_value_array_get_nth (values1, 0);
|
||||
dest1 = g_value_get_boxed (tmp_val);
|
||||
tmp_val = g_value_array_get_nth (values1, 1);
|
||||
prefix1 = g_value_get_uint (tmp_val);
|
||||
tmp_val = g_value_array_get_nth (values1, 2);
|
||||
next_hop1 = g_value_get_boxed (tmp_val);
|
||||
tmp_val = g_value_array_get_nth (values1, 3);
|
||||
metric1 = g_value_get_uint (tmp_val);
|
||||
|
||||
/* Second struct IPv6 route */
|
||||
tmp_val = g_value_array_get_nth (values2, 0);
|
||||
dest2 = g_value_get_boxed (tmp_val);
|
||||
tmp_val = g_value_array_get_nth (values2, 1);
|
||||
prefix2 = g_value_get_uint (tmp_val);
|
||||
tmp_val = g_value_array_get_nth (values2, 2);
|
||||
next_hop2 = g_value_get_boxed (tmp_val);
|
||||
tmp_val = g_value_array_get_nth (values2, 3);
|
||||
metric2 = g_value_get_uint (tmp_val);
|
||||
|
||||
/* Compare the routes */
|
||||
if (prefix1 != prefix2)
|
||||
return prefix1 < prefix2 ? -1 : prefix1 > prefix2;
|
||||
|
||||
if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *)dest1->data, (struct in6_addr *)dest2->data)) {
|
||||
for (i = 0; ret == 0 && i < dest1->len; i++)
|
||||
ret = dest1->data[i] < dest2->data[i] ? -1 : dest1->data[i] > dest2->data[i];
|
||||
}
|
||||
|
||||
if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *)next_hop1->data, (struct in6_addr *)next_hop2->data)) {
|
||||
for (i = 0; ret == 0 && i < next_hop1->len; i++)
|
||||
ret = next_hop1->data[i] < next_hop2->data[i] ? -1 : next_hop1->data[i] > next_hop2->data[i];
|
||||
}
|
||||
|
||||
if (metric1 != metric2)
|
||||
ret = metric1 < metric2 ? -1 : metric1 > metric2;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_struct (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
/* value1 and value2 must contain the same type since
|
||||
* _gvalues_compare() enforced that already.
|
||||
*/
|
||||
|
||||
if (G_VALUE_HOLDS (value1, DBUS_TYPE_G_IP6_ADDRESS)) {
|
||||
return _gvalue_ip6_address_compare (value1, value2);
|
||||
} else if (G_VALUE_HOLDS (value1, DBUS_TYPE_G_IP6_ROUTE)) {
|
||||
return _gvalue_ip6_route_compare (value1, value2);
|
||||
} else {
|
||||
g_warning ("Don't know how to compare structures");
|
||||
return (value1 == value2);
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
_gvalues_compare (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
GType type1;
|
||||
GType type2;
|
||||
gint ret;
|
||||
|
||||
if (value1 == value2)
|
||||
return 0;
|
||||
if (!value1)
|
||||
return 1;
|
||||
if (!value2)
|
||||
return -1;
|
||||
|
||||
type1 = G_VALUE_TYPE (value1);
|
||||
type2 = G_VALUE_TYPE (value2);
|
||||
|
||||
if (type1 != type2)
|
||||
return type1 < type2 ? -1 : type1 > type2;
|
||||
|
||||
if (type_is_fixed_size (type1, NULL))
|
||||
ret = _gvalues_compare_fixed (value1, value2);
|
||||
else if (type1 == G_TYPE_STRING)
|
||||
ret = _gvalues_compare_string (value1, value2);
|
||||
else if (G_VALUE_HOLDS_BOXED (value1)) {
|
||||
gpointer p1 = g_value_get_boxed (value1);
|
||||
gpointer p2 = g_value_get_boxed (value2);
|
||||
|
||||
if (p1 == p2)
|
||||
ret = 0; /* Exactly the same values */
|
||||
else if (!p1)
|
||||
ret = 1; /* The comparision functions below don't handle NULLs */
|
||||
else if (!p2)
|
||||
ret = -1; /* The comparision functions below don't handle NULLs */
|
||||
else if (type1 == G_TYPE_STRV)
|
||||
ret = _gvalues_compare_strv (value1, value2);
|
||||
else if (dbus_g_type_is_collection (type1))
|
||||
ret = _gvalues_compare_collection (value1, value2);
|
||||
else if (dbus_g_type_is_map (type1))
|
||||
ret = _gvalues_compare_map (value1, value2);
|
||||
else if (dbus_g_type_is_struct (type1))
|
||||
ret = _gvalues_compare_struct (value1, value2);
|
||||
else if (type1 == G_TYPE_VALUE)
|
||||
ret = _gvalues_compare ((GValue *) g_value_get_boxed (value1), (GValue *) g_value_get_boxed (value2));
|
||||
else {
|
||||
g_warning ("Don't know how to compare boxed types '%s'", g_type_name (type1));
|
||||
ret = value1 == value2;
|
||||
}
|
||||
} else {
|
||||
g_warning ("Don't know how to compare types '%s'", g_type_name (type1));
|
||||
ret = value1 == value2;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
param_specialized_init (GParamSpec *pspec)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
param_specialized_set_default (GParamSpec *pspec, GValue *value)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
param_specialized_validate (GParamSpec *pspec, GValue *value)
|
||||
{
|
||||
NMParamSpecSpecialized *sspec = NM_PARAM_SPEC_SPECIALIZED (pspec);
|
||||
GType value_type = G_VALUE_TYPE (value);
|
||||
gboolean changed = FALSE;
|
||||
|
||||
if (!g_value_type_compatible (value_type, G_PARAM_SPEC_VALUE_TYPE (sspec))) {
|
||||
g_value_reset (value);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static gint
|
||||
param_specialized_values_cmp (GParamSpec *pspec,
|
||||
const GValue *value1,
|
||||
const GValue *value2)
|
||||
{
|
||||
return _gvalues_compare (value1, value2);
|
||||
}
|
||||
|
||||
GType
|
||||
_nm_param_spec_specialized_get_type (void)
|
||||
{
|
||||
static GType type;
|
||||
|
||||
if (G_UNLIKELY (type) == 0) {
|
||||
static const GParamSpecTypeInfo pspec_info = {
|
||||
sizeof (NMParamSpecSpecialized),
|
||||
0,
|
||||
param_specialized_init,
|
||||
G_TYPE_OBJECT, /* value_type */
|
||||
NULL, /* finalize */
|
||||
param_specialized_set_default,
|
||||
param_specialized_validate,
|
||||
param_specialized_values_cmp,
|
||||
};
|
||||
type = g_param_type_register_static ("NMParamSpecSpecialized", &pspec_info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GParamSpec *
|
||||
_nm_param_spec_specialized (const char *name,
|
||||
const char *nick,
|
||||
const char *blurb,
|
||||
GType specialized_type,
|
||||
GParamFlags flags)
|
||||
{
|
||||
NMParamSpecSpecialized *pspec;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (specialized_type, G_TYPE_BOXED), NULL);
|
||||
|
||||
pspec = g_param_spec_internal (NM_TYPE_PARAM_SPEC_SPECIALIZED,
|
||||
name, nick, blurb, flags);
|
||||
|
||||
G_PARAM_SPEC (pspec)->value_type = specialized_type;
|
||||
|
||||
return G_PARAM_SPEC (pspec);
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
/* Tests */
|
||||
|
||||
#if 0
|
||||
|
||||
static void
|
||||
compare_ints (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, G_TYPE_INT);
|
||||
g_value_init (&value2, G_TYPE_INT);
|
||||
|
||||
g_value_set_int (&value1, 5);
|
||||
g_value_set_int (&value2, 5);
|
||||
g_print ("Comparing ints 5 and 5: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_int (&value2, 10);
|
||||
g_print ("Comparing ints 5 and 10: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_int (&value2, 1);
|
||||
g_print ("Comparing ints 5 and 1: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_strings (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
const char *str1 = "hello";
|
||||
const char *str2 = "world";
|
||||
|
||||
g_value_init (&value1, G_TYPE_STRING);
|
||||
g_value_init (&value2, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (&value1, str1);
|
||||
g_value_set_string (&value2, str1);
|
||||
g_print ("Comparing identical strings: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_string (&value2, str2);
|
||||
g_print ("Comparing different strings: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_strv (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
char *strv1[] = { "foo", "bar", "baz", NULL };
|
||||
char *strv2[] = { "foo", "bar", "bar", NULL };
|
||||
char *strv3[] = { "foo", "bar", NULL };
|
||||
char *strv4[] = { "foo", "bar", "baz", "bam", NULL };
|
||||
|
||||
g_value_init (&value1, G_TYPE_STRV);
|
||||
g_value_init (&value2, G_TYPE_STRV);
|
||||
|
||||
g_value_set_boxed (&value1, strv1);
|
||||
g_value_set_boxed (&value2, strv1);
|
||||
g_print ("Comparing identical strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value2, strv2);
|
||||
g_print ("Comparing different strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value2, strv3);
|
||||
g_print ("Comparing different len (smaller) strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value2, strv4);
|
||||
g_print ("Comparing different len (longer) strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_garrays (void)
|
||||
{
|
||||
GArray *array1;
|
||||
GArray *array2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
int i;
|
||||
|
||||
g_value_init (&value1, DBUS_TYPE_G_UINT_ARRAY);
|
||||
array1 = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
g_value_init (&value2, DBUS_TYPE_G_UINT_ARRAY);
|
||||
array2 = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
g_array_append_val (array1, i);
|
||||
g_array_append_val (array2, i);
|
||||
}
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
|
||||
g_print ("Comparing identical arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_array_remove_index (array2, 0);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different length arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
i = 7;
|
||||
g_array_prepend_val (array2, i);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_ptrarrays (void)
|
||||
{
|
||||
GPtrArray *array1;
|
||||
GPtrArray *array2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
|
||||
array1 = g_ptr_array_new ();
|
||||
|
||||
g_value_init (&value2, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
|
||||
array2 = g_ptr_array_new ();
|
||||
|
||||
g_ptr_array_add (array1, "hello");
|
||||
g_ptr_array_add (array1, "world");
|
||||
g_value_set_boxed (&value1, array1);
|
||||
|
||||
g_ptr_array_add (array2, "hello");
|
||||
g_ptr_array_add (array2, "world");
|
||||
g_value_set_boxed (&value2, array2);
|
||||
|
||||
g_print ("Comparing identical ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_ptr_array_add (array2, "boo");
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different len ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_ptr_array_add (array1, "booz");
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_print ("Comparing different ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_str_hash (void)
|
||||
{
|
||||
GHashTable *hash1;
|
||||
GHashTable *hash2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
|
||||
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
|
||||
|
||||
hash1 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
hash2 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert (hash1, "key1", "hello");
|
||||
g_hash_table_insert (hash1, "key2", "world");
|
||||
|
||||
g_hash_table_insert (hash2, "key1", "hello");
|
||||
g_hash_table_insert (hash2, "key2", "world");
|
||||
|
||||
g_value_set_boxed (&value1, hash1);
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing identical str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_remove (hash2, "key2");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different length str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_insert (hash2, "key2", "moon");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static GValue *
|
||||
str_to_gvalue (const char *str)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, str);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
int_to_gvalue (int i)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_INT);
|
||||
g_value_set_int (value, i);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
compare_gvalue_hash (void)
|
||||
{
|
||||
GHashTable *hash1;
|
||||
GHashTable *hash2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
|
||||
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
|
||||
|
||||
hash1 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
hash2 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert (hash1, "key1", str_to_gvalue ("hello"));
|
||||
g_hash_table_insert (hash1, "key2", int_to_gvalue (5));
|
||||
|
||||
g_hash_table_insert (hash2, "key1", str_to_gvalue ("hello"));
|
||||
g_hash_table_insert (hash2, "key2", int_to_gvalue (5));
|
||||
|
||||
g_value_set_boxed (&value1, hash1);
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing identical gvalue hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_remove (hash2, "key2");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different length str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_insert (hash2, "key2", str_to_gvalue ("moon"));
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_ip6_addresses (void)
|
||||
{
|
||||
GValueArray *array1;
|
||||
GValueArray *array2;
|
||||
GValueArray *array3;
|
||||
GByteArray *ba1;
|
||||
GByteArray *ba2;
|
||||
GByteArray *ba3;
|
||||
GValue element = G_VALUE_INIT;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
struct in6_addr addr1;
|
||||
struct in6_addr addr2;
|
||||
struct in6_addr addr3;
|
||||
guint32 prefix1 = 64;
|
||||
guint32 prefix2 = 64;
|
||||
guint32 prefix3 = 0;
|
||||
|
||||
inet_pton (AF_INET6, "1:2:3:4:5:6:7:8", &addr1, sizeof (struct in6_addr));
|
||||
inet_pton (AF_INET6, "ffff:2:3:4:5:6:7:8", &addr2, sizeof (struct in6_addr));
|
||||
inet_pton (AF_INET6, "::", &addr3, sizeof (struct in6_addr));
|
||||
|
||||
/* address 1 */
|
||||
ba1 = g_byte_array_new ();
|
||||
array1 = g_value_array_new (2);
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba1, (guint8 *) addr1.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba1);
|
||||
g_value_array_append (array1, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix1);
|
||||
g_value_array_append (array1, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* address 2 */
|
||||
ba2 = g_byte_array_new ();
|
||||
array2 = g_value_array_new (2);
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba2, (guint8 *) addr2.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba2);
|
||||
g_value_array_append (array2, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix2);
|
||||
g_value_array_append (array2, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* address 3 */
|
||||
ba3 = g_byte_array_new ();
|
||||
array3 = g_value_array_new (2);
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba3, (guint8 *) addr3.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba3);
|
||||
g_value_array_append (array3, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix3);
|
||||
g_value_array_append (array3, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&value1, DBUS_TYPE_G_IP6_ADDRESS);
|
||||
g_value_init (&value2, DBUS_TYPE_G_IP6_ADDRESS);
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array1);
|
||||
g_print ("Comparing identical IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array3);
|
||||
g_print ("Comparing different IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
DBusGConnection *bus;
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
||||
g_type_init ();
|
||||
#endif
|
||||
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
||||
|
||||
compare_ints ();
|
||||
compare_strings ();
|
||||
compare_strv ();
|
||||
compare_garrays ();
|
||||
compare_ptrarrays ();
|
||||
compare_str_hash ();
|
||||
compare_gvalue_hash ();
|
||||
compare_ip6_addresses ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
43
libnm-core/nm-param-spec-specialized.h
Normal file
43
libnm-core/nm-param-spec-specialized.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* -*- 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 2007 - 2008 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_PARAM_SPEC_SPECIALIZED_H
|
||||
#define NM_PARAM_SPEC_SPECIALIZED_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
typedef struct _NMParamSpecSpecialized NMParamSpecSpecialized;
|
||||
|
||||
#define NM_TYPE_PARAM_SPEC_SPECIALIZED (_nm_param_spec_specialized_get_type ())
|
||||
|
||||
#define NM_IS_PARAM_SPEC_SPECIALIZED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), NM_TYPE_PARAM_SPEC_SPECIALIZED))
|
||||
#define NM_PARAM_SPEC_SPECIALIZED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), NM_TYPE_PARAM_SPEC_SPECIALIZED, NMParamSpecSpecialized))
|
||||
|
||||
GType _nm_param_spec_specialized_get_type (void);
|
||||
|
||||
GParamSpec *_nm_param_spec_specialized (const char *name,
|
||||
const char *nick,
|
||||
const char *blurb,
|
||||
GType specialized_type,
|
||||
GParamFlags flags);
|
||||
|
||||
#endif /* NM_PARAM_SPEC_SPECIALIZED_H */
|
||||
3699
libnm-core/nm-setting-8021x.c
Normal file
3699
libnm-core/nm-setting-8021x.c
Normal file
File diff suppressed because it is too large
Load diff
295
libnm-core/nm-setting-8021x.h
Normal file
295
libnm-core/nm-setting-8021x.h
Normal file
|
|
@ -0,0 +1,295 @@
|
|||
/* -*- 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 2007 - 2014 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_SETTING_8021X_H
|
||||
#define NM_SETTING_8021X_H
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <nm-setting.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* NMSetting8021xCKFormat:
|
||||
* @NM_SETTING_802_1X_CK_FORMAT_UNKNOWN: unknown file format
|
||||
* @NM_SETTING_802_1X_CK_FORMAT_X509: file contains an X.509 format certificate
|
||||
* @NM_SETTING_802_1X_CK_FORMAT_RAW_KEY: file contains an old-style OpenSSL PEM
|
||||
* or DER private key
|
||||
* @NM_SETTING_802_1X_CK_FORMAT_PKCS12: file contains a PKCS#12 certificate
|
||||
* and private key
|
||||
*
|
||||
* #NMSetting8021xCKFormat values indicate the general type of a certificate
|
||||
* or private key
|
||||
*/
|
||||
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,
|
||||
NM_SETTING_802_1X_CK_FORMAT_PKCS12
|
||||
} NMSetting8021xCKFormat;
|
||||
|
||||
/**
|
||||
* NMSetting8021xCKScheme:
|
||||
* @NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: unknown certificate or private key
|
||||
* scheme
|
||||
* @NM_SETTING_802_1X_CK_SCHEME_BLOB: certificate or key is stored as the raw
|
||||
* item data
|
||||
* @NM_SETTING_802_1X_CK_SCHEME_PATH: certificate or key is stored as a path
|
||||
* to a file containing the certificate or key data
|
||||
*
|
||||
* #NMSetting8021xCKScheme values indicate how a certificate or private key is
|
||||
* 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 { /*< 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
|
||||
} NMSetting8021xCKScheme;
|
||||
|
||||
|
||||
#define NM_TYPE_SETTING_802_1X (nm_setting_802_1x_get_type ())
|
||||
#define NM_SETTING_802_1X(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_802_1X, NMSetting8021x))
|
||||
#define NM_SETTING_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_802_1X, NMSetting8021xClass))
|
||||
#define NM_IS_SETTING_802_1X(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_802_1X))
|
||||
#define NM_IS_SETTING_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_802_1X))
|
||||
#define NM_SETTING_802_1X_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_802_1X, NMSetting8021xClass))
|
||||
|
||||
#define NM_SETTING_802_1X_SETTING_NAME "802-1x"
|
||||
|
||||
/**
|
||||
* NMSetting8021xError:
|
||||
* @NM_SETTING_802_1X_ERROR_UNKNOWN: unknown or unclassified error
|
||||
* @NM_SETTING_802_1X_ERROR_INVALID_PROPERTY: the property was invalid
|
||||
* @NM_SETTING_802_1X_ERROR_MISSING_PROPERTY: the property was missing and is
|
||||
* required
|
||||
*/
|
||||
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_SETTING_802_1X_ERROR nm_setting_802_1x_error_quark ()
|
||||
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"
|
||||
#define NM_SETTING_802_1X_ALTSUBJECT_MATCHES "altsubject-matches"
|
||||
#define NM_SETTING_802_1X_CLIENT_CERT "client-cert"
|
||||
#define NM_SETTING_802_1X_PHASE1_PEAPVER "phase1-peapver"
|
||||
#define NM_SETTING_802_1X_PHASE1_PEAPLABEL "phase1-peaplabel"
|
||||
#define NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING "phase1-fast-provisioning"
|
||||
#define NM_SETTING_802_1X_PHASE2_AUTH "phase2-auth"
|
||||
#define NM_SETTING_802_1X_PHASE2_AUTHEAP "phase2-autheap"
|
||||
#define NM_SETTING_802_1X_PHASE2_CA_CERT "phase2-ca-cert"
|
||||
#define NM_SETTING_802_1X_PHASE2_CA_PATH "phase2-ca-path"
|
||||
#define NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH "phase2-subject-match"
|
||||
#define NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES "phase2-altsubject-matches"
|
||||
#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"
|
||||
#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY "phase2-private-key"
|
||||
#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD "phase2-private-key-password"
|
||||
#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS "phase2-private-key-password-flags"
|
||||
#define NM_SETTING_802_1X_PIN "pin"
|
||||
#define NM_SETTING_802_1X_PIN_FLAGS "pin-flags"
|
||||
#define NM_SETTING_802_1X_SYSTEM_CA_CERTS "system-ca-certs"
|
||||
|
||||
/* PRIVATE KEY NOTE: when setting PKCS#12 private keys directly via properties
|
||||
* using the "blob" scheme, the data must be passed in PKCS#12 binary format.
|
||||
* In this case, the appropriate "client-cert" (or "phase2-client-cert")
|
||||
* property of the NMSetting8021x object must also contain the exact same
|
||||
* PKCS#12 binary data that the private key does. This is because the
|
||||
* PKCS#12 file contains both the private key and client certificate, so both
|
||||
* properties need to be set to the same thing. When using the "path" scheme,
|
||||
* just set both the private-key and client-cert properties to the same path.
|
||||
*
|
||||
* When setting OpenSSL-derived "traditional" format (ie S/MIME style, not
|
||||
* PKCS#8) RSA and DSA keys directly via properties with the "blob" scheme, they
|
||||
* should be passed to NetworkManager in PEM format with the "DEK-Info" and
|
||||
* "Proc-Type" tags intact. Decrypted private keys should not be used as this
|
||||
* is insecure and could allow unprivileged users to access the decrypted
|
||||
* private key data.
|
||||
*
|
||||
* When using the "path" scheme, just set the private-key and client-cert
|
||||
* properties to the paths to their respective objects.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
} NMSetting8021x;
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[4];
|
||||
} NMSetting8021xClass;
|
||||
|
||||
GType nm_setting_802_1x_get_type (void);
|
||||
|
||||
NMSetting *nm_setting_802_1x_new (void);
|
||||
|
||||
guint32 nm_setting_802_1x_get_num_eap_methods (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_eap_method (NMSetting8021x *setting, guint32 i);
|
||||
gboolean nm_setting_802_1x_add_eap_method (NMSetting8021x *setting, const char *eap);
|
||||
void nm_setting_802_1x_remove_eap_method (NMSetting8021x *setting, guint32 i);
|
||||
gboolean nm_setting_802_1x_remove_eap_method_by_value (NMSetting8021x *setting, const char *eap);
|
||||
void nm_setting_802_1x_clear_eap_methods (NMSetting8021x *setting);
|
||||
|
||||
const char * nm_setting_802_1x_get_identity (NMSetting8021x *setting);
|
||||
|
||||
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);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
NMSetting8021xCKScheme scheme,
|
||||
NMSetting8021xCKFormat *out_format,
|
||||
GError **error);
|
||||
|
||||
const char * nm_setting_802_1x_get_subject_match (NMSetting8021x *setting);
|
||||
|
||||
guint32 nm_setting_802_1x_get_num_altsubject_matches (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_altsubject_match (NMSetting8021x *setting,
|
||||
guint32 i);
|
||||
gboolean nm_setting_802_1x_add_altsubject_match (NMSetting8021x *setting,
|
||||
const char *altsubject_match);
|
||||
void nm_setting_802_1x_remove_altsubject_match (NMSetting8021x *setting,
|
||||
guint32 i);
|
||||
gboolean nm_setting_802_1x_remove_altsubject_match_by_value (NMSetting8021x *setting,
|
||||
const char *altsubject_match);
|
||||
void nm_setting_802_1x_clear_altsubject_matches (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
NMSetting8021xCKScheme scheme,
|
||||
NMSetting8021xCKFormat *out_format,
|
||||
GError **error);
|
||||
|
||||
const char * nm_setting_802_1x_get_phase1_peapver (NMSetting8021x *setting);
|
||||
|
||||
const char * nm_setting_802_1x_get_phase1_peaplabel (NMSetting8021x *setting);
|
||||
|
||||
const char * nm_setting_802_1x_get_phase1_fast_provisioning (NMSetting8021x *setting);
|
||||
|
||||
const char * nm_setting_802_1x_get_phase2_auth (NMSetting8021x *setting);
|
||||
|
||||
const char * nm_setting_802_1x_get_phase2_autheap (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
NMSetting8021xCKScheme scheme,
|
||||
NMSetting8021xCKFormat *out_format,
|
||||
GError **error);
|
||||
|
||||
const char * nm_setting_802_1x_get_phase2_subject_match (NMSetting8021x *setting);
|
||||
|
||||
guint32 nm_setting_802_1x_get_num_phase2_altsubject_matches (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_phase2_altsubject_match (NMSetting8021x *setting,
|
||||
guint32 i);
|
||||
gboolean nm_setting_802_1x_add_phase2_altsubject_match (NMSetting8021x *setting,
|
||||
const char *phase2_altsubject_match);
|
||||
void nm_setting_802_1x_remove_phase2_altsubject_match (NMSetting8021x *setting,
|
||||
guint32 i);
|
||||
gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value (NMSetting8021x *setting,
|
||||
const char *phase2_altsubject_match);
|
||||
void nm_setting_802_1x_clear_phase2_altsubject_matches (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
NMSetting8021xCKScheme scheme,
|
||||
NMSetting8021xCKFormat *out_format,
|
||||
GError **error);
|
||||
|
||||
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);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
||||
const char *key_path,
|
||||
const char *password,
|
||||
NMSetting8021xCKScheme scheme,
|
||||
NMSetting8021xCKFormat *out_format,
|
||||
GError **error);
|
||||
const char * nm_setting_802_1x_get_private_key_password (NMSetting8021x *setting);
|
||||
NMSettingSecretFlags nm_setting_802_1x_get_private_key_password_flags (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKFormat nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
||||
const char *key_path,
|
||||
const char *password,
|
||||
NMSetting8021xCKScheme scheme,
|
||||
NMSetting8021xCKFormat *out_format,
|
||||
GError **error);
|
||||
const char * nm_setting_802_1x_get_phase2_private_key_password (NMSetting8021x *setting);
|
||||
NMSettingSecretFlags nm_setting_802_1x_get_phase2_private_key_password_flags (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKFormat nm_setting_802_1x_get_phase2_private_key_format (NMSetting8021x *setting);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_8021X_H */
|
||||
464
libnm-core/nm-setting-adsl.c
Normal file
464
libnm-core/nm-setting-adsl.c
Normal file
|
|
@ -0,0 +1,464 @@
|
|||
/* -*- 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 - 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-adsl.h"
|
||||
#include "nm-setting-ppp.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-adsl
|
||||
* @short_description: Describes ADSL-based properties
|
||||
*
|
||||
* The #NMSettingAdsl object is a #NMSetting subclass that describes
|
||||
* properties of ADSL connections.
|
||||
*/
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_error_quark:
|
||||
*
|
||||
* Registers an error quark for #NMSettingAdsl if necessary.
|
||||
*
|
||||
* Returns: the error quark used for #NMSettingAdsl errors.
|
||||
**/
|
||||
GQuark
|
||||
nm_setting_adsl_error_quark (void)
|
||||
{
|
||||
static GQuark quark;
|
||||
|
||||
if (G_UNLIKELY (!quark))
|
||||
quark = g_quark_from_static_string ("nm-setting-adsl-error-quark");
|
||||
return quark;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING,
|
||||
_nm_register_setting (NM_SETTING_ADSL_SETTING_NAME,
|
||||
g_define_type_id,
|
||||
1,
|
||||
NM_SETTING_ADSL_ERROR))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_ADSL)
|
||||
|
||||
#define NM_SETTING_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_ADSL, NMSettingAdslPrivate))
|
||||
|
||||
typedef struct {
|
||||
char * username;
|
||||
char * password;
|
||||
NMSettingSecretFlags password_flags;
|
||||
char * protocol;
|
||||
char * encapsulation;
|
||||
guint32 vpi;
|
||||
guint32 vci;
|
||||
} NMSettingAdslPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_USERNAME,
|
||||
PROP_PASSWORD,
|
||||
PROP_PASSWORD_FLAGS,
|
||||
PROP_PROTOCOL,
|
||||
PROP_ENCAPSULATION,
|
||||
PROP_VPI,
|
||||
PROP_VCI,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_new:
|
||||
*
|
||||
* Creates a new #NMSettingAdsl object with default values.
|
||||
*
|
||||
* Returns: the new empty #NMSettingAdsl object
|
||||
**/
|
||||
NMSetting *
|
||||
nm_setting_adsl_new (void)
|
||||
{
|
||||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_ADSL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_username:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingAdsl:username property of the setting
|
||||
**/
|
||||
const char *
|
||||
nm_setting_adsl_get_username (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_password:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingAdsl:password property of the setting
|
||||
**/
|
||||
const char *
|
||||
nm_setting_adsl_get_password (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_password_flags:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingSecretFlags pertaining to the #NMSettingAdsl:password
|
||||
**/
|
||||
NMSettingSecretFlags
|
||||
nm_setting_adsl_get_password_flags (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NM_SETTING_SECRET_FLAG_NONE);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->password_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_protocol:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingAdsl:protocol property of the setting
|
||||
**/
|
||||
const char *
|
||||
nm_setting_adsl_get_protocol (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_encapsulation:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingAdsl:encapsulation property of the setting
|
||||
**/
|
||||
const char *
|
||||
nm_setting_adsl_get_encapsulation (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->encapsulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_vpi:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingAdsl:vpi property of the setting
|
||||
**/
|
||||
guint32
|
||||
nm_setting_adsl_get_vpi (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), 0);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->vpi;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_vci:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingAdsl:vci property of the setting
|
||||
**/
|
||||
guint32
|
||||
nm_setting_adsl_get_vci (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), 0);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->vci;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting);
|
||||
|
||||
if (!priv->username) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_ADSL_ERROR,
|
||||
NM_SETTING_ADSL_ERROR_MISSING_PROPERTY,
|
||||
_("property is missing"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_USERNAME);
|
||||
return FALSE;
|
||||
} else if (!strlen (priv->username)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_ADSL_ERROR,
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
|
||||
_("property is empty"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_USERNAME);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->password && !strlen (priv->password)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_ADSL_ERROR,
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
|
||||
_("property is empty"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PASSWORD);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) &&
|
||||
strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) &&
|
||||
strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_ADSL_ERROR,
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is not a valid value for the property"),
|
||||
priv->protocol);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PROTOCOL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (strcmp (priv->encapsulation, NM_SETTING_ADSL_ENCAPSULATION_VCMUX) &&
|
||||
strcmp (priv->encapsulation, NM_SETTING_ADSL_ENCAPSULATION_LLC) ) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_ADSL_ERROR,
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is not a valid value for the property"),
|
||||
priv->encapsulation);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_ENCAPSULATION);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GPtrArray *
|
||||
need_secrets (NMSetting *setting)
|
||||
{
|
||||
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting);
|
||||
GPtrArray *secrets = NULL;
|
||||
|
||||
if (priv->password)
|
||||
return NULL;
|
||||
|
||||
if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) {
|
||||
secrets = g_ptr_array_sized_new (1);
|
||||
g_ptr_array_add (secrets, NM_SETTING_ADSL_PASSWORD);
|
||||
}
|
||||
|
||||
return secrets;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_adsl_init (NMSettingAdsl *setting)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->username);
|
||||
g_free (priv->password);
|
||||
g_free (priv->protocol);
|
||||
g_free (priv->encapsulation);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_adsl_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_USERNAME:
|
||||
g_free (priv->username);
|
||||
priv->username = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_free (priv->password);
|
||||
priv->password = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_PASSWORD_FLAGS:
|
||||
priv->password_flags = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_PROTOCOL:
|
||||
g_free (priv->protocol);
|
||||
priv->protocol = g_ascii_strdown (g_value_get_string (value), -1);
|
||||
break;
|
||||
case PROP_ENCAPSULATION:
|
||||
g_free (priv->encapsulation);
|
||||
priv->encapsulation = g_ascii_strdown (g_value_get_string (value), -1);
|
||||
break;
|
||||
case PROP_VPI:
|
||||
priv->vpi = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_VCI:
|
||||
priv->vci = g_value_get_uint (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)
|
||||
{
|
||||
NMSettingAdsl *setting = NM_SETTING_ADSL (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_USERNAME:
|
||||
g_value_set_string (value, nm_setting_adsl_get_username (setting));
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_value_set_string (value, nm_setting_adsl_get_password (setting));
|
||||
break;
|
||||
case PROP_PASSWORD_FLAGS:
|
||||
g_value_set_uint (value, nm_setting_adsl_get_password_flags (setting));
|
||||
break;
|
||||
case PROP_PROTOCOL:
|
||||
g_value_set_string (value, nm_setting_adsl_get_protocol (setting));
|
||||
break;
|
||||
case PROP_ENCAPSULATION:
|
||||
g_value_set_string (value, nm_setting_adsl_get_encapsulation (setting));
|
||||
break;
|
||||
case PROP_VPI:
|
||||
g_value_set_uint (value, nm_setting_adsl_get_vpi (setting));
|
||||
break;
|
||||
case PROP_VCI:
|
||||
g_value_set_uint (value, nm_setting_adsl_get_vci (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_adsl_class_init (NMSettingAdslClass *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 (NMSettingAdslPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
parent_class->verify = verify;
|
||||
parent_class->need_secrets = need_secrets;
|
||||
|
||||
/* Properties */
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:username:
|
||||
*
|
||||
* Username used to authenticate with the ADSL service.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_USERNAME,
|
||||
g_param_spec_string (NM_SETTING_ADSL_USERNAME, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:password:
|
||||
*
|
||||
* Password used to authenticate with the ADSL service.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PASSWORD,
|
||||
g_param_spec_string (NM_SETTING_ADSL_PASSWORD, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_SECRET |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:password-flags:
|
||||
*
|
||||
* Flags indicating how to handle the #NMSettingAdsl:password property.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PASSWORD_FLAGS,
|
||||
g_param_spec_uint (NM_SETTING_ADSL_PASSWORD_FLAGS, "", "",
|
||||
NM_SETTING_SECRET_FLAG_NONE,
|
||||
NM_SETTING_SECRET_FLAGS_ALL,
|
||||
NM_SETTING_SECRET_FLAG_NONE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:protocol:
|
||||
*
|
||||
* ADSL connection protocol. Can be "pppoa", "pppoe" or "ipoatm".
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PROTOCOL,
|
||||
g_param_spec_string (NM_SETTING_ADSL_PROTOCOL, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:encapsulation:
|
||||
*
|
||||
* Encapsulation of ADSL connection. Can be "vcmux" or "llc".
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ENCAPSULATION,
|
||||
g_param_spec_string (NM_SETTING_ADSL_ENCAPSULATION, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:vpi:
|
||||
*
|
||||
* VPI of ADSL connection
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_VPI,
|
||||
g_param_spec_uint (NM_SETTING_ADSL_VPI, "", "",
|
||||
0, 65536, 0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:vci:
|
||||
*
|
||||
* VCI of ADSL connection
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_VCI,
|
||||
g_param_spec_uint (NM_SETTING_ADSL_VCI, "", "",
|
||||
0, 65536, 0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
97
libnm-core/nm-setting-adsl.h
Normal file
97
libnm-core/nm-setting-adsl.h
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/* -*- 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 2007 - 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_SETTING_ADSL_H
|
||||
#define NM_SETTING_ADSL_H
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <nm-setting.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_SETTING_ADSL (nm_setting_adsl_get_type ())
|
||||
#define NM_SETTING_ADSL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_ADSL, NMSettingAdsl))
|
||||
#define NM_SETTING_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_ADSL, NMSettingAdslClass))
|
||||
#define NM_IS_SETTING_ADSL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_ADSL))
|
||||
#define NM_IS_SETTING_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_ADSL))
|
||||
#define NM_SETTING_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_ADSL, NMSettingAdslClass))
|
||||
|
||||
#define NM_SETTING_ADSL_SETTING_NAME "adsl"
|
||||
|
||||
/**
|
||||
* NMSettingAdslError:
|
||||
* @NM_SETTING_ADSL_ERROR_UNKNOWN: unknown or unclassified error
|
||||
* @NM_SETTING_ADSL_ERROR_INVALID_PROPERTY: the property was invalid
|
||||
* @NM_SETTING_ADSL_ERROR_MISSING_PROPERTY: the property was missing and is
|
||||
* required
|
||||
*/
|
||||
typedef enum {
|
||||
NM_SETTING_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
|
||||
NM_SETTING_ADSL_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
|
||||
} NMSettingAdslError;
|
||||
|
||||
#define NM_SETTING_ADSL_ERROR nm_setting_adsl_error_quark ()
|
||||
GQuark nm_setting_adsl_error_quark (void);
|
||||
|
||||
#define NM_SETTING_ADSL_USERNAME "username"
|
||||
#define NM_SETTING_ADSL_PASSWORD "password"
|
||||
#define NM_SETTING_ADSL_PASSWORD_FLAGS "password-flags"
|
||||
#define NM_SETTING_ADSL_PROTOCOL "protocol"
|
||||
#define NM_SETTING_ADSL_ENCAPSULATION "encapsulation"
|
||||
#define NM_SETTING_ADSL_VPI "vpi"
|
||||
#define NM_SETTING_ADSL_VCI "vci"
|
||||
|
||||
#define NM_SETTING_ADSL_PROTOCOL_PPPOA "pppoa"
|
||||
#define NM_SETTING_ADSL_PROTOCOL_PPPOE "pppoe"
|
||||
#define NM_SETTING_ADSL_PROTOCOL_IPOATM "ipoatm"
|
||||
|
||||
#define NM_SETTING_ADSL_ENCAPSULATION_VCMUX "vcmux"
|
||||
#define NM_SETTING_ADSL_ENCAPSULATION_LLC "llc"
|
||||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
} NMSettingAdsl;
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[4];
|
||||
} NMSettingAdslClass;
|
||||
|
||||
GType nm_setting_adsl_get_type (void);
|
||||
|
||||
NMSetting *nm_setting_adsl_new (void);
|
||||
const char *nm_setting_adsl_get_username (NMSettingAdsl *setting);
|
||||
const char *nm_setting_adsl_get_password (NMSettingAdsl *setting);
|
||||
const char *nm_setting_adsl_get_protocol (NMSettingAdsl *setting);
|
||||
const char *nm_setting_adsl_get_encapsulation (NMSettingAdsl *setting);
|
||||
guint32 nm_setting_adsl_get_vpi (NMSettingAdsl *setting);
|
||||
guint32 nm_setting_adsl_get_vci (NMSettingAdsl *setting);
|
||||
NMSettingSecretFlags nm_setting_adsl_get_password_flags (NMSettingAdsl *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_ADSL_H */
|
||||
296
libnm-core/nm-setting-bluetooth.c
Normal file
296
libnm-core/nm-setting-bluetooth.c
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
/* -*- 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 2007 - 2013 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-setting-bluetooth.h"
|
||||
#include "nm-setting-cdma.h"
|
||||
#include "nm-setting-gsm.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-bluetooth
|
||||
* @short_description: Describes Bluetooth connection properties
|
||||
*
|
||||
* The #NMSettingBluetooth object is a #NMSetting subclass that describes
|
||||
* properties necessary for connection to devices that provide network
|
||||
* connections via the Bluetooth Dial-Up Networking (DUN) and Network Access
|
||||
* Point (NAP) profiles.
|
||||
**/
|
||||
|
||||
/**
|
||||
* nm_setting_bluetooth_error_quark:
|
||||
*
|
||||
* Registers an error quark for #NMSettingBluetooth if necessary.
|
||||
*
|
||||
* Returns: the error quark used for #NMSettingBluetooth errors.
|
||||
**/
|
||||
GQuark
|
||||
nm_setting_bluetooth_error_quark (void)
|
||||
{
|
||||
static GQuark quark;
|
||||
|
||||
if (G_UNLIKELY (!quark))
|
||||
quark = g_quark_from_static_string ("nm-setting-bluetooth-error-quark");
|
||||
return quark;
|
||||
}
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING,
|
||||
_nm_register_setting (NM_SETTING_BLUETOOTH_SETTING_NAME,
|
||||
g_define_type_id,
|
||||
1,
|
||||
NM_SETTING_BLUETOOTH_ERROR))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BLUETOOTH)
|
||||
|
||||
#define NM_SETTING_BLUETOOTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothPrivate))
|
||||
|
||||
typedef struct {
|
||||
GByteArray *bdaddr;
|
||||
char *type;
|
||||
} NMSettingBluetoothPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_BDADDR,
|
||||
PROP_TYPE,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
/**
|
||||
* nm_setting_bluetooth_new:
|
||||
*
|
||||
* Creates a new #NMSettingBluetooth object with default values.
|
||||
*
|
||||
* Returns: (transfer full): the new empty #NMSettingBluetooth object
|
||||
**/
|
||||
NMSetting *nm_setting_bluetooth_new (void)
|
||||
{
|
||||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_BLUETOOTH, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bluetooth_get_connection_type:
|
||||
* @setting: the #NMSettingBluetooth
|
||||
*
|
||||
* Returns the connection method for communicating with the remote device (i.e.
|
||||
* either DUN to a DUN-capable device or PANU to a NAP-capable device).
|
||||
*
|
||||
* Returns: the type, either %NM_SETTING_BLUETOOTH_PANU or %NM_SETTING_BLUETOOTH_DUN
|
||||
**/
|
||||
const char *
|
||||
nm_setting_bluetooth_get_connection_type (NMSettingBluetooth *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (setting), NULL);
|
||||
|
||||
return NM_SETTING_BLUETOOTH_GET_PRIVATE (setting)->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bluetooth_get_bdaddr:
|
||||
* @setting: the #NMSettingBluetooth
|
||||
*
|
||||
* Gets the Bluetooth address of the remote device which this setting
|
||||
* describes a connection to.
|
||||
*
|
||||
* Returns: the Bluetooth address
|
||||
**/
|
||||
const GByteArray *
|
||||
nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (setting), NULL);
|
||||
|
||||
return NM_SETTING_BLUETOOTH_GET_PRIVATE (setting)->bdaddr;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (setting);
|
||||
|
||||
if (!priv->bdaddr) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_BLUETOOTH_ERROR,
|
||||
NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
|
||||
_("property is missing"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->bdaddr && priv->bdaddr->len != ETH_ALEN) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_BLUETOOTH_ERROR,
|
||||
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
|
||||
_("property is invalid"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!priv->type) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_BLUETOOTH_ERROR,
|
||||
NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
|
||||
_("property is missing"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE);
|
||||
return FALSE;
|
||||
} else if (!g_str_equal (priv->type, NM_SETTING_BLUETOOTH_TYPE_DUN) &&
|
||||
!g_str_equal (priv->type, NM_SETTING_BLUETOOTH_TYPE_PANU)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BLUETOOTH_ERROR,
|
||||
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is not a valid value for the property"),
|
||||
priv->type);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Make sure the corresponding 'type' setting is present */
|
||||
if ( all_settings
|
||||
&& !strcmp (priv->type, NM_SETTING_BLUETOOTH_TYPE_DUN)) {
|
||||
gboolean gsm = FALSE, cdma = FALSE;
|
||||
|
||||
gsm = !!nm_setting_find_in_list (all_settings, NM_SETTING_GSM_SETTING_NAME);
|
||||
cdma = !!nm_setting_find_in_list (all_settings, NM_SETTING_CDMA_SETTING_NAME);
|
||||
|
||||
if (!gsm && !cdma) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BLUETOOTH_ERROR,
|
||||
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND,
|
||||
_("requires '%s' or '%s' setting"),
|
||||
NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* PANU doesn't need a 'type' setting since no further configuration
|
||||
* is required at the interface level.
|
||||
*/
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_bluetooth_init (NMSettingBluetooth *setting)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);
|
||||
|
||||
if (priv->bdaddr)
|
||||
g_byte_array_free (priv->bdaddr, TRUE);
|
||||
g_free (priv->type);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_bluetooth_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_BDADDR:
|
||||
if (priv->bdaddr)
|
||||
g_byte_array_free (priv->bdaddr, TRUE);
|
||||
priv->bdaddr = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_TYPE:
|
||||
g_free (priv->type);
|
||||
priv->type = 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)
|
||||
{
|
||||
NMSettingBluetooth *setting = NM_SETTING_BLUETOOTH (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_BDADDR:
|
||||
g_value_set_boxed (value, nm_setting_bluetooth_get_bdaddr (setting));
|
||||
break;
|
||||
case PROP_TYPE:
|
||||
g_value_set_string (value, nm_setting_bluetooth_get_connection_type (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_bluetooth_class_init (NMSettingBluetoothClass *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 (NMSettingBluetoothPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
parent_class->verify = verify;
|
||||
|
||||
/* Properties */
|
||||
|
||||
/**
|
||||
* NMSettingBluetooth:bdaddr:
|
||||
*
|
||||
* The Bluetooth address of the device.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BDADDR,
|
||||
_nm_param_spec_specialized (NM_SETTING_BLUETOOTH_BDADDR, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBluetooth:type:
|
||||
*
|
||||
* Either "dun" for Dial-Up Networking connections or "panu" for Personal
|
||||
* Area Networking connections to devices supporting the NAP profile.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TYPE,
|
||||
g_param_spec_string (NM_SETTING_BLUETOOTH_TYPE, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
101
libnm-core/nm-setting-bluetooth.h
Normal file
101
libnm-core/nm-setting-bluetooth.h
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/* -*- 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 2007 - 2009 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_SETTING_BLUETOOTH_H
|
||||
#define NM_SETTING_BLUETOOTH_H
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "nm-setting.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_SETTING_BLUETOOTH (nm_setting_bluetooth_get_type ())
|
||||
#define NM_SETTING_BLUETOOTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetooth))
|
||||
#define NM_SETTING_BLUETOOTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothClass))
|
||||
#define NM_IS_SETTING_BLUETOOTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BLUETOOTH))
|
||||
#define NM_IS_SETTING_BLUETOOTH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_BLUETOOTH))
|
||||
#define NM_SETTING_BLUETOOTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothClass))
|
||||
|
||||
#define NM_SETTING_BLUETOOTH_SETTING_NAME "bluetooth"
|
||||
|
||||
/**
|
||||
* NMSettingBluetoothError:
|
||||
* @NM_SETTING_BLUETOOTH_ERROR_UNKNOWN: unknown or unclassified error
|
||||
* @NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY: the property was invalid
|
||||
* @NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY: the property was missing and is
|
||||
* required
|
||||
* @NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND: the connection
|
||||
* did not contain a required type setting, ie for DUN connections the connection
|
||||
* must also contain an #NMSettingGsm or #NMSettingCdma as appropriate
|
||||
*/
|
||||
typedef enum {
|
||||
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_SETTING_BLUETOOTH_ERROR nm_setting_bluetooth_error_quark ()
|
||||
GQuark nm_setting_bluetooth_error_quark (void);
|
||||
|
||||
#define NM_SETTING_BLUETOOTH_BDADDR "bdaddr"
|
||||
#define NM_SETTING_BLUETOOTH_TYPE "type"
|
||||
|
||||
/**
|
||||
* NM_SETTING_BLUETOOTH_TYPE_DUN:
|
||||
*
|
||||
* Connection type describing a connection to devices that support the Bluetooth
|
||||
* DUN profile.
|
||||
*/
|
||||
#define NM_SETTING_BLUETOOTH_TYPE_DUN "dun"
|
||||
|
||||
/**
|
||||
* NM_SETTING_BLUETOOTH_TYPE_PANU:
|
||||
*
|
||||
* Connection type describing a connection to devices that support the Bluetooth
|
||||
* NAP (Network Access Point) protocol, which accepts connections via PANU.
|
||||
*/
|
||||
#define NM_SETTING_BLUETOOTH_TYPE_PANU "panu"
|
||||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
} NMSettingBluetooth;
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[4];
|
||||
} NMSettingBluetoothClass;
|
||||
|
||||
GType nm_setting_bluetooth_get_type (void);
|
||||
|
||||
NMSetting * nm_setting_bluetooth_new (void);
|
||||
const GByteArray *nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting);
|
||||
const char * nm_setting_bluetooth_get_connection_type (NMSettingBluetooth *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_BLUETOOTH_H */
|
||||
801
libnm-core/nm-setting-bond.c
Normal file
801
libnm-core/nm-setting-bond.c
Normal file
|
|
@ -0,0 +1,801 @@
|
|||
/* -*- 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 - 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <glib/gi18n.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"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-bond
|
||||
* @short_description: Describes connection properties for bonds
|
||||
*
|
||||
* 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_WITH_CODE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING,
|
||||
_nm_register_setting (NM_SETTING_BOND_SETTING_NAME,
|
||||
g_define_type_id,
|
||||
1,
|
||||
NM_SETTING_BOND_ERROR))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BOND)
|
||||
|
||||
#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
|
||||
};
|
||||
|
||||
enum {
|
||||
TYPE_INT,
|
||||
TYPE_STR,
|
||||
TYPE_BOTH,
|
||||
TYPE_IP,
|
||||
TYPE_IFNAME,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char *opt;
|
||||
const char *val;
|
||||
guint opt_type;
|
||||
guint min;
|
||||
guint max;
|
||||
char *list[10];
|
||||
} BondDefault;
|
||||
|
||||
static const BondDefault defaults[] = {
|
||||
{ NM_SETTING_BOND_OPTION_MODE, "balance-rr", TYPE_BOTH, 0, 6,
|
||||
{ "balance-rr", "active-backup", "balance-xor", "broadcast", "802.3ad", "balance-tlb", "balance-alb", NULL } },
|
||||
{ NM_SETTING_BOND_OPTION_MIIMON, "100", TYPE_INT, 0, G_MAXINT },
|
||||
{ NM_SETTING_BOND_OPTION_DOWNDELAY, "0", TYPE_INT, 0, G_MAXINT },
|
||||
{ NM_SETTING_BOND_OPTION_UPDELAY, "0", TYPE_INT, 0, G_MAXINT },
|
||||
{ NM_SETTING_BOND_OPTION_ARP_INTERVAL, "0", TYPE_INT, 0, G_MAXINT },
|
||||
{ NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "", TYPE_IP },
|
||||
{ NM_SETTING_BOND_OPTION_ARP_VALIDATE, "0", TYPE_BOTH, 0, 3,
|
||||
{ "none", "active", "backup", "all", NULL } },
|
||||
{ NM_SETTING_BOND_OPTION_PRIMARY, "", TYPE_IFNAME },
|
||||
{ NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, "0", TYPE_BOTH, 0, 2,
|
||||
{ "always", "better", "failure", NULL } },
|
||||
{ NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, "0", TYPE_BOTH, 0, 2,
|
||||
{ "none", "active", "follow", NULL } },
|
||||
{ NM_SETTING_BOND_OPTION_USE_CARRIER, "1", TYPE_INT, 0, 1 },
|
||||
{ NM_SETTING_BOND_OPTION_AD_SELECT, "0", TYPE_BOTH, 0, 2,
|
||||
{ "stable", "bandwidth", "count", NULL } },
|
||||
{ NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, "0", TYPE_BOTH, 0, 2,
|
||||
{ "layer2", "layer3+4", "layer2+3", NULL } },
|
||||
{ NM_SETTING_BOND_OPTION_RESEND_IGMP, "1", TYPE_INT, 0, 255 },
|
||||
};
|
||||
|
||||
/**
|
||||
* 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), NULL);
|
||||
|
||||
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_int (const char *name, const char *value, const BondDefault *def)
|
||||
{
|
||||
glong num;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < strlen (value); i++) {
|
||||
if (!g_ascii_isdigit (value[i]) && value[i] != '-')
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
num = strtol (value, NULL, 10);
|
||||
if (errno)
|
||||
return FALSE;
|
||||
if (num < def->min || num > def->max)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
validate_list (const char *name, const char *value, const BondDefault *def)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (def->list) && def->list[i]; i++) {
|
||||
if (g_strcmp0 (def->list[i], value) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* empty validation list means all values pass */
|
||||
return def->list[0] == NULL ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
validate_ip (const char *name, const char *value)
|
||||
{
|
||||
char **ips, **iter;
|
||||
gboolean success = TRUE;
|
||||
struct in_addr addr;
|
||||
|
||||
if (!value || !value[0])
|
||||
return FALSE;
|
||||
|
||||
ips = g_strsplit_set (value, ",", 0);
|
||||
for (iter = ips; iter && *iter && success; iter++)
|
||||
success = !!inet_aton (*iter, &addr);
|
||||
g_strfreev (ips);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
validate_ifname (const char *name, const char *value)
|
||||
{
|
||||
if (!value || !value[0])
|
||||
return FALSE;
|
||||
|
||||
return nm_utils_iface_valid_name (value);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bond_validate_option:
|
||||
* @name: the name of the option to validate
|
||||
* @value: the value of the option to validate
|
||||
*
|
||||
* Checks whether @name is a valid bond option and @value is a valid value for
|
||||
* the @name. If @value is %NULL, the function only validates the option name.
|
||||
*
|
||||
* Returns: %TRUE, if the @value is valid for the given name.
|
||||
* If the @name is not a valid option, %FALSE will be returned.
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_bond_validate_option (const char *name,
|
||||
const char *value)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (!name || !name[0])
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (defaults); i++) {
|
||||
if (g_strcmp0 (defaults[i].opt, name) == 0) {
|
||||
if (value == NULL)
|
||||
return TRUE;
|
||||
switch (defaults[i].opt_type) {
|
||||
case TYPE_INT:
|
||||
return validate_int (name, value, &defaults[i]);
|
||||
case TYPE_STR:
|
||||
return validate_list (name, value, &defaults[i]);
|
||||
case TYPE_BOTH:
|
||||
return ( validate_int (name, value, &defaults[i])
|
||||
|| validate_list (name, value, &defaults[i]));
|
||||
case TYPE_IP:
|
||||
return validate_ip (name, value);
|
||||
case TYPE_IFNAME:
|
||||
return validate_ifname (name, value);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
if (!nm_setting_bond_validate_option (name, NULL))
|
||||
return 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.
|
||||
*
|
||||
* The order of how to set several options is relevant because there are options
|
||||
* that conflict with each other.
|
||||
*
|
||||
* 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;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
|
||||
|
||||
if (!value || !nm_setting_bond_validate_option (name, value))
|
||||
return FALSE;
|
||||
|
||||
priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
||||
|
||||
g_hash_table_insert (priv->options, g_strdup (name), g_strdup (value));
|
||||
|
||||
if ( !strcmp (name, NM_SETTING_BOND_OPTION_MIIMON)
|
||||
&& strcmp (value, "0") != 0) {
|
||||
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)
|
||||
&& strcmp (value, "0") != 0) {
|
||||
g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_MIIMON);
|
||||
g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY);
|
||||
g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_UPDELAY);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_BOND_OPTIONS);
|
||||
|
||||
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)
|
||||
{
|
||||
gboolean found;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
|
||||
|
||||
if (!nm_setting_bond_validate_option (name, NULL))
|
||||
return FALSE;
|
||||
|
||||
found = g_hash_table_remove (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name);
|
||||
if (found)
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_BOND_OPTIONS);
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bond_get_valid_options:
|
||||
* @setting: the #NMSettingBond
|
||||
*
|
||||
* Returns a list of valid bond options.
|
||||
*
|
||||
* Returns: (transfer none): 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 (nm_setting_bond_validate_option (name, NULL), 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 nm_setting_bond_validate_option() should also be found in defaults */
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
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;
|
||||
const char *primary;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->options);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
|
||||
if (!value[0] || !nm_setting_bond_validate_option (key, value)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_OPTION,
|
||||
_("invalid option '%s' or its value '%s'"),
|
||||
key, value);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
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,
|
||||
_("only one of '%s' and '%s' can be set"),
|
||||
NM_SETTING_BOND_OPTION_MIIMON,
|
||||
NM_SETTING_BOND_OPTION_ARP_INTERVAL);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
}
|
||||
|
||||
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,
|
||||
_("mandatory option '%s' is missing"),
|
||||
NM_SETTING_BOND_OPTION_MODE);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
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,
|
||||
_("'%s' is not a valid value for '%s'"),
|
||||
value, NM_SETTING_BOND_OPTION_MODE);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
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,
|
||||
_("'%s=%s' is incompatible with '%s > 0'"),
|
||||
NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
primary = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_PRIMARY);
|
||||
if (strcmp (value, "active-backup") == 0) {
|
||||
if (primary && !nm_utils_iface_valid_name (primary)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_OPTION,
|
||||
_("'%s' is not a valid interface name for '%s' option"),
|
||||
primary, NM_SETTING_BOND_OPTION_PRIMARY);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if (primary) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_OPTION,
|
||||
_("'%s' option is only valid for '%s=%s'"),
|
||||
NM_SETTING_BOND_OPTION_PRIMARY,
|
||||
NM_SETTING_BOND_OPTION_MODE, "active-backup");
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (nm_setting_find_in_list (all_settings, NM_SETTING_INFINIBAND_SETTING_NAME)) {
|
||||
if (strcmp (value, "active-backup") != 0) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_OPTION,
|
||||
_("'%s=%s' is not a valid configuration for '%s'"),
|
||||
NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_INFINIBAND_SETTING_NAME);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
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,
|
||||
_("'%s' option requires '%s' option to be set"),
|
||||
NM_SETTING_BOND_OPTION_UPDELAY, NM_SETTING_BOND_OPTION_MIIMON);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
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,
|
||||
_("'%s' option requires '%s' option to be set"),
|
||||
NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_MIIMON);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
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,
|
||||
_("'%s' option requires '%s' option to be set"),
|
||||
NM_SETTING_BOND_OPTION_ARP_INTERVAL, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
addrs = g_strsplit (arp_ip_target, ",", -1);
|
||||
if (!addrs[0]) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_OPTION,
|
||||
_("'%s' option is empty"),
|
||||
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
g_strfreev (addrs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; addrs[i]; i++) {
|
||||
if (!inet_pton (AF_INET, addrs[i], &addr)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_OPTION,
|
||||
_("'%s' is not a valid IPv4 address for '%s' option"),
|
||||
NM_SETTING_BOND_OPTION_ARP_IP_TARGET, addrs[i]);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
g_strfreev (addrs);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
g_strfreev (addrs);
|
||||
} else {
|
||||
if (arp_ip_target) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_OPTION,
|
||||
_("'%s' option requires '%s' option to be set"),
|
||||
NM_SETTING_BOND_OPTION_ARP_IP_TARGET, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return _nm_setting_verify_deprecated_virtual_iface_name (
|
||||
priv->interface_name, FALSE,
|
||||
NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_INTERFACE_NAME,
|
||||
NM_SETTING_BOND_ERROR,
|
||||
NM_SETTING_BOND_ERROR_INVALID_PROPERTY,
|
||||
NM_SETTING_BOND_ERROR_MISSING_PROPERTY,
|
||||
all_settings, error);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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:
|
||||
g_free (priv->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, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* 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, "", "",
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
117
libnm-core/nm-setting-bond.h
Normal file
117
libnm-core/nm-setting-bond.h
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/* -*- 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 - 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_SETTING_BOND_H
|
||||
#define NM_SETTING_BOND_H
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#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 ((klass), 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"
|
||||
#define NM_SETTING_BOND_OPTION_ARP_VALIDATE "arp_validate"
|
||||
#define NM_SETTING_BOND_OPTION_PRIMARY "primary"
|
||||
#define NM_SETTING_BOND_OPTION_PRIMARY_RESELECT "primary_reselect"
|
||||
#define NM_SETTING_BOND_OPTION_FAIL_OVER_MAC "fail_over_mac"
|
||||
#define NM_SETTING_BOND_OPTION_USE_CARRIER "use_carrier"
|
||||
#define NM_SETTING_BOND_OPTION_AD_SELECT "ad_select"
|
||||
#define NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY "xmit_hash_policy"
|
||||
#define NM_SETTING_BOND_OPTION_RESEND_IGMP "resend_igmp"
|
||||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
} NMSettingBond;
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[4];
|
||||
} 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);
|
||||
|
||||
gboolean nm_setting_bond_validate_option (const char *name,
|
||||
const char *value);
|
||||
|
||||
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 */
|
||||
285
libnm-core/nm-setting-bridge-port.c
Normal file
285
libnm-core/nm-setting-bridge-port.c
Normal file
|
|
@ -0,0 +1,285 @@
|
|||
/* -*- 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 2012 - 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-bridge-port.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-bridge-port
|
||||
* @short_description: Describes connection properties for bridge ports
|
||||
*
|
||||
* The #NMSettingBridgePort object is a #NMSetting subclass that describes
|
||||
* optional properties that apply to bridge ports.
|
||||
**/
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_port_error_quark:
|
||||
*
|
||||
* Registers an error quark for #NMSettingBridgePort if necessary.
|
||||
*
|
||||
* Returns: the error quark used for #NMSettingBridgePort errors.
|
||||
**/
|
||||
GQuark
|
||||
nm_setting_bridge_port_error_quark (void)
|
||||
{
|
||||
static GQuark quark;
|
||||
|
||||
if (G_UNLIKELY (!quark))
|
||||
quark = g_quark_from_static_string ("nm-setting-bridge-port-error-quark");
|
||||
return quark;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingBridgePort, nm_setting_bridge_port, NM_TYPE_SETTING,
|
||||
_nm_register_setting (NM_SETTING_BRIDGE_PORT_SETTING_NAME,
|
||||
g_define_type_id,
|
||||
3,
|
||||
NM_SETTING_BRIDGE_PORT_ERROR))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE_PORT)
|
||||
|
||||
#define NM_SETTING_BRIDGE_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortPrivate))
|
||||
|
||||
typedef struct {
|
||||
guint16 priority;
|
||||
guint16 path_cost;
|
||||
gboolean hairpin_mode;
|
||||
} NMSettingBridgePortPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_PRIORITY,
|
||||
PROP_PATH_COST,
|
||||
PROP_HAIRPIN_MODE,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_port_get_priority:
|
||||
* @setting: the #NMSettingBridgePort
|
||||
*
|
||||
* Returns: the #NMSettingBridgePort:priority property of the setting
|
||||
**/
|
||||
guint16
|
||||
nm_setting_bridge_port_get_priority (NMSettingBridgePort *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_port_get_path_cost:
|
||||
* @setting: the #NMSettingBridgePort
|
||||
*
|
||||
* Returns: the #NMSettingBridgePort:path-cost property of the setting
|
||||
**/
|
||||
guint16
|
||||
nm_setting_bridge_port_get_path_cost (NMSettingBridgePort *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->path_cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_port_get_hairpin_mode:
|
||||
* @setting: the #NMSettingBridgePort
|
||||
*
|
||||
* Returns: the #NMSettingBridgePort:hairpin-mode property of the setting
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), FALSE);
|
||||
|
||||
return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->hairpin_mode;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#define BR_MAX_PORT_PRIORITY 63
|
||||
#define BR_DEF_PRIORITY 32
|
||||
|
||||
#define BR_MIN_PATH_COST 1
|
||||
#define BR_MAX_PATH_COST 65535
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting);
|
||||
|
||||
if (priv->priority > BR_MAX_PORT_PRIORITY) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BRIDGE_PORT_ERROR,
|
||||
NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
|
||||
_("'%d' is not a valid value for the property (should be <= %d)"),
|
||||
priv->priority, BR_MAX_PORT_PRIORITY);
|
||||
g_prefix_error (error, "%s.%s: ",
|
||||
NM_SETTING_BRIDGE_PORT_SETTING_NAME,
|
||||
NM_SETTING_BRIDGE_PORT_PRIORITY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->path_cost > BR_MAX_PATH_COST) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BRIDGE_PORT_ERROR,
|
||||
NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
|
||||
_("'%d' is not a valid value for the property (should be <= %d)"),
|
||||
priv->path_cost, BR_MAX_PATH_COST);
|
||||
g_prefix_error (error, "%s.%s: ",
|
||||
NM_SETTING_BRIDGE_PORT_SETTING_NAME,
|
||||
NM_SETTING_BRIDGE_PORT_PATH_COST);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_port_new:
|
||||
*
|
||||
* Creates a new #NMSettingBridgePort object with default values.
|
||||
*
|
||||
* Returns: (transfer full): the new empty #NMSettingBridgePort object
|
||||
**/
|
||||
NMSetting *
|
||||
nm_setting_bridge_port_new (void)
|
||||
{
|
||||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_BRIDGE_PORT, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_bridge_port_init (NMSettingBridgePort *setting)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PRIORITY:
|
||||
priv->priority = (guint16) (g_value_get_uint (value) & 0xFFFF);
|
||||
break;
|
||||
case PROP_PATH_COST:
|
||||
priv->path_cost = (guint16) (g_value_get_uint (value) & 0xFFFF);
|
||||
break;
|
||||
case PROP_HAIRPIN_MODE:
|
||||
priv->hairpin_mode = g_value_get_boolean (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)
|
||||
{
|
||||
NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PRIORITY:
|
||||
g_value_set_uint (value, priv->priority);
|
||||
break;
|
||||
case PROP_PATH_COST:
|
||||
g_value_set_uint (value, priv->path_cost);
|
||||
break;
|
||||
case PROP_HAIRPIN_MODE:
|
||||
g_value_set_boolean (value, priv->hairpin_mode);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_bridge_port_class_init (NMSettingBridgePortClass *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 (NMSettingBridgePortPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
parent_class->verify = verify;
|
||||
|
||||
/* Properties */
|
||||
/**
|
||||
* NMSettingBridgePort:priority:
|
||||
*
|
||||
* The Spanning Tree Protocol (STP) priority of this bridge port.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIORITY,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_PORT_PRIORITY, "", "",
|
||||
0, BR_MAX_PORT_PRIORITY, BR_DEF_PRIORITY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridgePort:path-cost:
|
||||
*
|
||||
* The Spanning Tree Protocol (STP) port cost for destinations via this
|
||||
* port.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PATH_COST,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_PORT_PATH_COST, "", "",
|
||||
0, BR_MAX_PATH_COST, 100,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridgePort:hairpin-mode:
|
||||
*
|
||||
* Enables or disabled "hairpin mode" for the port, which allows frames to
|
||||
* be sent back out through the port the frame was received on.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_HAIRPIN_MODE,
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, "", "",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
85
libnm-core/nm-setting-bridge-port.h
Normal file
85
libnm-core/nm-setting-bridge-port.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/* -*- 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 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_SETTING_BRIDGE_PORT_H
|
||||
#define NM_SETTING_BRIDGE_PORT_H
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <nm-setting.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_SETTING_BRIDGE_PORT (nm_setting_bridge_port_get_type ())
|
||||
#define NM_SETTING_BRIDGE_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePort))
|
||||
#define NM_SETTING_BRIDGE_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortClass))
|
||||
#define NM_IS_SETTING_BRIDGE_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BRIDGE_PORT))
|
||||
#define NM_IS_SETTING_BRIDGE_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_BRIDGE_PORT))
|
||||
#define NM_SETTING_BRIDGE_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortClass))
|
||||
|
||||
#define NM_SETTING_BRIDGE_PORT_SETTING_NAME "bridge-port"
|
||||
|
||||
/**
|
||||
* NMSettingBridgePortError:
|
||||
* @NM_SETTING_BRIDGE_PORT_ERROR_UNKNOWN: unknown or unclassified error
|
||||
* @NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY: the property was invalid
|
||||
* @NM_SETTING_BRIDGE_PORT_ERROR_MISSING_PROPERTY: the property was missing and
|
||||
* is required
|
||||
*/
|
||||
typedef enum {
|
||||
NM_SETTING_BRIDGE_PORT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
|
||||
NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
|
||||
NM_SETTING_BRIDGE_PORT_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
|
||||
} NMSettingBridgePortError;
|
||||
|
||||
#define NM_SETTING_BRIDGE_PORT_ERROR nm_setting_bridge_port_error_quark ()
|
||||
GQuark nm_setting_bridge_port_error_quark (void);
|
||||
|
||||
#define NM_SETTING_BRIDGE_PORT_PRIORITY "priority"
|
||||
#define NM_SETTING_BRIDGE_PORT_PATH_COST "path-cost"
|
||||
#define NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE "hairpin-mode"
|
||||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
} NMSettingBridgePort;
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[4];
|
||||
} NMSettingBridgePortClass;
|
||||
|
||||
GType nm_setting_bridge_port_get_type (void);
|
||||
|
||||
NMSetting * nm_setting_bridge_port_new (void);
|
||||
|
||||
guint16 nm_setting_bridge_port_get_priority (NMSettingBridgePort *setting);
|
||||
|
||||
guint16 nm_setting_bridge_port_get_path_cost (NMSettingBridgePort *setting);
|
||||
|
||||
gboolean nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_BRIDGE_PORT_H */
|
||||
537
libnm-core/nm-setting-bridge.c
Normal file
537
libnm-core/nm-setting-bridge.c
Normal file
|
|
@ -0,0 +1,537 @@
|
|||
/* -*- 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 - 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
#include "nm-setting-bridge.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-bridge
|
||||
* @short_description: Describes connection properties for bridges
|
||||
*
|
||||
* The #NMSettingBridge object is a #NMSetting subclass that describes properties
|
||||
* necessary for bridging connections.
|
||||
**/
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_error_quark:
|
||||
*
|
||||
* Registers an error quark for #NMSettingBridge if necessary.
|
||||
*
|
||||
* Returns: the error quark used for #NMSettingBridge errors.
|
||||
**/
|
||||
GQuark
|
||||
nm_setting_bridge_error_quark (void)
|
||||
{
|
||||
static GQuark quark;
|
||||
|
||||
if (G_UNLIKELY (!quark))
|
||||
quark = g_quark_from_static_string ("nm-setting-bridge-error-quark");
|
||||
return quark;
|
||||
}
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingBridge, nm_setting_bridge, NM_TYPE_SETTING,
|
||||
_nm_register_setting (NM_SETTING_BRIDGE_SETTING_NAME,
|
||||
g_define_type_id,
|
||||
1,
|
||||
NM_SETTING_BRIDGE_ERROR))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE)
|
||||
|
||||
#define NM_SETTING_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE, NMSettingBridgePrivate))
|
||||
|
||||
typedef struct {
|
||||
char * interface_name;
|
||||
GByteArray *mac_address;
|
||||
gboolean stp;
|
||||
guint16 priority;
|
||||
guint16 forward_delay;
|
||||
guint16 hello_time;
|
||||
guint16 max_age;
|
||||
guint32 ageing_time;
|
||||
} NMSettingBridgePrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_INTERFACE_NAME,
|
||||
PROP_MAC_ADDRESS,
|
||||
PROP_STP,
|
||||
PROP_PRIORITY,
|
||||
PROP_FORWARD_DELAY,
|
||||
PROP_HELLO_TIME,
|
||||
PROP_MAX_AGE,
|
||||
PROP_AGEING_TIME,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_new:
|
||||
*
|
||||
* Creates a new #NMSettingBridge object with default values.
|
||||
*
|
||||
* Returns: (transfer full): the new empty #NMSettingBridge object
|
||||
**/
|
||||
NMSetting *
|
||||
nm_setting_bridge_new (void)
|
||||
{
|
||||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_BRIDGE, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_interface_name:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:interface-name property of the setting
|
||||
**/
|
||||
const char *
|
||||
nm_setting_bridge_get_interface_name (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->interface_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_mac_address:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:mac-address property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
nm_setting_bridge_get_mac_address (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), NULL);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->mac_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_stp:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:stp property of the setting
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_bridge_get_stp (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), FALSE);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->stp;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_priority:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:priority property of the setting
|
||||
**/
|
||||
guint16
|
||||
nm_setting_bridge_get_priority (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_forward_delay:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:forward-delay property of the setting
|
||||
**/
|
||||
guint16
|
||||
nm_setting_bridge_get_forward_delay (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->forward_delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_hello_time:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:hello-time property of the setting
|
||||
**/
|
||||
guint16
|
||||
nm_setting_bridge_get_hello_time (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->hello_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_max_age:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:max-age property of the setting
|
||||
**/
|
||||
guint16
|
||||
nm_setting_bridge_get_max_age (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->max_age;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_ageing_time:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:ageing-time property of the setting
|
||||
**/
|
||||
guint
|
||||
nm_setting_bridge_get_ageing_time (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->ageing_time;
|
||||
}
|
||||
|
||||
/* IEEE 802.1D-1998 timer values */
|
||||
#define BR_MIN_HELLO_TIME 1
|
||||
#define BR_MAX_HELLO_TIME 10
|
||||
|
||||
#define BR_MIN_FORWARD_DELAY 2
|
||||
#define BR_MAX_FORWARD_DELAY 30
|
||||
|
||||
#define BR_MIN_MAX_AGE 6
|
||||
#define BR_MAX_MAX_AGE 40
|
||||
|
||||
/* IEEE 802.1D-1998 Table 7.4 */
|
||||
#define BR_MIN_AGEING_TIME 0
|
||||
#define BR_MAX_AGEING_TIME 1000000
|
||||
|
||||
static inline gboolean
|
||||
check_range (guint32 val,
|
||||
guint32 min,
|
||||
guint32 max,
|
||||
const char *prop,
|
||||
GError **error)
|
||||
{
|
||||
if ((val != 0) && (val < min || val > max)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_BRIDGE_ERROR,
|
||||
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
|
||||
_("value '%d' is out of range <%d-%d>"),
|
||||
val, min, max);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, prop);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
||||
|
||||
if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_BRIDGE_ERROR,
|
||||
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
|
||||
_("is not a valid MAC address"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_MAC_ADDRESS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!check_range (priv->forward_delay,
|
||||
BR_MIN_FORWARD_DELAY,
|
||||
BR_MAX_FORWARD_DELAY,
|
||||
NM_SETTING_BRIDGE_FORWARD_DELAY,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!check_range (priv->hello_time,
|
||||
BR_MIN_HELLO_TIME,
|
||||
BR_MAX_HELLO_TIME,
|
||||
NM_SETTING_BRIDGE_HELLO_TIME,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!check_range (priv->max_age,
|
||||
BR_MIN_MAX_AGE,
|
||||
BR_MAX_MAX_AGE,
|
||||
NM_SETTING_BRIDGE_MAX_AGE,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!check_range (priv->ageing_time,
|
||||
BR_MIN_AGEING_TIME,
|
||||
BR_MAX_AGEING_TIME,
|
||||
NM_SETTING_BRIDGE_AGEING_TIME,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
return _nm_setting_verify_deprecated_virtual_iface_name (
|
||||
priv->interface_name, FALSE,
|
||||
NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_INTERFACE_NAME,
|
||||
NM_SETTING_BRIDGE_ERROR,
|
||||
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
|
||||
NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY,
|
||||
all_settings, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_virtual_iface_name (NMSetting *setting)
|
||||
{
|
||||
NMSettingBridge *self = NM_SETTING_BRIDGE (setting);
|
||||
|
||||
return nm_setting_bridge_get_interface_name (self);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_bridge_init (NMSettingBridge *setting)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->interface_name);
|
||||
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_bridge_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_INTERFACE_NAME:
|
||||
g_free (priv->interface_name);
|
||||
priv->interface_name = g_value_dup_string (value);
|
||||
break;
|
||||
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_STP:
|
||||
priv->stp = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_PRIORITY:
|
||||
priv->priority = (guint16) g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_FORWARD_DELAY:
|
||||
priv->forward_delay = (guint16) g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_HELLO_TIME:
|
||||
priv->hello_time = (guint16) g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MAX_AGE:
|
||||
priv->max_age = (guint16) g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_AGEING_TIME:
|
||||
priv->ageing_time = g_value_get_uint (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)
|
||||
{
|
||||
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
|
||||
NMSettingBridge *setting = NM_SETTING_BRIDGE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_INTERFACE_NAME:
|
||||
g_value_set_string (value, nm_setting_bridge_get_interface_name (setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_bridge_get_mac_address (setting));
|
||||
break;
|
||||
case PROP_STP:
|
||||
g_value_set_boolean (value, priv->stp);
|
||||
break;
|
||||
case PROP_PRIORITY:
|
||||
g_value_set_uint (value, priv->priority);
|
||||
break;
|
||||
case PROP_FORWARD_DELAY:
|
||||
g_value_set_uint (value, priv->forward_delay);
|
||||
break;
|
||||
case PROP_HELLO_TIME:
|
||||
g_value_set_uint (value, priv->hello_time);
|
||||
break;
|
||||
case PROP_MAX_AGE:
|
||||
g_value_set_uint (value, priv->max_age);
|
||||
break;
|
||||
case PROP_AGEING_TIME:
|
||||
g_value_set_uint (value, priv->ageing_time);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_bridge_class_init (NMSettingBridgeClass *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 (NMSettingBridgePrivate));
|
||||
|
||||
/* 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 */
|
||||
/**
|
||||
* NMSettingBridge:interface-name:
|
||||
*
|
||||
* The name of the virtual in-kernel bridging network interface
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_INTERFACE_NAME,
|
||||
g_param_spec_string (NM_SETTING_BRIDGE_INTERFACE_NAME, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:mac-address:
|
||||
*
|
||||
* If specified, the MAC address of bridge. When creating a new bridge, this
|
||||
* MAC address will be set. When matching an existing (outside
|
||||
* NetworkManager created) bridge, this MAC address must match.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_BRIDGE_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:stp:
|
||||
*
|
||||
* Controls whether Spanning Tree Protocol (STP) is enabled for this bridge.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_STP,
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_STP, "", "",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:priority:
|
||||
*
|
||||
* Sets the Spanning Tree Protocol (STP) priority for this bridge. Lower
|
||||
* values are "better"; the lowest priority bridge will be elected the root
|
||||
* bridge.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIORITY,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_PRIORITY, "", "",
|
||||
0, G_MAXUINT16, 0x8000,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:forward-delay:
|
||||
*
|
||||
* The Spanning Tree Protocol (STP) forwarding delay, in seconds.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_FORWARD_DELAY,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_FORWARD_DELAY, "", "",
|
||||
0, BR_MAX_FORWARD_DELAY, 15,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:hello-time:
|
||||
*
|
||||
* The Spanning Tree Protocol (STP) hello time, in seconds.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_HELLO_TIME,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_HELLO_TIME, "", "",
|
||||
0, BR_MAX_HELLO_TIME, 2,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:max-age:
|
||||
*
|
||||
* The Spanning Tree Protocol (STP) maximum message age, in seconds.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAX_AGE,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_MAX_AGE, "", "",
|
||||
0, BR_MAX_MAX_AGE, 20,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:ageing-time:
|
||||
*
|
||||
* The Ethernet MAC address aging time, in seconds.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_AGEING_TIME,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_AGEING_TIME, "", "",
|
||||
0, BR_MAX_AGEING_TIME, 300,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
100
libnm-core/nm-setting-bridge.h
Normal file
100
libnm-core/nm-setting-bridge.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/* -*- 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 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_SETTING_BRIDGE_H
|
||||
#define NM_SETTING_BRIDGE_H
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <nm-setting.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_SETTING_BRIDGE (nm_setting_bridge_get_type ())
|
||||
#define NM_SETTING_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BRIDGE, NMSettingBridge))
|
||||
#define NM_SETTING_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BRIDGE, NMSettingBridgeClass))
|
||||
#define NM_IS_SETTING_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BRIDGE))
|
||||
#define NM_IS_SETTING_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_BRIDGE))
|
||||
#define NM_SETTING_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BRIDGE, NMSettingBridgeClass))
|
||||
|
||||
#define NM_SETTING_BRIDGE_SETTING_NAME "bridge"
|
||||
|
||||
/**
|
||||
* NMSettingBridgeError:
|
||||
* @NM_SETTING_BRIDGE_ERROR_UNKNOWN: unknown or unclassified error
|
||||
* @NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY: the property was invalid
|
||||
* @NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY: the property was missing and is
|
||||
* required
|
||||
*/
|
||||
typedef enum {
|
||||
NM_SETTING_BRIDGE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
|
||||
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
|
||||
NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
|
||||
} NMSettingBridgeError;
|
||||
|
||||
#define NM_SETTING_BRIDGE_ERROR nm_setting_bridge_error_quark ()
|
||||
GQuark nm_setting_bridge_error_quark (void);
|
||||
|
||||
#define NM_SETTING_BRIDGE_INTERFACE_NAME "interface-name"
|
||||
#define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address"
|
||||
#define NM_SETTING_BRIDGE_STP "stp"
|
||||
#define NM_SETTING_BRIDGE_PRIORITY "priority"
|
||||
#define NM_SETTING_BRIDGE_FORWARD_DELAY "forward-delay"
|
||||
#define NM_SETTING_BRIDGE_HELLO_TIME "hello-time"
|
||||
#define NM_SETTING_BRIDGE_MAX_AGE "max-age"
|
||||
#define NM_SETTING_BRIDGE_AGEING_TIME "ageing-time"
|
||||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
} NMSettingBridge;
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[4];
|
||||
} NMSettingBridgeClass;
|
||||
|
||||
GType nm_setting_bridge_get_type (void);
|
||||
|
||||
NMSetting * nm_setting_bridge_new (void);
|
||||
|
||||
const char * nm_setting_bridge_get_interface_name (NMSettingBridge *setting);
|
||||
|
||||
const GByteArray *nm_setting_bridge_get_mac_address (NMSettingBridge *setting);
|
||||
|
||||
gboolean nm_setting_bridge_get_stp (NMSettingBridge *setting);
|
||||
|
||||
guint16 nm_setting_bridge_get_priority (NMSettingBridge *setting);
|
||||
|
||||
guint16 nm_setting_bridge_get_forward_delay (NMSettingBridge *setting);
|
||||
|
||||
guint16 nm_setting_bridge_get_hello_time (NMSettingBridge *setting);
|
||||
|
||||
guint16 nm_setting_bridge_get_max_age (NMSettingBridge *setting);
|
||||
|
||||
guint32 nm_setting_bridge_get_ageing_time (NMSettingBridge *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_BRIDGE_H */
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue