cli: add NM_DEVICE_STATE_REASON_BR2684_FAILED reason-to-string mapping
[NetworkManager.git] / cli / src / common.c
1 /*
2  *  nmcli - command-line tool for controlling NetworkManager
3  *  Common functions and data shared between files.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * (C) Copyright 2012 Red Hat, Inc.
20  */
21
22 #include "config.h"
23
24 #include <glib.h>
25 #include <glib/gi18n.h>
26
27 #include "common.h"
28 #include "utils.h"
29
30 /* Available fields for IPv4 group */
31 static NmcOutputField nmc_fields_ip4_config[] = {
32         {"GROUP",      N_("GROUP"),       15, NULL, 0},  /* 0 */
33         {"ADDRESS",    N_("ADDRESS"),     68, NULL, 0},  /* 1 */
34         {"ROUTE",      N_("ROUTE"),       68, NULL, 0},  /* 2 */
35         {"DNS",        N_("DNS"),         35, NULL, 0},  /* 3 */
36         {"DOMAIN",     N_("DOMAIN"),      35, NULL, 0},  /* 4 */
37         {"WINS",       N_("WINS"),        20, NULL, 0},  /* 5 */
38         {NULL,         NULL,               0, NULL, 0}
39 };
40 #define NMC_FIELDS_IP4_CONFIG_ALL     "GROUP,ADDRESS,ROUTE,DNS,DOMAIN,WINS"
41
42 /* Available fields for DHCPv4 group */
43 static NmcOutputField nmc_fields_dhcp4_config[] = {
44         {"GROUP",      N_("GROUP"),       15, NULL, 0},  /* 0 */
45         {"OPTION",     N_("OPTION"),      80, NULL, 0},  /* 1 */
46         {NULL,         NULL,               0, NULL, 0}
47 };
48 #define NMC_FIELDS_DHCP4_CONFIG_ALL     "GROUP,OPTION"
49
50 /* Available fields for IPv6 group */
51 static NmcOutputField nmc_fields_ip6_config[] = {
52         {"GROUP",      N_("GROUP"),       15, NULL, 0},  /* 0 */
53         {"ADDRESS",    N_("ADDRESS"),     95, NULL, 0},  /* 1 */
54         {"ROUTE",      N_("ROUTE"),       95, NULL, 0},  /* 2 */
55         {"DNS",        N_("DNS"),         60, NULL, 0},  /* 3 */
56         {"DOMAIN",     N_("DOMAIN"),      35, NULL, 0},  /* 4 */
57         {NULL,         NULL,               0, NULL, 0}
58 };
59 #define NMC_FIELDS_IP6_CONFIG_ALL     "GROUP,ADDRESS,ROUTE,DNS,DOMAIN"
60
61 /* Available fields for DHCPv6 group */
62 static NmcOutputField nmc_fields_dhcp6_config[] = {
63         {"GROUP",      N_("GROUP"),       15, NULL, 0},  /* 0 */
64         {"OPTION",     N_("OPTION"),      80, NULL, 0},  /* 1 */
65         {NULL,         NULL,               0, NULL, 0}
66 };
67 #define NMC_FIELDS_DHCP6_CONFIG_ALL     "GROUP,OPTION"
68
69
70 gboolean
71 print_ip4_config (NMIP4Config *cfg4, NmCli *nmc, const char *group_prefix)
72 {
73         GSList *list, *iter;
74         const GArray *array;
75         const GPtrArray *ptr_array;
76         char **addr_arr = NULL;
77         char **route_arr = NULL;
78         char **dns_arr = NULL;
79         char **domain_arr = NULL;
80         char **wins_arr = NULL;
81         int i = 0;
82         guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
83         guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
84         guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
85
86         if (cfg4 == NULL)
87                 return FALSE;
88
89         nmc->allowed_fields = nmc_fields_ip4_config;
90         nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
91         nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_IP4_CONFIG_ALL, nmc->allowed_fields, NULL);
92         print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
93
94         /* addresses */
95         list = (GSList *) nm_ip4_config_get_addresses (cfg4);
96         addr_arr = g_new (char *, g_slist_length (list) + 1);
97         for (iter = list; iter; iter = g_slist_next (iter)) {
98                 NMIP4Address *addr = (NMIP4Address *) iter->data;
99                 guint32 prefix;
100                 char *ip_str, *gw_str;
101
102                 ip_str = nmc_ip4_address_as_string (nm_ip4_address_get_address (addr), NULL);
103                 prefix = nm_ip4_address_get_prefix (addr);
104                 gw_str = nmc_ip4_address_as_string (nm_ip4_address_get_gateway (addr), NULL);
105
106                 addr_arr[i++] = g_strdup_printf ("ip = %s/%u, gw = %s", ip_str, prefix, gw_str);
107                 g_free (ip_str);
108                 g_free (gw_str);
109         }
110         addr_arr[i] = NULL;
111
112         /* routes */
113         list = (GSList *) nm_ip4_config_get_routes (cfg4);
114         route_arr = g_new (char *, g_slist_length (list) + 1);
115         i = 0;
116         for (iter = list; iter; iter = g_slist_next (iter)) {
117                 NMIP4Route *route = (NMIP4Route *) iter->data;
118                 guint32 prefix, metric;
119                 char *dest_str, *nexthop_str;
120
121                 dest_str = nmc_ip4_address_as_string (nm_ip4_route_get_dest (route), NULL);
122                 nexthop_str = nmc_ip4_address_as_string (nm_ip4_route_get_next_hop (route), NULL);
123                 prefix = nm_ip4_route_get_prefix (route);
124                 metric = nm_ip4_route_get_metric (route);
125
126                 route_arr[i++] = g_strdup_printf ("dst = %s/%u, nh = %s, mt = %u", dest_str, prefix, nexthop_str, metric);
127                 g_free (dest_str);
128                 g_free (nexthop_str);
129         }
130         route_arr[i] = NULL;
131
132         /* DNS */
133         array = nm_ip4_config_get_nameservers (cfg4);
134         if (array) {
135                 dns_arr = g_new (char *, array->len + 1);
136                 for (i = 0; i < array->len; i++)
137                         dns_arr[i] = nmc_ip4_address_as_string (g_array_index (array, guint32, i), NULL);
138
139                 dns_arr[i] = NULL;
140         }
141
142         /* domains */
143         ptr_array = nm_ip4_config_get_domains (cfg4);
144         if (ptr_array) {
145                 domain_arr = g_new (char *, ptr_array->len + 1);
146                 for (i = 0; i < ptr_array->len; i++)
147                         domain_arr[i] = g_ptr_array_index (ptr_array, i);
148
149                 domain_arr[i] = NULL;
150         }
151
152         /* WINS */
153         array = nm_ip4_config_get_wins_servers (cfg4);
154         if (array) {
155                 wins_arr = g_new (char *, array->len + 1);
156                 for (i = 0; i < array->len; i++)
157                         wins_arr[i] = nmc_ip4_address_as_string (g_array_index (array, guint32, i), NULL);
158
159                 wins_arr[i] = NULL;
160         }
161
162         set_val_str (nmc->allowed_fields, 0, group_prefix);
163         set_val_arr (nmc->allowed_fields, 1, (const char **) addr_arr);
164         set_val_arr (nmc->allowed_fields, 2, (const char **) route_arr);
165         set_val_arr (nmc->allowed_fields, 3, (const char **) dns_arr);
166         set_val_arr (nmc->allowed_fields, 4, (const char **) domain_arr);
167         set_val_arr (nmc->allowed_fields, 5, (const char **) wins_arr);
168
169         nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
170         print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
171
172         g_strfreev (addr_arr);
173         g_strfreev (route_arr);
174         g_strfreev (dns_arr);
175         g_free (domain_arr);
176         g_strfreev (wins_arr);
177
178         return TRUE;
179 }
180
181 gboolean
182 print_ip6_config (NMIP6Config *cfg6, NmCli *nmc, const char *group_prefix)
183 {
184         GSList *list, *iter;
185         const GPtrArray *ptr_array;
186         char **addr_arr = NULL;
187         char **route_arr = NULL;
188         char **dns_arr = NULL;
189         char **domain_arr = NULL;
190         int i = 0;
191         guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
192         guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
193         guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
194
195         if (cfg6 == NULL)
196                 return FALSE;
197
198         nmc->allowed_fields = nmc_fields_ip6_config;
199         nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
200         nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_IP6_CONFIG_ALL, nmc->allowed_fields, NULL);
201         print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
202
203         /* addresses */
204         list = (GSList *) nm_ip6_config_get_addresses (cfg6);
205         addr_arr = g_new (char *, g_slist_length (list) + 1);
206         for (iter = list; iter; iter = g_slist_next (iter)) {
207                 NMIP6Address *addr = (NMIP6Address *) iter->data;
208                 guint32 prefix;
209                 char *ip_str, *gw_str;
210
211                 ip_str = nmc_ip6_address_as_string (nm_ip6_address_get_address (addr), NULL);
212                 prefix = nm_ip6_address_get_prefix (addr);
213                 gw_str = nmc_ip6_address_as_string (nm_ip6_address_get_gateway (addr), NULL);
214
215                 addr_arr[i++] = g_strdup_printf ("ip = %s/%u, gw = %s", ip_str, prefix, gw_str);
216                 g_free (ip_str);
217                 g_free (gw_str);
218         }
219         addr_arr[i] = NULL;
220
221         /* routes */
222         list = (GSList *) nm_ip6_config_get_routes (cfg6);
223         route_arr = g_new (char *, g_slist_length (list) + 1);
224         i = 0;
225         for (iter = list; iter; iter = g_slist_next (iter)) {
226                 NMIP6Route *route = (NMIP6Route *) iter->data;
227                 guint32 prefix, metric;
228                 char *dest_str, *nexthop_str;
229
230                 dest_str = nmc_ip6_address_as_string (nm_ip6_route_get_dest (route), NULL);
231                 nexthop_str = nmc_ip6_address_as_string (nm_ip6_route_get_next_hop (route), NULL);
232                 prefix = nm_ip6_route_get_prefix (route);
233                 metric = nm_ip6_route_get_metric (route);
234
235                 route_arr[i++] = g_strdup_printf ("dst = %s/%u, nh = %s, mt = %u", dest_str, prefix, nexthop_str, metric);
236                 g_free (dest_str);
237                 g_free (nexthop_str);
238         }
239         route_arr[i] = NULL;
240
241         /* DNS */
242         list = (GSList *) nm_ip6_config_get_nameservers (cfg6);
243         dns_arr = g_new (char *, g_slist_length (list) + 1);
244         i = 0;
245         for (iter = list; iter; iter = g_slist_next (iter))
246                 dns_arr[i++] = nmc_ip6_address_as_string (iter->data, NULL);
247
248         dns_arr[i] = NULL;
249
250         /* domains */
251         ptr_array = nm_ip6_config_get_domains (cfg6);
252         if (ptr_array) {
253                 domain_arr = g_new (char *, ptr_array->len + 1);
254                 for (i = 0; i < ptr_array->len; i++)
255                         domain_arr[i] = g_ptr_array_index (ptr_array, i);
256
257                 domain_arr[i] = NULL;
258         }
259
260         set_val_str (nmc->allowed_fields, 0, group_prefix);
261         set_val_arr (nmc->allowed_fields, 1, (const char **) addr_arr);
262         set_val_arr (nmc->allowed_fields, 2, (const char **) route_arr);
263         set_val_arr (nmc->allowed_fields, 3, (const char **) dns_arr);
264         set_val_arr (nmc->allowed_fields, 4, (const char **) domain_arr);
265
266         nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
267         print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
268
269         g_strfreev (addr_arr);
270         g_strfreev (route_arr);
271         g_strfreev (dns_arr);
272         g_free (domain_arr);
273
274         return TRUE;
275 }
276
277 gboolean
278 print_dhcp4_config (NMDHCP4Config *dhcp4, NmCli *nmc, const char *group_prefix)
279 {
280         GHashTable *table;
281         guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
282         guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
283         guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
284
285         if (dhcp4 == NULL)
286                 return FALSE;
287
288         table = nm_dhcp4_config_get_options (dhcp4);
289         if (table) {
290                 GHashTableIter table_iter;
291                 gpointer key, value;
292                 char **options_arr = NULL;
293                 int i = 0;
294
295                 nmc->allowed_fields = nmc_fields_dhcp4_config;
296                 nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
297                 nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DHCP4_CONFIG_ALL, nmc->allowed_fields, NULL);
298                 print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
299
300                 options_arr = g_new (char *, g_hash_table_size (table) + 1);
301                 g_hash_table_iter_init (&table_iter, table);
302                 while (g_hash_table_iter_next (&table_iter, &key, &value))
303                         options_arr[i++] = g_strdup_printf ("%s = %s", (char *) key, (char *) value);
304                 options_arr[i] = NULL;
305
306                 set_val_str (nmc->allowed_fields, 0, group_prefix);
307                 set_val_arr (nmc->allowed_fields, 1, (const char **) options_arr);
308
309                 nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
310                 print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
311
312                 g_strfreev (options_arr);
313
314                 return TRUE;
315         }
316         return FALSE;
317 }
318
319 gboolean
320 print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix)
321 {
322         GHashTable *table;
323         guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
324         guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
325         guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
326
327         if (dhcp6 == NULL)
328                 return FALSE;
329
330         table = nm_dhcp6_config_get_options (dhcp6);
331         if (table) {
332                 GHashTableIter table_iter;
333                 gpointer key, value;
334                 char **options_arr = NULL;
335                 int i = 0;
336
337                 nmc->allowed_fields = nmc_fields_dhcp6_config;
338                 nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
339                 nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DHCP6_CONFIG_ALL, nmc->allowed_fields, NULL);
340                 print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
341
342                 options_arr = g_new (char *, g_hash_table_size (table) + 1);
343                 g_hash_table_iter_init (&table_iter, table);
344                 while (g_hash_table_iter_next (&table_iter, &key, &value))
345                         options_arr[i++] = g_strdup_printf ("%s = %s", (char *) key, (char *) value);
346                 options_arr[i] = NULL;
347
348                 set_val_str (nmc->allowed_fields, 0, group_prefix);
349                 set_val_arr (nmc->allowed_fields, 1, (const char **) options_arr);
350
351                 nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
352                 print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
353
354                 g_strfreev (options_arr);
355
356                 return TRUE;
357         }
358         return FALSE;
359 }
360
361 const char *
362 nmc_device_state_to_string (NMDeviceState state)
363 {
364         switch (state) {
365         case NM_DEVICE_STATE_UNMANAGED:
366                 return _("unmanaged");
367         case NM_DEVICE_STATE_UNAVAILABLE:
368                 return _("unavailable");
369         case NM_DEVICE_STATE_DISCONNECTED:
370                 return _("disconnected");
371         case NM_DEVICE_STATE_PREPARE:
372                 return _("connecting (prepare)");
373         case NM_DEVICE_STATE_CONFIG:
374                 return _("connecting (configuring)");
375         case NM_DEVICE_STATE_NEED_AUTH:
376                 return _("connecting (need authentication)");
377         case NM_DEVICE_STATE_IP_CONFIG:
378                 return _("connecting (getting IP configuration)");
379         case NM_DEVICE_STATE_IP_CHECK:
380                 return _("connecting (checking IP connectivity)");
381         case NM_DEVICE_STATE_SECONDARIES:
382                 return _("connecting (starting secondary connections)");
383         case NM_DEVICE_STATE_ACTIVATED:
384                 return _("connected");
385         case NM_DEVICE_STATE_DEACTIVATING:
386                 return _("deactivating");
387         case NM_DEVICE_STATE_FAILED:
388                 return _("connection failed");
389         default:
390                 return _("unknown");
391         }
392 }
393
394 const char *
395 nmc_device_reason_to_string (NMDeviceStateReason reason)
396 {
397         switch (reason) {
398         case NM_DEVICE_STATE_REASON_NONE:
399                 return _("No reason given");
400
401         case NM_DEVICE_STATE_REASON_UNKNOWN:
402                 return _("Unknown error");
403
404         case NM_DEVICE_STATE_REASON_NOW_MANAGED:
405                 return _("Device is now managed");
406
407         case NM_DEVICE_STATE_REASON_NOW_UNMANAGED:
408                 return _("Device is now unmanaged");
409
410         case NM_DEVICE_STATE_REASON_CONFIG_FAILED:
411                 return _("The device could not be readied for configuration");
412
413         case NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE:
414                 return _("IP configuration could not be reserved (no available address, timeout, etc)");
415
416         case NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED:
417                 return _("The IP configuration is no longer valid");
418
419         case NM_DEVICE_STATE_REASON_NO_SECRETS:
420                 return _("Secrets were required, but not provided");
421
422         case NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT:
423                 return _("802.1X supplicant disconnected");
424
425         case NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED:
426                 return _("802.1X supplicant configuration failed");
427
428         case NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED:
429                 return _("802.1X supplicant failed");
430
431         case NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT:
432                 return _("802.1X supplicant took too long to authenticate");
433
434         case NM_DEVICE_STATE_REASON_PPP_START_FAILED:
435                 return _("PPP service failed to start");
436
437         case NM_DEVICE_STATE_REASON_PPP_DISCONNECT:
438                 return _("PPP service disconnected");
439
440         case NM_DEVICE_STATE_REASON_PPP_FAILED:
441                 return _("PPP failed");
442
443         case NM_DEVICE_STATE_REASON_DHCP_START_FAILED:
444                 return _("DHCP client failed to start");
445
446         case NM_DEVICE_STATE_REASON_DHCP_ERROR:
447                 return _("DHCP client error");
448
449         case NM_DEVICE_STATE_REASON_DHCP_FAILED:
450                 return _("DHCP client failed");
451
452         case NM_DEVICE_STATE_REASON_SHARED_START_FAILED:
453                 return _("Shared connection service failed to start");
454
455         case NM_DEVICE_STATE_REASON_SHARED_FAILED:
456                 return _("Shared connection service failed");
457
458         case NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED:
459                 return _("AutoIP service failed to start");
460
461         case NM_DEVICE_STATE_REASON_AUTOIP_ERROR:
462                 return _("AutoIP service error");
463
464         case NM_DEVICE_STATE_REASON_AUTOIP_FAILED:
465                 return _("AutoIP service failed");
466
467         case NM_DEVICE_STATE_REASON_MODEM_BUSY:
468                 return _("The line is busy");
469
470         case NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE:
471                 return _("No dial tone");
472
473         case NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER:
474                 return _("No carrier could be established");
475
476         case NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT:
477                 return _("The dialing request timed out");
478
479         case NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED:
480                 return _("The dialing attempt failed");
481
482         case NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED:
483                 return _("Modem initialization failed");
484
485         case NM_DEVICE_STATE_REASON_GSM_APN_FAILED:
486                 return _("Failed to select the specified APN");
487
488         case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING:
489                 return _("Not searching for networks");
490
491         case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED:
492                 return _("Network registration denied");
493
494         case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT:
495                 return _("Network registration timed out");
496
497         case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED:
498                 return _("Failed to register with the requested network");
499
500         case NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED:
501                 return _("PIN check failed");
502
503         case NM_DEVICE_STATE_REASON_FIRMWARE_MISSING:
504                 return _("Necessary firmware for the device may be missing");
505
506         case NM_DEVICE_STATE_REASON_REMOVED:
507                 return _("The device was removed");
508
509         case NM_DEVICE_STATE_REASON_SLEEPING:
510                 return _("NetworkManager went to sleep");
511
512         case NM_DEVICE_STATE_REASON_CONNECTION_REMOVED:
513                 return _("The device's active connection disappeared");
514
515         case NM_DEVICE_STATE_REASON_USER_REQUESTED:
516                 return _("Device disconnected by user or client");
517
518         case NM_DEVICE_STATE_REASON_CARRIER:
519                 return _("Carrier/link changed");
520
521         case NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED:
522                 return _("The device's existing connection was assumed");
523
524         case NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE:
525                 return _("The supplicant is now available");
526
527         case NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND:
528                 return _("The modem could not be found");
529
530         case NM_DEVICE_STATE_REASON_BT_FAILED:
531                 return _("The Bluetooth connection failed or timed out");
532
533         case NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED:
534                 return _("GSM Modem's SIM card not inserted");
535
536         case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED:
537                 return _("GSM Modem's SIM PIN required");
538
539         case NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED:
540                 return _("GSM Modem's SIM PUK required");
541
542         case NM_DEVICE_STATE_REASON_GSM_SIM_WRONG:
543                 return _("GSM Modem's SIM wrong");
544
545         case NM_DEVICE_STATE_REASON_INFINIBAND_MODE:
546                 return _("InfiniBand device does not support connected mode");
547
548         case NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED:
549                 return _("A dependency of the connection failed");
550
551         case NM_DEVICE_STATE_REASON_BR2684_FAILED:
552                 return _("A problem with the RFC 2684 Ethernet over ADSL bridge");
553
554         default:
555                 return _("Unknown");
556         }
557 }
558