Author: ahmed
Date: 2009-08-01 09:07:17 +0000 (Sat, 01 Aug 2009)
New Revision: 4
Added:
src/fkiptc.c
Log:
Adding FK iptc interface code
Added: src/fkiptc.c
===================================================================
--- src/fkiptc.c (rev 0)
+++ src/fkiptc.c 2009-08-01 09:07:17 UTC (rev 4)
@@ -0,0 +1,52 @@
+
+#include <getopt.h>
+#include <sys/errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <time.h>
+#include "libiptc/libiptc.h"
+#include
"/usr/src/kernels/2.6.29.6-213.fc11.x86_64/include/config/ip/nf/iptables.h"
+
+int main(void)
+{
+ struct iptc_handle *h;
+ const char *chain = NULL;
+ const char *tablename = "filter";
+ struct ipt_counters counters;
+ const char *policy = NULL;
+ int retcoz = 7;
+
+// program_name = "p1";
+// program_version = NETFILTER_VERSION;
+
+ h = iptc_init(tablename);
+ if ( !h ) {
+ printf("Error initializing: %s\n", iptc_strerror(errno));
+ exit(errno);
+ }
+
+ for (chain = iptc_first_chain(h); chain; chain = iptc_next_chain(h)) {
+// printf("%s\n", chain);
+ if ( (policy = iptc_get_policy(chain, &counters, h)) ) {
+ printf("%-10s %-10s\n",
+ chain, policy);
+ }
+
+ }
+// Flush INPUT chain
+ chain = iptc_first_chain(h);
+ printf("Resetting chain %-10s ", chain);
+ //ipt_chainlabel xx = "INPUT";
+ retcoz = iptc_flush_entries( chain , h);
+ printf("Return code : %d\n", retcoz);
+ retcoz = iptc_commit(h);
+ if (!retcoz)
+ {
+ printf("Commit Error");
+ }
+ exit(0);
+
+} /* main */
Show replies by date