]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
datatype: generate name for concat types
authorPatrick McHardy <kaber@trash.net>
Sat, 13 Dec 2014 07:50:34 +0000 (07:50 +0000)
committerPatrick McHardy <kaber@trash.net>
Tue, 16 Dec 2014 17:20:54 +0000 (18:20 +0100)
The name of a concat type is the names of the individual types concatenated
using a '.'.

Signed-off-by: Patrick McHardy <kaber@trash.net>
src/datatype.c

index 7f730776d66716261c9857de1b78a19d63572a70..807b0f1811d88d3ff333dffe640bb7ba023b192c 100644 (file)
@@ -928,12 +928,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;
@@ -944,6 +948,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;
 
@@ -953,6 +958,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);
        }