[PATCH 1/6] datatype: generate name for concat types

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

 



The name of a concat type is the names of the individual types concatenated
using a '.'.

Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
---
 src/datatype.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/datatype.c b/src/datatype.c
index 4519d87..29c967b 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -927,12 +927,16 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
 	struct datatype *dtype;
 	struct expr *i;
 	char desc[256] = "concatenation of (";
+	char name[256] = "";
 	unsigned int type = 0, size = 0;
 
 	list_for_each_entry(i, &expr->expressions, list) {
-		if (size != 0)
+		if (size != 0) {
 			strncat(desc, ", ", sizeof(desc) - strlen(desc) - 1);
+			strncat(name, " . ", sizeof(name) - strlen(name) - 1);
+		}
 		strncat(desc, i->dtype->desc, sizeof(desc) - strlen(desc) - 1);
+		strncat(name, i->dtype->name, sizeof(name) - strlen(name) - 1);
 
 		type <<= 8;
 		type  |= i->dtype->type;
@@ -943,6 +947,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
 	dtype		= dtype_alloc();
 	dtype->type	= type;
 	dtype->size	= size;
+	dtype->name	= xstrdup(name);
 	dtype->desc	= xstrdup(desc);
 	dtype->parse	= concat_type_parse;
 
@@ -952,6 +957,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
 void concat_type_destroy(const struct datatype *dtype)
 {
 	if (dtype->flags & DTYPE_F_ALLOC) {
+		xfree(dtype->name);
 		xfree(dtype->desc);
 		xfree(dtype);
 	}
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

  Powered by Linux