Skip to contentSkip to conversation

datatype: add time type parser and adapt output

RFC PATCH In review Pablo Neira Ayuso 2 participants 3 messages Jan 16, 2014 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

RFC PATCH 1/1 datatype: add time type parser and adapt output

This patch allows to specify a string to indicate the time, eg.

nft add rule filter output ct expiration \"1d2h3m4s\" counter

---
An alternative to this patch is to use seconds as input/output, that only needs a smaller patch to fix time_type_print().

 include/utils.h |    4 ++
 src/datatype.c  |  133 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 121 insertions(+), 16 deletions(-)
include/utils.h +4 -0
index 854986f..f23f8e6 100644
@@ -62,6 +62,10 @@
 	(void) (&_max1 == &_max2);		\
 	_max1 > _max2 ? _max1 : _max2; })
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (int)(sizeof(a)/sizeof((a)[0]))
+#endif
+
 extern void memory_allocation_error(void) __noreturn;
 
 extern void xfree(const void *ptr);
src/datatype.c +117 -16

158 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 8 lines · Pablo Neira Ayuso

This patch allows to specify a string to indicate the time, eg.

nft add rule filter output ct expiration \"1d2h3m4s\" counter

---
An alternative to this patch is to use seconds as input/output, that only needs a smaller patch to fix time_type_print().

I think this is a much more natural way to specify relative times.

Quoted 9 lines
 include/utils.h |    4 ++
 src/datatype.c  |  133 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 121 insertions(+), 16 deletions(-)
include/utils.h +0 -0
index 854986f..f23f8e6 100644

include/utils.h line 67

Quoted 6 lines
include/utils.h +3 -0
@@ -62,6 +62,10 @@
 	(void) (&_max1 == &_max2);		\
 	_max1 > _max2 ? _max1 : _max2; })
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (int)(sizeof(a)/sizeof((a)[0]))
+#endif

We have array_size().

#2 lore raw
Quoted 5 lines · Patrick McHardy
Quoted 4 lines · Pablo Neira Ayuso

This patch allows to specify a string to indicate the time, eg.

nft add rule filter output ct expiration \"1d2h3m4s\" counter

Quoted 7 lines
Quoted 3 lines

---
An alternative to this patch is to use seconds as input/output, that

only

Quoted 1 line

needs a smaller patch to fix time_type_print().

I think this is a much more natural way to specify relative times.

Sorry, just realized that this was very much imprecise, I meant your patch oft course.

Quoted 24 lines
Quoted 3 lines
 include/utils.h |    4 ++
 src/datatype.c  |  133

++++++++++++++++++++++++++++++++++++++++++++++++-------

include/utils.h line 67

Quoted 13 lines
 2 files changed, 121 insertions(+), 16 deletions(-)
include/utils.h +3 -0
index 854986f..f23f8e6 100644
@@ -62,6 +62,10 @@
 	(void) (&_max1 == &_max2);		\
 	_max1 > _max2 ? _max1 : _max2; })
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (int)(sizeof(a)/sizeof((a)[0]))
+#endif

We have array_size().
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.