lib_LTLIBRARIES = libxtables.la
libxtables_la_SOURCES = xtables.c
-libxtables_la_LDFLAGS = -version 0:0:0
+libxtables_la_LDFLAGS = -version-info 1:0:0
# iptables, dynamic
iptables_SOURCES = iptables-standalone.c iptables.c
#endif
};
+extern void *xtables_calloc(size_t, size_t);
+extern void *xtables_malloc(size_t);
+
/* Your shared library should call one of these. */
extern void xtables_register_match(struct xtables_match *me);
extern void xtables_register_target(struct xtables_target *me);
extern char *lib_dir;
-extern void *fw_calloc(size_t count, size_t size);
-extern void *fw_malloc(size_t size);
-
extern const char *modprobe_program;
extern int xtables_insmod(const char *modname, const char *modprobe, int quiet);
extern int load_xtables_ko(const char *modprobe, int quiet);
for (matchp = matches; matchp; matchp = matchp->next)
size += IP6T_ALIGN(sizeof(struct ip6t_entry_match)) + matchp->match->size;
- mask = fw_calloc(1, size
+ mask = xtables_calloc(1, size
+ IP6T_ALIGN(sizeof(struct ip6t_entry_target))
+ xtables_targets->size);
chain = ip6tc_next_chain(handle);
}
- chains = fw_malloc(sizeof(ip6t_chainlabel) * chaincount);
+ chains = xtables_malloc(sizeof(ip6t_chainlabel) * chaincount);
i = 0;
chain = ip6tc_first_chain(handle);
while (chain) {
for (matchp = matches; matchp; matchp = matchp->next)
size += matchp->match->m->u.match_size;
- e = fw_malloc(size + target->u.target_size);
+ e = xtables_malloc(size + target->u.target_size);
*e = *fw;
e->target_offset = size;
e->next_offset = size + target->u.target_size;
size = IP6T_ALIGN(sizeof(struct ip6t_entry_target))
+ target->size;
- target->t = fw_calloc(1, size);
+ target->t = xtables_calloc(1, size);
target->t->u.target_size = size;
strcpy(target->t->u.user.name, jumpto);
set_revision(target->t->u.user.name,
m = find_match(optarg, LOAD_MUST_SUCCEED, &matches);
size = IP6T_ALIGN(sizeof(struct ip6t_entry_match))
+ m->size;
- m->m = fw_calloc(1, size);
+ m->m = xtables_calloc(1, size);
m->m->u.match_size = size;
strcpy(m->m->u.user.name, m->name);
set_revision(m->m->u.user.name, m->revision);
size = IP6T_ALIGN(sizeof(struct ip6t_entry_match))
+ m->size;
- m->m = fw_calloc(1, size);
+ m->m = xtables_calloc(1, size);
m->m->u.match_size = size;
strcpy(m->m->u.user.name, m->name);
set_revision(m->m->u.user.name,
size = sizeof(struct ip6t_entry_target)
+ target->size;
- target->t = fw_calloc(1, size);
+ target->t = xtables_calloc(1, size);
target->t->u.target_size = size;
strcpy(target->t->u.user.name, jumpto);
if (target->init != NULL)
for (matchp = matches; matchp; matchp = matchp->next)
size += IPT_ALIGN(sizeof(struct ipt_entry_match)) + matchp->match->size;
- mask = fw_calloc(1, size
+ mask = xtables_calloc(1, size
+ IPT_ALIGN(sizeof(struct ipt_entry_target))
+ xtables_targets->size);
chain = iptc_next_chain(handle);
}
- chains = fw_malloc(sizeof(ipt_chainlabel) * chaincount);
+ chains = xtables_malloc(sizeof(ipt_chainlabel) * chaincount);
i = 0;
chain = iptc_first_chain(handle);
while (chain) {
for (matchp = matches; matchp; matchp = matchp->next)
size += matchp->match->m->u.match_size;
- e = fw_malloc(size + target->u.target_size);
+ e = xtables_malloc(size + target->u.target_size);
*e = *fw;
e->target_offset = size;
e->next_offset = size + target->u.target_size;
size = IPT_ALIGN(sizeof(struct ipt_entry_target))
+ target->size;
- target->t = fw_calloc(1, size);
+ target->t = xtables_calloc(1, size);
target->t->u.target_size = size;
strcpy(target->t->u.user.name, jumpto);
set_revision(target->t->u.user.name,
m = find_match(optarg, LOAD_MUST_SUCCEED, &matches);
size = IPT_ALIGN(sizeof(struct ipt_entry_match))
+ m->size;
- m->m = fw_calloc(1, size);
+ m->m = xtables_calloc(1, size);
m->m->u.match_size = size;
strcpy(m->m->u.user.name, m->name);
set_revision(m->m->u.user.name, m->revision);
size = IPT_ALIGN(sizeof(struct ipt_entry_match))
+ m->size;
- m->m = fw_calloc(1, size);
+ m->m = xtables_calloc(1, size);
m->m->u.match_size = size;
strcpy(m->m->u.user.name, m->name);
set_revision(m->m->u.user.name,
size = sizeof(struct ipt_entry_target)
+ target->size;
- target->t = fw_calloc(1, size);
+ target->t = xtables_calloc(1, size);
target->t->u.target_size = size;
strcpy(target->t->u.user.name, jumpto);
if (!iptc_is_chain(jumpto, *handle))
struct xtables_match *xtables_matches;
struct xtables_target *xtables_targets;
-void *fw_calloc(size_t count, size_t size)
+/**
+ * xtables_*alloc - wrappers that exit on failure
+ */
+void *xtables_calloc(size_t count, size_t size)
{
void *p;
return p;
}
-void *fw_malloc(size_t size)
+void *xtables_malloc(size_t size)
{
void *p;
break;
/* Second and subsequent clones */
- clone = fw_malloc(sizeof(struct xtables_match));
+ clone = xtables_malloc(sizeof(struct xtables_match));
memcpy(clone, ptr, sizeof(struct xtables_match));
clone->mflags = 0;
/* This is a clone: */
struct xtables_rule_match **i;
struct xtables_rule_match *newentry;
- newentry = fw_malloc(sizeof(struct xtables_rule_match));
+ newentry = xtables_malloc(sizeof(struct xtables_rule_match));
for (i = matches; *i; i = &(*i)->next) {
if (strcmp(name, (*i)->match->name) == 0)
while (host->h_addr_list[*naddr] != NULL)
++*naddr;
- addr = fw_calloc(*naddr, sizeof(struct in_addr) * *naddr);
+ addr = xtables_calloc(*naddr, sizeof(struct in_addr) * *naddr);
for (i = 0; i < *naddr; i++)
memcpy(&addr[i], host->h_addr_list[i],
sizeof(struct in_addr));
if ((addrptmp = numeric_to_ipaddr(name)) != NULL ||
(addrptmp = network_to_ipaddr(name)) != NULL) {
- addrp = fw_malloc(sizeof(struct in_addr));
+ addrp = xtables_malloc(sizeof(struct in_addr));
memcpy(addrp, addrptmp, sizeof(*addrp));
*naddrs = 1;
return addrp;
ip6addr_to_numeric(&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr));
#endif
/* Get the first element of the address-chain */
- addr = fw_malloc(sizeof(struct in6_addr));
+ addr = xtables_malloc(sizeof(struct in6_addr));
memcpy(addr, &((const struct sockaddr_in6 *)res->ai_addr)->sin6_addr,
sizeof(struct in6_addr));
freeaddrinfo(res);
if ((addrptmp = numeric_to_ip6addr(name)) != NULL ||
(addrptmp = network_to_ip6addr(name)) != NULL) {
- addrp = fw_malloc(sizeof(struct in6_addr));
+ addrp = xtables_malloc(sizeof(struct in6_addr));
memcpy(addrp, addrptmp, sizeof(*addrp));
*naddrs = 1;
return addrp;