]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: arg: Add support for ARGT_PBUF_FNUM arg type.
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 25 Feb 2019 14:20:35 +0000 (15:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 26 Feb 2019 15:27:05 +0000 (16:27 +0100)
This new argument type is used to parse Protocol Buffers field number
with dotted notation (e.g: 1.2.3.4).

include/types/arg.h
include/types/protocol_buffers.h [new file with mode: 0644]
src/arg.c

index 96974ba880d1b4129c3ddf121ffae5b150f7cedd..6580c1583299e9a6b9a47e256ebe39392aabb972 100644 (file)
@@ -29,6 +29,7 @@
 #include <common/mini-clist.h>
 
 #include <types/vars.h>
+#include <types/protocol_buffers.h>
 
 /* encoding of each arg type : up to 31 types are supported */
 #define ARGT_BITS      5
@@ -60,6 +61,7 @@ enum {
        ARGT_MAP,      /* a pointer to a map descriptor */
        ARGT_REG,      /* a pointer to a regex */
        ARGT_VAR,      /* contains a variable description. */
+       ARGT_PBUF_FNUM, /* a protocol buffer field number */
        /* please update arg_type_names[] in args.c if you add entries here */
 };
 
@@ -100,6 +102,7 @@ union arg_data {
        struct userlist *usr;
        struct map_descriptor *map;
        struct my_regex *reg;
+       struct pbuf_fid fid;
        struct var_desc var;
 };
 
diff --git a/include/types/protocol_buffers.h b/include/types/protocol_buffers.h
new file mode 100644 (file)
index 0000000..af5d262
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * include/types/protocol_buffers.h
+ * This file contains structure declarations for protocol buffers.
+ *
+ * Copyright 2012 Willy Tarreau <w@1wt.eu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _TYPES_PROTOCOL_BUFFERS_H
+#define _TYPES_PROTOCOL_BUFFERS_H
+
+struct pbuf_fid {
+       unsigned int *ids;
+       size_t sz;
+};
+
+#endif /* _TYPES_PROTOCOL_BUFFERS_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index 8e71dcca25da673cdcb5d8a13918c4175ec9c4aa..858f8ec5431f9f43131fa996f01ef7068fe169d8 100644 (file)
--- a/src/arg.c
+++ b/src/arg.c
@@ -35,6 +35,7 @@ const char *arg_type_names[ARGT_NBTYPES] = {
        [ARGT_MAP]  = "map",
        [ARGT_REG]  = "regex",
        [ARGT_VAR]  = "variable",
+       [ARGT_PBUF_FNUM] = "Protocol buffers field number",
        /* Unassigned types must never happen. Better crash during parsing if they do. */
 };
 
@@ -239,6 +240,12 @@ int make_arg_list(const char *in, int len, uint64_t mask, struct arg **argp,
                        arg->type = ARGT_SINT;
                        break;
 
+               case ARGT_PBUF_FNUM:
+                       if (!parse_dotted_uints(word, &arg->data.fid.ids, &arg->data.fid.sz))
+                               goto parse_err;
+
+                       break;
+
                        /* FIXME: other types need to be implemented here */
                default:
                        goto not_impl;