@@ -75,6 +75,11 @@ int ip6tc_append_entry(const xt_chainlabel chain,
const struct ip6t_entry *e,
struct xtc_handle *handle);
+/* Append entry `fw' to chain `chain'. Equivalent to insert with
+ rulenum = length of chain. */
+int ip6tc_append_entry2(const xt_chainlabel chain, const struct ip6t_entry *e,
+ struct xtc_handle *handle);
+
/* Check whether a matching rule exists */
int ip6tc_check_entry(const xt_chainlabel chain,
const struct ip6t_entry *origfw,
@@ -79,6 +79,12 @@ int iptc_append_entry(const xt_chainlabel chain,
const struct ipt_entry *e,
struct xtc_handle *handle);
+/* Append entry `e' to chain `chain'. Equivalent to insert with
+ rulenum = length of chain. Returns the position the entry was
+ inserted or 0 if an error occurs */
+int iptc_append_entry2(const xt_chainlabel chain, const struct ipt_entry *e,
+ struct xtc_handle *handle);
+
/* Check whether a mathching rule exists */
int iptc_check_entry(const xt_chainlabel chain,
const struct ipt_entry *origfw,
@@ -698,7 +698,8 @@ append_entry(const xt_chainlabel chain,
fw->ipv6.dmsk = dmasks[j];
if (verbose)
print_firewall_line(fw, handle);
- ret &= ip6tc_append_entry(chain, fw, handle);
+ if (ip6tc_append_entry2(chain, fw, handle) <= 0)
+ ret = 0;
}
}
@@ -700,7 +700,8 @@ append_entry(const xt_chainlabel chain,
fw->ip.dmsk.s_addr = dmasks[j].s_addr;
if (verbose)
print_firewall_line(fw, handle);
- ret &= iptc_append_entry(chain, fw, handle);
+ if (iptc_append_entry2(chain, fw, handle) <= 0)
+ ret = 0;
}
}
@@ -10,6 +10,6 @@ libiptc_la_SOURCES =
libiptc_la_LIBADD = libip4tc.la libip6tc.la
libiptc_la_LDFLAGS = -version-info 0:0:0 ${libiptc_LDFLAGS2}
libip4tc_la_SOURCES = libip4tc.c
-libip4tc_la_LDFLAGS = -version-info 1:0:1
+libip4tc_la_LDFLAGS = -version-info 2:0:2
libip6tc_la_SOURCES = libip6tc.c
-libip6tc_la_LDFLAGS = -version-info 1:0:1 ${libiptc_LDFLAGS2}
+libip6tc_la_LDFLAGS = -version-info 2:0:2 ${libiptc_LDFLAGS2}
@@ -70,6 +70,7 @@ typedef unsigned int socklen_t;
#define TC_INSERT_ENTRY iptc_insert_entry
#define TC_REPLACE_ENTRY iptc_replace_entry
#define TC_APPEND_ENTRY iptc_append_entry
+#define TC_APPEND_ENTRY2 iptc_append_entry2
#define TC_CHECK_ENTRY iptc_check_entry
#define TC_DELETE_ENTRY iptc_delete_entry
#define TC_DELETE_NUM_ENTRY iptc_delete_num_entry
@@ -68,6 +68,7 @@ typedef unsigned int socklen_t;
#define TC_INSERT_ENTRY ip6tc_insert_entry
#define TC_REPLACE_ENTRY ip6tc_replace_entry
#define TC_APPEND_ENTRY ip6tc_append_entry
+#define TC_APPEND_ENTRY2 ip6tc_append_entry2
#define TC_CHECK_ENTRY ip6tc_check_entry
#define TC_DELETE_ENTRY ip6tc_delete_entry
#define TC_DELETE_NUM_ENTRY ip6tc_delete_num_entry
@@ -1836,11 +1836,12 @@ TC_REPLACE_ENTRY(const IPT_CHAINLABEL chain,
}
/* Append entry `fw' to chain `chain'. Equivalent to insert with
- rulenum = length of chain. */
+ rulenum = length of chain. Returns the position the entry was
+ inserted or 0 if an error occurs */
int
-TC_APPEND_ENTRY(const IPT_CHAINLABEL chain,
- const STRUCT_ENTRY *e,
- struct xtc_handle *handle)
+TC_APPEND_ENTRY2(const IPT_CHAINLABEL chain,
+ const STRUCT_ENTRY *e,
+ struct xtc_handle *handle)
{
struct chain_head *c;
struct rule_head *r;
@@ -1872,7 +1873,13 @@ TC_APPEND_ENTRY(const IPT_CHAINLABEL chain,
set_changed(handle);
- return 1;
+ return c->num_rules;
+}
+
+int TC_APPEND_ENTRY(const IPT_CHAINLABEL chain, const STRUCT_ENTRY *e,
+ struct xtc_handle *handle)
+{
+ return (TC_APPEND_ENTRY2(chain, e, handle) <= 0) ? 0 : 1;
}
static inline int