* iptables version defines
@ 2008-05-30 8:16 Thomas Jarosch
2008-05-30 9:41 ` Krzysztof Oledzki
0 siblings, 1 reply; 13+ messages in thread
From: Thomas Jarosch @ 2008-05-30 8:16 UTC (permalink / raw)
To: netfilter-devel
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
?
Another solution would be to have an "iptables" and "iptables-1.4.1"
directory in the pom archive, though I don't know if that is supported.
(and would lead to code duplication.)
Thanks,
Thomas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: iptables version defines
2008-05-30 8:16 iptables version defines Thomas Jarosch
@ 2008-05-30 9:41 ` Krzysztof Oledzki
2008-05-30 9:56 ` Krzysztof Oledzki
2008-05-30 10:05 ` Krzysztof Oledzki
0 siblings, 2 replies; 13+ messages in thread
From: Krzysztof Oledzki @ 2008-05-30 9:41 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: netfilter-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 809 bytes --]
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
Best regards,
Krzysztof Olędzki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: iptables version defines
2008-05-30 9:41 ` Krzysztof Oledzki
@ 2008-05-30 9:56 ` Krzysztof Oledzki
2008-05-30 10:06 ` Thomas Jarosch
2008-05-30 10:05 ` Krzysztof Oledzki
1 sibling, 1 reply; 13+ messages in thread
From: Krzysztof Oledzki @ 2008-05-30 9:56 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: netfilter-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 935 bytes --]
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
[-- Attachment #2: Type: TEXT/PLAIN, Size: 1775 bytes --]
--- 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);
}
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: iptables version defines
2008-05-30 9:56 ` Krzysztof Oledzki
@ 2008-05-30 10:06 ` Thomas Jarosch
2008-05-30 10:53 ` Jan Engelhardt
0 siblings, 1 reply; 13+ messages in thread
From: Thomas Jarosch @ 2008-05-30 10:06 UTC (permalink / raw)
To: Krzysztof Oledzki; +Cc: netfilter-devel
Hi Krzysztof,
On Friday, 30. May 2008 11:56:28 you wrote:
> > #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.
Thanks for the patch! I've developed something similar yesterday, though not
as elegant as your version. This will solve the issue for iptables < 1.4.0.
The differences between 1.4.0 and the upcoming 1.4.1 are still an issue as
some function names changed. The version defines could be of help here.
Thomas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: iptables version defines
2008-05-30 10:06 ` Thomas Jarosch
@ 2008-05-30 10:53 ` Jan Engelhardt
2008-06-01 21:13 ` Patrick McHardy
0 siblings, 1 reply; 13+ messages in thread
From: Jan Engelhardt @ 2008-05-30 10:53 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: Krzysztof Oledzki, netfilter-devel
On Friday 2008-05-30 12:06, Thomas Jarosch wrote:
>Hi Krzysztof,
>
>On Friday, 30. May 2008 11:56:28 you wrote:
>> > #ifdef _XTABLES_H
>> > init(struct xt_entry_target *t)
>> > #else
>> > init(struct ipt_entry_target *t, unsigned int *nfcache)
>> > #endif
Woah this is ridiculously ugly. (Remember, such constructs were
just eliminated from the kernel in the past years.)
There is Xtables-addons which provides enough glue so that there is no reason
to play dirty preprocessor tricks like these. xt-a uses a technique where an
extra backwards-API layer is in place that translates the API (mostly
parameter shuffling, etc) in an IMHO perfect fashion.
That's for the kernel part; the same applies to the iptables glue --
of which there is not any yet, because 1.4.0.77 is the minimum required
version because of the newly exported xtables.h, and I had to start
*somewhere*. My suggestion that you follow up on it ;-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: iptables version defines
2008-05-30 10:53 ` Jan Engelhardt
@ 2008-06-01 21:13 ` Patrick McHardy
[not found] ` <200806021545.23690.thomas.jarosch@intra2net.com>
0 siblings, 1 reply; 13+ messages in thread
From: Patrick McHardy @ 2008-06-01 21:13 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: Thomas Jarosch, Krzysztof Oledzki, netfilter-devel
Jan Engelhardt wrote:
> On Friday 2008-05-30 12:06, Thomas Jarosch wrote:
>> Hi Krzysztof,
>>
>> On Friday, 30. May 2008 11:56:28 you wrote:
>>>> #ifdef _XTABLES_H
>>>> init(struct xt_entry_target *t)
>>>> #else
>>>> init(struct ipt_entry_target *t, unsigned int *nfcache)
>>>> #endif
>
> Woah this is ridiculously ugly. (Remember, such constructs were
> just eliminated from the kernel in the past years.)
I don't care about uglyness as long as it stays in external
code. So if someone sends me a patch to add this version
define, I'll add it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: iptables version defines
2008-05-30 9:41 ` Krzysztof Oledzki
2008-05-30 9:56 ` Krzysztof Oledzki
@ 2008-05-30 10:05 ` Krzysztof Oledzki
1 sibling, 0 replies; 13+ messages in thread
From: Krzysztof Oledzki @ 2008-05-30 10:05 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: netfilter-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 983 bytes --]
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
Bzzz, sorry. Just noticed that you had asked about 1.4.0->1.4.1, not
1.3->1.4.
Best regards,
Krzysztof Olędzki
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch] iptables version defines
@ 2008-06-02 13:49 Thomas Jarosch
2008-06-02 14:54 ` Jan Engelhardt
0 siblings, 1 reply; 13+ messages in thread
From: Thomas Jarosch @ 2008-06-02 13:49 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netfilter-devel, Jan Engelhardt
[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]
Hi Patrick,
[resent as I somehow sent an HTML email at first]
> >>>> #ifdef _XTABLES_H
> >>>> init(struct xt_entry_target *t)
> >>>> #else
> >>>> init(struct ipt_entry_target *t, unsigned int *nfcache)
> >>>> #endif
> >
> > Woah this is ridiculously ugly. (Remember, such constructs were
> > just eliminated from the kernel in the past years.)
>
> I don't care about uglyness as long as it stays in external
> code. So if someone sends me a patch to add this version
> define, I'll add it.
External code has to be "ugly" if you want to keep the user experience high.
I don't feel like breaking ipt_ACCOUNT for older iptables versions without
any real gain, it should work out of the box with iptables 1.4.0 and 1.4.1.
Attached is a patch to add the new defines. The macro XTABLES_VERSION
is already in use, so I named it XTABLES_VERSION_CHECK. I've also tested
that an empty XTABLES_VERSION_EXTRA in configure.ac works.
Now we can write code like this:
#if XTABLES_VERSION_CODE < XTABLES_VERSION_CHECK(1,5,0)
#warning You are obselete and will be assimilated.
#endif
Cheers,
Thomas
[-- Attachment #2: iptables-add-version.patch --]
[-- Type: text/x-diff, Size: 1795 bytes --]
Add xtables version defines.
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
--- iptables-1.4.1-rc2/configure.ac Mon May 26 14:23:58 2008
+++ iptables.version/configure.ac Mon Jun 2 15:05:57 2008
@@ -1,5 +1,11 @@
+define([_XTABLES_VERSION_MAJOR], 1)
+define([_XTABLES_VERSION_MINOR], 4)
+define([_XTABLES_VERSION_PATCH], 1)
+define([_XTABLES_VERSION_EXTRA], -rc2)
-AC_INIT([iptables], [1.4.1-rc2])
+define([_XTABLES_VERSION],_XTABLES_VERSION_MAJOR._XTABLES_VERSION_MINOR._XTABLES_VERSION_PATCH[]_XTABLES_VERSION_EXTRA)
+
+AC_INIT([iptables], _XTABLES_VERSION)
AC_CONFIG_HEADERS([config.h])
AC_PROG_INSTALL
AM_INIT_AUTOMAKE
@@ -56,4 +62,14 @@
AC_SUBST([kbuilddir])
AC_SUBST([ksourcedir])
AC_SUBST([xtlibdir])
+
+XTABLES_VERSION_MAJOR=_XTABLES_VERSION_MAJOR
+XTABLES_VERSION_MINOR=_XTABLES_VERSION_MINOR
+XTABLES_VERSION_PATCH=_XTABLES_VERSION_PATCH
+XTABLES_VERSION_EXTRA=_XTABLES_VERSION_EXTRA
+AC_SUBST([XTABLES_VERSION_MAJOR])
+AC_SUBST([XTABLES_VERSION_MINOR])
+AC_SUBST([XTABLES_VERSION_PATCH])
+AC_SUBST([XTABLES_VERSION_EXTRA])
+
AC_OUTPUT([Makefile extensions/GNUmakefile libipq/Makefile include/xtables.h])
--- iptables-1.4.1-rc2/include/xtables.h.in Mon May 26 14:15:40 2008
+++ iptables.version/include/xtables.h.in Mon Jun 2 15:03:46 2008
@@ -18,6 +18,12 @@
#endif
#define XTABLES_VERSION "@PACKAGE_VERSION@"
+#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 * @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@)
+
+#define XTABLES_VERSION_CHECK(x,y,z) (0x10000*(x) + 0x100*(y) + z)
+#define XTABLES_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
+#define XTABLES_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
+#define XTABLES_VERSION_PATCH(x) ( (x) & 0xFF)
/* Include file for additions: new matches and targets. */
struct xtables_match
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] iptables version defines
2008-06-02 13:49 [patch] " Thomas Jarosch
@ 2008-06-02 14:54 ` Jan Engelhardt
2008-06-02 15:32 ` Thomas Jarosch
0 siblings, 1 reply; 13+ messages in thread
From: Jan Engelhardt @ 2008-06-02 14:54 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: Patrick McHardy, netfilter-devel
On Monday 2008-06-02 15:49, Thomas Jarosch wrote:
>> I don't care about uglyness as long as it stays in external
>> code. So if someone sends me a patch to add this version
>> define, I'll add it.
>
>External code has to be "ugly" if you want to keep the user
>experience high. I don't feel like breaking ipt_ACCOUNT for older
>iptables versions without any real gain, it should work out of the
>box with iptables 1.4.0 and 1.4.1.
External code does not _necessarily_ have to be ugly; at least
one can make it so as to reduce the lot of redundant #if hackery;
xt-a does this for the kernel interface already, it should not be
hard to do the same for the iptables API once it becomes necessary.
For that to work, we need a XTABLES_VERSION_CODE, and since your
patch does just that, you get my approval. Comments follow...
>Add xtables version defines.
>
>Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
>
>--- iptables-1.4.1-rc2/configure.ac Mon May 26 14:23:58 2008
>+++ iptables.version/configure.ac Mon Jun 2 15:05:57 2008
>@@ -1,5 +1,11 @@
>+define([_XTABLES_VERSION_MAJOR], 1)
>+define([_XTABLES_VERSION_MINOR], 4)
>+define([_XTABLES_VERSION_PATCH], 1)
>+define([_XTABLES_VERSION_EXTRA], -rc2)
>
>-AC_INIT([iptables], [1.4.1-rc2])
>+define([_XTABLES_VERSION],_XTABLES_VERSION_MAJOR._XTABLES_VERSION_MINOR._XTABLES_VERSION_PATCH[]_XTABLES_VERSION_EXTRA)
>+
>+AC_INIT([iptables], _XTABLES_VERSION)
> AC_CONFIG_HEADERS([config.h])
> AC_PROG_INSTALL
> AM_INIT_AUTOMAKE
>@@ -56,4 +62,14 @@
> AC_SUBST([kbuilddir])
> AC_SUBST([ksourcedir])
> AC_SUBST([xtlibdir])
>+
>+XTABLES_VERSION_MAJOR=_XTABLES_VERSION_MAJOR
>+XTABLES_VERSION_MINOR=_XTABLES_VERSION_MINOR
>+XTABLES_VERSION_PATCH=_XTABLES_VERSION_PATCH
>+XTABLES_VERSION_EXTRA=_XTABLES_VERSION_EXTRA
>+AC_SUBST([XTABLES_VERSION_MAJOR])
>+AC_SUBST([XTABLES_VERSION_MINOR])
>+AC_SUBST([XTABLES_VERSION_PATCH])
>+AC_SUBST([XTABLES_VERSION_EXTRA])
>+
> AC_OUTPUT([Makefile extensions/GNUmakefile libipq/Makefile include/xtables.h])
>--- iptables-1.4.1-rc2/include/xtables.h.in Mon May 26 14:15:40 2008
>+++ iptables.version/include/xtables.h.in Mon Jun 2 15:03:46 2008
>@@ -18,6 +18,12 @@
> #endif
>
> #define XTABLES_VERSION "@PACKAGE_VERSION@"
>+#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 * @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@)
>+
>+#define XTABLES_VERSION_CHECK(x,y,z) (0x10000*(x) + 0x100*(y) + z)
Mh.... too much arithmetic for my taste, just use bitops like
linux/version.h. Also, regarding the _CHECK name, I'd propose
"XTABLES_API_VERSION" instead, which should look nicer on
#if XTABLES_VERSION_CODE < XTABLES_API_VERSION(1,4,0)
#error Upgrade, yo!
#endif
#define XTABLES_API_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c))
>+#define XTABLES_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
>+#define XTABLES_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
>+#define XTABLES_VERSION_PATCH(x) ( (x) & 0xFF)
I do not see a need for these three. The linux kernel does not
have such either, so please don't overdesign :)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] iptables version defines
2008-06-02 14:54 ` Jan Engelhardt
@ 2008-06-02 15:32 ` Thomas Jarosch
2008-06-02 17:03 ` Jan Engelhardt
2008-06-03 13:02 ` Patrick McHardy
0 siblings, 2 replies; 13+ messages in thread
From: Thomas Jarosch @ 2008-06-02 15:32 UTC (permalink / raw)
To: netfilter-devel; +Cc: Jan Engelhardt, Patrick McHardy
[-- Attachment #1: Type: text/plain, Size: 1550 bytes --]
Jan,
On Monday, 2. June 2008 16:54:57 you wrote:
> > #define XTABLES_VERSION "@PACKAGE_VERSION@"
> >+#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 *
> > @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@) +
> >+#define XTABLES_VERSION_CHECK(x,y,z) (0x10000*(x) + 0x100*(y) + z)
>
> Mh.... too much arithmetic for my taste, just use bitops like
> linux/version.h. Also, regarding the _CHECK name, I'd propose
> "XTABLES_API_VERSION" instead, which should look nicer on
> #if XTABLES_VERSION_CODE < XTABLES_API_VERSION(1,4,0)
> #error Upgrade, yo!
> #endif
>
>
> #define XTABLES_API_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c))
As you already pointed out, it's a matter of taste and neither
of both versions will hurt as it will be expanded at compile time.
Infact, imagine we would add another version level like "(x) << 32",
on x86 it is only valid to do a left shift operation for 0-31 bits
and so it could fail...
> >+#define XTABLES_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
> >+#define XTABLES_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
> >+#define XTABLES_VERSION_PATCH(x) ( (x) & 0xFF)
>
> I do not see a need for these three. The linux kernel does not
> have such either, so please don't overdesign :)
Well, I've created the same macros as there are already in include/iptables.h.
I'm alright with your proposed change to XTABLES_API_VERSION
and the drop of _MAJOR, _MINOR and _PATCH macros as
one can easily check for same thing via "xyz < XTABLES_API_VERSION(2,6,0)"
Attached is an updated patch.
Thomas
[-- Attachment #2: iptables-add-version.patch --]
[-- Type: text/x-diff, Size: 1792 bytes --]
Add xtables version defines.
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
diff -u -r iptables-1.4.1-rc2/configure.ac iptables.version/configure.ac
--- iptables-1.4.1-rc2/configure.ac Mon May 26 14:23:58 2008
+++ iptables.version/configure.ac Mon Jun 2 17:19:42 2008
@@ -1,5 +1,11 @@
+define([_XTABLES_VERSION_MAJOR], 1)
+define([_XTABLES_VERSION_MINOR], 4)
+define([_XTABLES_VERSION_PATCH], 1)
+define([_XTABLES_VERSION_EXTRA], -rc2)
-AC_INIT([iptables], [1.4.1-rc2])
+define([_XTABLES_VERSION],_XTABLES_VERSION_MAJOR._XTABLES_VERSION_MINOR._XTABLES_VERSION_PATCH[]_XTABLES_VERSION_EXTRA)
+
+AC_INIT([iptables], _XTABLES_VERSION)
AC_CONFIG_HEADERS([config.h])
AC_PROG_INSTALL
AM_INIT_AUTOMAKE
@@ -56,4 +62,14 @@
AC_SUBST([kbuilddir])
AC_SUBST([ksourcedir])
AC_SUBST([xtlibdir])
+
+XTABLES_VERSION_MAJOR=_XTABLES_VERSION_MAJOR
+XTABLES_VERSION_MINOR=_XTABLES_VERSION_MINOR
+XTABLES_VERSION_PATCH=_XTABLES_VERSION_PATCH
+XTABLES_VERSION_EXTRA=_XTABLES_VERSION_EXTRA
+AC_SUBST([XTABLES_VERSION_MAJOR])
+AC_SUBST([XTABLES_VERSION_MINOR])
+AC_SUBST([XTABLES_VERSION_PATCH])
+AC_SUBST([XTABLES_VERSION_EXTRA])
+
AC_OUTPUT([Makefile extensions/GNUmakefile libipq/Makefile include/xtables.h])
diff -u -r iptables-1.4.1-rc2/include/xtables.h.in iptables.version/include/xtables.h.in
--- iptables-1.4.1-rc2/include/xtables.h.in Mon May 26 14:15:40 2008
+++ iptables.version/include/xtables.h.in Mon Jun 2 17:20:55 2008
@@ -18,6 +18,9 @@
#endif
#define XTABLES_VERSION "@PACKAGE_VERSION@"
+#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 * @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@)
+
+#define XTABLES_API_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
/* Include file for additions: new matches and targets. */
struct xtables_match
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] iptables version defines
2008-06-02 15:32 ` Thomas Jarosch
@ 2008-06-02 17:03 ` Jan Engelhardt
2008-06-03 13:02 ` Patrick McHardy
1 sibling, 0 replies; 13+ messages in thread
From: Jan Engelhardt @ 2008-06-02 17:03 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: netfilter-devel, Patrick McHardy
On Monday 2008-06-02 17:32, Thomas Jarosch wrote:
>Jan,
>>
>> #define XTABLES_API_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c))
>
>As you already pointed out, it's a matter of taste and neither
>of both versions will hurt as it will be expanded at compile time.
>
>Infact, imagine we would add another version level like "(x) << 32",
>on x86 it is only valid to do a left shift operation for 0-31 bits
>and so it could fail...
First, you would use << 24 not << 32 :-)
Even so, << 32 is perfectly valid if you correctly declare it as a
unsigned long long.
>> >+#define XTABLES_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
>> >+#define XTABLES_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
>> >+#define XTABLES_VERSION_PATCH(x) ( (x) & 0xFF)
>>
>> I do not see a need for these three. The linux kernel does not
>> have such either, so please don't overdesign :)
>
>Well, I've created the same macros as there are already in include/iptables.h.
That's just leftover, they are not used either.
>I'm alright with your proposed change to XTABLES_API_VERSION
>and the drop of _MAJOR, _MINOR and _PATCH macros as
>one can easily check for same thing via "xyz < XTABLES_API_VERSION(2,6,0)"
>
>Attached is an updated patch.
I approve.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] iptables version defines
2008-06-02 15:32 ` Thomas Jarosch
2008-06-02 17:03 ` Jan Engelhardt
@ 2008-06-03 13:02 ` Patrick McHardy
1 sibling, 0 replies; 13+ messages in thread
From: Patrick McHardy @ 2008-06-03 13:02 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: netfilter-devel, Jan Engelhardt
Thomas Jarosch wrote:
> I'm alright with your proposed change to XTABLES_API_VERSION
> and the drop of _MAJOR, _MINOR and _PATCH macros as
> one can easily check for same thing via "xyz < XTABLES_API_VERSION(2,6,0)"
>
> Attached is an updated patch.
Applied and pushed out, thanks.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2008-06-03 13:02 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-30 8:16 iptables version defines Thomas Jarosch
2008-05-30 9:41 ` Krzysztof Oledzki
2008-05-30 9:56 ` Krzysztof Oledzki
2008-05-30 10:06 ` Thomas Jarosch
2008-05-30 10:53 ` Jan Engelhardt
2008-06-01 21:13 ` Patrick McHardy
[not found] ` <200806021545.23690.thomas.jarosch@intra2net.com>
2008-06-02 13:50 ` [patch] " Patrick McHardy
2008-05-30 10:05 ` Krzysztof Oledzki
-- strict thread matches above, loose matches on Subject: below --
2008-06-02 13:49 [patch] " Thomas Jarosch
2008-06-02 14:54 ` Jan Engelhardt
2008-06-02 15:32 ` Thomas Jarosch
2008-06-02 17:03 ` Jan Engelhardt
2008-06-03 13:02 ` Patrick McHardy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.