Re: iptables version defines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Fri, 30 May 2008, Krzysztof Oledzki wrote:



On Fri, 30 May 2008, Thomas Jarosch wrote:

Hello netfilter coreteam,

I'm currently looking for a way to support ipt_ACCOUNT
both for iptables 1.4.0 and iptables 1.4.1. Some function
names changed (addr_to_dotted() -> ipaddr_to_numeric())
and it would be easy to #ifdef around them.

The linux kernel provides multiple defines for its version number,
while iptables only supports a char* version string.

Would it make sense to add something like the kernel version defines
so one could write code like this:

#if IPTABLES_VERSION_CODE < IPTABLES_VERSION(1,4,1)
	abc
#else
	xyz
#endif

#ifdef _XTABLES_H
init(struct xt_entry_target *t)
#else
init(struct ipt_entry_target *t, unsigned int *nfcache)
#endif

Plese check the attached patch.

Best regards,

				Krzysztof Olędzki
--- libipt_ACCOUNT.c	2007-12-14 10:42:16.000000000 +0100
+++ libipt_ACCOUNT.c-new	2008-05-12 23:14:15.000000000 +0200
@@ -30,14 +30,20 @@
 
 /* Initialize the target. */
 static void
+#ifdef _XTABLES_H
+init(struct xt_entry_target *t)
+#else
 init(struct ipt_entry_target *t, unsigned int *nfcache)
+#endif
 {
     struct ipt_acc_info *accountinfo = (struct ipt_acc_info *)t->data;
 
     accountinfo->table_nr = -1;
 
+#ifndef _XTABLES_H
     /* Can't cache this */
     *nfcache |= NFC_UNKNOWN;
+#endif
 }
 
 #define IPT_ACCOUNT_OPT_ADDR 0x01
@@ -47,8 +53,11 @@
    ate an option */
 static int
 parse(int c, char **argv, int invert, unsigned int *flags,
-      const struct ipt_entry *entry,
-      struct ipt_entry_target **target)
+#ifdef _XTABLES_H
+      const void *entry, struct xt_entry_target **target)
+#else
+      const struct ipt_entry *entry, struct ipt_entry_target **target)
+#endif
 {
     struct ipt_acc_info *accountinfo = (struct ipt_acc_info *)(*target)->data;
     struct in_addr *addrs = NULL, mask;
@@ -137,8 +146,13 @@
 
 /* Prints out the targinfo. */
 static void
+#ifdef _XTABLES_H
+print(const void *ip,
+      const struct xt_entry_target *target,
+#else
 print(const struct ipt_ip *ip,
       const struct ipt_entry_target *target,
+#endif
       int numeric)
 {
     print_it (ip, target, 0);
@@ -146,7 +160,13 @@
 
 /* Saves the union ipt_targinfo in parsable form to stdout. */
 static void
-save(const struct ipt_ip *ip, const struct ipt_entry_target *target)
+#ifdef _XTABLES_H
+save(const void *ip,
+     const struct xt_entry_target *target)
+#else
+save(const struct ipt_ip *ip,
+     const struct ipt_entry_target *target)
+#endif
 {
     print_it(ip, target, 1);
 }

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux