IPTables-IPv4
view release on metacpan or search on metacpan
OUTPUT:
RETVAL
void
list_chains(self)
IPTables::IPv4::Table self
PREINIT:
char * chain;
SV * sv;
int count = 0;
PPCODE:
sv = ST(0);
chain = (char *)iptc_first_chain(self);
while(chain) {
count++;
if (GIMME_V == G_ARRAY)
XPUSHs(sv_2mortal(newSVpv(chain, 0)));
chain = (char *)iptc_next_chain(self);
}
if (GIMME_V == G_SCALAR)
XPUSHs(sv_2mortal(newSViv(count)));
void
list_rules(self, chain)
IPTables::IPv4::Table self
ipt_chainlabel chain
PREINIT:
SV * sv;
int count = 0;
PPCODE:
sv = ST(0);
if(iptc_is_chain(chain, *self)) {
struct ipt_entry *entry =
(struct ipt_entry *)iptc_first_rule(chain, self);
while(entry) {
count++;
if (GIMME_V == G_ARRAY)
XPUSHs(sv_2mortal(newRV_noinc((SV*)ipt_do_unpack(entry, self))));
entry = (struct ipt_entry *)iptc_next_rule(entry, self);
}
void
get_policy(self, chain)
IPTables::IPv4::Table self
ipt_chainlabel chain
PREINIT:
struct ipt_counters counter;
SV * sv;
char * target;
char * temp;
PPCODE:
sv = ST(0);
if((target = (char *)iptc_get_policy(chain, &counter, self))) {
XPUSHs(sv_2mortal(newSVpv(target, 0)));
asprintf(&temp, "%llu", counter.pcnt);
XPUSHs(sv_2mortal(newSVpv(temp, 0)));
free(temp);
asprintf(&temp, "%llu", counter.bcnt);
XPUSHs(sv_2mortal(newSVpv(temp, 0)));
free(temp);
}
OUTPUT:
RETVAL
void
list_chains(self)
IPTables::IPv6::Table self
PREINIT:
char * chain;
SV * sv;
int count = 0;
PPCODE:
sv = ST(0);
chain = (char *)ip6tc_first_chain(self);
while(chain) {
count++;
if (GIMME_V == G_ARRAY)
XPUSHs(sv_2mortal(newSVpv(chain, 0)));
chain = (char *)ip6tc_next_chain(self);
}
if (GIMME_V == G_SCALAR)
XPUSHs(sv_2mortal(newSViv(count)));
void
list_rules(self, chain)
IPTables::IPv6::Table self
ip6t_chainlabel chain
PREINIT:
SV * sv;
int count = 0;
PPCODE:
sv = ST(0);
if(ip6tc_is_chain(chain, *self)) {
struct ip6t_entry *entry =
(struct ip6t_entry *)ip6tc_first_rule(chain, self);
while(entry) {
count++;
if (GIMME_V == G_ARRAY)
XPUSHs(sv_2mortal(newRV_noinc((SV*)ipt_do_unpack(entry, self))));
entry = (struct ip6t_entry *)ip6tc_next_rule(entry, self);
}
void
get_policy(self, chain)
IPTables::IPv6::Table self
ip6t_chainlabel chain
PREINIT:
struct ip6t_counters counter;
SV * sv;
char * target;
char * temp;
PPCODE:
sv = ST(0);
if((target = (char *)ip6tc_get_policy(chain, &counter, self))) {
XPUSHs(sv_2mortal(newSVpv(target, 0)));
asprintf(&temp, "%llu", counter.pcnt);
XPUSHs(sv_2mortal(newSVpv(temp, 0)));
free(temp);
asprintf(&temp, "%llu", counter.bcnt);
XPUSHs(sv_2mortal(newSVpv(temp, 0)));
free(temp);
}
( run in 0.914 second using v1.01-cache-2.11-cpan-71847e10f99 )