blob: 23697214840b9441fa389a9cc7ba22d780ded01a [file] [log] [blame]
Willy Tarreau2ac57182012-04-19 15:24:50 +02001/*
2 * include/types/arg.h
3 * This file contains structure declarations for generaic argument parsing.
4 *
5 * Copyright 2012 Willy Tarreau <w@1wt.eu>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _TYPES_ARG_H
23#define _TYPES_ARG_H
24
25#include <sys/socket.h>
26#include <netinet/in.h>
27#include <types/buffers.h>
28
29enum {
30 ARGT_STOP = 0, /* end of the arg list */
31 ARGT_UINT, /* unsigned integer, which is a positive integer without any sign */
32 ARGT_SINT, /* signed integer, the sign (+/-) was explicit. Falls back to UINT if no sign. */
33 ARGT_STR, /* string */
34 ARGT_IPV4, /* an IPv4 address */
35 ARGT_MSK4, /* an IPv4 address mask (integer or dotted), stored as ARGT_IPV4 */
36 ARGT_IPV6, /* an IPv6 address */
37 ARGT_MSK6, /* an IPv6 address mask (integer or dotted), stored as ARGT_IPV4 */
38 ARGT_TIME, /* a delay in ms by default, stored as ARGT_UINT */
39 ARGT_SIZE, /* a size in bytes by default, stored as ARGT_UINT */
40 ARGT_FE, /* a pointer to a frontend only */
41 ARGT_BE, /* a pointer to a backend only */
42 ARGT_TAB, /* a pointer to a stick table */
43 ARGT_SRV, /* a pointer to a server */
44 ARGT_USR, /* a pointer to a user list */
45 ARGT_UNASSIGNED15, /* will probably be used for variables later */
46 ARGT_NBTYPES /* no more values past 15 */
47};
48
49/* some types that are externally defined */
50struct proxy;
51struct server;
52struct userlist;
53
54union arg_data {
55 unsigned int uint; /* used for uint, time, size */
56 int sint;
57 struct chunk str;
58 struct in_addr ipv4;
59 struct in6_addr ipv6;
60 struct proxy *prx; /* used for fe, be, tables */
61 struct server *srv;
62 struct userlist *usr;
63};
64
65struct arg {
66 int type; /* argument type */
67 union arg_data data; /* argument data */
68};
69
70
71#endif /* _TYPES_ARG_H */
72
73/*
74 * Local variables:
75 * c-indent-level: 8
76 * c-basic-offset: 8
77 * End:
78 */