wimax: make WiMAX mostly work

Heavily modify Inaky's Intel WiMAX SDK glue (originally from connman)
to be more generic and more thread-safe, and suitable for use with
NetworkManager instead of rolling our own client code.  Rewrite the
NMDeviceWimax code to mostly work.

Still to be done: actual connection logic, DHCP handling, spawning
wimaxd if it's not started yet
This commit is contained in:
Dan Williams 2011-01-03 23:55:38 -06:00
parent 7ce5053a9e
commit 9e80c1e85d
24 changed files with 2835 additions and 1464 deletions

View file

@ -38,7 +38,7 @@
#define NM_DBUS_INTERFACE_SERIAL_DEVICE NM_DBUS_INTERFACE_DEVICE ".Serial"
#define NM_DBUS_INTERFACE_GSM_DEVICE NM_DBUS_INTERFACE_DEVICE ".Gsm"
#define NM_DBUS_INTERFACE_CDMA_DEVICE NM_DBUS_INTERFACE_DEVICE ".Cdma"
#define NM_DBUS_INTERFACE_WIMAX_DEVICE NM_DBUS_INTERFACE_DEVICE ".WiMax"
#define NM_DBUS_INTERFACE_DEVICE_WIMAX NM_DBUS_INTERFACE_DEVICE ".WiMax"
#define NM_DBUS_INTERFACE_WIMAX_NSP NM_DBUS_INTERFACE ".WiMax.Nsp"
#define NM_DBUS_PATH_WIMAX_NSP NM_DBUS_PATH "/Nsp"
#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"

View file

@ -11,6 +11,7 @@ EXTRA_DIST = \
nm-device-cdma.xml \
nm-device-gsm.xml \
nm-device-serial.xml \
nm-device-wimax.xml \
nm-device.xml \
nm-ip4-config.xml \
nm-ip6-config.xml \
@ -25,6 +26,5 @@ EXTRA_DIST = \
nm-active-connection.xml \
nm-dhcp4-config.xml \
nm-dhcp6-config.xml \
nm-wimax-device.xml \
nm-wimax-nsp.xml

View file

@ -35,6 +35,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
<xi:include href="nm-device-serial.xml"/>
<xi:include href="nm-device-bt.xml"/>
<xi:include href="nm-device-olpc-mesh.xml"/>
<xi:include href="nm-device-wimax.xml"/>
<xi:include href="nm-wimax-nsp.xml"/>
<xi:include href="nm-ip4-config.xml"/>
<xi:include href="nm-ip6-config.xml"/>
<xi:include href="nm-dhcp4-config.xml"/>
@ -44,8 +46,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
<xi:include href="nm-active-connection.xml"/>
<xi:include href="nm-vpn-connection.xml"/>
<xi:include href="nm-vpn-plugin.xml"/>
<xi:include href="nm-wimax-device.xml"/>
<xi:include href="nm-wimax-nsp.xml"/>
<xi:include href="errors.xml"/>
<xi:include href="vpn-errors.xml"/>

View file

@ -10,6 +10,7 @@ BUILT_SOURCES = \
nm-device-ethernet-bindings.h \
nm-device-wifi-bindings.h \
nm-device-bt-bindings.h \
nm-device-wimax-bindings.h \
nm-exported-connection-glue.h \
nm-exported-connection-bindings.h \
nm-settings-glue.h \
@ -21,8 +22,7 @@ BUILT_SOURCES = \
nm-ip4-config-bindings.h \
nm-dhcp4-config-bindings.h \
nm-ip6-config-bindings.h \
nm-dhcp6-config-bindings.h \
nm-wimax-device-bindings.h
nm-dhcp6-config-bindings.h
#####################################################
# Deprecated original libnm_glib bits
@ -86,7 +86,7 @@ libnminclude_HEADERS = \
nm-settings-connection-interface.h \
nm-exported-connection.h \
nm-settings-service.h \
nm-wimax-device.h \
nm-device-wimax.h \
nm-wimax-nsp.h
libnm_glib_la_SOURCES = \
@ -123,7 +123,7 @@ libnm_glib_la_SOURCES = \
nm-settings-connection-interface.c \
nm-exported-connection.c \
nm-settings-service.c \
nm-wimax-device.c \
nm-device-wimax.c \
nm-wimax-nsp.c
libnm_glib_la_LIBADD = \
@ -205,8 +205,8 @@ nm-ip6-config-bindings.h: $(top_srcdir)/introspection/nm-ip6-config.xml
nm-dhcp6-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp6-config.xml
$(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=$@ $<
nm-device-wimax-bindings.h: $(top_srcdir)/introspection/nm-device-wimax.xml
dbus-binding-tool --prefix=nm_device_wimax --mode=glib-client --output=$@ $<
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnm-glib.pc libnm-glib-vpn.pc

View file

@ -167,12 +167,12 @@ global:
nm_vpn_connection_get_type;
nm_vpn_connection_get_vpn_state;
nm_vpn_connection_new;
nm_wimax_device_get_hw_address;
nm_wimax_device_get_active_nsp;
nm_wimax_device_get_nsp_by_path;
nm_wimax_device_get_nsps;
nm_wimax_device_get_type;
nm_wimax_device_new;
nm_device_wimax_get_hw_address;
nm_device_wimax_get_active_nsp;
nm_device_wimax_get_nsp_by_path;
nm_device_wimax_get_nsps;
nm_device_wimax_get_type;
nm_device_wimax_new;
nm_wimax_nsp_get_name;
nm_wimax_nsp_get_network_type;
nm_wimax_nsp_get_signal_quality;

View file

@ -17,26 +17,27 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2011 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
*/
#include <string.h>
#include "nm-wimax-device.h"
#include "nm-device-wimax.h"
#include "nm-object-private.h"
#include "nm-object-cache.h"
#include "nm-dbus-glib-types.h"
#include "nm-types-private.h"
#include "nm-wimax-device-bindings.h"
#include "nm-device-wimax-bindings.h"
G_DEFINE_TYPE (NMWimaxDevice, nm_wimax_device, NM_TYPE_DEVICE)
G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE)
#define NM_WIMAX_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_WIMAX_DEVICE, NMWimaxDevicePrivate))
#define NM_DEVICE_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxPrivate))
static gboolean demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field);
void _nm_wimax_device_set_wireless_enabled (NMWimaxDevice *wimax, gboolean enabled);
void _nm_device_wimax_set_wireless_enabled (NMDeviceWimax *wimax, gboolean enabled);
typedef struct {
gboolean disposed;
@ -46,7 +47,7 @@ typedef struct {
NMWimaxNsp *active_nsp;
gboolean null_active_nsp;
GPtrArray *nsps;
} NMWimaxDevicePrivate;
} NMDeviceWimaxPrivate;
enum {
PROP_0,
@ -69,46 +70,46 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
/**
* nm_wimax_device_new:
* nm_device_wimax_new:
* @connection: the #DBusGConnection
* @path: the DBus object path of the wimax
*
* Creates a new #NMWimaxDevice.
* Creates a new #NMDeviceWimax.
*
* Returns: a new wimax
**/
GObject *
nm_wimax_device_new (DBusGConnection *connection, const char *path)
nm_device_wimax_new (DBusGConnection *connection, const char *path)
{
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
return g_object_new (NM_TYPE_WIMAX_DEVICE,
return g_object_new (NM_TYPE_DEVICE_WIMAX,
NM_OBJECT_DBUS_CONNECTION, connection,
NM_OBJECT_DBUS_PATH, path,
NULL);
}
/**
* nm_wimax_device_get_hw_address:
* @device: a #NMWimaxDevice
* nm_device_wimax_get_hw_address:
* @device: a #NMDeviceWimax
*
* Gets the hardware (MAC) address of the #NMWimaxDevice
* Gets the hardware (MAC) address of the #NMDeviceWimax
*
* Returns: the hardware address. This is the internal string used by the
* device, and must not be modified.
**/
const char *
nm_wimax_device_get_hw_address (NMWimaxDevice *wimax)
nm_device_wimax_get_hw_address (NMDeviceWimax *wimax)
{
NMWimaxDevicePrivate *priv;
NMDeviceWimaxPrivate *priv;
g_return_val_if_fail (NM_IS_WIMAX_DEVICE (wimax), NULL);
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
priv = NM_WIMAX_DEVICE_GET_PRIVATE (wimax);
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
if (!priv->hw_address) {
priv->hw_address = _nm_object_get_string_property (NM_OBJECT (wimax),
NM_DBUS_INTERFACE_WIMAX_DEVICE,
NM_DBUS_INTERFACE_DEVICE_WIMAX,
DBUS_PROP_HW_ADDRESS);
}
@ -116,22 +117,22 @@ nm_wimax_device_get_hw_address (NMWimaxDevice *wimax)
}
/**
* nm_wimax_device_get_active_nsp:
* @wimax: a #NMWimaxDevice
* nm_device_wimax_get_active_nsp:
* @wimax: a #NMDeviceWimax
*
* Gets the active #NMWimaxNsp.
*
* Returns: the access point or %NULL if none is active
**/
NMWimaxNsp *
nm_wimax_device_get_active_nsp (NMWimaxDevice *wimax)
nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax)
{
NMWimaxDevicePrivate *priv;
NMDeviceWimaxPrivate *priv;
NMDeviceState state;
char *path;
GValue value = { 0, };
g_return_val_if_fail (NM_IS_WIMAX_DEVICE (wimax), NULL);
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
state = nm_device_get_state (NM_DEVICE (wimax));
switch (state) {
@ -146,14 +147,14 @@ nm_wimax_device_get_active_nsp (NMWimaxDevice *wimax)
break;
}
priv = NM_WIMAX_DEVICE_GET_PRIVATE (wimax);
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
if (priv->active_nsp)
return priv->active_nsp;
if (priv->null_active_nsp)
return NULL;
path = _nm_object_get_object_path_property (NM_OBJECT (wimax),
NM_DBUS_INTERFACE_WIMAX_DEVICE,
NM_DBUS_INTERFACE_DEVICE_WIMAX,
DBUS_PROP_ACTIVE_NSP);
if (path) {
g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
@ -166,26 +167,26 @@ nm_wimax_device_get_active_nsp (NMWimaxDevice *wimax)
}
/**
* nm_wimax_device_get_nsps:
* @wimax: a #NMWimaxDevice
* nm_device_wimax_get_nsps:
* @wimax: a #NMDeviceWimax
*
* Gets all the scanned NSPs of the #NMWimaxDevice.
* Gets all the scanned NSPs of the #NMDeviceWimax.
*
* Returns: a #GPtrArray containing all the scanned #NMWimaxNsp<!-- -->s.
* The returned array is owned by the client and should not be modified.
**/
const GPtrArray *
nm_wimax_device_get_nsps (NMWimaxDevice *wimax)
nm_device_wimax_get_nsps (NMDeviceWimax *wimax)
{
NMWimaxDevicePrivate *priv;
NMDeviceWimaxPrivate *priv;
DBusGConnection *connection;
GValue value = { 0, };
GError *error = NULL;
GPtrArray *temp;
g_return_val_if_fail (NM_IS_WIMAX_DEVICE (wimax), NULL);
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
priv = NM_WIMAX_DEVICE_GET_PRIVATE (wimax);
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
if (priv->nsps)
return handle_ptr_array_return (priv->nsps);
@ -205,8 +206,8 @@ nm_wimax_device_get_nsps (NMWimaxDevice *wimax)
}
/**
* nm_wimax_device_get_nsp_by_path:
* @wimax: a #NMWimaxDevice
* nm_device_wimax_get_nsp_by_path:
* @wimax: a #NMDeviceWimax
* @path: the object path of the NSP
*
* Gets a #NMWimaxNsp by path.
@ -214,17 +215,17 @@ nm_wimax_device_get_nsps (NMWimaxDevice *wimax)
* Returns: the access point or %NULL if none is found.
**/
NMWimaxNsp *
nm_wimax_device_get_nsp_by_path (NMWimaxDevice *wimax,
nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax,
const char *path)
{
const GPtrArray *nsps;
int i;
NMWimaxNsp *nsp = NULL;
g_return_val_if_fail (NM_IS_WIMAX_DEVICE (wimax), NULL);
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
g_return_val_if_fail (path != NULL, NULL);
nsps = nm_wimax_device_get_nsps (wimax);
nsps = nm_device_wimax_get_nsps (wimax);
if (!nsps)
return NULL;
@ -242,17 +243,17 @@ nm_wimax_device_get_nsp_by_path (NMWimaxDevice *wimax,
static void
nsp_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
{
NMWimaxDevice *self = NM_WIMAX_DEVICE (user_data);
NMWimaxDevicePrivate *priv;
NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data);
NMDeviceWimaxPrivate *priv;
GObject *nsp;
g_return_if_fail (self != NULL);
nsp = G_OBJECT (nm_wimax_device_get_nsp_by_path (self, path));
nsp = G_OBJECT (nm_device_wimax_get_nsp_by_path (self, path));
if (!nsp) {
DBusGConnection *connection = nm_object_get_connection (NM_OBJECT (self));
priv = NM_WIMAX_DEVICE_GET_PRIVATE (self);
priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
nsp = G_OBJECT (_nm_object_cache_get (path));
if (nsp) {
g_ptr_array_add (priv->nsps, g_object_ref (nsp));
@ -270,20 +271,20 @@ nsp_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
static void
nsp_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
{
NMWimaxDevice *self = NM_WIMAX_DEVICE (user_data);
NMWimaxDevicePrivate *priv = NM_WIMAX_DEVICE_GET_PRIVATE (self);
NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data);
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
NMWimaxNsp *nsp;
g_return_if_fail (self != NULL);
nsp = nm_wimax_device_get_nsp_by_path (self, path);
nsp = nm_device_wimax_get_nsp_by_path (self, path);
if (nsp) {
if (nsp == priv->active_nsp) {
g_object_unref (priv->active_nsp);
priv->active_nsp = NULL;
priv->null_active_nsp = FALSE;
_nm_object_queue_notify (NM_OBJECT (self), NM_WIMAX_DEVICE_ACTIVE_NSP);
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_ACTIVE_NSP);
}
g_signal_emit (self, signals[NSP_REMOVED], 0, nsp);
@ -293,13 +294,13 @@ nsp_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
}
static void
clean_up_nsps (NMWimaxDevice *self, gboolean notify)
clean_up_nsps (NMDeviceWimax *self, gboolean notify)
{
NMWimaxDevicePrivate *priv;
NMDeviceWimaxPrivate *priv;
g_return_if_fail (NM_IS_WIMAX_DEVICE (self));
g_return_if_fail (NM_IS_DEVICE_WIMAX (self));
priv = NM_WIMAX_DEVICE_GET_PRIVATE (self);
priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
if (priv->active_nsp) {
g_object_unref (priv->active_nsp);
@ -323,7 +324,7 @@ clean_up_nsps (NMWimaxDevice *self, gboolean notify)
/**************************************************************/
static void
nm_wimax_device_init (NMWimaxDevice *wimax)
nm_device_wimax_init (NMDeviceWimax *wimax)
{
}
@ -333,14 +334,14 @@ get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
NMWimaxDevice *self = NM_WIMAX_DEVICE (object);
NMDeviceWimax *self = NM_DEVICE_WIMAX (object);
switch (prop_id) {
case PROP_HW_ADDRESS:
g_value_set_string (value, nm_wimax_device_get_hw_address (self));
g_value_set_string (value, nm_device_wimax_get_hw_address (self));
break;
case PROP_ACTIVE_NSP:
g_value_set_object (value, nm_wimax_device_get_active_nsp (self));
g_value_set_object (value, nm_device_wimax_get_active_nsp (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -351,8 +352,8 @@ get_property (GObject *object,
static void
state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
{
NMWimaxDevice *self = NM_WIMAX_DEVICE (device);
NMWimaxDevicePrivate *priv = NM_WIMAX_DEVICE_GET_PRIVATE (self);
NMDeviceWimax *self = NM_DEVICE_WIMAX (device);
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
switch (nm_device_get_state (device)) {
case NM_DEVICE_STATE_UNKNOWN:
@ -365,7 +366,7 @@ state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
priv->active_nsp = NULL;
priv->null_active_nsp = FALSE;
}
_nm_object_queue_notify (NM_OBJECT (device), NM_WIMAX_DEVICE_ACTIVE_NSP);
_nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIMAX_ACTIVE_NSP);
break;
default:
break;
@ -375,7 +376,7 @@ state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
static gboolean
demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
{
NMWimaxDevicePrivate *priv = NM_WIMAX_DEVICE_GET_PRIVATE (object);
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
const char *path;
NMWimaxNsp *nsp = NULL;
DBusGConnection *connection;
@ -408,17 +409,17 @@ demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
if (nsp)
priv->active_nsp = nsp;
_nm_object_queue_notify (object, NM_WIMAX_DEVICE_ACTIVE_NSP);
_nm_object_queue_notify (object, NM_DEVICE_WIMAX_ACTIVE_NSP);
return TRUE;
}
static void
register_for_property_changed (NMWimaxDevice *wimax)
register_for_property_changed (NMDeviceWimax *wimax)
{
NMWimaxDevicePrivate *priv = NM_WIMAX_DEVICE_GET_PRIVATE (wimax);
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
const NMPropertiesChangedInfo property_changed_info[] = {
{ NM_WIMAX_DEVICE_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address },
{ NM_WIMAX_DEVICE_ACTIVE_NSP, demarshal_active_nsp, &priv->active_nsp },
{ NM_DEVICE_WIMAX_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address },
{ NM_DEVICE_WIMAX_ACTIVE_NSP, demarshal_active_nsp, &priv->active_nsp },
{ NULL },
};
@ -433,20 +434,20 @@ constructor (GType type,
GObjectConstructParam *construct_params)
{
GObject *object;
NMWimaxDevicePrivate *priv;
NMDeviceWimaxPrivate *priv;
object = G_OBJECT_CLASS (nm_wimax_device_parent_class)->constructor (type,
object = G_OBJECT_CLASS (nm_device_wimax_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
priv = NM_WIMAX_DEVICE_GET_PRIVATE (object);
priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
NM_DBUS_SERVICE,
nm_object_get_path (NM_OBJECT (object)),
NM_DBUS_INTERFACE_WIMAX_DEVICE);
NM_DBUS_INTERFACE_DEVICE_WIMAX);
dbus_g_proxy_add_signal (priv->proxy, "NspAdded",
DBUS_TYPE_G_OBJECT_PATH,
@ -462,7 +463,7 @@ constructor (GType type,
G_CALLBACK (nsp_removed_proxy),
object, NULL);
register_for_property_changed (NM_WIMAX_DEVICE (object));
register_for_property_changed (NM_DEVICE_WIMAX (object));
g_signal_connect (object,
"notify::" NM_DEVICE_STATE,
@ -475,38 +476,38 @@ constructor (GType type,
static void
dispose (GObject *object)
{
NMWimaxDevicePrivate *priv = NM_WIMAX_DEVICE_GET_PRIVATE (object);
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
if (priv->disposed) {
G_OBJECT_CLASS (nm_wimax_device_parent_class)->dispose (object);
G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object);
return;
}
priv->disposed = TRUE;
clean_up_nsps (NM_WIMAX_DEVICE (object), FALSE);
clean_up_nsps (NM_DEVICE_WIMAX (object), FALSE);
g_object_unref (priv->proxy);
G_OBJECT_CLASS (nm_wimax_device_parent_class)->dispose (object);
G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
NMWimaxDevicePrivate *priv = NM_WIMAX_DEVICE_GET_PRIVATE (object);
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
if (priv->hw_address)
g_free (priv->hw_address);
G_OBJECT_CLASS (nm_wimax_device_parent_class)->finalize (object);
G_OBJECT_CLASS (nm_device_wimax_parent_class)->finalize (object);
}
static void
nm_wimax_device_class_init (NMWimaxDeviceClass *wimax_class)
nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (wimax_class);
g_type_class_add_private (wimax_class, sizeof (NMWimaxDevicePrivate));
g_type_class_add_private (wimax_class, sizeof (NMDeviceWimaxPrivate));
/* virtual methods */
object_class->constructor = constructor;
@ -517,13 +518,13 @@ nm_wimax_device_class_init (NMWimaxDeviceClass *wimax_class)
/* properties */
/**
* NMWimaxDevice:active-nsp:
* NMDeviceWimax:active-nsp:
*
* The active #NMWimaxNsp of the device.
**/
g_object_class_install_property
(object_class, PROP_ACTIVE_NSP,
g_param_spec_object (NM_WIMAX_DEVICE_ACTIVE_NSP,
g_param_spec_object (NM_DEVICE_WIMAX_ACTIVE_NSP,
"Active NSP",
"Active NSP",
NM_TYPE_WIMAX_NSP,
@ -532,7 +533,7 @@ nm_wimax_device_class_init (NMWimaxDeviceClass *wimax_class)
/* signals */
/**
* NMWimaxDevice::nsp-added:
* NMDeviceWimax::nsp-added:
* @self: the wimax device that received the signal
* @nsp: the new NSP
*
@ -542,14 +543,14 @@ nm_wimax_device_class_init (NMWimaxDeviceClass *wimax_class)
g_signal_new ("nsp-added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMWimaxDeviceClass, nsp_added),
G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_added),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
/**
* NMWimaxDevice::nsp-removed:
* NMDeviceWimax::nsp-removed:
* @self: the wimax device that received the signal
* @nsp: the removed NSP
*
@ -559,7 +560,7 @@ nm_wimax_device_class_init (NMWimaxDeviceClass *wimax_class)
g_signal_new ("nsp-removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMWimaxDeviceClass, nsp_removed),
G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_removed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,

View file

@ -0,0 +1,68 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2011 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
*/
#ifndef NM_DEVICE_WIMAX_H
#define NM_DEVICE_WIMAX_H
#include "nm-device.h"
#include "nm-wimax-nsp.h"
G_BEGIN_DECLS
#define NM_TYPE_DEVICE_WIMAX (nm_device_wimax_get_type ())
#define NM_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimax))
#define NM_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
#define NM_IS_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WIMAX))
#define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DEVICE_WIMAX))
#define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
typedef struct {
NMDevice parent;
} NMDeviceWimax;
typedef struct {
NMDeviceClass parent;
/* Signals */
void (*nsp_added) (NMDeviceWimax *self, NMWimaxNsp *nsp);
void (*nsp_removed) (NMDeviceWimax *self, NMWimaxNsp *nsp);
} NMDeviceWimaxClass;
GType nm_device_wimax_get_type (void);
GObject *nm_device_wimax_new (DBusGConnection *connection,
const char *path);
const char *nm_device_wimax_get_hw_address (NMDeviceWimax *wimax);
NMWimaxNsp *nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax);
NMWimaxNsp *nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax,
const char *path);
const GPtrArray *nm_device_wimax_get_nsps (NMDeviceWimax *wimax);
G_END_DECLS
#endif /* NM_DEVICE_WIMAX_H */

View file

@ -32,7 +32,7 @@
#include "nm-gsm-device.h"
#include "nm-cdma-device.h"
#include "nm-device-bt.h"
#include "nm-wimax-device.h"
#include "nm-device-wimax.h"
#include "nm-device.h"
#include "nm-device-private.h"
#include "nm-object-private.h"
@ -726,7 +726,7 @@ nm_device_new (DBusGConnection *connection, const char *path)
dtype = NM_TYPE_DEVICE_BT;
break;
case NM_DEVICE_TYPE_WIMAX:
dtype = NM_TYPE_WIMAX_DEVICE;
dtype = NM_TYPE_DEVICE_WIMAX;
break;
default:
g_warning ("Unknown device type %d", g_value_get_uint (&value));

View file

@ -1,67 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2009 Novell, Inc.
*/
#ifndef NM_WIMAX_DEVICE_H
#define NM_WIMAX_DEVICE_H
#include "nm-device.h"
#include "nm-wimax-nsp.h"
G_BEGIN_DECLS
#define NM_TYPE_WIMAX_DEVICE (nm_wimax_device_get_type ())
#define NM_WIMAX_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIMAX_DEVICE, NMWimaxDevice))
#define NM_WIMAX_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIMAX_DEVICE, NMWimaxDeviceClass))
#define NM_IS_WIMAX_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIMAX_DEVICE))
#define NM_IS_WIMAX_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_WIMAX_DEVICE))
#define NM_WIMAX_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIMAX_DEVICE, NMWimaxDeviceClass))
#define NM_WIMAX_DEVICE_HW_ADDRESS "hw-address"
#define NM_WIMAX_DEVICE_ACTIVE_NSP "active-nsp"
typedef struct {
NMDevice parent;
} NMWimaxDevice;
typedef struct {
NMDeviceClass parent;
/* Signals */
void (*nsp_added) (NMWimaxDevice *self, NMWimaxNsp *nsp);
void (*nsp_removed) (NMWimaxDevice *self, NMWimaxNsp *nsp);
} NMWimaxDeviceClass;
GType nm_wimax_device_get_type (void);
GObject *nm_wimax_device_new (DBusGConnection *connection,
const char *path);
const char *nm_wimax_device_get_hw_address (NMWimaxDevice *wimax);
NMWimaxNsp *nm_wimax_device_get_active_nsp (NMWimaxDevice *wimax);
NMWimaxNsp *nm_wimax_device_get_nsp_by_path (NMWimaxDevice *wimax,
const char *path);
const GPtrArray *nm_wimax_device_get_nsps (NMWimaxDevice *wimax);
G_END_DECLS
#endif /* NM_WIMAX_DEVICE_H */

View file

@ -38,7 +38,7 @@
#include "nm-device-ethernet.h"
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
#include "nm-wimax-device.h"
#include "nm-device-wimax.h"
#include "nm-device-cdma.h"
#include "nm-device-gsm.h"
#include "nm-system.h"
@ -2117,7 +2117,7 @@ add_device (NMManager *self, NMDevice *device)
nm_device_interface_set_enabled (NM_DEVICE_INTERFACE (device),
priv->radio_states[RFKILL_TYPE_WWAN].enabled);
*/
} else if (NM_IS_WIMAX_DEVICE (device)) {
} else if (NM_IS_DEVICE_WIMAX (device)) {
nm_manager_rfkill_update (self, RFKILL_TYPE_WIMAX);
enabled = radio_enabled_for_type (self, RFKILL_TYPE_WIMAX);
nm_device_interface_set_enabled (NM_DEVICE_INTERFACE (device), enabled);

View file

@ -38,7 +38,7 @@
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
#include "nm-device-ethernet.h"
#include "nm-wimax-manager.h"
#include "nm-device-wimax.h"
typedef struct {
GUdevClient *client;
@ -339,6 +339,9 @@ is_olpc_mesh (GUdevDevice *device)
static gboolean
is_wimax (const char *driver)
{
/* FIXME: check 'DEVTYPE' instead; but since we only support Intel
* WiMAX devices for now this is appropriate.
*/
return g_strcmp0 (driver, "i2400m_usb") == 0;
}
@ -395,7 +398,7 @@ device_creator (NMUdevManager *manager,
else if (is_wireless (udev_device))
device = (GObject *) nm_device_wifi_new (path, ifname, driver);
else if (is_wimax (driver))
device = (GObject *) nm_wimax_manager_create_device (path, ifname, driver);
device = (GObject *) nm_device_wimax_new (path, ifname, driver);
else
device = (GObject *) nm_device_ethernet_new (path, ifname, driver);

View file

@ -1,5 +1,6 @@
INCLUDES = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_builddir}/marshallers
@ -7,15 +8,15 @@ INCLUDES = \
noinst_LTLIBRARIES = libwimax.la
libwimax_la_SOURCES = \
nm-wimax-device.c \
nm-wimax-device.h \
nm-wimax-manager.c \
nm-wimax-manager.h \
nm-device-wimax.c \
nm-device-wimax.h \
nm-wimax-nsp.c \
nm-wimax-nsp.h \
nm-wimax-types.h \
nm-wimax-util.c \
nm-wimax-util.h
nm-wimax-util.h \
iwmxsdk.c \
iwmxsdk.h
libwimax_la_CPPFLAGS = \
$(DBUS_CFLAGS) \
@ -29,11 +30,11 @@ libwimax_la_LIBADD = \
nm-wimax-nsp-glue.h: $(top_srcdir)/introspection/nm-wimax-nsp.xml
dbus-binding-tool --prefix=nm_wimax_nsp --mode=glib-server --output=$@ $<
nm-wimax-device-glue.h: $(top_srcdir)/introspection/nm-wimax-device.xml
dbus-binding-tool --prefix=nm_wimax_device --mode=glib-server --output=$@ $<
nm-device-wimax-glue.h: $(top_srcdir)/introspection/nm-device-wimax.xml
dbus-binding-tool --prefix=nm_device_wimax --mode=glib-server --output=$@ $<
BUILT_SOURCES = \
nm-wimax-nsp-glue.h \
nm-wimax-device-glue.h
nm-device-wimax-glue.h
CLEANFILES = $(BUILT_SOURCES)

1286
src/wimax/iwmxsdk.c Normal file

File diff suppressed because it is too large Load diff

98
src/wimax/iwmxsdk.h Normal file
View file

@ -0,0 +1,98 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
* Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef IWMXSDK_H
#define IWMXSDK_H
#include <wimax/WiMaxType.h>
#include <wimax/WiMaxTypesEx.h>
struct wmxsdk;
typedef void (*WimaxNewWmxsdkFunc) (struct wmxsdk *wmxsdk, void *user_data);
typedef void (*WimaxStateChangeFunc) (struct wmxsdk *wmxsdk,
WIMAX_API_DEVICE_STATUS new_status,
WIMAX_API_DEVICE_STATUS old_status,
WIMAX_API_STATUS_REASON reason,
void *user_data);
typedef void (*WimaxConnectResultFunc) (struct wmxsdk *wmxsdk,
WIMAX_API_NETWORK_CONNECTION_RESP resp,
void *user_data);
typedef void (*WimaxScanResultFunc) (struct wmxsdk *wmxsdk,
WIMAX_API_NSP_INFO_EX *nsps,
guint num_nsps,
void *user_data);
typedef void (*WimaxRemovedFunc) (struct wmxsdk *wmxsdk, void *user_data);
struct wmxsdk {
gint refcount;
WIMAX_API_DEVICE_ID device_id;
WimaxStateChangeFunc state_change_cb;
WimaxConnectResultFunc connect_result_cb;
WimaxScanResultFunc scan_result_cb;
WimaxRemovedFunc removed_cb;
void *callback_data;
GStaticMutex network_mutex;
WIMAX_API_DEVICE_STATUS status;
GMutex *status_mutex;
GMutex *connect_mutex;
char name[100];
char ifname[16];
};
struct wmxsdk *iwmx_sdk_get_wmxsdk_for_iface(const char *iface);
struct wmxsdk *wmxsdk_ref(struct wmxsdk *wmxsdk);
void wmxsdk_unref(struct wmxsdk *wmxsdk);
/* Register/unregister callbacks when a new wmxsdk is set up */
void iwmx_sdk_new_callback_register(WimaxNewWmxsdkFunc callback, void *user_data);
void iwmx_sdk_new_callback_unregister(WimaxNewWmxsdkFunc callback, void *user_data);
void iwmx_sdk_set_callbacks(struct wmxsdk *wmxsdk,
WimaxStateChangeFunc state_change_cb,
WimaxConnectResultFunc connect_result_cb,
WimaxScanResultFunc scan_result_cb,
WimaxRemovedFunc removed_cb,
void *user_data);
WIMAX_API_DEVICE_STATUS iwmxsdk_status_get(struct wmxsdk *wmxsdk);
int iwmx_sdk_connect(struct wmxsdk *wmxsdk, const char *nsp_name);
int iwmx_sdk_disconnect(struct wmxsdk *wmxsdk);
WIMAX_API_CONNECTED_NSP_INFO_EX *iwmx_sdk_get_connected_network(struct wmxsdk *wmxsdk);
const char *iwmx_sdk_dev_status_to_str(WIMAX_API_DEVICE_STATUS status);
const char *iwmx_sdk_reason_to_str(WIMAX_API_STATUS_REASON reason);
int iwmx_sdk_rf_state_set(struct wmxsdk *wmxsdk, WIMAX_API_RF_STATE rf_state);
int iwmx_sdk_get_networks(struct wmxsdk *wmxsdk);
int iwmx_sdk_api_init(void);
void iwmx_sdk_api_exit(void);
#endif /* IWMXSDK_H */

1071
src/wimax/nm-device-wimax.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,68 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
* Copyright (C) 2009 Novell, Inc.
*/
#ifndef NM_DEVICE_WIMAX_H
#define NM_DEVICE_WIMAX_H
#include <net/ethernet.h>
#include <WiMaxType.h>
#include "nm-device.h"
#include "nm-wimax-nsp.h"
G_BEGIN_DECLS
#define NM_TYPE_DEVICE_WIMAX (nm_device_wimax_get_type ())
#define NM_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimax))
#define NM_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
#define NM_IS_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WIMAX))
#define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIMAX))
#define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
typedef struct {
NMDevice parent;
} NMDeviceWimax;
typedef struct {
NMDeviceClass parent;
/* Signals */
void (*nsp_added) (NMDeviceWimax *wimax, NMWimaxNsp *nsp);
void (*nsp_removed) (NMDeviceWimax *wimax, NMWimaxNsp *nsp);
void (*properties_changed) (NMDeviceWimax *wimax, GHashTable *properties);
} NMDeviceWimaxClass;
GType nm_device_wimax_get_type (void);
NMDevice *nm_device_wimax_new (const char *udi,
const char *iface,
const char *driver);
void nm_device_wimax_get_hw_address (NMDeviceWimax *self,
struct ether_addr *addr);
NMWimaxNsp *nm_device_wimax_get_active_nsp (NMDeviceWimax *self);
G_END_DECLS
#endif /* NM_DEVICE_WIMAX_H */

File diff suppressed because it is too large Load diff

View file

@ -1,70 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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) 2009 Novell, Inc.
*/
#ifndef NM_WIMAX_DEVICE_H
#define NM_WIMAX_DEVICE_H
#include <net/ethernet.h>
#include <WiMaxType.h>
#include "nm-device.h"
#include "nm-wimax-nsp.h"
G_BEGIN_DECLS
#define NM_TYPE_WIMAX_DEVICE (nm_wimax_device_get_type ())
#define NM_WIMAX_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIMAX_DEVICE, NMWimaxDevice))
#define NM_WIMAX_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIMAX_DEVICE, NMWimaxDeviceClass))
#define NM_IS_WIMAX_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIMAX_DEVICE))
#define NM_IS_WIMAX_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIMAX_DEVICE))
#define NM_WIMAX_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIMAX_DEVICE, NMWimaxDeviceClass))
#define NM_WIMAX_DEVICE_INDEX "index"
#define NM_WIMAX_DEVICE_HW_ADDRESS "hw-address"
#define NM_WIMAX_DEVICE_ACTIVE_NSP "active-nsp"
typedef struct {
NMDevice parent;
} NMWimaxDevice;
typedef struct {
NMDeviceClass parent;
/* Signals */
void (*nsp_added) (NMWimaxDevice *wimax, NMWimaxNsp *nsp);
void (*nsp_removed) (NMWimaxDevice *wimax, NMWimaxNsp *nsp);
void (*properties_changed) (NMWimaxDevice *wimax, GHashTable *properties);
} NMWimaxDeviceClass;
GType nm_wimax_device_get_type (void);
NMDevice *nm_wimax_device_new (const char *udi,
const char *iface,
const char *driver,
guchar wimax_device_index);
void nm_wimax_device_get_hw_address (NMWimaxDevice *self,
struct ether_addr *addr);
GSList *nm_wimax_device_get_nsps (NMWimaxDevice *self);
NMWimaxNsp *nm_wimax_device_get_active_nsp (NMWimaxDevice *self);
G_END_DECLS
#endif /* NM_WIMAX_DEVICE_H */

View file

@ -15,120 +15,81 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2009 Novell, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <stdio.h>
#include <net/if.h>
#include <WiMaxAPI.h>
#include "nm-wimax-manager.h"
#include "nm-wimax-device.h"
#include "nm-wimax-util.h"
#include "nm-logging.h"
#include "iwmxsdk.h"
G_DEFINE_TYPE (NMWimaxManager, nm_wimax_manager, G_TYPE_OBJECT)
#define NM_WIMAX_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
NM_TYPE_WIMAX_MANAGER, \
NMWimaxManagerPrivate))
typedef struct {
WIMAX_API_DEVICE_ID device_id;
int refs;
} NMWimaxManager;
gboolean disposed;
static NMWimaxManager *global_wimax_manager = NULL;
gboolean sdk_initialized;
} NMWimaxManagerPrivate;
static NMWimaxManager *
/***************************************************/
/*************************************************************/
NMWimaxManager *
nm_wimax_manager_get (void)
{
WIMAX_API_RET result;
static NMWimaxManager *singleton = NULL;
if (!global_wimax_manager) {
global_wimax_manager = g_new (NMWimaxManager, 1);
global_wimax_manager->refs = 1;
if (!singleton)
singleton = NM_WIMAX_MANAGER (g_object_new (NM_TYPE_WIMAX_MANAGER, NULL));
else
g_object_ref (singleton);
g_debug ("Opening WiMAX API");
global_wimax_manager->device_id.structureSize = sizeof (NMWimaxManager);
global_wimax_manager->device_id.privilege = WIMAX_API_PRIVILEGE_READ_WRITE;
result = WiMaxAPIOpen (&global_wimax_manager->device_id);
if (result != WIMAX_API_RET_SUCCESS) {
nm_wimax_util_error (&global_wimax_manager->device_id, "Could not initialize WiMax", result);
g_free (global_wimax_manager);
global_wimax_manager = NULL;
}
} else
global_wimax_manager->refs++;
return global_wimax_manager;
g_assert (singleton);
return singleton;
}
static void
nm_wimax_manager_unref (NMWimaxManager *manager)
nm_wimax_manager_init (NMWimaxManager *self)
{
if (--manager->refs == 0) {
g_debug ("Closing WiMAX API");
WiMaxAPIClose (&manager->device_id);
g_free (manager);
global_wimax_manager = NULL;
NMWimaxManagerPrivate *priv = NM_WIMAX_MANAGER_GET_PRIVATE (self);
int ret;
ret = iwmx_sdk_api_init();
if (ret != 0) {
nm_log_warn (LOGD_WIMAX, "Failed to initialize WiMAX: %d", ret);
return;
}
priv->sdk_initialized = TRUE;
}
static gboolean
wimax_device_matches (WIMAX_API_HW_DEVICE_ID *hw_id,
const char *ifname)
static void
dispose (GObject *object)
{
const char *device_name;
char *s;
char hw_ifname[16];
NMWimaxManagerPrivate *priv = NM_WIMAX_MANAGER_GET_PRIVATE (object);
if (!hw_id)
return FALSE;
if (!priv->disposed) {
priv->disposed = TRUE;
device_name = (const char *) hw_id->deviceName;
if (!device_name)
return FALSE;
if (priv->sdk_initialized)
iwmx_sdk_api_exit ();
}
s = g_strrstr (device_name, "if:");
if (s == NULL || sscanf (s, "if:%15[^ \f\n\r\t\v]", hw_ifname) != 1)
return FALSE;
if (g_strcmp0 (ifname, hw_ifname))
return FALSE;
return TRUE;
G_OBJECT_CLASS (nm_wimax_manager_parent_class)->dispose (object);
}
NMDevice *
nm_wimax_manager_create_device (const char *path,
const char *ifname,
const char *driver)
static void
nm_wimax_manager_class_init (NMWimaxManagerClass *wimax_class)
{
NMWimaxManager *manager;
WIMAX_API_HW_DEVICE_ID device_id_list[5];
NMDevice *device = NULL;
guint32 device_id_list_size = 5;
WIMAX_API_RET result;
GObjectClass *object_class = G_OBJECT_CLASS (wimax_class);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (ifname != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
g_type_class_add_private (wimax_class, sizeof (NMWimaxManagerPrivate));
manager = nm_wimax_manager_get ();
if (!manager)
return NULL;
result = GetListDevice (&manager->device_id, device_id_list, &device_id_list_size);
if (result == WIMAX_API_RET_SUCCESS) {
int i;
for (i = 0; i < device_id_list_size; i++) {
if (wimax_device_matches (&device_id_list[i], ifname)) {
device = nm_wimax_device_new (path, ifname, driver, device_id_list[0].deviceIndex);
break;
}
}
} else
nm_wimax_util_error (&manager->device_id, "Could not get WiMax device list", result);
if (device)
g_object_weak_ref (G_OBJECT (device), (GWeakNotify) nm_wimax_manager_unref, manager);
else
nm_wimax_manager_unref (manager);
return device;
/* virtual methods */
object_class->dispose = dispose;
}

View file

@ -15,16 +15,36 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2009 Novell, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#ifndef NM_WIMAX_MANAGER_H
#define NM_WIMAX_MANAGER_H
#include "nm-device.h"
#include <glib.h>
#include <glib-object.h>
NMDevice *nm_wimax_manager_create_device (const char *path,
const char *ifname,
const char *driver);
#define NM_TYPE_WIMAX_MANAGER (nm_wimax_manager_get_type ())
#define NM_WIMAX_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIMAX_MANAGER, NMWimaxManager))
#define NM_WIMAX_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIMAX_MANAGER, NMWimaxManagerClass))
#define NM_IS_WIMAX_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIMAX_MANAGER))
#define NM_IS_WIMAX_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_WIMAX_MANAGER))
#define NM_WIMAX_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIMAX_MANAGER, NMWimaxManagerClass))
#define NM_WIMAX_MANAGER_DEVICE_ADDED "device-added"
#define NM_WIMAX_MANAGER_DEVICE_REMOVED "device-removed"
typedef struct {
GObject parent;
} NMWimaxManager;
typedef struct {
GObjectClass parent;
} NMWimaxManagerClass;
GType nm_wimax_manager_get_type (void);
NMWimaxManager *nm_wimax_manager_get (void);
#endif /* NM_WIMAX_MANAGER_H */

View file

@ -21,21 +21,41 @@
#include <WiMaxAPI.h>
#include "nm-wimax-util.h"
#include "nm-utils.h"
#include "iwmxsdk.h"
#include "nm-logging.h"
static guint sdk_refcount = 0;
void
nm_wimax_util_error (WIMAX_API_DEVICE_ID *device_id,
const char *message,
WIMAX_API_RET result)
nm_wimax_util_sdk_ref (void)
{
char *warning_msg;
char str[MAX_SIZE_OF_STRING_BUFFER];
guint32 str_len = MAX_SIZE_OF_STRING_BUFFER;
int ret = 0;
GetErrorString (device_id, result, str, &str_len);
warning_msg = g_strconcat (message, ": %s (%d)", NULL);
g_warning (warning_msg, str, result);
g_free (warning_msg);
}
if (sdk_refcount == 0) {
ret = iwmx_sdk_api_init ();
if (ret != 0) {
nm_log_warn (LOGD_WIMAX, "Failed to initialize WiMAX: %d", ret);
return;
}
}
sdk_refcount++;
}
gboolean
nm_wimax_util_sdk_is_initialized (void)
{
return sdk_refcount > 0;
}
void
nm_wimax_util_sdk_unref (void)
{
g_return_if_fail (sdk_refcount > 0);
sdk_refcount--;
if (sdk_refcount == 0)
iwmx_sdk_api_exit ();
}
NMWimaxNspNetworkType
nm_wimax_util_convert_network_type (WIMAX_API_NETWORK_TYPE wimax_network_type)
@ -60,56 +80,3 @@ nm_wimax_util_convert_network_type (WIMAX_API_NETWORK_TYPE wimax_network_type)
return type;
}
/* cinr_to_percentage() and the comment is borrowed from connman */
/*
* FIXME: pulled it it out of some hole
*
* the cinr to percentage computation comes from the L3/L4 doc
*
* But some other places (L4 code) have a more complex, seemingly
* logarithmical computation.
*
* Oh well...
*
*/
int
nm_wimax_util_cinr_to_percentage (int cinr)
{
int strength;
if (cinr <= -5)
strength = 0;
else if (cinr >= 25)
strength = 100;
else /* Calc percentage on the value from -5 to 25 */
strength = ((100UL * (cinr - -5)) / (25 - -5));
return strength;
}
const char *
nm_wimax_util_device_status_to_str (WIMAX_API_DEVICE_STATUS status)
{
switch (status) {
case WIMAX_API_DEVICE_STATUS_UnInitialized:
return "Device is uninitialized";
case WIMAX_API_DEVICE_STATUS_RF_OFF_HW_SW:
return "Device RF Off(both H/W and S/W)";
case WIMAX_API_DEVICE_STATUS_RF_OFF_HW:
return "Device RF Off(via H/W switch)";
case WIMAX_API_DEVICE_STATUS_RF_OFF_SW:
return "Device RF Off(via S/W switch)";
case WIMAX_API_DEVICE_STATUS_Ready:
return "Device is ready";
case WIMAX_API_DEVICE_STATUS_Scanning:
return "Device is scanning";
case WIMAX_API_DEVICE_STATUS_Connecting:
return "Connection in progress";
case WIMAX_API_DEVICE_STATUS_Data_Connected:
return "Layer 2 connected";
}
return "Unknown device state";
}

View file

@ -21,17 +21,18 @@
#ifndef NM_WIMAX_UTIL_H
#define NM_WIMAX_UTIL_H
#include <glib.h>
#include <WiMaxType.h>
#include <WiMaxError.h>
#include "nm-wimax-types.h"
void nm_wimax_util_error (WIMAX_API_DEVICE_ID *device_id,
const char *message,
WIMAX_API_RET result);
void nm_wimax_util_sdk_ref (void);
gboolean nm_wimax_util_sdk_is_initialized (void);
void nm_wimax_util_sdk_unref (void);
NMWimaxNspNetworkType nm_wimax_util_convert_network_type (WIMAX_API_NETWORK_TYPE wimax_network_type);
int nm_wimax_util_cinr_to_percentage (int cinr);
const char *nm_wimax_util_device_status_to_str (WIMAX_API_DEVICE_STATUS status);
#endif /* NM_WIMAX_UTIL_H */

View file

@ -38,7 +38,7 @@
#include <nm-gsm-device.h>
#include <nm-cdma-device.h>
#include <nm-device-bt.h>
#include <nm-wimax-device.h>
#include <nm-device-wimax.h>
#include <nm-utils.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
@ -199,13 +199,13 @@ wimax_network_type_to_str (NMWimaxNspNetworkType type)
{
switch (type) {
case NM_WIMAX_NSP_NETWORK_TYPE_HOME:
return "Home network";
return "Home";
case NM_WIMAX_NSP_NETWORK_TYPE_PARTNER:
return "Partner network";
return "Partner";
case NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER:
return "Roaming partner network";
return "Roaming";
default:
return "Unknown network";
return "Unknown";
}
}
@ -225,11 +225,11 @@ detail_nsp (gpointer data, gpointer user_data)
active = g_strcmp0 (active_name, name) == 0;
label = g_strdup_printf (" %s%s", active ? "*" : "", name);
data_str = g_strdup_printf ("%s, Signal quality: %d",
wimax_network_type_to_str (nm_wimax_nsp_get_network_type (nsp)),
nm_wimax_nsp_get_signal_quality (nsp));
data_str = g_strdup_printf ("%d%% (%s)",
nm_wimax_nsp_get_signal_quality (nsp),
wimax_network_type_to_str (nm_wimax_nsp_get_network_type (nsp)));
print_string (label, data);
print_string (label, data_str);
g_free (label);
g_free (data_str);
}
@ -379,7 +379,7 @@ detail_device (gpointer data, gpointer user_data)
print_string ("Type", "Mobile Broadband (CDMA)");
else if (NM_IS_DEVICE_BT (device))
print_string ("Type", "Bluetooth");
else if (NM_IS_WIMAX_DEVICE (device))
else if (NM_IS_DEVICE_WIMAX (device))
print_string ("Type", "WiMAX");
print_string ("Driver", nm_device_get_driver (device) ? nm_device_get_driver (device) : "(unknown)");
@ -396,8 +396,8 @@ detail_device (gpointer data, gpointer user_data)
tmp = g_strdup (nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device)));
else if (NM_IS_DEVICE_WIFI (device))
tmp = g_strdup (nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device)));
else if (NM_IS_WIMAX_DEVICE (device))
tmp = g_strdup (nm_wimax_device_get_hw_address (NM_WIMAX_DEVICE (device)));
else if (NM_IS_DEVICE_WIMAX (device))
tmp = g_strdup (nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device)));
if (tmp) {
print_string ("HW Address", tmp);
@ -463,19 +463,19 @@ detail_device (gpointer data, gpointer user_data)
print_string (" Carrier", "on");
else
print_string (" Carrier", "off");
} else if (NM_IS_WIMAX_DEVICE (device)) {
} else if (NM_IS_DEVICE_WIMAX (device)) {
NMWimaxNsp *active_nsp = NULL;
const char *active_name = NULL;
const GPtrArray *nsps;
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
active_nsp = nm_wimax_device_get_active_nsp (NM_WIMAX_DEVICE (device));
active_nsp = nm_device_wimax_get_active_nsp (NM_DEVICE_WIMAX (device));
active_name = active_nsp ? nm_wimax_nsp_get_name (active_nsp) : NULL;
}
printf ("\n WiMAX NSPs %s\n", active_nsp ? "(* current NSP)" : "");
nsps = nm_wimax_device_get_nsps (NM_WIMAX_DEVICE (device));
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
if (nsps && nsps->len)
g_ptr_array_foreach ((GPtrArray *) nsps, detail_nsp, (gpointer) active_name);
}