summary refs log tree commit diff
path: root/src/modem-manager/nm-modem.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2012-10-26 21:32:57 +0200
committerMichael Biebl <biebl@debian.org>2012-10-26 21:32:57 +0200
commit36cb2f364a821e1be50b23e03a18891ec55adb06 (patch)
treedcc7ff4019373acf1583c3271c4efbddbf43aa6c /src/modem-manager/nm-modem.c
parent8c98b34228abb4dfde822ad89106b4d8b2287639 (diff)
Imported Upstream version 0.9.6.4 upstream/0.9.6.4
Diffstat (limited to 'src/modem-manager/nm-modem.c')
-rw-r--r--src/modem-manager/nm-modem.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/modem-manager/nm-modem.c b/src/modem-manager/nm-modem.c
index c9c9e9a4..c43e5e16 100644
--- a/src/modem-manager/nm-modem.c
+++ b/src/modem-manager/nm-modem.c
@@ -282,6 +282,25 @@ ppp_stage3_ip4_config_start (NMModem *self,
 /*****************************************************************************/
 /* IP method static */
 
+static char addr_to_string_buf[INET6_ADDRSTRLEN + 1];
+
+static const char *
+ip_address_to_string (guint32 numeric)
+{
+	struct in_addr temp_addr;
+
+	memset (&addr_to_string_buf, '\0', sizeof (addr_to_string_buf));
+	temp_addr.s_addr = numeric;
+
+	if (inet_ntop (AF_INET, &temp_addr, addr_to_string_buf, INET_ADDRSTRLEN)) {
+		return addr_to_string_buf;
+	} else {
+		nm_log_warn (LOGD_VPN, "error converting IP4 address 0x%X",
+		             ntohl (temp_addr.s_addr));
+		return NULL;
+	}
+}
+
 static void
 static_stage3_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 {
@@ -293,23 +312,39 @@ static_stage3_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 
 	priv->call = NULL;
 
+	/* Returned value array is (uuuu): [IP, DNS1, DNS2, DNS3], all in
+	 * network byte order.
+	 */
 	if (dbus_g_proxy_end_call (proxy, call, &error,
-							   G_TYPE_VALUE_ARRAY, &ret_array,
-							   G_TYPE_INVALID)) {
+	                           G_TYPE_VALUE_ARRAY, &ret_array,
+	                           G_TYPE_INVALID)) {
 		NMIP4Address *addr;
 		int i;
 
 		config = nm_ip4_config_new ();
 
 		addr = nm_ip4_address_new ();
+
+		nm_log_info (LOGD_MB, "(%s): IPv4 static configuration:", priv->iface);
+
+		/* IP address */
 		nm_ip4_address_set_address (addr, g_value_get_uint (g_value_array_get_nth (ret_array, 0)));
 		nm_ip4_address_set_prefix (addr, 32);
 		nm_ip4_config_take_address (config, addr);
 
-		for (i = 0; i < ret_array->n_values; i++) {
+		nm_log_info (LOGD_MB, "  address %s/%d",
+		             ip_address_to_string (nm_ip4_address_get_address (addr)),
+		             nm_ip4_address_get_prefix (addr));
+
+		/* DNS servers */
+		for (i = 1; i < ret_array->n_values; i++) {
 			GValue *value = g_value_array_get_nth (ret_array, i);
+			guint32 tmp = g_value_get_uint (value);
 
-			nm_ip4_config_add_nameserver (config, g_value_get_uint (value));
+			if (tmp > 0) {
+				nm_ip4_config_add_nameserver (config, tmp);
+				nm_log_info (LOGD_MB, "  DNS %s", ip_address_to_string (tmp));
+			}
 		}
 		g_value_array_free (ret_array);
 	}