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