summaryrefslogtreecommitdiff
path: root/libnm-glib
diff options
context:
space:
mode:
authorTambet Ingo <tambet@ximian.com>2007-02-16 11:23:49 +0000
committerTambet Ingo <tambet@gmail.com>2007-02-16 11:23:49 +0000
commitc40051389cccf8171a26938db7c167b9ca0010cf (patch)
tree387d614ac1e9e04dc2034f852af875757950e6d8 /libnm-glib
parent333f46827183b47d3d8b17a3453c9d55fb10f267 (diff)
downloadNetworkManager-c40051389cccf8171a26938db7c167b9ca0010cf.tar.gz
2007-02-16 Tambet Ingo <tambet@ximian.com>
* introspection/nm-ip4-config.xml: Implement. * libnm-glib/libnm-glib-test.c: Use new DBUS API in tests. * libnm-glib/nm-ip4-config.c: * libnm-glib/nm-ip4-config.c: Implement. * src/nm-ap-security[-*]: Remove circular dependencies between APs and AP securities. APs reference security. * src/nm-device-802-11-wireless.c: Implement missing properties that need to be exported over DBUS. * src/nm-device-802-3-ethernet.c: Ditto. * src/NetworkManagerAP.c: * src/NetworkManagerAP.h: - Convert to GObject, export over DBUS. * src/nm-ip4-config.h: * src/nm-ip4-config.h: - Convert to GObject, export over DBUS. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2322 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-glib')
-rw-r--r--libnm-glib/Makefile.am4
-rw-r--r--libnm-glib/libnm-glib-test.c173
-rw-r--r--libnm-glib/nm-access-point.c28
-rw-r--r--libnm-glib/nm-access-point.h6
-rw-r--r--libnm-glib/nm-client.c2
-rw-r--r--libnm-glib/nm-device-802-11-wireless.c24
-rw-r--r--libnm-glib/nm-device-802-11-wireless.h4
-rw-r--r--libnm-glib/nm-device-802-3-ethernet.c5
-rw-r--r--libnm-glib/nm-device-802-3-ethernet.h2
-rw-r--r--libnm-glib/nm-device.c25
-rw-r--r--libnm-glib/nm-device.h5
-rw-r--r--libnm-glib/nm-ip4-config.c183
-rw-r--r--libnm-glib/nm-ip4-config.h40
13 files changed, 462 insertions, 39 deletions
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am
index 28f451a44a..7bb194462f 100644
--- a/libnm-glib/Makefile.am
+++ b/libnm-glib/Makefile.am
@@ -20,7 +20,8 @@ libnminclude_HEADERS = \
nm-device.h \
nm-device-802-3-ethernet.h \
nm-device-802-11-wireless.h \
- nm-access-point.h
+ nm-access-point.h \
+ nm-ip4-config.h
libnm_glib_la_SOURCES = \
nm-client.c \
@@ -29,6 +30,7 @@ libnm_glib_la_SOURCES = \
nm-device-802-3-ethernet.c \
nm-device-802-11-wireless.c \
nm-access-point.c \
+ nm-ip4-config.c \
nm-utils.c \
nm-utils.h \
$(BUILT_SOURCES)
diff --git a/libnm-glib/libnm-glib-test.c b/libnm-glib/libnm-glib-test.c
index a03b3a2060..b3c67c7cbd 100644
--- a/libnm-glib/libnm-glib-test.c
+++ b/libnm-glib/libnm-glib-test.c
@@ -1,4 +1,9 @@
#include <stdlib.h>
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
#include "nm-client.h"
#include "nm-device.h"
#include "nm-device-802-3-ethernet.h"
@@ -33,12 +38,150 @@ test_get_state (NMClient *client)
return TRUE;
}
+static gchar *
+ip4_address_as_string (guint32 ip)
+{
+ struct in_addr tmp_addr;
+ gchar *ip_string;
+
+ tmp_addr.s_addr = ip;
+ ip_string = inet_ntoa (tmp_addr);
+
+ return g_strdup (ip_string);
+}
+
+static void
+dump_ip4_config (NMIP4Config *cfg)
+{
+ char *tmp;
+ GArray *array;
+ char **ptr_array;
+ int i;
+
+ tmp = ip4_address_as_string (nm_ip4_config_get_address (cfg));
+ g_print ("IP4 address: %s\n", tmp);
+ g_free (tmp);
+
+ tmp = ip4_address_as_string (nm_ip4_config_get_gateway (cfg));
+ g_print ("IP4 gateway: %s\n", tmp);
+ g_free (tmp);
+
+ tmp = ip4_address_as_string (nm_ip4_config_get_netmask (cfg));
+ g_print ("IP4 netmask: %s\n", tmp);
+ g_free (tmp);
+
+ tmp = ip4_address_as_string (nm_ip4_config_get_broadcast (cfg));
+ g_print ("IP4 broadcast: %s\n", tmp);
+ g_free (tmp);
+
+ tmp = nm_ip4_config_get_hostname (cfg);
+ g_print ("IP4 hostname: %s\n", tmp);
+ g_free (tmp);
+
+ array = nm_ip4_config_get_nameservers (cfg);
+ if (array) {
+ g_print ("IP4 DNS:\n");
+ for (i = 0; i < array->len; i++) {
+ tmp = ip4_address_as_string (g_array_index (array, guint32, i));
+ g_print ("\t%s\n", tmp);
+ g_free (tmp);
+ }
+
+ g_array_free (array, TRUE);
+ }
+
+ ptr_array = nm_ip4_config_get_domains (cfg);
+ if (ptr_array) {
+ g_print ("IP4 domains:\n");
+ for (i = 0; ptr_array[i]; i++) {
+ g_print ("\t%s\n", ptr_array[i]);
+ }
+
+ g_strfreev (ptr_array);
+ }
+
+ tmp = nm_ip4_config_get_nis_domain (cfg);
+ g_print ("IP4 NIS domain: %s\n", tmp);
+ g_free (tmp);
+
+ array = nm_ip4_config_get_nis_servers (cfg);
+ if (array) {
+ g_print ("IP4 NIS servers:\n");
+ for (i = 0; i < array->len; i++) {
+ tmp = ip4_address_as_string (g_array_index (array, guint32, i));
+ g_print ("\t%s\n", tmp);
+ g_free (tmp);
+ }
+
+ g_array_free (array, TRUE);
+ }
+}
+
+static void
+dump_wireless (NMDevice80211Wireless *device)
+{
+ char *str;
+ GSList *iter;
+ GSList *networks;
+
+ g_print ("Mode: %d\n", nm_device_802_11_wireless_get_mode (device));
+ g_print ("Bitrate: %d\n", nm_device_802_11_wireless_get_bitrate (device));
+
+ str = nm_device_802_11_wireless_get_hw_address (device);
+ g_print ("MAC: %s\n", str);
+ g_free (str);
+
+ g_print ("Networks:\n");
+ networks = nm_device_802_11_wireless_get_networks (device);
+ for (iter = networks; iter; iter = iter->next) {
+ NMAccessPoint *ap = NM_ACCESS_POINT (iter->data);
+
+ str = nm_access_point_get_essid (ap);
+ g_print ("\tEssid: %s\n", str);
+ g_free (str);
+
+ /* This is not provided by NM yet */
+#if 0
+ str = nm_access_point_get_address (ap);
+ g_print ("\tAddress: %s\n", str);
+ g_free (str);
+
+ str = nm_access_point_get_hw_address (ap);
+ g_print ("\tMAC Address: %s\n", str);
+ g_free (str);
+#endif
+
+ g_print ("\tCapabilities: %d\n", nm_access_point_get_capabilities (ap));
+ g_print ("\tEncrypted: %d\n", nm_access_point_is_encrypted (ap));
+ g_print ("\tFrequency: %f\n", nm_access_point_get_frequency (ap));
+
+ g_print ("\tMode: %d\n", nm_access_point_get_mode (ap));
+ g_print ("\tRate: %d\n", nm_access_point_get_rate (ap));
+ g_print ("\tStrength: %d\n", nm_access_point_get_strength (ap));
+
+ g_print ("\n");
+ }
+
+ g_slist_foreach (networks, (GFunc) g_object_unref, NULL);
+ g_slist_free (networks);
+}
+
+static void
+dump_wired (NMDevice8023Ethernet *device)
+{
+ char *str;
+
+ g_print ("Speed: %d\n", nm_device_802_3_ethernet_get_speed (device));
+
+ str = nm_device_802_3_ethernet_get_hw_address (device);
+ g_print ("MAC: %s\n", str);
+ g_free (str);
+}
static void
dump_device (NMDevice *device)
{
char *str;
- gboolean b;
guint32 u;
NMDeviceState state;
@@ -60,24 +203,16 @@ dump_device (NMDevice *device)
state = nm_device_get_state (device);
g_print ("State: %d\n", state);
- if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
- int speed = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (device));
- g_print ("Speed: %d\n", speed);
- } else if (NM_IS_DEVICE_802_11_WIRELESS (device)) {
- GSList *iter;
- GSList *networks = nm_device_802_11_wireless_get_networks (NM_DEVICE_802_11_WIRELESS (device));
-
- g_print ("Networks:\n");
- for (iter = networks; iter; iter = iter->next) {
- NMAccessPoint *ap = NM_ACCESS_POINT (iter->data);
-
- str = nm_access_point_get_essid (ap);
- g_print ("\tEssid: %s\n", str);
- g_free (str);
- }
- g_slist_foreach (networks, (GFunc) g_object_unref, NULL);
- g_slist_free (networks);
+ if (state == NM_DEVICE_STATE_ACTIVATED) {
+ NMIP4Config *cfg = nm_device_get_ip4_config (device);
+ dump_ip4_config (cfg);
+ g_object_unref (cfg);
}
+
+ if (NM_IS_DEVICE_802_3_ETHERNET (device))
+ dump_wired (NM_DEVICE_802_3_ETHERNET (device));
+ else if (NM_IS_DEVICE_802_11_WIRELESS (device))
+ dump_wireless (NM_DEVICE_802_11_WIRELESS (device));
}
static gboolean
@@ -181,7 +316,7 @@ main (int argc, char *argv[])
exit (1);
}
- test_wireless_enabled (client);
+/* test_wireless_enabled (client); */
test_get_state (client);
test_devices (client);
diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c
index 320b1121c6..0795162e66 100644
--- a/libnm-glib/nm-access-point.c
+++ b/libnm-glib/nm-access-point.c
@@ -1,5 +1,6 @@
#include "nm-access-point.h"
#include "NetworkManager.h"
+#include "nm-utils.h"
#include "nm-access-point-bindings.h"
@@ -43,11 +44,11 @@ nm_access_point_get_address (NMAccessPoint *ap)
return address;
}
-int
+guint32
nm_access_point_get_capabilities (NMAccessPoint *ap)
{
GValue value = {0,};
- int caps = 0;
+ guint32 caps = 0;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
@@ -55,7 +56,7 @@ nm_access_point_get_capabilities (NMAccessPoint *ap)
NM_DBUS_INTERFACE_ACCESS_POINT,
"Capabilities",
&value))
- caps = g_value_get_int (&value);
+ caps = g_value_get_uint (&value);
return caps;
}
@@ -94,9 +95,22 @@ nm_access_point_get_essid (NMAccessPoint *ap)
return essid;
}
-double
+gdouble
nm_access_point_get_frequency (NMAccessPoint *ap)
{
+ GValue value = {0,};
+ double freq = 0.0;
+
+ g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), freq);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (ap),
+ NM_DBUS_INTERFACE_ACCESS_POINT,
+ "Frequency",
+ &value))
+ freq = g_value_get_double (&value);
+
+ return freq;
+
}
char *
@@ -133,11 +147,11 @@ nm_access_point_get_mode (NMAccessPoint *ap)
return mode;
}
-int
+guint32
nm_access_point_get_rate (NMAccessPoint *ap)
{
GValue value = {0,};
- int rate = 0;
+ guint32 rate = 0;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
@@ -145,7 +159,7 @@ nm_access_point_get_rate (NMAccessPoint *ap)
NM_DBUS_INTERFACE_ACCESS_POINT,
"Rate",
&value))
- rate = g_value_get_int (&value);
+ rate = g_value_get_uint (&value);
return rate;
}
diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h
index 13c626e4d6..9ff4c3b421 100644
--- a/libnm-glib/nm-access-point.h
+++ b/libnm-glib/nm-access-point.h
@@ -25,13 +25,13 @@ GType nm_access_point_get_type (void);
NMAccessPoint *nm_access_point_new (DBusGConnection *connection, const char *path);
char *nm_access_point_get_address (NMAccessPoint *ap);
-int nm_access_point_get_capabilities (NMAccessPoint *ap);
+guint32 nm_access_point_get_capabilities (NMAccessPoint *ap);
gboolean nm_access_point_is_encrypted (NMAccessPoint *ap);
char *nm_access_point_get_essid (NMAccessPoint *ap);
-double nm_access_point_get_frequency (NMAccessPoint *ap);
+gdouble nm_access_point_get_frequency (NMAccessPoint *ap);
char *nm_access_point_get_hw_address (NMAccessPoint *ap);
int nm_access_point_get_mode (NMAccessPoint *ap);
-int nm_access_point_get_rate (NMAccessPoint *ap);
+guint32 nm_access_point_get_rate (NMAccessPoint *ap);
int nm_access_point_get_strength (NMAccessPoint *ap);
#endif /* NM_ACCESS_POINT_H */
diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c
index 8a7bed2a92..cd6f55f213 100644
--- a/libnm-glib/nm-client.c
+++ b/libnm-glib/nm-client.c
@@ -75,7 +75,7 @@ nm_client_new (void)
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
if (!connection) {
- g_warning ("Couldn't connect to system bus: %d", err->message);
+ g_warning ("Couldn't connect to system bus: %s", err->message);
g_error_free (err);
return NULL;
}
diff --git a/libnm-glib/nm-device-802-11-wireless.c b/libnm-glib/nm-device-802-11-wireless.c
index a8fbd71242..dcd8085eeb 100644
--- a/libnm-glib/nm-device-802-11-wireless.c
+++ b/libnm-glib/nm-device-802-11-wireless.c
@@ -1,5 +1,6 @@
#include "nm-device-802-11-wireless.h"
#include "nm-device-private.h"
+#include "nm-utils.h"
#include "nm-device-802-11-wireless-bindings.h"
@@ -30,7 +31,7 @@ nm_device_802_11_wireless_new (DBusGConnection *connection, const char *path)
}
char *
-nm_device_802_11_wireless_get_address (NMDevice80211Wireless *device)
+nm_device_802_11_wireless_get_hw_address (NMDevice80211Wireless *device)
{
GValue value = {0,};
char *address = NULL;
@@ -39,7 +40,7 @@ nm_device_802_11_wireless_get_address (NMDevice80211Wireless *device)
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "Address",
+ "HwAddress",
&value))
address = g_strdup (g_value_get_string (&value));
@@ -56,13 +57,30 @@ nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device)
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "Node",
+ "Mode",
&value))
mode = g_value_get_int (&value);
return mode;
}
+int
+nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device)
+{
+ GValue value = {0,};
+ int bitrate = 0;
+
+ g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), 0);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (device),
+ NM_DBUS_INTERFACE_DEVICE_WIRELESS,
+ "Bitrate",
+ &value))
+ bitrate = g_value_get_int (&value);
+
+ return bitrate;
+}
+
NMAccessPoint *
nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device)
{
diff --git a/libnm-glib/nm-device-802-11-wireless.h b/libnm-glib/nm-device-802-11-wireless.h
index f87f966eda..0c36fb422a 100644
--- a/libnm-glib/nm-device-802-11-wireless.h
+++ b/libnm-glib/nm-device-802-11-wireless.h
@@ -23,10 +23,10 @@ GType nm_device_802_11_wireless_get_type (void);
NMDevice80211Wireless *nm_device_802_11_wireless_new (DBusGConnection *connection,
const char *path);
-int nm_device_802_11_wireless_get_speed (NMDevice80211Wireless *device);
-char *nm_device_802_11_wireless_get_address (NMDevice80211Wireless *device);
+char *nm_device_802_11_wireless_get_hw_address (NMDevice80211Wireless *device);
int nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device);
+int nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device);
NMAccessPoint *nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device);
GSList *nm_device_802_11_wireless_get_networks (NMDevice80211Wireless *device);
diff --git a/libnm-glib/nm-device-802-3-ethernet.c b/libnm-glib/nm-device-802-3-ethernet.c
index 5051b1aee2..a51402865f 100644
--- a/libnm-glib/nm-device-802-3-ethernet.c
+++ b/libnm-glib/nm-device-802-3-ethernet.c
@@ -1,5 +1,6 @@
#include "nm-device-802-3-ethernet.h"
#include "nm-device-private.h"
+#include "nm-utils.h"
#include "nm-device-802-3-ethernet-bindings.h"
@@ -47,7 +48,7 @@ nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device)
}
char *
-nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *device)
+nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device)
{
char *address = NULL;
GValue value = {0,};
@@ -56,7 +57,7 @@ nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *device)
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
- "Address",
+ "HwAddress",
&value))
address = g_strdup (g_value_get_string (&value));
diff --git a/libnm-glib/nm-device-802-3-ethernet.h b/libnm-glib/nm-device-802-3-ethernet.h
index 7535820628..8eb58ce247 100644
--- a/libnm-glib/nm-device-802-3-ethernet.h
+++ b/libnm-glib/nm-device-802-3-ethernet.h
@@ -23,7 +23,7 @@ GType nm_device_802_3_ethernet_get_type (void);
NMDevice8023Ethernet *nm_device_802_3_ethernet_new (DBusGConnection *connection,
const char *path);
int nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device);
-char *nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *device);
+char *nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device);
void nm_device_802_3_ethernet_activate (NMDevice8023Ethernet *device,
gboolean user_requested);
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
index 6fd5e68927..6517ecb546 100644
--- a/libnm-glib/nm-device.c
+++ b/libnm-glib/nm-device.c
@@ -1,5 +1,6 @@
#include "nm-device.h"
#include "nm-device-private.h"
+#include "nm-utils.h"
#include "nm-device-bindings.h"
@@ -164,6 +165,30 @@ nm_device_get_ip4_address (NMDevice *device)
return address;
}
+NMIP4Config *
+nm_device_get_ip4_config (NMDevice *device)
+{
+ NMIP4Config *config = NULL;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_DEVICE (device), 0);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (device),
+ NM_DBUS_INTERFACE_DEVICE,
+ "Ip4Config",
+ &value)) {
+ DBusGConnection *connection = NULL;
+
+ g_assert (G_VALUE_TYPE (&value) == DBUS_TYPE_G_OBJECT_PATH);
+
+ g_object_get (device, "connection", &connection, NULL);
+
+ config = nm_ip4_config_new (connection, (const char *) g_value_get_boxed (&value));
+ }
+
+ return config;
+}
+
NMDeviceState
nm_device_get_state (NMDevice *device)
{
diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h
index dcdaf9a88c..0ca6845eaf 100644
--- a/libnm-glib/nm-device.h
+++ b/libnm-glib/nm-device.h
@@ -5,6 +5,7 @@
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include "NetworkManager.h"
+#include "nm-ip4-config.h"
#define NM_TYPE_DEVICE (nm_device_get_type ())
#define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
@@ -34,6 +35,10 @@ char *nm_device_get_iface (NMDevice *device);
char *nm_device_get_udi (NMDevice *device);
char *nm_device_get_driver (NMDevice *device);
guint32 nm_device_get_ip4_address (NMDevice *device);
+NMIP4Config *nm_device_get_ip4_config (NMDevice *device);
NMDeviceState nm_device_get_state (NMDevice *device);
+NMDeviceType nm_device_type_for_path (DBusGConnection *connection,
+ const char *path);
+
#endif /* NM_DEVICE_H */
diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c
new file mode 100644
index 0000000000..68f99f6915
--- /dev/null
+++ b/libnm-glib/nm-ip4-config.c
@@ -0,0 +1,183 @@
+#include "nm-ip4-config.h"
+#include "nm-device-private.h"
+#include "nm-utils.h"
+
+
+G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, DBUS_TYPE_G_PROXY)
+
+static void
+nm_ip4_config_init (NMIP4Config *config)
+{
+}
+
+static void
+nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
+{
+}
+
+#define INTERFACE NM_DBUS_INTERFACE ".IP4Config"
+
+NMIP4Config *
+nm_ip4_config_new (DBusGConnection *connection, const char *object_path)
+{
+ return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
+ "name", NM_DBUS_SERVICE,
+ "path", object_path,
+ "interface", INTERFACE,
+ "connection", connection,
+ NULL);
+}
+
+guint32
+nm_ip4_config_get_address (NMIP4Config *config)
+{
+ guint32 address = 0;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "Address",
+ &value))
+ address = g_value_get_uint (&value);
+
+ return address;
+}
+
+guint32
+nm_ip4_config_get_gateway (NMIP4Config *config)
+{
+ guint32 gateway = 0;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "Gateway",
+ &value))
+ gateway = g_value_get_uint (&value);
+
+ return gateway;
+}
+
+guint32
+nm_ip4_config_get_netmask (NMIP4Config *config)
+{
+ guint32 netmask = 0;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "Netmask",
+ &value))
+ netmask = g_value_get_uint (&value);
+
+ return netmask;
+}
+
+guint32
+nm_ip4_config_get_broadcast (NMIP4Config *config)
+{
+ guint32 broadcast = 0;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "Broadcast",
+ &value))
+ broadcast = g_value_get_uint (&value);
+
+ return broadcast;
+}
+
+char *
+nm_ip4_config_get_hostname (NMIP4Config *config)
+{
+ char *address = NULL;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "Hostname",
+ &value))
+ address = g_strdup (g_value_get_string (&value));
+
+ return address;
+}
+
+GArray *
+nm_ip4_config_get_nameservers (NMIP4Config *config)
+{
+ GArray *array = NULL;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "Nameservers",
+ &value))
+ array = (GArray *) g_value_get_boxed (&value);
+
+ return array;
+}
+
+
+char **
+nm_ip4_config_get_domains (NMIP4Config *config)
+{
+ char **array = NULL;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "Domains",
+ &value))
+ array = (char **) g_value_get_boxed (&value);
+
+ return array;
+}
+
+char *
+nm_ip4_config_get_nis_domain (NMIP4Config *config)
+{
+ char *address = NULL;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "NisDomain",
+ &value))
+ address = g_strdup (g_value_get_string (&value));
+
+ return address;
+}
+
+GArray *
+nm_ip4_config_get_nis_servers (NMIP4Config *config)
+{
+ GArray *array = NULL;
+ GValue value = {0,};
+
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
+
+ if (nm_dbus_get_property (DBUS_G_PROXY (config),
+ INTERFACE,
+ "NisServers",
+ &value))
+ array = (GArray *) g_value_get_boxed (&value);
+
+ return array;
+}
diff --git a/libnm-glib/nm-ip4-config.h b/libnm-glib/nm-ip4-config.h
new file mode 100644
index 0000000000..0c179f1e6e
--- /dev/null
+++ b/libnm-glib/nm-ip4-config.h
@@ -0,0 +1,40 @@
+#ifndef NM_IP4_CONFIG_H
+#define NM_IP4_CONFIG_H
+
+#include <glib/gtypes.h>
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+#include "NetworkManager.h"
+
+#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
+#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
+#define NM_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
+#define NM_IS_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP4_CONFIG))
+#define NM_IS_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_IP4_CONFIG))
+#define NM_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
+
+typedef struct {
+ DBusGProxy parent;
+} NMIP4Config;
+
+typedef struct {
+ DBusGProxyClass parent;
+} NMIP4ConfigClass;
+
+GType nm_ip4_config_get_type (void);
+
+NMIP4Config *nm_ip4_config_new (DBusGConnection *connection,
+ const char *object_path);
+
+guint32 nm_ip4_config_get_address (NMIP4Config *config);
+guint32 nm_ip4_config_get_gateway (NMIP4Config *config);
+guint32 nm_ip4_config_get_netmask (NMIP4Config *config);
+guint32 nm_ip4_config_get_broadcast (NMIP4Config *config);
+char *nm_ip4_config_get_hostname (NMIP4Config *config);
+GArray *nm_ip4_config_get_nameservers (NMIP4Config *config);
+char **nm_ip4_config_get_domains (NMIP4Config *config);
+char *nm_ip4_config_get_nis_domain (NMIP4Config *config);
+GArray *nm_ip4_config_get_nis_servers (NMIP4Config *config);
+
+
+#endif /* NM_IP4_CONFIG_H */