X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=iptables-save.c;h=6c7267e20ce0d5b7948302da65d7bc715ef6c2eb;hb=6afea0b41dfbc3824956d11d960ad80097218feb;hp=90163b501aa1c0e67e5015200879591dcd7757cf;hpb=f7b70cf9e00324b89b02de213bcd0dde7044d035;p=iptables.git diff --git a/iptables-save.c b/iptables-save.c index 90163b5..6c7267e 100644 --- a/iptables-save.c +++ b/iptables-save.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "libiptc/libiptc.h" #include "iptables.h" @@ -75,6 +76,7 @@ static const struct pprot chain_protos[] = { { "icmp", IPPROTO_ICMP }, { "esp", IPPROTO_ESP }, { "ah", IPPROTO_AH }, + { "sctp", IPPROTO_SCTP }, }; static void print_proto(u_int16_t proto, int invert) @@ -83,6 +85,12 @@ static void print_proto(u_int16_t proto, int invert) unsigned int i; const char *invertstr = invert ? "! " : ""; + struct protoent *pent = getprotobynumber(proto); + if (pent) { + printf("-p %s%s ", invertstr, pent->p_name); + return; + } + for (i = 0; i < sizeof(chain_protos)/sizeof(struct pprot); i++) if (chain_protos[i].num == proto) { printf("-p %s%s ", @@ -111,7 +119,7 @@ static int print_match(const struct ipt_entry_match *e, const struct ipt_ip *ip) { struct iptables_match *match - = find_match(e->u.user.name, TRY_LOAD); + = find_match(e->u.user.name, TRY_LOAD, NULL); if (match) { printf("-m %s ", e->u.user.name); @@ -157,7 +165,7 @@ static void print_rule(const struct ipt_entry *e, /* print counters */ if (counters) - printf("[%llu:%llu] ", e->counters.pcnt, e->counters.bcnt); + printf("[%llu:%llu] ", (unsigned long long)e->counters.pcnt, (unsigned long long)e->counters.bcnt); /* print chain name */ printf("-A %s ", chain); @@ -276,7 +284,7 @@ static int do_output(const char *tablename) struct ipt_counters count; printf("%s ", iptc_get_policy(chain, &count, &h)); - printf("[%llu:%llu]\n", count.pcnt, count.bcnt); + printf("[%llu:%llu]\n", (unsigned long long)count.pcnt, (unsigned long long)count.bcnt); } else { printf("- [0:0]\n"); } @@ -313,7 +321,13 @@ static int do_output(const char *tablename) * :Chain name POLICY packets bytes * rule */ -int main(int argc, char *argv[]) +#ifdef IPTABLES_MULTI +int +iptables_save_main(int argc, char *argv[]) +#else +int +main(int argc, char *argv[]) +#endif { const char *tablename = NULL; int c; @@ -321,6 +335,10 @@ int main(int argc, char *argv[]) program_name = "iptables-save"; program_version = IPTABLES_VERSION; + lib_dir = getenv("IPTABLES_LIB_DIR"); + if (!lib_dir) + lib_dir = IPT_LIB_DIR; + #ifdef NO_SHARED_LIBS init_extensions(); #endif