4 * Copyright (c) 2012-2014 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @desc API for nfacct module
24 * Copyright (c) 2012-2014 Samsung Electronics Co., Ltd. All rights reserved.
28 #ifndef _RESOURCED_NFACCT_RULE_H
29 #define _RESOURCED_NFACCT_RULE_H
32 #include "data_usage.h"
35 #include <sys/types.h>
39 NFACCT_COUNTER_UNKNOWN,
40 NFACCT_COUNTER_IN = (1 << 1),
41 NFACCT_COUNTER_OUT = (1 << 2),
42 NFACCT_COUNTER_LAST_ELEM
43 } nfacct_rule_direction;
46 NFACCT_ACTION_UNKNOWN,
50 NFACCT_ACTION_LAST_ELEM,
57 NFACCT_JUMP_LAST_ELEM,
64 NFACCT_RULE_LAST_ELEM,
68 char name[MAX_NAME_LENGTH];
69 char ifname[MAX_NAME_LENGTH];
73 resourced_iface_type iftype;
74 nfacct_rule_direction iotype;
75 nfacct_rule_intend intend;
76 struct counter_arg *carg;
77 resourced_ret_c(*iptables_rule)(struct nfacct_rule *counter);
83 void generate_counter_name(struct nfacct_rule *counter);
84 bool recreate_counter_by_name(char *cnt_name, struct nfacct_rule *counter);
86 resourced_ret_c nfacct_send_get(struct counter_arg *carg);
87 resourced_ret_c nfacct_send_initiate(struct counter_arg *carg);
89 resourced_ret_c exec_iptables_cmd(const char *cmd_buf, pid_t *pid);
90 resourced_ret_c produce_net_rule(struct nfacct_rule *rule,
91 const int send_limit, const int rcv_limit,
92 const nfacct_rule_action action,
93 const nfacct_rule_jump jump,
94 const nfacct_rule_direction iotype);
96 #endif /* _RESOURCED_NFACCT_RULE_H */