summaryrefslogtreecommitdiffstats
path: root/iptables
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-02-01 19:24:38 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-02-16 19:30:25 +0100
commit6b60dc5be58a5781cacc4e6f238454d5e8421760 (patch)
treebe23e91f26e5295c12cd69ee5091454345cfaa6b /iptables
parentca9a1a6a9f64ee5d94038abb451b27cc9581c81b (diff)
extensions: rename xt_buf to xt_xlate
Use a more generic name for this object to prepare the introduction of other translation specific fields. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables')
-rw-r--r--iptables/nft-ipv4.c20
-rw-r--r--iptables/nft-ipv6.c22
-rw-r--r--iptables/nft-shared.h4
-rw-r--r--iptables/nft.h4
-rw-r--r--iptables/xtables-translate.c30
5 files changed, 40 insertions, 40 deletions
diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
index ede8f176..5e2857d3 100644
--- a/iptables/nft-ipv4.c
+++ b/iptables/nft-ipv4.c
@@ -429,24 +429,24 @@ static void nft_ipv4_save_counters(const void *data)
save_counters(cs->counters.pcnt, cs->counters.bcnt);
}
-static int nft_ipv4_xlate(const void *data, struct xt_buf *buf)
+static int nft_ipv4_xlate(const void *data, struct xt_xlate *xl)
{
const struct iptables_command_state *cs = data;
int ret;
if (cs->fw.ip.iniface[0] != '\0') {
- xt_buf_add(buf, "iifname %s%s ",
+ xt_xlate_add(xl, "iifname %s%s ",
cs->fw.ip.invflags & IPT_INV_VIA_IN ? "!= " : "",
cs->fw.ip.iniface);
}
if (cs->fw.ip.outiface[0] != '\0') {
- xt_buf_add(buf, "oifname %s%s ",
+ xt_xlate_add(xl, "oifname %s%s ",
cs->fw.ip.invflags & IPT_INV_VIA_OUT? "!= " : "",
cs->fw.ip.outiface);
}
if (cs->fw.ip.flags & IPT_F_FRAG) {
- xt_buf_add(buf, "ip frag-off %s%x ",
+ xt_xlate_add(xl, "ip frag-off %s%x ",
cs->fw.ip.invflags & IPT_INV_FRAG? "" : "!= ", 0);
}
@@ -459,7 +459,7 @@ static int nft_ipv4_xlate(const void *data, struct xt_buf *buf)
snprintf(protonum, sizeof(protonum), "%u",
cs->fw.ip.proto);
protonum[sizeof(protonum) - 1] = '\0';
- xt_buf_add(buf, "ip protocol %s%s ",
+ xt_xlate_add(xl, "ip protocol %s%s ",
cs->fw.ip.invflags & IPT_INV_PROTO ?
"!= " : "",
pent ? pent->p_name : protonum);
@@ -467,24 +467,24 @@ static int nft_ipv4_xlate(const void *data, struct xt_buf *buf)
}
if (cs->fw.ip.src.s_addr != 0) {
- xt_buf_add(buf, "ip saddr %s%s ",
+ xt_xlate_add(xl, "ip saddr %s%s ",
cs->fw.ip.invflags & IPT_INV_SRCIP ? "!= " : "",
inet_ntoa(cs->fw.ip.src));
}
if (cs->fw.ip.dst.s_addr != 0) {
- xt_buf_add(buf, "ip daddr %s%s ",
+ xt_xlate_add(xl, "ip daddr %s%s ",
cs->fw.ip.invflags & IPT_INV_DSTIP ? "!= " : "",
inet_ntoa(cs->fw.ip.dst));
}
- ret = xlate_matches(cs, buf);
+ ret = xlate_matches(cs, xl);
if (!ret)
return ret;
/* Always add counters per rule, as in iptables */
- xt_buf_add(buf, "counter ");
+ xt_xlate_add(xl, "counter ");
- ret = xlate_action(cs, !!(cs->fw.ip.flags & IPT_F_GOTO), buf);
+ ret = xlate_action(cs, !!(cs->fw.ip.flags & IPT_F_GOTO), xl);
return ret;
}
diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
index 0b6ff97e..77ac5b80 100644
--- a/iptables/nft-ipv6.c
+++ b/iptables/nft-ipv6.c
@@ -378,7 +378,7 @@ static void nft_ipv6_save_counters(const void *data)
}
static void xlate_ipv6_addr(const char *selector, const struct in6_addr *addr,
- int invert, struct xt_buf *buf)
+ int invert, struct xt_xlate *xl)
{
char addr_str[INET6_ADDRSTRLEN];
@@ -386,22 +386,22 @@ static void xlate_ipv6_addr(const char *selector, const struct in6_addr *addr,
return;
inet_ntop(AF_INET6, addr, addr_str, INET6_ADDRSTRLEN);
- xt_buf_add(buf, "%s %s%s ", selector, invert ? "!= " : "", addr_str);
+ xt_xlate_add(xl, "%s %s%s ", selector, invert ? "!= " : "", addr_str);
}
-static int nft_ipv6_xlate(const void *data, struct xt_buf *buf)
+static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl)
{
const struct iptables_command_state *cs = data;
int ret;
if (cs->fw6.ipv6.iniface[0] != '\0') {
- xt_buf_add(buf, "iifname %s%s ",
+ xt_xlate_add(xl, "iifname %s%s ",
cs->fw6.ipv6.invflags & IP6T_INV_VIA_IN ?
"!= " : "",
cs->fw6.ipv6.iniface);
}
if (cs->fw6.ipv6.outiface[0] != '\0') {
- xt_buf_add(buf, "oifname %s%s ",
+ xt_xlate_add(xl, "oifname %s%s ",
cs->fw6.ipv6.invflags & IP6T_INV_VIA_OUT ?
"!= " : "",
cs->fw6.ipv6.outiface);
@@ -416,7 +416,7 @@ static int nft_ipv6_xlate(const void *data, struct xt_buf *buf)
snprintf(protonum, sizeof(protonum), "%u",
cs->fw6.ipv6.proto);
protonum[sizeof(protonum) - 1] = '\0';
- xt_buf_add(buf, "ip6 nexthdr %s%s ",
+ xt_xlate_add(xl, "ip6 nexthdr %s%s ",
cs->fw6.ipv6.invflags & IP6T_INV_PROTO ?
"!= " : "",
pent ? pent->p_name : protonum);
@@ -424,18 +424,18 @@ static int nft_ipv6_xlate(const void *data, struct xt_buf *buf)
}
xlate_ipv6_addr("ip6 saddr", &cs->fw6.ipv6.src,
- cs->fw6.ipv6.invflags & IP6T_INV_SRCIP, buf);
+ cs->fw6.ipv6.invflags & IP6T_INV_SRCIP, xl);
xlate_ipv6_addr("ip6 daddr", &cs->fw6.ipv6.dst,
- cs->fw6.ipv6.invflags & IP6T_INV_DSTIP, buf);
+ cs->fw6.ipv6.invflags & IP6T_INV_DSTIP, xl);
- ret = xlate_matches(cs, buf);
+ ret = xlate_matches(cs, xl);
if (!ret)
return ret;
/* Always add counters per rule, as in iptables */
- xt_buf_add(buf, "counter ");
+ xt_xlate_add(xl, "counter ");
- ret = xlate_action(cs, !!(cs->fw6.ipv6.flags & IP6T_F_GOTO), buf);
+ ret = xlate_action(cs, !!(cs->fw6.ipv6.flags & IP6T_F_GOTO), xl);
return ret;
}
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
index 73861833..c0948fd4 100644
--- a/iptables/nft-shared.h
+++ b/iptables/nft-shared.h
@@ -37,7 +37,7 @@
#define FMT(tab,notab) ((format) & FMT_NOTABLE ? (notab) : (tab))
struct xtables_args;
-struct xt_buf;
+struct xt_xlate;
enum {
NFT_XT_CTX_PAYLOAD = (1 << 0),
@@ -102,7 +102,7 @@ struct nft_family_ops {
void (*parse_target)(struct xtables_target *t, void *data);
bool (*rule_find)(struct nft_family_ops *ops, struct nftnl_rule *r,
void *data);
- int (*xlate)(const void *data, struct xt_buf *buf);
+ int (*xlate)(const void *data, struct xt_xlate *xl);
};
void add_meta(struct nftnl_rule *r, uint32_t key);
diff --git a/iptables/nft.h b/iptables/nft.h
index 192050a4..281e1c69 100644
--- a/iptables/nft.h
+++ b/iptables/nft.h
@@ -161,9 +161,9 @@ int nft_xtables_config_load(struct nft_handle *h, const char *filename, uint32_t
struct xt_buf;
bool xlate_find_match(const struct iptables_command_state *cs, const char *p_name);
-int xlate_matches(const struct iptables_command_state *cs, struct xt_buf *buf);
+int xlate_matches(const struct iptables_command_state *cs, struct xt_xlate *xl);
int xlate_action(const struct iptables_command_state *cs, bool goto_set,
- struct xt_buf *buf);
+ struct xt_xlate *xl);
/*
* ARP
diff --git a/iptables/xtables-translate.c b/iptables/xtables-translate.c
index 30028c35..9e2c6aeb 100644
--- a/iptables/xtables-translate.c
+++ b/iptables/xtables-translate.c
@@ -35,7 +35,7 @@
#include "nft-shared.h"
int xlate_action(const struct iptables_command_state *cs, bool goto_set,
- struct xt_buf *buf)
+ struct xt_xlate *xl)
{
int ret = 1, numeric = cs->options & OPT_NUMERIC;
@@ -43,27 +43,27 @@ int xlate_action(const struct iptables_command_state *cs, bool goto_set,
if (cs->target != NULL) {
/* Standard target? */
if (strcmp(cs->jumpto, XTC_LABEL_ACCEPT) == 0)
- xt_buf_add(buf, "accept");
+ xt_xlate_add(xl, "accept");
else if (strcmp(cs->jumpto, XTC_LABEL_DROP) == 0)
- xt_buf_add(buf, "drop");
+ xt_xlate_add(xl, "drop");
else if (strcmp(cs->jumpto, XTC_LABEL_RETURN) == 0)
- xt_buf_add(buf, "return");
+ xt_xlate_add(xl, "return");
else if (cs->target->xlate)
- ret = cs->target->xlate(cs->target->t, buf, numeric);
+ ret = cs->target->xlate(cs->target->t, xl, numeric);
else
return 0;
} else if (strlen(cs->jumpto) > 0) {
/* Not standard, then it's a go / jump to chain */
if (goto_set)
- xt_buf_add(buf, "goto %s", cs->jumpto);
+ xt_xlate_add(xl, "goto %s", cs->jumpto);
else
- xt_buf_add(buf, "jump %s", cs->jumpto);
+ xt_xlate_add(xl, "jump %s", cs->jumpto);
}
return ret;
}
-int xlate_matches(const struct iptables_command_state *cs, struct xt_buf *buf)
+int xlate_matches(const struct iptables_command_state *cs, struct xt_xlate *xl)
{
struct xtables_rule_match *matchp;
int ret = 1, numeric = cs->options & OPT_NUMERIC;
@@ -72,7 +72,7 @@ int xlate_matches(const struct iptables_command_state *cs, struct xt_buf *buf)
if (!matchp->match->xlate)
return 0;
- ret = matchp->match->xlate(matchp->match->m, buf, numeric);
+ ret = matchp->match->xlate(matchp->match->m, xl, numeric);
if (!ret)
break;
}
@@ -101,22 +101,22 @@ static int nft_rule_xlate_add(struct nft_handle *h,
const struct iptables_command_state *cs,
bool append)
{
- struct xt_buf *buf = xt_buf_alloc(10240);
+ struct xt_xlate *xl = xt_xlate_alloc(10240);
int ret;
if (append) {
- xt_buf_add(buf, "add rule %s %s %s ",
+ xt_xlate_add(xl, "add rule %s %s %s ",
family2str[h->family], p->table, p->chain);
} else {
- xt_buf_add(buf, "insert rule %s %s %s ",
+ xt_xlate_add(xl, "insert rule %s %s %s ",
family2str[h->family], p->table, p->chain);
}
- ret = h->ops->xlate(cs, buf);
+ ret = h->ops->xlate(cs, xl);
if (ret)
- printf("%s\n", xt_buf_get(buf));
+ printf("%s\n", xt_xlate_get(xl));
- xt_buf_free(buf);
+ xt_xlate_free(xl);
return ret;
}