Merge remote branch 'origin/master' into wimax

This commit is contained in:
Dan Williams 2011-01-02 17:24:23 -06:00
commit 0587ef1179
306 changed files with 56174 additions and 15932 deletions

6
.gitignore vendored
View file

@ -93,12 +93,14 @@ libnm-util/tests/test-need-secrets
libnm-util/tests/test-setting-8021x
src/tests/test-dhcp-options
src/tests/test-policy-hosts
src/dhcp-manager/tests/test-dhcp-dhclient
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_*
system-settings/plugins/ifupdown/tests/test-ifupdown
m4/gtk-doc.m4
m4/intltool.m4
@ -106,5 +108,9 @@ m4/libtool.m4
m4/lt*.m4
policy/org.freedesktop.network-manager-settings.system.policy
policy/org.freedesktop.NetworkManager.policy
data/NetworkManager.service
data/org.freedesktop.NetworkManager.service
cli/src/nmcli

View file

@ -1317,7 +1317,7 @@
2008-09-30 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerPolicy.c
- (lookup_thread_worker): don't store the idle handler ID becuase the
- (lookup_thread_worker): don't store the idle handler ID because the
idle handler could have already run and freed the LookupThread
structure
@ -8391,7 +8391,7 @@
internally; clients should provide a setting that applies to
the device with 'autoconnect: True'. Problem was that these
internally auto-created connections don't have a proxy or service
name becuase they weren't created by a settings daemon, and therefore
name because they weren't created by a settings daemon, and therefore
clients have no idea what to do with them.
2007-10-03 Dan Williams <dcbw@redhat.com>
@ -9794,7 +9794,7 @@
* libnm-glib/nm-settings.c
libnm-glib/nm-settings.h
- make the dbus path a property of the object, and autogenerate it.
It can't be composed of the 'id' field becuase that's not available
It can't be composed of the 'id' field because that's not available
yet during the GObject creation in nm_connection_settings_init()
2007-08-29 Dan Williams <dcbw@redhat.com>

View file

@ -10,6 +10,7 @@ SUBDIRS = \
cli \
tools \
policy \
data \
initscript \
test \
po \
@ -24,7 +25,11 @@ EXTRA_DIST = \
intltool-merge.in \
intltool-update.in
DISTCHECK_CONFIGURE_FLAGS = --with-tests=yes --with-docs=yes --with-udev-dir=$$dc_install_base/lib/udev
DISTCHECK_CONFIGURE_FLAGS = \
--with-tests=yes \
--with-docs=yes \
--with-udev-dir=$$dc_install_base/lib/udev \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
DISTCLEANFILES = intltool-extract intltool-merge intltool-update

4
README
View file

@ -66,11 +66,11 @@ those drivers that are shipped with the upstream Linux kernel, because only
those drivers can be easily fixed and debugged. ndiswrapper, vendor binary
drivers, or other out-of-tree drivers may or may not work well with
NetworkManager, precisely because they have not been vetted and improved by the
open-source community, and becuase problems in these drivers usually cannot
open-source community, and because problems in these drivers usually cannot
be fixed.
Sometimes, command-line tools like 'iwconfig' will work, but NetworkManager will
fail. This is again often due to buggy drivers, becuase these drivers simply
fail. This is again often due to buggy drivers, because these drivers simply
aren't expecting the dynamic requests that NetworkManager and wpa_supplicant
make. Driver bugs should be filed in the bug tracker of the distribution being
run, since often distributions customize their kernel and drivers.

View file

@ -60,7 +60,7 @@ nm_dispatcher_action_LDADD = \
$(GLIB_LIBS)
nm-dispatcher-glue.h: nm-dispatcher.xml
dbus-binding-tool --prefix=nm_dispatcher --mode=glib-server --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_dispatcher --mode=glib-server --output=$@ $<
udevrulesdir = $(UDEV_BASE_DIR)/rules.d
udevrules_DATA = 77-nm-olpc-mesh.rules

View file

@ -489,6 +489,10 @@ nm_dispatcher_action (Handler *h,
if (!d->persist)
d->quit_timeout = g_timeout_add_seconds (10, quit_timeout_cb, NULL);
/* Hostname changes don't require a device nor contain a connection */
if (!strcmp (action, "hostname"))
goto dispatch;
connection = nm_connection_new_from_hash (connection_hash, error);
if (connection) {
NMSettingConnection *s_con;
@ -506,10 +510,6 @@ nm_dispatcher_action (Handler *h,
*error = NULL;
}
/* Hostname changes don't require a device */
if (!strcmp (action, "hostname"))
goto dispatch;
/* interface name */
value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_INTERFACE);
if (!value || !G_VALUE_HOLDS_STRING (value)) {

View file

@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <netinet/ether.h>
@ -64,9 +65,10 @@ static NmcOutputField nmc_fields_con_status[] = {
{"DBUS-SERVICE", N_("DBUS-SERVICE"), 45, NULL, 0}, /* 5 */
{"SPEC-OBJECT", N_("SPEC-OBJECT"), 10, NULL, 0}, /* 6 */
{"VPN", N_("VPN"), 5, NULL, 0}, /* 7 */
{"DBUS-PATH", N_("DBUS-PATH"), 51, NULL, 0}, /* 8 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_CON_STATUS_ALL "NAME,UUID,DEVICES,SCOPE,DEFAULT,VPN,DBUS-SERVICE,SPEC-OBJECT"
#define NMC_FIELDS_CON_STATUS_ALL "NAME,UUID,DEVICES,SCOPE,DEFAULT,VPN,DBUS-SERVICE,DBUS-PATH,SPEC-OBJECT"
#define NMC_FIELDS_CON_STATUS_COMMON "NAME,UUID,DEVICES,SCOPE,DEFAULT,VPN"
/* Available fields for 'con list' */
@ -79,9 +81,10 @@ static NmcOutputField nmc_fields_con_list[] = {
{"TIMESTAMP-REAL", N_("TIMESTAMP-REAL"), 34, NULL, 0}, /* 5 */
{"AUTOCONNECT", N_("AUTOCONNECT"), 13, NULL, 0}, /* 6 */
{"READONLY", N_("READONLY"), 10, NULL, 0}, /* 7 */
{"DBUS-PATH", N_("DBUS-PATH"), 42, NULL, 0}, /* 8 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_CON_LIST_ALL "NAME,UUID,TYPE,SCOPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,READONLY"
#define NMC_FIELDS_CON_LIST_ALL "NAME,UUID,TYPE,SCOPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,READONLY,DBUS-PATH"
#define NMC_FIELDS_CON_LIST_COMMON "NAME,UUID,TYPE,SCOPE,TIMESTAMP-REAL"
@ -375,6 +378,7 @@ show_connection (NMConnection *data, gpointer user_data)
timestamp = nm_setting_connection_get_timestamp (s_con);
timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
strftime (timestamp_real_str, sizeof (timestamp_real_str), "%c", localtime ((time_t *) &timestamp));
nmc->allowed_fields[0].value = nm_setting_connection_get_id (s_con);
nmc->allowed_fields[1].value = nm_setting_connection_get_uuid (s_con);
nmc->allowed_fields[2].value = nm_setting_connection_get_connection_type (s_con);
@ -383,6 +387,7 @@ show_connection (NMConnection *data, gpointer user_data)
nmc->allowed_fields[5].value = timestamp ? timestamp_real_str : _("never");
nmc->allowed_fields[6].value = nm_setting_connection_get_autoconnect (s_con) ? _("yes") : _("no");
nmc->allowed_fields[7].value = nm_setting_connection_get_read_only (s_con) ? _("yes") : _("no");
nmc->allowed_fields[8].value = nm_connection_get_path (connection);
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
print_fields (nmc->print_fields, nmc->allowed_fields);
@ -603,6 +608,7 @@ show_active_connection (gpointer data, gpointer user_data)
info->nmc->allowed_fields[5].value = nm_active_connection_get_service_name (active);
info->nmc->allowed_fields[6].value = nm_active_connection_get_specific_object (active);
info->nmc->allowed_fields[7].value = NM_IS_VPN_CONNECTION (active) ? _("yes") : _("no");
info->nmc->allowed_fields[8].value = nm_object_get_path (NM_OBJECT (active));
info->nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
print_fields (info->nmc->print_fields, info->nmc->allowed_fields);
@ -711,10 +717,11 @@ check_ethernet_compatible (NMDeviceEthernet *device, NMConnection *connection, G
if (s_wired) {
const GByteArray *mac;
const char *device_mac_str;
struct ether_addr *device_mac;
struct ether_addr *device_mac = NULL;
device_mac_str = nm_device_ethernet_get_hw_address (device);
device_mac = ether_aton (device_mac_str);
device_mac_str = nm_device_ethernet_get_permanent_hw_address (device);
if (device_mac_str)
device_mac = ether_aton (device_mac_str);
if (!device_mac) {
g_set_error (error, 0, 0, "Invalid device MAC address.");
return FALSE;
@ -760,10 +767,11 @@ check_wifi_compatible (NMDeviceWifi *device, NMConnection *connection, GError **
if (s_wireless) {
const GByteArray *mac;
const char *device_mac_str;
struct ether_addr *device_mac;
struct ether_addr *device_mac = NULL;
device_mac_str = nm_device_wifi_get_hw_address (device);
device_mac = ether_aton (device_mac_str);
device_mac_str = nm_device_wifi_get_permanent_hw_address (device);
if (device_mac_str)
device_mac = ether_aton (device_mac_str);
if (!device_mac) {
g_set_error (error, 0, 0, "Invalid device MAC address.");
return FALSE;
@ -1288,7 +1296,7 @@ activate_connection_cb (gpointer user_data, const char *path, GError *error)
printf (_("Active connection state: %s\n"), active_connection_state_to_string (state));
printf (_("Active connection path: %s\n"), orig_path);
if (!orig_nmc->should_wait || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (orig_nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
/* don't want to wait or already activated */
quit ();
} else {
@ -1415,7 +1423,10 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
goto error;
}
nmc->should_wait = wait;
/* Use nowait_flag instead of should_wait because exitting has to be postponed till active_connection_state_cb()
* is called, giving NM time to check our permissions */
nmc->nowait_flag = !wait;
nmc->should_wait = TRUE;
nm_client_activate_connection (nmc->client,
is_system ? NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS,
con_path,
@ -1504,6 +1515,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
else {
fprintf (stderr, _("Warning: Connection not active\n"));
}
sleep (1); /* Don't quit immediatelly and give NM time to check our permissions */
error:
nmc->should_wait = FALSE;

View file

@ -41,6 +41,7 @@
//#include <nm-device-olpc-mesh.h>
#include <nm-utils.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
#include <nm-vpn-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
@ -57,12 +58,13 @@
/* Available fields for 'dev status' */
static NmcOutputField nmc_fields_dev_status[] = {
{"DEVICE", N_("DEVICE"), 10, NULL, 0}, /* 0 */
{"TYPE", N_("TYPE"), 17, NULL, 0}, /* 1 */
{"STATE", N_("STATE"), 12, NULL, 0}, /* 2 */
{NULL, NULL, 0, NULL, 0}
{"DEVICE", N_("DEVICE"), 10, NULL, 0}, /* 0 */
{"TYPE", N_("TYPE"), 17, NULL, 0}, /* 1 */
{"STATE", N_("STATE"), 13, NULL, 0}, /* 2 */
{"DBUS-PATH", N_("DBUS-PATH"), 43, NULL, 0}, /* 3 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_DEV_STATUS_ALL "DEVICE,TYPE,STATE"
#define NMC_FIELDS_DEV_STATUS_ALL "DEVICE,TYPE,STATE,DBUS-PATH"
#define NMC_FIELDS_DEV_STATUS_COMMON "DEVICE,TYPE,STATE"
@ -75,10 +77,12 @@ static NmcOutputField nmc_fields_dev_list_sections[] = {
{"WIRED-PROPERTIES", N_("WIRED-PROPERTIES"), 0, NULL, 0}, /* 4 */
{"IP4-SETTINGS", N_("IP4-SETTINGS"), 0, NULL, 0}, /* 5 */
{"IP4-DNS", N_("IP4-DNS"), 0, NULL, 0}, /* 6 */
{"IP6-SETTINGS", N_("IP6-SETTINGS"), 0, NULL, 0}, /* 7 */
{"IP6-DNS", N_("IP6-DNS"), 0, NULL, 0}, /* 8 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_DEV_LIST_SECTIONS_ALL "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS"
#define NMC_FIELDS_DEV_LIST_SECTIONS_COMMON "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS"
#define NMC_FIELDS_DEV_LIST_SECTIONS_ALL "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
#define NMC_FIELDS_DEV_LIST_SECTIONS_COMMON "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
/* Available fields for 'dev list' - GENERAL part */
static NmcOutputField nmc_fields_dev_list_general[] = {
@ -137,6 +141,17 @@ static NmcOutputField nmc_fields_dev_list_ip4_settings[] = {
#define NMC_FIELDS_DEV_LIST_IP4_SETTINGS_ALL "NAME,ADDRESS,PREFIX,GATEWAY"
#define NMC_FIELDS_DEV_LIST_IP4_SETTINGS_COMMON "NAME,ADDRESS,PREFIX,GATEWAY"
/* Available fields for 'dev list' - IPv6 settings part */
static NmcOutputField nmc_fields_dev_list_ip6_settings[] = {
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
{"ADDRESS", N_("ADDRESS"), 15, NULL, 0}, /* 1 */
{"PREFIX", N_("PREFIX"), 20, NULL, 0}, /* 2 */
{"GATEWAY", N_("GATEWAY"), 20, NULL, 0}, /* 3 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_DEV_LIST_IP6_SETTINGS_ALL "NAME,ADDRESS,PREFIX,GATEWAY"
#define NMC_FIELDS_DEV_LIST_IP6_SETTINGS_COMMON "NAME,ADDRESS,PREFIX,GATEWAY"
/* Available fields for 'dev list' - IPv4 settings DNS part */
static NmcOutputField nmc_fields_dev_list_ip4_dns[] = {
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
@ -146,6 +161,14 @@ static NmcOutputField nmc_fields_dev_list_ip4_dns[] = {
#define NMC_FIELDS_DEV_LIST_IP4_DNS_ALL "NAME,DNS"
#define NMC_FIELDS_DEV_LIST_IP4_DNS_COMMON "NAME,DNS"
/* Available fields for 'dev list' - IPv6 settings DNS part */
static NmcOutputField nmc_fields_dev_list_ip6_dns[] = {
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
{"DNS", N_("DNS"), 17, NULL, 0}, /* 1 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_DEV_LIST_IP6_DNS_ALL "NAME,DNS"
#define NMC_FIELDS_DEV_LIST_IP6_DNS_COMMON "NAME,DNS"
/* Available fields for 'dev wifi list' */
static NmcOutputField nmc_fields_dev_wifi_list[] = {
@ -161,9 +184,10 @@ static NmcOutputField nmc_fields_dev_wifi_list[] = {
{"RSN-FLAGS", N_("RSN-FLAGS"), 25, NULL, 0}, /* 9 */
{"DEVICE", N_("DEVICE"), 10, NULL, 0}, /* 10 */
{"ACTIVE", N_("ACTIVE"), 8, NULL, 0}, /* 11 */
{"DBUS-PATH", N_("DBUS-PATH"), 46, NULL, 0}, /* 12 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_DEV_WIFI_LIST_ALL "SSID,BSSID,MODE,FREQ,RATE,SIGNAL,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE"
#define NMC_FIELDS_DEV_WIFI_LIST_ALL "SSID,BSSID,MODE,FREQ,RATE,SIGNAL,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,DBUS-PATH"
#define NMC_FIELDS_DEV_WIFI_LIST_COMMON "SSID,BSSID,MODE,FREQ,RATE,SIGNAL,SECURITY,ACTIVE"
#define NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST "NAME,"NMC_FIELDS_DEV_WIFI_LIST_COMMON
@ -305,6 +329,28 @@ ip4_address_as_string (guint32 ip)
}
}
static gchar *
ip6_address_as_string (const struct in6_addr *ip)
{
char buf[INET6_ADDRSTRLEN];
memset (&buf, '\0', sizeof (buf));
if (inet_ntop (AF_INET6, ip, buf, INET6_ADDRSTRLEN)) {
return g_strdup (buf);
} else {
int j;
GString *ip6_str = g_string_new (NULL);
g_string_append_printf (ip6_str, "%02X", ip->s6_addr[0]);
for (j = 1; j < 16; j++)
g_string_append_printf (ip6_str, " %02X", ip->s6_addr[j]);
nm_warning ("%s: error converting IP6 address %s",
__func__, ip6_str->str);
g_string_free (ip6_str, TRUE);
return NULL;
}
}
typedef struct {
NmCli *nmc;
int index;
@ -386,6 +432,7 @@ detail_access_point (gpointer data, gpointer user_data)
info->nmc->allowed_fields[9].value = rsn_flags_str;
info->nmc->allowed_fields[10].value = info->device;
info->nmc->allowed_fields[11].value = active ? _("yes") : _("no");
info->nmc->allowed_fields[12].value = nm_object_get_path (NM_OBJECT (ap));
info->nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
print_fields (info->nmc->print_fields, info->nmc->allowed_fields);
@ -590,17 +637,18 @@ show_device_info (gpointer data, gpointer user_data)
/* IP Setup info */
if (state == NM_DEVICE_STATE_ACTIVATED) {
NMIP4Config *cfg = nm_device_get_ip4_config (device);
NMIP4Config *cfg4 = nm_device_get_ip4_config (device);
NMIP6Config *cfg6 = nm_device_get_ip6_config (device);
GSList *iter;
/* IP4-SETTINGS */
if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[5].name)) {
if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[5].name)) {
nmc->allowed_fields = nmc_fields_dev_list_ip4_settings;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP4_SETTINGS_ALL, nmc->allowed_fields, NULL);
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
for (iter = (GSList *) nm_ip4_config_get_addresses (cfg); iter; iter = g_slist_next (iter)) {
for (iter = (GSList *) nm_ip4_config_get_addresses (cfg4); iter; iter = g_slist_next (iter)) {
NMIP4Address *addr = (NMIP4Address *) iter->data;
guint32 prefix = nm_ip4_address_get_prefix (addr);
char *tmp2;
@ -628,8 +676,8 @@ show_device_info (gpointer data, gpointer user_data)
was_output = TRUE;
}
/* IP4-DNS */
if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[6].name)) {
array = nm_ip4_config_get_nameservers (cfg);
if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[6].name)) {
array = nm_ip4_config_get_nameservers (cfg4);
if (array) {
int i;
@ -652,6 +700,59 @@ show_device_info (gpointer data, gpointer user_data)
}
was_output = TRUE;
}
/* IP6-SETTINGS */
if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[7].name)) {
nmc->allowed_fields = nmc_fields_dev_list_ip6_settings;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP6_SETTINGS_ALL, nmc->allowed_fields, NULL);
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
for (iter = (GSList *) nm_ip6_config_get_addresses (cfg6); iter; iter = g_slist_next (iter)) {
NMIP6Address *addr = (NMIP6Address *) iter->data;
guint32 prefix = nm_ip6_address_get_prefix (addr);
char *addr_str, *prefix_str, *gateway_str;
addr_str = ip6_address_as_string (nm_ip6_address_get_address (addr));
prefix_str = g_strdup_printf ("%d", prefix);
gateway_str = ip6_address_as_string (nm_ip6_address_get_gateway (addr));
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[7].name; /* "IP6-SETTINGS" */
nmc->allowed_fields[1].value = addr_str;
nmc->allowed_fields[2].value = prefix_str;
nmc->allowed_fields[3].value = gateway_str;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
g_free (addr_str);
g_free (prefix_str);
g_free (gateway_str);
}
was_output = TRUE;
}
/* IP6-DNS */
if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[8].name)) {
int i = 1;
nmc->allowed_fields = nmc_fields_dev_list_ip6_dns;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP6_DNS_ALL, nmc->allowed_fields, NULL);
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
for (iter = (GSList *) nm_ip6_config_get_nameservers (cfg6); iter; iter = g_slist_next (iter)) {
char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[8].name, i++);
tmp = ip6_address_as_string (iter->data);
nmc->allowed_fields[0].value = dns_name; /* "IP6-DNS<num>" */
nmc->allowed_fields[1].value = tmp;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
g_free (tmp);
g_free (dns_name);
}
was_output = TRUE;
}
}
}
@ -665,6 +766,7 @@ show_device_status (NMDevice *device, NmCli *nmc)
nmc->allowed_fields[0].value = nm_device_get_iface (device);
nmc->allowed_fields[1].value = get_device_type (device);
nmc->allowed_fields[2].value = device_state_to_string (nm_device_get_state (device));
nmc->allowed_fields[3].value = nm_object_get_path (NM_OBJECT (device));
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
print_fields (nmc->print_fields, nmc->allowed_fields);
@ -831,7 +933,7 @@ disconnect_device_cb (NMDevice *device, GError *error, gpointer user_data)
state = nm_device_get_state (device);
printf (_("Device state: %d (%s)\n"), state, device_state_to_string (state));
if (!nmc->should_wait || state == NM_DEVICE_STATE_DISCONNECTED) {
if (nmc->nowait_flag || state == NM_DEVICE_STATE_DISCONNECTED) {
/* Don't want to wait or device already disconnected */
quit ();
} else {
@ -917,7 +1019,10 @@ do_device_disconnect (NmCli *nmc, int argc, char **argv)
goto error;
}
nmc->should_wait = wait;
/* Use nowait_flag instead of should_wait because exitting has to be postponed till disconnect_device_cb()
* is called, giving NM time to check our permissions */
nmc->nowait_flag = !wait;
nmc->should_wait = TRUE;
nm_device_disconnect (device, disconnect_device_cb, nmc);
error:

View file

@ -34,14 +34,16 @@
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 */
{"NET-ENABLED", N_("NET-ENABLED"), 13, NULL, 0}, /* 2 */
{"WIFI-HARDWARE", N_("WIFI-HARDWARE"), 15, NULL, 0}, /* 3 */
{"WIFI", N_("WIFI"), 10, NULL, 0}, /* 4 */
{"WWAN-HARDWARE", N_("WWAN-HARDWARE"), 15, NULL, 0}, /* 5 */
{"WWAN", N_("WWAN"), 10, NULL, 0}, /* 6 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#define NMC_FIELDS_NM_STATUS_COMMON "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#define NMC_FIELDS_NM_NET_ENABLED "NET-ENABLED"
#define NMC_FIELDS_NM_WIFI "WIFI"
#define NMC_FIELDS_NM_WWAN "WWAN"
@ -60,10 +62,10 @@ usage (void)
{
fprintf (stderr,
_("Usage: nmcli nm { COMMAND | help }\n\n"
" COMMAND := { status | sleep | wakeup | wifi | wwan }\n\n"
" COMMAND := { status | enable | sleep | wifi | wwan }\n\n"
" status\n"
" sleep\n"
" wakeup\n"
" enable [true|false]\n"
" sleep [true|false]\n"
" wifi [on|off]\n"
" wwan [on|off]\n\n"));
}
@ -97,6 +99,7 @@ static NMCResultCode
show_nm_status (NmCli *nmc)
{
gboolean nm_running;
gboolean net_enabled;
NMState state;
const char *wireless_hw_enabled_str, *wireless_enabled_str;
const char *wwan_hw_enabled_str, *wwan_enabled_str;
@ -136,6 +139,7 @@ show_nm_status (NmCli *nmc)
nm_running = nm_client_get_manager_running (nmc->client);
state = nm_client_get_state (nmc->client);
net_enabled = nm_client_networking_get_enabled (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");
@ -147,10 +151,11 @@ show_nm_status (NmCli *nmc)
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->allowed_fields[2].value = net_enabled ? _("enabled") : _("disabled");
nmc->allowed_fields[3].value = wireless_hw_enabled_str;
nmc->allowed_fields[4].value = wireless_enabled_str;
nmc->allowed_fields[5].value = wwan_hw_enabled_str;
nmc->allowed_fields[6].value = wwan_enabled_str;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
@ -158,12 +163,49 @@ show_nm_status (NmCli *nmc)
return NMC_RESULT_SUCCESS;
}
/* libnm-glib doesn't provide API fro Sleep method - implement D-Bus call ourselves */
static void networking_set_sleep (NmCli *nmc, gboolean in_sleep)
{
DBusGConnection *connection = NULL;
DBusGProxy *proxy = NULL;
GError *err = NULL;
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
if (!connection) {
g_string_printf (nmc->return_text, _("Error: Couldn't connect to system bus: %s"), err->message);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
g_error_free (err);
goto gone;
}
proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager");
if (!proxy) {
g_string_printf (nmc->return_text, _("Error: Couldn't create D-Bus object proxy."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto gone;
}
if (!dbus_g_proxy_call (proxy, "Sleep", &err, G_TYPE_BOOLEAN, in_sleep, G_TYPE_INVALID, G_TYPE_INVALID)) {
g_string_printf (nmc->return_text, _("Error in sleep: %s"), err->message);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
g_error_free (err);
}
gone:
if (connection) dbus_g_connection_unref (connection);
if (proxy) g_object_unref (proxy);
}
/* 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 sleep_flag;
gboolean enable_net;
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;
@ -186,11 +228,54 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
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, "enable") == 0) {
if (next_arg (&argc, &argv) != 0) {
/* no argument, show current state of networking */
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
goto opt_error;
if (nmc->required_fields && strcasecmp (nmc->required_fields, "NET-ENABLED")) {
g_string_printf (nmc->return_text, _("Error: '--fields' value '%s' is not valid here; allowed fields: %s"),
nmc->required_fields, NMC_FIELDS_NM_NET_ENABLED);
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_NET_ENABLED, 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 = _("Networking enabled");
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
nmc->allowed_fields[2].value = nm_client_networking_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, "true"))
enable_net = TRUE;
else if (!strcmp (*argv, "false"))
enable_net = FALSE;
else {
g_string_printf (nmc->return_text, _("Error: invalid 'enable' parameter: '%s'; use 'true' or 'false'."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
nm_client_networking_set_enabled (nmc->client, enable_net);
}
}
else if (matches (*argv, "wakeup") == 0) {
nm_client_sleep (nmc->client, FALSE);
else if (matches (*argv, "sleep") == 0) {
if (next_arg (&argc, &argv) != 0) {
g_string_printf (nmc->return_text, _("Error: Sleeping status is not exported by NetworkManager."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
} else {
if (!strcmp (*argv, "true"))
sleep_flag = TRUE;
else if (!strcmp (*argv, "false"))
sleep_flag = FALSE;
else {
g_string_printf (nmc->return_text, _("Error: invalid 'sleep' parameter: '%s'; use 'true' or 'false'."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
networking_set_sleep (nmc, sleep_flag);
}
}
else if (matches (*argv, "wifi") == 0) {
if (next_arg (&argc, &argv) != 0) {
@ -208,7 +293,7 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
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->allowed_fields[4].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 {
@ -240,7 +325,7 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
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->allowed_fields[6].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 {

View file

@ -286,6 +286,7 @@ nmc_init (NmCli *nmc)
nmc->user_connections = NULL;
nmc->should_wait = FALSE;
nmc->nowait_flag = TRUE;
nmc->print_output = NMC_PRINT_NORMAL;
nmc->multiline_output = FALSE;
nmc->mode_specified = FALSE;

View file

@ -102,6 +102,7 @@ typedef struct _NmCli {
GSList *user_connections; /* List of user connections */
gboolean should_wait; /* Indication that nmcli should not end yet */
gboolean nowait_flag; /* '--nowait' option; used for passing to callbacks */
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 */

View file

@ -50,13 +50,14 @@ static NmcOutputField nmc_fields_setting_connection[] = {
/* Available fields for NM_SETTING_WIRED_SETTING_NAME */
static NmcOutputField nmc_fields_setting_wired[] = {
SETTING_FIELD ("name", 17), /* 0 */
SETTING_FIELD (NM_SETTING_WIRED_PORT, 8), /* 1 */
SETTING_FIELD (NM_SETTING_WIRED_SPEED, 10), /* 2 */
SETTING_FIELD (NM_SETTING_WIRED_DUPLEX, 10), /* 3 */
SETTING_FIELD (NM_SETTING_WIRED_AUTO_NEGOTIATE, 15), /* 4 */
SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS, 19), /* 5 */
SETTING_FIELD (NM_SETTING_WIRED_MTU, 6), /* 6 */
SETTING_FIELD ("name", 17), /* 0 */
SETTING_FIELD (NM_SETTING_WIRED_PORT, 8), /* 1 */
SETTING_FIELD (NM_SETTING_WIRED_SPEED, 10), /* 2 */
SETTING_FIELD (NM_SETTING_WIRED_DUPLEX, 10), /* 3 */
SETTING_FIELD (NM_SETTING_WIRED_AUTO_NEGOTIATE, 15), /* 4 */
SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS, 19), /* 5 */
SETTING_FIELD (NM_SETTING_WIRED_CLONED_MAC_ADDRESS, 19), /* 6 */
SETTING_FIELD (NM_SETTING_WIRED_MTU, 6), /* 7 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTING_WIRED_ALL "name"","\
@ -65,6 +66,7 @@ static NmcOutputField nmc_fields_setting_wired[] = {
NM_SETTING_WIRED_DUPLEX","\
NM_SETTING_WIRED_AUTO_NEGOTIATE","\
NM_SETTING_WIRED_MAC_ADDRESS","\
NM_SETTING_WIRED_CLONED_MAC_ADDRESS","\
NM_SETTING_WIRED_MTU
#define NMC_FIELDS_SETTING_WIRED_COMMON NMC_FIELDS_SETTING_WIRED_ALL
@ -131,9 +133,10 @@ static NmcOutputField nmc_fields_setting_wireless[] = {
SETTING_FIELD (NM_SETTING_WIRELESS_RATE, 10), /* 6 */
SETTING_FIELD (NM_SETTING_WIRELESS_TX_POWER, 10), /* 7 */
SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS, 19), /* 8 */
SETTING_FIELD (NM_SETTING_WIRELESS_MTU, 6), /* 9 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEEN_BSSIDS, 35), /* 10 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEC, 10), /* 11 */
SETTING_FIELD (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, 19), /* 9 */
SETTING_FIELD (NM_SETTING_WIRELESS_MTU, 6), /* 10 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEEN_BSSIDS, 35), /* 11 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEC, 10), /* 12 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTING_WIRELESS_ALL "name"","\
@ -145,6 +148,7 @@ static NmcOutputField nmc_fields_setting_wireless[] = {
NM_SETTING_WIRELESS_RATE","\
NM_SETTING_WIRELESS_TX_POWER","\
NM_SETTING_WIRELESS_MAC_ADDRESS","\
NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS","\
NM_SETTING_WIRELESS_MTU","\
NM_SETTING_WIRELESS_SEEN_BSSIDS","\
NM_SETTING_WIRELESS_SEC
@ -518,7 +522,7 @@ setting_wired_details (NMSetting *setting, NmCli *nmc)
{
NMSettingWired *s_wired;
const GByteArray *mac;
char *speed_str, *mtu_str, *mac_str = NULL;
char *speed_str, *mtu_str, *device_mac_str = NULL, *cloned_mac_str = NULL;
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;
@ -535,21 +539,26 @@ setting_wired_details (NMSetting *setting, NmCli *nmc)
mtu_str = g_strdup_printf ("%d", nm_setting_wired_get_mtu (s_wired));
mac = nm_setting_wired_get_mac_address (s_wired);
if (mac)
mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
device_mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
mac = nm_setting_wired_get_cloned_mac_address (s_wired);
if (mac)
cloned_mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
nmc->allowed_fields[0].value = NM_SETTING_WIRED_SETTING_NAME;
nmc->allowed_fields[1].value = nm_setting_wired_get_port (s_wired);
nmc->allowed_fields[2].value = speed_str;
nmc->allowed_fields[3].value = nm_setting_wired_get_duplex (s_wired);
nmc->allowed_fields[4].value = nm_setting_wired_get_auto_negotiate (s_wired) ? _("yes") : _("no");
nmc->allowed_fields[5].value = mac_str;
nmc->allowed_fields[6].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
nmc->allowed_fields[5].value = device_mac_str;
nmc->allowed_fields[6].value = cloned_mac_str;
nmc->allowed_fields[7].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
g_free (speed_str);
g_free (mac_str);
g_free (device_mac_str);
g_free (cloned_mac_str);
g_free (mtu_str);
return TRUE;
@ -663,7 +672,7 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
int i;
const GByteArray *ssid, *bssid, *mac;
char *ssid_str, *channel_str, *rate_str, *tx_power_str, *mtu_str;
char *mac_str = NULL, *bssid_str = NULL;
char *device_mac_str = NULL, *cloned_mac_str = NULL, *bssid_str = NULL;
GString *seen_bssids;
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;
@ -688,7 +697,10 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
mtu_str = g_strdup_printf ("%d", nm_setting_wireless_get_mtu (s_wireless));
mac = nm_setting_wireless_get_mac_address (s_wireless);
if (mac)
mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
device_mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
mac = nm_setting_wireless_get_cloned_mac_address (s_wireless);
if (mac)
cloned_mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
seen_bssids = g_string_new (NULL);
for (i = 0; i < nm_setting_wireless_get_num_seen_bssids (s_wireless); i++) {
if (i > 0)
@ -704,10 +716,11 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
nmc->allowed_fields[5].value = bssid_str ? bssid_str : _("not set");
nmc->allowed_fields[6].value = rate_str;
nmc->allowed_fields[7].value = tx_power_str;
nmc->allowed_fields[8].value = mac_str ? mac_str : _("not set");
nmc->allowed_fields[9].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
nmc->allowed_fields[10].value = seen_bssids->str;
nmc->allowed_fields[11].value = nm_setting_wireless_get_security (s_wireless);
nmc->allowed_fields[8].value = device_mac_str ? device_mac_str : _("not set");
nmc->allowed_fields[9].value = cloned_mac_str ? cloned_mac_str : _("not set");
nmc->allowed_fields[10].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
nmc->allowed_fields[11].value = seen_bssids->str;
nmc->allowed_fields[12].value = nm_setting_wireless_get_security (s_wireless);
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
@ -717,7 +730,8 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
g_free (bssid_str);
g_free (rate_str);
g_free (tx_power_str);
g_free (mac_str);
g_free (device_mac_str);
g_free (cloned_mac_str);
g_free (mtu_str);
g_string_free (seen_bssids, TRUE);

View file

@ -1,7 +1,8 @@
AC_PREREQ(2.52)
AC_INIT(NetworkManager, 0.8.0.997, dcbw@redhat.com, NetworkManager)
AC_INIT(NetworkManager, 0.8.990, dcbw@redhat.com, NetworkManager)
AM_INIT_AUTOMAKE([1.9 subdir-objects tar-ustar no-dist-gzip dist-bzip2])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
AM_MAINTAINER_MODE
AC_CONFIG_MACRO_DIR([m4])
@ -29,7 +30,7 @@ AC_SUBST([ACLOCAL_AMFLAGS])
dnl maintainer mode stuff
if test $USE_MAINTAINER_MODE = yes; then
DISABLE_DEPRECATED="-DG_DISABLE_DEPRECATED -DGCONF_DISABLE_DEPRECATED"
DISABLE_DEPRECATED="-DG_DISABLE_DEPRECATED"
else
DISABLE_DEPRECATED=""
fi
@ -83,7 +84,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, mandriva or pardus]))
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, pardus, linexa or exherbo]))
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")
@ -95,6 +96,8 @@ if test "z$with_distro" = "z"; then
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")
AC_CHECK_FILE(/etc/linexa-release,with_distro="linexa")
AC_CHECK_FILE(/etc/exherbo-release,with_distro="exherbo")
if test "z$with_distro" = "z"; then
with_distro=`lsb_release -is`
fi
@ -106,7 +109,7 @@ if test "z$with_distro" = "z"; then
exit 1
else
case $with_distro in
redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus) ;;
redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa|exherbo) ;;
*)
echo "Your distribution (${with_distro}) is not yet supported! (patches welcome)"
exit 1
@ -164,6 +167,16 @@ if test x"$with_distro" = xpardus; then
AC_DEFINE(TARGET_PARDUS, 1, [Define if you have Pardus])
fi
AM_CONDITIONAL(TARGET_LINEXA, test x"$with_distro" = xlinexa)
if test x"$with_distro" = xlinexa; then
AC_DEFINE(TARGET_LINEXA, 1, [Define if you have linexa])
fi
AM_CONDITIONAL(TARGET_EXHERBO, test x"$with_distro" = xexherbo)
if test x"$with_distro" = xexherbo; then
AC_DEFINE(TARGET_EXHERBO, 1, [Define if you have Exherbo])
fi
dnl
dnl Distribution version string
dnl
@ -202,6 +215,12 @@ dnl
AC_CHECK_LIB([dl], [dladdr], LIBDL="-ldl", LIBDL="")
AC_SUBST(LIBDL)
dnl
dnl Checks for new dbus-glib property access function
dnl
AC_CHECK_LIB([dbus-glib-1], [dbus_glib_global_set_disable_legacy_property_access], ac_have_dg_prop="1", ac_have_dg_prop="0")
AC_DEFINE_UNQUOTED(HAVE_DBUS_GLIB_DISABLE_LEGACY_PROP_ACCESS, $ac_have_dg_prop, [Define if you have a dbus-glib with dbus_glib_global_set_disable_legacy_property_access()])
PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1 dbus-glib-1 >= 0.75)
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
@ -230,6 +249,16 @@ else
fi
AC_SUBST(UDEV_BASE_DIR)
# systemd
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[],
[with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
if test "x$with_systemdsystemunitdir" != xno; then
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
PKG_CHECK_MODULES(LIBNL, libnl-1 >= 1.0-pre8)
AC_SUBST(LIBNL_CFLAGS)
AC_SUBST(LIBNL_LIBS)
@ -239,11 +268,14 @@ PKG_CHECK_MODULES(UUID, uuid)
AC_SUBST(UUID_CFLAGS)
AC_SUBST(UUID_LIBS)
PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
PKG_CHECK_MODULES(WIMAX, libiWmxSdk-0)
PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
AC_SUBST(POLKIT_CFLAGS)
PKG_CHECK_MODULES(WIMAX, libiWmxSdk-0)
# Check for polkit_authority_get_sync()
AC_CHECK_LIB([polkit-gobject-1], [polkit_authority_get_sync], ac_have_pk_auth_get_sync="1", ac_have_pk_auth_get_sync="0")
AC_DEFINE_UNQUOTED(HAVE_POLKIT_AUTHORITY_GET_SYNC, $ac_have_pk_auth_get_sync, [Define if you have a polkit with polkit_authority_get_sync()])
AC_ARG_WITH(crypto, AS_HELP_STRING([--with-crypto=nss | gnutls], [Cryptography library to use for certificate and key operations]),ac_crypto=$withval, ac_crypto=nss)
@ -251,6 +283,20 @@ with_nss=no
with_gnutls=no
if test x"$ac_crypto" = xnss; then
PKG_CHECK_MODULES(NSS, [nss >= 3.11])
# Work around a pkg-config bug (fdo #29801) where exists != usable
AC_PATH_PROG(PKGCONFIG_PATH, pkg-config, no)
if test x"$PKGCONFIG_PATH" = xno; then
AC_MSG_ERROR([pkgconfig required but not found])
else
FOO=`$PKGCONFIG_PATH --cflags --libs nss`
if test x"$?" != "x0"; then
AC_MSG_ERROR([No usable NSS found])
fi
fi
AC_SUBST(NSS_CFLAGS)
AC_SUBST(NSS_LIBS)
AC_DEFINE(HAVE_NSS, 1, [Define if you have NSS])
with_nss=yes
elif test x"$ac_crypto" = xgnutls; then
@ -267,7 +313,7 @@ elif test x"$ac_crypto" = xgnutls; then
with_gnutls=yes
fi
else
AC_MSG_ERROR([Please choose either 'nss' or 'gnutls' for certificate and key operations])
AC_MSG_ERROR([Please choose either 'nss' or 'gnutls' for certificate and crypto operations])
fi
AM_CONDITIONAL(WITH_NSS, test x"$with_nss" != xno)
AM_CONDITIONAL(WITH_GNUTLS, test x"$with_gnutls" != xno)
@ -306,21 +352,30 @@ AC_SUBST(PPPD_PLUGIN_DIR)
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_dhclient}" in
# NM only works with ISC dhclient - other derivatives don't have
# the same userland. dhclient 4.x is required for IPv6 support;
# with older versions NM won't be able to use DHCPv6.
/*)
DHCLIENT_PATH="${with_dhclient}"
DHCLIENT_VERSION=4
if test -x "${with_dhclient}"; then
case `"${with_dhclient}" --version 2>&1` in
"isc-dhclient-4"*) DHCLIENT_VERSION=4; break;;
"isc-dhclient-V3"*) DHCLIENT_VERSION=3; break;;
esac
fi
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;;
"isc-dhclient-4"*) DHCLIENT_PATH="$path/dhclient"; DHCLIENT_VERSION=4; break;;
"isc-dhclient-V3"*) DHCLIENT_PATH="$path/dhclient"; DHCLIENT_VERSION=3; break;;
esac
done
if test -n "${DHCLIENT_PATH}"; then
@ -345,10 +400,10 @@ case "${with_dhcpcd}" in
AC_MSG_CHECKING(for dhcpcd)
# We fully work with upstream dhcpcd-4
for path in /sbin /usr/sbin /usr/pkg/sbin /usr/local/sbin; do
test -x "${path}/dhclient" || continue
test -x "${path}/dhcpcd" || continue
case `"$path/dhcpcd" --version 2>/dev/null` in
"dhcpcd "[123]*);;
"dhcpcd "*) DHCP_CLIENT_PATH="$path/dhcpcd"; break;;
"dhcpcd "*) DHCPCD_PATH="$path/dhcpcd"; break;;
esac
done
if test -n "${DHCPCD_PATH}"; then
@ -365,9 +420,10 @@ if test -z "$DHCPCD_PATH" -a -z "$DHCLIENT_PATH"; then
# in most distros, so use it.
AC_MSG_WARN([Could not find a suitable DHCP client])
DHCLIENT_PATH=/sbin/dhclient
AC_MSG_WARN([Falling back to ISC dhclient, ${DHCP_CLIENT_PATH}])
AC_MSG_WARN([Falling back to ISC dhclient, ${DHCLIENT_PATH}])
fi
AC_SUBST(DHCLIENT_PATH)
AC_SUBST(DHCLIENT_VERSION)
AC_SUBST(DHCPCD_PATH)
# resolvconf support
@ -425,6 +481,16 @@ fi
AC_DEFINE_UNQUOTED(SYSTEM_CA_PATH, "$SYSTEM_CA_PATH", [Define to path to system CA certificates])
AC_SUBST(SYSTEM_CA_PATH)
AC_ARG_WITH(kernel-firmware-dir, AS_HELP_STRING([--with-kernel-firmware-dir=DIR], [where kernel firmware directory is (default is /lib/firmware)]))
if test -n "$with_kernel_firmware_dir" ; then
KERNEL_FIRMWARE_DIR="$with_kernel_firmware_dir"
else
KERNEL_FIRMWARE_DIR="/lib/firmware"
fi
AC_DEFINE_UNQUOTED(KERNEL_FIRMWARE_DIR, "$KERNEL_FIRMWARE_DIR", [Define to path of the kernel firmware directory])
AC_SUBST(KERNEL_FIRMWARE_DIR)
NM_COMPILER_WARNINGS
GTK_DOC_CHECK(1.0)
@ -451,9 +517,10 @@ src/Makefile
src/tests/Makefile
marshallers/Makefile
src/logging/Makefile
src/named-manager/Makefile
src/dns-manager/Makefile
src/vpn-manager/Makefile
src/dhcp-manager/Makefile
src/dhcp-manager/tests/Makefile
src/ip6-manager/Makefile
src/supplicant-manager/Makefile
src/supplicant-manager/tests/Makefile
@ -476,12 +543,14 @@ tools/Makefile
system-settings/Makefile
system-settings/plugins/Makefile
system-settings/plugins/ifupdown/Makefile
system-settings/plugins/ifupdown/tests/Makefile
system-settings/plugins/ifnet/Makefile
system-settings/plugins/ifnet/tests/Makefile
system-settings/plugins/ifcfg-rh/Makefile
system-settings/plugins/ifcfg-rh/tests/Makefile
system-settings/plugins/ifcfg-rh/tests/network-scripts/Makefile
system-settings/plugins/ifcfg-suse/Makefile
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
@ -504,21 +573,26 @@ initscript/paldo/Makefile
initscript/paldo/NetworkManager
initscript/Mandriva/Makefile
initscript/Mandriva/networkmanager
initscript/linexa/Makefile
initscript/linexa/networkmanager
introspection/Makefile
man/Makefile
man/NetworkManager.8
man/NetworkManager.conf.5
man/nm-system-settings.conf.5
man/nm-tool.1
man/nm-online.1
man/nmcli.1
po/Makefile.in
policy/Makefile
data/Makefile
docs/Makefile
docs/libnm-glib/Makefile
docs/libnm-util/Makefile
NetworkManager.pc
examples/Makefile
examples/python/Makefile
examples/C/Makefile
])
AC_OUTPUT
@ -530,6 +604,7 @@ echo
if test -n "${DHCLIENT_PATH}"; then
echo ISC dhclient support: ${DHCLIENT_PATH}
echo ISC dhclient version: ${DHCLIENT_VERSION}
else
echo ISC dhclient support: no
fi
@ -540,6 +615,12 @@ else
echo dhcpcd support: no
fi
if test -n "${with_systemdsystemunitdir}"; then
echo systemd support: ${with_systemdsystemunitdir}
else
echo systemd support: no
fi
echo
echo Building documentation: ${with_docs}
echo Building tests: ${with_tests}

26
data/Makefile.am Normal file
View file

@ -0,0 +1,26 @@
if HAVE_SYSTEMD
systemdsystemunit_DATA = NetworkManager.service
NetworkManager.service: NetworkManager.service.in
$(edit) $< >$@
servicedir = $(datadir)/dbus-1/system-services
service_in_files = org.freedesktop.NetworkManager.service.in
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
$(edit) $< >$@
endif
edit = sed \
-e 's|@sbindir[@]|$(sbindir)|g' \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g'
EXTRA_DIST = \
NetworkManager.service.in \
org.freedesktop.NetworkManager.service.in
CLEANFILES = NetworkManager.service org.freedesktop.NetworkManager.service

View file

@ -0,0 +1,12 @@
[Unit]
Description=Network Manager
After=syslog.target
[Service]
Type=dbus
BusName=org.freedesktop.NetworkManager
ExecStart=@sbindir@/NetworkManager --no-daemon
[Install]
WantedBy=network.target multi-user.target
Alias=dbus-org.freedesktop.NetworkManager.service

View file

@ -0,0 +1,11 @@
# This D-Bus service activation file is only for systemd support since
# an auto-activated NetworkManager would be quite surprising for those people
# who have NM installed but turned off. Thus the Exec path available to
# D-Bus is /bin/false, but systemd knows the real Exec path due to the NM
# systemd .service file.
[D-BUS Service]
Name=org.freedesktop.NetworkManager
Exec=/bin/false
User=root
SystemdService=dbus-org.freedesktop.NetworkManager.service

View file

@ -1,7 +1,7 @@
SUBDIRS = libnm-glib libnm-util
if WITH_DOCS
SUBDIRS = libnm-glib libnm-util
INCLUDES = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/libnm-util

54
examples/C/Makefile.am Normal file
View file

@ -0,0 +1,54 @@
INCLUDES = -I${top_srcdir}/libnm-util \
-I${top_srcdir}/libnm-glib \
-I${top_srcdir}/include
AM_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS)
noinst_PROGRAMS = \
add-connection-glib \
get-active-connections \
list-connections-dbus \
list-connections-libnm-glib \
get-ap-info-libnm-glib
add_connection_glib_SOURCES = add-connection-glib.c
add_connection_glib_LDADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
get_active_connections_SOURCES = get-active-connections.c
get_active_connections_LDADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
list_connections_dbus_SOURCES = list-connections-dbus.c
list_connections_dbus_LDADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
list_connections_libnm_glib_SOURCES = list-connections-libnm-glib.c
list_connections_libnm_glib_LDADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/libnm-glib/libnm-glib.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
get_ap_info_libnm_glib_SOURCES = get-ap-info-libnm-glib.c
get_ap_info_libnm_glib_LDADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/libnm-glib/libnm-glib.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
EXTRA_DIST = \
add-connection-glib.c \
get-active-connections.c \
list-connections-dbus.c \
list-connections-libnm-glib.c \
get-ap-info-libnm-glib.c

View file

@ -0,0 +1,113 @@
/*
* 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.
*/
/*
* The example shows how to call AddConnection() D-Bus method to add
* a connection to system settings service. It uses dbus-glib and libnm-util
* libraries.
*
* Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` add-connection-glib.c -o add-connection-glib
*/
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <nm-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-ip4-config.h>
#include <NetworkManager.h>
#include <nm-utils.h>
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
static void
add_connection (DBusGProxy *proxy, const char *con_name)
{
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
NMSettingIP4Config *s_ip4;
char *uuid;
GHashTable *hash;
GError *error = NULL;
/* Create a new connection object */
connection = (NMConnection *) nm_connection_new ();
/* Build up the 'connection' Setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
uuid = nm_utils_uuid_generate ();
g_object_set (G_OBJECT (s_con),
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_ID, con_name,
NM_SETTING_CONNECTION_TYPE, "802-3-ethernet",
NULL);
g_free (uuid);
nm_connection_add_setting (connection, NM_SETTING (s_con));
/* Build up the 'wired' Setting */
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wired));
/* Build up the 'ipv4' Setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
g_object_set (G_OBJECT (s_ip4),
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
NULL);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
hash = nm_connection_to_hash (connection);
/* Call AddConnection with the hash as argument */
dbus_g_proxy_call (proxy, "AddConnection", &error,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
G_TYPE_INVALID);
g_hash_table_destroy (hash);
g_object_unref (connection);
}
int main (int argc, char *argv[])
{
DBusGConnection *bus;
DBusGProxy *proxy;
/* Initialize GType system */
g_type_init ();
/* Get system bus */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
/* Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h */
proxy = dbus_g_proxy_new_for_name (bus,
NM_DBUS_SERVICE_SYSTEM_SETTINGS,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
/* Add a connection */
add_connection (proxy, "__Test connection__");
g_object_unref (proxy);
dbus_g_connection_unref (bus);
return 0;
}

View file

@ -0,0 +1,248 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2010 Red Hat, Inc.
*/
/*
* The example shows how to call the D-Bus properties interface to get the
* list of currently active connections known to NetworkManager. It uses
* dbus-glib and libnm-util libraries.
*
* Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` get-active-connections.c -o get-active-connections
*/
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <nm-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-ip4-config.h>
#include <NetworkManager.h>
#include <nm-utils.h>
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
static void
print_connection (DBusGConnection *bus, const char *service, const char *path)
{
DBusGProxy *proxy;
GError *error = NULL;
GHashTable *hash = NULL;
NMConnection *connection = NULL;
/* This function asks the Settings Service that provides this network
* configuration for the details of that configuration.
*/
/* Create the D-Bus proxy for the Settings Service so we can ask it for the
* connection configuration details.
*/
proxy = dbus_g_proxy_new_for_name (bus,
service,
path,
NM_DBUS_IFACE_SETTINGS_CONNECTION);
g_assert (proxy);
/* Request the all the configuration of the Connection */
if (!dbus_g_proxy_call (proxy, "GetSettings", &error,
G_TYPE_INVALID,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &hash,
G_TYPE_INVALID)) {
g_warning ("Failed to get active connection Connection property: %s",
error->message);
g_error_free (error);
goto out;
}
/* Using the raw configuration, create an NMConnection object for it. This
* step also verifies that the data we got from the settings service is
* valid. */
connection = nm_connection_new_from_hash (hash, &error);
if (!connection) {
g_warning ("Received invalid connection data: %s", error->message);
g_error_free (error);
goto out;
}
/* And finally dump all the configuration to stdout */
g_message ("%s => %s", service, path);
nm_connection_dump (connection);
out:
if (connection)
g_object_unref (connection);
if (hash)
g_hash_table_destroy (hash);
g_object_unref (proxy);
}
static void
get_active_connection_details (DBusGConnection *bus, const char *obj_path)
{
DBusGProxy *props_proxy;
GValue path_value = { 0 };
GValue serv_value = { 0 };
GError *error = NULL;
const char *path = NULL, *service = NULL;
/* This function gets the backing Connection object that describes the
* network configuration that the ActiveConnection object is actually using.
* The ActiveConnection object contains the mapping between the configuration
* and the actual network interfaces that are using that configuration.
*/
/* Create a D-Bus object proxy for the active connection object's properties */
props_proxy = dbus_g_proxy_new_for_name (bus,
NM_DBUS_SERVICE,
obj_path,
DBUS_INTERFACE_PROPERTIES);
g_assert (props_proxy);
/* Get the object path of the Connection details */
if (!dbus_g_proxy_call (props_proxy, "Get", &error,
G_TYPE_STRING, NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
G_TYPE_STRING, "Connection",
G_TYPE_INVALID,
G_TYPE_VALUE, &path_value,
G_TYPE_INVALID)) {
g_warning ("Failed to get active connection Connection property: %s",
error->message);
g_error_free (error);
goto out;
}
if (!G_VALUE_HOLDS (&path_value, DBUS_TYPE_G_OBJECT_PATH)) {
g_warning ("Unexpected type returned getting Connection property: %s",
G_VALUE_TYPE_NAME (&path_value));
goto out;
}
path = g_value_get_boxed (&path_value);
if (!path) {
g_warning ("Missing connection path!");
goto out;
}
/* Get the service name of the D-Bus service that provides the Connection */
if (!dbus_g_proxy_call (props_proxy, "Get", &error,
G_TYPE_STRING, NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
G_TYPE_STRING, "ServiceName",
G_TYPE_INVALID,
G_TYPE_VALUE, &serv_value,
G_TYPE_INVALID)) {
g_warning ("Failed to get active connection ServiceName property: %s",
error->message);
g_error_free (error);
goto out;
}
if (!G_VALUE_HOLDS (&serv_value, G_TYPE_STRING)) {
g_warning ("Unexpected type returned getting Connection property: %s",
G_VALUE_TYPE_NAME (&serv_value));
goto out;
}
service = g_value_get_string (&serv_value);
if (!service) {
g_warning ("Missing connection service name!");
goto out;
}
/* Print out the actual connection details */
print_connection (bus, service, path);
out:
g_value_unset (&path_value);
g_value_unset (&serv_value);
g_object_unref (props_proxy);
}
static void
get_active_connections (DBusGConnection *bus, DBusGProxy *proxy)
{
GError *error = NULL;
GValue value = { 0 };
GPtrArray *paths = NULL;
int i;
/* Get the ActiveConnections property from the NM Manager object */
if (!dbus_g_proxy_call (proxy, "Get", &error,
G_TYPE_STRING, NM_DBUS_INTERFACE,
G_TYPE_STRING, "ActiveConnections",
G_TYPE_INVALID,
G_TYPE_VALUE, &value,
G_TYPE_INVALID)) {
g_warning ("Failed to get ActiveConnections property: %s", error->message);
g_error_free (error);
return;
}
/* Make sure the ActiveConnections property is the type we expect it to be */
if (!G_VALUE_HOLDS (&value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) {
g_warning ("Unexpected type returned getting ActiveConnections: %s",
G_VALUE_TYPE_NAME (&value));
goto out;
}
/* Extract the active connections array from the GValue */
paths = g_value_get_boxed (&value);
if (!paths) {
g_warning ("Could not retrieve active connections property");
goto out;
}
/* And print out the details of each active connection */
for (i = 0; i < paths->len; i++)
get_active_connection_details (bus, g_ptr_array_index (paths, i));
out:
g_value_unset (&value);
}
int main (int argc, char *argv[])
{
DBusGConnection *bus;
DBusGProxy *props_proxy;
/* Initialize GType system */
g_type_init ();
/* Get system bus */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
/* Create a D-Bus proxy to get the object properties from the NM Manager
* object. NM_DBUS_* defines are from NetworkManager.h.
*/
props_proxy = dbus_g_proxy_new_for_name (bus,
NM_DBUS_SERVICE,
NM_DBUS_PATH,
DBUS_INTERFACE_PROPERTIES);
g_assert (props_proxy);
/* Get active connections */
get_active_connections (bus, props_proxy);
g_object_unref (props_proxy);
dbus_g_connection_unref (bus);
return 0;
}

View file

@ -0,0 +1,229 @@
/*
* 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.
*/
/*
* The example shows how to get info about APs visible by Wi-Fi devices
* using libnm-glib (that wraps direct D-Bus calls).
* The example uses dbus-glib, libnm-util and libnm-glib libraries.
*
* Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util libnm-glib` get-ap-info-libnm-glib.c -o get-ap-info-libnm-glib
*/
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <nm-client.h>
#include <nm-device.h>
#include <nm-device-wifi.h>
#include <nm-access-point.h>
#include <NetworkManager.h>
#include <nm-utils.h>
/* Convert flags to string */
static char *
ap_wpa_rsn_flags_to_string (guint32 flags)
{
char *flags_str[16]; /* Enough space for flags and terminating NULL */
char *ret_str;
int i = 0;
if (flags & NM_802_11_AP_SEC_PAIR_WEP40)
flags_str[i++] = g_strdup ("pair_wpe40");
if (flags & NM_802_11_AP_SEC_PAIR_WEP104)
flags_str[i++] = g_strdup ("pair_wpe104");
if (flags & NM_802_11_AP_SEC_PAIR_TKIP)
flags_str[i++] = g_strdup ("pair_tkip");
if (flags & NM_802_11_AP_SEC_PAIR_CCMP)
flags_str[i++] = g_strdup ("pair_ccmp");
if (flags & NM_802_11_AP_SEC_GROUP_WEP40)
flags_str[i++] = g_strdup ("group_wpe40");
if (flags & NM_802_11_AP_SEC_GROUP_WEP104)
flags_str[i++] = g_strdup ("group_wpe104");
if (flags & NM_802_11_AP_SEC_GROUP_TKIP)
flags_str[i++] = g_strdup ("group_tkip");
if (flags & NM_802_11_AP_SEC_GROUP_CCMP)
flags_str[i++] = g_strdup ("group_ccmp");
if (flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
flags_str[i++] = g_strdup ("psk");
if (flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
flags_str[i++] = g_strdup ("802.1X");
if (i == 0)
flags_str[i++] = g_strdup ("none");
flags_str[i] = NULL;
ret_str = g_strjoinv (" ", flags_str);
i = 0;
while (flags_str[i])
g_free (flags_str[i++]);
return ret_str;
}
static void
show_access_point_info (NMAccessPoint *ap)
{
guint32 flags, wpa_flags, rsn_flags, freq, bitrate;
guint8 strength;
const GByteArray *ssid;
const char *hwaddr;
NM80211Mode mode;
char *freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str;
GString *security_str;
/* Get AP properties */
flags = nm_access_point_get_flags (ap);
wpa_flags = nm_access_point_get_wpa_flags (ap);
rsn_flags = nm_access_point_get_rsn_flags (ap);
ssid = nm_access_point_get_ssid (ap);
hwaddr = nm_access_point_get_hw_address (ap);
freq = nm_access_point_get_frequency (ap);
mode = nm_access_point_get_mode (ap);
bitrate = nm_access_point_get_max_bitrate (ap);
strength = nm_access_point_get_strength (ap);
/* Convert to strings */
ssid_str = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
freq_str = g_strdup_printf ("%u MHz", freq);
bitrate_str = g_strdup_printf ("%u MB/s", bitrate/1000);
strength_str = g_strdup_printf ("%u", strength);
wpa_flags_str = ap_wpa_rsn_flags_to_string (wpa_flags);
rsn_flags_str = ap_wpa_rsn_flags_to_string (rsn_flags);
security_str = g_string_new (NULL);
if ( !(flags & NM_802_11_AP_FLAGS_PRIVACY)
&& (wpa_flags != NM_802_11_AP_SEC_NONE)
&& (rsn_flags != NM_802_11_AP_SEC_NONE))
g_string_append (security_str, "Encrypted: ");
if ( (flags & NM_802_11_AP_FLAGS_PRIVACY)
&& (wpa_flags == NM_802_11_AP_SEC_NONE)
&& (rsn_flags == NM_802_11_AP_SEC_NONE))
g_string_append (security_str, "WEP ");
if (wpa_flags != NM_802_11_AP_SEC_NONE)
g_string_append (security_str, "WPA ");
if (rsn_flags != NM_802_11_AP_SEC_NONE)
g_string_append (security_str, "WPA2 ");
if ( (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
|| (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
g_string_append (security_str, "Enterprise ");
if (security_str->len > 0)
g_string_truncate (security_str, security_str->len-1); /* Chop off last space */
printf ("SSID: %s\n", ssid_str);
printf ("BSSID: %s\n", hwaddr);
printf ("Mode: %s\n", mode == NM_802_11_MODE_ADHOC ? "Ad-Hoc" : mode == NM_802_11_MODE_INFRA ? "Infrastructure" : "Unknown");
printf ("Freq: %s\n", freq_str);
printf ("Bitrate: %s\n", bitrate_str);
printf ("Strength: %s\n", strength_str);
printf ("Security: %s\n", security_str->str);
printf ("WPA flags: %s\n", wpa_flags_str);
printf ("RSN flags: %s\n", rsn_flags_str);
printf ("D-Bus path: %s\n\n", nm_object_get_path (NM_OBJECT (ap)));
g_free (ssid_str);
g_free (freq_str);
g_free (bitrate_str);
g_free (strength_str);
g_free (wpa_flags_str);
g_free (rsn_flags_str);
g_string_free (security_str, TRUE);
}
static void
show_wifi_device_info (NMDevice *device)
{
NMAccessPoint *active_ap = NULL;
const GPtrArray *aps;
const char *iface;
const char *driver;
guint32 speed;
const GByteArray *active_ssid;
char *active_ssid_str = NULL;
int i;
/* Get active AP */
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
if ((active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device)))) {
active_ssid = nm_access_point_get_ssid (active_ap);
active_ssid_str = nm_utils_ssid_to_utf8 ((const char *) active_ssid->data, active_ssid->len);
}
}
iface = nm_device_get_iface (device);
driver = nm_device_get_driver (device);
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device));
speed /= 1000;
printf ("Device: %s ---- Driver: %s ---- Speed: %d MB/s ---- Active AP: %s\n",
iface, driver, speed, active_ssid_str ? active_ssid_str : "none");
printf ("=================================================================================\n");
g_free (active_ssid_str);
/* Get all APs of the Wi-Fi device */
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
/* Print AP details */
for (i = 0; aps && (i < aps->len); i++) {
NMAccessPoint *ap = g_ptr_array_index (aps, i);
show_access_point_info (ap);
}
}
int main (int argc, char *argv[])
{
DBusGConnection *bus;
NMClient *client;
const GPtrArray *devices;
int i;
/* Initialize GType system */
g_type_init ();
/* Get system bus */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
/* Get NMClient object */
client = nm_client_new ();
if (!client) {
dbus_g_connection_unref (bus);
g_message ("Error: Could not create NMClient.");
return EXIT_FAILURE;
}
/* Get all devices managed by NetworkManager */
devices = nm_client_get_devices (client);
/* Go through the array and process Wi-Fi devices */
for (i = 0; devices && (i < devices->len); i++) {
NMDevice *device = g_ptr_array_index (devices, i);
if (NM_IS_DEVICE_WIFI (device))
show_wifi_device_info (device);
}
g_object_unref (client);
dbus_g_connection_unref (bus);
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,83 @@
/*
* 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.
*/
/*
* The example shows how to list connections from System Settings service using direct
* D-Bus call of ListConnections method.
* The example uses dbus-glib, libnm-util libraries.
*
* Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` list-connections-dbus.c -o list-connections-dbus
*/
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <NetworkManager.h>
#include <nm-utils.h>
#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
static void
list_connections (DBusGProxy *proxy)
{
int i;
GError *error = NULL;
GPtrArray *con_array;
/* Call ListConnections D-Bus method */
dbus_g_proxy_call (proxy, "ListConnections", &error,
/* No input arguments */
G_TYPE_INVALID,
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &con_array, /* Return values */
G_TYPE_INVALID);
for (i = 0; con_array && i < con_array->len; i++) {
char *connection_path = g_ptr_array_index (con_array, i);
printf ("%s\n", connection_path);
g_free (connection_path);
}
g_ptr_array_free (con_array, TRUE);
}
int main (int argc, char *argv[])
{
DBusGConnection *bus;
DBusGProxy *proxy;
/* Initialize GType system */
g_type_init ();
/* Get system bus */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
/* Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h */
proxy = dbus_g_proxy_new_for_name (bus,
NM_DBUS_SERVICE_SYSTEM_SETTINGS,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
/* List connections of system settings service */
list_connections (proxy);
g_object_unref (proxy);
dbus_g_connection_unref (bus);
return 0;
}

View file

@ -0,0 +1,178 @@
/*
* 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.
*/
/*
* The example shows how to list connections from System Settings service using libnm-glib
* (that wraps direct D-Bus calls).
* The example uses dbus-glib, libnm-util and libnm-glib libraries.
*
* Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util libnm-glib` list-connections-libnm-glib.c -o list-connections-libnm-glib
*/
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <nm-connection.h>
#include <nm-setting-connection.h>
#include <NetworkManager.h>
#include <nm-utils.h>
#include <nm-remote-settings.h>
#include <nm-remote-settings-system.h>
#include <nm-settings-interface.h>
/* Global variables */
GMainLoop *loop = NULL; /* Main loop variable - needed for waiting for signal */
int result = EXIT_SUCCESS;
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);
}
/* Print details of connection */
static void
show_connection (NMConnection *data, gpointer user_data)
{
NMConnection *connection = (NMConnection *) data;
NMSettingConnection *s_con;
guint64 timestamp;
char *timestamp_str;
char timestamp_real_str[64];
const char *val1, *val2, *val3, *val4, *val5;
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
if (s_con) {
/* Get various info from NMSettingConnection and show it */
timestamp = nm_setting_connection_get_timestamp (s_con);
timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
strftime (timestamp_real_str, sizeof (timestamp_real_str), "%c", localtime ((time_t *) &timestamp));
val1 = nm_setting_connection_get_id (s_con);
val2 = nm_setting_connection_get_uuid (s_con);
val3 = nm_setting_connection_get_connection_type (s_con);
val4 = nm_connection_get_path (connection);
val5 = timestamp ? timestamp_real_str : "never";
printf ("%-25s | %s | %-15s | %-43s | %s\n", val1, val2, val3, val4, val5);
g_free (timestamp_str);
}
}
/* This callback is called when connections from the settings service are ready.
* Now the connections can be listed.
*/
static void
get_connections_cb (NMSettingsInterface *settings, gpointer user_data)
{
GSList *system_connections;
system_connections = nm_settings_interface_list_connections (settings);
printf ("System connections:\n===================\n");
g_slist_foreach (system_connections, (GFunc) show_connection, NULL);
g_slist_free (system_connections);
g_object_unref (settings);
/* We are done, exit main loop */
g_main_loop_quit (loop);
}
/* Get system settings and then connect to connections-read signal */
static gboolean
list_connections (gpointer data)
{
DBusGConnection *bus = (DBusGConnection *) data;
NMRemoteSettingsSystem *system_settings;
gboolean system_settings_running;
/* Get system settings */
if (!(system_settings = nm_remote_settings_system_new (bus))) {
g_message ("Error: Could not get system settings.");
result = EXIT_FAILURE;
g_main_loop_quit (loop);
return FALSE;
}
/* Find out whether setting service is running */
g_object_get (system_settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &system_settings_running, NULL);
if (!system_settings_running) {
g_message ("Error: Can't obtain connections: settings service is not running.");
result = EXIT_FAILURE;
g_main_loop_quit (loop);
return FALSE;
}
/* Connect to signal "connections-read" - emitted when connections are fetched and ready */
g_signal_connect (system_settings, NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
G_CALLBACK (get_connections_cb), NULL);
return FALSE;
}
int main (int argc, char *argv[])
{
DBusGConnection *bus;
/* Initialize GType system */
g_type_init ();
/* Get system bus */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
/* Run list_connections from main loop, because we need to wait for "connections-read"
* signal to have connections ready. The execution will be finished in get_connections_cb()
* callback on the signal.
*/
g_idle_add (list_connections, bus);
loop = g_main_loop_new (NULL, FALSE); /* Create main loop */
setup_signals (); /* Setup UNIX signals */
g_main_loop_run (loop); /* Run main loop */
g_main_loop_unref (loop);
dbus_g_connection_unref (bus);
return result;
}

View file

@ -1 +1,3 @@
SUBDIRS=python
SUBDIRS= \
python \
C

View file

@ -3,6 +3,7 @@ EXTRA_DIST = \
add-system-connection.py \
vpn.py \
list-connections.py \
show-bssids.py
show-bssids.py \
disconnect-device.py

View file

@ -0,0 +1,62 @@
#!/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2010 Red Hat, Inc.
#
import dbus, sys
# This example takes a device interface name as a parameter and tells
# NetworkManager to disconnect that device, closing down any network
# connection it may have
if len(sys.argv) != 2:
raise Exception("Usage: %s <interface>" % sys.argv[0])
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")
dpath = None
# Find the device the user wants to disconnect
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")
iface = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface")
if iface == sys.argv[1]:
dpath = d
break
if not dpath or not len(dpath):
raise Exception("NetworkManager knows nothing about %s" % sys.argv[1])
dev_proxy = bus.get_object("org.freedesktop.NetworkManager", dpath)
dev_iface = dbus.Interface(dev_proxy, "org.freedesktop.NetworkManager.Device")
prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties")
# Make sure the device is connected before we try to disconnect it
state = prop_iface.Get("org.freedesktop.NetworkManager.Device", "State")
if state <= 3:
raise Exception("Device %s isn't connected" % sys.argv[1])
# Tell NM to disconnect it
dev_iface.Disconnect()

View file

@ -47,13 +47,13 @@ active = manager_prop_iface.Get("org.freedesktop.NetworkManager", "ActiveConnect
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")
state = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "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")
con_path = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "Connection")
con_service = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "ServiceName")
# ask the provider of the connection for its details
service_proxy = bus.get_object(con_service, con_path)

View file

@ -16,7 +16,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 - 2008 Red Hat, Inc.
* (C) Copyright 2004 - 2010 Red Hat, Inc.
*/
#ifndef NETWORK_MANAGER_H
@ -250,7 +250,7 @@ typedef enum {
/* Device is now managed */
NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
/* Device is now managed unmanaged */
/* Device is now unmanaged */
NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
/* The device could not be readied for configuration */

View file

@ -166,6 +166,9 @@ typedef enum {
*/
#define NM_VPN_PLUGIN_IP4_CONFIG_ROUTES "routes"
/* boolean: prevent this VPN connection from ever getting the default route */
#define NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT "never-default"
/* Deprecated */
#define NM_VPN_PLUGIN_IP4_CONFIG_GATEWAY NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY

View file

@ -23,3 +23,6 @@ endif
if TARGET_MANDRIVA
SUBDIRS += Mandriva
endif
if TARGET_LINEXA
SUBDIRS += linexa
endif

View file

@ -49,7 +49,7 @@ start()
echo
echo -n $"Starting NetworkManager daemon: "
daemon --check $servicename $processname --pid-file=$pidfile
daemon --pidfile $pidfile --check $servicename $processname --pid-file=$pidfile
RETVAL=$?
echo
if [ -n "${NETWORKWAIT}" ]; then

View file

@ -0,0 +1,6 @@
EXTRA_DIST = networkmanager
DISTCLEANFILES = networkmanager
initddir = $(sysconfdir)/rc.d/init.d
initd_SCRIPTS = networkmanager

View file

@ -0,0 +1,59 @@
#!/bin/bash
# Start the networkmanager daemon
#
# Author: Elias <elias@linexa.de>
# [2010-08-20]
# Information about the daemon
title="networkmanager" # No spaces allowed in here
start_after="dbus" # dependencies for start-up
stop_after="xinetd" # dependencies for stop
runlevel="2" # start/stop in this runlevel
sequence="25" # "checkinstall networkmanager enable"
# will create links to:
# /etc/rc.d/rc${runlevel}.d/S${sequence}${title}
# /etc/rc.d/rc${runlevel}.d/S$((100 - ${sequence}))${title}
# check whether daemon is running
# returns 0 if running, >0 if not
check() {
[ -f /var/run/NetworkManager.pid ]
}
# start procedure
start() {
if check ; then
warning "${title} is already running. Type 'service restart ${title}'" # Issue a warning
else
/usr/sbin/NetworkManager &
evaluate_retval "Starting ${title}. " # Print [ done ] or [ failed ] depending on outcome
fi
}
# stop procedure
stop() {
if check ; then # daemon is running
kill $(cat /var/run/NetworkManager.pid)
evaluate_retval "Stopping ${title}." # Print [ done ] or [ failed ] depending on outcome
else # daemon not running
warning "${title} is not running." # Issue a warning
fi
}
# restart procedure
restart() {
stop
sleep 1
start
}
# reload action
reload() {
if check ; then # daemon is running
kill -HUP $(cat /var/run/NetworkManager.pid) &>/dev/null
evaluate_retval "Reloading ${title}." # Print [ done ] or [ failed ] depending on outcome
else # daemon not running
warning "${title} is not running." # Issue a warning
fi
}

View file

@ -5,7 +5,13 @@
<property name="HwAddress" type="s" access="read">
<tp:docstring>
Hardware address of the device.
Active hardware address of the device.
</tp:docstring>
</property>
<property name="PermHwAddress" type="s" access="read">
<tp:docstring>
Permanent hardware address of the device.
</tp:docstring>
</property>

View file

@ -16,9 +16,16 @@
<property name="HwAddress" type="s" access="read">
<tp:docstring>
The hardware address of the device.
The active hardware address of the device.
</tp:docstring>
</property>
<property name="PermHwAddress" type="s" access="read">
<tp:docstring>
The permanent hardware address of the device.
</tp:docstring>
</property>
<property name="Mode" type="u" access="read" tp:type="NM_802_11_MODE">
<tp:docstring>
The operating mode of the wireless device.

View file

@ -9,7 +9,15 @@
</property>
<property name="Interface" type="s" access="read">
<tp:docstring>
The network interface offered by the device.
The name of the device's control (and often data) interface.
</tp:docstring>
</property>
<property name="IpInterface" type="s" access="read">
<tp:docstring>
The name of the device's data interface when available. This property
may not refer to the actual data interface until the device has
successfully established a data connection, indicated by the device's
State becoming ACTIVATED.
</tp:docstring>
</property>
<property name="Driver" type="s" access="read">
@ -52,6 +60,12 @@
Whether or not this device is managed by NetworkManager.
</tp:docstring>
</property>
<property name="FirmwareMissing" type="b" access="read">
<tp:docstring>
If TRUE, indicates the device is likely missing firmware necessary for
its operation.
</tp:docstring>
</property>
<property name="DeviceType" type="u" access="read" tp:type="NM_DEVICE_TYPE">
<tp:docstring>
The general type of the network device; ie Ethernet, WiFi, etc.
@ -59,10 +73,11 @@
</property>
<method name="Disconnect">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<tp:docstring>
Disconnects a device and prevents the device from automatically activating further connections without user intervention.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/>
</method>
<signal name="StateChanged">

View file

@ -31,14 +31,31 @@ object. dbus-glib generates the same bound function names for D-Bus the methods
<method name="DeactivateConnection">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_deactivate_connection"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="active_connection" type="o" direction="in"/>
</method>
<method name="Sleep">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_sleep"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="sleep" type="b" direction="in"/>
</method>
<method name="Enable">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_enable"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="enable" type="b" direction="in"/>
</method>
<method name="GetPermissions">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_permissions"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="permissions" type="a{ss}" direction="out"/>
</method>
<signal name="CheckPermissions"/>
<property name="NetworkingEnabled" type="b" access="read"/>
<property name="WirelessEnabled" type="b" access="readwrite"/>
<property name="WirelessHardwareEnabled" type="b" access="read"/>
<property name="WwanEnabled" type="b" access="readwrite"/>
@ -46,6 +63,7 @@ object. dbus-glib generates the same bound function names for D-Bus the methods
<property name="WimaxEnabled" type="b" access="readwrite"/>
<property name="WimaxHardwareEnabled" type="b" access="read"/>
<property name="ActiveConnections" type="ao" access="read"/>
<property name="Version" type="s" access="read"/>
<property name="State" type="u" access="read"/>
<signal name="StateChanged">

View file

@ -77,6 +77,7 @@
Deactivate an active connection.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_deactivate_connection"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="active_connection" type="o" direction="in">
<tp:docstring>
The currently active connection to deactivate.
@ -86,8 +87,12 @@
<method name="Sleep">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_sleep"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<tp:docstring>
Control the NetworkManager daemon's sleep state. When asleep, all interfaces that it manages are deactivated. When awake, devices are available to be activated.
Control the NetworkManager daemon's sleep state. When asleep, all
interfaces that it manages are deactivated. When awake, devices are
available to be activated. This command should not be called directly
by users or clients; it is intended for system suspend/resume tracking.
</tp:docstring>
<arg name="sleep" type="b" direction="in">
<tp:docstring>
@ -96,6 +101,52 @@
</arg>
</method>
<method name="Enable">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_enable"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<tp:docstring>
Control whether overall networking is enabled or disabled. When
disabled, all interfaces that NM manages are deactivated. When enabled,
all managed interfaces are re-enabled and available to be activated.
This command should be used by clients that provide to users the ability
to enable/disable all networking.
</tp:docstring>
<arg name="enable" type="b" direction="in">
<tp:docstring>
If FALSE, indicates that all networking should be disabled. If TRUE,
indicates that NetworkManager should begin managing network devices.
</tp:docstring>
</arg>
</method>
<method name="GetPermissions">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_permissions"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<tp:docstring>
Returns the permissions a caller has for various authenticated operations
that NetworkManager provides, like Enable/Disable networking, changing
WiFi, WWAN, and WiMAX state, etc.
</tp:docstring>
<arg name="permissions" type="a{ss}" direction="out">
<tp:docstring>
Dictionary of available permissions and results. Each permission
is represented by a name (ie "org.freedesktop.NetworkManager.Foobar")
and each result is one of the following values: "yes" (the permission
is available), "auth" (the permission is available after a successful
authentication), or "no" (the permission is denied). Clients may use
these values in the UI to indicate the ability to perform certain
operations.
</tp:docstring>
</arg>
</method>
<signal name="CheckPermissions">
<tp:docstring>
Emitted when system authorization details change, indicating that
clients may wish to recheck permissions with GetPermissions.
</tp:docstring>
</signal>
<method name="SetLogging">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_set_logging"/>
<tp:docstring>
@ -118,6 +169,13 @@
</arg>
</method>
<property name="NetworkingEnabled" type="b" access="read">
<tp:docstring>
Indicates if overall networking is currently enabled or not. See the
Enable() method.
</tp:docstring>
</property>
<property name="WirelessEnabled" type="b" access="readwrite">
<tp:docstring>
Indicates if wireless is currently enabled or not.
@ -160,6 +218,12 @@
</tp:docstring>
</property>
<property name="Version" type="s" access="read">
<tp:docstring>
NetworkManager version.
</tp:docstring>
</property>
<property name="State" type="u" access="read" tp:type="NM_STATE">
<tp:docstring>
The overall state of the NetworkManager daemon.
@ -259,6 +323,7 @@
DEPRECATED. Control the NetworkManager daemon's sleep state. When asleep, all interfaces that it manages are deactivated.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_legacy_sleep"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
</method>
<method name="wake">
@ -266,6 +331,7 @@
DEPRECATED. Control the NetworkManager daemon's sleep state. When awake, all known interfaces are available to be activated.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_legacy_wake"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
</method>
<method name="state">

View file

@ -53,7 +53,6 @@ lib_LTLIBRARIES = libnm-glib.la libnm-glib-vpn.la
libnm_glib_la_CFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
$(GCONF_CFLAGS) \
$(GUDEV_CFLAGS)
libnmincludedir = $(includedir)/libnm-glib
@ -133,11 +132,10 @@ libnm_glib_la_LIBADD = \
$(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:2:2"
-version-info "6:2:4"
noinst_PROGRAMS = libnm-glib-test
@ -154,58 +152,58 @@ libnm_glib_vpn_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib-vpn.ver \
nm-client-bindings.h: $(top_srcdir)/introspection/nm-manager-client.xml
dbus-binding-tool --prefix=nm_client --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_client --mode=glib-client --output=$@ $<
nm-device-bindings.h: $(top_srcdir)/introspection/nm-device.xml
dbus-binding-tool --prefix=nm_device --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_device --mode=glib-client --output=$@ $<
nm-device-ethernet-bindings.h: $(top_srcdir)/introspection/nm-device-ethernet.xml
dbus-binding-tool --prefix=nm_device_ethernet --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_device_ethernet --mode=glib-client --output=$@ $<
nm-device-wifi-bindings.h: $(top_srcdir)/introspection/nm-device-wifi.xml
dbus-binding-tool --prefix=nm_device_wifi --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_device_wifi --mode=glib-client --output=$@ $<
nm-device-bt-bindings.h: $(top_srcdir)/introspection/nm-device-bt.xml
dbus-binding-tool --prefix=nm_device_bt --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_device_bt --mode=glib-client --output=$@ $<
nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml
dbus-binding-tool --prefix=nm_access_point --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_access_point --mode=glib-client --output=$@ $<
nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml
dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $<
nm-settings-bindings.h: $(top_srcdir)/introspection/nm-settings.xml
dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $<
nm-settings-system-bindings.h: $(top_srcdir)/introspection/nm-settings-system.xml
dbus-binding-tool --prefix=nm_settings_system --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_system --mode=glib-client --output=$@ $<
nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml
dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=$@ $<
nm-exported-connection-bindings.h: $(top_srcdir)/introspection/nm-exported-connection.xml
dbus-binding-tool --prefix=nm_exported_connection --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-client --output=$@ $<
nm-vpn-connection-bindings.h: $(top_srcdir)/introspection/nm-vpn-connection.xml
dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-client --output=$@ $<
nm-vpn-plugin-glue.h: $(top_srcdir)/introspection/nm-vpn-plugin.xml
dbus-binding-tool --prefix=nm_vpn_plugin --mode=glib-server --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_plugin --mode=glib-server --output=$@ $<
nm-active-connection-bindings.h: $(top_srcdir)/introspection/nm-active-connection.xml
dbus-binding-tool --prefix=nm_active_connection --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_active_connection --mode=glib-client --output=$@ $<
nm-ip4-config-bindings.h: $(top_srcdir)/introspection/nm-ip4-config.xml
dbus-binding-tool --prefix=nm_ip4_config --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_ip4_config --mode=glib-client --output=$@ $<
nm-dhcp4-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp4-config.xml
dbus-binding-tool --prefix=nm_dhcp4_config --mode=glib-client --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_dhcp4_config --mode=glib-client --output=$@ $<
nm-ip6-config-bindings.h: $(top_srcdir)/introspection/nm-ip6-config.xml
dbus-binding-tool --prefix=nm_ip6_config --mode=glib-client --output=$@ $<
$(AM_V_GEN) 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=$@ $<
$(AM_V_GEN) 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=$@ $<

View file

@ -34,8 +34,11 @@ global:
nm_client_get_device_by_path;
nm_client_get_devices;
nm_client_get_manager_running;
nm_client_get_permission_result;
nm_client_get_state;
nm_client_get_type;
nm_client_networking_get_enabled;
nm_client_networking_set_enabled;
nm_client_new;
nm_client_sleep;
nm_client_wireless_get_enabled;
@ -63,12 +66,14 @@ global:
nm_device_bt_get_type;
nm_device_ethernet_get_carrier;
nm_device_ethernet_get_hw_address;
nm_device_ethernet_get_permanent_hw_address;
nm_device_ethernet_get_speed;
nm_device_ethernet_get_type;
nm_device_ethernet_new;
nm_device_get_capabilities;
nm_device_get_dhcp4_config;
nm_device_get_driver;
nm_device_get_firmware_missing;
nm_device_get_iface;
nm_device_get_ip4_config;
nm_device_get_ip6_config;
@ -85,6 +90,7 @@ global:
nm_device_wifi_get_bitrate;
nm_device_wifi_get_capabilities;
nm_device_wifi_get_hw_address;
nm_device_wifi_get_permanent_hw_address;
nm_device_wifi_get_mode;
nm_device_wifi_get_type;
nm_device_wifi_new;
@ -92,6 +98,10 @@ global:
nm_dhcp4_config_get_options;
nm_dhcp4_config_get_type;
nm_dhcp4_config_new;
nm_dhcp6_config_get_one_option;
nm_dhcp6_config_get_options;
nm_dhcp6_config_get_type;
nm_dhcp6_config_new;
nm_exported_connection_export;
nm_exported_connection_get_type;
nm_exported_connection_new;

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 <dbus/dbus-glib.h>
@ -58,6 +58,11 @@ typedef struct {
GPtrArray *devices;
GPtrArray *active_connections;
DBusGProxyCall *perm_call;
GHashTable *permissions;
gboolean have_networking_enabled;
gboolean networking_enabled;
gboolean wireless_enabled;
gboolean wireless_hw_enabled;
@ -72,6 +77,7 @@ enum {
PROP_0,
PROP_STATE,
PROP_MANAGER_RUNNING,
PROP_NETWORKING_ENABLED,
PROP_WIRELESS_ENABLED,
PROP_WIRELESS_HARDWARE_ENABLED,
PROP_WWAN_ENABLED,
@ -86,6 +92,7 @@ enum {
enum {
DEVICE_ADDED,
DEVICE_REMOVED,
PERMISSION_CHANGED,
LAST_SIGNAL
};
@ -101,12 +108,31 @@ static void proxy_name_owner_changed (DBusGProxy *proxy,
static void client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data);
static void client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data);
static void
handle_net_enabled_changed (GObject *object,
GParamSpec *pspec,
GValue *value,
gpointer user_data)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
/* Update the cache flag when it changes */
priv->have_networking_enabled = TRUE;
}
static void
nm_client_init (NMClient *client)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
priv->state = NM_STATE_UNKNOWN;
priv->permissions = g_hash_table_new (g_direct_hash, g_direct_equal);
g_signal_connect (client,
"notify::" NM_CLIENT_NETWORKING_ENABLED,
G_CALLBACK (handle_net_enabled_changed),
client);
}
static void
@ -285,6 +311,7 @@ register_for_property_changed (NMClient *client)
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
const NMPropertiesChangedInfo property_changed_info[] = {
{ NM_CLIENT_STATE, _nm_object_demarshal_generic, &priv->state },
{ NM_CLIENT_NETWORKING_ENABLED, _nm_object_demarshal_generic, &priv->networking_enabled },
{ NM_CLIENT_WIRELESS_ENABLED, _nm_object_demarshal_generic, &priv->wireless_enabled },
{ NM_CLIENT_WIRELESS_HARDWARE_ENABLED, _nm_object_demarshal_generic, &priv->wireless_hw_enabled },
{ NM_CLIENT_WWAN_ENABLED, _nm_object_demarshal_generic, &priv->wwan_enabled },
@ -300,6 +327,130 @@ register_for_property_changed (NMClient *client)
property_changed_info);
}
#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
#define NM_AUTH_PERMISSION_USE_USER_CONNECTIONS "org.freedesktop.NetworkManager.use-user-connections"
static NMClientPermission
nm_permission_to_client (const char *nm)
{
if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK))
return NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK;
else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI))
return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI;
else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN))
return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN;
else if (!strcmp (nm, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS))
return NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS;
return NM_CLIENT_PERMISSION_NONE;
}
static NMClientPermissionResult
nm_permission_result_to_client (const char *nm)
{
if (!strcmp (nm, "yes"))
return NM_CLIENT_PERMISSION_RESULT_YES;
else if (!strcmp (nm, "no"))
return NM_CLIENT_PERMISSION_RESULT_NO;
else if (!strcmp (nm, "auth"))
return NM_CLIENT_PERMISSION_RESULT_AUTH;
return NM_CLIENT_PERMISSION_RESULT_UNKNOWN;
}
static void
update_permissions (NMClient *self, GHashTable *permissions)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
GHashTableIter iter;
gpointer key, value;
NMClientPermission perm;
NMClientPermissionResult perm_result;
GList *keys, *keys_iter;
/* get list of old permissions for change notification */
keys = g_hash_table_get_keys (priv->permissions);
g_hash_table_remove_all (priv->permissions);
if (permissions) {
/* Process new permissions */
g_hash_table_iter_init (&iter, permissions);
while (g_hash_table_iter_next (&iter, &key, &value)) {
perm = nm_permission_to_client ((const char *) key);
perm_result = nm_permission_result_to_client ((const char *) value);
if (perm) {
g_hash_table_insert (priv->permissions,
GUINT_TO_POINTER (perm),
GUINT_TO_POINTER (perm_result));
/* Remove this permission from the list of previous permissions
* we'll be sending NM_CLIENT_PERMISSION_RESULT_UNKNOWN for
* in the change signal since it is still a known permission.
*/
keys = g_list_remove (keys, GUINT_TO_POINTER (perm));
}
}
}
/* Signal changes in all updated permissions */
g_hash_table_iter_init (&iter, priv->permissions);
while (g_hash_table_iter_next (&iter, &key, &value)) {
g_signal_emit (self, signals[PERMISSION_CHANGED], 0,
GPOINTER_TO_UINT (key),
GPOINTER_TO_UINT (value));
}
/* And signal changes in all permissions that used to be valid but for
* some reason weren't received in the last request (if any).
*/
for (keys_iter = keys; keys_iter; keys_iter = g_list_next (keys_iter)) {
g_signal_emit (self, signals[PERMISSION_CHANGED], 0,
GPOINTER_TO_UINT (keys_iter->data),
NM_CLIENT_PERMISSION_RESULT_UNKNOWN);
}
g_list_free (keys);
}
static void
get_permissions_sync (NMClient *self)
{
gboolean success;
GHashTable *permissions = NULL;
success = dbus_g_proxy_call_with_timeout (NM_CLIENT_GET_PRIVATE (self)->client_proxy,
"GetPermissions", 3000, NULL,
G_TYPE_INVALID,
DBUS_TYPE_G_MAP_OF_STRING, &permissions, G_TYPE_INVALID);
update_permissions (self, success ? permissions : NULL);
if (permissions)
g_hash_table_destroy (permissions);
}
static void
get_permissions_reply (DBusGProxy *proxy,
GHashTable *permissions,
GError *error,
gpointer user_data)
{
NMClient *self = NM_CLIENT (user_data);
NM_CLIENT_GET_PRIVATE (self)->perm_call = NULL;
update_permissions (NM_CLIENT (user_data), error ? NULL : permissions);
}
static void
client_recheck_permissions (DBusGProxy *proxy, gpointer user_data)
{
NMClient *self = NM_CLIENT (user_data);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
if (!priv->perm_call) {
priv->perm_call = org_freedesktop_NetworkManager_get_permissions_async (NM_CLIENT_GET_PRIVATE (self)->client_proxy,
get_permissions_reply,
self);
}
}
static GObject*
constructor (GType type,
guint n_construct_params,
@ -340,6 +491,15 @@ constructor (GType type,
object,
NULL);
/* Permissions */
dbus_g_proxy_add_signal (priv->client_proxy, "CheckPermissions", G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->client_proxy,
"CheckPermissions",
G_CALLBACK (client_recheck_permissions),
object,
NULL);
get_permissions_sync (NM_CLIENT (object));
priv->bus_proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
@ -398,12 +558,17 @@ dispose (GObject *object)
return;
}
if (priv->perm_call)
dbus_g_proxy_cancel_call (priv->client_proxy, priv->perm_call);
g_object_unref (priv->client_proxy);
g_object_unref (priv->bus_proxy);
free_object_array (&priv->devices);
free_object_array (&priv->active_connections);
g_hash_table_destroy (priv->permissions);
G_OBJECT_CLASS (nm_client_parent_class)->dispose (object);
}
@ -479,6 +644,9 @@ get_property (GObject *object,
case PROP_MANAGER_RUNNING:
g_value_set_boolean (value, priv->manager_running);
break;
case PROP_NETWORKING_ENABLED:
g_value_set_boolean (value, priv->networking_enabled);
break;
case PROP_WIRELESS_ENABLED:
g_value_set_boolean (value, priv->wireless_enabled);
break;
@ -547,6 +715,19 @@ nm_client_class_init (NMClientClass *client_class)
FALSE,
G_PARAM_READABLE));
/**
* NMClient::networking-enabled:
*
* Whether networking is enabled.
**/
g_object_class_install_property
(object_class, PROP_NETWORKING_ENABLED,
g_param_spec_boolean (NM_CLIENT_NETWORKING_ENABLED,
"NetworkingEnabled",
"Is networking enabled",
TRUE,
G_PARAM_READABLE));
/**
* NMClient::wireless-enabled:
*
@ -673,6 +854,22 @@ nm_client_class_init (NMClientClass *client_class)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
/**
* NMClient::permission-changed:
* @widget: the client that received the signal
* @permission: a permission from #NMClientPermission
* @result: the permission's result, one of #NMClientPermissionResult
*
* Notifies that a permission has changed
**/
signals[PERMISSION_CHANGED] =
g_signal_new ("permission-changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
_nm_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
}
/**
@ -1184,26 +1381,69 @@ nm_client_get_state (NMClient *client)
}
/**
* nm_client_sleep:
* nm_client_networking_get_enabled:
* @client: a #NMClient
* @sleep: %TRUE to put the daemon to sleep
*
* Enables or disables networking. When the daemon is put to sleep, it'll deactivate and disable
* all the active devices.
* Whether networking is enabled or disabled.
*
* Returns: %TRUE if networking is disabled, %FALSE if networking is enabled
**/
gboolean
nm_client_networking_get_enabled (NMClient *client)
{
NMClientPrivate *priv;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
priv = NM_CLIENT_GET_PRIVATE (client);
if (!priv->have_networking_enabled) {
priv = NM_CLIENT_GET_PRIVATE (client);
if (!priv->networking_enabled) {
priv->networking_enabled = _nm_object_get_boolean_property (NM_OBJECT (client),
NM_DBUS_INTERFACE,
"NetworkingEnabled");
priv->have_networking_enabled = TRUE;
}
}
return priv->networking_enabled;
}
/**
* nm_client_networking_set_enabled:
* @client: a #NMClient
* @enabled: %TRUE to set networking enabled, %FALSE to set networking disabled
*
* Enables or disables networking. When networking is disabled, all controlled
* interfaces are disconnected and deactivated. When networking is enabled,
* all controlled interfaces are available for activation.
**/
void
nm_client_sleep (NMClient *client, gboolean sleep)
nm_client_networking_set_enabled (NMClient *client, gboolean enable)
{
GError *err = NULL;
g_return_if_fail (NM_IS_CLIENT (client));
if (!org_freedesktop_NetworkManager_sleep (NM_CLIENT_GET_PRIVATE (client)->client_proxy, sleep, &err)) {
g_warning ("Error in sleep: %s", err->message);
if (!org_freedesktop_NetworkManager_enable (NM_CLIENT_GET_PRIVATE (client)->client_proxy, enable, &err)) {
g_warning ("Error enabling/disabling networking: %s", err->message);
g_error_free (err);
}
}
/**
* nm_client_sleep:
* @client: a #NMClient
* @sleep: %TRUE to put the daemon to sleep
*
* Deprecated; use nm_client_networking_set_enabled() instead.
**/
void
nm_client_sleep (NMClient *client, gboolean sleep)
{
nm_client_networking_set_enabled (client, !sleep);
}
/**
* nm_client_get_manager_running:
* @client: a #NMClient
@ -1220,3 +1460,25 @@ nm_client_get_manager_running (NMClient *client)
return NM_CLIENT_GET_PRIVATE (client)->manager_running;
}
/**
* nm_client_get_permission_result:
* @client: a #NMClient
* @permission: the permission for which to return the result, one of #NMClientPermission
*
* Requests the result of a specific permission, which indicates whether the
* client can or cannot perform the action the permission represents
*
* Returns: the permission's result, one of #NMClientPermissionResult
**/
NMClientPermissionResult
nm_client_get_permission_result (NMClient *client, NMClientPermission permission)
{
gpointer result;
g_return_val_if_fail (NM_IS_CLIENT (client), NM_CLIENT_PERMISSION_RESULT_UNKNOWN);
result = g_hash_table_lookup (NM_CLIENT_GET_PRIVATE (client)->permissions,
GUINT_TO_POINTER (permission));
return GPOINTER_TO_UINT (result);
}

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_CLIENT_H
@ -43,6 +43,7 @@ G_BEGIN_DECLS
#define NM_CLIENT_STATE "state"
#define NM_CLIENT_MANAGER_RUNNING "manager-running"
#define NM_CLIENT_NETWORKING_ENABLED "networking-enabled"
#define NM_CLIENT_WIRELESS_ENABLED "wireless-enabled"
#define NM_CLIENT_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
#define NM_CLIENT_WWAN_ENABLED "wwan-enabled"
@ -51,6 +52,25 @@ G_BEGIN_DECLS
#define NM_CLIENT_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled"
#define NM_CLIENT_ACTIVE_CONNECTIONS "active-connections"
/* Permissions */
typedef enum {
NM_CLIENT_PERMISSION_NONE = 0,
NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK = 1,
NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI = 2,
NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN = 3,
NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS = 4,
NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS
} NMClientPermission;
typedef enum {
NM_CLIENT_PERMISSION_RESULT_UNKNOWN = 0,
NM_CLIENT_PERMISSION_RESULT_YES,
NM_CLIENT_PERMISSION_RESULT_AUTH,
NM_CLIENT_PERMISSION_RESULT_NO
} NMClientPermissionResult;
typedef struct {
NMObject parent;
} NMClient;
@ -90,6 +110,9 @@ void nm_client_activate_connection (NMClient *client,
void nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active);
gboolean nm_client_networking_get_enabled (NMClient *client);
void nm_client_networking_set_enabled (NMClient *client, gboolean enabled);
gboolean nm_client_wireless_get_enabled (NMClient *client);
void nm_client_wireless_set_enabled (NMClient *client, gboolean enabled);
gboolean nm_client_wireless_hardware_get_enabled (NMClient *client);
@ -107,6 +130,9 @@ gboolean nm_client_get_manager_running (NMClient *client);
const GPtrArray *nm_client_get_active_connections (NMClient *client);
void nm_client_sleep (NMClient *client, gboolean sleep);
NMClientPermissionResult nm_client_get_permission_result (NMClient *client,
NMClientPermission permission);
G_END_DECLS
#endif /* NM_CLIENT_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 "nm-device-ethernet.h"
@ -34,7 +34,8 @@ G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE)
typedef struct {
DBusGProxy *proxy;
char * hw_address;
char *hw_address;
char *perm_hw_address;
guint32 speed;
gboolean carrier;
gboolean carrier_valid;
@ -45,6 +46,7 @@ typedef struct {
enum {
PROP_0,
PROP_HW_ADDRESS,
PROP_PERM_HW_ADDRESS,
PROP_SPEED,
PROP_CARRIER,
@ -52,6 +54,7 @@ enum {
};
#define DBUS_PROP_HW_ADDRESS "HwAddress"
#define DBUS_PROP_PERM_HW_ADDRESS "PermHwAddress"
#define DBUS_PROP_SPEED "Speed"
#define DBUS_PROP_CARRIER "Carrier"
@ -80,9 +83,9 @@ nm_device_ethernet_new (DBusGConnection *connection, const char *path)
* nm_device_ethernet_get_hw_address:
* @device: a #NMDeviceEthernet
*
* Gets the hardware (MAC) address of the #NMDeviceEthernet
* Gets the active hardware (MAC) address of the #NMDeviceEthernet
*
* Returns: the hardware address. This is the internal string used by the
* Returns: the active hardware address. This is the internal string used by the
* device, and must not be modified.
**/
const char *
@ -102,6 +105,32 @@ nm_device_ethernet_get_hw_address (NMDeviceEthernet *device)
return priv->hw_address;
}
/**
* nm_device_ethernet_get_permanent_hw_address:
* @device: a #NMDeviceEthernet
*
* Gets the permanent hardware (MAC) address of the #NMDeviceEthernet
*
* Returns: the permanent hardware address. This is the internal string used by the
* device, and must not be modified.
**/
const char *
nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device)
{
NMDeviceEthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL);
priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
if (!priv->perm_hw_address) {
priv->perm_hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_PERM_HW_ADDRESS);
}
return priv->perm_hw_address;
}
/**
* nm_device_ethernet_get_speed:
* @device: a #NMDeviceEthernet
@ -168,9 +197,10 @@ register_for_property_changed (NMDeviceEthernet *device)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
const NMPropertiesChangedInfo property_changed_info[] = {
{ NM_DEVICE_ETHERNET_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address },
{ NM_DEVICE_ETHERNET_SPEED, _nm_object_demarshal_generic, &priv->speed },
{ NM_DEVICE_ETHERNET_CARRIER, _nm_object_demarshal_generic, &priv->carrier },
{ NM_DEVICE_ETHERNET_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address },
{ NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, _nm_object_demarshal_generic, &priv->perm_hw_address },
{ NM_DEVICE_ETHERNET_SPEED, _nm_object_demarshal_generic, &priv->speed },
{ NM_DEVICE_ETHERNET_CARRIER, _nm_object_demarshal_generic, &priv->carrier },
{ NULL },
};
@ -230,6 +260,9 @@ finalize (GObject *object)
if (priv->hw_address)
g_free (priv->hw_address);
if (priv->perm_hw_address)
g_free (priv->perm_hw_address);
G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object);
}
@ -245,6 +278,9 @@ get_property (GObject *object,
case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_ethernet_get_hw_address (device));
break;
case PROP_PERM_HW_ADDRESS:
g_value_set_string (value, nm_device_ethernet_get_permanent_hw_address (device));
break;
case PROP_SPEED:
g_value_set_uint (value, nm_device_ethernet_get_speed (device));
break;
@ -275,13 +311,26 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *device_class)
/**
* NMDeviceEthernet:hw-address:
*
* The hardware (MAC) address of the device.
* The active hardware (MAC) address of the device.
**/
g_object_class_install_property
(object_class, PROP_HW_ADDRESS,
g_param_spec_string (NM_DEVICE_ETHERNET_HW_ADDRESS,
"MAC Address",
"Hardware MAC address",
"Active MAC Address",
"Currently set hardware MAC address",
NULL,
G_PARAM_READABLE));
/**
* NMDeviceEthernet:perm-hw-address:
*
* The permanent hardware (MAC) address of the device.
**/
g_object_class_install_property
(object_class, PROP_PERM_HW_ADDRESS,
g_param_spec_string (NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS,
"Permanent MAC Address",
"Permanent hardware MAC address",
NULL,
G_PARAM_READABLE));

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_DEVICE_ETHERNET_H
@ -36,6 +36,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetClass))
#define NM_DEVICE_ETHERNET_HW_ADDRESS "hw-address"
#define NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS "perm-hw-address"
#define NM_DEVICE_ETHERNET_SPEED "speed"
#define NM_DEVICE_ETHERNET_CARRIER "carrier"
@ -60,6 +61,7 @@ GType nm_device_ethernet_get_type (void);
GObject *nm_device_ethernet_new (DBusGConnection *connection, const char *path);
const char * nm_device_ethernet_get_hw_address (NMDeviceEthernet *device);
const char * nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device);
guint32 nm_device_ethernet_get_speed (NMDeviceEthernet *device);
gboolean nm_device_ethernet_get_carrier (NMDeviceEthernet *device);

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>
@ -45,6 +45,7 @@ typedef struct {
DBusGProxy *proxy;
char *hw_address;
char *perm_hw_address;
NM80211Mode mode;
guint32 rate;
NMAccessPoint *active_ap;
@ -58,6 +59,7 @@ typedef struct {
enum {
PROP_0,
PROP_HW_ADDRESS,
PROP_PERM_HW_ADDRESS,
PROP_MODE,
PROP_BITRATE,
PROP_ACTIVE_ACCESS_POINT,
@ -67,6 +69,7 @@ enum {
};
#define DBUS_PROP_HW_ADDRESS "HwAddress"
#define DBUS_PROP_PERM_HW_ADDRESS "PermHwAddress"
#define DBUS_PROP_MODE "Mode"
#define DBUS_PROP_BITRATE "Bitrate"
#define DBUS_PROP_ACTIVE_ACCESS_POINT "ActiveAccessPoint"
@ -106,9 +109,9 @@ nm_device_wifi_new (DBusGConnection *connection, const char *path)
* nm_device_wifi_get_hw_address:
* @device: a #NMDeviceWifi
*
* Gets the hardware (MAC) address of the #NMDeviceWifi
* Gets the actual hardware (MAC) address of the #NMDeviceWifi
*
* Returns: the hardware address. This is the internal string used by the
* Returns: the actual hardware address. This is the internal string used by the
* device, and must not be modified.
**/
const char *
@ -128,6 +131,32 @@ nm_device_wifi_get_hw_address (NMDeviceWifi *device)
return priv->hw_address;
}
/**
* nm_device_wifi_get_permanent_hw_address:
* @device: a #NMDeviceWifi
*
* Gets the permanent hardware (MAC) address of the #NMDeviceWifi
*
* Returns: the permanent hardware address. This is the internal string used by the
* device, and must not be modified.
**/
const char *
nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device)
{
NMDeviceWifiPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
if (!priv->perm_hw_address) {
priv->perm_hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
DBUS_PROP_PERM_HW_ADDRESS);
}
return priv->perm_hw_address;
}
/**
* nm_device_wifi_get_mode:
* @device: a #NMDeviceWifi
@ -464,6 +493,9 @@ get_property (GObject *object,
case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_wifi_get_hw_address (self));
break;
case PROP_PERM_HW_ADDRESS:
g_value_set_string (value, nm_device_wifi_get_permanent_hw_address (self));
break;
case PROP_MODE:
g_value_set_uint (value, nm_device_wifi_get_mode (self));
break;
@ -554,11 +586,12 @@ register_for_property_changed (NMDeviceWifi *device)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
const NMPropertiesChangedInfo property_changed_info[] = {
{ NM_DEVICE_WIFI_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address },
{ NM_DEVICE_WIFI_MODE, _nm_object_demarshal_generic, &priv->mode },
{ NM_DEVICE_WIFI_BITRATE, _nm_object_demarshal_generic, &priv->rate },
{ NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, demarshal_active_ap, &priv->active_ap },
{ NM_DEVICE_WIFI_CAPABILITIES, _nm_object_demarshal_generic, &priv->wireless_caps },
{ NM_DEVICE_WIFI_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address },
{ NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, _nm_object_demarshal_generic, &priv->perm_hw_address },
{ NM_DEVICE_WIFI_MODE, _nm_object_demarshal_generic, &priv->mode },
{ NM_DEVICE_WIFI_BITRATE, _nm_object_demarshal_generic, &priv->rate },
{ NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, demarshal_active_ap, &priv->active_ap },
{ NM_DEVICE_WIFI_CAPABILITIES, _nm_object_demarshal_generic, &priv->wireless_caps },
{ NULL },
};
@ -638,6 +671,9 @@ finalize (GObject *object)
if (priv->hw_address)
g_free (priv->hw_address);
if (priv->perm_hw_address)
g_free (priv->perm_hw_address);
G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object);
}
@ -664,8 +700,21 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class)
g_object_class_install_property
(object_class, PROP_HW_ADDRESS,
g_param_spec_string (NM_DEVICE_WIFI_HW_ADDRESS,
"MAC Address",
"Hardware MAC address",
"Active MAC Address",
"Currently set hardware MAC address",
NULL,
G_PARAM_READABLE));
/**
* NMDeviceWifi:perm-hw-address:
*
* The hardware (MAC) address of the device.
**/
g_object_class_install_property
(object_class, PROP_PERM_HW_ADDRESS,
g_param_spec_string (NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS,
"Permanent MAC Address",
"Permanent hardware MAC address",
NULL,
G_PARAM_READABLE));

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_DEVICE_WIFI_H
@ -37,6 +37,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifiClass))
#define NM_DEVICE_WIFI_HW_ADDRESS "hw-address"
#define NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS "perm-hw-address"
#define NM_DEVICE_WIFI_MODE "mode"
#define NM_DEVICE_WIFI_BITRATE "bitrate"
#define NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT "active-access-point"
@ -67,6 +68,7 @@ GType nm_device_wifi_get_type (void);
GObject *nm_device_wifi_new (DBusGConnection *connection, const char *path);
const char * nm_device_wifi_get_hw_address (NMDeviceWifi *device);
const char * nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device);
NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device);
guint32 nm_device_wifi_get_bitrate (NMDeviceWifi *device);
guint32 nm_device_wifi_get_capabilities (NMDeviceWifi *device);

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>
@ -50,10 +50,12 @@ typedef struct {
DBusGProxy *proxy;
char *iface;
char *ip_iface;
char *udi;
char *driver;
guint32 capabilities;
gboolean managed;
gboolean firmware_missing;
NMIP4Config *ip4_config;
gboolean null_ip4_config;
NMDHCP4Config *dhcp4_config;
@ -76,6 +78,7 @@ enum {
PROP_DRIVER,
PROP_CAPABILITIES,
PROP_MANAGED,
PROP_FIRMWARE_MISSING,
PROP_IP4_CONFIG,
PROP_DHCP4_CONFIG,
PROP_IP6_CONFIG,
@ -83,6 +86,7 @@ enum {
PROP_PRODUCT,
PROP_VENDOR,
PROP_DHCP6_CONFIG,
PROP_IP_INTERFACE,
LAST_PROP
};
@ -269,15 +273,17 @@ register_for_property_changed (NMDevice *device)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
const NMPropertiesChangedInfo property_changed_info[] = {
{ NM_DEVICE_UDI, _nm_object_demarshal_generic, &priv->udi },
{ NM_DEVICE_INTERFACE, _nm_object_demarshal_generic, &priv->iface },
{ NM_DEVICE_DRIVER, _nm_object_demarshal_generic, &priv->driver },
{ NM_DEVICE_CAPABILITIES, _nm_object_demarshal_generic, &priv->capabilities },
{ NM_DEVICE_MANAGED, _nm_object_demarshal_generic, &priv->managed },
{ 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 },
{ NM_DEVICE_UDI, _nm_object_demarshal_generic, &priv->udi },
{ NM_DEVICE_INTERFACE, _nm_object_demarshal_generic, &priv->iface },
{ NM_DEVICE_IP_INTERFACE, _nm_object_demarshal_generic, &priv->ip_iface },
{ NM_DEVICE_DRIVER, _nm_object_demarshal_generic, &priv->driver },
{ NM_DEVICE_CAPABILITIES, _nm_object_demarshal_generic, &priv->capabilities },
{ NM_DEVICE_MANAGED, _nm_object_demarshal_generic, &priv->managed },
{ NM_DEVICE_FIRMWARE_MISSING, _nm_object_demarshal_generic, &priv->firmware_missing },
{ 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 },
};
@ -377,6 +383,7 @@ finalize (GObject *object)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
g_free (priv->iface);
g_free (priv->ip_iface);
g_free (priv->udi);
g_free (priv->driver);
g_free (priv->product);
@ -400,6 +407,9 @@ get_property (GObject *object,
case PROP_INTERFACE:
g_value_set_string (value, nm_device_get_iface (device));
break;
case PROP_IP_INTERFACE:
g_value_set_string (value, nm_device_get_ip_iface (device));
break;
case PROP_DRIVER:
g_value_set_string (value, nm_device_get_driver (device));
break;
@ -409,6 +419,9 @@ get_property (GObject *object,
case PROP_MANAGED:
g_value_set_boolean (value, nm_device_get_managed (device));
break;
case PROP_FIRMWARE_MISSING:
g_value_set_boolean (value, nm_device_get_firmware_missing (device));
break;
case PROP_IP4_CONFIG:
g_value_set_object (value, nm_device_get_ip4_config (device));
break;
@ -464,6 +477,20 @@ nm_device_class_init (NMDeviceClass *device_class)
NULL,
G_PARAM_READABLE));
/**
* NMDevice:ip-interface:
*
* The IP interface of the device which should be used for all IP-related
* operations like addressing and routing.
**/
g_object_class_install_property
(object_class, PROP_IP_INTERFACE,
g_param_spec_string (NM_DEVICE_IP_INTERFACE,
"IP Interface",
"IP Interface name",
NULL,
G_PARAM_READABLE));
/**
* NMDevice:udi:
*
@ -516,6 +543,20 @@ nm_device_class_init (NMDeviceClass *device_class)
FALSE,
G_PARAM_READABLE));
/**
* NMDevice:firmware-missing:
*
* When %TRUE indicates the device is likely missing firmware required
* for its operation.
**/
g_object_class_install_property
(object_class, PROP_FIRMWARE_MISSING,
g_param_spec_boolean (NM_DEVICE_FIRMWARE_MISSING,
"FirmwareMissing",
"Firmware missing",
FALSE,
G_PARAM_READABLE));
/**
* NMDevice:ip4-config:
*
@ -730,6 +771,33 @@ nm_device_get_iface (NMDevice *device)
return priv->iface;
}
/**
* nm_device_get_ip_iface:
* @device: a #NMDevice
*
* Gets the IP interface name of the #NMDevice over which IP traffic flows
* when the device is in the ACTIVATED state.
*
* Returns: the IP traffic interface of the device. This is the internal string
* used by the device, and must not be modified.
**/
const char *
nm_device_get_ip_iface (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->ip_iface) {
priv->ip_iface = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
"IpInterface");
}
return priv->ip_iface;
}
/**
* nm_device_get_udi:
* @device: a #NMDevice
@ -833,6 +901,33 @@ nm_device_get_managed (NMDevice *device)
return priv->managed;
}
/**
* nm_device_get_firmware_missing:
* @device: a #NMDevice
*
* Indicates that firmware required for the device's operation is likely
* to be missing.
*
* Returns: %TRUE if firmware required for the device's operation is likely
* to be missing.
**/
gboolean
nm_device_get_firmware_missing (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->firmware_missing) {
priv->firmware_missing = _nm_object_get_boolean_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
"FirmwareMissing");
}
return priv->firmware_missing;
}
/**
* nm_device_get_ip4_config:
* @device: a #NMDevice
@ -1055,7 +1150,7 @@ nm_device_update_description (NMDevice *device)
{
NMDevicePrivate *priv;
const char *subsys[3] = { "net", "tty", NULL };
GUdevDevice *udev_device = NULL, *tmpdev;
GUdevDevice *udev_device = NULL, *tmpdev, *olddev;
const char *ifname;
guint32 count = 0;
const char *vendor, *model;
@ -1073,9 +1168,8 @@ nm_device_update_description (NMDevice *device)
if (!ifname)
return;
if (NM_IS_DEVICE_ETHERNET (device) || NM_IS_DEVICE_WIFI (device))
udev_device = g_udev_client_query_by_subsystem_and_name (priv->client, "net", ifname);
else if (NM_IS_GSM_DEVICE (device) || NM_IS_CDMA_DEVICE (device))
udev_device = g_udev_client_query_by_subsystem_and_name (priv->client, "net", ifname);
if (!udev_device)
udev_device = g_udev_client_query_by_subsystem_and_name (priv->client, "tty", ifname);
if (!udev_device)
return;
@ -1088,7 +1182,11 @@ nm_device_update_description (NMDevice *device)
/* Walk up the chain of the device and its parents a few steps to grab
* vendor and device ID information off it.
*/
tmpdev = udev_device;
/* Ref the device again because we have to unref it each iteration,
* as g_udev_device_get_parent() returns a ref-ed object.
*/
tmpdev = g_object_ref (udev_device);
while ((count++ < 3) && tmpdev && (!priv->vendor || !priv->product)) {
if (!priv->vendor)
priv->vendor = get_decoded_property (tmpdev, "ID_VENDOR_ENC");
@ -1096,11 +1194,23 @@ nm_device_update_description (NMDevice *device)
if (!priv->product)
priv->product = get_decoded_property (tmpdev, "ID_MODEL_ENC");
olddev = tmpdev;
tmpdev = g_udev_device_get_parent (tmpdev);
g_object_unref (olddev);
}
/* Unref the last device if we found what we needed before running out
* of parents.
*/
if (tmpdev)
g_object_unref (tmpdev);
/* If we didn't get strings directly from the device, try database strings */
tmpdev = udev_device;
/* Again, ref the original device as we need to unref it every iteration
* since g_udev_device_get_parent() returns a refed object.
*/
tmpdev = g_object_ref (udev_device);
count = 0;
while ((count++ < 3) && tmpdev && (!priv->vendor || !priv->product)) {
if (!priv->vendor) {
@ -1115,9 +1225,20 @@ nm_device_update_description (NMDevice *device)
priv->product = g_strdup (model);
}
olddev = tmpdev;
tmpdev = g_udev_device_get_parent (tmpdev);
g_object_unref (olddev);
}
/* Unref the last device if we found what we needed before running out
* of parents.
*/
if (tmpdev)
g_object_unref (tmpdev);
/* Balance the initial g_udev_client_query_by_subsystem_and_name() */
g_object_unref (udev_device);
_nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_VENDOR);
_nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_PRODUCT);
}

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_DEVICE_H
@ -46,9 +46,11 @@ G_BEGIN_DECLS
#define NM_DEVICE_UDI "udi"
#define NM_DEVICE_INTERFACE "interface"
#define NM_DEVICE_IP_INTERFACE "ip-interface"
#define NM_DEVICE_DRIVER "driver"
#define NM_DEVICE_CAPABILITIES "capabilities"
#define NM_DEVICE_MANAGED "managed"
#define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
#define NM_DEVICE_IP4_CONFIG "ip4-config"
#define NM_DEVICE_DHCP4_CONFIG "dhcp4-config"
#define NM_DEVICE_IP6_CONFIG "ip6-config"
@ -83,18 +85,20 @@ GType nm_device_get_type (void);
GObject * nm_device_new (DBusGConnection *connection, const char *path);
const char * nm_device_get_iface (NMDevice *device);
const char * nm_device_get_udi (NMDevice *device);
const char * nm_device_get_driver (NMDevice *device);
guint32 nm_device_get_capabilities (NMDevice *device);
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);
const char * nm_device_get_iface (NMDevice *device);
const char * nm_device_get_ip_iface (NMDevice *device);
const char * nm_device_get_udi (NMDevice *device);
const char * nm_device_get_driver (NMDevice *device);
guint32 nm_device_get_capabilities (NMDevice *device);
gboolean nm_device_get_managed (NMDevice *device);
gboolean nm_device_get_firmware_missing (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);
typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);

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.
*/
@ -216,9 +216,9 @@ nm_dhcp4_config_get_options (NMDHCP4Config *config)
return priv->options;
if (!_nm_object_get_property (NM_OBJECT (config),
"org.freedesktop.DBus.Properties",
"Options",
&value))
NM_DBUS_INTERFACE_DHCP4_CONFIG,
"Options",
&value))
goto out;
demarshal_dhcp4_options (NM_OBJECT (config), NULL, &value, &priv->options);

View file

@ -216,9 +216,9 @@ nm_dhcp6_config_get_options (NMDHCP6Config *config)
return priv->options;
if (!_nm_object_get_property (NM_OBJECT (config),
"org.freedesktop.DBus.Properties",
"Options",
&value))
NM_DBUS_INTERFACE_DHCP6_CONFIG,
"Options",
&value))
goto out;
demarshal_dhcp6_options (NM_OBJECT (config), NULL, &value, &priv->options);

View file

@ -92,7 +92,7 @@ demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GValue *val
if (!_nm_ip6_address_array_demarshal (value, (GSList **) field))
return FALSE;
if (!strcmp (pspec->name, NM_IP6_CONFIG_NAMESERVERS))
if (pspec && !strcmp (pspec->name, NM_IP6_CONFIG_NAMESERVERS))
_nm_object_queue_notify (object, NM_IP6_CONFIG_NAMESERVERS);
return TRUE;
@ -162,9 +162,9 @@ nm_ip6_config_get_addresses (NMIP6Config *config)
return priv->addresses;
if (!_nm_object_get_property (NM_OBJECT (config),
"org.freedesktop.DBus.Properties",
"Addresses",
&value)) {
NM_DBUS_INTERFACE_IP6_CONFIG,
"Addresses",
&value)) {
return NULL;
}
@ -188,6 +188,7 @@ const GSList *
nm_ip6_config_get_nameservers (NMIP6Config *config)
{
NMIP6ConfigPrivate *priv;
GParamSpec *pspec;
GValue value = {0,};
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
@ -203,7 +204,8 @@ nm_ip6_config_get_nameservers (NMIP6Config *config)
return NULL;
}
demarshal_ip6_nameserver_array (NM_OBJECT (config), NULL, &value, &priv->nameservers);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (config)), NM_IP6_CONFIG_NAMESERVERS);
demarshal_ip6_nameserver_array (NM_OBJECT (config), pspec, &value, &priv->nameservers);
g_value_unset (&value);
return priv->nameservers;

View file

@ -47,7 +47,7 @@ typedef struct {
NMObject *parent;
GSList *notify_props;
gulong notify_id;
guint32 notify_id;
gboolean disposed;
} NMObjectPrivate;
@ -255,18 +255,23 @@ deferred_notify_cb (gpointer data)
{
NMObject *object = NM_OBJECT (data);
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
GSList *iter;
GSList *props, *iter;
priv->notify_id = 0;
priv->notify_props = g_slist_reverse (priv->notify_props);
for (iter = priv->notify_props; iter; iter = g_slist_next (iter)) {
/* Clear priv->notify_props early so that an NMObject subclass that
* listens to property changes can queue up other property changes
* during the g_object_notify() call separately from the property
* list we're iterating.
*/
props = g_slist_reverse (priv->notify_props);
priv->notify_props = NULL;
for (iter = props; iter; iter = g_slist_next (iter)) {
g_object_notify (G_OBJECT (object), (const char *) iter->data);
g_free (iter->data);
}
g_slist_free (priv->notify_props);
priv->notify_props = NULL;
g_slist_free (props);
return FALSE;
}
@ -522,12 +527,17 @@ _nm_object_set_property (NMObject *object,
g_return_if_fail (prop_name != NULL);
g_return_if_fail (G_IS_VALUE (value));
dbus_g_proxy_call_no_reply (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
"Set",
G_TYPE_STRING, interface,
G_TYPE_STRING, prop_name,
G_TYPE_VALUE, value,
G_TYPE_INVALID);
if (!dbus_g_proxy_call_with_timeout (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
"Set", 2000, NULL,
G_TYPE_STRING, interface,
G_TYPE_STRING, prop_name,
G_TYPE_VALUE, value,
G_TYPE_INVALID)) {
/* Ignore errors. dbus_g_proxy_call_with_timeout() is called instead of
* dbus_g_proxy_call_no_reply() to give NM chance to authenticate the caller.
*/
}
}
char *

View file

@ -164,7 +164,7 @@ get_secrets_cb (DBusGProxy *proxy, GHashTable *secrets, GError *error, gpointer
RemoteCall *call = user_data;
NMSettingsConnectionInterfaceGetSecretsFunc func = (NMSettingsConnectionInterfaceGetSecretsFunc) call->callback;
(*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), secrets, error, call->user_data);
(*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error ? NULL : secrets, error, call->user_data);
remote_call_complete (call->self, call);
}

View file

@ -166,12 +166,26 @@ fetch_connections_done (DBusGProxy *proxy,
int i;
if (error) {
g_warning ("%s: error fetching %s connections: (%d) %s.",
__func__,
priv->scope == NM_CONNECTION_SCOPE_USER ? "user" : "system",
error->code,
error->message ? error->message : "(unknown)");
gboolean is_spawn_error = FALSE;
/* Don't warn if the user settings service wasn't running since that's
* just annoying when running headless.
*/
if ( g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
|| g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER))
is_spawn_error = TRUE;
if (!is_spawn_error || priv->scope == NM_CONNECTION_SCOPE_SYSTEM) {
g_warning ("%s: error fetching %s connections: (%d) %s.",
__func__,
priv->scope == NM_CONNECTION_SCOPE_USER ? "user" : "system",
error->code,
error->message ? error->message : "(unknown)");
}
g_clear_error (&error);
/* We tried to read connections and failed */
g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ);
return;
}

View file

@ -17,7 +17,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 "nm-settings-interface.h"
@ -62,6 +62,8 @@ nm_settings_interface_error_get_type (void)
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED, "SecretsRequestCanceled"),
/* The request could not be completed because permission was denied. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED, "PermissionDenied"),
/* The requested setting does not existing in this connection. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING, "InvalidSetting"),
{ 0, 0, 0 },
};
etype = g_enum_register_static ("NMSettingsInterfaceError", values);

View file

@ -17,7 +17,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.
*/
#ifndef NM_SETTINGS_INTERFACE_H
@ -36,7 +36,8 @@ typedef enum {
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED
NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED,
NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING,
} NMSettingsInterfaceError;
#define NM_SETTINGS_INTERFACE_ERROR (nm_settings_interface_error_quark ())

View file

@ -359,7 +359,7 @@ _nm_ip6_address_array_demarshal (GValue *value, GSList **dest)
{
GPtrArray *array;
if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_UINT_ARRAY))
if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR))
return FALSE;
if (*dest) {
@ -373,12 +373,12 @@ _nm_ip6_address_array_demarshal (GValue *value, GSList **dest)
int i;
for (i = 0; i < array->len; i++) {
struct in6_addr *addr = g_ptr_array_index (array, i);
struct in6_addr *dup;
GByteArray *bytearray = (GByteArray *) g_ptr_array_index (array, i);
struct in6_addr *addr;
dup = g_malloc0 (sizeof (struct in6_addr));
memcpy (dup, addr, sizeof (struct in6_addr));
*dest = g_slist_append (*dest, dup);
addr = g_malloc0 (sizeof (struct in6_addr));
memcpy (addr->s6_addr, bytearray->data, bytearray->len);
*dest = g_slist_append (*dest, addr);
}
}

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 "4:4:3"
-version-info "7:0:6"
if WITH_GNUTLS
libnm_util_la_SOURCES += crypto_gnutls.c

View file

@ -23,6 +23,7 @@
#include <glib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <stdlib.h>
#include <glib/gi18n.h>

View file

@ -294,7 +294,15 @@ global:
nm_setting_wired_get_duplex;
nm_setting_wired_get_auto_negotiate;
nm_setting_wired_get_mac_address;
nm_setting_wired_get_cloned_mac_address;
nm_setting_wired_get_mtu;
nm_setting_wired_get_num_s390_options;
nm_setting_wired_get_s390_nettype;
nm_setting_wired_get_s390_option;
nm_setting_wired_get_s390_option_by_key;
nm_setting_wired_add_s390_option;
nm_setting_wired_get_s390_subchannels;
nm_setting_wired_remove_s390_option;
nm_setting_wireless_ap_security_compatible;
nm_setting_wireless_error_get_type;
nm_setting_wireless_error_quark;
@ -308,6 +316,7 @@ global:
nm_setting_wireless_get_rate;
nm_setting_wireless_get_tx_power;
nm_setting_wireless_get_mac_address;
nm_setting_wireless_get_cloned_mac_address;
nm_setting_wireless_get_mtu;
nm_setting_wireless_get_security;
nm_setting_wireless_add_seen_bssid;
@ -371,6 +380,10 @@ global:
nm_utils_ssid_to_utf8;
nm_utils_uuid_generate;
nm_utils_uuid_generate_from_string;
nm_utils_wifi_freq_to_channel;
nm_utils_wifi_channel_to_freq;
nm_utils_wifi_find_next_channel;
nm_utils_wifi_is_channel_valid;
nm_ip4_address_compare;
nm_ip4_address_dup;
nm_ip4_address_get_address;

View file

@ -562,30 +562,6 @@ nm_connection_compare (NMConnection *a,
return info.failed ? FALSE : TRUE;
}
typedef struct {
gboolean success;
GSList *all_settings;
GError **error;
} VerifySettingsInfo;
static void
verify_one_setting (gpointer data, gpointer user_data)
{
NMSetting *setting = NM_SETTING (data);
VerifySettingsInfo *info = (VerifySettingsInfo *) user_data;
if (info->success)
info->success = nm_setting_verify (setting, info->all_settings, info->error);
}
static void
hash_values_to_slist (gpointer key, gpointer value, gpointer user_data)
{
GSList **list = (GSList **) user_data;
*list = g_slist_prepend (*list, value);
}
/**
* nm_connection_verify:
* @connection: the #NMConnection to verify
@ -608,7 +584,10 @@ nm_connection_verify (NMConnection *connection, GError **error)
{
NMConnectionPrivate *priv;
NMSetting *s_con;
VerifySettingsInfo info;
GHashTableIter iter;
gpointer value;
GSList *all_settings = NULL;
gboolean success = TRUE;
if (error)
g_return_val_if_fail (*error == NULL, FALSE);
@ -633,15 +612,18 @@ nm_connection_verify (NMConnection *connection, GError **error)
return FALSE;
}
/* Now, run the verify function of each setting */
memset (&info, 0, sizeof (info));
info.success = TRUE;
info.error = error;
g_hash_table_foreach (priv->settings, hash_values_to_slist, &info.all_settings);
/* Build up the list of settings */
g_hash_table_iter_init (&iter, priv->settings);
while (g_hash_table_iter_next (&iter, NULL, &value))
all_settings = g_slist_append (all_settings, value);
g_slist_foreach (info.all_settings, verify_one_setting, &info);
g_slist_free (info.all_settings);
return info.success;
/* Now, run the verify function of each setting */
g_hash_table_iter_init (&iter, priv->settings);
while (g_hash_table_iter_next (&iter, NULL, &value) && success)
success = nm_setting_verify (NM_SETTING (value), all_settings, error);
g_slist_free (all_settings);
return success;
}
/**

View file

@ -231,12 +231,30 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if (priv->apn && (strlen (priv->apn) < 1 || strchr (priv->apn, '"'))) {
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_APN);
return FALSE;
if (priv->apn) {
guint32 apn_len = strlen (priv->apn);
guint32 i;
if (apn_len < 1 || apn_len > 64) {
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_APN);
return FALSE;
}
/* APNs roughly follow the same rules as DNS domain names. Allowed
* characters are a-z, 0-9, . and -. GSM 03.60 Section 14.9.
*/
for (i = 0; i < apn_len; i++) {
if (!isalnum (priv->apn[i]) && (priv->apn[i] != '.') && (priv->apn[i] != '-')) {
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_APN);
return FALSE;
}
}
}
if (priv->username && !strlen (priv->username)) {
@ -326,6 +344,7 @@ set_property (GObject *object, guint prop_id,
{
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
const char *str;
char *tmp;
switch (prop_id) {
case PROP_NUMBER:
@ -342,11 +361,17 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_APN:
g_free (priv->apn);
priv->apn = g_value_dup_string (value);
priv->apn = NULL;
tmp = g_value_dup_string (value);
if (tmp)
priv->apn = g_strstrip (tmp);
break;
case PROP_NETWORK_ID:
g_free (priv->network_id);
priv->network_id = g_value_dup_string (value);
priv->network_id = NULL;
tmp = g_value_dup_string (value);
if (tmp)
priv->network_id = g_strstrip (tmp);
break;
case PROP_NETWORK_TYPE:
priv->network_type = g_value_get_int (value);
@ -503,6 +528,8 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
* the user will be billed for their network usage and whether the user has
* access to the Internet or just a provider-specific walled-garden, so it
* is important to use the correct APN for the user's mobile broadband plan.
* The APN may only be composed of the characters a-z, 0-9, ., and - per
* GSM 03.60 Section 14.9.
**/
g_object_class_install_property
(object_class, PROP_APN,
@ -515,7 +542,8 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
"user has access to the Internet or just a provider-"
"specific walled-garden, so it is important to use "
"the correct APN for the user's mobile broadband "
"plan.",
"plan. The APN may only be composed of the characters "
"a-z, 0-9, ., and - per GSM 03.60 Section 14.9.",
NULL,
G_PARAM_READWRITE | 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.
*/
@ -112,15 +112,6 @@ nm_setting_pppoe_get_password (NMSettingPPPOE *setting)
return NM_SETTING_PPPOE_GET_PRIVATE (setting)->password;
}
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
NMSetting *setting = NM_SETTING (a);
const char *str = (const char *) b;
return strcmp (nm_setting_get_name (setting), str);
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@ -148,14 +139,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if (!g_slist_find_custom (all_settings, NM_SETTING_PPP_SETTING_NAME, find_setting_by_name)) {
g_set_error (error,
NM_SETTING_PPPOE_ERROR,
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING,
NULL);
return FALSE;
}
return TRUE;
}

View file

@ -149,10 +149,10 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
/* Serial connections require a PPP setting */
if (all_settings &&
!g_slist_find_custom (all_settings, NM_SETTING_PPP_SETTING_NAME, find_setting_by_name)) {
g_set_error (error,
NM_SETTING_SERIAL_ERROR,
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING,
NULL);
g_set_error_literal (error,
NM_SETTING_SERIAL_ERROR,
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING,
"Missing required PPP setting");
return FALSE;
}

View file

@ -248,6 +248,7 @@ static gboolean
update_one_secret (NMSetting *setting, const char *key, GValue *value, GError **error)
{
NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
char *str;
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
@ -259,8 +260,17 @@ update_one_secret (NMSetting *setting, const char *key, GValue *value, GError **
return FALSE;
}
g_hash_table_insert (priv->secrets, g_strdup (key), g_value_dup_string (value));
return FALSE;
str = g_value_dup_string (value);
if (!str || !strlen (str)) {
g_set_error (error, NM_SETTING_ERROR,
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
"Secret %s was empty", key);
g_free (str);
return FALSE;
}
g_hash_table_insert (priv->secrets, g_strdup (key), str);
return TRUE;
}
static void

View file

@ -19,16 +19,20 @@
* 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.
*/
#include <string.h>
#include <ctype.h>
#include <net/ethernet.h>
#include <dbus/dbus-glib.h>
#include "nm-setting-wired.h"
#include "nm-param-spec-specialized.h"
#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-dbus-glib-types.h"
GQuark
nm_setting_wired_error_quark (void)
@ -73,8 +77,12 @@ typedef struct {
guint32 speed;
char *duplex;
gboolean auto_negotiate;
GByteArray *mac_address;
GByteArray *device_mac_address;
GByteArray *cloned_mac_address;
guint32 mtu;
GPtrArray *s390_subchannels;
char *s390_nettype;
GHashTable *s390_options;
} NMSettingWiredPrivate;
enum {
@ -84,11 +92,25 @@ enum {
PROP_DUPLEX,
PROP_AUTO_NEGOTIATE,
PROP_MAC_ADDRESS,
PROP_CLONED_MAC_ADDRESS,
PROP_MTU,
PROP_S390_SUBCHANNELS,
PROP_S390_NETTYPE,
PROP_S390_OPTIONS,
LAST_PROP
};
static const char *valid_s390_opts[] = {
"portno", "layer2", "portname", "protocol", "priority_queueing",
"buffer_count", "isolation", "total", "inter", "inter_jumbo", "route4",
"route6", "fake_broadcast", "broadcast_mode", "canonical_macaddr",
"checksumming", "sniffer", "large_send", "ipato_enable", "ipato_invert4",
"ipato_add4", "ipato_invert6", "ipato_add6", "vipa_add4", "vipa_add6",
"rxip_add4", "rxip_add6", "lancmd_timeout",
NULL
};
NMSetting *
nm_setting_wired_new (void)
{
@ -132,7 +154,15 @@ nm_setting_wired_get_mac_address (NMSettingWired *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
return NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address;
return NM_SETTING_WIRED_GET_PRIVATE (setting)->device_mac_address;
}
const GByteArray *
nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
return NM_SETTING_WIRED_GET_PRIVATE (setting)->cloned_mac_address;
}
guint32
@ -143,12 +173,197 @@ nm_setting_wired_get_mtu (NMSettingWired *setting)
return NM_SETTING_WIRED_GET_PRIVATE (setting)->mtu;
}
/**
* nm_setting_wired_get_s390_subchannels:
* @setting: the #NMSettingWired
*
* Return the list of s390 subchannels that identify the device that this
* connection is applicable to. The connection should only be used in
* conjunction with that device.
*
* Returns: a #GPtrArray of strings, each specifying one subchannel the
* s390 device uses to communicate to the host.
**/
const GPtrArray *
nm_setting_wired_get_s390_subchannels (NMSettingWired *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels;
}
/**
* nm_setting_wired_get_s390_nettype:
* @setting: the #NMSettingWired
*
* Returns the s390 device type this connection should apply to. Will be one
* of 'qeth', 'lcs', or 'ctcm'.
*
* Returns: the s390 device type
**/
const char *
nm_setting_wired_get_s390_nettype (NMSettingWired *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_nettype;
}
/**
* nm_setting_wired_get_num_s390_options:
* @setting: the #NMSettingWired
*
* Returns the number of s390-specific options that should be set for this
* device when it is activated. This can be used to retrieve each s390
* option individually using nm_setting_wired_get_s390_option().
*
* Returns: the number of s390-specific device options
**/
guint32
nm_setting_wired_get_num_s390_options (NMSettingWired *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
return g_hash_table_size (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options);
}
/**
* nm_setting_wired_get_s390_option:
* @setting: the #NMSettingWired
* @idx: index of the desired option, from 0 to
* nm_setting_wired_get_num_s390_options() - 1
* @out_key: on return, the key name of the s390 specific option; this value is
* owned by the setting and should not be modified
* @out_value: on return, the value of the key of the s390 specific option; this
* value is owned by the setting and should not be modified
*
* Given an index, return the value of the s390 option at that index. indexes
* are *not* guaranteed to be static across modifications to options done by
* nm_setting_wired_add_s390_option() and nm_setting_wired_remove_s390_option(),
* and should not be used to refer to options except for short periods of time
* such as during option iteration.
*
* Returns: %TRUE on success if the index was valid and an option was found,
* %FALSE if the index was invalid (ie, greater than the number of options
* currently held by the setting)
**/
gboolean
nm_setting_wired_get_s390_option (NMSettingWired *setting,
guint32 idx,
const char **out_key,
const char **out_value)
{
NMSettingWiredPrivate *priv;
guint32 num_keys;
GList *keys;
const char *_key = NULL, *_value = NULL;
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
num_keys = nm_setting_wired_get_num_s390_options (setting);
g_return_val_if_fail (idx < num_keys, FALSE);
keys = g_hash_table_get_keys (priv->s390_options);
_key = g_list_nth_data (keys, idx);
_value = g_hash_table_lookup (priv->s390_options, _key);
if (out_key)
*out_key = _key;
if (out_value)
*out_value = _value;
return TRUE;
}
/**
* nm_setting_wired_get_s390_option_by_key:
* @setting: the #NMSettingWired
* @key: the key for which to retrieve the value
*
* Returns the value associated with the s390-specific option specified by
* @key, if it exists.
*
* Returns: the value, or NULL if the key/value pair was never added to the
* setting; the value is owned by the setting and must not be modified
**/
const char *
nm_setting_wired_get_s390_option_by_key (NMSettingWired *setting,
const char *key)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
g_return_val_if_fail (key != NULL, NULL);
g_return_val_if_fail (strlen (key), NULL);
return g_hash_table_lookup (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key);
}
/**
* nm_setting_wired_add_s390_options:
* @setting: the #NMSettingWired
* @key: key name for the option
* @value: value for the option
*
* Add an option to the table. The option is compared to an internal list
* of allowed options. Key names may contain only alphanumeric characters
* (ie [a-zA-Z0-9]). Adding a new key replaces any existing key/value pair that
* may already exist.
*
* Returns: %TRUE if the option was valid and was added to the internal option
* list, %FALSE if it was not.
**/
gboolean nm_setting_wired_add_s390_option (NMSettingWired *setting,
const char *key,
const char *value)
{
size_t value_len;
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (strlen (key), FALSE);
g_return_val_if_fail (_nm_utils_string_in_list (key, valid_s390_opts), FALSE);
g_return_val_if_fail (value != NULL, FALSE);
value_len = strlen (value);
g_return_val_if_fail (value_len > 0 && value_len < 200, FALSE);
g_hash_table_insert (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options,
g_strdup (key),
g_strdup (value));
return TRUE;
}
/**
* nm_setting_wired_remove_s390_options:
* @setting: the #NMSettingWired
* @key: key name for the option to remove
*
* Remove the s390-specific option referenced by @key from the internal option
* list.
*
* Returns: %TRUE if the option was found and removed from the internal option
* list, %FALSE if it was not.
**/
gboolean
nm_setting_wired_remove_s390_option (NMSettingWired *setting,
const char *key)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (strlen (key), FALSE);
return g_hash_table_remove (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key);
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
const char *valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
const char *valid_duplex[] = { "half", "full", NULL };
const char *valid_nettype[] = { "qeth", "lcs", "ctcm", NULL };
GHashTableIter iter;
const char *key, *value;
if (priv->port && !_nm_utils_string_in_list (priv->port, valid_ports)) {
g_set_error (error,
@ -166,7 +381,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
if (priv->device_mac_address && priv->device_mac_address->len != ETH_ALEN) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
@ -174,13 +389,54 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if ( priv->s390_subchannels
&& !(priv->s390_subchannels->len == 3 || priv->s390_subchannels->len == 2)) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRED_S390_SUBCHANNELS);
return FALSE;
}
if (priv->s390_nettype && !_nm_utils_string_in_list (priv->s390_nettype, valid_nettype)) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRED_S390_NETTYPE);
return FALSE;
}
g_hash_table_iter_init (&iter, priv->s390_options);
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
if ( !_nm_utils_string_in_list (key, valid_s390_opts)
|| !strlen (value)
|| (strlen (value) > 200)) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRED_S390_OPTIONS);
return FALSE;
}
}
if (priv->cloned_mac_address && priv->cloned_mac_address->len != ETH_ALEN) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRED_CLONED_MAC_ADDRESS);
return FALSE;
}
return TRUE;
}
static void
nm_setting_wired_init (NMSettingWired *setting)
{
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
g_object_set (setting, NM_SETTING_NAME, NM_SETTING_WIRED_SETTING_NAME, NULL);
priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
}
static void
@ -190,18 +446,31 @@ finalize (GObject *object)
g_free (priv->port);
g_free (priv->duplex);
g_free (priv->s390_nettype);
if (priv->mac_address)
g_byte_array_free (priv->mac_address, TRUE);
g_hash_table_destroy (priv->s390_options);
if (priv->device_mac_address)
g_byte_array_free (priv->device_mac_address, TRUE);
if (priv->cloned_mac_address)
g_byte_array_free (priv->cloned_mac_address, TRUE);
G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object);
}
static void
copy_hash (gpointer key, gpointer value, gpointer user_data)
{
g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value));
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
const GValue *value, GParamSpec *pspec)
{
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
GHashTable *new_hash;
switch (prop_id) {
case PROP_PORT:
@ -219,13 +488,36 @@ set_property (GObject *object, guint prop_id,
priv->auto_negotiate = g_value_get_boolean (value);
break;
case PROP_MAC_ADDRESS:
if (priv->mac_address)
g_byte_array_free (priv->mac_address, TRUE);
priv->mac_address = g_value_dup_boxed (value);
if (priv->device_mac_address)
g_byte_array_free (priv->device_mac_address, TRUE);
priv->device_mac_address = g_value_dup_boxed (value);
break;
case PROP_CLONED_MAC_ADDRESS:
if (priv->cloned_mac_address)
g_byte_array_free (priv->cloned_mac_address, TRUE);
priv->cloned_mac_address = g_value_dup_boxed (value);
break;
case PROP_MTU:
priv->mtu = g_value_get_uint (value);
break;
case PROP_S390_SUBCHANNELS:
if (priv->s390_subchannels) {
g_ptr_array_foreach (priv->s390_subchannels, (GFunc) g_free, NULL);
g_ptr_array_free (priv->s390_subchannels, TRUE);
}
priv->s390_subchannels = g_value_dup_boxed (value);
break;
case PROP_S390_NETTYPE:
g_free (priv->s390_nettype);
priv->s390_nettype = g_value_dup_string (value);
break;
case PROP_S390_OPTIONS:
/* Must make a deep copy of the hash table here... */
g_hash_table_remove_all (priv->s390_options);
new_hash = g_value_get_boxed (value);
if (new_hash)
g_hash_table_foreach (new_hash, copy_hash, priv->s390_options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -234,9 +526,10 @@ set_property (GObject *object, guint prop_id,
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
GValue *value, GParamSpec *pspec)
{
NMSettingWired *setting = NM_SETTING_WIRED (object);
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
switch (prop_id) {
case PROP_PORT:
@ -254,9 +547,21 @@ get_property (GObject *object, guint prop_id,
case PROP_MAC_ADDRESS:
g_value_set_boxed (value, nm_setting_wired_get_mac_address (setting));
break;
case PROP_CLONED_MAC_ADDRESS:
g_value_set_boxed (value, nm_setting_wired_get_cloned_mac_address (setting));
break;
case PROP_MTU:
g_value_set_uint (value, nm_setting_wired_get_mtu (setting));
break;
case PROP_S390_SUBCHANNELS:
g_value_set_boxed (value, nm_setting_wired_get_s390_subchannels (setting));
break;
case PROP_S390_NETTYPE:
g_value_set_string (value, nm_setting_wired_get_s390_nettype (setting));
break;
case PROP_S390_OPTIONS:
g_value_set_boxed (value, priv->s390_options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -351,20 +656,36 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
* NMSettingWired:mac-address:
*
* If specified, this connection will only apply to the ethernet device
* whose MAC address matches. This property does not change the MAC address
* of the device (known as MAC spoofing).
* whose permanent MAC address matches. This property does not change the MAC address
* of the device (i.e. MAC spoofing).
**/
g_object_class_install_property
(object_class, PROP_MAC_ADDRESS,
_nm_param_spec_specialized (NM_SETTING_WIRED_MAC_ADDRESS,
"MAC Address",
"Device MAC Address",
"If specified, this connection will only apply to "
"the ethernet device whose MAC address matches. "
"the ethernet device whose permanent MAC address matches. "
"This property does not change the MAC address "
"of the device (known as MAC spoofing).",
"of the device (i.e. MAC spoofing).",
DBUS_TYPE_G_UCHAR_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingWired:cloned-mac-address:
*
* If specified, request that the device use this MAC address instead of its
* permanent MAC address. This is known as MAC cloning or spoofing.
**/
g_object_class_install_property
(object_class, PROP_CLONED_MAC_ADDRESS,
_nm_param_spec_specialized (NM_SETTING_WIRED_CLONED_MAC_ADDRESS,
"Cloned MAC Address",
"If specified, request that the device use "
"this MAC address instead of its permanent MAC address. "
"This is known as MAC cloning or spoofing.",
DBUS_TYPE_G_UCHAR_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingWired:mtu:
*
@ -380,5 +701,66 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
"multiple Ethernet frames.",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
/**
* NMSettingWired:s390-subchannels:
*
* Identifies specific subchannels that this network device uses for
* communcation with z/VM or s390 host. Like #NMSettingWired:mac-address
* for non-z/VM devices, this property can be used to ensure this connection
* only applies to the network device that uses these subchannels. The
* list should contain exactly 3 strings, and each string may only be
* composed of hexadecimal characters and the period (.) character.
**/
g_object_class_install_property
(object_class, PROP_S390_SUBCHANNELS,
_nm_param_spec_specialized (NM_SETTING_WIRED_S390_SUBCHANNELS,
"z/VM Subchannels",
"Identifies specific subchannels that this "
"network device uses for communcation with z/VM "
"or s390 host. Like the 'mac-address' property "
"for non-z/VM devices, this property can be used "
"to ensure this connection only applies to the "
"network device that uses these subchannels. The "
"list should contain exactly 3 strings, and each "
"string may only be composed of hexadecimal "
"characters and the period (.) character.",
DBUS_TYPE_G_ARRAY_OF_STRING,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingWired:s390-nettype:
*
* s390 network device type; one of 'qeth', 'lcs', or 'ctc', representing
* the different types of virtual network devices available on s390 systems.
**/
g_object_class_install_property
(object_class, PROP_S390_NETTYPE,
g_param_spec_string (NM_SETTING_WIRED_S390_NETTYPE,
"s390 Net Type",
"s390 network device type; one of 'qeth', 'lcs', or "
"'ctc', representing the different types of virtual "
"network devices available on s390 systems.",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingWired:s390-options:
*
* Dictionary of key/value pairs of s390-specific device options. Both keys
* and values must be strings. Allowed keys include 'portno', 'layer2',
* 'portname', 'protocol', among others. Key names must contain only
* alphanumeric characters (ie, [a-zA-Z0-9]).
**/
g_object_class_install_property
(object_class, PROP_S390_OPTIONS,
_nm_param_spec_specialized (NM_SETTING_WIRED_S390_OPTIONS,
"s390 Options",
"Dictionary of key/value pairs of s390-specific "
"device options. Both keys and values must be "
"strings. Allowed keys include 'portno', "
"'layer2', 'portname', 'protocol', among others.",
DBUS_TYPE_G_MAP_OF_STRING,
G_PARAM_READWRITE | 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.
*/
@ -57,7 +57,11 @@ GQuark nm_setting_wired_error_quark (void);
#define NM_SETTING_WIRED_DUPLEX "duplex"
#define NM_SETTING_WIRED_AUTO_NEGOTIATE "auto-negotiate"
#define NM_SETTING_WIRED_MAC_ADDRESS "mac-address"
#define NM_SETTING_WIRED_CLONED_MAC_ADDRESS "cloned-mac-address"
#define NM_SETTING_WIRED_MTU "mtu"
#define NM_SETTING_WIRED_S390_SUBCHANNELS "s390-subchannels"
#define NM_SETTING_WIRED_S390_NETTYPE "s390-nettype"
#define NM_SETTING_WIRED_S390_OPTIONS "s390-options"
typedef struct {
NMSetting parent;
@ -75,13 +79,30 @@ typedef struct {
GType nm_setting_wired_get_type (void);
NMSetting *nm_setting_wired_new (void);
const char *nm_setting_wired_get_port (NMSettingWired *setting);
guint32 nm_setting_wired_get_speed (NMSettingWired *setting);
const char *nm_setting_wired_get_duplex (NMSettingWired *setting);
gboolean nm_setting_wired_get_auto_negotiate (NMSettingWired *setting);
const GByteArray *nm_setting_wired_get_mac_address (NMSettingWired *setting);
guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
NMSetting * nm_setting_wired_new (void);
const char * nm_setting_wired_get_port (NMSettingWired *setting);
guint32 nm_setting_wired_get_speed (NMSettingWired *setting);
const char * nm_setting_wired_get_duplex (NMSettingWired *setting);
gboolean nm_setting_wired_get_auto_negotiate (NMSettingWired *setting);
const GByteArray *nm_setting_wired_get_mac_address (NMSettingWired *setting);
const GByteArray *nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting);
guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
const GPtrArray * nm_setting_wired_get_s390_subchannels (NMSettingWired *setting);
const char * nm_setting_wired_get_s390_nettype (NMSettingWired *setting);
guint32 nm_setting_wired_get_num_s390_options (NMSettingWired *setting);
gboolean nm_setting_wired_get_s390_option (NMSettingWired *setting,
guint32 idx,
const char **out_key,
const char **out_value);
const char * nm_setting_wired_get_s390_option_by_key (NMSettingWired *setting,
const char *key);
gboolean nm_setting_wired_add_s390_option (NMSettingWired *setting,
const char *key,
const char *item);
gboolean nm_setting_wired_remove_s390_option (NMSettingWired *setting,
const char *key);
G_END_DECLS

View file

@ -19,10 +19,11 @@
* 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.
*/
#include <config.h>
#include <string.h>
#include <ctype.h>
#include <dbus/dbus-glib.h>

View file

@ -19,11 +19,12 @@
* 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.
*/
#include <string.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <dbus/dbus-glib.h>
@ -86,7 +87,8 @@ typedef struct {
GByteArray *bssid;
guint32 rate;
guint32 tx_power;
GByteArray *mac_address;
GByteArray *device_mac_address;
GByteArray *cloned_mac_address;
guint32 mtu;
GSList *seen_bssids;
char *security;
@ -102,6 +104,7 @@ enum {
PROP_RATE,
PROP_TX_POWER,
PROP_MAC_ADDRESS,
PROP_CLONED_MAC_ADDRESS,
PROP_MTU,
PROP_SEEN_BSSIDS,
PROP_SEC,
@ -353,7 +356,15 @@ nm_setting_wireless_get_mac_address (NMSettingWireless *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address;
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->device_mac_address;
}
const GByteArray *
nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->cloned_mac_address;
}
guint32
@ -480,31 +491,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
if (priv->channel) {
if (!strcmp (priv->band, "a")) {
int i;
int valid_channels[] = { 7, 8, 9, 11, 12, 16, 34, 36, 40, 44, 48,
52, 56, 60, 64, 100, 104, 108, 112, 116,
120, 124, 128, 132, 136, 140, 149, 153,
157, 161, 165, 183, 184, 185, 187, 188,
192, 196, 0 };
for (i = 0; valid_channels[i]; i++) {
if (priv->channel == valid_channels[i])
break;
}
if (valid_channels[i] == 0) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRELESS_CHANNEL);
return FALSE;
}
} else if (!strcmp (priv->band, "bg") && priv->channel > 14) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRELESS_CHANNEL);
if (!nm_utils_wifi_is_channel_valid (priv->channel, priv->band)) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRELESS_CHANNEL);
return FALSE;
}
}
@ -517,7 +508,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
if (priv->device_mac_address && priv->device_mac_address->len != ETH_ALEN) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
@ -525,6 +516,14 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if (priv->cloned_mac_address && priv->cloned_mac_address->len != ETH_ALEN) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS);
return FALSE;
}
for (iter = priv->seen_bssids; iter; iter = iter->next) {
struct ether_addr addr;
@ -568,8 +567,10 @@ finalize (GObject *object)
g_byte_array_free (priv->ssid, TRUE);
if (priv->bssid)
g_byte_array_free (priv->bssid, TRUE);
if (priv->mac_address)
g_byte_array_free (priv->mac_address, TRUE);
if (priv->device_mac_address)
g_byte_array_free (priv->device_mac_address, TRUE);
if (priv->cloned_mac_address)
g_byte_array_free (priv->cloned_mac_address, TRUE);
nm_utils_slist_free (priv->seen_bssids, g_free);
@ -611,9 +612,14 @@ set_property (GObject *object, guint prop_id,
priv->tx_power = g_value_get_uint (value);
break;
case PROP_MAC_ADDRESS:
if (priv->mac_address)
g_byte_array_free (priv->mac_address, TRUE);
priv->mac_address = g_value_dup_boxed (value);
if (priv->device_mac_address)
g_byte_array_free (priv->device_mac_address, TRUE);
priv->device_mac_address = g_value_dup_boxed (value);
break;
case PROP_CLONED_MAC_ADDRESS:
if (priv->cloned_mac_address)
g_byte_array_free (priv->cloned_mac_address, TRUE);
priv->cloned_mac_address = g_value_dup_boxed (value);
break;
case PROP_MTU:
priv->mtu = g_value_get_uint (value);
@ -663,6 +669,9 @@ get_property (GObject *object, guint prop_id,
case PROP_MAC_ADDRESS:
g_value_set_boxed (value, nm_setting_wireless_get_mac_address (setting));
break;
case PROP_CLONED_MAC_ADDRESS:
g_value_set_boxed (value, nm_setting_wireless_get_cloned_mac_address (setting));
break;
case PROP_MTU:
g_value_set_uint (value, nm_setting_wireless_get_mtu (setting));
break;
@ -829,20 +838,36 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
* NMSettingWireless:mac-address:
*
* If specified, this connection will only apply to the WiFi device
* whose MAC address matches. This property does not change the MAC address
* of the device (known as MAC spoofing).
* whose permanent MAC address matches. This property does not change the MAC address
* of the device (i.e. MAC spoofing).
**/
g_object_class_install_property
(object_class, PROP_MAC_ADDRESS,
_nm_param_spec_specialized (NM_SETTING_WIRELESS_MAC_ADDRESS,
"MAC Address",
"Device MAC Address",
"If specified, this connection will only apply to "
"the WiFi device whose MAC address matches. "
"the WiFi device whose permanent MAC address matches. "
"This property does not change the MAC address "
"of the device (known as MAC spoofing).",
"of the device (i.e. MAC spoofing).",
DBUS_TYPE_G_UCHAR_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingWireless:cloned-mac-address:
*
* If specified, request that the Wifi device use this MAC address instead of its
* permanent MAC address. This is known as MAC cloning or spoofing.
**/
g_object_class_install_property
(object_class, PROP_CLONED_MAC_ADDRESS,
_nm_param_spec_specialized (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS,
"Spoof MAC Address",
"If specified, request that the WiFi device use "
"this MAC address instead of its permanent MAC address. "
"This is known as MAC cloning or spoofing.",
DBUS_TYPE_G_UCHAR_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingWireless:seen-bssids:
*

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.
*/
@ -63,6 +63,7 @@ GQuark nm_setting_wireless_error_quark (void);
#define NM_SETTING_WIRELESS_RATE "rate"
#define NM_SETTING_WIRELESS_TX_POWER "tx-power"
#define NM_SETTING_WIRELESS_MAC_ADDRESS "mac-address"
#define NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS "cloned-mac-address"
#define NM_SETTING_WIRELESS_MTU "mtu"
#define NM_SETTING_WIRELESS_SEEN_BSSIDS "seen-bssids"
#define NM_SETTING_WIRELESS_SEC "security"
@ -93,6 +94,7 @@ const GByteArray *nm_setting_wireless_get_bssid (NMSettingWireless
guint32 nm_setting_wireless_get_rate (NMSettingWireless *setting);
guint32 nm_setting_wireless_get_tx_power (NMSettingWireless *setting);
const GByteArray *nm_setting_wireless_get_mac_address (NMSettingWireless *setting);
const GByteArray *nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting);
guint32 nm_setting_wireless_get_mtu (NMSettingWireless *setting);
const char *nm_setting_wireless_get_security (NMSettingWireless *setting);

View file

@ -620,6 +620,8 @@ nm_setting_to_string (NMSetting *setting)
is_serializable = prop_spec->flags & NM_SETTING_PARAM_SERIALIZE;
is_default = g_param_value_defaults (prop_spec, &value);
g_value_unset (&value);
if (is_serializable || is_default) {
g_string_append (string, " (");

View file

@ -117,7 +117,7 @@ static const struct IsoLangToEncodings isoLangEntries2[] =
/* Arabic */
{ "ar", {"iso-8859-6", "windows-1256", NULL} },
/* Balitc */
/* Baltic */
{ "et", {"iso-8859-4", "windows-1257", NULL} }, /* Estonian */
{ "lt", {"iso-8859-4", "windows-1257", NULL} }, /* Lithuanian */
{ "lv", {"iso-8859-4", "windows-1257", NULL} }, /* Latvian */
@ -352,7 +352,7 @@ nm_utils_ssid_to_utf8 (const char *ssid, guint32 len)
/* Shamelessly ripped from the Linux kernel ieee80211 stack */
/**
* nm_utils_deinit:
* nm_utils_is_empty_ssid:
* @ssid: pointer to a buffer containing the SSID data
* @len: length of the SSID data in @ssid
*
@ -567,6 +567,24 @@ nm_utils_convert_strv_to_slist (const GValue *src_value, GValue *dest_value)
g_value_take_boxed (dest_value, g_slist_reverse (list));
}
static void
nm_utils_convert_strv_to_ptrarray (const GValue *src_value, GValue *dest_value)
{
char **str;
GPtrArray *array = NULL;
guint i = 0;
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), G_TYPE_STRV));
str = (char **) g_value_get_boxed (src_value);
array = g_ptr_array_sized_new (3);
while (str && str[i])
g_ptr_array_add (array, g_strdup (str[i++]));
g_value_take_boxed (dest_value, array);
}
static void
nm_utils_convert_strv_to_string (const GValue *src_value, GValue *dest_value)
{
@ -593,6 +611,32 @@ nm_utils_convert_strv_to_string (const GValue *src_value, GValue *dest_value)
g_string_free (printable, FALSE);
}
static void
nm_utils_convert_string_array_to_string (const GValue *src_value, GValue *dest_value)
{
GPtrArray *strings;
GString *printable;
int i;
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_STRING));
strings = (GPtrArray *) g_value_get_boxed (src_value);
printable = g_string_new ("[");
for (i = 0; strings && i < strings->len; i++) {
if (i > 0)
g_string_append (printable, ", '");
else
g_string_append_c (printable, '\'');
g_string_append (printable, g_ptr_array_index (strings, i));
g_string_append_c (printable, '\'');
}
g_string_append_c (printable, ']');
g_value_take_string (dest_value, printable->str);
g_string_free (printable, FALSE);
}
static void
nm_utils_convert_uint_array_to_string (const GValue *src_value, GValue *dest_value)
{
@ -1055,9 +1099,15 @@ _nm_utils_register_value_transformations (void)
g_value_register_transform_func (G_TYPE_STRV,
DBUS_TYPE_G_LIST_OF_STRING,
nm_utils_convert_strv_to_slist);
g_value_register_transform_func (G_TYPE_STRV,
DBUS_TYPE_G_ARRAY_OF_STRING,
nm_utils_convert_strv_to_ptrarray);
g_value_register_transform_func (DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRING,
nm_utils_convert_strv_to_string);
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_STRING,
G_TYPE_STRING,
nm_utils_convert_string_array_to_string);
g_value_register_transform_func (DBUS_TYPE_G_UINT_ARRAY,
G_TYPE_STRING,
nm_utils_convert_uint_array_to_string);
@ -1219,14 +1269,24 @@ nm_utils_security_valid (NMUtilsSecurityType type,
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA))
return FALSE;
if (have_ap) {
/* Ad-Hoc WPA APs won't necessarily have the PSK flag set */
if ((ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK) || adhoc) {
if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_TKIP)
/* Ad-Hoc WPA APs won't necessarily have the PSK flag set, and
* they don't have any pairwise ciphers. */
if (adhoc) {
if ( (ap_wpa & NM_802_11_AP_SEC_GROUP_TKIP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
return TRUE;
if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_CCMP)
if ( (ap_wpa & NM_802_11_AP_SEC_GROUP_CCMP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
return TRUE;
} else {
if (ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK) {
if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_TKIP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
return TRUE;
if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_CCMP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
return TRUE;
}
}
return FALSE;
}
@ -1235,14 +1295,22 @@ nm_utils_security_valid (NMUtilsSecurityType type,
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN))
return FALSE;
if (have_ap) {
/* Ad-Hoc WPA APs won't necessarily have the PSK flag set */
if ((ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK) || adhoc) {
if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_TKIP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
/* Ad-Hoc WPA APs won't necessarily have the PSK flag set, and
* they don't have any pairwise ciphers, nor any RSA flags yet. */
if (adhoc) {
if (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)
return TRUE;
if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_CCMP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
if (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)
return TRUE;
} else {
if (ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK) {
if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_TKIP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
return TRUE;
if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_CCMP)
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
return TRUE;
}
}
return FALSE;
}
@ -2102,3 +2170,212 @@ out:
return ret;
}
/* Band, channel/frequency stuff for wireless */
struct cf_pair {
guint32 chan;
guint32 freq;
};
static struct cf_pair a_table[] = {
/* A band */
{ 7, 5035 },
{ 8, 5040 },
{ 9, 5045 },
{ 11, 5055 },
{ 12, 5060 },
{ 16, 5080 },
{ 34, 5170 },
{ 36, 5180 },
{ 38, 5190 },
{ 40, 5200 },
{ 42, 5210 },
{ 44, 5220 },
{ 46, 5230 },
{ 48, 5240 },
{ 50, 5250 },
{ 52, 5260 },
{ 56, 5280 },
{ 58, 5290 },
{ 60, 5300 },
{ 64, 5320 },
{ 100, 5500 },
{ 104, 5520 },
{ 108, 5540 },
{ 112, 5560 },
{ 116, 5580 },
{ 120, 5600 },
{ 124, 5620 },
{ 128, 5640 },
{ 132, 5660 },
{ 136, 5680 },
{ 140, 5700 },
{ 149, 5745 },
{ 152, 5760 },
{ 153, 5765 },
{ 157, 5785 },
{ 160, 5800 },
{ 161, 5805 },
{ 165, 5825 },
{ 183, 4915 },
{ 184, 4920 },
{ 185, 4925 },
{ 187, 4935 },
{ 188, 4945 },
{ 192, 4960 },
{ 196, 4980 },
{ 0, -1 }
};
static struct cf_pair bg_table[] = {
/* B/G band */
{ 1, 2412 },
{ 2, 2417 },
{ 3, 2422 },
{ 4, 2427 },
{ 5, 2432 },
{ 6, 2437 },
{ 7, 2442 },
{ 8, 2447 },
{ 9, 2452 },
{ 10, 2457 },
{ 11, 2462 },
{ 12, 2467 },
{ 13, 2472 },
{ 14, 2484 },
{ 0, -1 }
};
/**
* nm_utils_wifi_freq_to_channel:
* @freq: frequency
*
* Utility function to translate a WiFi frequency to its corresponding channel.
*
* Returns: the channel represented by the frequency or 0
**/
guint32
nm_utils_wifi_freq_to_channel (guint32 freq)
{
int i = 0;
if (freq > 4900) {
while (a_table[i].chan && (a_table[i].freq != freq))
i++;
return a_table[i].chan;
} else {
while (bg_table[i].chan && (bg_table[i].freq != freq))
i++;
return bg_table[i].chan;
}
return 0;
}
/**
* nm_utils_wifi_channel_to_freq:
* @channel: channel
* @band: frequency band for wireless ("a" or "bg")
*
* Utility function to translate a WiFi channel to its corresponding frequency.
*
* Returns: the frequency represented by the channel of the band,
* or -1 when the freq is invalid, or 0 when the band
* is invalid
**/
guint32
nm_utils_wifi_channel_to_freq (guint32 channel, const char *band)
{
int i = 0;
if (!strcmp (band, "a")) {
while (a_table[i].chan && (a_table[i].chan != channel))
i++;
return a_table[i].freq;
} else if (!strcmp (band, "bg")) {
while (bg_table[i].chan && (bg_table[i].chan != channel))
i++;
return bg_table[i].freq;
}
return 0;
}
/**
* nm_utils_wifi_find_next_channel:
* @channel: current channel
* @direction: whether going downward (0 or less) or upward (1 or more)
* @band: frequency band for wireless ("a" or "bg")
*
* Utility function to find out next/previous WiFi channel for a channel.
*
* Returns: the next channel in the specified direction or 0
**/
guint32
nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band)
{
size_t a_size = sizeof (a_table) / sizeof (struct cf_pair);
size_t bg_size = sizeof (bg_table) / sizeof (struct cf_pair);
struct cf_pair *pair = NULL;
if (!strcmp (band, "a")) {
if (channel < a_table[0].chan)
return a_table[0].chan;
if (channel > a_table[a_size - 2].chan)
return a_table[a_size - 2].chan;
pair = &a_table[0];
} else if (!strcmp (band, "bg")) {
if (channel < bg_table[0].chan)
return bg_table[0].chan;
if (channel > bg_table[bg_size - 2].chan)
return bg_table[bg_size - 2].chan;
pair = &bg_table[0];
} else {
g_assert_not_reached ();
return 0;
}
while (pair->chan) {
if (channel == pair->chan)
return channel;
if ((channel < (pair+1)->chan) && (channel > pair->chan)) {
if (direction > 0)
return (pair+1)->chan;
else
return pair->chan;
}
pair++;
}
return 0;
}
/**
* nm_utils_wifi_is_channel_valid:
* @channel: channel
* @band: frequency band for wireless ("a" or "bg")
*
* Utility function to verify WiFi channel validity.
*
* Returns: TRUE or FALSE
**/
gboolean
nm_utils_wifi_is_channel_valid (guint32 channel, const char *band)
{
struct cf_pair *table = NULL;
int i = 0;
if (!strcmp (band, "a"))
table = a_table;
else if (!strcmp (band, "bg"))
table = bg_table;
else
return FALSE;
while (table[i].chan && (table[i].chan != channel))
i++;
if (table[i].chan != 0)
return TRUE;
else
return FALSE;
}

View file

@ -215,4 +215,9 @@ GByteArray *nm_utils_rsa_key_encrypt (const GByteArray *data,
G_END_DECLS
guint32 nm_utils_wifi_freq_to_channel (guint32 freq);
guint32 nm_utils_wifi_channel_to_freq (guint32 channel, const char *band);
guint32 nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band);
gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band);
#endif /* NM_UTILS_H */

View file

@ -28,6 +28,7 @@
#include "nm-setting-connection.h"
#include "nm-setting-vpn.h"
#include "nm-setting-gsm.h"
#include "nm-setting-ip6-config.h"
#include "nm-dbus-glib-types.h"
@ -222,6 +223,72 @@ test_setting_ip6_config_old_address_array (void)
g_object_unref (s_ip6);
}
static void
test_setting_gsm_apn_spaces (void)
{
NMSettingGsm *s_gsm;
const char *tmp;
s_gsm = (NMSettingGsm *) nm_setting_gsm_new ();
ASSERT (s_gsm != NULL,
"gsm-apn-spaces",
"error creating GSM setting");
/* Trailing space */
g_object_set (s_gsm, NM_SETTING_GSM_APN, "foobar ", NULL);
tmp = nm_setting_gsm_get_apn (s_gsm);
ASSERT (tmp != NULL,
"gsm-apn-spaces", "empty APN");
ASSERT (strcmp (tmp, "foobar") == 0,
"gsm-apn-spaces", "unexpected APN");
/* Leading space */
g_object_set (s_gsm, NM_SETTING_GSM_APN, " foobar", NULL);
tmp = nm_setting_gsm_get_apn (s_gsm);
ASSERT (tmp != NULL,
"gsm-apn-spaces", "empty APN");
ASSERT (strcmp (tmp, "foobar") == 0,
"gsm-apn-spaces", "unexpected APN");
}
static void
test_setting_gsm_apn_bad_chars (void)
{
NMSettingGsm *s_gsm;
s_gsm = (NMSettingGsm *) nm_setting_gsm_new ();
ASSERT (s_gsm != NULL,
"gsm-apn-bad-chars",
"error creating GSM setting");
g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", NULL);
/* Make sure a valid APN works */
g_object_set (s_gsm, NM_SETTING_GSM_APN, "foobar123.-baz", NULL);
ASSERT (nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL) == TRUE,
"gsm-apn-bad-chars", "unexpectedly invalid GSM setting");
/* Random invalid chars */
g_object_set (s_gsm, NM_SETTING_GSM_APN, "@#%$@#%@#%", NULL);
ASSERT (nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL) == FALSE,
"gsm-apn-bad-chars", "unexpectedly valid GSM setting");
/* Spaces */
g_object_set (s_gsm, NM_SETTING_GSM_APN, "foobar baz", NULL);
ASSERT (nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL) == FALSE,
"gsm-apn-bad-chars", "unexpectedly valid GSM setting");
/* 0 characters long */
g_object_set (s_gsm, NM_SETTING_GSM_APN, "", NULL);
ASSERT (nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL) == FALSE,
"gsm-apn-bad-chars", "unexpectedly valid GSM setting");
/* 65-character long */
g_object_set (s_gsm, NM_SETTING_GSM_APN, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl1", NULL);
ASSERT (nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL) == FALSE,
"gsm-apn-bad-chars", "unexpectedly valid GSM setting");
}
int main (int argc, char **argv)
{
GError *error = NULL;
@ -237,6 +304,8 @@ int main (int argc, char **argv)
/* The tests */
test_setting_vpn_items ();
test_setting_ip6_config_old_address_array ();
test_setting_gsm_apn_spaces ();
test_setting_gsm_apn_bad_chars ();
base = g_path_get_basename (argv[0]);
fprintf (stdout, "%s: SUCCESS\n", base);

View file

@ -3,6 +3,7 @@ man_MANS = \
NetworkManager.conf.5 \
nm-system-settings.conf.5 \
nm-tool.1 \
nm-online.1 \
nmcli.1
EXTRA_DIST = \
@ -11,6 +12,7 @@ EXTRA_DIST = \
NetworkManager.conf.5.in \
nm-system-settings.conf.5.in \
nm-tool.1.in \
nm-online.1.in \
nmcli.1.in
CLEANFILES = $(man_MANS)

View file

@ -52,6 +52,10 @@ A VPN connection has been deactivated.
.TP
.I "hostname"
The system hostname has been updated. Use gethostname(2) to retrieve it.
.I "dhcp4\-change"
The DHCPv4 lease has changed (renewed, rebound, etc).
.I "dhcp6\-change"
The DHCPv6 lease has changed (renewed, rebound, etc).
.SH OPTIONS
The following options are supported:
.TP

View file

@ -2,7 +2,7 @@
.\"
.\" Copyright (C) 2010 Red Hat, Inc.
.\"
.TH "NetworkManager.conf" "5" "1 February 2010" ""
.TH "NetworkManager.conf" "5" "23 November 2010" ""
.SH NAME
NetworkManager.conf \- NetworkManager configuration file
.SH SYNOPSIS
@ -44,12 +44,13 @@ Description of sections and available keys follows:
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.
List system settings plugin names separated by ','. These 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:"
@ -87,6 +88,38 @@ 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.
.TP
.B no-auto-default=\fI<hwaddr>\fP,\fI<hwaddr>\fP,... | \fI*\fP
Set devices for which NetworkManager shouldn't create default wired connection
(Auto eth0). NetworkManager creates a default wired connection for any wired
device that is managed and doesn't have a connection configured. List a device
in this option to inhibit creating the default connection for the device.
.br
When the default wired connection is deleted or saved to a new persistent connection
by a plugin, the MAC address of the wired device is automatically added to this list
to prevent creating the default connection for that device again.
Devices are specified by their MAC addresses, in lowercase. Multiple
entries are separated by commas. You can use the glob character \fI*\fP instead
of listing addresses to specify all devices.
.br
Examples:
.nf
no-auto-default=00:22:68:5c:5d:c4,00:1e:65:ff:aa:ee
no-auto-default=*
.fi
.TP
.B dns=\fIplugin1\fP,\fIplugin2\fP, ...
List DNS plugin names separated by ','. DNS plugins are used to provide local
caching nameserver functionality (which speeds up DNS queries) and to push
DNS data to applications that use it.
.P
.RS
.B "Available plugins:"
.br
.TP
.I dnsmasq
this plugin uses dnsmasq to provide local caching nameserver functionality.
.RE
.SS [keyfile]
This section contains keyfile-specific options and thus only has effect when using \fIkeyfile\fP plugin.
.TP
@ -96,10 +129,12 @@ Set a persistent hostname when using the \fIkeyfile\fP plugin.
.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:
<hwaddr> is MAC address of the device to be ignored, in hex-digits-and-colons notation.
Multiple entries are separated by a semicolon. No spaces are allowed in the value.
.br
Example:
.nf
unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1e:65:30:d1:c4
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.

64
man/nm-online.1.in Normal file
View file

@ -0,0 +1,64 @@
.\" nm-online (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 NM-ONLINE "1" "6 August 2010"
.SH NAME
nm-online \- ask NetworkManager whether the network is connected
.SH SYNOPSIS
.B nm-online
.RI " [ " OPTIONS " ]
.SH DESCRIPTION
.B nm-online
is a utility to find out whether we are online. It is done by asking
NetworkManager about its status. When run, \fInm\-online\fP waits until
NetworkManager reports an active connection, or specified timeout expires. On
exit, the returned status code should be checked (see the return codes bellow).
.SH OPTIONS
.TP
.B \-t, \-\-timeout
Time to wait for a connection, in seconds. If not specified, the default is 30
seconds.
.TP
.B \-x, \-\-exit
Exit immediately if NetworkManager is not running or connecting.
.TP
.B \-q, \-\-quiet
Don't print anything.
.SH EXIT STATUS
.IP "0" 4
Success - already online or connection established within given timeout
.IP "1" 4
Offline or not online within given timeout
.IP "2" 4
Unspecified error
.SH SEE ALSO
.BR nm\-tool (1),
.BR nmcli (1),
.BR NetworkManager(8).

View file

@ -22,7 +22,7 @@
.\"
.\" Copyright (C) 2010 Red Hat, Inc.
.\"
.TH NMCLI "1" "14 April 2010"
.TH NMCLI "1" "22 September 2010"
.SH NAME
nmcli \- command-line tool for controlling NetworkManager
@ -131,7 +131,7 @@ NetworkManager
.br
Use this object to inquire and change state of NetworkManager.
.TP
.SS \fICOMMAND\fP := { status | sleep | wakeup | wifi | wwan }
.SS \fICOMMAND\fP := { status | enable | sleep | wifi | wwan }
.sp
.RS
.TP
@ -145,28 +145,31 @@ command is provided to \fInm\fP object.
No simple reference.
.fi
.TP
.B sleep
.B enable [true|false]
.br
Put NetworkManager to sleeping mode. Thus all interfaces that NetworkManager
manages are deactivated.
Get networking-enabled status or enable/disable networking by NetworkManager.
All interfaces managed by NetworkManager are deactivated when networking has
been disabled.
.br
.nf
\fBReference to D-Bus:\fP
interface: org.freedesktop.NetworkManager
method: Sleep
arguments: TRUE
method: Enable
arguments: TRUE or FALSE
.fi
.TP
.B wakeup
.B sleep [true|false]
.br
Awake NetworkManager from sleep. When NetworkManager is awaken, devices are
available to be activated.
Get sleep status or put to sleep/awake NetworkManager. All interfaces managed by NetworkManager
are deactivated when it falls asleep. This command is not meant for user to enable/disable
networking, use \fIenable\fP for that. D-Bus \fISleep\fP method is designed
to put NetworkManager to sleep or awake for suspending/resuming computer.
.br
.nf
\fBReference to D-Bus:\fP
interface: org.freedesktop.NetworkManager
method: Sleep
arguments: FALSE
arguments: TRUE or FALSE
.fi
.TP
.B wifi [on|off]
@ -312,10 +315,54 @@ No simple reference.
.fi
.RE
.SH ENVIRONMENT VARIABLES
\fInmcli\fP's behavior is affected by the following environment variables.
.IP "LC_ALL" 13
If set to a non-empty string value, override the values of all the other
internationalization variables.
.IP "LC_MESSAGES" 13
Determines the locale to be used for internationalised messages.
.IP "LANG" 13
Provides a default value for the internationalization variables that are unset
or null.
.RE
Notes about localization:
.br
Be aware that \fInmcli\fP is localized and that's why the output depends on
your environment. It's important to realize that especially when you parse the
output.
.br
Call \fInmcli\fP as \fBLC_ALL=C nmcli\fP to be sure the locale is
set to "C" while executing in a script.
\fBLC_ALL\fP, \fBLC_MESSAGES\fP, \fBLANG\fP variables specify the LC_MESSAGES
locale category (in that order), which determines the language that \fInmcli\fP
uses for messages. The "C" locale is used if none of these variables are set,
and this locale uses English messages.
.SH EXIT STATUS
\fInmcli\fP exits with status 0 if it succeeds, a value greater than 0 is returned if errors occur.
.IP "0" 4
Success - indicates the operation succeeded
.IP "1" 4
Unknown or unspecified error
.IP "2" 4
Invalid user input, wrong \fInmcli\fP invocation
.IP "3" 4
Timeout expired (see commands with \fI\-\-timeout\fP option)
.IP "4" 4
Connection activation failed
.IP "5" 4
Connection deactivation failed
.IP "6" 4
Disconnecting device failed
.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 nm\-online (1),
.BR NetworkManager(8).

View file

@ -14,6 +14,7 @@ dz
el
en_CA
en_GB
eo
es
et
eu
@ -54,6 +55,7 @@ sq
sr
sr@latin
sv
ta
te
th
uk

View file

@ -11,13 +11,16 @@ libnm-util/crypto.c
libnm-util/crypto_gnutls.c
libnm-util/crypto_nss.c
libnm-util/nm-utils.c
policy/org.freedesktop.network-manager-settings.system.policy.in
policy/org.freedesktop.NetworkManager.policy.in
src/nm-netlink-monitor.c
src/main.c
src/dhcp-manager/nm-dhcp-dhclient.c
src/dhcp-manager/nm-dhcp-dhclient-utils.c
src/dhcp-manager/nm-dhcp-manager.c
src/logging/nm-logging.c
src/named-manager/nm-named-manager.c
src/dns-manager/nm-dns-manager.c
src/system-settings/nm-default-wired-connection.c
system-settings/plugins/ifcfg-rh/reader.c
policy/org.freedesktop.network-manager-settings.system.policy.in
system-settings/plugins/ifnet/connection_parser.c

View file

@ -67,11 +67,11 @@ msgid ""
"\n"
msgstr ""
#: ../src/named-manager/nm-named-manager.c:117
#: ../src/dns-manager/nm-dns-manager.c:117
msgid "NOTE: the glibc resolver does not support more than 3 nameservers."
msgstr ""
#: ../src/named-manager/nm-named-manager.c:119
#: ../src/dns-manager/nm-dns-manager.c:119
msgid "The nameservers listed below may not be recognized."
msgstr ""

View file

@ -1590,11 +1590,11 @@ msgstr "অজ্ঞাত লগ স্তৰ '%s'"
msgid "Unknown log domain '%s'"
msgstr "অজ্ঞাত লগ ডোমেইন '%s'"
#: ../src/named-manager/nm-named-manager.c:343
#: ../src/dns-manager/nm-dns-manager.c:343
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr "মন কৰিব: libc resolver ৰ দ্বাৰা ৩ তকৈ অধিক নামৰ সেৱক সমৰ্থিত ন'হ'বও পাৰে ।"
#: ../src/named-manager/nm-named-manager.c:345
#: ../src/dns-manager/nm-dns-manager.c:345
msgid "The nameservers listed below may not be recognized."
msgstr "নিম্নলিখিত নাম-সেৱকসমূহ চিনাক্ত ন'হ'বও পাৰে ।"

View file

@ -55,11 +55,11 @@ msgid "Invalid option. Please use --help to see a list of valid options.\n"
msgstr ""
"Niapravilnaja opcyja. Kab pahladzieć śpis mahčymych opcyj, užyj --help.\n"
#: ../src/named-manager/nm-named-manager.c:218
#: ../src/dns-manager/nm-dns-manager.c:218
msgid "NOTE: the glibc resolver does not support more than 3 nameservers."
msgstr "UVAHA: resolver glibc nie padtrymlivaje bolš za 3 servery nazvaŭ."
#: ../src/named-manager/nm-named-manager.c:220
#: ../src/dns-manager/nm-dns-manager.c:220
msgid "The nameservers listed below may not be recognized."
msgstr "Niemahčyma paznać nastupnyja servery nazvaŭ."

2161
po/bg.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -335,13 +335,13 @@ msgstr ""
"# Fusionat des de %s\n"
"\n"
#: ../src/named-manager/nm-named-manager.c:256
#: ../src/dns-manager/nm-dns-manager.c:256
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr ""
"NOTA: pot ser que el sistema de resolució de la libc no funcioni amb més de "
"3 servidors de noms."
#: ../src/named-manager/nm-named-manager.c:258
#: ../src/dns-manager/nm-dns-manager.c:258
msgid "The nameservers listed below may not be recognized."
msgstr "Pot ser que no es reconeguin els servidors de noms llistats més avall."

1784
po/cs.po

File diff suppressed because it is too large Load diff

1435
po/de.po

File diff suppressed because it is too large Load diff

1610
po/el.po

File diff suppressed because it is too large Load diff

View file

@ -318,11 +318,11 @@ msgstr "unable to connect to netlink: %s"
msgid "unable to join netlink group: %s"
msgstr "unable to join netlink group: %s"
#: ../src/named-manager/nm-named-manager.c:315
#: ../src/dns-manager/nm-dns-manager.c:315
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr "NOTE: the libc resolver may not support more than 3 nameservers."
#: ../src/named-manager/nm-named-manager.c:317
#: ../src/dns-manager/nm-dns-manager.c:317
msgid "The nameservers listed below may not be recognized."
msgstr "The nameservers listed below may not be recognised."

1766
po/eo.po Normal file

File diff suppressed because it is too large Load diff

1622
po/es.po

File diff suppressed because it is too large Load diff

View file

@ -76,11 +76,11 @@ msgstr ""
"# Liidetud allikast %s\n"
"\n"
#: ../src/named-manager/nm-named-manager.c:240
#: ../src/dns-manager/nm-dns-manager.c:240
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr "MÄRKUS: libc lahendaja ei pruugi toetada rohkem kui 3 nimeserverit."
#: ../src/named-manager/nm-named-manager.c:242
#: ../src/dns-manager/nm-dns-manager.c:242
msgid "The nameservers listed below may not be recognized."
msgstr "Järgneva nimistu nimeservereid ei tuntud ära."

View file

@ -1300,11 +1300,11 @@ msgstr "ezin da netlink-ekin konektatu: %s"
msgid "unable to join netlink group: %s"
msgstr "ezin da netlink taldearekin elkartu: %s"
#: ../src/named-manager/nm-named-manager.c:315
#: ../src/dns-manager/nm-dns-manager.c:315
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr "OHARRA: libc-en ebaztaileak ez du 3 izen-zerbitzari baino gehiago onartzen."
#: ../src/named-manager/nm-named-manager.c:317
#: ../src/dns-manager/nm-dns-manager.c:317
msgid "The nameservers listed below may not be recognized."
msgstr "Azpian zerrendatutako izen-zenbitzariak ez dira ezagutuko."

View file

@ -308,11 +308,11 @@ msgstr ""
"# Yhdistetty tiedostosta %s\n"
"\n"
#: ../src/named-manager/nm-named-manager.c:256
#: ../src/dns-manager/nm-dns-manager.c:256
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr "HUOMAUTUS: libc-nimenselvennys ei ehkä tue kuin kolmea nimipalvelinta."
#: ../src/named-manager/nm-named-manager.c:258
#: ../src/dns-manager/nm-dns-manager.c:258
msgid "The nameservers listed below may not be recognized."
msgstr "Alla olevaa nimipalvelinluetteloa ei voitu tunnistaa."

1778
po/fr.po

File diff suppressed because it is too large Load diff

1551
po/gl.po

File diff suppressed because it is too large Load diff

View file

@ -1588,11 +1588,11 @@ msgstr "અજ્ઞાત લોગ સ્તર '%s'"
msgid "Unknown log domain '%s'"
msgstr "અજ્ઞાત લોગ ડોમેઇન '%s'"
#: ../src/named-manager/nm-named-manager.c:343
#: ../src/dns-manager/nm-dns-manager.c:343
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr "નોંધ: libc સુધારનાર એ ૩ નામ સર્વરો કરતા વધારે આધારને સમાવી શકતુ નથી."
#: ../src/named-manager/nm-named-manager.c:345
#: ../src/dns-manager/nm-dns-manager.c:345
msgid "The nameservers listed below may not be recognized."
msgstr "નીચે યાદી થયેલ નામસર્વરો એ ઓળખી શકાતા નથી."

138
po/hi.po
View file

@ -5,12 +5,12 @@
# Rajesh Ranjan <rranjan@redhat.com>, 2010.
msgid ""
msgstr ""
"Project-Id-Version: NetworkManager.master\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager&component=general\n"
"POT-Creation-Date: 2010-05-06 14:31+0530\n"
"PO-Revision-Date: 2010-05-07 15:23+0530\n"
"Project-Id-Version: hi\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-07-20 12:39+0530\n"
"PO-Revision-Date: 2010-07-26 13:05+0530\n"
"Last-Translator: Rajesh Ranjan <rranjan@redhat.com>\n"
"Language-Team: Hindi <Red Hat>\n"
"Language-Team: Hindi <fedora-trans-hi@redhat.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -499,6 +499,16 @@ msgstr "IP4-SETTINGS"
msgid "IP4-DNS"
msgstr "IP4-DNS"
#. 6
#: ../cli/src/devices.c:79
msgid "IP6-SETTINGS"
msgstr "IP6-SETTINGS"
#. 7
#: ../cli/src/devices.c:80
msgid "IP6-DNS"
msgstr "IP6-DNS"
#. 2
#: ../cli/src/devices.c:88
msgid "DRIVER"
@ -1501,6 +1511,88 @@ msgstr "गोपित कुंजी को PEM फाइल में लि
msgid "Could not allocate memory for PEM file data."
msgstr "PEM फाइल आँकड़ा के लिए स्मृति नहीं आबंटित कर सका."
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:1
msgid "Connection sharing via a protected WiFi network"
msgstr "किसी संरक्षित WiFi संजाल के द्वारा कनेक्शन साझा"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:2
msgid "Connection sharing via an open WiFi network"
msgstr "किसी खुले WiFi संजाल के द्वारा कनेक्शन साझा"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:3
msgid "Modify persistent system hostname"
msgstr "स्थिर सिस्टम होस्टनेम को सुधारें"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:4
msgid "Modify system connections"
msgstr "सिस्टम कनेक्शन सुधारें"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:5
msgid "System policy prevents modification of system settings"
msgstr "सिस्टम नीति सिस्टम सेटिंग के रूपांतरण को रोकता है."
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:6
msgid "System policy prevents modification of the persistent system hostname"
msgstr "सिस्टम नीति स्थिर सिस्टम होस्टनेम के रूपांतरण को रोकता है."
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:7
msgid "System policy prevents sharing connections via a protected WiFi network"
msgstr "किसी संरक्षित WiFi संजाल के द्वारा साझा कनेक्शन को सिस्टम नीति रोकता है"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:8
msgid "System policy prevents sharing connections via an open WiFi network"
msgstr "किसी खुले WiFi संजाल के द्वारा साझा कनेक्शन को सिस्टम नीति रोकता है"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:1
msgid "Allow control of network connections"
msgstr "संजाल कनेक्शन के नियंत्रण स्वीकार करें"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:2
msgid "Allow use of user-specific connections"
msgstr "उपयोक्ता विशिष्ट कनेक्शन के उपयोग की स्वीकृति दें"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:3
msgid "Enable or disable WiFi devices"
msgstr "WiFi युक्तियाँ सक्रिय या निष्क्रिय करें"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:4
msgid "Enable or disable mobile broadband devices"
msgstr "मोबाइल ब्राडबैंड युक्तियाँ सक्रिय या निष्क्रिय करें"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:5
msgid "Enable or disable system networking"
msgstr "तंत्र संजालन सक्रिय या निष्क्रिय करें"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:6
msgid ""
"Put NetworkManager to sleep or wake it up (should only be used by system "
"power management)"
msgstr " NetworkManager को स्लीप स्थिति या वेकअप स्थिति में रखें (केवल सिस्टम पावर मैनेजमेंट के द्वारा प्रयोग किया जाएगा)"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:7
msgid "System policy prevents control of network connections"
msgstr "सिस्टम कनेक्शन के नियंत्रण को सिस्टम नीति रोकता है"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:8
msgid "System policy prevents enabling or disabling WiFi devices"
msgstr "WiFi युक्ति के सक्रियण या निष्क्रियण को तंत्र नीति रोकता है"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:9
msgid "System policy prevents enabling or disabling mobile broadband devices"
msgstr "मोबाइल ब्रॉडबैंड युक्ति के सक्रियण या निष्क्रियण को तंत्र नीति रोकता है"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:10
msgid "System policy prevents enabling or disabling system networking"
msgstr "तंत्र संजालन के युक्ति के सक्रियण या निष्क्रियण को तंत्र नीति रोकता है"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:11
msgid "System policy prevents putting NetworkManager to sleep or waking it up"
msgstr "NetworkManager को स्लीप या वेकअप स्थिति में लाने के लिए नेटवर्कमैनेजर रोकता है"
#: ../policy/org.freedesktop.NetworkManager.policy.in.h:12
msgid "System policy prevents use of user-specific connections"
msgstr "सिस्टम नीति उपयोक्ता विशेष कनेक्शन के उपयोग को रोकता है"
#: ../src/nm-netlink-monitor.c:100 ../src/nm-netlink-monitor.c:231
#: ../src/nm-netlink-monitor.c:653
#, c-format
@ -1591,11 +1683,11 @@ msgstr "अज्ञात लॉग स्तर '%s'"
msgid "Unknown log domain '%s'"
msgstr "अज्ञात लॉग डोमेन '%s'"
#: ../src/named-manager/nm-named-manager.c:343
#: ../src/dns-manager/nm-dns-manager.c:343
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
msgstr "नोट: libc समाधानकर्ता 3 नेमसर्वर से अधिक का समर्थन नहीं कर सकता है."
#: ../src/named-manager/nm-named-manager.c:345
#: ../src/dns-manager/nm-dns-manager.c:345
msgid "The nameservers listed below may not be recognized."
msgstr "नीचे सूची में दिया गया नेमसर्वर पहचाना नहीं जा सकता है."
@ -1608,35 +1700,3 @@ msgstr "स्वतः %s"
msgid "System"
msgstr "तंत्र"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:1
msgid "Connection sharing via a protected WiFi network"
msgstr "किसी संरक्षित WiFi संजाल के द्वारा कनेक्शन साझा"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:2
msgid "Connection sharing via an open WiFi network"
msgstr "किसी खुले WiFi संजाल के द्वारा कनेक्शन साझा"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:3
msgid "Modify persistent system hostname"
msgstr "स्थिर सिस्टम होस्टनेम को सुधारें"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:4
msgid "Modify system connections"
msgstr "सिस्टम कनेक्शन सुधारें"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:5
msgid "System policy prevents modification of system settings"
msgstr "सिस्टम नीति सिस्टम सेटिंग के रूपांतरण को रोकता है."
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:6
msgid "System policy prevents modification of the persistent system hostname"
msgstr "सिस्टम नीति स्थिर सिस्टम होस्टनेम के रूपांतरण को रोकता है."
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:7
msgid "System policy prevents sharing connections via a protected WiFi network"
msgstr "किसी संरक्षित WiFi संजाल के द्वारा साझा कनेक्शन को सिस्टम नीति रोकता है"
#: ../policy/org.freedesktop.network-manager-settings.system.policy.in.h:8
msgid "System policy prevents sharing connections via an open WiFi network"
msgstr "किसी खुले WiFi संजाल के द्वारा साझा कनेक्शन को सिस्टम नीति रोकता है"

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