static unsigned int __add_port_match(ip6tables_protocol_type_e prot_type,
ip6tables_port_type_e sport_type, unsigned short sport1, unsigned short sport2,
ip6tables_port_type_e dport_type, unsigned short dport1, unsigned short dport2,
+ unsigned char tcp_flag_mask, unsigned char tcp_flag_compare,
ip6t_entry_match_t *start)
{
switch (prot_type) {
tcp.dpts[1] = 0xFFFF;
break;
}
+ tcp.flg_mask = tcp_flag_mask;
+ tcp.flg_cmp = tcp_flag_compare;
return __add_match(IP6TC_TCP, start, 0, sizeof(ip6t_tcp_info_t), &tcp);
}
case IP6TABLES_PROTOCOL_UDP:
if ((rule->s_port_type > IP6TABLES_PORT_NONE &&
rule->s_port_type <= IP6TABLES_PORT_RANGE) ||
(rule->d_port_type > IP6TABLES_PORT_NONE &&
- rule->d_port_type <= IP6TABLES_PORT_RANGE)) {
+ rule->d_port_type <= IP6TABLES_PORT_RANGE) ||
+ rule->tcp_flag_compare != 0 ||
+ rule->tcp_flag_mask != 0) {
ip6t_entry_t *e = (ip6t_entry_t *)(entry);
(*size_match) += __add_port_match(rule->protocol,
rule->s_port_type, rule->s_port1, rule->s_port2,
rule->d_port_type, rule->d_port1, rule->d_port2,
+ rule->tcp_flag_mask, rule->tcp_flag_compare,
(ip6t_entry_match_t *) (e->elems + (*size_match)));
e->target_offset += match_size;
ip6tables_port_type_e s_port_type;
ip6tables_port_type_e d_port_type;
ip6tables_protocol_type_e protocol;
+ unsigned char tcp_flag_mask;
+ unsigned char tcp_flag_compare;
struct in6_addr s_ip1;
struct in6_addr s_ip2;
struct in6_addr d_ip1;
static unsigned int __add_port_match(iptables_protocol_type_e prot_type,
iptables_port_type_e sport_type, unsigned short sport1, unsigned short sport2,
iptables_port_type_e dport_type, unsigned short dport1, unsigned short dport2,
+ unsigned char tcp_flag_mask, unsigned char tcp_flag_compare,
ipt_entry_match_t *start)
{
switch (prot_type) {
tcp.dpts[1] = 0xFFFF;
break;
}
+ tcp.flg_mask = tcp_flag_mask;
+ tcp.flg_cmp = tcp_flag_compare;
return __add_match(IPTC_TCP, start, 0, sizeof(ipt_tcp_info_t), &tcp);
}
case IPTABLES_PROTOCOL_UDP:
if ((rule->s_port_type > IPTABLES_PORT_NONE &&
rule->s_port_type <= IPTABLES_PORT_RANGE) ||
(rule->d_port_type > IPTABLES_PORT_NONE &&
- rule->d_port_type <= IPTABLES_PORT_RANGE)) {
+ rule->d_port_type <= IPTABLES_PORT_RANGE) ||
+ rule->tcp_flag_compare != 0 ||
+ rule->tcp_flag_mask != 0) {
ipt_entry_t *e = (ipt_entry_t *)(entry);
(*size_match) += __add_port_match(rule->protocol,
rule->s_port_type, rule->s_port1, rule->s_port2,
rule->d_port_type, rule->d_port1, rule->d_port2,
+ rule->tcp_flag_mask, rule->tcp_flag_compare,
(ipt_entry_match_t *) (e->elems + (*size_match)));
e->target_offset += match_size;
iptables_port_type_e s_port_type;
iptables_port_type_e d_port_type;
iptables_protocol_type_e protocol;
+ unsigned char tcp_flag_mask;
+ unsigned char tcp_flag_compare;
struct in_addr s_ip1;
struct in_addr s_ip2;
struct in_addr d_ip1;
#define RULE_CGROUP "cgroup"
#define RULE_NFACCT "nfacct"
#define RULE_PROTOCOL "protocol"
+#define RULE_MASK "tcp_flag_mask"
+#define RULE_COMPARE "tcp_flag_compare"
#define RULE_TARGET "target"
#define RULE_TARGETTYPE "target_type"
rule->protocol = g_variant_get_uint16(value);
STC_LOGD("%s: [%u]", RULE_PROTOCOL, rule->protocol);
+ } else if (!g_strcmp0(key, RULE_MASK)) {
+ if (rule->protocol == IPTABLES_PROTOCOL_TCP) {
+ rule->tcp_flag_mask = g_variant_get_byte(value);
+ STC_LOGD("%s: [%u]", RULE_MASK, rule->tcp_flag_mask);
+ }
+
+ } else if (!g_strcmp0(key, RULE_COMPARE)) {
+ if (rule->protocol == IPTABLES_PROTOCOL_TCP) {
+ rule->tcp_flag_compare = g_variant_get_byte(value);
+ STC_LOGD("%s: [%u]", RULE_COMPARE, rule->tcp_flag_compare);
+ }
+
} else if (!g_strcmp0(key, RULE_TARGET)) {
gsize len = 0;
rule->target = g_variant_dup_string(value, &len);
rule->protocol = g_variant_get_uint16(value);
STC_LOGD("%s: [%u]", RULE_PROTOCOL, rule->protocol);
+ } else if (!g_strcmp0(key, RULE_MASK)) {
+ if (rule->protocol == IP6TABLES_PROTOCOL_TCP) {
+ rule->tcp_flag_mask = g_variant_get_byte(value);
+ STC_LOGD("%s: [%u]", RULE_MASK, rule->tcp_flag_mask);
+ }
+
+ } else if (!g_strcmp0(key, RULE_COMPARE)) {
+ if (rule->protocol == IP6TABLES_PROTOCOL_TCP) {
+ rule->tcp_flag_compare = g_variant_get_byte(value);
+ STC_LOGD("%s: [%u]", RULE_COMPARE, rule->tcp_flag_compare);
+ }
+
} else if (!g_strcmp0(key, RULE_TARGET)) {
gsize len = 0;
rule->target = g_variant_dup_string(value, &len);