~kvalo/connman/bug-734339

« back to all changes in this revision

Viewing changes to src/device.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel, Alexander Sack, Mathieu Trudel
  • Date: 2009-10-14 23:59:04 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20091014235904-xbulmde9bfcx0wuk
Tags: 0.42+dfsg-0ubuntu1
* new upstream release 0.42 with FFe (LP: #444172)

[ Alexander Sack <asac@ubuntu.com> ]
* LP: #402998 - homepage used in package is outdated; updated to
  http://www.connman.net
  - update debian/control
* LP: #402999 - add Vcs-Browser to debian/control and change Vcs-Bzr
  to read/write location
  - update debian/control
* LP: #400576 - Please use compatible mode to provide NetworkManager
  dbus interface; ship a /etc/default/connman which enables NM
  compatibility mode; also include example how to enable debugging
  - add debian/connman.default
* explicitly install init script
  - debian/connnman.install
* set --only-scripts parameter for dh_installinit (cdbs)
  - update debian/rules

[ Mathieu Trudel <mathieu.tl@gmail.com> ]
* bump Standards-Version to 3.8.3
  - update debian/control 
* add GIT_BRANCH, GIT_BRANCH_NAME, DEB_MAJOR_VERSION to support daily builds
  - update debian/rules
* Add update-local-branch code to work with local git copies
  - update debian/rules 
* Revise get-orig-source code, add get-current-source and GET_SOURCE snippets
  - update debian/rules
* Handle dfsg special case, add MAKE_DFSG_COMPLIANT snippet
  - update debian/rules
* Add pre-build, clean targets
  - update debian/rules 
* Patch init script to add LSB headers (Closes: #543869)
  - add debian/patches/01-init-script-lsb-headers.patch
  - update debian/patches/series

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
        enum connman_device_type type;
38
38
        enum connman_device_mode mode;
39
39
        connman_bool_t secondary;
 
40
        connman_bool_t offlinemode;
 
41
        connman_bool_t blocked;
40
42
        connman_bool_t powered;
 
43
        connman_bool_t powered_pending;
 
44
        connman_bool_t powered_persistent;
41
45
        connman_bool_t carrier;
42
46
        connman_bool_t scanning;
43
47
        connman_bool_t disconnected;
48
52
        char *interface;
49
53
        char *control;
50
54
        char *ident;
 
55
        int phyindex;
51
56
        unsigned int connections;
52
57
        guint scan_timeout;
53
58
        struct connman_ipconfig *ipconfig;
82
87
        return TRUE;
83
88
}
84
89
 
85
 
static void reset_scan_trigger(struct connman_device *device)
 
90
static void clear_scan_trigger(struct connman_device *device)
86
91
{
87
92
        if (device->scan_timeout > 0) {
88
93
                g_source_remove(device->scan_timeout);
89
94
                device->scan_timeout = 0;
90
95
        }
 
96
}
 
97
 
 
98
static void reset_scan_trigger(struct connman_device *device)
 
99
{
 
100
        clear_scan_trigger(device);
91
101
 
92
102
        if (device->scan_interval > 0) {
93
103
                guint interval = device->scan_interval;
96
106
        }
97
107
}
98
108
 
 
109
static void force_scan_trigger(struct connman_device *device)
 
110
{
 
111
        clear_scan_trigger(device);
 
112
 
 
113
        device->scan_timeout = g_timeout_add_seconds(5,
 
114
                                        device_scan_trigger, device);
 
115
}
 
116
 
99
117
static const char *type2description(enum connman_device_type type)
100
118
{
101
119
        switch (type) {
189
207
 
190
208
                switch (device->element.ipv4.method) {
191
209
                case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
192
 
                case CONNMAN_IPCONFIG_METHOD_OFF:
 
210
                case CONNMAN_IPCONFIG_METHOD_IGNORE:
193
211
                        return 0;
194
212
                case CONNMAN_IPCONFIG_METHOD_STATIC:
195
213
                        type = CONNMAN_ELEMENT_TYPE_IPV4;
245
263
 
246
264
static int set_carrier(struct connman_device *device, connman_bool_t carrier)
247
265
{
248
 
        struct connman_service *service;
249
 
 
250
266
        if (carrier == TRUE)
251
267
                __connman_profile_add_device(device);
252
268
        else
253
269
                __connman_profile_remove_device(device);
254
270
 
255
 
        service = __connman_service_lookup_from_device(device);
256
 
        __connman_service_set_carrier(service, carrier);
257
 
 
258
271
        return set_connected(device, carrier);
259
272
}
260
273
 
292
305
 
293
306
        DBG("device %p powered %d", device, powered);
294
307
 
295
 
        if (device->powered == powered)
 
308
        if (device->powered_pending == powered)
296
309
                return -EALREADY;
297
310
 
298
311
        if (!driver)
302
315
 
303
316
        if (powered == TRUE) {
304
317
                if (driver->enable) {
 
318
                        device->powered_pending = powered;
 
319
 
305
320
                        err = driver->enable(device);
306
321
                        if (err == 0)
307
322
                                __connman_notifier_enable(type);
308
323
                } else
309
324
                        err = -EINVAL;
310
325
        } else {
 
326
                device->powered_pending = powered;
 
327
 
 
328
                clear_scan_trigger(device);
 
329
 
311
330
                g_hash_table_remove_all(device->networks);
312
331
 
313
332
                set_carrier(device, FALSE);
322
341
 
323
342
        if (err == 0) {
324
343
                device->powered = powered;
325
 
                powered_changed(device);
 
344
 
 
345
                if (device->registered == TRUE)
 
346
                        powered_changed(device);
326
347
        }
327
348
 
328
349
        return err;
484
505
 
485
506
                dbus_message_iter_get_basic(&value, &powered);
486
507
 
 
508
                device->powered_persistent = powered;
 
509
 
 
510
                __connman_storage_save_device(device);
 
511
 
487
512
                if (device->powered == powered)
488
513
                        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
489
514
 
522
547
                if (device->scan_interval != interval) {
523
548
                        device->scan_interval = interval;
524
549
 
 
550
                        __connman_storage_save_device(device);
 
551
 
525
552
                        reset_scan_trigger(device);
526
553
                }
527
554
        } else if (g_str_has_prefix(name, "IPv4.") == TRUE) {
528
555
                int err;
529
556
 
 
557
                if (device->ipconfig == NULL)
 
558
                        return __connman_error_invalid_property(msg);
 
559
 
530
560
                switch (device->mode) {
531
561
                case CONNMAN_DEVICE_MODE_UNKNOWN:
532
562
                case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
543
573
        } else
544
574
                return __connman_error_invalid_property(msg);
545
575
 
546
 
        __connman_storage_save_device(device);
547
 
 
548
576
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
549
577
}
550
578
 
656
684
                                                CONNMAN_DEVICE_INTERFACE);
657
685
}
658
686
 
659
 
static void device_enable(struct connman_device *device)
660
 
{
661
 
        DBG("device %p", device);
662
 
 
663
 
        if (device->powered == TRUE)
664
 
                return;
665
 
 
666
 
        if (device->driver->enable) {
667
 
                if (device->driver->enable(device) == 0) {
668
 
                        enum connman_service_type type;
669
 
 
670
 
                        device->powered = TRUE;
671
 
 
672
 
                        type = __connman_device_get_service_type(device);
673
 
                        __connman_notifier_enable(type);
674
 
                }
675
 
        }
676
 
}
677
 
 
678
 
static void device_disable(struct connman_device *device)
679
 
{
680
 
        DBG("device %p", device);
681
 
 
682
 
        if (device->powered == FALSE)
683
 
                return;
684
 
 
685
 
        g_hash_table_remove_all(device->networks);
686
 
 
687
 
        if (device->driver->disable) {
688
 
                if (device->driver->disable(device) == 0) {
689
 
                        enum connman_service_type type;
690
 
 
691
 
                        device->powered = FALSE;
692
 
 
693
 
                        type = __connman_device_get_service_type(device);
694
 
                        __connman_notifier_disable(type);
695
 
                }
696
 
        }
697
 
}
698
 
 
699
687
static int setup_device(struct connman_device *device)
700
688
{
 
689
        enum connman_service_type type;
701
690
        int err;
702
691
 
703
692
        DBG("device %p", device);
710
699
                return err;
711
700
        }
712
701
 
 
702
        type = __connman_device_get_service_type(device);
 
703
        __connman_notifier_register(type);
 
704
 
713
705
        switch (device->mode) {
714
706
        case CONNMAN_DEVICE_MODE_UNKNOWN:
715
707
        case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
721
713
                break;
722
714
        }
723
715
 
724
 
        device_enable(device);
 
716
        if (device->offlinemode == FALSE &&
 
717
                                device->powered_persistent == TRUE)
 
718
                __connman_device_enable(device);
725
719
 
726
720
        return 0;
727
721
}
751
745
 
752
746
static void remove_device(struct connman_device *device)
753
747
{
 
748
        enum connman_service_type type;
 
749
 
754
750
        DBG("device %p", device);
755
751
 
756
 
        device_disable(device);
 
752
        __connman_device_disable(device);
757
753
 
758
754
        switch (device->mode) {
759
755
        case CONNMAN_DEVICE_MODE_UNKNOWN:
766
762
                break;
767
763
        }
768
764
 
 
765
        type = __connman_device_get_service_type(device);
 
766
        __connman_notifier_unregister(type);
 
767
 
769
768
        unregister_interface(&device->element);
770
769
 
771
770
        if (device->driver->remove)
876
875
        g_free(device->control);
877
876
        g_free(device->interface);
878
877
 
879
 
        connman_ipconfig_unref(device->ipconfig);
 
878
        if (device->ipconfig != NULL) {
 
879
                connman_ipconfig_unref(device->ipconfig);
 
880
                device->ipconfig = NULL;
 
881
        }
880
882
 
881
883
        g_free(device->last_network);
882
884
 
927
929
        device->mode      = CONNMAN_DEVICE_MODE_UNKNOWN;
928
930
        device->secondary = FALSE;
929
931
 
 
932
        device->powered_persistent = TRUE;
 
933
 
 
934
        device->phyindex = -1;
 
935
 
930
936
        switch (type) {
931
937
        case CONNMAN_DEVICE_TYPE_UNKNOWN:
932
938
        case CONNMAN_DEVICE_TYPE_VENDOR:
954
960
                break;
955
961
        }
956
962
 
957
 
        device->ipconfig = connman_ipconfig_create();
958
 
        if (device->ipconfig == NULL) {
959
 
                connman_device_unref(device);
960
 
                return NULL;
961
 
        }
962
 
 
963
963
        device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
964
964
                                                g_free, unregister_network);
965
965
 
1039
1039
void connman_device_set_index(struct connman_device *device, int index)
1040
1040
{
1041
1041
        device->element.index = index;
 
1042
 
 
1043
        if (device->ipconfig != NULL) {
 
1044
                if (index == connman_ipconfig_get_index(device->ipconfig))
 
1045
                        return;
 
1046
 
 
1047
                connman_ipconfig_unref(device->ipconfig);
 
1048
        }
 
1049
 
 
1050
        device->ipconfig = connman_ipconfig_create(index);
1042
1051
}
1043
1052
 
1044
1053
/**
1052
1061
        return device->element.index;
1053
1062
}
1054
1063
 
 
1064
int __connman_device_get_phyindex(struct connman_device *device)
 
1065
{
 
1066
        return device->phyindex;
 
1067
}
 
1068
 
 
1069
void __connman_device_set_phyindex(struct connman_device *device,
 
1070
                                                        int phyindex)
 
1071
{
 
1072
        device->phyindex = phyindex;
 
1073
}
 
1074
 
1055
1075
/**
1056
1076
 * connman_device_set_interface:
1057
1077
 * @device: device structure
1183
1203
                return -EALREADY;
1184
1204
 
1185
1205
        device->powered = powered;
 
1206
        device->powered_pending = powered;
1186
1207
 
1187
1208
        type = __connman_device_get_service_type(device);
1188
1209
 
1207
1228
        return 0;
1208
1229
}
1209
1230
 
 
1231
int __connman_device_set_blocked(struct connman_device *device,
 
1232
                                                connman_bool_t blocked)
 
1233
{
 
1234
        connman_bool_t powered;
 
1235
 
 
1236
        DBG("device %p blocked %d", device, blocked);
 
1237
 
 
1238
        device->blocked = blocked;
 
1239
 
 
1240
        if (device->offlinemode == TRUE)
 
1241
                return 0;
 
1242
 
 
1243
        if (blocked == FALSE)
 
1244
                powered = device->powered_persistent;
 
1245
        else
 
1246
                powered = FALSE;
 
1247
 
 
1248
        return set_powered(device, powered);
 
1249
}
 
1250
 
1210
1251
/**
1211
1252
 * connman_device_set_carrier:
1212
1253
 * @device: device structure
1244
1285
        if (device->powered == FALSE)
1245
1286
                return -ENOLINK;
1246
1287
 
 
1288
        reset_scan_trigger(device);
 
1289
 
1247
1290
        return device->driver->scan(device);
1248
1291
}
1249
1292
 
1250
1293
int __connman_device_enable(struct connman_device *device)
1251
1294
{
 
1295
        enum connman_service_type type;
 
1296
        int err;
 
1297
 
 
1298
        DBG("device %p", device);
 
1299
 
1252
1300
        if (!device->driver || !device->driver->enable)
1253
1301
                return -EOPNOTSUPP;
1254
1302
 
1255
 
        if (device->powered == TRUE)
 
1303
        if (device->powered_pending == TRUE)
1256
1304
                return -EALREADY;
1257
1305
 
1258
 
        device_enable(device);
 
1306
        device->powered_pending = TRUE;
 
1307
 
 
1308
        err = device->driver->enable(device);
 
1309
        if (err < 0)
 
1310
                return err;
 
1311
 
 
1312
        device->powered = TRUE;
 
1313
 
 
1314
        type = __connman_device_get_service_type(device);
 
1315
        __connman_notifier_enable(type);
1259
1316
 
1260
1317
        return 0;
1261
1318
}
1262
1319
 
 
1320
int __connman_device_enable_persistent(struct connman_device *device)
 
1321
{
 
1322
        DBG("device %p", device);
 
1323
 
 
1324
        device->powered_persistent = TRUE;
 
1325
 
 
1326
        __connman_storage_save_device(device);
 
1327
 
 
1328
        return __connman_device_enable(device);
 
1329
}
 
1330
 
1263
1331
int __connman_device_disable(struct connman_device *device)
1264
1332
{
 
1333
        enum connman_service_type type;
 
1334
        int err;
 
1335
 
 
1336
        DBG("device %p", device);
 
1337
 
1265
1338
        if (!device->driver || !device->driver->disable)
1266
1339
                return -EOPNOTSUPP;
1267
1340
 
1268
1341
        if (device->powered == FALSE)
1269
1342
                return -ENOLINK;
1270
1343
 
1271
 
        device_disable(device);
 
1344
        if (device->powered_pending == FALSE)
 
1345
                return -EALREADY;
 
1346
 
 
1347
        device->powered_pending = FALSE;
 
1348
 
 
1349
        clear_scan_trigger(device);
 
1350
 
 
1351
        g_hash_table_remove_all(device->networks);
 
1352
 
 
1353
        err = device->driver->disable(device);
 
1354
        if (err < 0)
 
1355
                return err;
 
1356
 
 
1357
        device->powered = FALSE;
 
1358
 
 
1359
        type = __connman_device_get_service_type(device);
 
1360
        __connman_notifier_disable(type);
1272
1361
 
1273
1362
        return 0;
1274
1363
}
1275
1364
 
 
1365
int __connman_device_disable_persistent(struct connman_device *device)
 
1366
{
 
1367
        DBG("device %p", device);
 
1368
 
 
1369
        device->powered_persistent = FALSE;
 
1370
 
 
1371
        __connman_storage_save_device(device);
 
1372
 
 
1373
        return __connman_device_disable(device);
 
1374
}
 
1375
 
1276
1376
int __connman_device_connect(struct connman_device *device)
1277
1377
{
1278
1378
        DBG("device %p", device);
1428
1528
 
1429
1529
        device->disconnected = disconnected;
1430
1530
 
 
1531
        if (disconnected == TRUE)
 
1532
                force_scan_trigger(device);
 
1533
 
1431
1534
        return 0;
1432
1535
}
1433
1536
 
1529
1632
        if (device == NULL)
1530
1633
                return;
1531
1634
 
 
1635
        device->offlinemode = offlinemode;
 
1636
 
1532
1637
        powered = (offlinemode == TRUE) ? FALSE : TRUE;
1533
1638
 
1534
1639
        if (device->powered == powered)
1535
1640
                return;
1536
1641
 
 
1642
        if (device->powered_persistent == FALSE)
 
1643
                powered = FALSE;
 
1644
 
1537
1645
        set_powered(device, powered);
1538
1646
}
1539
1647
 
1544
1652
        __connman_element_foreach(NULL, CONNMAN_ELEMENT_TYPE_DEVICE,
1545
1653
                        set_offlinemode, GUINT_TO_POINTER(offlinemode));
1546
1654
 
1547
 
        __connman_notifier_offline_mode(offlinemode);
 
1655
        __connman_notifier_offlinemode(offlinemode);
1548
1656
 
1549
1657
        return 0;
1550
1658
}
1551
1659
 
1552
1660
void __connman_device_increase_connections(struct connman_device *device)
1553
1661
{
1554
 
        enum connman_service_type type;
1555
 
 
1556
1662
        device->connections++;
1557
 
 
1558
 
        type = __connman_device_get_service_type(device);
1559
 
        __connman_notifier_connect(type);
1560
1663
}
1561
1664
 
1562
1665
void __connman_device_decrease_connections(struct connman_device *device)
1563
1666
{
1564
 
        enum connman_service_type type;
1565
 
 
1566
1667
        device->connections--;
1567
 
 
1568
 
        type = __connman_device_get_service_type(device);
1569
 
        __connman_notifier_disconnect(type);
1570
1668
}
1571
1669
 
1572
1670
/**
1595
1693
 
1596
1694
        __connman_network_set_device(network, device);
1597
1695
 
1598
 
        __connman_storage_load_network(network);
1599
 
 
1600
1696
        err = connman_element_register((struct connman_element *) network,
1601
1697
                                                        &device->element);
1602
1698
        if (err < 0) {
1676
1772
 */
1677
1773
int connman_device_register(struct connman_device *device)
1678
1774
{
1679
 
        enum connman_service_type type;
1680
 
 
1681
1775
        __connman_storage_load_device(device);
1682
1776
 
1683
 
        switch (device->mode) {
1684
 
        case CONNMAN_DEVICE_MODE_UNKNOWN:
1685
 
        case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
1686
 
                break;
1687
 
        case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
1688
 
        case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
1689
 
                __connman_storage_init_network(device);
1690
 
                break;
1691
 
        }
1692
 
 
1693
 
        type = __connman_device_get_service_type(device);
1694
 
        __connman_notifier_register(type);
 
1777
        device->offlinemode = __connman_profile_get_offlinemode();
1695
1778
 
1696
1779
        return connman_element_register(&device->element, NULL);
1697
1780
}
1704
1787
 */
1705
1788
void connman_device_unregister(struct connman_device *device)
1706
1789
{
1707
 
        enum connman_service_type type;
1708
 
 
1709
1790
        __connman_storage_save_device(device);
1710
1791
 
1711
 
        type = __connman_device_get_service_type(device);
1712
 
        __connman_notifier_unregister(type);
1713
 
 
1714
1792
        connman_element_unregister(&device->element);
1715
1793
}
1716
1794
 
1805
1883
 
1806
1884
static int device_load(struct connman_device *device)
1807
1885
{
 
1886
        const char *ident = __connman_profile_active_ident();
1808
1887
        GKeyFile *keyfile;
1809
 
        gchar *pathname, *identifier, *data = NULL;
1810
 
        gsize length;
 
1888
        GError *error = NULL;
 
1889
        gchar *identifier;
 
1890
        connman_bool_t powered;
1811
1891
        int val;
1812
1892
 
1813
1893
        DBG("device %p", device);
1814
1894
 
1815
 
        pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR,
1816
 
                                        __connman_profile_active_ident());
1817
 
        if (pathname == NULL)
1818
 
                return -ENOMEM;
1819
 
 
1820
 
        keyfile = g_key_file_new();
1821
 
 
1822
 
        if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) {
1823
 
                g_free(pathname);
1824
 
                return -ENOENT;
1825
 
        }
1826
 
 
1827
 
        g_free(pathname);
1828
 
 
1829
 
        if (g_key_file_load_from_data(keyfile, data, length,
1830
 
                                                        0, NULL) == FALSE) {
1831
 
                g_free(data);
1832
 
                return -EILSEQ;
1833
 
        }
1834
 
 
1835
 
        g_free(data);
 
1895
        keyfile = __connman_storage_open(ident);
 
1896
        if (keyfile == NULL)
 
1897
                return 0;
1836
1898
 
1837
1899
        identifier = g_strdup_printf("device_%s", device->element.name);
1838
1900
        if (identifier == NULL)
1839
1901
                goto done;
1840
1902
 
 
1903
        powered = g_key_file_get_boolean(keyfile, identifier,
 
1904
                                                "Powered", &error);
 
1905
        if (error == NULL)
 
1906
                device->powered_persistent = powered;
 
1907
        g_clear_error(&error);
 
1908
 
1841
1909
        switch (device->mode) {
1842
1910
        case CONNMAN_DEVICE_MODE_UNKNOWN:
1843
1911
        case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
1845
1913
        case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
1846
1914
        case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
1847
1915
                val = g_key_file_get_integer(keyfile, identifier,
1848
 
                                                        "ScanInterval", NULL);
1849
 
                if (val > 0)
 
1916
                                                "ScanInterval", &error);
 
1917
                if (error == NULL && val > 0)
1850
1918
                        device->scan_interval = val;
 
1919
                g_clear_error(&error);
1851
1920
                break;
1852
1921
        }
1853
1922
 
1854
1923
done:
1855
 
        g_key_file_free(keyfile);
1856
 
 
1857
1924
        g_free(identifier);
1858
1925
 
 
1926
        __connman_storage_close(ident, keyfile, FALSE);
 
1927
 
1859
1928
        return 0;
1860
1929
}
1861
1930
 
1862
1931
static int device_save(struct connman_device *device)
1863
1932
{
 
1933
        const char *ident = __connman_profile_active_ident();
1864
1934
        GKeyFile *keyfile;
1865
 
        gchar *pathname, *identifier = NULL, *data = NULL;
1866
 
        gsize length;
 
1935
        gchar *identifier;
1867
1936
 
1868
1937
        DBG("device %p", device);
1869
1938
 
1870
 
        pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR,
1871
 
                                        __connman_profile_active_ident());
1872
 
        if (pathname == NULL)
1873
 
                return -ENOMEM;
1874
 
 
1875
 
        keyfile = g_key_file_new();
1876
 
 
1877
 
        if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE)
1878
 
                goto update;
1879
 
 
1880
 
        if (length > 0) {
1881
 
                if (g_key_file_load_from_data(keyfile, data, length,
1882
 
                                                        0, NULL) == FALSE)
1883
 
                        goto done;
1884
 
        }
1885
 
 
1886
 
        g_free(data);
1887
 
 
1888
 
update:
 
1939
        keyfile = __connman_storage_open(ident);
 
1940
        if (keyfile == NULL)
 
1941
                return 0;
 
1942
 
1889
1943
        identifier = g_strdup_printf("device_%s", device->element.name);
1890
1944
        if (identifier == NULL)
1891
1945
                goto done;
1892
1946
 
 
1947
        g_key_file_set_boolean(keyfile, identifier,
 
1948
                                        "Powered", device->powered_persistent);
 
1949
 
1893
1950
        switch (device->mode) {
1894
1951
        case CONNMAN_DEVICE_MODE_UNKNOWN:
1895
1952
        case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
1902
1959
                break;
1903
1960
        }
1904
1961
 
1905
 
        data = g_key_file_to_data(keyfile, &length, NULL);
1906
 
 
1907
 
        if (g_file_set_contents(pathname, data, length, NULL) == FALSE)
1908
 
                connman_error("Failed to store device information");
1909
 
 
1910
1962
done:
1911
 
        g_free(data);
1912
 
 
1913
 
        g_key_file_free(keyfile);
1914
 
 
1915
1963
        g_free(identifier);
1916
 
        g_free(pathname);
 
1964
 
 
1965
        __connman_storage_close(ident, keyfile, TRUE);
1917
1966
 
1918
1967
        return 0;
1919
1968
}