NetworkManager r3432 - in trunk: . introspection libnm-glib src test



Author: dcbw
Date: Wed Mar 12 17:44:39 2008
New Revision: 3432
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3432&view=rev

Log:
2008-03-12  Dan Williams  <dcbw redhat com>

	Harmonize the 802.11 bitrate API

	* introspection/nm-access-point.xml
		- 'Rate' -> 'MaxBitrate'; clarify units

	* introspection/nm-device-802-11-wireless.xml
		- Clarify units of 'Bitrate'

	* src/NetworkManagerAP.c
	  src/NetworkManagerAP.h
		- (set_property, get_property, nm_ap_class_init): rename 'rate'
			property to 'max-bitrate'
		- (foreach_property_cb): convert rate to Kb/s

	* src/nm-device-802-11-wireless.c
		- (nm_device_802_11_wireless_get_bitrate): return rate in Kb/s

	* libnm-glib/nm-access-point.c
	  libnm-glib/nm-access-point.h
		- 'rate' -> 'max-bitrate'

	* test/nm-tool.c
	  libnm-glib/libnm-glib-test.c
		- Fix up for these changes



Modified:
   trunk/ChangeLog
   trunk/introspection/nm-access-point.xml
   trunk/introspection/nm-device-802-11-wireless.xml
   trunk/libnm-glib/libnm-glib-test.c
   trunk/libnm-glib/nm-access-point.c
   trunk/libnm-glib/nm-access-point.h
   trunk/src/NetworkManagerAP.c
   trunk/src/NetworkManagerAP.h
   trunk/src/nm-device-802-11-wireless.c
   trunk/test/nm-tool.c

Modified: trunk/introspection/nm-access-point.xml
==============================================================================
--- trunk/introspection/nm-access-point.xml	(original)
+++ trunk/introspection/nm-access-point.xml	Wed Mar 12 17:44:39 2008
@@ -15,7 +15,7 @@
       <tp:docstring>The Service Set Identifier identifying the access point.</tp:docstring>
     </property>
     <property name="Frequency" type="u" access="read">
-      <tp:docstring>The radio channel frequency in use by the access point.</tp:docstring>
+      <tp:docstring>The radio channel frequency in use by the access point, in MHz.</tp:docstring>
     </property>
     <property name="HwAddress" type="s" access="read">
       <tp:docstring>The hardware address of the access point.</tp:docstring>
@@ -24,8 +24,8 @@
     <property name="Mode" type="i" access="read" tp:type="IW_MODE">
       <tp:docstring>Describes the operating mode of the access point.</tp:docstring>
     </property>
-    <property name="Rate" type="u" access="read">
-      <tp:docstring>The bit rate currently achievable to this access point.</tp:docstring>
+    <property name="MaxBitrate" type="u" access="read">
+      <tp:docstring>The maximum bitrate this access point is capable of, in kilobits/second (Kb/s).</tp:docstring>
     </property>
     <property name="Strength" type="y" access="read">
       <tp:docstring>The current signal strength received from this access point.</tp:docstring>

Modified: trunk/introspection/nm-device-802-11-wireless.xml
==============================================================================
--- trunk/introspection/nm-device-802-11-wireless.xml	(original)
+++ trunk/introspection/nm-device-802-11-wireless.xml	Wed Mar 12 17:44:39 2008
@@ -27,7 +27,7 @@
 
     <property name="Bitrate" type="u" access="read">
       <tp:docstring>
-        The bit rate currently used by the wireless device. FIXME: Why is this not called Rate like for AP?
+        The bit rate currently used by the wireless device, in kilobits/second (Kb/s).
       </tp:docstring>
     </property>
     <property name="ActiveAccessPoint" type="o" access="read">

Modified: trunk/libnm-glib/libnm-glib-test.c
==============================================================================
--- trunk/libnm-glib/libnm-glib-test.c	(original)
+++ trunk/libnm-glib/libnm-glib-test.c	Wed Mar 12 17:44:39 2008
@@ -141,7 +141,7 @@
 	g_print ("\tFrequency: %u\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 ("\tRate: %d\n", nm_access_point_get_max_bitrate (ap));
 	g_print ("\tStrength: %d\n", nm_access_point_get_strength (ap));
 }
 

Modified: trunk/libnm-glib/nm-access-point.c
==============================================================================
--- trunk/libnm-glib/nm-access-point.c	(original)
+++ trunk/libnm-glib/nm-access-point.c	Wed Mar 12 17:44:39 2008
@@ -21,7 +21,7 @@
 	guint32 frequency;
 	char *hw_address;
 	int mode;
-	guint32 rate;
+	guint32 max_bitrate;
 	gint8 strength;
 } NMAccessPointPrivate;
 
@@ -34,7 +34,7 @@
 	PROP_FREQUENCY,
 	PROP_HW_ADDRESS,
 	PROP_MODE,
-	PROP_RATE,
+	PROP_MAX_BITRATE,
 	PROP_STRENGTH,
 
 	LAST_PROP
@@ -47,7 +47,7 @@
 #define DBUS_PROP_FREQUENCY "Frequency"
 #define DBUS_PROP_HW_ADDRESS "HwAddress"
 #define DBUS_PROP_MODE "Mode"
-#define DBUS_PROP_RATE "Rate"
+#define DBUS_PROP_MAX_BITRATE "MaxBitrate"
 #define DBUS_PROP_STRENGTH "Strength"
 
 NMAccessPoint *
@@ -253,29 +253,29 @@
 }
 
 static void
-nm_access_point_set_rate (NMAccessPoint *ap, guint32 rate)
+nm_access_point_set_max_bitrate (NMAccessPoint *ap, guint32 bitrate)
 {
 	NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
 
-	priv->rate = rate;
-	g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_RATE);
+	priv->max_bitrate = bitrate;
+	g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_MAX_BITRATE);
 }
 
 guint32
-nm_access_point_get_rate (NMAccessPoint *ap)
+nm_access_point_get_max_bitrate (NMAccessPoint *ap)
 {
 	NMAccessPointPrivate *priv;
 
 	g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
 
 	priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
-	if (!priv->rate) {
-		priv->rate = nm_object_get_uint_property (NM_OBJECT (ap),
-		                                          NM_DBUS_INTERFACE_ACCESS_POINT,
-		                                          DBUS_PROP_RATE);
+	if (!priv->max_bitrate) {
+		priv->max_bitrate = nm_object_get_uint_property (NM_OBJECT (ap),
+		                                              NM_DBUS_INTERFACE_ACCESS_POINT,
+		                                              DBUS_PROP_MAX_BITRATE);
 	}
 
-	return priv->rate;
+	return priv->max_bitrate;
 }
 
 static void
@@ -370,8 +370,8 @@
 	case PROP_MODE:
 		nm_access_point_set_mode (ap, g_value_get_int (value));
 		break;
-	case PROP_RATE:
-		nm_access_point_set_rate (ap, g_value_get_uint (value));
+	case PROP_MAX_BITRATE:
+		nm_access_point_set_max_bitrate (ap, g_value_get_uint (value));
 		break;
 	case PROP_STRENGTH:
 		nm_access_point_set_strength (ap, g_value_get_char (value));
@@ -420,8 +420,8 @@
 	case PROP_MODE:
 		g_value_set_int (value, priv->mode);
 		break;
-	case PROP_RATE:
-		g_value_set_uint (value, priv->rate);
+	case PROP_MAX_BITRATE:
+		g_value_set_uint (value, priv->max_bitrate);
 		break;
 	case PROP_STRENGTH:
 		g_value_set_char (value, priv->strength);
@@ -533,10 +533,10 @@
 					    G_PARAM_READWRITE));
 
 	g_object_class_install_property
-		(object_class, PROP_RATE,
-		 g_param_spec_uint (NM_ACCESS_POINT_RATE,
-						"Rate",
-						"Rate",
+		(object_class, PROP_MAX_BITRATE,
+		 g_param_spec_uint (NM_ACCESS_POINT_MAX_BITRATE,
+						"Max Bitrate",
+						"Max Bitrate",
 						0, G_MAXUINT32, 0,
 						G_PARAM_READWRITE));
 

Modified: trunk/libnm-glib/nm-access-point.h
==============================================================================
--- trunk/libnm-glib/nm-access-point.h	(original)
+++ trunk/libnm-glib/nm-access-point.h	Wed Mar 12 17:44:39 2008
@@ -15,13 +15,13 @@
 #define NM_ACCESS_POINT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACCESS_POINT, NMAccessPointClass))
 
 #define NM_ACCESS_POINT_FLAGS      "flags"
-#define NM_ACCESS_POINT_WPA_FLAGS  "wpa_flags"
-#define NM_ACCESS_POINT_RSN_FLAGS  "rsn_flags"
+#define NM_ACCESS_POINT_WPA_FLAGS  "wpa-flags"
+#define NM_ACCESS_POINT_RSN_FLAGS  "rsn-flags"
 #define NM_ACCESS_POINT_SSID       "ssid"
 #define NM_ACCESS_POINT_FREQUENCY  "frequency"
-#define NM_ACCESS_POINT_HW_ADDRESS "hw_address"
+#define NM_ACCESS_POINT_HW_ADDRESS "hw-address"
 #define NM_ACCESS_POINT_MODE       "mode"
-#define NM_ACCESS_POINT_RATE       "rate"
+#define NM_ACCESS_POINT_MAX_BITRATE   "max-bitrate"
 #define NM_ACCESS_POINT_STRENGTH   "strength"
 
 typedef struct {
@@ -43,7 +43,7 @@
 guint32      nm_access_point_get_frequency    (NMAccessPoint *ap);
 const char * nm_access_point_get_hw_address   (NMAccessPoint *ap);
 int          nm_access_point_get_mode         (NMAccessPoint *ap);
-guint32      nm_access_point_get_rate         (NMAccessPoint *ap);
+guint32      nm_access_point_get_max_bitrate  (NMAccessPoint *ap);
 gint8        nm_access_point_get_strength     (NMAccessPoint *ap);
 
 G_END_DECLS

Modified: trunk/src/NetworkManagerAP.c
==============================================================================
--- trunk/src/NetworkManagerAP.c	(original)
+++ trunk/src/NetworkManagerAP.c	Wed Mar 12 17:44:39 2008
@@ -43,8 +43,8 @@
 	struct ether_addr	address;
 	int				mode;		/* from IW_MODE_* in wireless.h */
 	gint8			strength;
-	guint32			freq;		/* Frequency in GHz * 1000; ie 2.412 == 2412 */
-	guint32			rate;
+	guint32			freq;		/* Frequency in MHz; ie 2412 (== 2.412 GHz) */
+	guint32			max_bitrate;/* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */
 
 	guint32			flags;		/* General flags */
 	guint32			wpa_flags;	/* WPA-related flags */
@@ -88,7 +88,7 @@
 	PROP_FREQUENCY,
 	PROP_HW_ADDRESS,
 	PROP_MODE,
-	PROP_RATE,
+	PROP_MAX_BITRATE,
 	PROP_STRENGTH,
 	LAST_PROP
 };
@@ -145,8 +145,8 @@
 	case PROP_MODE:
 		nm_ap_set_mode (ap, g_value_get_int (value));
 		break;
-	case PROP_RATE:
-		nm_ap_set_rate (ap, g_value_get_uint (value));
+	case PROP_MAX_BITRATE:
+		nm_ap_set_max_bitrate (ap, g_value_get_uint (value));
 		break;
 	case PROP_STRENGTH:
 		nm_ap_set_strength (ap, g_value_get_char (value));
@@ -196,8 +196,8 @@
 	case PROP_MODE:
 		g_value_set_int (value, priv->mode);
 		break;
-	case PROP_RATE:
-		g_value_set_uint (value, priv->rate);
+	case PROP_MAX_BITRATE:
+		g_value_set_uint (value, priv->max_bitrate);
 		break;
 	case PROP_STRENGTH:
 		g_value_set_char (value, priv->strength);
@@ -298,10 +298,10 @@
 						   G_PARAM_READWRITE));
 
 	g_object_class_install_property
-		(object_class, PROP_RATE,
-		 g_param_spec_uint (NM_AP_RATE,
-							"Rate",
-							"Rate",
+		(object_class, PROP_MAX_BITRATE,
+		 g_param_spec_uint (NM_AP_MAX_BITRATE,
+							"Max Bitrate",
+							"Max Bitrate",
 							0, G_MAXUINT16, 0,
 							G_PARAM_READWRITE));
 
@@ -429,7 +429,8 @@
 		if (!strcmp (key, "frequency")) {
 			nm_ap_set_freq (ap, (guint32) int_val);
 		} else if (!strcmp (key, "maxrate")) {
-			nm_ap_set_rate (ap, int_val);
+			/* Supplicant reports as b/s, we use Kb/s internally */
+			nm_ap_set_max_bitrate (ap, int_val / 1000);
 		}
 	} else if (G_VALUE_HOLDS_UINT (variant)) {
 		guint32 val = g_value_get_uint (variant);
@@ -671,7 +672,7 @@
 	         MAC_ARG (priv->address.ether_addr_octet),
 	         priv->strength,
 	         priv->freq,
-	         priv->rate,
+	         priv->max_bitrate,
 	         priv->invalid,
 	         priv->mode,
 	         priv->last_seen);
@@ -968,22 +969,22 @@
 
 
 /*
- * Get/set functions for rate
+ * Get/set functions for max bitrate
  *
  */
-guint32 nm_ap_get_rate (NMAccessPoint *ap)
+guint32 nm_ap_get_max_bitrate (NMAccessPoint *ap)
 {
 	guint32 rate;
 
 	g_return_val_if_fail (NM_IS_AP (ap), 0);
 
-	g_object_get (ap, NM_AP_RATE, &rate, NULL);
+	g_object_get (ap, NM_AP_MAX_BITRATE, &rate, NULL);
 
 	return rate;
 }
 
 void
-nm_ap_set_rate (NMAccessPoint *ap, guint32 rate)
+nm_ap_set_max_bitrate (NMAccessPoint *ap, guint32 bitrate)
 {
 	NMAccessPointPrivate *priv;
 
@@ -991,9 +992,9 @@
 
 	priv = NM_AP_GET_PRIVATE (ap);
 
-	if (priv->rate != rate) {
-		priv->rate = rate;
-		g_object_notify (G_OBJECT (ap), NM_AP_RATE);
+	if (priv->max_bitrate != bitrate) {
+		priv->max_bitrate = bitrate;
+		g_object_notify (G_OBJECT (ap), NM_AP_MAX_BITRATE);
 	}
 }
 

Modified: trunk/src/NetworkManagerAP.h
==============================================================================
--- trunk/src/NetworkManagerAP.h	(original)
+++ trunk/src/NetworkManagerAP.h	Wed Mar 12 17:44:39 2008
@@ -43,7 +43,7 @@
 #define NM_AP_FREQUENCY "frequency"
 #define NM_AP_HW_ADDRESS "hw-address"
 #define NM_AP_MODE "mode"
-#define NM_AP_RATE "rate"
+#define NM_AP_MAX_BITRATE "max-bitrate"
 #define NM_AP_STRENGTH "strength"
 
 typedef struct {
@@ -93,8 +93,8 @@
 guint32			nm_ap_get_freq			(NMAccessPoint *ap);
 void				nm_ap_set_freq			(NMAccessPoint *ap, guint32 freq);
 
-guint32			nm_ap_get_rate			(NMAccessPoint *ap);
-void				nm_ap_set_rate			(NMAccessPoint *ap, guint32 rate);
+guint32			nm_ap_get_max_bitrate			(NMAccessPoint *ap);
+void				nm_ap_set_max_bitrate		(NMAccessPoint *ap, guint32 bitrate);
 
 gboolean			nm_ap_get_invalid		(const NMAccessPoint *ap);
 void				nm_ap_set_invalid		(NMAccessPoint *ap, gboolean invalid);

Modified: trunk/src/nm-device-802-11-wireless.c
==============================================================================
--- trunk/src/nm-device-802-11-wireless.c	(original)
+++ trunk/src/nm-device-802-11-wireless.c	Wed Mar 12 17:44:39 2008
@@ -1319,7 +1319,7 @@
  * nm_device_802_11_wireless_get_bitrate
  *
  * For wireless devices, get the bitrate to broadcast/receive at.
- * Returned value is rate in b/s.
+ * Returned value is rate in Kb/s.
  *
  */
 static guint32
@@ -1342,7 +1342,7 @@
 	err = iw_get_ext (nm_dev_sock_get_fd (sk), iface, SIOCGIWRATE, &wrq);
 	nm_dev_sock_close (sk);
 
-	return ((err >= 0) ? wrq.u.bitrate.value : 0);
+	return ((err >= 0) ? wrq.u.bitrate.value / 1000 : 0);
 }
 
 /*
@@ -1663,7 +1663,7 @@
 		nm_ap_set_last_seen (found_ap, nm_ap_get_last_seen (merge_ap));
 		nm_ap_set_broadcast (found_ap, nm_ap_get_broadcast (merge_ap));
 		nm_ap_set_freq (found_ap, nm_ap_get_freq (merge_ap));
-		nm_ap_set_rate (found_ap, nm_ap_get_rate (merge_ap));
+		nm_ap_set_max_bitrate (found_ap, nm_ap_get_max_bitrate (merge_ap));
 
 		/* If the AP is noticed in a scan, it's automatically no longer
 		 * fake, since it clearly exists somewhere.

Modified: trunk/test/nm-tool.c
==============================================================================
--- trunk/test/nm-tool.c	(original)
+++ trunk/test/nm-tool.c	Wed Mar 12 17:44:39 2008
@@ -125,7 +125,7 @@
 							(nm_access_point_get_mode (ap) == IW_MODE_INFRA) ? "Infra" : "Ad-Hoc",
 							nm_access_point_get_hw_address (ap),
 							nm_access_point_get_frequency (ap),
-							nm_access_point_get_rate (ap) / 1000000,
+							nm_access_point_get_max_bitrate (ap) / 1000,
 							nm_access_point_get_strength (ap));
 
 	if (   !(flags & NM_802_11_AP_FLAGS_PRIVACY)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]