Removed unwanted function send_net_restriction() and its related code. 67/133767/1
authorNishant Chaprana <n.chaprana@samsung.com>
Tue, 13 Jun 2017 09:12:11 +0000 (14:42 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Tue, 13 Jun 2017 09:12:11 +0000 (14:42 +0530)
Change-Id: I68390c4d018778f6811fc1a9f2c0852b7aca1317
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/transmission.h [moved from src/configure/include/transmission.h with 100% similarity]
src/configure/include/netlink-restriction.h [deleted file]
src/configure/nf-restriction.c [deleted file]
src/monitor/include/stc-monitor.h
src/monitor/stc-monitor.c

diff --git a/src/configure/include/netlink-restriction.h b/src/configure/include/netlink-restriction.h
deleted file mode 100755 (executable)
index 069a4a3..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- *  @file net-restriction.h
- *  @desc Performance management API. Network restriction.
- *  @version 1.0
- *
- *  Created on: Jun 18, 2012
- */
-
-#ifndef __STC_NET_RESTRICTION_H__
-#define __STC_NET_RESTRICTION_H__
-
-#include <sys/types.h>
-
-#include "stc-manager.h"
-#include "transmission.h"
-
-/**
- * @brief Send network restriction for specific classid
- * rst_type - type of restriction on the basis of which the restriction
- * can be applied, removed or excluded.
- * classid - id, that generated for each application in the cgroup
- * quota_id - quota_id to store in nf_cntr tree
- * iftype - network interface type to process restriction
- * send_limit - amount number of engress bytes allowed for restriction
- * rcv_limit - amount number of ingress bytes allowed for restriction
- * snd_warning_limit - threshold for warning notification on engress bytes
- * rcv_warning_limit - threshold for warning notification on ingress bytes
- */
-int send_net_restriction(const enum traffic_restriction_type rst_type,
-                        const guint32 classid, const int quota_id,
-                        const stc_iface_type_e iftype,
-                        const int64_t send_limit, const int64_t rcv_limit,
-                        const int64_t snd_warning_threshold,
-                        const int64_t rcv_warning_threshold,
-                        const char *ifname);
-
-#endif /* __STC_NET_RESTRICTION_H__ */
diff --git a/src/configure/nf-restriction.c b/src/configure/nf-restriction.c
deleted file mode 100755 (executable)
index 2423ee0..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * @file nf-restriction.c
- *
- * @desc Implementation for set up/down restrictions.
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- */
-
-#include "stc-error.h"
-#include "stc-manager.h"
-#include "netlink-restriction.h"
-#include "helper-nfacct-rule.h"
-#include "helper-restriction.h"
-#include "stc-default-connection.h"
-#include "stc-monitor.h"
-#include "counter.h"
-
-static stc_error_e apply_net_restriction(struct nfacct_rule *rule,
-                                        const int64_t send_limit,
-                                        const int64_t rcv_limit)
-{
-       nfacct_rule_jump jump;
-
-       /* block immediately */
-       if (!rcv_limit) { /* for dual nfacct entity for restriction add || !send_limit */
-               return produce_net_rule(rule, 0, 0, NFACCT_ACTION_INSERT,
-                                       NFACCT_JUMP_REJECT, NFACCT_COUNTER_OUT);
-       }
-
-       jump = ((rule->intend == NFACCT_WARN) ?
-               NFACCT_JUMP_ACCEPT : NFACCT_JUMP_REJECT);
-
-       return produce_net_rule(rule, send_limit, rcv_limit,
-                               NFACCT_ACTION_APPEND, jump,
-                               NFACCT_COUNTER_IN | NFACCT_COUNTER_OUT);
-}
-
-static stc_error_e revert_net_restriction(struct nfacct_rule *rule,
-                                         const int64_t send_limit,
-                                         const int64_t rcv_limit)
-{
-       nfacct_rule_jump jump = ((rule->intend == NFACCT_WARN) ?
-                                NFACCT_JUMP_ACCEPT : NFACCT_JUMP_REJECT);
-
-       return produce_net_rule(rule, send_limit, rcv_limit,
-                               NFACCT_ACTION_DELETE, jump,
-                               NFACCT_COUNTER_IN | NFACCT_COUNTER_OUT);
-
-}
-
-static stc_error_e exclude_net_restriction(struct nfacct_rule *rule)
-{
-       /* Idea to remove old counter and insert new one at first position
-        * iptables has following architecture: it gets all entries from kernel
-        * modifies this list and returns it back, without iptables it could be
-        * done for one step, but with iptables cmd 2 steps is necessary */
-       rule->intend = NFACCT_COUNTER;
-       stc_error_e ret = produce_net_rule(rule, 0, 0, NFACCT_ACTION_DELETE,
-                                          NFACCT_JUMP_UNKNOWN,
-                                          NFACCT_COUNTER_IN | NFACCT_COUNTER_OUT);
-
-       ret_value_msg_if(ret != STC_ERROR_NONE, ret, "Failed to delete");
-
-       return produce_net_rule(rule, 0, 0,
-                               NFACCT_ACTION_INSERT, NFACCT_JUMP_UNKNOWN,
-                               NFACCT_COUNTER_IN | NFACCT_COUNTER_OUT);
-}
-
-stc_error_e send_net_restriction(const enum traffic_restriction_type rst_type,
-                                const guint32 classid, const int quota_id,
-                                const stc_iface_type_e iftype,
-                                const int64_t send_limit,
-                                const int64_t rcv_limit,
-                                const int64_t snd_warning_threshold,
-                                const int64_t rcv_warning_threshold,
-                                const char *ifname)
-{
-       int ret;
-       stc_s *stc = stc_get_manager();
-       struct counter_arg *carg;
-       struct nfacct_rule rule = {
-               .name = {0},
-               .ifname = {0},
-               .quota_id = quota_id,
-       };
-
-       rule.rst_state = convert_to_restriction_state(rst_type);
-
-       ret_value_msg_if(stc == NULL, STC_ERROR_FAIL, "Can't get stc data");
-       if (!stc->carg) {
-               stc->carg = MALLOC0(counter_arg_s, 1);
-               stc->carg->sock = stc_monitor_get_counter_socket();
-       }
-
-       carg = stc->carg;
-       ret_value_msg_if(carg == NULL, STC_ERROR_FAIL, "Empty counter");
-
-       rule.classid = classid;
-       rule.iftype = iftype;
-       rule.carg = carg;
-       rule.roaming = stc_default_connection_get_roaming();
-       STRING_SAVE_COPY(rule.ifname, ifname);
-
-       if (rst_type == RST_SET) {
-               /* snd_warning_threshold && */
-               if (rcv_warning_threshold) {
-                       rule.intend = NFACCT_WARN;
-                       ret = apply_net_restriction(&rule,
-                                                   snd_warning_threshold,
-                                                   rcv_warning_threshold);
-                       ret_value_msg_if(ret != STC_ERROR_NONE, ret,
-                                        "Can't apply network restriction");
-               }
-               rule.intend = NFACCT_BLOCK;
-               ret = apply_net_restriction(&rule, send_limit, rcv_limit);
-               ret_value_msg_if(ret != STC_ERROR_NONE, ret,
-                                "Can't apply network restriction");
-       } else if (rst_type == RST_UNSET) {
-               rule.intend = NFACCT_WARN;
-               ret = revert_net_restriction(&rule,
-                                            snd_warning_threshold,
-                                            rcv_warning_threshold);
-               ret_value_msg_if(ret != STC_ERROR_NONE, ret,
-                                "Can't revert network restriction");
-               rule.intend = NFACCT_BLOCK;
-               return revert_net_restriction(&rule, send_limit,
-                                             rcv_limit);
-       } else if (rst_type == RST_EXCLUDE)
-               return exclude_net_restriction(&rule);
-
-       return STC_ERROR_NONE;
-}
index feb0f12..07b4715 100644 (file)
@@ -24,7 +24,6 @@
 #include "stc-manager-util.h"
 #include "table-restrictions.h"
 #include "helper-nl.h"
-#include "netlink-restriction.h"
 
 /* 1 seconds */
 #define CONTR_TIMER_INTERVAL 1
index a0a58ff..1dac02f 100755 (executable)
@@ -413,15 +413,6 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                 effective_limit.in_bytes, effective_limit.out_bytes,
                 effective_warn_limit.in_bytes, effective_warn_limit.out_bytes);
 
-       send_net_restriction(rst_type,
-                            rstn_value->classid,
-                            0 /*quota_id*/,
-                            connection->type,
-                            effective_limit.out_bytes,
-                            effective_limit.in_bytes,
-                            effective_warn_limit.out_bytes,
-                            effective_warn_limit.in_bytes,
-                            connection->ifname);
        switch (rst_type) {
        case RST_SET:
                rstn_value->rst_state = STC_RESTRICTION_ACTIVATED;