a9875081d8006c3e39824cd789342d3039c388ff
[platform/core/connectivity/net-config.git] / plugin / online-monitor / online-monitor.h
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2021 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 <curl/curl.h>
21
22 #include "plugin.h"
23 #include "util.h"
24
25 #ifdef USE_NETCONFIG_LOG
26 #include "log.h"
27 #else
28 #include <dlog.h>
29
30 #define NETCONFIG_TAG           "NETCONFIG"
31 #define __LOG(level, format, arg...) \
32         do { \
33                 SLOG(level, NETCONFIG_TAG, format, ## arg); \
34         } while (0)
35
36 #define DBG(format, arg...)     __LOG(LOG_DEBUG, format, ## arg)
37 #define ERR(format, arg...)     __LOG(LOG_ERROR, format, ## arg)
38 #endif
39
40 #define ONLINE_MONITOR_CONF             "/var/lib/net-config/online_monitor.conf"
41
42 typedef enum {
43         ONLINE_MONITOR_STATE_UNINITIALIZED = 0,
44         ONLINE_MONITOR_STATE_INITIALIZED = 1,
45         ONLINE_MONITOR_STATE_MONITORING_STARTED = 2,
46         ONLINE_MONITOR_STATE_MONITORING_STOPPED = 3,
47         ONLINE_MONITOR_STATE_OFFLINE_DETECTED = 4,
48         ONLINE_MONITOR_STATE_URL_CHECK_SUCCEEDED = 5,
49         ONLINE_MONITOR_STATE_URL_CHECK_FAILED = 6,
50 } online_monitor_state_e;
51
52 typedef enum {
53         ONLINE_MONITOR_DETECTION_NONE = 0,
54         ONLINE_MONITOR_DETECTION_UNREACHABLE = 1,
55         ONLINE_MONITOR_DETECTION_DNS_REFUSED = 2,
56         ONLINE_MONITOR_DETECTION_NO_DNS_RESPONSE = 3,
57 } online_monitor_detection_e;
58
59 typedef struct {
60         gboolean is_enabled;
61         gboolean common_info;
62         gboolean dlog;
63         gboolean supplicant_log;
64         gboolean packet_dump;
65         char **url_list;
66         int max_report_count;
67 } online_monitor_config_t;
68
69 typedef void(*online_monitor_state_chaged_cb)
70                 (online_monitor_state_e state, char *ifname, online_monitor_detection_e reason);
71
72 void online_monitor_url_check_result(gboolean result);
73 void online_monitor_notifier_register(online_monitor_state_chaged_cb notifier);
74 void online_monitor_notifier_unregister(online_monitor_state_chaged_cb notifier);
75 online_monitor_config_t *online_monitor_get_configuration(void);
76
77 int report_manager_init(void);
78 int report_manager_deinit(void);
79 int url_checker_init(void);
80 int url_checker_deinit(void);
81
82