+static stc_error_e __add_iptables_tether_in(struct nfacct_rule *counter,
+ const gchar *ipaddr)
+{
+ int ret;
+
+ if (counter == NULL || ipaddr == NULL)
+ return STC_ERROR_INVALID_PARAMETER;
+
+ counter->action = NFACCT_ACTION_INSERT;
+ counter->iotype = NFACCT_COUNTER_IN;
+ counter->jump = __get_jump_by_intend(counter);
+ counter->iptype = NFACCT_TYPE_IPV4;
+ counter->send_limit = 0;
+ counter->rcv_limit = 0;
+ counter->src_iprange_type = NFACCT_IPRANGE_TYPE_SINGLE;
+ counter->src_ip1 = g_strdup(ipaddr);
+
+ ret = produce_net_rule(counter);
+
+ g_free(counter->src_ip1);
+ counter->src_iprange_type = NFACCT_IPRANGE_TYPE_NONE;
+ return ret;
+}
+
+static stc_error_e __add_iptables_tether_out(struct nfacct_rule *counter,
+ const gchar *ipaddr)
+{
+ int ret;
+
+ if (counter == NULL || ipaddr == NULL)
+ return STC_ERROR_INVALID_PARAMETER;
+
+ counter->action = NFACCT_ACTION_INSERT;
+ counter->iotype = NFACCT_COUNTER_OUT;
+ counter->jump = __get_jump_by_intend(counter);
+ counter->iptype = NFACCT_TYPE_IPV4;
+ counter->send_limit = 0;
+ counter->rcv_limit = 0;
+ counter->dst_iprange_type = NFACCT_IPRANGE_TYPE_SINGLE;
+ counter->dst_ip1 = g_strdup(ipaddr);
+
+ ret = produce_net_rule(counter);
+
+ g_free(counter->dst_ip1);
+ counter->dst_iprange_type = NFACCT_IPRANGE_TYPE_NONE;
+ return ret;
+}
+
+static stc_error_e __del_iptables_tether_in(struct nfacct_rule *counter,
+ const gchar *ipaddr)
+{
+ int ret;
+
+ if (counter == NULL || ipaddr == NULL)
+ return STC_ERROR_INVALID_PARAMETER;
+
+ counter->action = NFACCT_ACTION_DELETE;
+ counter->iotype = NFACCT_COUNTER_IN;
+ counter->jump = __get_jump_by_intend(counter);
+ counter->iptype = NFACCT_TYPE_IPV4;
+ counter->send_limit = 0;
+ counter->rcv_limit = 0;
+ counter->src_iprange_type = NFACCT_IPRANGE_TYPE_SINGLE;
+ counter->src_ip1 = g_strdup(ipaddr);
+
+ ret = produce_net_rule(counter);
+
+ g_free(counter->src_ip1);
+ counter->src_iprange_type = NFACCT_IPRANGE_TYPE_NONE;
+ return ret;
+}
+
+static stc_error_e __del_iptables_tether_out(struct nfacct_rule *counter,
+ const gchar *ipaddr)
+{
+ int ret;
+
+ if (counter == NULL || ipaddr == NULL)
+ return STC_ERROR_INVALID_PARAMETER;
+
+ counter->action = NFACCT_ACTION_DELETE;
+ counter->iotype = NFACCT_COUNTER_OUT;
+ counter->jump = __get_jump_by_intend(counter);
+ counter->iptype = NFACCT_TYPE_IPV4;
+ counter->send_limit = 0;
+ counter->rcv_limit = 0;
+ counter->dst_iprange_type = NFACCT_IPRANGE_TYPE_SINGLE;
+ counter->dst_ip1 = g_strdup(ipaddr);
+
+ ret = produce_net_rule(counter);
+
+ g_free(counter->dst_ip1);
+ counter->dst_iprange_type = NFACCT_IPRANGE_TYPE_NONE;
+ return ret;
+}
+