#include <string.h>
#include <dlfcn.h>
#include <time.h>
+#include <netdb.h>
#include "libiptc/libiptc.h"
#include "iptables.h"
{ "icmp", IPPROTO_ICMP },
{ "esp", IPPROTO_ESP },
{ "ah", IPPROTO_AH },
+ { "sctp", IPPROTO_SCTP },
};
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 ",
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);
/* 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);
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");
}
* :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;
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