MINOR: arg: Add support for ARGT_PBUF_FNUM arg type.

This new argument type is used to parse Protocol Buffers field number
with dotted notation (e.g: 1.2.3.4).
This commit is contained in:
Frdric Lcaille 2019-02-25 15:20:35 +01:00 committed by Willy Tarreau
parent 3b71716685
commit 3a463c92cf
3 changed files with 47 additions and 0 deletions

View 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;
};

View File

@ -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:
*/

View File

@ -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;