~network-manager/network-manager/ubuntu.hardy-backports.07

« back to all changes in this revision

Viewing changes to src/nm-hal-manager.c

* merge 0.7~~svn20080818t061112+eni0 snapshot to hardy branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#include "nm-device-wifi.h"
15
15
#include "nm-device-ethernet.h"
16
16
#include "nm-gsm-device.h"
 
17
#include "nm-hso-gsm-device.h"
17
18
#include "nm-cdma-device.h"
18
19
 
19
20
/* Killswitch poll frequency in seconds */
220
221
        return is_modem;
221
222
}
222
223
 
 
224
static char *
 
225
get_hso_netdev (LibHalContext *ctx, const char *udi)
 
226
{
 
227
        char *serial_parent, *netdev = NULL;
 
228
        char **netdevs;
 
229
        int num, i;
 
230
 
 
231
        /* Get the serial interface's originating device UDI, used to find the
 
232
         * originating device's netdev.
 
233
         */
 
234
        serial_parent = libhal_device_get_property_string (ctx, udi, "serial.originating_device", NULL);
 
235
        if (!serial_parent)
 
236
                serial_parent = libhal_device_get_property_string (ctx, udi, "info.parent", NULL);
 
237
        if (!serial_parent)
 
238
                return NULL;
 
239
 
 
240
        /* Look for the originating device's netdev */
 
241
        netdevs = libhal_find_device_by_capability (ctx, "net", &num, NULL);
 
242
        for (i = 0; netdevs && !netdev && (i < num); i++) {
 
243
                char *netdev_parent, *tmp;
 
244
 
 
245
                netdev_parent = libhal_device_get_property_string (ctx, netdevs[i], "net.originating_device", NULL);
 
246
                if (!netdev_parent)
 
247
                        netdev_parent = libhal_device_get_property_string (ctx, netdevs[i], "net.physical_device", NULL);
 
248
                if (!netdev_parent)
 
249
                        continue;
 
250
 
 
251
                if (!strcmp (netdev_parent, serial_parent)) {
 
252
                        /* We found it */
 
253
                        tmp = libhal_device_get_property_string (ctx, netdevs[i], "net.interface", NULL);
 
254
                        if (tmp) {
 
255
                                netdev = g_strdup (tmp);
 
256
                                libhal_free_string (tmp);
 
257
                        }
 
258
                }
 
259
 
 
260
                libhal_free_string (netdev_parent);
 
261
        }
 
262
        libhal_free_string_array (netdevs);
 
263
        libhal_free_string (serial_parent);
 
264
 
 
265
        return netdev;
 
266
}
 
267
 
223
268
static GObject *
224
269
modem_device_creator (NMHalManager *self, const char *udi, gboolean managed)
225
270
{
231
276
        char **capabilities, **iter;
232
277
        gboolean type_gsm = FALSE;
233
278
        gboolean type_cdma = FALSE;
 
279
        char *netdev = NULL;
234
280
 
235
281
        serial_device = libhal_device_get_property_string (priv->hal_ctx, udi, "serial.device", NULL);
236
282
 
274
320
                g_strfreev (capabilities);
275
321
        }
276
322
 
277
 
        if (type_gsm)
278
 
                device = (GObject *) nm_gsm_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
279
 
        else if (type_cdma)
 
323
        /* Special handling of 'hso' cards (until punted out to a modem manager) */
 
324
        if (type_gsm && !strcmp (driver_name, "hso"))
 
325
                netdev = get_hso_netdev (priv->hal_ctx, udi);
 
326
 
 
327
        if (type_gsm) {
 
328
                if (netdev)
 
329
                        device = (GObject *) nm_hso_gsm_device_new (udi, serial_device + strlen ("/dev/"), NULL, netdev, driver_name, managed);
 
330
                else
 
331
                        device = (GObject *) nm_gsm_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
 
332
        } else if (type_cdma)
280
333
                device = (GObject *) nm_cdma_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
281
334
 
282
335
out:
302
355
 
303
356
        /* Wireless device */
304
357
        creator = g_slice_new0 (DeviceCreator);
305
 
        creator->device_type_name = g_strdup ("wireless (802.11)");
 
358
        creator->device_type_name = g_strdup ("802.11 WiFi");
306
359
        creator->capability_str = g_strdup ("net.80211");
307
360
        creator->is_device_fn = is_wireless_device;
308
361
        creator->creator_fn = wireless_device_creator;