Merge remote branch 'origin/master' into wimax

This commit is contained in:
Dan Williams
2010-05-19 08:55:26 -07:00
290 changed files with 58599 additions and 12315 deletions

46
.gitignore vendored
View File

@@ -2,6 +2,7 @@
*.o
*.lo
*.la
*.bz2
Makefile
Makefile.in*
configure
@@ -22,24 +23,47 @@ autom4te.cache
intltool-*
gtk-doc.make
TAGS
COPYING
INSTALL
*.pc
man/*.[185]
po/*.gmo
po/.intltool-merge-cache
docs/libnm-glib/*.stamp
docs/libnm-glib/html/
docs/libnm-glib/tmpl/
docs/libnm-glib/xml/
docs/libnm-glib/libnm-glib-*.txt
docs/libnm-glib/libnm-glib.args
docs/libnm-glib/libnm-glib.hierarchy
docs/libnm-glib/libnm-glib.interfaces
docs/libnm-glib/libnm-glib.prerequisites
docs/libnm-glib/libnm-glib.signals
docs/libnm-util/*.stamp
docs/libnm-util/html/
docs/libnm-util/tmpl/
docs/libnm-util/xml/
docs/libnm-util/libnm-util-*.txt
COPYING
INSTALL
*.pc
man/*.[18]
po/*.gmo
docs/libnm-util/libnm-util-decl-list.txt.bak
docs/libnm-util/libnm-util-decl.txt.bak
docs/libnm-util/libnm-util.args
docs/libnm-util/libnm-util.hierarchy
docs/libnm-util/libnm-util.interfaces
docs/libnm-util/libnm-util.prerequisites
docs/libnm-util/libnm-util.signals
docs/libnm-util/libnm-util.types
docs/generate-settings-spec
docs/settings-spec.html
docs/spec.html
callouts/nm-dhcp-client.action
callouts/nm-avahi-autoipd.action
callouts/nm-dispatcher.action
callouts/org.freedesktop.nm_dispatcher.service
callouts/nm-modem-probe
dispatcher-daemon/NetworkManagerDispatcher
initscript/*/NetworkManagerDispatcher
initscript/*/networkmanager-dispatcher
@@ -53,8 +77,10 @@ nm-marshal.[ch]
libnm-glib/libnm-glib-test
src/NetworkManager
src/nm-crash-logger
src/supplicant-manager/tests/test-supplicant-config
system-settings/src/nm-system-settings
system-settings/src/org.freedesktop.NetworkManagerSystemSettings.service
test/libnm-glib-test
test/libnm_glib_test
test/nm-online
test/nm-tool
@@ -62,8 +88,17 @@ test/nmtestdevices
libnm-util/test-crypto
libnm-util/tests/test-crypto
libnm-util/tests/test-settings-defaults
libnm-util/tests/test-general
libnm-util/tests/test-need-secrets
libnm-util/tests/test-setting-8021x
src/tests/test-dhcp-options
src/tests/test-policy-hosts
system-settings/plugins/keyfile/tests/test-keyfile
system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh
system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils
system-settings/plugins/ifcfg-rh/tests/network-scripts/Test_Write_*
system-settings/plugins/ifcfg-rh/tests/network-scripts/*-Test_Write_*
m4/gtk-doc.m4
m4/intltool.m4
@@ -72,3 +107,4 @@ m4/lt*.m4
policy/org.freedesktop.network-manager-settings.system.policy
cli/src/nmcli

View File

@@ -1,6 +1,5 @@
SUBDIRS = marshallers
SUBDIRS += \
SUBDIRS = \
marshallers \
libnm-util \
libnm-glib \
src \
@@ -8,13 +7,15 @@ SUBDIRS += \
introspection \
callouts \
system-settings \
cli \
tools \
policy \
initscript \
test \
po \
man \
docs
docs \
examples
EXTRA_DIST = \
CONTRIBUTING \

View File

@@ -7,7 +7,7 @@ REQUIRED_AUTOMAKE_VERSION=1.9
PKG_NAME=NetworkManager
(test -f $srcdir/configure.ac \
&& test -f $srcdir/src/NetworkManager.c) || {
&& test -f $srcdir/src/main.c) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level $PKG_NAME directory"
exit 1

2
cli/Makefile.am Normal file
View File

@@ -0,0 +1,2 @@
SUBDIRS = src

38
cli/src/Makefile.am Normal file
View File

@@ -0,0 +1,38 @@
bin_PROGRAMS = \
nmcli
INCLUDES = \
-I${top_srcdir} \
-I${top_srcdir}/include \
-I${top_builddir}/marshallers \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/libnm-glib
nmcli_SOURCES = \
connections.c \
connections.h \
devices.c \
devices.h \
network-manager.c \
network-manager.h \
settings.c \
settings.h \
nmcli.c \
nmcli.h \
utils.c \
utils.h
nmcli_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
-DNMCLI_LOCALEDIR=\"$(datadir)/locale\" \
-DG_DISABLE_DEPRECATED
nmcli_LDADD = \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/libnm-glib/libnm-glib.la

1642
cli/src/connections.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
/* nmcli - command-line tool to control NetworkManager
*
* 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
@@ -15,17 +14,14 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2006 - 2008 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
* (C) Copyright 2010 Red Hat, Inc.
*/
#ifndef NM_LOGGING_H
#define NM_LOGGING_H
#ifndef NMC_CONNECTIONS_H
#define NMC_CONNECTIONS_H
#include <glib.h>
#include "nmcli.h"
void nm_logging_setup (gboolean become_daemon);
void nm_logging_backtrace (void);
void nm_logging_shutdown (void);
NMCResultCode do_connections (NmCli *nmc, int argc, char **argv);
#endif /* NM_LOGGING_H */
#endif /* NMC_CONNECTIONS_H */

1196
cli/src/devices.c Normal file

File diff suppressed because it is too large Load Diff

27
cli/src/devices.h Normal file
View File

@@ -0,0 +1,27 @@
/* nmcli - command-line tool to control NetworkManager
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
#ifndef NMC_DEVICES_H
#define NMC_DEVICES_H
#include "nmcli.h"
NMCResultCode do_devices (NmCli *nmc, int argc, char **argv);
#endif /* NMC_DEVICES_H */

278
cli/src/network-manager.c Normal file
View File

@@ -0,0 +1,278 @@
/* nmcli - command-line tool to control NetworkManager
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <nm-client.h>
#include <nm-setting-connection.h>
#include "utils.h"
#include "network-manager.h"
/* Available fields for 'nm status' */
static NmcOutputField nmc_fields_nm_status[] = {
{"RUNNING", N_("RUNNING"), 15, NULL, 0}, /* 0 */
{"STATE", N_("STATE"), 15, NULL, 0}, /* 1 */
{"WIFI-HARDWARE", N_("WIFI-HARDWARE"), 15, NULL, 0}, /* 2 */
{"WIFI", N_("WIFI"), 10, NULL, 0}, /* 3 */
{"WWAN-HARDWARE", N_("WWAN-HARDWARE"), 15, NULL, 0}, /* 4 */
{"WWAN", N_("WWAN"), 10, NULL, 0}, /* 5 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#define NMC_FIELDS_NM_STATUS_COMMON "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#define NMC_FIELDS_NM_WIFI "WIFI"
#define NMC_FIELDS_NM_WWAN "WWAN"
extern GMainLoop *loop;
/* static function prototypes */
static void usage (void);
static void quit (void);
static const char *nm_state_to_string (NMState state);
static NMCResultCode show_nm_status (NmCli *nmc);
static void
usage (void)
{
fprintf (stderr,
_("Usage: nmcli nm { COMMAND | help }\n\n"
" COMMAND := { status | sleep | wakeup | wifi | wwan }\n\n"
" status\n"
" sleep\n"
" wakeup\n"
" wifi [on|off]\n"
" wwan [on|off]\n\n"));
}
/* quit main loop */
static void
quit (void)
{
g_main_loop_quit (loop); /* quit main loop */
}
static const char *
nm_state_to_string (NMState state)
{
switch (state) {
case NM_STATE_ASLEEP:
return _("asleep");
case NM_STATE_CONNECTING:
return _("connecting");
case NM_STATE_CONNECTED:
return _("connected");
case NM_STATE_DISCONNECTED:
return _("disconnected");
case NM_STATE_UNKNOWN:
default:
return _("unknown");
}
}
static NMCResultCode
show_nm_status (NmCli *nmc)
{
gboolean nm_running;
NMState state;
const char *wireless_hw_enabled_str, *wireless_enabled_str;
const char *wwan_hw_enabled_str, *wwan_enabled_str;
GError *error = NULL;
const char *fields_str;
const char *fields_all = NMC_FIELDS_NM_STATUS_ALL;
const char *fields_common = NMC_FIELDS_NM_STATUS_COMMON;
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
g_return_val_if_fail (nmc->client != NULL, NMC_RESULT_ERROR_UNKNOWN);
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
fields_str = fields_common;
else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0)
fields_str = fields_all;
else
fields_str = nmc->required_fields;
nmc->allowed_fields = nmc_fields_nm_status;
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
if (error) {
if (error->code == 0)
g_string_printf (nmc->return_text, _("Error: 'nm status': %s"), error->message);
else
g_string_printf (nmc->return_text, _("Error: 'nm status': %s; allowed fields: %s"), error->message, NMC_FIELDS_NM_STATUS_ALL);
g_error_free (error);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.header_name = _("NetworkManager status");
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
nm_running = nm_client_get_manager_running (nmc->client);
state = nm_client_get_state (nmc->client);
if (nm_running) {
wireless_hw_enabled_str = nm_client_wireless_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
wireless_enabled_str = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
wwan_hw_enabled_str = nm_client_wwan_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
wwan_enabled_str = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
} else {
wireless_hw_enabled_str = wireless_enabled_str = wwan_hw_enabled_str = wwan_enabled_str = _("unknown");
}
nmc->allowed_fields[0].value = nm_running ? _("running") : _("not running");
nmc->allowed_fields[1].value = nm_state_to_string (state);
nmc->allowed_fields[2].value = wireless_hw_enabled_str;
nmc->allowed_fields[3].value = wireless_enabled_str;
nmc->allowed_fields[4].value = wwan_hw_enabled_str;
nmc->allowed_fields[5].value = wwan_enabled_str;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
return NMC_RESULT_SUCCESS;
}
/* entry point function for global network manager related commands 'nmcli nm' */
NMCResultCode
do_network_manager (NmCli *nmc, int argc, char **argv)
{
GError *error = NULL;
gboolean enable_wifi;
gboolean enable_wwan;
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
/* create NMClient */
if (!nmc->get_client (nmc))
goto end;
if (argc == 0) {
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
goto opt_error;
nmc->return_value = show_nm_status (nmc);
}
if (argc > 0) {
if (matches (*argv, "status") == 0) {
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
goto opt_error;
nmc->return_value = show_nm_status (nmc);
}
else if (matches (*argv, "sleep") == 0) {
nm_client_sleep (nmc->client, TRUE);
}
else if (matches (*argv, "wakeup") == 0) {
nm_client_sleep (nmc->client, FALSE);
}
else if (matches (*argv, "wifi") == 0) {
if (next_arg (&argc, &argv) != 0) {
/* no argument, show current WiFi state */
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
goto opt_error;
if (nmc->required_fields && strcasecmp (nmc->required_fields, "WIFI")) {
g_string_printf (nmc->return_text, _("Error: '--fields' value '%s' is not valid here; allowed fields: %s"),
nmc->required_fields, NMC_FIELDS_NM_WIFI);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
nmc->allowed_fields = nmc_fields_nm_status;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_NM_WIFI, nmc->allowed_fields, NULL);
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.header_name = _("WiFi enabled");
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
nmc->allowed_fields[3].value = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
} else {
if (!strcmp (*argv, "on"))
enable_wifi = TRUE;
else if (!strcmp (*argv, "off"))
enable_wifi = FALSE;
else {
g_string_printf (nmc->return_text, _("Error: invalid 'wifi' parameter: '%s'."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
nm_client_wireless_set_enabled (nmc->client, enable_wifi);
}
}
else if (matches (*argv, "wwan") == 0) {
if (next_arg (&argc, &argv) != 0) {
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
goto opt_error;
/* no argument, show current WWAN state */
if (nmc->required_fields && strcasecmp (nmc->required_fields, "WWAN")) {
g_string_printf (nmc->return_text, _("Error: '--fields' value '%s' is not valid here; allowed fields: %s"),
nmc->required_fields, NMC_FIELDS_NM_WWAN);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
nmc->allowed_fields = nmc_fields_nm_status;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_NM_WWAN, nmc->allowed_fields, NULL);
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.header_name = _("WWAN enabled");
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
nmc->allowed_fields[5].value = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
} else {
if (!strcmp (*argv, "on"))
enable_wwan = TRUE;
else if (!strcmp (*argv, "off"))
enable_wwan = FALSE;
else {
g_string_printf (nmc->return_text, _("Error: invalid 'wwan' parameter: '%s'."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
nm_client_wwan_set_enabled (nmc->client, enable_wwan);
}
}
else if (strcmp (*argv, "help") == 0) {
usage ();
}
else {
g_string_printf (nmc->return_text, _("Error: 'nm' command '%s' is not valid."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
}
}
end:
quit ();
return nmc->return_value;
opt_error:
quit ();
g_string_printf (nmc->return_text, _("Error: %s."), error->message);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
g_error_free (error);
return nmc->return_value;
}

27
cli/src/network-manager.h Normal file
View File

@@ -0,0 +1,27 @@
/* nmcli - command-line tool to control NetworkManager
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
#ifndef NMC_NETWORK_MANAGER_H
#define NMC_NETWORK_MANAGER_H
#include "nmcli.h"
NMCResultCode do_network_manager (NmCli *nmc, int argc, char **argv);
#endif /* NMC_NETWORK_MANAGER_H */

363
cli/src/nmcli.c Normal file
View File

@@ -0,0 +1,363 @@
/* nmcli - command-line tool to control NetworkManager
*
* Jiri Klimes <jklimes@redhat.com>
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
/* Generated configuration file */
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <nm-client.h>
#include <nm-setting-connection.h>
#include <nm-remote-settings.h>
#include <nm-remote-settings-system.h>
#include <nm-settings-interface.h>
#include <nm-settings-connection-interface.h>
#include "nmcli.h"
#include "utils.h"
#include "connections.h"
#include "devices.h"
#include "network-manager.h"
#if defined(NM_DIST_VERSION)
# define NMCLI_VERSION NM_DIST_VERSION
#else
# define NMCLI_VERSION VERSION
#endif
typedef struct {
NmCli *nmc;
int argc;
char **argv;
} ArgsInfo;
/* --- Global variables --- */
GMainLoop *loop = NULL;
static void
usage (const char *prog_name)
{
fprintf (stderr,
_("Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n\n"
"OPTIONS\n"
" -t[erse] terse output\n"
" -p[retty] pretty output\n"
" -m[ode] tabular|multiline output mode\n"
" -f[ields] <field1,field2,...>|all|common specify fields to output\n"
" -e[scape] yes|no escape columns separators in values\n"
" -v[ersion] show program version\n"
" -h[elp] print this help\n\n"
"OBJECT\n"
" nm NetworkManager status\n"
" con NetworkManager connections\n"
" dev devices managed by NetworkManager\n\n"),
prog_name);
}
static NMCResultCode
do_help (NmCli *nmc, int argc, char **argv)
{
usage ("nmcli");
return NMC_RESULT_SUCCESS;
}
static const struct cmd {
const char *cmd;
NMCResultCode (*func) (NmCli *nmc, int argc, char **argv);
} nmcli_cmds[] = {
{ "nm", do_network_manager },
{ "con", do_connections },
{ "dev", do_devices },
{ "help", do_help },
{ 0 }
};
static NMCResultCode
do_cmd (NmCli *nmc, const char *argv0, int argc, char **argv)
{
const struct cmd *c;
for (c = nmcli_cmds; c->cmd; ++c) {
if (matches (argv0, c->cmd) == 0)
return c->func (nmc, argc-1, argv+1);
}
g_string_printf (nmc->return_text, _("Error: Object '%s' is unknown, try 'nmcli help'."), argv0);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
static NMCResultCode
parse_command_line (NmCli *nmc, int argc, char **argv)
{
char *base;
base = strrchr (argv[0], '/');
if (base == NULL)
base = argv[0];
else
base++;
/* parse options */
while (argc > 1) {
char *opt = argv[1];
/* '--' ends options */
if (strcmp (opt, "--") == 0) {
argc--; argv++;
break;
}
if (opt[0] != '-')
break;
if (opt[1] == '-')
opt++;
if (matches (opt, "-terse") == 0) {
if (nmc->print_output == NMC_PRINT_TERSE) {
g_string_printf (nmc->return_text, _("Error: Option '--terse' is specified the second time."));
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
else if (nmc->print_output == NMC_PRINT_PRETTY) {
g_string_printf (nmc->return_text, _("Error: Option '--terse' is mutually exclusive with '--pretty'."));
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
else
nmc->print_output = NMC_PRINT_TERSE;
} else if (matches (opt, "-pretty") == 0) {
if (nmc->print_output == NMC_PRINT_PRETTY) {
g_string_printf (nmc->return_text, _("Error: Option '--pretty' is specified the second time."));
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
else if (nmc->print_output == NMC_PRINT_TERSE) {
g_string_printf (nmc->return_text, _("Error: Option '--pretty' is mutually exclusive with '--terse'."));
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
else
nmc->print_output = NMC_PRINT_PRETTY;
} else if (matches (opt, "-mode") == 0) {
nmc->mode_specified = TRUE;
next_arg (&argc, &argv);
if (argc <= 1) {
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
if (!strcmp (argv[1], "tabular"))
nmc->multiline_output = FALSE;
else if (!strcmp (argv[1], "multiline"))
nmc->multiline_output = TRUE;
else {
g_string_printf (nmc->return_text, _("Error: '%s' is not valid argument for '%s' option."), argv[1], opt);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
} else if (matches (opt, "-escape") == 0) {
next_arg (&argc, &argv);
if (argc <= 1) {
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
if (!strcmp (argv[1], "yes"))
nmc->escape_values = TRUE;
else if (!strcmp (argv[1], "no"))
nmc->escape_values = FALSE;
else {
g_string_printf (nmc->return_text, _("Error: '%s' is not valid argument for '%s' option."), argv[1], opt);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
} else if (matches (opt, "-fields") == 0) {
next_arg (&argc, &argv);
if (argc <= 1) {
g_string_printf (nmc->return_text, _("Error: fields for '%s' options are missing."), opt);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
nmc->required_fields = g_strdup (argv[1]);
} else if (matches (opt, "-version") == 0) {
printf (_("nmcli tool, version %s\n"), NMCLI_VERSION);
return NMC_RESULT_SUCCESS;
} else if (matches (opt, "-help") == 0) {
usage (base);
return NMC_RESULT_SUCCESS;
} else {
g_string_printf (nmc->return_text, _("Error: Option '%s' is unknown, try 'nmcli -help'."), opt);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
argc--;
argv++;
}
if (argc > 1)
return do_cmd (nmc, argv[1], argc-1, argv+1);
usage (base);
return nmc->return_value;
}
static void
signal_handler (int signo)
{
if (signo == SIGINT || signo == SIGTERM) {
g_message (_("Caught signal %d, shutting down..."), signo);
g_main_loop_quit (loop);
}
}
static void
setup_signals (void)
{
struct sigaction action;
sigset_t mask;
sigemptyset (&mask);
action.sa_handler = signal_handler;
action.sa_mask = mask;
action.sa_flags = 0;
sigaction (SIGTERM, &action, NULL);
sigaction (SIGINT, &action, NULL);
}
static NMClient *
nmc_get_client (NmCli *nmc)
{
if (!nmc->client) {
nmc->client = nm_client_new ();
if (!nmc->client) {
g_string_printf (nmc->return_text, _("Error: Could not connect to NetworkManager."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
}
}
return nmc->client;
}
/* Initialize NmCli structure - set default values */
static void
nmc_init (NmCli *nmc)
{
nmc->client = NULL;
nmc->get_client = &nmc_get_client;
nmc->return_value = NMC_RESULT_SUCCESS;
nmc->return_text = g_string_new (_("Success"));
nmc->timeout = 10;
nmc->system_settings = NULL;
nmc->user_settings = NULL;
nmc->system_settings_running = FALSE;
nmc->user_settings_running = FALSE;
nmc->system_connections = NULL;
nmc->user_connections = NULL;
nmc->should_wait = FALSE;
nmc->print_output = NMC_PRINT_NORMAL;
nmc->multiline_output = FALSE;
nmc->mode_specified = FALSE;
nmc->escape_values = TRUE;
nmc->required_fields = NULL;
nmc->allowed_fields = NULL;
memset (&nmc->print_fields, '\0', sizeof (NmcPrintFields));
}
static void
nmc_cleanup (NmCli *nmc)
{
if (nmc->client) g_object_unref (nmc->client);
g_string_free (nmc->return_text, TRUE);
if (nmc->system_settings) g_object_unref (nmc->system_settings);
if (nmc->user_settings) g_object_unref (nmc->user_settings);
g_slist_free (nmc->system_connections);
g_slist_free (nmc->user_connections);
g_free (nmc->required_fields);
if (nmc->print_fields.indices)
g_array_free (nmc->print_fields.indices, TRUE);
}
static gboolean
start (gpointer data)
{
ArgsInfo *info = (ArgsInfo *) data;
info->nmc->return_value = parse_command_line (info->nmc, info->argc, info->argv);
if (!info->nmc->should_wait)
g_main_loop_quit (loop);
return FALSE;
}
int
main (int argc, char *argv[])
{
NmCli nmc;
ArgsInfo args_info = { &nmc, argc, argv };
/* Set locale to use environment variables */
setlocale (LC_ALL, "");
#ifdef GETTEXT_PACKAGE
/* Set i18n stuff */
bindtextdomain (GETTEXT_PACKAGE, NMCLI_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
g_type_init ();
nmc_init (&nmc);
g_idle_add (start, &args_info);
loop = g_main_loop_new (NULL, FALSE); /* create main loop */
setup_signals (); /* setup UNIX signals */
g_main_loop_run (loop); /* run main loop */
/* Print result descripting text */
if (nmc.return_value != NMC_RESULT_SUCCESS) {
fprintf (stderr, "%s\n", nmc.return_text->str);
}
g_main_loop_unref (loop);
nmc_cleanup (&nmc);
return nmc.return_value;
}

114
cli/src/nmcli.h Normal file
View File

@@ -0,0 +1,114 @@
/* nmcli - command-line tool to control NetworkManager
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
#ifndef NMC_NMCLI_H
#define NMC_NMCLI_H
#include <glib.h>
#include <nm-client.h>
#include <nm-remote-settings.h>
#include <nm-remote-settings-system.h>
/* nmcli exit codes */
typedef enum {
/* Indicates successful execution */
NMC_RESULT_SUCCESS = 0,
/* Unknown / unspecified error */
NMC_RESULT_ERROR_UNKNOWN = 1,
/* Wrong invocation of nmcli */
NMC_RESULT_ERROR_USER_INPUT = 2,
/* A timeout expired */
NMC_RESULT_ERROR_TIMEOUT_EXPIRED = 3,
/* Error in connection activation */
NMC_RESULT_ERROR_CON_ACTIVATION = 4,
/* Error in connection deactivation */
NMC_RESULT_ERROR_CON_DEACTIVATION = 5,
/* Error in device disconnect */
NMC_RESULT_ERROR_DEV_DISCONNECT = 6
} NMCResultCode;
typedef enum {
NMC_PRINT_TERSE = 0,
NMC_PRINT_NORMAL = 1,
NMC_PRINT_PRETTY = 2
} NMCPrintOutput;
/* === Output fields === */
typedef struct {
const char *name; /* Field's name */
const char *name_l10n; /* Field's name for translation */
int width; /* Width in screen columns */
const char *value; /* Value of current field */
guint32 flags; /* Flags */
} NmcOutputField;
/* Flags for NmcPrintFields */
#define NMC_PF_FLAG_MULTILINE 0x00000001 /* Multiline output instead of tabular */
#define NMC_PF_FLAG_TERSE 0x00000002 /* Terse output mode */
#define NMC_PF_FLAG_PRETTY 0x00000004 /* Pretty output mode */
#define NMC_PF_FLAG_MAIN_HEADER_ADD 0x00000008 /* Print main header in addition to values/field names */
#define NMC_PF_FLAG_MAIN_HEADER_ONLY 0x00000010 /* Print main header only */
#define NMC_PF_FLAG_FIELD_NAMES 0x00000020 /* Print field names instead of values */
#define NMC_PF_FLAG_ESCAPE 0x00000040 /* Escape column separator and '\' */
#define NMC_PF_FLAG_SECTION_PREFIX 0x00000080 /* Use the first value as section prefix for the other field names - just in multiline */
typedef struct {
GArray *indices; /* Array of field indices to the array of allowed fields */
char *header_name; /* Name of the output */
int indent; /* Indent by this number of spaces */
guint32 flags; /* Various flags for controlling output: see NMC_PF_FLAG_* values */
} NmcPrintFields;
/* NmCli - main structure */
typedef struct _NmCli {
NMClient *client; /* Pointer to NMClient of libnm-glib */
NMClient *(*get_client) (struct _NmCli *nmc); /* Pointer to function for creating NMClient */
NMCResultCode return_value; /* Return code of nmcli */
GString *return_text; /* Reason text */
int timeout; /* Operation timeout */
NMRemoteSettingsSystem *system_settings; /* System settings */
NMRemoteSettings *user_settings; /* User settings */
gboolean system_settings_running; /* Is system settings service running? */
gboolean user_settings_running; /* Is user settings service running? */
GSList *system_connections; /* List of system connections */
GSList *user_connections; /* List of user connections */
gboolean should_wait; /* Indication that nmcli should not end yet */
NMCPrintOutput print_output; /* Output mode */
gboolean multiline_output; /* Multiline output instead of default tabular */
gboolean mode_specified; /* Whether tabular/multiline mode was specified via '--mode' option */
gboolean escape_values; /* Whether to escape ':' and '\' in terse tabular mode */
char *required_fields; /* Required fields in output: '--fields' option */
NmcOutputField *allowed_fields; /* Array of allowed fields for particular commands */
NmcPrintFields print_fields; /* Structure with field indices to print */
} NmCli;
#endif /* NMC_NMCLI_H */

1369
cli/src/settings.c Normal file

File diff suppressed because it is too large Load Diff

59
cli/src/settings.h Normal file
View File

@@ -0,0 +1,59 @@
/* nmcli - command-line tool to control NetworkManager
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
#ifndef NMC_SETTINGS_H
#define NMC_SETTINGS_H
#include <nm-setting-connection.h>
#include <nm-setting-wired.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 "nmcli.h"
#include "utils.h"
gboolean setting_connection_details (NMSetting *setting, NmCli *nmc);
gboolean setting_wired_details (NMSetting *setting, NmCli *nmc);
gboolean setting_802_1X_details (NMSetting *setting, NmCli *nmc);
gboolean setting_wireless_details (NMSetting *setting, NmCli *nmc);
gboolean setting_wireless_security_details (NMSetting *setting, NmCli *nmc);
gboolean setting_ip4_config_details (NMSetting *setting, NmCli *nmc);
gboolean setting_ip6_config_details (NMSetting *setting, NmCli *nmc);
gboolean setting_serial_details (NMSetting *setting, NmCli *nmc);
gboolean setting_ppp_details (NMSetting *setting, NmCli *nmc);
gboolean setting_pppoe_details (NMSetting *setting, NmCli *nmc);
gboolean setting_gsm_details (NMSetting *setting, NmCli *nmc);
gboolean setting_cdma_details (NMSetting *setting, NmCli *nmc);
gboolean setting_bluetooth_details (NMSetting *setting, NmCli *nmc);
gboolean setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc);
gboolean setting_vpn_details (NMSetting *setting, NmCli *nmc);
#endif /* NMC_SETTINGS_H */

298
cli/src/utils.c Normal file
View File

@@ -0,0 +1,298 @@
/* nmcli - command-line tool to control NetworkManager
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n.h>
#include "utils.h"
int
matches (const char *cmd, const char *pattern)
{
int len = strlen (cmd);
if (len > strlen (pattern))
return -1;
return memcmp (pattern, cmd, len);
}
int
next_arg (int *argc, char ***argv)
{
if (*argc <= 1) {
return -1;
}
else {
(*argc)--;
(*argv)++;
}
return 0;
}
/*
* Convert SSID to a printable form.
* If it is an UTF-8 string, enclose it in quotes and return it.
* Otherwise convert it to a hex string representation.
* Caller has to free the returned string using g_free()
*/
char *
ssid_to_printable (const char *str, gsize len)
{
GString *printable;
char *printable_str;
int i;
if (str == NULL || len == 0)
return NULL;
if (g_utf8_validate (str, len, NULL))
return g_strdup_printf ("'%.*s'", (int) len, str);
printable = g_string_new (NULL);
for (i = 0; i < len; i++) {
g_string_append_printf (printable, "%02X", (unsigned char) str[i]);
}
printable_str = g_string_free (printable, FALSE);
return printable_str;
}
/*
* Find out how many columns an UTF-8 string occupies on the screen
*/
int
nmc_string_screen_width (const char *start, const char *end)
{
int width = 0;
if (end == NULL)
end = start + strlen (start);
while (start < end) {
width += g_unichar_iswide (g_utf8_get_char (start)) ? 2 : g_unichar_iszerowidth (g_utf8_get_char (start)) ? 0 : 1;
start = g_utf8_next_char (start);
}
return width;
}
/*
* Parse comma separated fields in 'fields_str' according to 'fields_array'.
* IN: 'field_str': comma-separated fields names
* 'fields_array': array of allowed fields
* RETURN: GArray with indices representing fields in 'fields_array'.
* Caller is responsible to free it.
*/
GArray *
parse_output_fields (const char *fields_str, const NmcOutputField fields_array[], GError **error)
{
char **fields, **iter;
GArray *array;
int i;
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
array = g_array_new (FALSE, FALSE, sizeof (int));
/* Split supplied fields string */
fields = g_strsplit_set (fields_str, ",", -1);
for (iter = fields; iter && *iter; iter++) {
for (i = 0; fields_array[i].name; i++) {
if (strcasecmp (*iter, fields_array[i].name) == 0) {
g_array_append_val (array, i);
break;
}
}
if (fields_array[i].name == NULL) {
if (!strcasecmp (*iter, "all") || !strcasecmp (*iter, "common"))
g_set_error (error, 0, 0, _("field '%s' has to be alone"), *iter);
else
g_set_error (error, 0, 1, _("invalid field '%s'"), *iter);
g_array_free (array, TRUE);
array = NULL;
goto done;
}
}
done:
if (fields)
g_strfreev (fields);
return array;
}
gboolean
nmc_terse_option_check (NMCPrintOutput print_output, const char *fields, GError **error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (print_output == NMC_PRINT_TERSE) {
if (!fields) {
g_set_error (error, 0, 0, _("Option '--terse' requires specifying '--fields'"));
return FALSE;
} else if ( !strcasecmp (fields, "all")
|| !strcasecmp (fields, "common")) {
g_set_error (error, 0, 0, _("Option '--terse' requires specific '--fields' option values , not '%s'"), fields);
return FALSE;
}
}
return TRUE;
}
/*
* Print both headers or values of 'field_values' array.
* Entries to print and their order are specified via indices
* in 'fields.indices' array.
* 'fields.flags' specify various aspects influencing the output.
*/
void
print_fields (const NmcPrintFields fields, const NmcOutputField field_values[])
{
GString *str;
int width1, width2;
int table_width = 0;
char *line = NULL;
char *indent_str;
const char *value;
const char *not_set_str = _("not set");
int i, idx;
gboolean multiline = fields.flags & NMC_PF_FLAG_MULTILINE;
gboolean terse = fields.flags & NMC_PF_FLAG_TERSE;
gboolean pretty = fields.flags & NMC_PF_FLAG_PRETTY;
gboolean main_header_add = fields.flags & NMC_PF_FLAG_MAIN_HEADER_ADD;
gboolean main_header_only = fields.flags & NMC_PF_FLAG_MAIN_HEADER_ONLY;
gboolean field_names = fields.flags & NMC_PF_FLAG_FIELD_NAMES;
gboolean escape = fields.flags & NMC_PF_FLAG_ESCAPE;
gboolean section_prefix = fields.flags & NMC_PF_FLAG_SECTION_PREFIX;
gboolean main_header = main_header_add || main_header_only;
/* No headers are printed in terse mode:
* - neither main header nor field (column) names
*/
if ((main_header_only || field_names) && terse)
return;
if (multiline) {
/* --- Multiline mode --- */
enum { ML_HEADER_WIDTH = 79 };
if (main_header && pretty) {
/* Print the main header */
int header_width = nmc_string_screen_width (fields.header_name, NULL) + 4;
table_width = header_width < ML_HEADER_WIDTH ? ML_HEADER_WIDTH : header_width;
line = g_strnfill (ML_HEADER_WIDTH, '=');
width1 = strlen (fields.header_name);
width2 = nmc_string_screen_width (fields.header_name, NULL);
printf ("%s\n", line);
printf ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
printf ("%s\n", line);
g_free (line);
}
/* Print values */
if (!main_header_only && !field_names) {
for (i = 0; i < fields.indices->len; i++) {
char *tmp;
idx = g_array_index (fields.indices, int, i);
if (section_prefix && idx == 0) /* The first field is section prefix */
continue;
tmp = g_strdup_printf ("%s%s%s:", section_prefix ? field_values[0].value : "",
section_prefix ? "." : "",
_(field_values[idx].name_l10n));
printf ("%-*s%s\n", terse ? 0 : 32, tmp, field_values[idx].value ? field_values[idx].value : not_set_str);
g_free (tmp);
}
if (pretty) {
line = g_strnfill (ML_HEADER_WIDTH, '-');
printf ("%s\n", line);
g_free (line);
}
}
return;
}
/* --- Tabular mode: each line = one object --- */
str = g_string_new (NULL);
for (i = 0; i < fields.indices->len; i++) {
idx = g_array_index (fields.indices, int, i);
if (field_names)
value = _(field_values[idx].name_l10n);
else
value = field_values[idx].value ? field_values[idx].value : not_set_str;
if (terse) {
if (escape) {
const char *p = value;
while (*p) {
if (*p == ':' || *p == '\\')
g_string_append_c (str, '\\'); /* Escaping by '\' */
g_string_append_c (str, *p);
p++;
}
}
else
g_string_append_printf (str, "%s", value);
g_string_append_c (str, ':'); /* Column separator */
} else {
width1 = strlen (value);
width2 = nmc_string_screen_width (value, NULL); /* Width of the string (in screen colums) */
if (strlen (value) == 0)
value = "--";
g_string_append_printf (str, "%-*s", field_values[idx].width + width1 - width2, value);
g_string_append_c (str, ' '); /* Column separator */
table_width += field_values[idx].width + width1 - width2 + 1;
}
}
/* Print the main table header */
if (main_header && pretty) {
int header_width = nmc_string_screen_width (fields.header_name, NULL) + 4;
table_width = table_width < header_width ? header_width : table_width;
line = g_strnfill (table_width, '=');
width1 = strlen (fields.header_name);
width2 = nmc_string_screen_width (fields.header_name, NULL);
printf ("%s\n", line);
printf ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
printf ("%s\n", line);
g_free (line);
}
/* Print actual values */
if (!main_header_only && str->len > 0) {
g_string_truncate (str, str->len-1); /* Chop off last column separator */
if (fields.indent > 0) {
indent_str = g_strnfill (fields.indent, ' ');
g_string_prepend (str, indent_str);
g_free (indent_str);
}
printf ("%s\n", str->str);
}
/* Print horizontal separator */
if (!main_header_only && field_names && pretty) {
if (str->len > 0) {
line = g_strnfill (table_width, '-');
printf ("%s\n", line);
g_free (line);
}
}
g_string_free (str, TRUE);
}

36
cli/src/utils.h Normal file
View File

@@ -0,0 +1,36 @@
/* nmcli - command-line tool to control NetworkManager
*
* 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.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
#ifndef NMC_UTILS_H
#define NMC_UTILS_H
#include <glib.h>
#include "nmcli.h"
/* === Functions === */
int matches (const char *cmd, const char *pattern);
int next_arg (int *argc, char ***argv);
char *ssid_to_printable (const char *str, gsize len);
int nmc_string_screen_width (const char *start, const char *end);
GArray *parse_output_fields (const char *fields_str, const NmcOutputField fields_array[], GError **error);
gboolean nmc_terse_option_check (NMCPrintOutput print_output, const char *fields, GError **error);
void print_fields (const NmcPrintFields fields, const NmcOutputField field_values[]);
#endif /* NMC_UTILS_H */

View File

@@ -1,6 +1,6 @@
AC_PREREQ(2.52)
AC_INIT(NetworkManager, 0.7.997, dcbw@redhat.com, NetworkManager)
AC_INIT(NetworkManager, 0.8.0.997, dcbw@redhat.com, NetworkManager)
AM_INIT_AUTOMAKE([1.9 subdir-objects tar-ustar no-dist-gzip dist-bzip2])
AM_MAINTAINER_MODE
@@ -83,7 +83,7 @@ dnl Make sha1.c happy on big endian systems
dnl
AC_C_BIGENDIAN
AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo or mandriva]))
AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo, mandriva or pardus]))
if test "z$with_distro" = "z"; then
AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
@@ -94,6 +94,7 @@ if test "z$with_distro" = "z"; then
AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
AC_CHECK_FILE(/etc/frugalware-release,with_distro="frugalware")
AC_CHECK_FILE(/etc/mandriva-release,with_distro="mandriva")
AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
if test "z$with_distro" = "z"; then
with_distro=`lsb_release -is`
fi
@@ -105,7 +106,7 @@ if test "z$with_distro" = "z"; then
exit 1
else
case $with_distro in
redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva) ;;
redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus) ;;
*)
echo "Your distribution (${with_distro}) is not yet supported! (patches welcome)"
exit 1
@@ -158,6 +159,19 @@ if test x"$with_distro" = xmandriva; then
AC_DEFINE(TARGET_MANDRIVA, 1, [Define if you have Mandriva])
fi
AM_CONDITIONAL(TARGET_PARDUS, test x"$with_distro" = xpardus)
if test x"$with_distro" = xpardus; then
AC_DEFINE(TARGET_PARDUS, 1, [Define if you have Pardus])
fi
dnl
dnl Distribution version string
dnl
AC_ARG_WITH(dist-version, AS_HELP_STRING([--with-dist-version=<NM-distribution-version>], [Define the NM's distribution version string]), ac_distver=$withval, ac_distver="")
if ! test x"$ac_distver" = x""; then
AC_DEFINE_UNQUOTED(NM_DIST_VERSION, "$ac_distver", [Define the distribution version string])
fi
AC_MSG_CHECKING([Linux Wireless Extensions >= 18])
AC_TRY_COMPILE([#ifndef __user
#define __user
@@ -284,71 +298,77 @@ AC_ARG_WITH([pppd-plugin-dir], AS_HELP_STRING([--with-pppd-plugin-dir=DIR], [pat
if test -n "$with_pppd_plugin_dir" ; then
PPPD_PLUGIN_DIR="$with_pppd_plugin_dir"
else
PPPD_PLUGIN_DIR="${libdir}/pppd/2.4.4"
PPPD_PLUGIN_DIR="${libdir}/pppd/2.4.5"
fi
AC_SUBST(PPPD_PLUGIN_DIR)
# DHCP client
AC_ARG_WITH([dhcp-client], AS_HELP_STRING([--with-dhcp-client=dhcpcd|dhclient], [path to the chosen dhcp client]))
# dhclient support
AC_ARG_WITH([dhclient], AS_HELP_STRING([--with-dhclient=yes|no|path], [Enable dhclient 4.x support]))
# If a full path is given, use that and do not test if it works or not.
case "${with_dhcp_client}" in
case "${with_dhclient}" in
/*)
DHCP_CLIENT_PATH="${with_dhcp_client}"
AC_MSG_NOTICE(using the DHCP client ${DHCP_CLIENT_PATH})
DHCLIENT_PATH="${with_dhclient}"
AC_MSG_NOTICE(using dhclient at ${DHCLIENT_PATH})
;;
no) AC_MSG_NOTICE(dhclient support disabled)
;;
*)
AC_MSG_CHECKING(for dhclient)
# NM only works with ISC dhclient - other derivatives don't have
# the same userland. NM also requires dhclient 4.x since older
# versions do not have IPv6 support.
for path in /sbin /usr/sbin /usr/pkg/sbin /usr/local/sbin; do
test -x "${path}/dhclient" || continue
case `"$path/dhclient" --version 2>&1` in
"isc-dhclient-4"*) DHCLIENT_PATH="$path/dhclient"; break;;
esac
done
if test -n "${DHCLIENT_PATH}"; then
AC_MSG_RESULT($DHCLIENT_PATH)
else
AC_MSG_RESULT(no)
fi
;;
esac
if test -z "$DHCP_CLIENT_PATH" -a \( -z "$with_dhcp_client" -o x`basename "$with_dhcp_client"` = "xdhclient" \); then
# We only work with ISC dhclient - the FreeBSD and OpenBSD derivatives don't have the same userland.
AC_MSG_CHECKING(for dhclient)
for client in "$with_dhcp_client" /sbin/dhclient /usr/pkg/sbin/dhclient /usr/local/sbin/dhclient; do
test -x "$client" || continue
case `"$client" --version 2>&1` in
"isc-dhclient-"*) DHCP_CLIENT_PATH="$client"; break;;
esac
done
if test -z "$DHCP_CLIENT_PATH"; then
AC_MSG_RESULT(no)
if test -n "$with_dhcp_client"; then
AC_MSG_ERROR([Could not find ISC dhclient])
fi
else
AC_MSG_RESULT($DHCP_CLIENT_PATH)
fi
fi
if test -z "$DHCP_CLIENT_PATH" -a \( -z "$with_dhcp_client" -o x`basename "$with_dhcp_client"` = "xdhcpcd" \); then
test -n "$DHCP_CLIENT_PATH" && echo bar
# dhcpcd support
AC_ARG_WITH([dhcpcd], AS_HELP_STRING([--with-dhcpcd=yes|no|path], [Enable dhcpcd 4.x support]))
# If a full path is given, use that and do not test if it works or not.
case "${with_dhcpcd}" in
/*)
DHCPCD_PATH="${with_dhcpcd}"
AC_MSG_NOTICE(using dhcpcd at ${DHCPCD_PATH})
;;
no) AC_MSG_NOTICE(dhcpcd support disabled)
;;
*)
AC_MSG_CHECKING(for dhcpcd)
# We fully work with upstream dhcpcd-4
AC_MSG_CHECKING([for dhcpcd])
for client in "$with_dhcp_client" /sbin/dhcpcd /usr/pkg/sbin/dhcpcd /usr/local/sbin/dhcpcd; do
test -x "$client" || continue
case `"$client" --version 2>/dev/null` in
for path in /sbin /usr/sbin /usr/pkg/sbin /usr/local/sbin; do
test -x "${path}/dhclient" || continue
case `"$path/dhcpcd" --version 2>/dev/null` in
"dhcpcd "[123]*);;
"dhcpcd "*) DHCP_CLIENT_PATH="$client"; break;;
"dhcpcd "*) DHCP_CLIENT_PATH="$path/dhcpcd"; break;;
esac
done
if test -z "$DHCP_CLIENT_PATH"; then
AC_MSG_RESULT(no)
if test -n "$with_dhcp_client"; then
AC_MSG_ERROR([Could not find dhcpcd-4 or newer])
fi
if test -n "${DHCPCD_PATH}"; then
AC_MSG_RESULT($DHCPCD_PATH)
else
AC_MSG_RESULT($DHCP_CLIENT_PATH)
AC_MSG_RESULT(no)
fi
fi
if test -z "$DHCP_CLIENT_PATH"; then
;;
esac
if test -z "$DHCPCD_PATH" -a -z "$DHCLIENT_PATH"; then
# DHCP clients are not a build time dependency, only runtime.
# dhclient has been the longtime default for NM and it's in /sbin
# in most distros, so use it.
AC_MSG_WARN([Could not find a suitable DHCP client])
DHCP_CLIENT_PATH=/sbin/dhclient
DHCLIENT_PATH=/sbin/dhclient
AC_MSG_WARN([Falling back to ISC dhclient, ${DHCP_CLIENT_PATH}])
fi
AC_SUBST(DHCP_CLIENT_PATH)
DHCP_CLIENT=`basename "$DHCP_CLIENT_PATH"`
if test "$DHCP_CLIENT" != "dhclient" -a "$DHCP_CLIENT" != "dhcpcd"; then
AC_MSG_ERROR([No backend for the DHCP client ${DHCP_CLIENT}])
fi
AC_SUBST(DHCP_CLIENT)
AC_SUBST(DHCLIENT_PATH)
AC_SUBST(DHCPCD_PATH)
# resolvconf support
AC_ARG_WITH([resolvconf],
@@ -430,6 +450,7 @@ include/Makefile
src/Makefile
src/tests/Makefile
marshallers/Makefile
src/logging/Makefile
src/named-manager/Makefile
src/vpn-manager/Makefile
src/dhcp-manager/Makefile
@@ -463,6 +484,8 @@ system-settings/plugins/keyfile/Makefile
system-settings/plugins/keyfile/io/Makefile
system-settings/plugins/keyfile/tests/Makefile
system-settings/plugins/keyfile/tests/keyfiles/Makefile
cli/Makefile
cli/src/Makefile
test/Makefile
initscript/Makefile
initscript/RedHat/Makefile
@@ -484,23 +507,41 @@ initscript/Mandriva/networkmanager
introspection/Makefile
man/Makefile
man/NetworkManager.8
man/NetworkManager.conf.5
man/nm-system-settings.conf.5
man/nm-tool.1
man/nmcli.1
po/Makefile.in
policy/Makefile
docs/Makefile
docs/libnm-glib/Makefile
docs/libnm-util/Makefile
NetworkManager.pc
examples/Makefile
examples/python/Makefile
])
AC_OUTPUT
echo
echo Distribution targeting: ${with_distro}
echo Distribution target: ${with_distro}
echo 'if this is not correct, please specifiy your distro with --with-distro=DISTRO'
echo
echo Building documentation: ${with_docs}
if test -n "${DHCLIENT_PATH}"; then
echo ISC dhclient support: ${DHCLIENT_PATH}
else
echo ISC dhclient support: no
fi
if test -n "${DHCPCD_PATH}"; then
echo dhcpcd support: ${DHCPCD_PATH}
else
echo dhcpcd support: no
fi
echo
echo Building documentation: ${with_docs}
echo Building tests: ${with_tests}
echo

View File

@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2009 Red Hat, Inc.
* (C) Copyright 2009 - 2010 Red Hat, Inc.
*/
#include <stdio.h>
@@ -86,7 +86,7 @@ static TypeNameElement name_map[] = {
{ "GPtrArray_GArray_guint__", "array of array of uint32" },
{ "GPtrArray_GArray_guchar__", "array of byte array" },
{ "GHashTable_gchararray+gchararray_", "dict of (string::string)" },
{ "GPtrArray_GValueArray_GArray_guchar_+guint__", "array of (byte array, uint32)" },
{ "GPtrArray_GValueArray_GArray_guchar_+guint+GArray_guchar___", "array of (byte array, uint32, byte array)" },
{ "GPtrArray_GValueArray_GArray_guchar_+guint+GArray_guchar_+guint__", "array of (byte array, uint32, byte array, uint32)" },
{ NULL, NULL }
};
@@ -128,6 +128,7 @@ write_one_setting (FILE *f, SettingNewFunc func)
value_desc = g_param_spec_get_blurb (*iter);
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (*iter));
g_param_value_set_default (*iter, &value);
default_value = g_strdup_value_contents (&value);
if (default_value && !strcmp (default_value, "NULL")) {
g_free (default_value);

View File

@@ -34,23 +34,26 @@ IGNORE_HFILES= \
nm-device-private.h \
nm-object-cache.h \
nm-object-private.h \
nm-remote-connection-private.h \
nm-types-private.h \
nm-access-point-bindings.h \
nm-active-connection-bindings.h \
nm-client-bindings.h \
nm-device-bindings.h \
nm-device-bt-bindings.h \
nm-device-ethernet-bindings.h \
nm-device-wifi-bindings.h \
nm-exported-connection-glue.h \
nm-dhcp4-config-bindings.h \
nm-dhcp6-config-bindings.h \
nm-exported-connection-bindings.h \
nm-settings-glue.h \
nm-exported-connection-glue.h \
nm-ip4-config-bindings.h \
nm-ip6-config-bindings.h \
nm-settings-bindings.h \
nm-settings-glue.h \
nm-settings-system-bindings.h \
nm-vpn-connection-bindings.h \
nm-vpn-plugin-glue.h \
nm-active-connection-bindings.h \
nm-ip4-config-bindings.h \
nm-dhcp4-config-bindings.h \
nm-ip4-config-bindings.h
nm-vpn-plugin-glue.h
# Images to copy into HTML directory.
HTML_IMAGES =

View File

@@ -5,35 +5,40 @@
<bookinfo>
<title>libnm-glib Reference Manual</title>
<releaseinfo>
for libnm-glib [VERSION]
for libnm-glib 0.8
The latest version of this documentation can be found on-line at
<ulink role="online-location" url="http://[SERVER]/libnm-glib/index.html">http://[SERVER]/libnm-glib/</ulink>.
<ulink role="online-location" url="http://projects.gnome.org/NetworkManager/developers/libnm-glib/08/">http://projects.gnome.org/NetworkManager/developers/libnm-glib/08/</ulink>.
</releaseinfo>
</bookinfo>
<chapter>
<title>[Insert title here]</title>
<xi:include href="xml/nm-access-point.xml"/>
<xi:include href="xml/nm-cdma-device.xml"/>
<title>libnm-glib Objects</title>
<xi:include href="xml/nm-client.xml"/>
<xi:include href="xml/nm-gsm-device.xml"/>
<xi:include href="xml/nm-device.xml"/>
<xi:include href="xml/nm-ip4-config.xml"/>
<xi:include href="xml/nm-ip6-config.xml"/>
<xi:include href="xml/nm-object.xml"/>
<xi:include href="xml/nm-settings.xml"/>
<xi:include href="xml/nm-vpn-connection.xml"/>
<xi:include href="xml/nm-vpn-plugin.xml"/>
<xi:include href="xml/nm-dbus-settings-system.xml"/>
<xi:include href="xml/nm-active-connection.xml"/>
<xi:include href="xml/nm-device.xml"/>
<xi:include href="xml/nm-device-ethernet.xml"/>
<xi:include href="xml/nm-device-wifi.xml"/>
<xi:include href="xml/nm-dbus-connection.xml"/>
<xi:include href="xml/nm-serial-device.xml"/>
<xi:include href="xml/nm-dbus-settings.xml"/>
<xi:include href="xml/nm-gsm-device.xml"/>
<xi:include href="xml/nm-cdma-device.xml"/>
<xi:include href="xml/nm-device-bt.xml"/>
<xi:include href="xml/nm-access-point.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-vpn-plugin-ui-interface.xml"/>
<xi:include href="xml/libnm_glib.xml"/>
<xi:include href="xml/nm-dhcp6-config.xml"/>
<xi:include href="xml/nm-exported-connection.xml"/>
<xi:include href="xml/nm-object.xml"/>
<xi:include href="xml/nm-remote-connection.xml"/>
<xi:include href="xml/nm-remote-settings.xml"/>
<xi:include href="xml/nm-remote-settings-system.xml"/>
<xi:include href="xml/nm-settings-connection-interface.xml"/>
<xi:include href="xml/nm-settings-interface.xml"/>
<xi:include href="xml/nm-settings-service.xml"/>
<xi:include href="xml/nm-settings-system-interface.xml"/>
<xi:include href="xml/nm-types.xml"/>
<xi:include href="xml/nm-vpn-connection.xml"/>
<xi:include href="xml/nm-vpn-plugin.xml"/>
<xi:include href="xml/nm-vpn-plugin-ui-interface.xml"/>
</chapter>
</book>

View File

@@ -8,9 +8,9 @@
<bookinfo>
<title>libnm-util Reference Manual</title>
<releaseinfo>
for libnm-util [VERSION]
for libnm-util 0.8
The latest version of this documentation can be found on-line at
<ulink role="online-location" url="http://[SERVER]/libnm-util/index.html">http://[SERVER]/libnm-util/</ulink>.
<ulink role="online-location" url="http://projects.gnome.org/NetworkManager/developers/libnm-util/08/">http://projects.gnome.org/NetworkManager/developers/libnm-util/08/</ulink>.
</releaseinfo>
</bookinfo>

1
examples/Makefile.am Normal file
View File

@@ -0,0 +1 @@
SUBDIRS=python

View File

@@ -0,0 +1,8 @@
EXTRA_DIST = \
nm-state.py \
add-system-connection.py \
vpn.py \
list-connections.py \
show-bssids.py

View File

@@ -0,0 +1,48 @@
#!/bin/env python
#
# 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 (C) 2010 Red Hat, Inc.
#
import dbus
s_wired = dbus.Dictionary({'duplex': 'full'})
s_con = dbus.Dictionary({
'type': '802-3-ethernet',
'uuid': '7371bb78-c1f7-42a3-a9db-5b9566e8ca07',
'id': 'MyConnection'})
addr1 = dbus.Array([dbus.UInt32(50462986L), dbus.UInt32(8L), dbus.UInt32(16908554L)], signature=dbus.Signature('u'))
s_ip4 = dbus.Dictionary({
'addresses': dbus.Array([addr1], signature=dbus.Signature('au')),
'method': 'manual'})
s_ip6 = dbus.Dictionary({'method': 'ignore'})
con = dbus.Dictionary({
'802-3-ethernet': s_wired,
'connection': s_con,
'ipv4': s_ip4,
'ipv6': s_ip6})
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManagerSystemSettings", "/org/freedesktop/NetworkManagerSettings")
settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
settings.AddConnection(con)

View File

@@ -0,0 +1,112 @@
#!/bin/env python
#
# 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 (C) 2010 Red Hat, Inc.
#
import dbus
# This example asks both the system settings service and the user settings
# service for all configured connections. It also asks for secrets, demonstrating
# the mechanisms each settings service uses to prevent unauthorized access to
# a user's network passwords
bus = dbus.SystemBus()
def merge_secrets(proxy, config, setting_name):
try:
# returns a dict of dicts mapping name::setting, where setting is a dict
# mapping key::value. Each member of the 'setting' dict is a secret
secrets = proxy.GetSecrets(setting_name, [], False)
# Copy the secrets into our connection config
for setting in secrets:
for key in secrets[setting]:
config[setting_name][key] = setting[key]
except Exception, e:
pass
def dict_to_string(d, indent):
# Try to trivially translate a dictionary's elements into nice string
# formatting.
dstr = ""
for key in d:
val = d[key]
str_val = ""
add_string = True
if type(val) == type(dbus.Array([])):
for elt in val:
if type(elt) == type(dbus.Byte(1)):
str_val += "%s " % int(elt)
elif type(elt) == type(dbus.String("")):
str_val += "%s" % elt
elif type(val) == type(dbus.Dictionary({})):
dstr += dict_to_string(val, indent + " ")
add_string = False
else:
str_val = val
if add_string:
dstr += "%s%s: %s\n" % (indent, key, str_val)
return dstr
def connection_to_string(config):
# dump a connection configuration to a the console
for setting_name in config:
print " Setting: %s" % setting_name
print dict_to_string(config[setting_name], " ")
print ""
def print_one_services_connections(service_name, desc):
# Ask the settings service for the list of connections it provides
proxy = bus.get_object(service_name, "/org/freedesktop/NetworkManagerSettings")
settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
connection_paths = settings.ListConnections()
print "%s connections --------------------------------------------\n" % desc
# List each connection's name, UUID, and type
for path in connection_paths:
con_proxy = bus.get_object(service_name, path)
connection = dbus.Interface(con_proxy, "org.freedesktop.NetworkManagerSettings.Connection")
config = connection.GetSettings()
# Now get secrets too; we grab the secrets for each type of connection
# (since there isn't a "get all secrets" call because most of the time
# you only need 'wifi' secrets or '802.1x' secrets, not everything) and
# merge that into the configuration data
connection_secrets = dbus.Interface(con_proxy, "org.freedesktop.NetworkManagerSettings.Connection.Secrets")
merge_secrets(connection_secrets, config, '802-11-wireless')
merge_secrets(connection_secrets, config, '802-11-wireless-security')
merge_secrets(connection_secrets, config, '802-1x')
merge_secrets(connection_secrets, config, 'gsm')
merge_secrets(connection_secrets, config, 'cdma')
merge_secrets(connection_secrets, config, 'ppp')
# Get the details of the 'connection' setting
s_con = config['connection']
print "name: %s" % s_con['id']
print " uuid: %s" % s_con['uuid']
print " type: %s" % s_con['type']
print " ----------------------------"
connection_to_string(config)
print ""
# Print out connection information for all connections
print_one_services_connections("org.freedesktop.NetworkManagerSystemSettings", "System")
print_one_services_connections("org.freedesktop.NetworkManagerUserSettings", "User")

View File

@@ -0,0 +1,69 @@
#!/bin/env python
#
# 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 (C) 2010 Red Hat, Inc.
#
import dbus
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")
# Get device-specific state
devices = manager.GetDevices()
for d in devices:
dev_proxy = bus.get_object("org.freedesktop.NetworkManager", d)
prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties")
# Get the device's current state and interface name
state = prop_iface.Get("org.freedesktop.NetworkManager.Device", "State")
name = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface")
# and print them out
if state == 8: # activated
print "Device %s is activated" % name
else:
print "Device %s is not activated" % name
# Get active connection state
manager_prop_iface = dbus.Interface(proxy, "org.freedesktop.DBus.Properties")
active = manager_prop_iface.Get("org.freedesktop.NetworkManager", "ActiveConnections")
for a in active:
ac_proxy = bus.get_object("org.freedesktop.NetworkManager", a)
prop_iface = dbus.Interface(ac_proxy, "org.freedesktop.DBus.Properties")
state = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "State")
# Connections in NM are a collection of settings that describe everything
# needed to connect to a specific network. Lets get those details so we
# can find the user-readable name of the connection.
con_path = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "Connection")
con_service = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "ServiceName")
# ask the provider of the connection for its details
service_proxy = bus.get_object(con_service, con_path)
con_iface = dbus.Interface(service_proxy, "org.freedesktop.NetworkManagerSettings.Connection")
con_details = con_iface.GetSettings()
con_name = con_details['connection']['id']
if state == 2: # activated
print "Connection '%s' is activated" % con_name
else:
print "Connection '%s' is activating" % con_name

View File

@@ -0,0 +1,78 @@
#!/bin/env python
#
# 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 (C) 2010 Red Hat, Inc.
#
# This example prints out all the AP BSSIDs that all WiFi devices on the
# machine can see. Useful for location-based services like Skyhook that
# can geolocate you based on the APs you can see.
import dbus
bus = dbus.SystemBus()
# Get a proxy for the base NetworkManager object
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")
all_aps = []
print "Associated APs:"
# Get all network devices
devices = manager.GetDevices()
for d in devices:
dev_proxy = bus.get_object("org.freedesktop.NetworkManager", d)
prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties")
# Make sure the device is enabled before we try to use it
state = prop_iface.Get("org.freedesktop.NetworkManager.Device", "State")
if state <= 2:
continue
# Get device's type; we only want wifi devices
iface = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface")
dtype = prop_iface.Get("org.freedesktop.NetworkManager.Device", "DeviceType")
if dtype == 2: # WiFi
# Get a proxy for the wifi interface
wifi_iface = dbus.Interface(dev_proxy, "org.freedesktop.NetworkManager.Device.Wireless")
wifi_prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties")
# Get the associated AP's object path
connected_path = wifi_prop_iface.Get("org.freedesktop.NetworkManager.Device.Wireless", "ActiveAccessPoint")
# Get all APs the card can see
aps = wifi_iface.GetAccessPoints()
for path in aps:
ap_proxy = bus.get_object("org.freedesktop.NetworkManager", path)
ap_prop_iface = dbus.Interface(ap_proxy, "org.freedesktop.DBus.Properties")
bssid = ap_prop_iface.Get("org.freedesktop.NetworkManager.AccessPoint", "HwAddress")
# Cache the BSSID
if not bssid in all_aps:
all_aps.append(bssid)
# Print the current AP's BSSID
if path == connected_path:
print "%s (%s)" % (bssid, iface)
# and print out all APs the wifi devices can see
print"\nFound APs:"
for bssid in all_aps:
print bssid

152
examples/python/vpn.py Normal file
View File

@@ -0,0 +1,152 @@
#!/usr/bin/python
#
# 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 (C) 2009 Novell, Inc.
# Copyright (C) 2009 Red Hat, Inc.
#
# Run this script without any arguments to list the available connection uuids.
# The uuid of the connection to activate
CONNECTION_UUID="ac6dc9b2-85ef-4311-83d8-add5d7db3f59"
# UID to use. Note that NM only allows the owner of the connection to activate it.
#UID=1000
UID=0
import sys
import os
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import gobject
DBusGMainLoop(set_as_default=True)
def get_connections():
bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', '/org/freedesktop/NetworkManagerSettings')
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings')
return iface.ListConnections()
def get_connection_by_uuid(uuid):
bus = dbus.SystemBus()
for c in get_connections():
proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', c)
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
settings = iface.GetSettings()
if settings['connection']['uuid'] == uuid:
return c
return None
def list_uuids():
bus = dbus.SystemBus()
for c in get_connections():
proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', c)
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
settings = iface.GetSettings()
conn = settings['connection']
print "%s - %s (%s)" % (conn['uuid'], conn['id'], conn['type'])
def get_active_connection_path(uuid):
bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
active_connections = iface.Get('org.freedesktop.NetworkManager', 'ActiveConnections')
all_connections = get_connections()
for a in active_connections:
proxy = bus.get_object('org.freedesktop.NetworkManager', a)
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
path = iface.Get('org.freedesktop.NetworkManager.Connection.Active', 'Connection')
proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', path)
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
settings = iface.GetSettings()
if settings['connection']['uuid'] == uuid:
return a
return None
def get_wifi_device_path():
bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager')
devices = iface.GetDevices()
for d in devices:
proxy = bus.get_object('org.freedesktop.NetworkManager', d)
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
devtype = iface.Get('org.freedesktop.NetworkManager.Device', 'DeviceType')
if devtype == 2:
return d
return None
def activate_connection(connection_path, device_path):
def reply_handler(opath):
print "Success: device activating"
sys.exit(0)
def error_handler(*args):
print "Error activating device: %s" % args
sys.exit(1)
bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager')
iface.ActivateConnection('org.freedesktop.NetworkManagerUserSettings',
connection_path,
device_path,
"/",
reply_handler=reply_handler,
error_handler=error_handler)
# Change the UID first if required
if UID != 0:
os.setuid(UID)
# Are we configured?
if not len(CONNECTION_UUID):
print "missing connection UUID"
sys.exit(0)
connection_path = get_connection_by_uuid(CONNECTION_UUID)
if not connection_path:
# Configured VPN connection is not known to NM, check CONNECTION_UUID.
print "couldn't find the connection"
sys.exit(1)
device_path = get_wifi_device_path()
if not device_path:
print "no wifi device found"
sys.exit(1)
# Is it already activated?
if get_active_connection_path(CONNECTION_UUID):
print "already connected"
sys.exit(0)
print "Activating connection..."
activate_connection(connection_path, device_path)
loop = gobject.MainLoop()
loop.run()

View File

@@ -45,6 +45,7 @@
#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_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings"
@@ -244,130 +245,136 @@ typedef enum {
NM_DEVICE_STATE_REASON_NONE = 0,
/* Unknown error */
NM_DEVICE_STATE_REASON_UNKNOWN,
NM_DEVICE_STATE_REASON_UNKNOWN = 1,
/* Device is now managed */
NM_DEVICE_STATE_REASON_NOW_MANAGED,
NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
/* Device is now managed unmanaged */
NM_DEVICE_STATE_REASON_NOW_UNMANAGED,
NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
/* The device could not be readied for configuration */
NM_DEVICE_STATE_REASON_CONFIG_FAILED,
NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4,
/* IP configuration could not be reserved (no available address, timeout, etc) */
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE,
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5,
/* The IP config is no longer valid */
NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED,
NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6,
/* Secrets were required, but not provided */
NM_DEVICE_STATE_REASON_NO_SECRETS,
NM_DEVICE_STATE_REASON_NO_SECRETS = 7,
/* 802.1x supplicant disconnected */
NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT,
NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8,
/* 802.1x supplicant configuration failed */
NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED,
NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9,
/* 802.1x supplicant failed */
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED,
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10,
/* 802.1x supplicant took too long to authenticate */
NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT,
NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11,
/* PPP service failed to start */
NM_DEVICE_STATE_REASON_PPP_START_FAILED,
NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12,
/* PPP service disconnected */
NM_DEVICE_STATE_REASON_PPP_DISCONNECT,
NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13,
/* PPP failed */
NM_DEVICE_STATE_REASON_PPP_FAILED,
NM_DEVICE_STATE_REASON_PPP_FAILED = 14,
/* DHCP client failed to start */
NM_DEVICE_STATE_REASON_DHCP_START_FAILED,
NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15,
/* DHCP client error */
NM_DEVICE_STATE_REASON_DHCP_ERROR,
NM_DEVICE_STATE_REASON_DHCP_ERROR = 16,
/* DHCP client failed */
NM_DEVICE_STATE_REASON_DHCP_FAILED,
NM_DEVICE_STATE_REASON_DHCP_FAILED = 17,
/* Shared connection service failed to start */
NM_DEVICE_STATE_REASON_SHARED_START_FAILED,
NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18,
/* Shared connection service failed */
NM_DEVICE_STATE_REASON_SHARED_FAILED,
NM_DEVICE_STATE_REASON_SHARED_FAILED = 19,
/* AutoIP service failed to start */
NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED,
NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20,
/* AutoIP service error */
NM_DEVICE_STATE_REASON_AUTOIP_ERROR,
NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21,
/* AutoIP service failed */
NM_DEVICE_STATE_REASON_AUTOIP_FAILED,
NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22,
/* The line is busy */
NM_DEVICE_STATE_REASON_MODEM_BUSY,
NM_DEVICE_STATE_REASON_MODEM_BUSY = 23,
/* No dial tone */
NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE,
NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24,
/* No carrier could be established */
NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER,
NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25,
/* The dialing request timed out */
NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT,
NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26,
/* The dialing attempt failed */
NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED,
NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27,
/* Modem initialization failed */
NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED,
NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28,
/* Failed to select the specified APN */
NM_DEVICE_STATE_REASON_GSM_APN_FAILED,
NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29,
/* Not searching for networks */
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING,
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30,
/* Network registration denied */
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED,
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31,
/* Network registration timed out */
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT,
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32,
/* Failed to register with the requested network */
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED,
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33,
/* PIN check failed */
NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED,
NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34,
/* Necessary firmware for the device may be missing */
NM_DEVICE_STATE_REASON_FIRMWARE_MISSING,
NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35,
/* The device was removed */
NM_DEVICE_STATE_REASON_REMOVED,
NM_DEVICE_STATE_REASON_REMOVED = 36,
/* NetworkManager went to sleep */
NM_DEVICE_STATE_REASON_SLEEPING,
NM_DEVICE_STATE_REASON_SLEEPING = 37,
/* The device's active connection disappeared */
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38,
/* Device disconnected by user or client */
NM_DEVICE_STATE_REASON_USER_REQUESTED,
NM_DEVICE_STATE_REASON_USER_REQUESTED = 39,
/* Carrier/link changed */
NM_DEVICE_STATE_REASON_CARRIER,
NM_DEVICE_STATE_REASON_CARRIER = 40,
/* The device's existing connection was assumed */
NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED,
NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41,
/* The supplicant is now available */
NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE,
NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42,
/* The modem could not be found */
NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43,
/* The Bluetooth connection failed or timed out */
NM_DEVICE_STATE_REASON_BT_FAILED = 44,
/* Unused */
NM_DEVICE_STATE_REASON_LAST = 0xFFFF

View File

@@ -34,7 +34,7 @@
#define DBUS_TYPE_G_MAP_OF_STRING (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
#define DBUS_TYPE_G_LIST_OF_STRING (dbus_g_type_get_collection ("GSList", G_TYPE_STRING))
#define DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
#define DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_INVALID))
#define DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ADDRESS))
#define DBUS_TYPE_G_IP6_ROUTE (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
#define DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ROUTE))

View File

@@ -24,6 +24,7 @@ EXTRA_DIST = \
nm-ppp-manager.xml \
nm-active-connection.xml \
nm-dhcp4-config.xml \
nm-dhcp6-config.xml \
nm-wimax-device.xml \
nm-wimax-nsp.xml

View File

@@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
<xi:include href="nm-ip4-config.xml"/>
<xi:include href="nm-ip6-config.xml"/>
<xi:include href="nm-dhcp4-config.xml"/>
<xi:include href="nm-dhcp6-config.xml"/>
<xi:include href="nm-settings.xml"/>
<xi:include href="nm-exported-connection.xml"/>
<xi:include href="nm-active-connection.xml"/>

View File

@@ -18,7 +18,10 @@
<tp:docstring>The state of this active connection.</tp:docstring>
</property>
<property name="Default" type="b" access="read">
<tp:docstring>Whether this active connection is the default connection, i.e. whether it currently owns the default route.</tp:docstring>
<tp:docstring>Whether this active connection is the default IPv4 connection, i.e. whether it currently owns the default IPv4 route.</tp:docstring>
</property>
<property name="Default6" type="b" access="read">
<tp:docstring>Whether this active connection is the default IPv6 connection, i.e. whether it currently owns the default IPv6 route.</tp:docstring>
</property>
<property name="Vpn" type="b" access="read">
<tp:docstring>Whether this active connection is also a VPN connection.</tp:docstring>

View File

@@ -7,12 +7,14 @@
The hardware address of the device.
</tp:docstring>
</property>
<property name="Companion" type="s" access="read">
<property name="Companion" type="o" access="read">
<tp:docstring>
The object path of the companion device.
</tp:docstring>
</property>
<property name="ActiveChannel" type="o" access="read">
<property name="ActiveChannel" type="u" access="read">
<tp:docstring>
The currently active channel.
</tp:docstring>

View File

@@ -392,6 +392,16 @@
The 802.1x supplicant is now available.
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="MODEM_NOT_FOUND" value="43">
<tp:docstring>
The modem could not be found.
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="BT_FAILED" value="44">
<tp:docstring>
The Bluetooth connection timed out or failed.
</tp:docstring>
</tp:enumvalue>
</tp:enum>
</interface>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.DHCP6Config">
<tp:docstring>
Options and configuration returned by the IPv6 DHCP server.
</tp:docstring>
<property name="Options" type="a{sv}" access="read">
<tp:docstring>Configuration options returned by a DHCP server, if any.</tp:docstring>
</property>
<signal name="PropertiesChanged">
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
<tp:docstring>
A dictionary mapping property names to variant boxed values
</tp:docstring>
</arg>
</signal>
</interface>
</node>

View File

@@ -46,7 +46,7 @@
</tp:docstring>
<arg name="settings" type="a{sa{sv}}" tp:type="String_String_Variant_Map_Map">
<tp:docstring>
Contains the changed settings.
Contains complete connection setting parameters, including changes.
</tp:docstring>
</arg>
</signal>

View File

@@ -2,8 +2,8 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.IP6Config">
<property name="Addresses" type="a(ayu)" access="read">
<tp:docstring>Tuples of IPv6 address/prefix.</tp:docstring>
<property name="Addresses" type="a(ayuay)" access="read">
<tp:docstring>Tuples of IPv6 address/prefix/gateway.</tp:docstring>
</property>
<property name="Nameservers" type="aay" access="read">
<tp:docstring>The nameservers in use.</tp:docstring>

View File

@@ -96,6 +96,28 @@
</arg>
</method>
<method name="SetLogging">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_set_logging"/>
<tp:docstring>
Set logging verbosity and which operations are logged.
</tp:docstring>
<arg name="level" type="s" direction="in">
<tp:docstring>
One of [ERR, WARN, INFO, DEBUG].
</tp:docstring>
</arg>
<arg name="domains" type="s" direction="in">
<tp:docstring>
A combination of logging domains separated by commas (','), or "NONE"
to disable logging. Each domain enables logging for operations
related to that domain. Available domains are: [NONE, HW, RFKILL,
ETHER, WIFI, BT, MB, DHCP4, DHCP6, PPP, WIFI_SCAN, IP4, IP6, AUTOIP4,
DNS, VPN, SHARING, SUPPLICANT, USER_SET, SYS_SET, SUSPEND, CORE,
DEVICE, OLPC]
</tp:docstring>
</arg>
</method>
<property name="WirelessEnabled" type="b" access="readwrite">
<tp:docstring>
Indicates if wireless is currently enabled or not.

View File

@@ -21,8 +21,33 @@ BUILT_SOURCES = \
nm-ip4-config-bindings.h \
nm-dhcp4-config-bindings.h \
nm-ip6-config-bindings.h \
nm-dhcp6-config-bindings.h \
nm-wimax-device-bindings.h
#####################################################
# Deprecated original libnm_glib bits
#####################################################
noinst_LTLIBRARIES = libdeprecated-nm-glib.la
libdeprecated_nm_glib_la_SOURCES = \
libnm_glib.h \
libnm_glib.c
libdeprecated_nm_glib_la_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
-Wno-deprecated-declarations \
-Wno-deprecated
libdeprecated_nm_glib_la_LIBADD = \
$(DBUS_LIBS) \
$(GLIB_LIBS)
#####################################################
# Real libnm-glib stuff
#####################################################
lib_LTLIBRARIES = libnm-glib.la libnm-glib-vpn.la
libnm_glib_la_CFLAGS = \
@@ -53,6 +78,7 @@ libnminclude_HEADERS = \
nm-active-connection.h \
nm-dhcp4-config.h \
nm-ip6-config.h \
nm-dhcp6-config.h \
nm-remote-connection.h \
nm-settings-interface.h \
nm-settings-system-interface.h \
@@ -65,7 +91,6 @@ libnminclude_HEADERS = \
nm-wimax-nsp.h
libnm_glib_la_SOURCES = \
libnm_glib.c \
nm-object.c \
nm-object-private.h \
nm-client.c \
@@ -89,6 +114,7 @@ libnm_glib_la_SOURCES = \
nm-active-connection.c \
nm-dhcp4-config.c \
nm-ip6-config.c \
nm-dhcp6-config.c \
nm-remote-connection.c \
nm-remote-connection-private.h \
nm-settings-interface.c \
@@ -104,13 +130,14 @@ libnm_glib_la_SOURCES = \
libnm_glib_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/marshallers/libmarshallers.la \
$(builddir)/libdeprecated-nm-glib.la \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(GCONF_LIBS) \
$(GUDEV_LIBS)
libnm_glib_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib.ver \
-version-info "4:0:2"
-version-info "4:2:2"
noinst_PROGRAMS = libnm-glib-test
@@ -177,6 +204,9 @@ nm-dhcp4-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp4-config.xml
nm-ip6-config-bindings.h: $(top_srcdir)/introspection/nm-ip6-config.xml
dbus-binding-tool --prefix=nm_ip6_config --mode=glib-client --output=$@ $<
nm-dhcp6-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp6-config.xml
dbus-binding-tool --prefix=nm_dhcp6_config --mode=glib-client --output=$@ $<
nm-wimax-device-bindings.h: $(top_srcdir)/introspection/nm-wimax-device.xml
dbus-binding-tool --prefix=nm_wimax_device --mode=glib-client --output=$@ $<
@@ -187,5 +217,4 @@ DISTCLEANFILES = libnm-glib.pc libnm-glib.pc
EXTRA_DIST = libnm-glib.pc.in libnm-glib-vpn.pc.in libnm-glib.ver libnm-glib-vpn.ver
CLEANFILES = \
$(BUILT_SOURCES)
CLEANFILES = $(BUILT_SOURCES)

View File

@@ -36,6 +36,7 @@
#include "nm-device-wifi.h"
#include "nm-utils.h"
#include "nm-active-connection.h"
#include "nm-vpn-connection.h"
#include "nm-setting-ip4-config.h"
static gboolean
@@ -291,8 +292,10 @@ active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_d
connection = g_ptr_array_index (connections, i);
g_print (" %s\n", nm_object_get_path (NM_OBJECT (connection)));
devices = nm_active_connection_get_devices (connection);
for (j = 0; j < devices->len; j++)
for (j = 0; devices && j < devices->len; j++)
g_print (" %s\n", nm_device_get_udi (g_ptr_array_index (devices, j)));
if (NM_IS_VPN_CONNECTION (connection))
g_print (" VPN base connection: %s\n", nm_active_connection_get_specific_object (connection));
}
}

View File

@@ -6,7 +6,7 @@ includedir=@includedir@
Name: libnm-glib-vpn
Description: Convenience library for NetworkManager VPN plugins
Version: @VERSION@
Requires: NetworkManager >= 0.7.995 glib-2.0 dbus-glib-1
Requires: NetworkManager >= 0.7.999 glib-2.0 dbus-glib-1
Cflags: -I${includedir}/libnm-glib
Libs: -L${libdir} -lnm-glib-vpn

View File

@@ -6,7 +6,7 @@ includedir=@includedir@
Name: libnm-glib
Description: Convenience library for clients of NetworkManager
Version: @VERSION@
Requires: NetworkManager >= 0.7.995 glib-2.0 dbus-glib-1
Requires: NetworkManager >= 0.7.999 glib-2.0 dbus-glib-1
Cflags: -I${includedir}/libnm-glib
Libs: -L${libdir} -lnm-glib

View File

@@ -18,6 +18,7 @@ global:
nm_access_point_new;
nm_active_connection_get_connection;
nm_active_connection_get_default;
nm_active_connection_get_default6;
nm_active_connection_get_devices;
nm_active_connection_get_scope;
nm_active_connection_get_service_name;
@@ -132,6 +133,7 @@ global:
nm_settings_connection_interface_get_type;
nm_settings_connection_interface_update;
nm_settings_interface_add_connection;
nm_settings_interface_error_get_type;
nm_settings_interface_error_quark;
nm_settings_interface_get_connection_by_path;
nm_settings_interface_get_type;

View File

@@ -37,21 +37,21 @@ typedef enum libnm_glib_state
LIBNM_NO_NETWORK_CONNECTION,
LIBNM_ACTIVE_NETWORK_CONNECTION,
LIBNM_INVALID_CONTEXT
} libnm_glib_state;
} libnm_glib_state G_GNUC_DEPRECATED;
typedef struct libnm_glib_ctx libnm_glib_ctx;
typedef struct libnm_glib_ctx libnm_glib_ctx G_GNUC_DEPRECATED;
typedef void (*libnm_glib_callback_func) (libnm_glib_ctx *libnm_ctx, gpointer user_data);
typedef void (*libnm_glib_callback_func) (libnm_glib_ctx *libnm_ctx, gpointer user_data) G_GNUC_DEPRECATED;
libnm_glib_ctx *libnm_glib_init (void);
void libnm_glib_shutdown (libnm_glib_ctx *ctx);
G_GNUC_DEPRECATED libnm_glib_ctx * libnm_glib_init (void);
G_GNUC_DEPRECATED void libnm_glib_shutdown (libnm_glib_ctx *ctx);
libnm_glib_state libnm_glib_get_network_state (const libnm_glib_ctx *ctx);
G_GNUC_DEPRECATED libnm_glib_state libnm_glib_get_network_state (const libnm_glib_ctx *ctx);
guint libnm_glib_register_callback (libnm_glib_ctx *ctx, libnm_glib_callback_func func, gpointer user_data, GMainContext *g_main_ctx);
void libnm_glib_unregister_callback (libnm_glib_ctx *ctx, guint id);
G_GNUC_DEPRECATED guint libnm_glib_register_callback (libnm_glib_ctx *ctx, libnm_glib_callback_func func, gpointer user_data, GMainContext *g_main_ctx);
G_GNUC_DEPRECATED void libnm_glib_unregister_callback (libnm_glib_ctx *ctx, guint id);
G_END_DECLS

View File

@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
@@ -50,6 +50,7 @@ typedef struct {
GPtrArray *devices;
NMActiveConnectionState state;
gboolean is_default;
gboolean is_default6;
} NMActiveConnectionPrivate;
enum {
@@ -60,6 +61,7 @@ enum {
PROP_DEVICES,
PROP_STATE,
PROP_DEFAULT,
PROP_DEFAULT6,
LAST_PROP
};
@@ -70,6 +72,7 @@ enum {
#define DBUS_PROP_DEVICES "Devices"
#define DBUS_PROP_STATE "State"
#define DBUS_PROP_DEFAULT "Default"
#define DBUS_PROP_DEFAULT6 "Default6"
/**
* nm_active_connection_new:
@@ -263,10 +266,10 @@ nm_active_connection_get_state (NMActiveConnection *connection)
* nm_active_connection_get_default:
* @connection: a #NMActiveConnection
*
* Whether the active connection is the default one (that is, is used for the default route
* and DNS information).
* Whether the active connection is the default IPv4 one (that is, is used for
* the default IPv4 route and DNS information).
*
* Returns: %TRUE if the active connection is the default one
* Returns: %TRUE if the active connection is the default IPv4 connection
**/
gboolean
nm_active_connection_get_default (NMActiveConnection *connection)
@@ -285,6 +288,32 @@ nm_active_connection_get_default (NMActiveConnection *connection)
return priv->is_default;
}
/**
* nm_active_connection_get_default6:
* @connection: a #NMActiveConnection
*
* Whether the active connection is the default IPv6 one (that is, is used for
* the default IPv6 route and DNS information).
*
* Returns: %TRUE if the active connection is the default IPv6 connection
**/
gboolean
nm_active_connection_get_default6 (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->is_default6) {
priv->is_default6 = _nm_object_get_boolean_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_DEFAULT6);
}
return priv->is_default6;
}
static void
nm_active_connection_init (NMActiveConnection *ap)
{
@@ -350,6 +379,9 @@ get_property (GObject *object,
case PROP_DEFAULT:
g_value_set_boolean (value, nm_active_connection_get_default (self));
break;
case PROP_DEFAULT6:
g_value_set_boolean (value, nm_active_connection_get_default6 (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -392,6 +424,7 @@ register_for_property_changed (NMActiveConnection *connection)
{ NM_ACTIVE_CONNECTION_DEVICES, demarshal_devices, &priv->devices },
{ NM_ACTIVE_CONNECTION_STATE, _nm_object_demarshal_generic, &priv->state },
{ NM_ACTIVE_CONNECTION_DEFAULT, _nm_object_demarshal_generic, &priv->is_default },
{ NM_ACTIVE_CONNECTION_DEFAULT6, _nm_object_demarshal_generic, &priv->is_default6 },
{ NULL },
};
@@ -512,13 +545,26 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
/**
* NMActiveConnection:default:
*
* Whether the active connection is the default one.
* Whether the active connection is the default IPv4 one.
**/
g_object_class_install_property
(object_class, PROP_DEFAULT,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT,
"Default",
"Is the default active connection",
"Is the default IPv4 active connection",
FALSE,
G_PARAM_READABLE));
/**
* NMActiveConnection:default6:
*
* Whether the active connection is the default IPv6 one.
**/
g_object_class_install_property
(object_class, PROP_DEFAULT6,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
"Default6",
"Is the default IPv6 active connection",
FALSE,
G_PARAM_READABLE));
}

View File

@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
@@ -45,6 +45,7 @@ G_BEGIN_DECLS
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
#define NM_ACTIVE_CONNECTION_STATE "state"
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
typedef struct {
NMObject parent;
@@ -73,6 +74,7 @@ const char * nm_active_connection_get_specific_object (NMActiveConnection *c
const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *connection);
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection);
gboolean nm_active_connection_get_default (NMActiveConnection *connection);
gboolean nm_active_connection_get_default6 (NMActiveConnection *connection);
G_END_DECLS

View File

@@ -95,7 +95,7 @@ nm_device_bt_get_hw_address (NMDeviceBt *device)
priv = NM_DEVICE_BT_GET_PRIVATE (device);
if (!priv->hw_address) {
priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
DBUS_PROP_HW_ADDRESS);
}

View File

@@ -60,6 +60,8 @@ typedef struct {
gboolean null_dhcp4_config;
NMIP6Config *ip6_config;
gboolean null_ip6_config;
NMDHCP6Config *dhcp6_config;
gboolean null_dhcp6_config;
NMDeviceState state;
GUdevClient *client;
@@ -80,6 +82,7 @@ enum {
PROP_STATE,
PROP_PRODUCT,
PROP_VENDOR,
PROP_DHCP6_CONFIG,
LAST_PROP
};
@@ -221,6 +224,46 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
return TRUE;
}
static gboolean
demarshal_dhcp6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
const char *path;
NMDHCP6Config *config = NULL;
DBusGConnection *connection;
if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
return FALSE;
priv->null_dhcp6_config = FALSE;
path = g_value_get_boxed (value);
if (path) {
if (!strcmp (path, "/"))
priv->null_dhcp6_config = TRUE;
else {
config = NM_DHCP6_CONFIG (_nm_object_cache_get (path));
if (config)
config = g_object_ref (config);
else {
connection = nm_object_get_connection (object);
config = NM_DHCP6_CONFIG (nm_dhcp6_config_new (connection, path));
}
}
}
if (priv->dhcp6_config) {
g_object_unref (priv->dhcp6_config);
priv->dhcp6_config = NULL;
}
if (config)
priv->dhcp6_config = config;
_nm_object_queue_notify (object, NM_DEVICE_DHCP6_CONFIG);
return TRUE;
}
static void
register_for_property_changed (NMDevice *device)
{
@@ -234,6 +277,7 @@ register_for_property_changed (NMDevice *device)
{ NM_DEVICE_IP4_CONFIG, demarshal_ip4_config, &priv->ip4_config },
{ NM_DEVICE_DHCP4_CONFIG, demarshal_dhcp4_config, &priv->dhcp4_config },
{ NM_DEVICE_IP6_CONFIG, demarshal_ip6_config, &priv->ip6_config },
{ NM_DEVICE_DHCP6_CONFIG, demarshal_dhcp6_config, &priv->dhcp6_config },
{ NULL },
};
@@ -319,6 +363,8 @@ dispose (GObject *object)
g_object_unref (priv->dhcp4_config);
if (priv->ip6_config)
g_object_unref (priv->ip6_config);
if (priv->dhcp6_config)
g_object_unref (priv->dhcp6_config);
if (priv->client)
g_object_unref (priv->client);
@@ -372,6 +418,9 @@ get_property (GObject *object,
case PROP_IP6_CONFIG:
g_value_set_object (value, nm_device_get_ip6_config (device));
break;
case PROP_DHCP6_CONFIG:
g_value_set_object (value, nm_device_get_dhcp6_config (device));
break;
case PROP_STATE:
g_value_set_uint (value, nm_device_get_state (device));
break;
@@ -506,6 +555,19 @@ nm_device_class_init (NMDeviceClass *device_class)
NM_TYPE_IP6_CONFIG,
G_PARAM_READABLE));
/**
* NMDevice:dhcp6-config:
*
* The #NMDHCP6Config of the device.
**/
g_object_class_install_property
(object_class, PROP_DHCP6_CONFIG,
g_param_spec_object (NM_DEVICE_DHCP6_CONFIG,
"DHCP6 Config",
"DHCP6 Config",
NM_TYPE_DHCP6_CONFIG,
G_PARAM_READABLE));
/**
* NMDevice:state:
*
@@ -874,6 +936,41 @@ nm_device_get_ip6_config (NMDevice *device)
return priv->ip6_config;
}
/**
* nm_device_get_dhcp6_config:
* @device: a #NMDevice
*
* Gets the current #NMDHCP6Config associated with the #NMDevice.
*
* Returns: the #NMDHCPConfig or %NULL if the device is not activated or not
* using DHCP.
**/
NMDHCP6Config *
nm_device_get_dhcp6_config (NMDevice *device)
{
NMDevicePrivate *priv;
char *path;
GValue value = { 0, };
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (priv->dhcp6_config)
return priv->dhcp6_config;
if (priv->null_dhcp6_config)
return NULL;
path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp6Config");
if (path) {
g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
g_value_take_boxed (&value, path);
demarshal_dhcp6_config (NM_OBJECT (device), NULL, &value, &priv->dhcp6_config);
g_value_unset (&value);
}
return priv->dhcp6_config;
}
/**
* nm_device_get_state:
* @device: a #NMDevice

View File

@@ -32,6 +32,7 @@
#include "nm-ip4-config.h"
#include "nm-dhcp4-config.h"
#include "nm-ip6-config.h"
#include "nm-dhcp6-config.h"
#include "nm-connection.h"
G_BEGIN_DECLS
@@ -51,6 +52,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_IP4_CONFIG "ip4-config"
#define NM_DEVICE_DHCP4_CONFIG "dhcp4-config"
#define NM_DEVICE_IP6_CONFIG "ip6-config"
#define NM_DEVICE_DHCP6_CONFIG "dhcp6-config"
#define NM_DEVICE_STATE "state"
#define NM_DEVICE_VENDOR "vendor"
#define NM_DEVICE_PRODUCT "product"
@@ -89,6 +91,7 @@ gboolean nm_device_get_managed (NMDevice *device);
NMIP4Config * nm_device_get_ip4_config (NMDevice *device);
NMDHCP4Config * nm_device_get_dhcp4_config (NMDevice *device);
NMIP6Config * nm_device_get_ip6_config (NMDevice *device);
NMDHCP6Config * nm_device_get_dhcp6_config (NMDevice *device);
NMDeviceState nm_device_get_state (NMDevice *device);
const char * nm_device_get_product (NMDevice *device);
const char * nm_device_get_vendor (NMDevice *device);

View File

@@ -0,0 +1,248 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* 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 (C) 2008 - 2010 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
#include <string.h>
#include "nm-dhcp6-config.h"
#include "NetworkManager.h"
#include "nm-types-private.h"
#include "nm-object-private.h"
#include "nm-utils.h"
G_DEFINE_TYPE (NMDHCP6Config, nm_dhcp6_config, NM_TYPE_OBJECT)
#define NM_DHCP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP6_CONFIG, NMDHCP6ConfigPrivate))
typedef struct {
DBusGProxy *proxy;
GHashTable *options;
} NMDHCP6ConfigPrivate;
enum {
PROP_0,
PROP_OPTIONS,
LAST_PROP
};
static void
nm_dhcp6_config_init (NMDHCP6Config *config)
{
}
static void
copy_options (gpointer key, gpointer data, gpointer user_data)
{
GHashTable *options = (GHashTable *) user_data;
GValue *value = (GValue *) data;
g_hash_table_insert (options, g_strdup (key), g_value_dup_string (value));
}
static gboolean
demarshal_dhcp6_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
{
NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
GHashTable *new_options;
g_hash_table_remove_all (priv->options);
new_options = g_value_get_boxed (value);
if (new_options)
g_hash_table_foreach (new_options, copy_options, priv->options);
_nm_object_queue_notify (object, NM_DHCP6_CONFIG_OPTIONS);
return TRUE;
}
static void
register_for_property_changed (NMDHCP6Config *config)
{
NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (config);
const NMPropertiesChangedInfo property_changed_info[] = {
{ NM_DHCP6_CONFIG_OPTIONS, demarshal_dhcp6_options, &priv->options },
{ NULL },
};
_nm_object_handle_properties_changed (NM_OBJECT (config),
priv->proxy,
property_changed_info);
}
static GObject*
constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
NMObject *object;
DBusGConnection *connection;
NMDHCP6ConfigPrivate *priv;
object = (NMObject *) G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
connection = nm_object_get_connection (object);
priv->proxy = dbus_g_proxy_new_for_name (connection,
NM_DBUS_SERVICE,
nm_object_get_path (object),
NM_DBUS_INTERFACE_DHCP6_CONFIG);
register_for_property_changed (NM_DHCP6_CONFIG (object));
return G_OBJECT (object);
}
static void
finalize (GObject *object)
{
NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
if (priv->options)
g_hash_table_destroy (priv->options);
g_object_unref (priv->proxy);
G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->finalize (object);
}
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
NMDHCP6Config *self = NM_DHCP6_CONFIG (object);
switch (prop_id) {
case PROP_OPTIONS:
g_value_set_boxed (value, nm_dhcp6_config_get_options (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_dhcp6_config_class_init (NMDHCP6ConfigClass *config_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
g_type_class_add_private (config_class, sizeof (NMDHCP6ConfigPrivate));
/* virtual methods */
object_class->constructor = constructor;
object_class->get_property = get_property;
object_class->finalize = finalize;
/* properties */
/**
* NMDHCP6Config:options:
*
* The #GHashTable containing options of the configuration.
**/
g_object_class_install_property
(object_class, PROP_OPTIONS,
g_param_spec_boxed (NM_DHCP6_CONFIG_OPTIONS,
"Options",
"Options",
G_TYPE_HASH_TABLE,
G_PARAM_READABLE));
}
/**
* nm_dhcp6_config_new:
* @connection: the #DBusGConnection
* @object_path: the DBus object path of the device
*
* Creates a new #NMDHCP6Config.
*
* Returns: a new configuration
**/
GObject *
nm_dhcp6_config_new (DBusGConnection *connection, const char *object_path)
{
return (GObject *) g_object_new (NM_TYPE_DHCP6_CONFIG,
NM_OBJECT_DBUS_CONNECTION, connection,
NM_OBJECT_DBUS_PATH, object_path,
NULL);
}
/**
* nm_dhcp6_config_get_options:
* @config: a #NMDHCP6Config
*
* Gets all the options contained in the configuration.
*
* Returns: the #GHashTable containing strings for keys and values.
* This is the internal copy used by the configuration, and must not be modified.
**/
GHashTable *
nm_dhcp6_config_get_options (NMDHCP6Config *config)
{
NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (config);
GValue value = { 0, };
if (g_hash_table_size (priv->options))
return priv->options;
if (!_nm_object_get_property (NM_OBJECT (config),
"org.freedesktop.DBus.Properties",
"Options",
&value))
goto out;
demarshal_dhcp6_options (NM_OBJECT (config), NULL, &value, &priv->options);
g_value_unset (&value);
out:
return priv->options;
}
/**
* nm_dhcp6_config_get_one_option:
* @config: a #NMDHCP6Config
* @option: the option to retrieve
*
* Gets one option by option name.
*
* Returns: the configuration option's value. This is the internal string used by the
* configuration, and must not be modified.
**/
const char *
nm_dhcp6_config_get_one_option (NMDHCP6Config *config, const char *option)
{
g_return_val_if_fail (NM_IS_DHCP6_CONFIG (config), NULL);
return g_hash_table_lookup (nm_dhcp6_config_get_options (config), option);
}

View File

@@ -0,0 +1,68 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* 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 (C) 2008 - 2010 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
#ifndef NM_DHCP6_CONFIG_H
#define NM_DHCP6_CONFIG_H
#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include "nm-object.h"
G_BEGIN_DECLS
#define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ())
#define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDHCP6Config))
#define NM_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP6_CONFIG, NMDHCP6ConfigClass))
#define NM_IS_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP6_CONFIG))
#define NM_IS_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DHCP6_CONFIG))
typedef struct {
NMObject parent;
} NMDHCP6Config;
typedef struct {
NMObjectClass parent;
/* Padding for future expansion */
void (*_reserved1) (void);
void (*_reserved2) (void);
void (*_reserved3) (void);
void (*_reserved4) (void);
void (*_reserved5) (void);
void (*_reserved6) (void);
} NMDHCP6ConfigClass;
#define NM_DHCP6_CONFIG_OPTIONS "options"
GType nm_dhcp6_config_get_type (void);
GObject *nm_dhcp6_config_new (DBusGConnection *connection, const char *object_path);
GHashTable * nm_dhcp6_config_get_options (NMDHCP6Config *config);
const char * nm_dhcp6_config_get_one_option (NMDHCP6Config *config, const char *option);
G_END_DECLS
#endif /* NM_DHCP6_CONFIG_H */

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 Novell, Inc.
* (C) Copyright 2008 - 2009 Red Hat, Inc.
@@ -227,7 +228,9 @@ impl_exported_connection_get_secrets (NMExportedConnection *self,
if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets)
NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets (self, setting_name, hints, request_new, context);
else {
error = g_error_new (0, 0, "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
dbus_g_method_return_error (context, error);
g_error_free (error);
}

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2009 Red Hat, Inc.
*/

View File

@@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include <string.h>
@@ -324,12 +324,14 @@ constructor (GType type,
nm_connection_get_path (NM_CONNECTION (object)),
NM_DBUS_IFACE_SETTINGS_CONNECTION);
g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
priv->secrets_proxy = dbus_g_proxy_new_for_name (priv->bus,
service,
nm_connection_get_path (NM_CONNECTION (object)),
NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS);
g_assert (priv->secrets_proxy);
dbus_g_proxy_set_default_timeout (priv->secrets_proxy, G_MAXINT);
dbus_g_proxy_add_signal (priv->proxy, "Updated", DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Updated", G_CALLBACK (updated_cb), object, NULL);

View File

@@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <string.h>
@@ -280,6 +280,7 @@ constructor (GType type,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS_SYSTEM);
g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,

View File

@@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <string.h>
@@ -414,6 +414,7 @@ constructor (GType type,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
dbus_g_proxy_add_signal (priv->proxy, "NewConnection",
DBUS_TYPE_G_OBJECT_PATH,

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* 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 (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* 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 (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2008 Red Hat, Inc.

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* 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 (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
@@ -27,6 +28,8 @@
#include "NetworkManager.h"
#include "nm-settings-connection-interface.h"
G_BEGIN_DECLS
typedef enum {
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION = 0,
NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION,
@@ -100,5 +103,6 @@ gboolean nm_settings_interface_add_connection (NMSettingsInterface *settings,
NMSettingsAddConnectionFunc callback,
gpointer user_data);
G_END_DECLS
#endif /* NM_SETTINGS_INTERFACE_H */

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 Novell, Inc.
* (C) Copyright 2008 - 2009 Red Hat, Inc.

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2009 Red Hat, Inc.
*/

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* 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 (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2008 Red Hat, Inc.

View File

@@ -1,19 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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 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 program is distributed in the hope that it will be useful,
* 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 General Public License for more details.
* 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 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.
* 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 (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
@@ -26,6 +27,8 @@
#include "NetworkManager.h"
G_BEGIN_DECLS
typedef enum {
NM_SETTINGS_SYSTEM_PERMISSION_NONE = 0x0,
NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY = 0x1,
@@ -100,4 +103,6 @@ gboolean nm_settings_system_interface_get_permissions (NMSettingsSystemInterface
NMSettingsSystemGetPermissionsFunc callback,
gpointer user_data);
G_END_DECLS
#endif /* NM_SETTINGS_SYSTEM_INTERFACE_H */

View File

@@ -26,6 +26,8 @@
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define NM_TYPE_SSID (nm_ssid_get_type ())
GType nm_ssid_get_type (void) G_GNUC_CONST;
@@ -47,4 +49,6 @@ GType nm_ip6_address_array_get_type (void) G_GNUC_CONST;
#define NM_TYPE_IP6_ROUTE_OBJECT_ARRAY (nm_ip6_route_object_array_get_type ())
GType nm_ip6_route_object_array_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* NM_TYPES_H */

View File

@@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2008 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include <string.h>
@@ -40,6 +40,17 @@ typedef struct {
NMVPNConnectionState vpn_state;
} NMVPNConnectionPrivate;
enum {
PROP_0,
PROP_VPN_STATE,
PROP_BANNER,
LAST_PROP
};
#define DBUS_PROP_VPN_STATE "VpnState"
#define DBUS_PROP_BANNER "Banner"
enum {
VPN_STATE_CHANGED,
@@ -75,7 +86,7 @@ nm_vpn_connection_get_banner (NMVPNConnection *vpn)
if (!priv->banner) {
priv->banner = _nm_object_get_string_property (NM_OBJECT (vpn),
NM_DBUS_INTERFACE_VPN_CONNECTION,
"Banner");
DBUS_PROP_BANNER);
if (priv->banner && !strlen (priv->banner)) {
g_free (priv->banner);
priv->banner = NULL;
@@ -95,7 +106,7 @@ nm_vpn_connection_get_vpn_state (NMVPNConnection *vpn)
if (priv->vpn_state == NM_VPN_CONNECTION_STATE_UNKNOWN) {
priv->vpn_state = _nm_object_get_uint_property (NM_OBJECT (vpn),
NM_DBUS_INTERFACE_VPN_CONNECTION,
"VpnState");
DBUS_PROP_VPN_STATE);
}
return priv->vpn_state;
}
@@ -172,6 +183,27 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object);
}
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
NMVPNConnection *self = NM_VPN_CONNECTION (object);
switch (prop_id) {
case PROP_VPN_STATE:
g_value_set_uint (value, nm_vpn_connection_get_vpn_state (self));
break;
case PROP_BANNER:
g_value_set_string (value, nm_vpn_connection_get_banner (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
{
@@ -181,8 +213,37 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
/* virtual methods */
object_class->constructor = constructor;
object_class->get_property = get_property;
object_class->finalize = finalize;
/* properties */
/**
* NMVPNConnection:vpn-state:
*
* The VPN state of the active VPN connection.
**/
g_object_class_install_property (object_class, PROP_VPN_STATE,
g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE,
"VpnState",
"Current VPN state",
NM_VPN_CONNECTION_STATE_UNKNOWN,
NM_VPN_CONNECTION_STATE_DISCONNECTED,
NM_VPN_CONNECTION_STATE_UNKNOWN,
G_PARAM_READABLE));
/**
* NMVPNConnection:banner:
*
* The VPN login banner of the active VPN connection.
**/
g_object_class_install_property (object_class, PROP_BANNER,
g_param_spec_string (NM_VPN_CONNECTION_BANNER,
"Banner",
"Login Banner",
NULL,
G_PARAM_READABLE));
/* signals */
signals[VPN_STATE_CHANGED] =
g_signal_new ("vpn-state-changed",

View File

@@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2008 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#ifndef NM_VPN_CONNECTION_H
@@ -39,6 +39,9 @@ G_BEGIN_DECLS
#define NM_IS_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_VPN_CONNECTION))
#define NM_VPN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnectionClass))
#define NM_VPN_CONNECTION_VPN_STATE "vpn-state"
#define NM_VPN_CONNECTION_BANNER "banner"
typedef struct {
NMActiveConnection parent;
} NMVPNConnection;

View File

@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 - 2010 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
@@ -113,8 +113,8 @@ nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), NULL);
if (nm_vpn_plugin_ui_interface_get_capabilities (iface) & NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT) {
g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import != NULL, NULL);
return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import (iface, path, error);
g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import_from_file != NULL, NULL);
return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import_from_file (iface, path, error);
}
return NULL;
}
@@ -128,8 +128,8 @@ nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), FALSE);
if (nm_vpn_plugin_ui_interface_get_capabilities (iface) & NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT) {
g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export != NULL, FALSE);
return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export (iface, path, connection, error);
g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export_to_file != NULL, FALSE);
return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export_to_file (iface, path, connection, error);
}
return FALSE;
}

View File

@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 - 2010 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
@@ -91,14 +91,19 @@ struct _NMVpnPluginUiInterface {
* additional information. Note that 'error' can be NULL, in which case no
* additional error information should be provided.
*/
NMConnection * (*import) (NMVpnPluginUiInterface *iface, const char *path, GError **error);
NMConnection * (*import_from_file) (NMVpnPluginUiInterface *iface,
const char *path,
GError **error);
/* Export the given connection to the specified path. Return TRUE on success.
* On error, return FALSE and set 'error' with additional error information.
* Note that 'error' can be NULL, in which case no additional error information
* should be provided.
*/
gboolean (*export) (NMVpnPluginUiInterface *iface, const char *path, NMConnection *connection, GError **error);
gboolean (*export_to_file) (NMVpnPluginUiInterface *iface,
const char *path,
NMConnection *connection,
GError **error);
/* For a given connection, return a suggested file name. Returned value should
* be NULL or a suggested file name allocated via g_malloc/g_new/etc to be freed

View File

@@ -61,7 +61,7 @@ libnm_util_la_SOURCES= \
libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS)
libnm_util_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-util.ver \
-version-info "2:0:1"
-version-info "4:4:3"
if WITH_GNUTLS
libnm_util_la_SOURCES += crypto_gnutls.c

View File

@@ -51,11 +51,11 @@ crypto_init (GError **error)
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 1);
ret = NSS_NoDB_Init (NULL);
if (ret != SECSuccess) {
PR_Cleanup ();
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;
}

View File

@@ -3,10 +3,10 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libnm_util
Name: libnm-util
Description: Convenience library for clients of NetworkManager
Version: @VERSION@
Requires: glib-2.0
Requires: glib-2.0 dbus-glib-1
Cflags: -I${includedir}/NetworkManager
Libs: -L${libdir} -lnm-util

View File

@@ -132,9 +132,11 @@ global:
nm_setting_gsm_get_apn;
nm_setting_gsm_get_network_id;
nm_setting_gsm_get_network_type;
nm_setting_gsm_get_allowed_bands;
nm_setting_gsm_get_band;
nm_setting_gsm_get_pin;
nm_setting_gsm_get_puk;
nm_setting_gsm_get_home_only;
nm_setting_ip4_config_error_get_type;
nm_setting_ip4_config_error_quark;
nm_setting_ip4_config_get_type;
@@ -166,8 +168,7 @@ global:
nm_setting_ip4_config_get_dhcp_hostname;
nm_setting_ip4_config_get_dhcp_send_hostname;
nm_setting_ip4_config_get_never_default;
nm_setting_ip6_config_error_get_type;
nm_setting_ip6_config_error_quark;
nm_setting_ip4_config_get_may_fail;
nm_ip6_address_new;
nm_ip6_address_dup;
nm_ip6_address_ref;
@@ -175,6 +176,8 @@ global:
nm_ip6_address_compare;
nm_ip6_address_get_address;
nm_ip6_address_set_address;
nm_ip6_address_get_gateway;
nm_ip6_address_set_gateway;
nm_ip6_address_get_prefix;
nm_ip6_address_set_prefix;
nm_ip6_route_new;
@@ -190,6 +193,8 @@ global:
nm_ip6_route_set_next_hop;
nm_ip6_route_get_metric;
nm_ip6_route_set_metric;
nm_setting_ip6_config_error_get_type;
nm_setting_ip6_config_error_quark;
nm_setting_ip6_config_get_type;
nm_setting_ip6_config_new;
nm_setting_ip6_config_get_method;
@@ -216,6 +221,7 @@ global:
nm_setting_ip6_config_get_ignore_auto_routes;
nm_setting_ip6_config_get_ignore_auto_dns;
nm_setting_ip6_config_get_never_default;
nm_setting_ip6_config_get_may_fail;
nm_setting_need_secrets;
nm_setting_ppp_error_get_type;
nm_setting_ppp_error_quark;
@@ -351,6 +357,7 @@ global:
nm_utils_ip4_addresses_to_gvalue;
nm_utils_ip4_netmask_to_prefix;
nm_utils_ip4_prefix_to_netmask;
nm_utils_ip4_get_default_prefix;
nm_utils_ip4_routes_from_gvalue;
nm_utils_ip4_routes_to_gvalue;
nm_utils_ip6_addresses_from_gvalue;

View File

@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
@@ -31,8 +31,11 @@ struct _NMParamSpecSpecialized {
#include <string.h>
#include <math.h>
#include <netinet/in.h>
#include <dbus/dbus-glib.h>
#include "nm-dbus-glib-types.h"
/***********************************************************/
/* nm_gvalues_compare */
@@ -367,11 +370,141 @@ nm_gvalues_compare_map (const GValue *value1, const GValue *value2)
return ret;
}
static gint
nm_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
nm_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
nm_gvalues_compare_struct (const GValue *value1, const GValue *value2)
{
g_warning ("Not implemented");
return 0;
/* value1 and value2 must contain the same type since
* nm_gvalues_compare() enforced that already.
*/
if (G_VALUE_HOLDS (value1, DBUS_TYPE_G_IP6_ADDRESS)) {
return nm_gvalue_ip6_address_compare (value1, value2);
} else if (G_VALUE_HOLDS (value1, DBUS_TYPE_G_IP6_ROUTE)) {
return nm_gvalue_ip6_route_compare (value1, value2);
} else {
g_warning ("Don't know how to compare structures");
return (value1 == value2);
}
}
gint
@@ -736,6 +869,87 @@ compare_gvalue_hash (void)
g_print ("Comparing different str hashes: %d\n", nm_gvalues_compare (&value1, &value2));
}
static void
compare_ip6_addresses (void)
{
GValueArray *array1;
GValueArray *array2;
GValueArray *array3;
GByteArray *ba1;
GByteArray *ba2;
GByteArray *ba3;
GValue element = { 0 };
GValue value1 = { 0 };
GValue value2 = { 0 };
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", nm_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", nm_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", nm_gvalues_compare (&value1, &value2));
}
int
main (int argc, char *argv[])
{
@@ -751,6 +965,7 @@ main (int argc, char *argv[])
compare_ptrarrays ();
compare_str_hash ();
compare_gvalue_hash ();
compare_ip6_addresses ();
return 0;
}

View File

@@ -434,7 +434,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
"(ie, contains only hexadecimal characters and '-'). "
"The UUID should be assigned when the connection is "
"created and never changed as long as the connection "
"stilla pplies to the same network. For example, "
"still applies to the same network. For example, "
"it should not be changed when the user changes the "
"connection's 'id', but should be recreated when the "
"WiFi SSID, mobile broadband network provider, or the "

View File

@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
@@ -80,6 +80,8 @@ typedef struct {
guint32 allowed_bands; /* A bitfield of NM_SETTING_GSM_BAND_* */
char *pin;
gboolean home_only;
} NMSettingGsmPrivate;
enum {
@@ -94,6 +96,7 @@ enum {
PROP_PIN,
PROP_PUK,
PROP_ALLOWED_BANDS,
PROP_HOME_ONLY,
LAST_PROP
};
@@ -191,6 +194,14 @@ nm_setting_gsm_get_puk (NMSettingGsm *setting)
return NULL;
}
gboolean
nm_setting_gsm_get_home_only (NMSettingGsm *setting)
{
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), FALSE);
return NM_SETTING_GSM_GET_PRIVATE (setting)->home_only;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@@ -356,6 +367,9 @@ set_property (GObject *object, guint prop_id,
if (str && strlen (str))
g_warning ("Tried to set deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_PUK);
break;
case PROP_HOME_ONLY:
priv->home_only = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -401,6 +415,9 @@ get_property (GObject *object, guint prop_id,
/* deprecated */
g_value_set_int (value, -1);
break;
case PROP_HOME_ONLY:
g_value_set_boolean (value, nm_setting_gsm_get_home_only (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -572,7 +589,8 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|| NM_SETTING_GSM_BAND_U800
|| NM_SETTING_GSM_BAND_U850
|| NM_SETTING_GSM_BAND_U900
|| NM_SETTING_GSM_BAND_U17IX,
|| NM_SETTING_GSM_BAND_U17IX
|| NM_SETTING_GSM_BAND_U1900,
NM_SETTING_GSM_BAND_ANY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
@@ -593,6 +611,22 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
/**
* NMSettingGsm:home-only:
*
* When TRUE, only connections to the home network will be allowed.
* Connections to roaming networks will not be made.
**/
g_object_class_install_property
(object_class, PROP_HOME_ONLY,
g_param_spec_boolean (NM_SETTING_GSM_HOME_ONLY,
"PIN",
"When TRUE, only connections to the home network will "
"be allowed. Connections to roaming networks will "
"not be made.",
FALSE,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/* Deprecated properties */
/**
* NMSettingGsm:puk:

View File

@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
@@ -61,6 +61,7 @@ GQuark nm_setting_gsm_error_quark (void);
#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands"
#define NM_SETTING_GSM_PIN "pin"
#define NM_SETTING_GSM_HOME_ONLY "home-only"
/* DEPRECATED & UNUSED */
#define NM_SETTING_GSM_PUK "puk"
@@ -95,6 +96,7 @@ typedef enum {
NM_SETTING_GSM_BAND_U850 = 0x00000200, /* WCDMA 3GPP UMTS 850 MHz (Class V) */
NM_SETTING_GSM_BAND_U900 = 0x00000400, /* WCDMA 3GPP UMTS 900 MHz (Class VIII) */
NM_SETTING_GSM_BAND_U17IX = 0x00000800, /* WCDMA 3GPP UMTS 1700 MHz (Class IX) */
NM_SETTING_GSM_BAND_U1900 = 0x00001000, /* WCDMA 3GPP UMTS 1900 MHz (Class II) */
} NMSettingGsmNetworkBand;
typedef struct {
@@ -122,6 +124,7 @@ const char *nm_setting_gsm_get_network_id (NMSettingGsm *setting);
int nm_setting_gsm_get_network_type (NMSettingGsm *setting);
guint32 nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting);
const char *nm_setting_gsm_get_pin (NMSettingGsm *setting);
gboolean nm_setting_gsm_get_home_only (NMSettingGsm *setting);
/* DEPRECATED & UNUSED */
const char *nm_setting_gsm_get_puk (NMSettingGsm *setting);

View File

@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
@@ -83,6 +83,7 @@ typedef struct {
gboolean dhcp_send_hostname;
char *dhcp_hostname;
gboolean never_default;
gboolean may_fail;
} NMSettingIP4ConfigPrivate;
enum {
@@ -98,6 +99,7 @@ enum {
PROP_DHCP_SEND_HOSTNAME,
PROP_DHCP_HOSTNAME,
PROP_NEVER_DEFAULT,
PROP_MAY_FAIL,
LAST_PROP
};
@@ -438,6 +440,14 @@ nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting)
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->never_default;
}
gboolean
nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->may_fail;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@@ -462,7 +472,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
} else if ( !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)
|| !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
|| !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)
|| !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
if (priv->dns && priv->dns->len) {
g_set_error (error,
NM_SETTING_IP4_CONFIG_ERROR,
@@ -640,6 +651,9 @@ set_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
priv->never_default = g_value_get_boolean (value);
break;
case PROP_MAY_FAIL:
priv->may_fail = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -687,6 +701,9 @@ get_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
g_value_set_boolean (value, priv->never_default);
break;
case PROP_MAY_FAIL:
g_value_set_boolean (value, priv->may_fail);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -721,7 +738,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
* network access to other computers) then the interface is assigned an
* address in the 10.42.x.1/24 range and a DHCP and forwarding DNS server
* are started, and the interface is NAT-ed to the current default network
* connection. This property must be set.
* connection. 'disabled' means IPv4 will not be used on this connection.
* This property must be set.
**/
g_object_class_install_property
(object_class, PROP_METHOD,
@@ -742,7 +760,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"address in the 10.42.x.1/24 range and a DHCP and "
"forwarding DNS server are started, and the "
"interface is NAT-ed to the current default network "
"connection. This property must be set.",
"connection. 'disabled' means IPv4 will not be "
"used on this connection. This property must be set.",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
@@ -751,8 +770,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
*
* List of DNS servers (network byte order). For the 'auto' method, these
* DNS servers are appended to those (if any) returned by automatic
* configuration. DNS servers cannot be used with the 'shared' or
* 'link-local' methods as there is no usptream network. In all other
* configuration. DNS servers cannot be used with the 'shared', 'link-local',
* or 'disabled' methods as there is no usptream network. In all other
* methods, these DNS servers are used as the only DNS servers for this
* connection.
**/
@@ -764,10 +783,10 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"the 'auto' method, these DNS servers are "
"appended to those (if any) returned by automatic "
"configuration. DNS servers cannot be used with "
"the 'shared' or 'link-local' methods as there is "
"no usptream network. In all other methods, "
"these DNS servers are used as the only DNS "
"servers for this connection.",
"the 'shared', 'link-local', or 'disabled' "
"methods as there is no usptream network. In all "
"other methods, these DNS servers are used as the "
"only DNS servers for this connection.",
DBUS_TYPE_G_UINT_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
@@ -776,9 +795,9 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
*
* List of DNS search domains. For the 'auto' method, these search domains
* are appended to those returned by automatic configuration. Search domains
* cannot be used with the 'shared' or 'link-local' methods as there is no
* upstream network. In all other methods, these search domains are used
* as the only search domains for this connection.
* cannot be used with the 'shared', 'link-local', or 'disabled' methods as
* there is no upstream network. In all other methods, these search domains
* are used as the only search domains for this connection.
**/
g_object_class_install_property
(object_class, PROP_DNS_SEARCH,
@@ -787,11 +806,11 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"List of DNS search domains. For the 'auto' "
"method, these search domains are appended to "
"those returned by automatic configuration. "
"Search domains cannot be used with the 'shared' "
"or 'link-local' methods as there is no upstream "
"network. In all other methods, these search "
"domains are used as the only search domains for "
"this connection.",
"Search domains cannot be used with the 'shared', "
"'link-local', or 'disabled' methods as there is "
"no upstream network. In all other methods, these "
"search domains are used as the only search domains "
"for this connection.",
DBUS_TYPE_G_LIST_OF_STRING,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
@@ -804,8 +823,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
* (network byte order). The gateway may be left as 0 if no gateway exists
* for that subnet. For the 'auto' method, given IP addresses are appended
* to those returned by automatic configuration. Addresses cannot be used
* with the 'shared' or 'link-local' methods as the interface is
* automatically assigned an address with these methods.
* with the 'shared', 'link-local', or 'disabled' methods as addressing is
* either automatic or disabled with these methods.
**/
g_object_class_install_property
(object_class, PROP_ADDRESSES,
@@ -820,9 +839,9 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"for that subnet. For the 'auto' method, given "
"IP addresses are appended to those returned by "
"automatic configuration. Addresses cannot be "
"used with the 'shared' or 'link-local' methods "
"as the interface is automatically assigned an "
"address with these methods.",
"used with the 'shared', 'link-local', or "
"'disabled' methods as addressing is either "
"automatic or disabled with these methods.",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
@@ -835,8 +854,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
* address prefix (1 - 32), the third being the next-hop (network byte
* order) if any, and the fourth being the route metric. For the 'auto'
* method, given IP routes are appended to those returned by automatic
* configuration. Routes cannot be used with the 'shared' or 'link-local'
* methods because there is no upstream network.
* configuration. Routes cannot be used with the 'shared', 'link-local',
* or 'disabled' methods because there is no upstream network.
**/
g_object_class_install_property
(object_class, PROP_ROUTES,
@@ -852,8 +871,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"For the 'auto' method, given IP routes are "
"appended to those returned by automatic "
"configuration. Routes cannot be used with the "
"'shared' or 'link-local' methods as there is no "
"upstream network.",
"'shared', 'link-local', or 'disabled', methods "
"as there is no upstream network.",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
@@ -879,7 +898,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
* NMSettingIP4Config:ignore-auto-dns:
*
* When the method is set to 'auto' and this property to TRUE, automatically
* configured nameservers and search domains are ignored and only namservers
* configured nameservers and search domains are ignored and only nameservers
* and search domains specified in #NMSettingIP4Config:dns and
* #NMSettingIP4Config:dns-search, if any, are used.
**/
@@ -889,7 +908,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"Ignore automatic DNS",
"When the method is set to 'auto' and this property "
"to TRUE, automatically configured nameservers and "
"search domains are ignored and only namservers and "
"search domains are ignored and only nameservers and "
"search domains specified in the 'dns' and 'dns-search' "
"properties, if any, are used.",
FALSE,
@@ -965,6 +984,31 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"the default route by NetworkManager.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingIP4Config:may-fail:
*
* If TRUE, allow overall network configuration to proceed even if IPv4
* configuration times out. Note that at least one IP configuration
* must succeed or overall network configuration will still fail. For
* example, in IPv6-only networks, setting this property to TRUE allows
* the overall network configuration to succeed if IPv4 configuration fails
* but IPv6 configuration completes successfully.
**/
g_object_class_install_property
(object_class, PROP_MAY_FAIL,
g_param_spec_boolean (NM_SETTING_IP4_CONFIG_MAY_FAIL,
"May Fail",
"If TRUE, allow overall network configuration to "
"proceed even if IPv4 configuration times out. "
"Note that at least one IP configuration must "
"succeed or overall network configuration will still "
"fail. For example, in IPv6-only networks, setting "
"this property to TRUE allows the overall network "
"configuration to succeed if IPv4 configuration "
"fails but IPv6 configuration completes successfully.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
}

View File

@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
@@ -64,11 +64,13 @@ GQuark nm_setting_ip4_config_error_quark (void);
#define NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
#define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
#define NM_SETTING_IP4_CONFIG_NEVER_DEFAULT "never-default"
#define NM_SETTING_IP4_CONFIG_MAY_FAIL "may-fail"
#define NM_SETTING_IP4_CONFIG_METHOD_AUTO "auto"
#define NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL "link-local"
#define NM_SETTING_IP4_CONFIG_METHOD_MANUAL "manual"
#define NM_SETTING_IP4_CONFIG_METHOD_SHARED "shared"
#define NM_SETTING_IP4_CONFIG_METHOD_DISABLED "disabled"
typedef struct NMIP4Address NMIP4Address;
@@ -168,6 +170,8 @@ const char * nm_setting_ip4_config_get_dhcp_hostname (NMSettingIP4Config *
gboolean nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting);
gboolean nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting);
G_END_DECLS
#endif /* NM_SETTING_IP4_CONFIG_H */

View File

@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
*/
#include <string.h>
@@ -79,6 +79,7 @@ typedef struct {
gboolean ignore_auto_routes;
gboolean ignore_auto_dns;
gboolean never_default;
gboolean may_fail;
} NMSettingIP6ConfigPrivate;
@@ -92,6 +93,7 @@ enum {
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
PROP_NEVER_DEFAULT,
PROP_MAY_FAIL,
LAST_PROP
};
@@ -414,6 +416,14 @@ nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting)
return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->never_default;
}
gboolean
nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->may_fail;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@@ -435,12 +445,10 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NM_SETTING_IP6_CONFIG_ADDRESSES);
return FALSE;
}
} else if ( !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
|| !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
} else if ( !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
|| !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)
|| !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) {
if (!priv->ignore_auto_dns) {
if (priv->dns && g_slist_length (priv->dns)) {
if (g_slist_length (priv->dns)) {
g_set_error (error,
NM_SETTING_IP6_CONFIG_ERROR,
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
@@ -455,7 +463,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NM_SETTING_IP6_CONFIG_DNS_SEARCH);
return FALSE;
}
}
if (g_slist_length (priv->addresses)) {
g_set_error (error,
@@ -464,6 +471,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NM_SETTING_IP6_CONFIG_ADDRESSES);
return FALSE;
}
} else if ( !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
|| !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
/* nothing to do */
} else {
g_set_error (error,
NM_SETTING_IP6_CONFIG_ERROR,
@@ -535,6 +545,9 @@ set_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
priv->never_default = g_value_get_boolean (value);
break;
case PROP_MAY_FAIL:
priv->may_fail = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -572,6 +585,9 @@ get_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
g_value_set_boolean (value, priv->never_default);
break;
case PROP_MAY_FAIL:
g_value_set_boolean (value, priv->may_fail);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -598,30 +614,33 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
*
* IPv6 configuration method. If 'auto' is specified then the appropriate
* automatic method (DHCP, PPP, advertisement, etc) is used for the
* interface and most other properties can be left unset. If 'link-local'
* is specified, then an IPv6 link-local address will be assigned to the
* interface. If 'manual' is specified, static IP addressing is used and
* at least one IP address must be given in the 'addresses' property. If
* 'ignored' is specified, IPv6 configuration is not done. This property
* must be set. NOTE: DHCP configuration and the 'shared' method are not
* yet supported.
* interface and most other properties can be left unset. To force the use
* of DHCP only, specify 'dhcp'; this method is only valid for ethernet-
* based hardware. If 'link-local' is specified, then an IPv6 link-local
* address will be assigned to the interface. If 'manual' is specified,
* static IP addressing is used and at least one IP address must be given
* in the 'addresses' property. If 'ignored' is specified, IPv6
* configuration is not done. This property must be set. NOTE: the 'shared'
* method are not yet supported.
**/
g_object_class_install_property
(object_class, PROP_METHOD,
g_param_spec_string (NM_SETTING_IP6_CONFIG_METHOD,
"Method",
"IPv6 configuration method. If 'auto' is specified "
"then the appropriate automatic method (DHCP, PPP, "
"then the appropriate automatic method (PPP, router "
"advertisement, etc) is used for the device and "
"most other properties can be left unset. If "
"most other properties can be left unset. To force "
"the use of DHCP only, specify 'dhcp'; this method "
"is only valid for ethernet-based hardware. If "
"'link-local' is specified, then an IPv6 link-local "
"address will be assigned to the interface. If "
"'manual' is specified, static IP addressing is "
"used and at least one IP address must be given in "
" the 'addresses' property. If 'ignored' is "
"specified, IPv6 configuration is not done. This "
"property must be set. NOTE: DHCP configuration "
"and the 'shared' method are not yet supported.",
"property must be set. NOTE: the 'shared' method"
"is not yet supported.",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
@@ -681,25 +700,32 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
* NMSettingIP6Config:addresses:
*
* Array of IPv6 address structures. Each IPv6 address structure is
* composed of 2 members, the first being a byte array containing the IPv6
* address (network byte order) and the second a 32-bit integer containing
* the IPv6 address prefix. For the 'auto' method, given IP addresses are
* appended to those returned by automatic configuration. Addresses cannot
* be used with the 'shared' or 'link-local' methods as the interface is
* automatically assigned an address with these methods.
* composed of 3 members, the first being a byte array containing the IPv6
* address (network byte order), the second a 32-bit integer containing the
* IPv6 address prefix, and the third a byte array containing the IPv6
* address (network byte order) of the gateway associated with this address,
* if any. If no gateway is given, the third element should be given as
* all zeros. For the 'auto' method, given IP addresses are appended to
* those returned by automatic configuration. Addresses cannot be used with
* the 'shared' or 'link-local' methods as the interface is automatically
* assigned an address with these methods.
**/
g_object_class_install_property
(object_class, PROP_ADDRESSES,
_nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_ADDRESSES,
"Addresses",
"Array of IPv6 address structures. Each IPv6 "
"address structure is composed of 2 members, the "
"address structure is composed of 3 members, the "
"first being a byte array containing the IPv6 "
"address (network byte order) and the second a "
"address (network byte order), the second a "
"32-bit integer containing the IPv6 address "
"prefix. For the 'auto' method, given IP "
"addresses are appended to those returned by "
"automatic configuration. Addresses cannot be "
"prefix, and the third a byte array containing "
"the IPv6 address (network byte order) of the "
"gateway associated with this address, if any. "
"If no gateway is given, the third element should "
"be given as all zeros. For the 'auto' method, "
"given IP addresses are appended to those returned "
"by automatic configuration. Addresses cannot be "
"used with the 'shared' or 'link-local' methods "
"as the interface is automatically assigned an "
"address with these methods.",
@@ -740,38 +766,39 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
/**
* NMSettingIP6Config:ignore-auto-routes:
*
* When the method is set to 'auto' and this property to TRUE, automatically
* configured routes are ignored and only routes specified in
* #NMSettingIP6Config:routes, if any, are used.
* When the method is set to 'auto' or 'dhcp' and this property is set to
* TRUE, automatically configured routes are ignored and only routes
* specified in #NMSettingIP6Config:routes, if any, are used.
**/
g_object_class_install_property
(object_class, PROP_IGNORE_AUTO_ROUTES,
g_param_spec_boolean (NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES,
"Ignore automatic routes",
"When the method is set to 'auto' and this property "
"to TRUE, automatically configured routes are "
"ignored and only routes specified in the 'routes' "
"property, if any, are used.",
"When the method is set to 'auto' or 'dhcp' and this "
"property is set to TRUE, automatically configured "
"routes are ignored and only routes specified in the "
"'routes' property, if any, are used.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingIP6Config:ignore-auto-dns:
*
* When the method is set to 'auto' and this property to TRUE, automatically
* configured nameservers and search domains are ignored and only namservers
* and search domains specified in #NMSettingIP6Config:dns and
* #NMSettingIP6Config:dns-search, if any, are used.
* When the method is set to 'auto' or 'dhcp' and this property is set to
* TRUE, automatically configured nameservers and search domains are ignored
* and only nameservers and search domains specified in
* #NMSettingIP6Config:dns and #NMSettingIP6Config:dns-search, if any, are
* used.
**/
g_object_class_install_property
(object_class, PROP_IGNORE_AUTO_DNS,
g_param_spec_boolean (NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS,
"Ignore DHCPv6/RDNSS DNS",
"When the method is set to 'auto' and this property "
"to TRUE, automatically configured nameservers and "
"search domains are ignored and only namservers and "
"search domains specified in the 'dns' and 'dns-search' "
"properties, if any, are used.",
"When the method is set to 'auto' or 'dhcp' and this "
"property is set to TRUE, automatically configured "
"nameservers and search domains are ignored and only "
"nameservers and search domains specified in the 'dns' "
"and 'dns-search' properties, if any, are used.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
@@ -791,12 +818,39 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingIP6Config:may-fail:
*
* If TRUE, allow overall network configuration to proceed even if IPv6
* configuration times out. Note that at least one IP configuration
* must succeed or overall network configuration will still fail. For
* example, in IPv4-only networks, setting this property to TRUE allows
* the overall network configuration to succeed if IPv6 configuration fails
* but IPv4 configuration completes successfully.
**/
g_object_class_install_property
(object_class, PROP_MAY_FAIL,
g_param_spec_boolean (NM_SETTING_IP6_CONFIG_MAY_FAIL,
"May Fail",
"If TRUE, allow overall network configuration to "
"proceed even if IPv6 configuration times out. "
"Note that at least one IP configuration must "
"succeed or overall network configuration will still "
"fail. For example, in IPv4-only networks, setting "
"this property to TRUE allows the overall network "
"configuration to succeed if IPv6 configuration "
"fails but IPv4 configuration completes successfully.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
}
/********************************************************************/
struct NMIP6Address {
guint32 refcount;
struct in6_addr address;
guint32 prefix;
struct in6_addr gateway;
};
NMIP6Address *
@@ -820,6 +874,7 @@ nm_ip6_address_dup (NMIP6Address *source)
address = nm_ip6_address_new ();
address->prefix = source->prefix;
memcpy (&address->address, &source->address, sizeof (struct in6_addr));
memcpy (&address->gateway, &source->gateway, sizeof (struct in6_addr));
return address;
}
@@ -856,7 +911,8 @@ nm_ip6_address_compare (NMIP6Address *address, NMIP6Address *other)
g_return_val_if_fail (other->refcount > 0, FALSE);
if ( memcmp (&address->address, &other->address, sizeof (struct in6_addr))
|| address->prefix != other->prefix)
|| address->prefix != other->prefix
|| memcmp (&address->gateway, &other->gateway, sizeof (struct in6_addr)))
return FALSE;
return TRUE;
}
@@ -898,6 +954,27 @@ nm_ip6_address_set_prefix (NMIP6Address *address, guint32 prefix)
address->prefix = prefix;
}
const struct in6_addr *
nm_ip6_address_get_gateway (NMIP6Address *address)
{
g_return_val_if_fail (address != NULL, 0);
g_return_val_if_fail (address->refcount > 0, 0);
return &address->gateway;
}
void
nm_ip6_address_set_gateway (NMIP6Address *address, const struct in6_addr *gw)
{
g_return_if_fail (address != NULL);
g_return_if_fail (address->refcount > 0);
g_return_if_fail (gw != NULL);
memcpy (&address->gateway, gw, sizeof (struct in6_addr));
}
/********************************************************************/
struct NMIP6Route {
guint32 refcount;

View File

@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
*/
#ifndef NM_SETTING_IP6_CONFIG_H
@@ -62,9 +62,11 @@ GQuark nm_setting_ip6_config_error_quark (void);
#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
#define NM_SETTING_IP6_CONFIG_NEVER_DEFAULT "never-default"
#define NM_SETTING_IP6_CONFIG_MAY_FAIL "may-fail"
#define NM_SETTING_IP6_CONFIG_METHOD_IGNORE "ignore"
#define NM_SETTING_IP6_CONFIG_METHOD_AUTO "auto"
#define NM_SETTING_IP6_CONFIG_METHOD_DHCP "dhcp"
#define NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL "link-local"
#define NM_SETTING_IP6_CONFIG_METHOD_MANUAL "manual"
#define NM_SETTING_IP6_CONFIG_METHOD_SHARED "shared"
@@ -87,6 +89,10 @@ guint32 nm_ip6_address_get_prefix (NMIP6Address *address);
void nm_ip6_address_set_prefix (NMIP6Address *address,
guint32 prefix);
const struct in6_addr *nm_ip6_address_get_gateway (NMIP6Address *address);
void nm_ip6_address_set_gateway (NMIP6Address *address,
const struct in6_addr *gw);
typedef struct NMIP6Route NMIP6Route;
NMIP6Route * nm_ip6_route_new (void);
@@ -158,6 +164,7 @@ gboolean nm_setting_ip6_config_get_ignore_auto_routes (NMSettingIP
gboolean nm_setting_ip6_config_get_ignore_auto_dns (NMSettingIP6Config *setting);
gboolean nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting);
gboolean nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting);
G_END_DECLS

View File

@@ -1,5 +1,4 @@
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* Dan Williams <dcbw@redhat.com>
* Tambet Ingo <tambet@gmail.com>

View File

@@ -1,4 +1,29 @@
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* Dan Williams <dcbw@redhat.com>
* Tambet Ingo <tambet@gmail.com>
* Sjoerd Simons <sjoerd.simons@collabora.co.uk>
* Daniel Drake <dsd@laptop.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
* (C) Copyright 2009 One Laptop per Child
*/
#ifndef NM_SETTING_OLPC_MESH_H
#define NM_SETTING_OLPC_MESH_H

View File

@@ -21,7 +21,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2005 - 2009 Red Hat, Inc.
* (C) Copyright 2005 - 2010 Red Hat, Inc.
*/
#include <string.h>
@@ -275,6 +275,8 @@ nm_utils_init (GError **error)
if (!crypto_init (error))
return FALSE;
_nm_utils_register_value_transformations ();
atexit (nm_utils_deinit);
initialized = TRUE;
}
@@ -624,7 +626,7 @@ nm_utils_convert_uint_array_to_string (const GValue *src_value, GValue *dest_val
}
static void
nm_utils_convert_ip4_addr_struct_array_to_string (const GValue *src_value, GValue *dest_value)
nm_utils_convert_ip4_addr_route_struct_array_to_string (const GValue *src_value, GValue *dest_value)
{
GPtrArray *ptr_array;
GString *printable;
@@ -639,6 +641,7 @@ nm_utils_convert_ip4_addr_struct_array_to_string (const GValue *src_value, GValu
GArray *array;
char buf[INET_ADDRSTRLEN + 1];
struct in_addr addr;
gboolean is_addr; /* array contains address x route */
if (i > 0)
g_string_append (printable, ", ");
@@ -649,13 +652,17 @@ nm_utils_convert_ip4_addr_struct_array_to_string (const GValue *src_value, GValu
g_string_append (printable, "invalid");
continue;
}
is_addr = (array->len < 4);
memset (buf, 0, sizeof (buf));
addr.s_addr = g_array_index (array, guint32, 0);
if (!inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN))
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
if (is_addr)
g_string_append_printf (printable, "ip = %s", buf);
else
g_string_append_printf (printable, "dst = %s", buf);
g_string_append (printable, ", ");
memset (buf, 0, sizeof (buf));
@@ -670,7 +677,18 @@ nm_utils_convert_ip4_addr_struct_array_to_string (const GValue *src_value, GValu
if (!inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN))
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
if (is_addr)
g_string_append_printf (printable, "gw = %s", buf);
else
g_string_append_printf (printable, "nh = %s", buf);
}
if (array->len > 3) {
g_string_append (printable, ", ");
memset (buf, 0, sizeof (buf));
g_string_append_printf (printable, "mt = %u",
g_array_index (array, guint32, 3));
}
g_string_append (printable, " }");
@@ -729,6 +747,7 @@ nm_utils_convert_string_hash_to_string (const GValue *src_value, GValue *dest_va
hash = (GHashTable *) g_value_get_boxed (src_value);
printable = g_string_new ("[");
if (hash)
g_hash_table_foreach (hash, convert_one_string_hash_entry, printable);
g_string_append (printable, " ]");
@@ -764,6 +783,269 @@ nm_utils_convert_byte_array_to_string (const GValue *src_value, GValue *dest_val
g_string_free (printable, FALSE);
}
static gboolean
nm_utils_inet6_ntop (struct in6_addr *addr, char *buf)
{
if (!inet_ntop (AF_INET6, addr, buf, INET6_ADDRSTRLEN)) {
int i;
GString *ip6_str = g_string_new (NULL);
g_string_append_printf (ip6_str, "%02X", addr->s6_addr[0]);
for (i = 1; i < 16; i++)
g_string_append_printf (ip6_str, " %02X", addr->s6_addr[i]);
nm_warning ("%s: error converting IP6 address %s",
__func__, ip6_str->str);
g_string_free (ip6_str, TRUE);
return FALSE;
}
return TRUE;
}
static void
nm_utils_convert_ip6_dns_array_to_string (const GValue *src_value, GValue *dest_value)
{
GPtrArray *ptr_array;
GString *printable;
guint i = 0;
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR));
ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
printable = g_string_new ("[");
while (ptr_array && (i < ptr_array->len)) {
GByteArray *bytearray;
char buf[INET6_ADDRSTRLEN];
struct in6_addr *addr;
if (i > 0)
g_string_append (printable, ", ");
bytearray = (GByteArray *) g_ptr_array_index (ptr_array, i++);
if (bytearray->len != 16) {
g_string_append (printable, "invalid");
continue;
}
addr = (struct in6_addr *) bytearray->data;
memset (buf, 0, sizeof (buf));
nm_utils_inet6_ntop (addr, buf);
g_string_append_printf (printable, "%s", buf);
}
g_string_append_c (printable, ']');
g_value_take_string (dest_value, printable->str);
g_string_free (printable, FALSE);
}
static void
nm_utils_convert_ip6_addr_struct_array_to_string (const GValue *src_value, GValue *dest_value)
{
GPtrArray *ptr_array;
GString *printable;
guint i = 0;
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS));
ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
printable = g_string_new ("[");
while (ptr_array && (i < ptr_array->len)) {
GValueArray *elements;
GValue *tmp;
GByteArray *ba_addr;
char buf[INET6_ADDRSTRLEN];
struct in6_addr *addr;
guint32 prefix;
if (i > 0)
g_string_append (printable, ", ");
g_string_append (printable, "{ ");
elements = (GValueArray *) g_ptr_array_index (ptr_array, i++);
if ( (elements->n_values != 3)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 0)) != DBUS_TYPE_G_UCHAR_ARRAY)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 1)) != G_TYPE_UINT)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 2)) != DBUS_TYPE_G_UCHAR_ARRAY)) {
g_string_append (printable, "invalid }");
continue;
}
/* IPv6 address */
tmp = g_value_array_get_nth (elements, 0);
ba_addr = g_value_get_boxed (tmp);
if (ba_addr->len != 16) {
g_string_append (printable, "invalid }");
continue;
}
addr = (struct in6_addr *) ba_addr->data;
memset (buf, 0, sizeof (buf));
nm_utils_inet6_ntop (addr, buf);
g_string_append_printf (printable, "ip = %s", buf);
g_string_append (printable, ", ");
/* Prefix */
tmp = g_value_array_get_nth (elements, 1);
prefix = g_value_get_uint (tmp);
if (prefix > 128) {
g_string_append (printable, "invalid }");
continue;
}
g_string_append_printf (printable, "px = %u", prefix);
g_string_append (printable, ", ");
/* IPv6 Gateway */
tmp = g_value_array_get_nth (elements, 2);
ba_addr = g_value_get_boxed (tmp);
if (ba_addr->len != 16) {
g_string_append (printable, "invalid }");
continue;
}
addr = (struct in6_addr *) ba_addr->data;
memset (buf, 0, sizeof (buf));
nm_utils_inet6_ntop (addr, buf);
g_string_append_printf (printable, "gw = %s", buf);
g_string_append (printable, " }");
}
g_string_append_c (printable, ']');
g_value_take_string (dest_value, printable->str);
g_string_free (printable, FALSE);
}
static void
nm_utils_convert_ip6_route_struct_array_to_string (const GValue *src_value, GValue *dest_value)
{
GPtrArray *ptr_array;
GString *printable;
guint i = 0;
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE));
ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
printable = g_string_new ("[");
while (ptr_array && (i < ptr_array->len)) {
GValueArray *elements;
GValue *tmp;
GByteArray *ba_addr;
char buf[INET6_ADDRSTRLEN];
struct in6_addr *addr;
guint32 prefix, metric;
if (i > 0)
g_string_append (printable, ", ");
g_string_append (printable, "{ ");
elements = (GValueArray *) g_ptr_array_index (ptr_array, i++);
if ( (elements->n_values != 4)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 0)) != DBUS_TYPE_G_UCHAR_ARRAY)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 1)) != G_TYPE_UINT)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 2)) != DBUS_TYPE_G_UCHAR_ARRAY)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 3)) != G_TYPE_UINT)) {
g_string_append (printable, "invalid");
continue;
}
/* Destination address */
tmp = g_value_array_get_nth (elements, 0);
ba_addr = g_value_get_boxed (tmp);
if (ba_addr->len != 16) {
g_string_append (printable, "invalid");
continue;
}
addr = (struct in6_addr *) ba_addr->data;
memset (buf, 0, sizeof (buf));
nm_utils_inet6_ntop (addr, buf);
g_string_append_printf (printable, "dst = %s", buf);
g_string_append (printable, ", ");
/* Prefix */
tmp = g_value_array_get_nth (elements, 1);
prefix = g_value_get_uint (tmp);
if (prefix > 128) {
g_string_append (printable, "invalid");
continue;
}
g_string_append_printf (printable, "px = %u", prefix);
g_string_append (printable, ", ");
/* Next hop addresses */
tmp = g_value_array_get_nth (elements, 2);
ba_addr = g_value_get_boxed (tmp);
if (ba_addr->len != 16) {
g_string_append (printable, "invalid");
continue;
}
addr = (struct in6_addr *) ba_addr->data;
memset (buf, 0, sizeof (buf));
nm_utils_inet6_ntop (addr, buf);
g_string_append_printf (printable, "nh = %s", buf);
g_string_append (printable, ", ");
/* Metric */
tmp = g_value_array_get_nth (elements, 3);
metric = g_value_get_uint (tmp);
g_string_append_printf (printable, "mt = %u", metric);
g_string_append (printable, " }");
}
g_string_append_c (printable, ']');
g_value_take_string (dest_value, printable->str);
g_string_free (printable, FALSE);
}
#define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
#define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS))
static void
nm_utils_convert_old_ip6_addr_array (const GValue *src_value, GValue *dst_value)
{
GPtrArray *src_outer_array;
GPtrArray *dst_outer_array;
guint i;
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS));
src_outer_array = (GPtrArray *) g_value_get_boxed (src_value);
dst_outer_array = g_ptr_array_new ();
for (i = 0; src_outer_array && (i < src_outer_array->len); i++) {
GValueArray *src_addr_array;
GValueArray *dst_addr_array;
GValue element = {0, };
GValue *src_addr, *src_prefix;
GByteArray *ba;
src_addr_array = (GValueArray *) g_ptr_array_index (src_outer_array, i);
if ( (src_addr_array->n_values != 2)
|| (G_VALUE_TYPE (g_value_array_get_nth (src_addr_array, 0)) != DBUS_TYPE_G_UCHAR_ARRAY)
|| (G_VALUE_TYPE (g_value_array_get_nth (src_addr_array, 1)) != G_TYPE_UINT)) {
g_warning ("%s: invalid old IPv6 address type", __func__);
return;
}
dst_addr_array = g_value_array_new (3);
src_addr = g_value_array_get_nth (src_addr_array, 0);
g_value_array_append (dst_addr_array, src_addr);
src_prefix = g_value_array_get_nth (src_addr_array, 1);
g_value_array_append (dst_addr_array, src_prefix);
/* Blank Gateway */
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
ba = g_byte_array_new ();
g_byte_array_append (ba, (guint8 *) "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16);
g_value_take_boxed (&element, ba);
g_value_array_append (dst_addr_array, &element);
g_value_unset (&element);
g_ptr_array_add (dst_outer_array, dst_addr_array);
}
g_value_take_boxed (dst_value, dst_outer_array);
}
void
_nm_utils_register_value_transformations (void)
{
@@ -781,7 +1063,7 @@ _nm_utils_register_value_transformations (void)
nm_utils_convert_uint_array_to_string);
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
G_TYPE_STRING,
nm_utils_convert_ip4_addr_struct_array_to_string);
nm_utils_convert_ip4_addr_route_struct_array_to_string);
g_value_register_transform_func (DBUS_TYPE_G_MAP_OF_VARIANT,
G_TYPE_STRING,
nm_utils_convert_gvalue_hash_to_string);
@@ -791,6 +1073,18 @@ _nm_utils_register_value_transformations (void)
g_value_register_transform_func (DBUS_TYPE_G_UCHAR_ARRAY,
G_TYPE_STRING,
nm_utils_convert_byte_array_to_string);
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR,
G_TYPE_STRING,
nm_utils_convert_ip6_dns_array_to_string);
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
G_TYPE_STRING,
nm_utils_convert_ip6_addr_struct_array_to_string);
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
G_TYPE_STRING,
nm_utils_convert_ip6_route_struct_array_to_string);
g_value_register_transform_func (OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
nm_utils_convert_old_ip6_addr_array);
registered = TRUE;
}
}
@@ -1209,6 +1503,41 @@ nm_utils_ip4_prefix_to_netmask (guint32 prefix)
}
/**
* nm_utils_ip4_get_default_prefix:
* @ip: an IPv4 address (in network byte order)
*
* When the Internet was originally set up, various ranges of IP addresses were
* segmented into three network classes: A, B, and C. This function will return
* a prefix that is associated with the IP address specified defining where it
* falls in the predefined classes.
*
* Returns: the default class prefix for the given IP
**/
/* The function is originally from ipcalc.c of Red Hat's initscripts. */
guint32
nm_utils_ip4_get_default_prefix (guint32 ip)
{
if (((ntohl (ip) & 0xFF000000) >> 24) <= 127)
return 8; /* Class A - 255.0.0.0 */
else if (((ntohl (ip) & 0xFF000000) >> 24) <= 191)
return 16; /* Class B - 255.255.0.0 */
return 24; /* Class C - 255.255.255.0 */
}
/**
* nm_utils_ip6_addresses_from_gvalue:
* @value: gvalue containing a GPtrArray of GValueArrays of (GArray of guchars) and guint32
*
* Utility function to convert a #GPtrArray of #GValueArrays of (#GArray of guchars) and guint32
* representing a list of NetworkManager IPv6 addresses (which is a tuple of address,
* prefix, and gateway), into a GSList of #NMIP6Address objects. The specific format of
* this serialization is not guaranteed to be stable and the #GValueArray may be
* extended in the future.
*
* Returns: a newly allocated #GSList of #NMIP6Address objects
**/
GSList *
nm_utils_ip6_addresses_from_gvalue (const GValue *value)
{
@@ -1222,16 +1551,28 @@ nm_utils_ip6_addresses_from_gvalue (const GValue *value)
GValueArray *elements = (GValueArray *) g_ptr_array_index (addresses, i);
GValue *tmp;
GByteArray *ba_addr;
GByteArray *ba_gw = NULL;
NMIP6Address *addr;
guint32 prefix;
if ( (elements->n_values != 2)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 0)) != DBUS_TYPE_G_UCHAR_ARRAY)
if (elements->n_values < 2 || elements->n_values > 3) {
nm_warning ("%s: ignoring invalid IP6 address structure", __func__);
continue;
}
if ( (G_VALUE_TYPE (g_value_array_get_nth (elements, 0)) != DBUS_TYPE_G_UCHAR_ARRAY)
|| (G_VALUE_TYPE (g_value_array_get_nth (elements, 1)) != G_TYPE_UINT)) {
nm_warning ("%s: ignoring invalid IP6 address structure", __func__);
continue;
}
/* Check optional 3rd element (gateway) */
if ( elements->n_values == 3
&& (G_VALUE_TYPE (g_value_array_get_nth (elements, 2)) != DBUS_TYPE_G_UCHAR_ARRAY)) {
nm_warning ("%s: ignoring invalid IP6 address structure", __func__);
continue;
}
tmp = g_value_array_get_nth (elements, 0);
ba_addr = g_value_get_boxed (tmp);
if (ba_addr->len != 16) {
@@ -1248,15 +1589,41 @@ nm_utils_ip6_addresses_from_gvalue (const GValue *value)
continue;
}
if (elements->n_values == 3) {
tmp = g_value_array_get_nth (elements, 2);
ba_gw = g_value_get_boxed (tmp);
if (ba_gw->len != 16) {
nm_warning ("%s: ignoring invalid IP6 gateway address of length %d",
__func__, ba_gw->len);
continue;
}
}
addr = nm_ip6_address_new ();
nm_ip6_address_set_prefix (addr, prefix);
nm_ip6_address_set_address (addr, (const struct in6_addr *) ba_addr->data);
if (ba_gw)
nm_ip6_address_set_gateway (addr, (const struct in6_addr *) ba_gw->data);
list = g_slist_prepend (list, addr);
}
return g_slist_reverse (list);
}
/**
* nm_utils_ip6_addresses_to_gvalue:
* @list: a list of #NMIP6Address objects
* @value: a pointer to a #GValue into which to place the converted addresses,
* which should be unset by the caller (when no longer needed) with
* g_value_unset().
*
* Utility function to convert a #GSList of #NMIP6Address objects into a
* GPtrArray of GValueArrays representing a list of NetworkManager IPv6 addresses
* (which is a tuple of address, prefix, and gateway). The specific format of
* this serialization is not guaranteed to be stable and may be extended in the
* future.
**/
void
nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value)
{
@@ -1271,8 +1638,9 @@ nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value)
GValue element = {0, };
GByteArray *ba;
array = g_value_array_new (2);
array = g_value_array_new (3);
/* IP address */
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
ba = g_byte_array_new ();
g_byte_array_append (ba, (guint8 *) nm_ip6_address_get_address (addr), 16);
@@ -1280,17 +1648,39 @@ nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value)
g_value_array_append (array, &element);
g_value_unset (&element);
/* Prefix */
g_value_init (&element, G_TYPE_UINT);
g_value_set_uint (&element, nm_ip6_address_get_prefix (addr));
g_value_array_append (array, &element);
g_value_unset (&element);
/* Gateway */
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
ba = g_byte_array_new ();
g_byte_array_append (ba, (guint8 *) nm_ip6_address_get_gateway (addr), 16);
g_value_take_boxed (&element, ba);
g_value_array_append (array, &element);
g_value_unset (&element);
g_ptr_array_add (addresses, array);
}
g_value_take_boxed (value, addresses);
}
/**
* nm_utils_ip6_routes_from_gvalue:
* @value: gvalue containing a GPtrArray of GValueArrays of (GArray or guchars), guint32,
* (GArray of guchars), and guint32
*
* Utility function GPtrArray of GValueArrays of (GArray or guchars), guint32,
* (GArray of guchars), and guint32 representing a list of NetworkManager IPv6
* routes (which is a tuple of destination, prefix, next hop, and metric)
* into a GSList of #NMIP6Route objects. The specific format of this serialization
* is not guaranteed to be stable and may be extended in the future.
*
* Returns: a newly allocated #GSList of #NMIP6Route objects
**/
GSList *
nm_utils_ip6_routes_from_gvalue (const GValue *value)
{
@@ -1343,6 +1733,19 @@ nm_utils_ip6_routes_from_gvalue (const GValue *value)
return g_slist_reverse (list);
}
/**
* nm_utils_ip6_routes_to_gvalue:
* @list: a list of #NMIP6Route objects
* @value: a pointer to a #GValue into which to place the converted routes,
* which should be unset by the caller (when no longer needed) with
* g_value_unset().
*
* Utility function to convert a #GSList of #NMIP6Route objects into a GPtrArray of
* GValueArrays of (GArray or guchars), guint32, (GArray of guchars), and guint32
* representing a list of NetworkManager IPv6 routes (which is a tuple of destination,
* prefix, next hop, and metric). The specific format of this serialization is not
* guaranteed to be stable and may be extended in the future.
**/
void
nm_utils_ip6_routes_to_gvalue (GSList *list, GValue *value)
{

View File

@@ -20,7 +20,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2005 - 2008 Red Hat, Inc.
* (C) Copyright 2005 - 2010 Red Hat, Inc.
*/
#ifndef NM_UTILS_H
@@ -31,6 +31,8 @@
#include "nm-connection.h"
G_BEGIN_DECLS
/*********************************************************/
/* The API defined here is _NOT_ guaranteed in any way!! */
/*********************************************************/
@@ -192,6 +194,7 @@ void nm_utils_ip4_routes_to_gvalue (GSList *list, GValue *value);
guint32 nm_utils_ip4_netmask_to_prefix (guint32 netmask);
guint32 nm_utils_ip4_prefix_to_netmask (guint32 prefix);
guint32 nm_utils_ip4_get_default_prefix (guint32 ip);
GSList *nm_utils_ip6_addresses_from_gvalue (const GValue *value);
void nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value);
@@ -210,4 +213,6 @@ GByteArray *nm_utils_rsa_key_encrypt (const GByteArray *data,
char **out_password,
GError **error);
G_END_DECLS
#endif /* NM_UTILS_H */

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 - 2009 Red Hat, Inc.
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*
*/
@@ -28,7 +28,8 @@
#include "nm-setting-connection.h"
#include "nm-setting-vpn.h"
#include "nm-setting-ip6-config.h"
#include "nm-dbus-glib-types.h"
static void
vpn_check_func (const char *key, const char *value, gpointer user_data)
@@ -128,6 +129,99 @@ test_setting_vpn_items (void)
g_object_unref (s_vpn);
}
#define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
#define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS))
/* Test that setting the IPv6 setting's 'addresses' property using the old
* IPv6 address format still works, i.e. that the GValue transformation function
* from old->new is working correctly.
*/
static void
test_setting_ip6_config_old_address_array (void)
{
NMSettingIP6Config *s_ip6;
GPtrArray *addresses, *read_addresses;
GValueArray *array, *read_array;
GValue element = {0, }, written_value = {0, }, read_value = {0, };
GByteArray *ba;
const guint8 addr[16] = { 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
0x11, 0x22, 0x33, 0x44, 0x66, 0x77, 0x88, 0x99 };
const guint8 gw[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
guint32 prefix = 56;
GValue *read_addr, *read_prefix, *read_gw;
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
ASSERT (s_ip6 != NULL,
"ip6-old-addr", "error creating IP6 setting");
g_value_init (&written_value, OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS);
addresses = g_ptr_array_new ();
array = g_value_array_new (3);
/* IP address */
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
ba = g_byte_array_new ();
g_byte_array_append (ba, &addr[0], sizeof (addr));
g_value_take_boxed (&element, ba);
g_value_array_append (array, &element);
g_value_unset (&element);
/* Prefix */
g_value_init (&element, G_TYPE_UINT);
g_value_set_uint (&element, prefix);
g_value_array_append (array, &element);
g_value_unset (&element);
g_ptr_array_add (addresses, array);
g_value_set_boxed (&written_value, addresses);
/* Set the address array on the object */
g_object_set_property (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_ADDRESSES, &written_value);
/* Get it back so we can compare it */
g_value_init (&read_value, DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS);
g_object_get_property (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_ADDRESSES, &read_value);
ASSERT (G_VALUE_HOLDS (&read_value, DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS),
"ip6-old-addr", "wrong addresses property value type '%s'",
G_VALUE_TYPE_NAME (&read_value));
read_addresses = (GPtrArray *) g_value_get_boxed (&read_value);
ASSERT (read_addresses != NULL,
"ip6-old-addr", "missing addresses on readback");
ASSERT (read_addresses->len == 1,
"ip6-old-addr", "expected one address on readback");
read_array = (GValueArray *) g_ptr_array_index (read_addresses, 0);
read_addr = g_value_array_get_nth (read_array, 0);
ba = g_value_get_boxed (read_addr);
ASSERT (ba->len == sizeof (addr),
"ip6-old-addr", "unexpected address item length %d", ba->len);
ASSERT (memcmp (ba->data, &addr[0], sizeof (addr)) == 0,
"ip6-old-addr", "unexpected failure comparing addresses");
read_prefix = g_value_array_get_nth (read_array, 1);
ASSERT (g_value_get_uint (read_prefix) == prefix,
"ip6-old-addr", "unexpected failure comparing prefix");
/* Ensure the gateway is all zeros, which is how the 2-item to 3-item
* conversion happens.
*/
read_gw = g_value_array_get_nth (read_array, 2);
ba = g_value_get_boxed (read_gw);
ASSERT (ba->len == sizeof (gw),
"ip6-old-addr", "unexpected gateway item length %d", ba->len);
ASSERT (memcmp (ba->data, &gw[0], sizeof (gw)) == 0,
"ip6-old-addr", "unexpected failure comparing gateways");
g_value_unset (&written_value);
g_value_unset (&read_value);
g_object_unref (s_ip6);
}
int main (int argc, char **argv)
{
GError *error = NULL;
@@ -142,6 +236,7 @@ int main (int argc, char **argv)
/* The tests */
test_setting_vpn_items ();
test_setting_ip6_config_old_address_array ();
base = g_path_get_basename (argv[0]);
fprintf (stdout, "%s: SUCCESS\n", base);

View File

@@ -118,7 +118,7 @@ int main (int argc, char **argv)
test_defaults (NM_TYPE_SETTING_CDMA, NM_SETTING_CDMA_SETTING_NAME);
test_defaults (NM_TYPE_SETTING_GSM, NM_SETTING_GSM_SETTING_NAME);
test_defaults (NM_TYPE_SETTING_IP4_CONFIG, NM_SETTING_IP4_CONFIG_SETTING_NAME);
// test_defaults (NM_TYPE_SETTING_IP6_CONFIG, NM_SETTING_IP6_CONFIG_SETTING_NAME);
test_defaults (NM_TYPE_SETTING_IP6_CONFIG, NM_SETTING_IP6_CONFIG_SETTING_NAME);
test_defaults (NM_TYPE_SETTING_PPP, NM_SETTING_PPP_SETTING_NAME);
test_defaults (NM_TYPE_SETTING_PPPOE, NM_SETTING_PPPOE_SETTING_NAME);
test_defaults (NM_TYPE_SETTING_SERIAL, NM_SETTING_SERIAL_SETTING_NAME);

View File

@@ -1,8 +1,17 @@
man_MANS = \
NetworkManager.8 \
nm-tool.1
NetworkManager.conf.5 \
nm-system-settings.conf.5 \
nm-tool.1 \
nmcli.1
EXTRA_DIST = \
$(man_MANS) \
NetworkManager.8.in \
nm-tool.1.in
NetworkManager.conf.5.in \
nm-system-settings.conf.5.in \
nm-tool.1.in \
nmcli.1.in
CLEANFILES = $(man_MANS)

View File

@@ -1,14 +1,14 @@
.\" NetworkManager(8) manual page
.\"
.\" Copyright (C) 2005 - 2009 Red Hat, Inc.
.\" Copyright (C) 2005 - 2010 Red Hat, Inc.
.\" Copyright (C) 2005 - 2009 Novell, Inc.
.\" Copyright (C) 2005 Robert Love
.\"
.TH NETWORKMANAGER "8"
.TH NETWORKMANAGER "8" "January 29, 2010"
.SH NAME
NetworkManager \- network management daemon
.SH SYNOPSIS
.B NetworkManager [\-\-no-daemon]
.B NetworkManager [\-\-no\-daemon] [\-\-pid\-file=<filename>] [\-\-state\-file=<filename>] [\-\-config=<filename>] [\-\-plugins=<plugin1>,plugin2>,...] [\-\-log\-level=<level>] [\-\-log\-domains=<domain1>,<domain2>,...]
.SH DESCRIPTION
The \fINetworkManager\fP daemon attempts to make networking configuration and
operation as painless and automatic as possible by managing the primary network
@@ -18,7 +18,7 @@ connection for that device becomes available, unless that behavior is disabled.
Information about networking is exported via a D-Bus interface to any interested
application, providing a rich API with which to inspect and control network
settings and operation.
.TP
.P
NetworkManager will execute scripts in the /etc/NetworkManager/dispatcher.d
directory in alphabetical order in response to network events. Each script
should be (a) a regular file, (b) owned by root, (c) not writable by group or
@@ -29,12 +29,12 @@ and second an action.
.I "up"
The interface has been activated. The environment contains more information
about the interface; CONNECTION_UUID contains the UUID of the connection. Other
variables are IP4_ADDRESS_N where N is a number from 0 to (# IPv4 addresses - 1),
variables are IP4_ADDRESS_N where N is a number from 0 to (# IPv4 addresses \- 1),
in the format "address/prefix gateway". IP4_NUM_ADDRESSES contains the number
addresses the script may expect. IP4_NAMESERVERS contains a space-separated
list of the DNS servers, and IP4_DOMAINS contains a space-separated list of the
search domains. Routes use the format IP4_ROUTE_N where N is a number from 0
to (# IPv4 routes - 1), in the format "address/prefix next-hop metric", and
to (# IPv4 routes \- 1), in the format "address/prefix next-hop metric", and
IP4_NUM_ROUTES contains the number of routes to expect. If the connection used
DHCP for address configuration, the received DHCP configuration is passed in the
environment using standard DHCP option names, prefixed with "DHCP4_", like
@@ -43,11 +43,11 @@ environment using standard DHCP option names, prefixed with "DHCP4_", like
.I "down"
The interface has been deactivated.
.TP
.I "vpn-up"
.I "vpn\-up"
A VPN connection has been activated. The environment contains the connection
UUID in the variable CONNECTION_UUID.
.TP
.I "vpn-down"
.I "vpn\-down"
A VPN connection has been deactivated.
.TP
.I "hostname"
@@ -55,21 +55,54 @@ The system hostname has been updated. Use gethostname(2) to retrieve it.
.SH OPTIONS
The following options are supported:
.TP
.I "--no-daemon"
.I "\-\-no\-daemon"
Do not daemonize. This is useful for debugging, and directs log output to the
controlling terminal in addition to syslog.
.TP
.I "\-\-pid\-file=<filename>"
Specify location of a PID file. The PID file is used for storing PID of the
running proccess and prevents running multiple instances.
.TP
.I "\-\-state\-file=<filename>"
Specify file for storing state of the NetworkManager persistently. If not specified,
the default value of '<LOCALSTATEDIR>/lib/NetworkManager/NetworkManager.state' is
used; where <LOCALSTATEDIR> is dependent on your distribution (usually it's /var).
.TP
.I "\-\-config=<filename>"
Specify configuration file to set up various settings for NetworkManager. If not
specified, the default value of '<SYSCONFDIR>/NetworkManager/NetworkManager.conf'
is used with a fallback to the older 'nm\-system\-settings.conf' if located in
the same directory; where <SYSCONFDIR> is dependent on your distribution (usually
it's /etc). See \fBNetworkManager.conf\fP(5) for more information on configuration
file.
.TP
.I "\-\-plugins=<plugin1>,<plugin2>, ...
List plugins used to manage system-wide connection settings. This list has
preference over plugins specified in the configuration file. Currently supported
plugins are: keyfile, ifcfg\-rh, ifcfg\-suse, ifupdown.
See \fBNetworkManager.conf\fP(5) for more information on the plugins.
.TP
.I "\-\-log\-level=<level>
Sets how much information NetworkManager sends to the log destination (usually
syslog's "daemon" facility). By default, only informational, warning, and error
messages are logged. See \fBNetworkManager.conf\fP(5) for more information on
log levels and domains.
.TP
.I "\-\-log\-domains=<domain1>,<domain2>, ...
Sets which operations are logged to the log destination (usually syslog). By
default, most domains are logging-enabled. See \fBNetworkManager.conf\fP(5) for
more information on log levels and domains.
.SH DEBUGGING
The following environment variables are supported to help debugging. When used
in conjunction with the "--no-daemon" option (thus echoing PPP and DHCP helper
in conjunction with the "\-\-no\-daemon" option (thus echoing PPP and DHCP helper
output to stdout) these can quickly help pinpoint the source of connection
issues.
.TP
.I "NM_SERIAL_DEBUG"
When set to anything, causes NetworkManager to log all serial communication to
and from serial devices like mobile broadband 3G modems.
issues. Also see the \-\-log\-level and \-\-log\-domains to enable debug logging inside
NetworkManager itself.
.TP
.I "NM_PPP_DEBUG"
When set to anything, causes NetworkManager to turn on PPP debugging in pppd,
which logs all PPP and PPTP frames and client/server exchanges.
.SH SEE ALSO
.BR nm-tool (1)
.BR nm\-tool (1),
.BR NetworkManager.conf (5).

View File

@@ -0,0 +1,139 @@
.\" NetworkManager.conf(5) manual page
.\"
.\" Copyright (C) 2010 Red Hat, Inc.
.\"
.TH "NetworkManager.conf" "5" "1 February 2010" ""
.SH NAME
NetworkManager.conf \- NetworkManager configuration file
.SH SYNOPSIS
/etc/NetworkManager/NetworkManager.conf
.br
or
.br
\fI<SYSCONFDIR>\fP/NetworkManager/NetworkManager.conf
.br
where <SYSCONFDIR> depends on your distribution or build.
.SH DESCRIPTION
.P
.I NetworkManager.conf
is a configuration file for NetworkManager. It is used to set up various
aspects of NetworkManager's behavior. The location of
the file may be changed through use of the "\-\-config=" argument for
\fBNetworkManager\fP (8).
It is not necessary to restart NetworkManager when making changes, as the
configuration file is watched for changes and reloaded automatically when necessary.
.SH "FILE FORMAT"
.P
The configuration file format is so-called key file (sort of ini-style format).
It consists of sections (groups) of key-value pairs. Lines beginning with a '#' and blank
lines are considered comments. Sections are started by a header line containing
the section enclosed in '[' and ']', and ended implicitly by the start of
the next section or the end of the file. Each key-value pair must be contained
in a section.
.br
Minimal system settings configuration file looks like this:
.P
.nf
[main]
plugins=keyfile
.fi
.P
Description of sections and available keys follows:
.SS [main]
This section is the only mandatory section of the configuration file.
.TP
.B plugins=\fIplugin1\fP,\fIplugin2\fP, ...
List plugin names separated by ','. Plugins are used to read/write system-wide
connection. When more plugins are specified, the connections are read from all
listed plugins. When writing connections, the plugins will be asked to save the
connection in the order listed here. If the first plugin cannot write out that
connection type, or can't write out any connections, the next plugin is tried.
If none of the plugins can save the connection, the error is returned to the user.
.P
.RS
.B "Available plugins:"
.br
.TP
.I keyfile
plugin is the generic plugin that supports all the connection types and
capabilities that NetworkManager has. It writes files out in a .ini-style format in
/etc/NetworkManager/system-connections. For security, it will ignore files
that are readable or writeable by any user or group other than
.I root
since private keys and passphrases may be stored in plaintext inside the file.
.TP
.I ifcfg\-rh
plugin is used on the Fedora and Red Hat Enterprise Linux distributions
to read and write configuration from the standard /etc/sysconfig/network-scripts/ifcfg-* files.
It currently supports reading wired, WiFi, and 802.1x connections, but does not yet support reading
or writing mobile broadband, PPPoE, or VPN connections. To allow reading and writing of these
add \fIkeyfile\fP plugin to your configuration as well.
.TP
.I ifupdown
plugin is used on the Debian and Ubuntu distributions, and reads connections from
/etc/network/interfaces. Since it cannot write connections out (that support isn't planned),
it is usually paired with the \fIkeyfile\fP plugin to enable saving and editing of new connections.
The \fIifupdown\fP plugin supports basic wired and WiFi connections, including WPA-PSK.
.TP
.I ifcfg\-suse
plugin is only provided for simple backward compatibility with SUSE and OpenSUSE configuration.
Most setups should be using the \fIkeyfile\fP plugin instead. The \fIifcfg\-suse\fP plugin supports
reading wired and WiFi connections, but does not support saving any connection types.
.RE
.TP
.B dhcp=\fIdhclient\fP | \fIdhcpcd\fP
This key sets up what DHCP client NetworkManager will use. Presently
\fIdhclient\fP and \fIdhcpcd\fP are supported. The client configured here should
be available on your system too. If this key is missing, available DHCP clients
are looked for in this order: dhclient, dhcpcd.
.SS [keyfile]
This section contains keyfile-specific options and thus only has effect when using \fIkeyfile\fP plugin.
.TP
.B hostname=\fI<hostname>\fP
Set a persistent hostname when using the \fIkeyfile\fP plugin.
.TP
.B unmanaged-devices=\fImac:<hwaddr>\fP;\fImac:<hwaddr>\fP;...
Set devices that should be ignored by NetworkManager when using the \fIkeyfile\fP
plugin. Devices are specified in the following format: "mac:<hwaddr>", where
<hwaddr> is MAC address of the device to be ignored, in lowercase. Multiple
entries are separated by a semicolon. Example:
.nf
unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1e:65:30:d1:c4
.fi
.SS [ifupdown]
This section contains ifupdown-specific options and thus only has effect when using \fIifupdown\fP plugin.
.TP
.B managed=\fIfalse\fP | \fItrue\fP
Controls whether interfaces listed in the 'interfaces' file are managed by NetworkManager.
If set to \fItrue\fP, then interfaces listed in /etc/network/interfaces are managed by NetworkManager.
If set to \fIfalse\fP, then any interface listed in /etc/network/interfaces will be
ignored by NetworkManager. Remember that NetworkManager controls the default route,
so because the interface is ignored, NetworkManager may assign the default route to
some other interface.
When the option is missing, \fIfalse\fP value is taken as default.
.SS [logging]
This section controls NetworkManager's logging. Any settings here are
overridden by the \-\-log\-level and \-\-log\-domains command-line options.
.TP
.B level=\fI<level>\fP
One of [ERR, WARN, INFO, DEBUG]. The ERR level logs only critical errors. WARN
logs warnings that may reflect operation. INFO logs various informational
messages that are useful for tracking state and operations. DEBUG enables
verbose logging for debugging purposes. Subsequent levels also log all messages
from earlier levels; thus setting the log level to INFO also logs error and
warning messages.
.TP
.B domains=\fI<domain1>,<domain2>, ...\fP
The following log domains are available: [NONE, HW, RKILL, ETHER, WIFI, BT, MB,
DHCP4, DHCP6, PPP, WIFI_SCAN, IP4, IP6, AUTOIP4, DNS, VPN, SHARING, SUPPLICANT,
USER_SET, SYS_SET, SUSPEND, CORE, DEVICE, OLPC]. When "NONE" is given by itself,
logging is disabled. MB = Mobile Broadband, USER_SET = user settings operations
and communication, SYS_SET = system settings service operations, OLPC = OLPC
Mesh device operations, CORE = core daemon operations, DEVICE = activation and
general interface operations.
.SH "SEE ALSO"
.BR http://live.gnome.org/NetworkManager/SystemSettings
.sp
.BR NetworkManager (8),
.BR nm\-tool (1).

View File

@@ -0,0 +1,26 @@
.\" nm-system-settings.conf(5) manual page
.\"
.\" Copyright (C) 2010 Red Hat, Inc.
.\"
.TH "nm-system-settings.conf" "5" "1 February 2010" ""
.SH NAME
nm\-system\-settings.conf \- Deprecated NetworkManager configuration file
.SH SYNOPSIS
/etc/NetworkManager/nm\-system\-settings.conf
.br
or
.br
\fI<SYSCONFDIR>\fP/NetworkManager/nm\-system\-settings.conf
.br
where <SYSCONFDIR> depends on your distribution or build.
.SH DESCRIPTION
.P
.I nm\-system\-settings.conf
is a deprecated configuration file for \fBNetworkManager\fP (5). While this
file can still be used, NetworkManager now defaults to reading the config
file <SYSCONFDIR>\fP/NetworkManager/NetworkManager.conf\fP instead, falling back
to nm\-system\-settings.conf if NetworkManager.conf does not exist.
.SH "SEE ALSO"
.BR NetworkManager (8),
.BR NetworkManager.conf (5),
.BR nm\-tool (1).

321
man/nmcli.1.in Normal file
View File

@@ -0,0 +1,321 @@
.\" nmcli (1) manual page
.\"
.\" This is free documentation; 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.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual 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 manual; if not, write to the Free
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.\" Copyright (C) 2010 Red Hat, Inc.
.\"
.TH NMCLI "1" "14 April 2010"
.SH NAME
nmcli \- command-line tool for controlling NetworkManager
.SH SYNOPSIS
.ad l
.B nmcli
.RI " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
.BR help " } "
.sp
.IR OBJECT " := { "
.BR nm " | " con " | " dev " } "
.sp
.IR OPTIONS " := { "
.br
\fB\-t\fR[\fIerse\fR]
.br
\fB\-p\fR[\fIretty\fR]
.br
\fB\-m\fR[\fImode\fR] tabular | multiline
.br
\fB\-f\fR[\fIields\fR] <field1,field2,...> | all | common
.br
\fB\-e\fR[\fIscape\fR] yes | no
.br
\fB\-v\fR[\fIersion\fR]
.br
\fB\-h\fR[\fIelp\fR]
.br
.RI "}"
.SH DESCRIPTION
.B nmcli
is a command-line tool for controlling NetworkManager and getting its status.
It is not meant as a replacement of \fInm-applet\fP or other similar clients.
Rather it's a complementary utility to these programs.
The main \fInmcli\fP's usage is on servers, headless machines or just for
power users who prefer the command line.
.P
The use cases comprise:
.IP \(em 4
Initscripts: ifup/ifdown can utilize NetworkManager via \fInmcli\fP instead of
having to manage connections itself and possible interfere with NetworkManager.
.IP \(em 4
Servers, headless machines: No GUI is available; then \fInmcli\fP is used to
talk directly to NetworkManager and control only system-wide connections.
.IP \(em 4
User sessions: For this case, \fInmcli\fP can talk to \fInm-applet\fP to find
user connections. It can still talk directly to NetworkManager for manipulating
these connections. As \fInmcli\fP doesn't have direct access to user
configuration data in GConf, \fInm-applet\fP handles that itself. That may,
for example, cause the applet to pop up keyring dialogs when secrets are needed.
.SS \fIOPTIONS\fP
.TP
.B \-t, \-\-terse
Output is terse. This mode is designed and suitable for computer (script)
processing.
.TP
.B \-p, \-\-pretty
Output is pretty. This causes \fInmcli\fP to produce easy readable outputs
for humans, i.e. values are aligned, headers are printed, etc.
.TP
.B \-m, \-\-mode tabular | multiline
Switch between \fItabular\fP and \fImultiline\fP output.
If omitted, default is \fItabular\fP for most commands. For the commands
producing more structured information, that cannot be displayed on a single
line, default is \fImultiline\fP. Currenly, they are:
.br
.nf
'nmcli con list id|uuid <name>'
'nmcli dev list'
.fi
\fItabular\fP - Output is a table where each line describes a single entry.
Columns define particular properties of the entry.
.br
\fImultiline\fP - Each entry comprises more lines, each property on its own line.
The values are prefixed with the property name.
.TP
.B \-f, \-\-fields <field1,field2,...> | all | common
This option is used to specify what fields (column names) should be printed.
Valid field names differ for specific commands. List available fields by
providing an invalid value to the \fI--fields\fP option.
.br
\fIall\fP is used to print all valid field values of the command.
\fIcommon\fP is used to print common field values of the command.
If omitted, default is \fIcommon\fP.
The option is mandatory when \fI--terse\fP is used. In this case, generic
values \fIall\fP and \fIcommon\fP cannot be used. (This is to maintain
compatibility when new fields are added in the future).
.TP
.B \-e, \-\-escape yes | no
Whether to escape ':' and '\\' characters in terse tabular mode. The escape
character is '\\'.
If omitted, default is \fIyes\fP.
.TP
.B \-v, \-\-version
Show \fInmcli\fP version.
.TP
.B \-h, \-\-help
Print help information.
.SS \fIOBJECT\fP
.TP
.B nm
NetworkManager
.br
Use this object to inquire and change state of NetworkManager.
.TP
.SS \fICOMMAND\fP := { status | sleep | wakeup | wifi | wwan }
.sp
.RS
.TP
.B status
.br
Show overall status of NetworkManager. This is the default action, when no
command is provided to \fInm\fP object.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.TP
.B sleep
.br
Put NetworkManager to sleeping mode. Thus all interfaces that NetworkManager
manages are deactivated.
.br
.nf
\fBReference to D-Bus:\fP
interface: org.freedesktop.NetworkManager
method: Sleep
arguments: TRUE
.fi
.TP
.B wakeup
.br
Awake NetworkManager from sleep. When NetworkManager is awaken, devices are
available to be activated.
.br
.nf
\fBReference to D-Bus:\fP
interface: org.freedesktop.NetworkManager
method: Sleep
arguments: FALSE
.fi
.TP
.B wifi [on|off]
.br
Inquire or set status of WiFi in NetworkManager. Without any further argument,
WiFi status is printed; \fIon\fP enables WiFi; \fIoff\fP disables WiFi.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.TP
.B wwan [on|off]
.br
Inquire or set status of WWAN in NetworkManager. Without any further argument,
WWAN status is printed; \fIon\fP enables WWAN; \fIoff\fP disables WWAN.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.RE
.TP
.B con
Connections
.br
Get information about NetworkManager's connections.
.TP
.SS \fICOMMAND\fP := { list | status | up | down }
.sp
.RS
.TP
.B list [id <id> | uuid <id> | system | user]
.br
List configured connections. Without a parameter, configured connection from
both system and user settings services are listed. \fIsystem\fP argument filters
only system-wide connections, \fIuser\fP prints user connections only.
In order to get connection details, \fIid\fP with connection's name or \fIuuid\fP
with connection's UUID shall be specified.
When no command is given to \fIcon\fP object, the default action is 'nmcli con list'.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.TP
.B status
.br
Print status of active connections.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.TP
.B up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [\-\-nowait] [\-\-timeout <timeout>]
.br
Activate a connection. The connection is identified by its name using \fIid\fP
or UUID using \fIuuid\fP. For requiring particular device to activate
the connection on, \fIiface\fP option with interface name should be given.
\fIap\fP option can further concretize what AP should be used in case of WiFi
connection. \fI\-\-nowait\fP option causes \fInmcli\fP to exit immediately and
not to wait for command completion. \fI\-\-timeout\fP option provides a means
to specify how long to wait for operation completion.
.br
.nf
\fBReference to D-Bus:\fP
interface: org.freedesktop.NetworkManager
method: ActivateConnection
arguments: according to arguments
.fi
.TP
.B down id <id> | uuid <id>
.br
Deactivate a connection.
The connection is identified by its name using \fIid\fP
or UUID using \fIuuid\fP.
.br
.nf
\fBReference to D-Bus:\fP
interface: org.freedesktop.NetworkManager
method: DeactivateConnection
arguments: according to arguments
.fi
.RE
.TP
.B dev
Devices
.br
Get information about devices.
.TP
.SS \fICOMMAND\fP := { status | list | disconnect | wifi }
.sp
.RS
.TP
.B status
.br
Print status of devices. This is the default action, when no command
is specified to \fIdev\fP object.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.TP
.B list [iface <iface>]
.br
Get detailed information about devices. Without an argument, all devices are
examined. To get information for a specific device, \fIiface\fP argument
with the interface name should be provided.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.TP
.B disconnect iface <iface> [\-\-nowait] [\-\-timeout <timeout>]
.br
Disconnect a device and prevent the device from automatically activating further
connections without user/manual intervention. \fI\-\-nowait\fP option causes
\fInmcli\fP to exit immediately and not to wait for command completion.
\fI\-\-timeout\fP option provides a means to specify how long to wait for
operation completion.
.br
.nf
\fBReference to D-Bus:\fP
interface: org.freedesktop.NetworkManager.Device
method: Disconnect
arguments: none
.fi
.TP
.B wifi [list [iface <iface>] [hwaddr <hwaddr>]]
.br
List available WiFi access points. \fIiface\fP and \fIhwaddr\fP options
can be used to get just APs for particular interface or specific AP,
respectively.
.br
.nf
\fBReference to D-Bus:\fP
No simple reference.
.fi
.RE
.SH BUGS
There are probably some. If you find a bug, please report to
https://bugzilla.gnome.org/ \- product \fINetworkManager\fP.
.SH SEE ALSO
.BR nm\-tool (1),
.BR NetworkManager(8).

View File

@@ -15,11 +15,15 @@ VOID:POINTER,POINTER
VOID:STRING,STRING,STRING,UINT
VOID:OBJECT,UINT,UINT
VOID:STRING,INT
VOID:STRING,UINT
VOID:INT,UINT
VOID:INT,UINT,BOOLEAN
VOID:OBJECT,OBJECT,ENUM
VOID:POINTER,STRING
VOID:STRING,BOXED
BOOLEAN:POINTER,STRING,BOOLEAN,UINT,STRING,STRING
VOID:STRING,BOOLEAN,UINT,STRING,STRING
BOOLEAN:VOID
VOID:STRING,BOOLEAN
VOID:STRING,OBJECT,POINTER
VOID:BOOLEAN,UINT

View File

@@ -22,6 +22,7 @@ fr
gl
gu
he
hi
hr
hu
id
@@ -34,6 +35,7 @@ ku
lt
lv
mk
ml
mr
nb
ne

View File

@@ -1,14 +1,21 @@
[encoding: UTF-8]
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
cli/src/connections.c
cli/src/devices.c
cli/src/network-manager.c
cli/src/nmcli.c
cli/src/settings.c
cli/src/utils.c
libnm-util/crypto.c
libnm-util/crypto_gnutls.c
libnm-util/crypto_nss.c
libnm-util/nm-utils.c
src/nm-netlink-monitor.c
src/NetworkManager.c
src/main.c
src/dhcp-manager/nm-dhcp-dhclient.c
src/ip6-manager/nm-netlink-listener.c
src/dhcp-manager/nm-dhcp-manager.c
src/logging/nm-logging.c
src/named-manager/nm-named-manager.c
src/system-settings/nm-default-wired-connection.c
system-settings/plugins/ifcfg-rh/reader.c

1620
po/as.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1525
po/cs.po

File diff suppressed because it is too large Load Diff

1627
po/de.po

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More