2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __STC_PLUGIN_MONITOR_RSTN_H__
18 #define __STC_PLUGIN_MONITOR_RSTN_H__
22 #include "stc-error.h"
23 #include "stc-manager.h"
24 #include "stc-plugin-monitor-context.h"
25 #include "stc-plugin-monitor-connection.h"
26 #include "stc-restriction.h"
27 #include "table-restrictions.h"
29 #define GRANULARITY 10
31 #define MAX_INT_LENGTH 128
32 #define MAX_KEY_LENGTH 128
35 STC_RSTN_LIMIT_TYPE_DATA_WARN,
36 STC_RSTN_LIMIT_TYPE_DATA,
37 STC_RSTN_LIMIT_TYPE_MONTHLY,
38 STC_RSTN_LIMIT_TYPE_WEEKLY,
39 STC_RSTN_LIMIT_TYPE_DAILY,
40 STC_RSTN_LIMIT_TYPE_MAX
41 } stc_rstn_limit_type_e;
44 STC_RSTN_STATE_INIT = -1,
47 } stc_rstn_noti_state_e;
52 stc_iface_type_e iftype;
55 stc_roaming_type_e roaming;
58 uint64_t restriction_id;
59 stc_rstn_state_e rstn_state;
60 stc_rstn_type_e rstn_type;
62 int64_t counter[STC_RSTN_LIMIT_TYPE_MAX];
63 int64_t limit[STC_RSTN_LIMIT_TYPE_MAX];
64 int32_t limit_exceeded;
65 int32_t limit_notified;
68 time_t month_start_ts;
76 time_t month_start_ts;
82 } stc_rstn_cumulative_data_s;
85 stc_error_e stc_plugin_monitor_rstn_add(const table_restrictions_info *info);
86 stc_error_e stc_plugin_monitor_rstn_remove(const table_restrictions_info *info);
89 void stc_monitor_rstn_reset_time_counters_if_required(void);
90 void stc_monitor_rstn_update_counter(gpointer data,
92 void stc_monitor_rstn_update_iface_counter(classid_bytes_context_s *context);
93 void stc_monitor_rstn_action_when_limit_exceeded(stc_rstn_limit_type_e limit_type,
94 stc_rstn_data_s *rstn_data,
95 classid_bytes_context_s *context);
96 gboolean stc_monitor_rstn_flush_contr_to_db(gpointer user_data);
97 void stc_monitor_rstn_add_for_app(uint32_t classid);
98 void stc_monitor_rstn_add_by_connection(stc_connection_s *conn);
99 void stc_monitor_rstn_remove_for_app(uint32_t classid);
100 void stc_monitor_rstn_remove_by_connection(stc_connection_s *conn);
101 void stc_monitor_rstns_load(void);
102 GHashTable *stc_monitor_rstns_init(void);
104 #endif /* __STC_PLUGIN_MONITOR_RSTN_H__ */