~ubuntu-branches/ubuntu/precise/network-manager/precise

« back to all changes in this revision

Viewing changes to cli/src/devices.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-02-09 16:45:41 UTC
  • mfrom: (1.1.53)
  • Revision ID: package-import@ubuntu.com-20120209164541-4h90zknlsfdb7x35
Tags: 0.9.2.0+git201202091925.c721477-0ubuntu1
* upstream snapshot 2012-02-09 19:25:59 (GMT)
  + c721477d11d4fe144111d6d2eec8f93f2e9186c9
* debian/patches/avoid-periodic-disk-wakeups.patch: refreshed.
* debian/patches/nl3-default-ip6-route.patch: refreshed.
* debian/libnm-glib4.symbols: add symbols:
  + nm_active_connection_get_master@Base
  + nm_client_new_async@Base
  + nm_client_new_finish@Base
  + nm_remote_settings_new_async@Base
  + nm_remote_settings_new_finish@Base
  + nm_device_get_state_reason@Base
* debian/libnm-util2.symbols: add symbols:
  + nm_setting_802_1x_get_pac_file@Base
  + nm_setting_infiniband_get_transport_mode@Base

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
        {"DRIVER",            N_("DRIVER"),             9, NULL, 0},  /* 5 */
106
106
        {"HWADDR",            N_("HWADDR"),            19, NULL, 0},  /* 6 */
107
107
        {"STATE",             N_("STATE"),             14, NULL, 0},  /* 7 */
108
 
        {"UDI",               N_("UDI"),               64, NULL, 0},  /* 8 */
109
 
        {"IP-IFACE",          N_("IP-IFACE"),          10, NULL, 0},  /* 9 */
110
 
        {"NM-MANAGED",        N_("NM-MANAGED"),        15, NULL, 0},  /* 10 */
111
 
        {"FIRMWARE-MISSING",  N_("FIRMWARE-MISSING"),  18, NULL, 0},  /* 11 */
112
 
        {"CONNECTION",        N_("CONNECTION"),        51, NULL, 0},  /* 12 */
 
108
        {"REASON",            N_("REASON"),            25, NULL, 0},  /* 8 */
 
109
        {"UDI",               N_("UDI"),               64, NULL, 0},  /* 9 */
 
110
        {"IP-IFACE",          N_("IP-IFACE"),          10, NULL, 0},  /* 10 */
 
111
        {"NM-MANAGED",        N_("NM-MANAGED"),        15, NULL, 0},  /* 11 */
 
112
        {"FIRMWARE-MISSING",  N_("FIRMWARE-MISSING"),  18, NULL, 0},  /* 12 */
 
113
        {"CONNECTION",        N_("CONNECTION"),        51, NULL, 0},  /* 13 */
113
114
        {NULL, NULL, 0, NULL, 0}
114
115
};
115
 
#define NMC_FIELDS_DEV_LIST_GENERAL_ALL     "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,HWADDR,STATE,UDI,IP-IFACE,NM-MANAGED,FIRMWARE-MISSING,CONNECTION"
 
116
#define NMC_FIELDS_DEV_LIST_GENERAL_ALL     "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,HWADDR,STATE,REASON,UDI,IP-IFACE,NM-MANAGED,FIRMWARE-MISSING,CONNECTION"
116
117
#define NMC_FIELDS_DEV_LIST_GENERAL_COMMON  "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,HWADDR,STATE"
117
118
 
118
119
/* Available fields for 'dev list' - CAPABILITIES part */
265
266
        }
266
267
}
267
268
 
 
269
static const char *
 
270
device_reason_to_string (NMDeviceStateReason reason)
 
271
{
 
272
        switch (reason) {
 
273
        case NM_DEVICE_STATE_REASON_NONE:
 
274
                return _("No reason given");
 
275
 
 
276
        case NM_DEVICE_STATE_REASON_UNKNOWN:
 
277
                return _("Unknown error");
 
278
 
 
279
        case NM_DEVICE_STATE_REASON_NOW_MANAGED:
 
280
                return _("Device is now managed");
 
281
 
 
282
        case NM_DEVICE_STATE_REASON_NOW_UNMANAGED:
 
283
                return _("Device is now unmanaged");
 
284
 
 
285
        case NM_DEVICE_STATE_REASON_CONFIG_FAILED:
 
286
                return _("The device could not be readied for configuration");
 
287
 
 
288
        case NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE:
 
289
                return _("IP configuration could not be reserved (no available address, timeout, etc)");
 
290
 
 
291
        case NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED:
 
292
                return _("The IP configuration is no longer valid");
 
293
 
 
294
        case NM_DEVICE_STATE_REASON_NO_SECRETS:
 
295
                return _("Secrets were required, but not provided");
 
296
 
 
297
        case NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT:
 
298
                return _("802.1X supplicant disconnected");
 
299
 
 
300
        case NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED:
 
301
                return _("802.1X supplicant configuration failed");
 
302
 
 
303
        case NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED:
 
304
                return _("802.1X supplicant failed");
 
305
 
 
306
        case NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT:
 
307
                return _("802.1X supplicant took too long to authenticate");
 
308
 
 
309
        case NM_DEVICE_STATE_REASON_PPP_START_FAILED:
 
310
                return _("PPP service failed to start");
 
311
 
 
312
        case NM_DEVICE_STATE_REASON_PPP_DISCONNECT:
 
313
                return _("PPP service disconnected");
 
314
 
 
315
        case NM_DEVICE_STATE_REASON_PPP_FAILED:
 
316
                return _("PPP failed");
 
317
 
 
318
        case NM_DEVICE_STATE_REASON_DHCP_START_FAILED:
 
319
                return _("DHCP client failed to start");
 
320
 
 
321
        case NM_DEVICE_STATE_REASON_DHCP_ERROR:
 
322
                return _("DHCP client error");
 
323
 
 
324
        case NM_DEVICE_STATE_REASON_DHCP_FAILED:
 
325
                return _("DHCP client failed");
 
326
 
 
327
        case NM_DEVICE_STATE_REASON_SHARED_START_FAILED:
 
328
                return _("Shared connection service failed to start");
 
329
 
 
330
        case NM_DEVICE_STATE_REASON_SHARED_FAILED:
 
331
                return _("Shared connection service failed");
 
332
 
 
333
        case NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED:
 
334
                return _("AutoIP service failed to start");
 
335
 
 
336
        case NM_DEVICE_STATE_REASON_AUTOIP_ERROR:
 
337
                return _("AutoIP service error");
 
338
 
 
339
        case NM_DEVICE_STATE_REASON_AUTOIP_FAILED:
 
340
                return _("AutoIP service failed");
 
341
 
 
342
        case NM_DEVICE_STATE_REASON_MODEM_BUSY:
 
343
                return _("The line is busy");
 
344
 
 
345
        case NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE:
 
346
                return _("No dial tone");
 
347
 
 
348
        case NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER:
 
349
                return _("No carrier could be established");
 
350
 
 
351
        case NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT:
 
352
                return _("The dialing request timed out");
 
353
 
 
354
        case NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED:
 
355
                return _("The dialing attempt failed");
 
356
 
 
357
        case NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED:
 
358
                return _("Modem initialization failed");
 
359
 
 
360
        case NM_DEVICE_STATE_REASON_GSM_APN_FAILED:
 
361
                return _("Failed to select the specified APN");
 
362
 
 
363
        case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING:
 
364
                return _("Not searching for networks");
 
365
 
 
366
        case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED:
 
367
                return _("Network registration denied");
 
368
 
 
369
        case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT:
 
370
                return _("Network registration timed out");
 
371
 
 
372
        case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED:
 
373
                return _("Failed to register with the requested network");
 
374
 
 
375
        case NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED:
 
376
                return _("PIN check failed");
 
377
 
 
378
        case NM_DEVICE_STATE_REASON_FIRMWARE_MISSING:
 
379
                return _("Necessary firmware for the device may be missing");
 
380
 
 
381
        case NM_DEVICE_STATE_REASON_REMOVED:
 
382
                return _("The device was removed");
 
383
 
 
384
        case NM_DEVICE_STATE_REASON_SLEEPING:
 
385
                return _("NetworkManager went to sleep");
 
386
 
 
387
        case NM_DEVICE_STATE_REASON_CONNECTION_REMOVED:
 
388
                return _("The device's active connection disappeared");
 
389
 
 
390
        case NM_DEVICE_STATE_REASON_USER_REQUESTED:
 
391
                return _("Device disconnected by user or client");
 
392
 
 
393
        case NM_DEVICE_STATE_REASON_CARRIER:
 
394
                return _("Carrier/link changed");
 
395
 
 
396
        case NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED:
 
397
                return _("The device's existing connection was assumed");
 
398
 
 
399
        case NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE:
 
400
                return _("The supplicant is now available");
 
401
 
 
402
        case NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND:
 
403
                return _("The modem could not be found");
 
404
 
 
405
        case NM_DEVICE_STATE_REASON_BT_FAILED:
 
406
                return _("The Bluetooth connection failed or timed out");
 
407
 
 
408
        case NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED:
 
409
                return _("GSM Modem's SIM card not inserted");
 
410
 
 
411
        case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED:
 
412
                return _("GSM Modem's SIM PIN required");
 
413
 
 
414
        case NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED:
 
415
                return _("GSM Modem's SIM PUK required");
 
416
 
 
417
        case NM_DEVICE_STATE_REASON_GSM_SIM_WRONG:
 
418
                return _("GSM Modem's SIM wrong");
 
419
 
 
420
        case NM_DEVICE_STATE_REASON_INFINIBAND_MODE:
 
421
                return _("Infiniband device does not support connected mode");
 
422
        default:
 
423
                return _("Unknown");
 
424
        }
 
425
}
 
426
 
268
427
/* Convert device type to string. Use setting names strings to match with
269
428
 * connection type names.
270
429
 */
502
661
        APInfo *info;
503
662
        const char *hwaddr = NULL;
504
663
        NMDeviceState state = NM_DEVICE_STATE_UNKNOWN;
 
664
        NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
505
665
        NMDeviceCapabilities caps;
506
666
        NMActiveConnection *acon;
507
667
        guint32 speed;
508
668
        char *speed_str = NULL;
 
669
        char *state_str = NULL;
 
670
        char *reason_str = NULL;
509
671
        GArray *sections_array;
510
672
        int k;
511
673
        char *fields_str;
550
712
 
551
713
                was_output = FALSE;
552
714
 
553
 
                state = nm_device_get_state (device);
 
715
                state = nm_device_get_state_reason (device, &reason);
554
716
 
555
717
                /* section GENERAL */
556
718
                if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[0].name)) {
570
732
                        else if (NM_IS_DEVICE_INFINIBAND (device))
571
733
                                hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
572
734
 
 
735
 
 
736
                        state_str = g_strdup_printf ("%d (%s)", state, device_state_to_string (state));
 
737
                        reason_str = g_strdup_printf ("%d (%s)", reason, device_reason_to_string (reason));
 
738
 
573
739
                        nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name;  /* "GENERAL"*/
574
740
                        nmc->allowed_fields[1].value = nm_device_get_iface (device);
575
741
                        nmc->allowed_fields[2].value = device_type_to_string (device);
577
743
                        nmc->allowed_fields[4].value = nm_device_get_product (device);
578
744
                        nmc->allowed_fields[5].value = nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)");
579
745
                        nmc->allowed_fields[6].value = hwaddr ? hwaddr : _("(unknown)");
580
 
                        nmc->allowed_fields[7].value = device_state_to_string (state);
581
 
                        nmc->allowed_fields[8].value = nm_device_get_udi (device);
582
 
                        nmc->allowed_fields[9].value = nm_device_get_ip_iface (device);
583
 
                        nmc->allowed_fields[10].value = nm_device_get_managed (device) ? _("yes") : _("no");
584
 
                        nmc->allowed_fields[11].value = nm_device_get_firmware_missing (device) ? _("yes") : _("no");
585
 
                        nmc->allowed_fields[12].value = (acon = nm_device_get_active_connection (device)) ?
 
746
                        nmc->allowed_fields[7].value = state_str;
 
747
                        nmc->allowed_fields[8].value = reason_str;
 
748
                        nmc->allowed_fields[9].value = nm_device_get_udi (device);
 
749
                        nmc->allowed_fields[10].value = nm_device_get_ip_iface (device);
 
750
                        nmc->allowed_fields[11].value = nm_device_get_managed (device) ? _("yes") : _("no");
 
751
                        nmc->allowed_fields[12].value = nm_device_get_firmware_missing (device) ? _("yes") : _("no");
 
752
                        nmc->allowed_fields[13].value = (acon = nm_device_get_active_connection (device)) ?
586
753
                                                           nm_object_get_path (NM_OBJECT (acon)) : _("not connected");
587
754
 
588
755
                        nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
589
756
                        print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
 
757
                        g_free (state_str);
 
758
                        g_free (reason_str);
590
759
                        was_output = TRUE;
591
760
                }
592
761