Implement sending 'enable ethernet' to the ConnMan
[platform/core/connectivity/wifi-mesh-manager.git] / src / meshd.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include <glib.h>
25
26 #include "mesh.h"
27 #include "mesh-log.h"
28 #include "mesh-util.h"
29 #include "mesh-service.h"
30 #include "mesh-service-interface.h"
31
32 /**< mesh service */
33 mesh_service *meshsvc;
34
35 int main(int argc, char *argv[])
36 {
37         mesh_service *service = NULL;
38         int ret_code = 0;
39         gboolean ret;
40
41         __MESH_LOG_FUNC_ENTER__;
42
43 #if !GLIB_CHECK_VERSION(2, 32, 0)
44         if (!g_thread_supported())
45                 g_thread_init(NULL);
46 #endif
47
48 #if !GLIB_CHECK_VERSION(2, 36, 0)
49         g_type_init();
50 #endif
51         NOTUSED(argc);
52         NOTUSED(argv);
53
54         MESH_LOGI("service mainloop start");
55
56         /* Create mesh service */
57         meshsvc = service = meshd_service_new();
58
59         /* Initialize mesh service interface layer */
60         ret = meshd_service_interface_init(service);
61         if (G_UNLIKELY(FALSE == ret)) {
62                 MESH_LOGE("meshd_service_interface_init failed!");
63                 goto END;
64         }
65
66         /* Run mesh service */
67         ret = meshd_service_run(service);
68         if (G_UNLIKELY(FALSE == ret)) {
69                 MESH_LOGE("Run service failed!");
70                 ret_code = EXIT_FAILURE;
71         }
72
73 END:
74         /* Free mesh service */
75         meshd_service_interface_deinit(service);
76         meshd_service_free(service);
77         meshsvc = NULL;
78
79         __MESH_LOG_FUNC_EXIT__;
80         return 0;
81 }
82