2 * Copyright (c) 2016 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_NFACCT_RULE_H__
18 #define __STC_NFACCT_RULE_H__
23 #include <sys/types.h>
26 #include "helper-nl.h"
28 #define NFACCT_NAME_MAX 32
31 NFACCT_COUNTER_UNKNOWN,
32 NFACCT_COUNTER_IN = (1 << 1),
33 NFACCT_COUNTER_OUT = (1 << 2),
34 NFACCT_COUNTER_FORWARD = (1 << 3),
35 NFACCT_COUNTER_LAST_ELEM
36 } nfacct_rule_direction;
39 NFACCT_ACTION_UNKNOWN,
43 NFACCT_ACTION_LAST_ELEM,
50 NFACCT_JUMP_LAST_ELEM,
62 NFACCT_RULE_LAST_ELEM,
69 NFACCT_TYPE_IPV4_IPV6,
74 NFACCT_IPRANGE_TYPE_NONE,
75 NFACCT_IPRANGE_TYPE_SINGLE,
76 NFACCT_IPRANGE_TYPE_MASK,
77 NFACCT_IPRANGE_TYPE_RANGE,
78 } nfacct_rule_iprange_type;
80 enum nfnl_acct_flags {
81 NFACCT_F_QUOTA_PKTS = (1 << 0),
82 NFACCT_F_QUOTA_BYTES = (1 << 1),
83 NFACCT_F_OVERQUOTA = (1 << 2), /* can't be set from userspace */
88 * base nfacct_rule with following fields:
89 * name, ifname, pid, classid, iftype, intend, carg, iptables_rule
91 * and inherited nfacct_rule_counter and nfacct_rule_restriction
92 * with additional field:
93 * quota, quota_id, roaming, rstn_state
95 * But ANSI C doesn't support inheritance.
98 char name[NFACCT_NAME_MAX];
99 char ifname[MAX_IFACE_LENGTH];
103 stc_iface_type_e iftype;
104 nfacct_rule_action action;
105 nfacct_rule_direction iotype;
106 nfacct_rule_intend intend;
107 nfacct_rule_jump jump; /* in most cases jump is evalutation based on intend, but not always */
108 stc_app_state_e app_state;
109 stc_rstn_state_e rstn_state;
110 nfacct_rule_iptype iptype;
111 nfacct_rule_iprange_type src_iprange_type;
112 nfacct_rule_iprange_type dst_iprange_type;
118 struct counter_arg *carg;
119 stc_error_e(*iptables_rule)(struct nfacct_rule *counter);
122 stc_roaming_type_e roaming;
128 typedef struct nfacct_rule nfacct_rule_s;
132 void generate_counter_name(nfacct_rule_s *counter);
133 bool recreate_counter_by_name(char *cnt_name, nfacct_rule_s *counter);
135 stc_error_e nfacct_send_get_all(struct counter_arg *carg);
136 stc_error_e produce_net_rule(nfacct_rule_s *rule);
138 netlink_serialization_command *
139 netlink_create_command(struct netlink_serialization_params *params);
141 #endif /* __STC_NFACCT_RULE_H__ */