Commit 792b14de authored by Dan Williams's avatar Dan Williams

2007-10-26 Dan Williams <dcbw@redhat.com>

	Patch from Helmut Schaa <hschaa@suse.de> (and more bits from me)

	* src/NetworkManagerAP.c
	  src/NetworkManagerAP.h
	  libnm-glib/nm-access-point.c
	  libnm-glib/nm-access-point.h
		- Make 'rate' property a guint32 to better match with WEXT and
			wpa_supplicant and to allow representation of higher bitrates

	* src/nm-device-802-11-wireless.c
	  introspection/nm-device-802-11-wireless.xml
	  libnm-glib/nm-device-802-11-wireless.c
	  libnm-glib/nm-device-802-11-wireless.h
		- Make 'bitrate' property a guint32 to match AP 'rate' property type

	* src/nm-device-802-3-ethernet.c
	  src/nm-device-802-3-ethernet.h
	  introspection/nm-device-802-3-ethernet.xml
	  libnm-glib/nm-device-802-3-ethernet.c
	  libnm-glib/nm-device-802-3-ethernet.h
		- Make 'speed' property a guint32 to match other speed/rate types
		- Make nm_device_802_3_ethernet_get_speed() static

	* test/nm-tool.c
		- Update for the changes above



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3030 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent fb7e6b46
2007-10-26 Dan Williams <dcbw@redhat.com>
Patch from Helmut Schaa <hschaa@suse.de> (and more bits from me)
* src/NetworkManagerAP.c
src/NetworkManagerAP.h
libnm-glib/nm-access-point.c
libnm-glib/nm-access-point.h
- Make 'rate' property a guint32 to better match with WEXT and
wpa_supplicant and to allow representation of higher bitrates
* src/nm-device-802-11-wireless.c
introspection/nm-device-802-11-wireless.xml
libnm-glib/nm-device-802-11-wireless.c
libnm-glib/nm-device-802-11-wireless.h
- Make 'bitrate' property a guint32 to match AP 'rate' property type
* src/nm-device-802-3-ethernet.c
src/nm-device-802-3-ethernet.h
introspection/nm-device-802-3-ethernet.xml
libnm-glib/nm-device-802-3-ethernet.c
libnm-glib/nm-device-802-3-ethernet.h
- Make 'speed' property a guint32 to match other speed/rate types
- Make nm_device_802_3_ethernet_get_speed() static
* test/nm-tool.c
- Update for the changes above
2007-10-26 Dan Williams <dcbw@redhat.com>
* src/named-manager/nm-named-manager.c
......
......@@ -9,7 +9,7 @@
<property name="HwAddress" type="s" access="read"/>
<property name="Mode" type="i" access="read"/>
<property name="Bitrate" type="i" access="read"/>
<property name="Bitrate" type="u" access="read"/>
<property name="ActiveAccessPoint" type="o" access="read"/>
<property name="WirelessCapabilities" type="u" access="read"/>
......
......@@ -3,6 +3,6 @@
<node name="/">
<interface name="org.freedesktop.NetworkManager.Device.Wired">
<property name="HwAddress" type="s" access="read"/>
<property name="Speed" type="i" access="read"/>
<property name="Speed" type="u" access="read"/>
</interface>
</node>
......@@ -534,7 +534,7 @@ nm_access_point_class_init (NMAccessPointClass *ap_class)
g_param_spec_uint (NM_ACCESS_POINT_RATE,
"Rate",
"Rate",
0, G_MAXUINT16, 0,
0, G_MAXUINT32, 0,
G_PARAM_READWRITE));
g_object_class_install_property
......
......@@ -17,7 +17,7 @@ typedef struct {
char * hw_address;
int mode;
int rate;
guint32 rate;
NMAccessPoint *current_ap;
guint32 wireless_caps;
......@@ -117,7 +117,7 @@ nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device)
}
static void
nm_device_802_11_wireless_set_bitrate (NMDevice80211Wireless *self, int bitrate)
nm_device_802_11_wireless_set_bitrate (NMDevice80211Wireless *self, guint32 bitrate)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
......@@ -127,7 +127,7 @@ nm_device_802_11_wireless_set_bitrate (NMDevice80211Wireless *self, int bitrate)
}
}
int
guint32
nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device)
{
NMDevice80211WirelessPrivate *priv;
......@@ -150,7 +150,7 @@ nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device)
priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (device);
if (!priv->rate) {
priv->rate = nm_object_get_int_property (NM_OBJECT (device),
priv->rate = nm_object_get_uint_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
DBUS_PROP_BITRATE);
}
......@@ -371,7 +371,7 @@ set_property (GObject *object, guint prop_id,
nm_device_802_11_wireless_set_mode (device, g_value_get_int (value));
break;
case PROP_BITRATE:
nm_device_802_11_wireless_set_bitrate (device, g_value_get_int (value));
nm_device_802_11_wireless_set_bitrate (device, g_value_get_uint (value));
break;
case PROP_ACTIVE_ACCESS_POINT:
nm_device_802_11_wireless_set_active_ap (device, (char *) g_value_get_boxed (value));
......@@ -401,7 +401,7 @@ get_property (GObject *object,
g_value_set_int (value, priv->mode);
break;
case PROP_BITRATE:
g_value_set_int (value, priv->rate);
g_value_set_uint (value, priv->rate);
break;
case PROP_ACTIVE_ACCESS_POINT:
g_value_set_boxed (value, priv->current_ap ? nm_object_get_path (NM_OBJECT (priv->current_ap)) : "/");
......@@ -549,10 +549,10 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *device_class)
g_object_class_install_property
(object_class, PROP_BITRATE,
g_param_spec_int (NM_DEVICE_802_11_WIRELESS_BITRATE,
g_param_spec_uint (NM_DEVICE_802_11_WIRELESS_BITRATE,
"Bit Rate",
"Bit Rate",
0, G_MAXINT32, 0,
0, G_MAXUINT32, 0,
G_PARAM_READWRITE));
g_object_class_install_property
......
......@@ -38,7 +38,7 @@ NMDevice80211Wireless *nm_device_802_11_wireless_new (DBusGConnection *c
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);
guint32 nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device);
guint32 nm_device_802_11_wireless_get_capabilities (NMDevice80211Wireless *device);
NMAccessPoint * nm_device_802_11_wireless_get_active_access_point (NMDevice80211Wireless *device);
......
......@@ -84,12 +84,12 @@ nm_device_802_3_ethernet_new (DBusGConnection *connection, const char *path)
NULL);
}
int
guint32
nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device)
{
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), 0);
return nm_object_get_int_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, "Speed");
return nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, "Speed");
}
char *
......
......@@ -24,7 +24,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);
guint32 nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device);
char *nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device);
G_END_DECLS
......
......@@ -43,7 +43,7 @@ typedef struct
int mode; /* from IW_MODE_* in wireless.h */
gint8 strength;
guint32 freq; /* Frequency in GHz * 1000; ie 2.412 == 2412 */
guint16 rate;
guint32 rate;
guint32 flags; /* General flags */
guint32 wpa_flags; /* WPA-related flags */
......@@ -965,9 +965,9 @@ nm_ap_set_freq (NMAccessPoint *ap,
* Get/set functions for rate
*
*/
guint16 nm_ap_get_rate (NMAccessPoint *ap)
guint32 nm_ap_get_rate (NMAccessPoint *ap)
{
guint16 rate;
guint32 rate;
g_return_val_if_fail (NM_IS_AP (ap), 0);
......@@ -977,7 +977,7 @@ guint16 nm_ap_get_rate (NMAccessPoint *ap)
}
void
nm_ap_set_rate (NMAccessPoint *ap, guint16 rate)
nm_ap_set_rate (NMAccessPoint *ap, guint32 rate)
{
NMAccessPointPrivate *priv;
......
......@@ -93,8 +93,8 @@ void nm_ap_set_strength (NMAccessPoint *ap, gint8 strength);
guint32 nm_ap_get_freq (NMAccessPoint *ap);
void nm_ap_set_freq (NMAccessPoint *ap, guint32 freq);
guint16 nm_ap_get_rate (NMAccessPoint *ap);
void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate);
guint32 nm_ap_get_rate (NMAccessPoint *ap);
void nm_ap_set_rate (NMAccessPoint *ap, guint32 rate);
gboolean nm_ap_get_invalid (const NMAccessPoint *ap);
void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid);
......
......@@ -124,7 +124,7 @@ struct _NMDevice80211WirelessPrivate
GSList * ap_list;
NMAccessPoint * current_ap;
int rate;
guint32 rate;
gboolean scanning;
GTimeVal scheduled_scan_time;
......@@ -185,7 +185,7 @@ static void cleanup_supplicant_interface (NMDevice80211Wireless * self);
static void device_cleanup (NMDevice80211Wireless *self);
static int nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *self);
static guint32 nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *self);
static void
......@@ -562,7 +562,7 @@ periodic_update (NMDevice80211Wireless *self, gboolean honor_scan)
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
NMDeviceState state;
NMAccessPoint *new_ap;
int new_rate;
guint32 new_rate;
/* BSSID and signal strength have meaningful values only if the device
is activated and not scanning */
......@@ -1298,10 +1298,10 @@ nm_device_802_11_wireless_set_ssid (NMDevice80211Wireless *self,
* nm_device_802_11_wireless_get_bitrate
*
* For wireless devices, get the bitrate to broadcast/receive at.
* Returned value is rate in Mb/s.
* Returned value is rate in b/s.
*
*/
static int
static guint32
nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *self)
{
NMSock *sk;
......@@ -1318,7 +1318,7 @@ nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *self)
nm_dev_sock_close (sk);
}
return ((err >= 0) ? wrq.u.bitrate.value / 1000000 : 0);
return ((err >= 0) ? wrq.u.bitrate.value : 0);
}
/*
......@@ -2881,7 +2881,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_int (value, nm_device_802_11_wireless_get_mode (device));
break;
case PROP_BITRATE:
g_value_set_int (value, priv->rate);
g_value_set_uint (value, priv->rate);
break;
case PROP_CAPABILITIES:
g_value_set_uint (value, priv->capabilities);
......@@ -2949,10 +2949,10 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_BITRATE,
g_param_spec_int (NM_DEVICE_802_11_WIRELESS_BITRATE,
g_param_spec_uint (NM_DEVICE_802_11_WIRELESS_BITRATE,
"Bitrate",
"Bitrate",
0, G_MAXINT32, 0,
0, G_MAXUINT32, 0,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_ACTIVE_ACCESS_POINT,
......
......@@ -61,6 +61,8 @@ enum {
LAST_PROP
};
static guint32 nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self);
static gboolean supports_mii_carrier_detect (NMDevice8023Ethernet *dev);
static gboolean supports_ethtool_carrier_detect (NMDevice8023Ethernet *dev);
......@@ -435,7 +437,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, &hw_addr_buf[0]);
break;
case PROP_SPEED:
g_value_set_int (value, nm_device_802_3_ethernet_get_speed (device));
g_value_set_uint (value, nm_device_802_3_ethernet_get_speed (device));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -479,10 +481,10 @@ nm_device_802_3_ethernet_class_init (NMDevice8023EthernetClass *klass)
g_object_class_install_property
(object_class, PROP_SPEED,
g_param_spec_int (NM_DEVICE_802_3_ETHERNET_SPEED,
g_param_spec_uint (NM_DEVICE_802_3_ETHERNET_SPEED,
"Speed",
"Speed",
0, G_MAXINT32, 0,
0, G_MAXUINT32, 0,
G_PARAM_READABLE));
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
......@@ -551,14 +553,15 @@ out:
}
int
/* Returns speed in Mb/s */
static guint32
nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self)
{
NMSock * sk;
struct ifreq ifr;
struct ethtool_cmd edata;
const char * iface;
int speed = 0;
guint32 speed = 0;
g_return_val_if_fail (self != NULL, FALSE);
......@@ -575,7 +578,7 @@ nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self)
ifr.ifr_data = (char *) &edata;
if (ioctl (nm_dev_sock_get_fd (sk), SIOCETHTOOL, &ifr) == -1)
goto out;
speed = edata.speed;
speed = edata.speed > 0 ? (guint32) edata.speed : 0;
out:
nm_dev_sock_close (sk);
......
......@@ -59,8 +59,6 @@ NMDevice8023Ethernet *nm_device_802_3_ethernet_new (int index,
void nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *dev,
struct ether_addr *addr);
int nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self);
G_END_DECLS
#endif /* NM_DEVICE_802_3_ETHERNET_H */
......@@ -125,7 +125,7 @@ detail_access_point (gpointer data, gpointer user_data)
(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) / 1024,
nm_access_point_get_rate (ap) / 1000000,
nm_access_point_get_strength (ap));
if ( !(flags & NM_802_11_AP_FLAGS_PRIVACY)
......@@ -175,8 +175,8 @@ detail_device (gpointer data, gpointer user_data)
NMDevice *device = NM_DEVICE (data);
char *tmp;
NMDeviceState state;
int caps;
int speed;
guint32 caps;
guint32 speed;
GArray *array;
state = nm_device_get_state (device);
......@@ -225,15 +225,19 @@ detail_device (gpointer data, gpointer user_data)
print_string (" Carrier Detect", "yes");
speed = 0;
if (NM_IS_DEVICE_802_3_ETHERNET (device))
if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
/* Speed in Mb/s */
speed = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (device));
else if (NM_IS_DEVICE_802_11_WIRELESS (device))
} else if (NM_IS_DEVICE_802_11_WIRELESS (device)) {
/* Speed in b/s */
speed = nm_device_802_11_wireless_get_bitrate (NM_DEVICE_802_11_WIRELESS (device));
speed /= 1000000;
}
if (speed) {
char *speed_string;
speed_string = g_strdup_printf ("%d Mb/s", speed);
speed_string = g_strdup_printf ("%u Mb/s", speed);
print_string (" Speed", speed_string);
g_free (speed_string);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment