blob: 81f5816c2e87cd6363a0f5f8fea6945d1f91a0c0 [file] [log] [blame]
Thierry FOURNIER4aec0a42018-02-23 11:42:57 +01001/* Main SPOA server includes
2 *
3 * Copyright 2016 HAProxy Technologies, Christopher Faulet <cfaulet@haproxy.com>
4 * Copyright 2018 OZON / Thierry Fournier <thierry.fournier@ozon.io>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef __SPOA_H__
12#define __SPOA_H__
13
14#include <stdbool.h>
15#include <stdint.h>
16#include <netinet/in.h>
17
18#define MAX_FRAME_SIZE 16384
19#define SPOP_VERSION "1.0"
20#define SPOA_CAPABILITIES ""
21
22/* All supported data types */
23enum spoe_data_type {
24 SPOE_DATA_T_NULL = 0,
25 SPOE_DATA_T_BOOL,
26 SPOE_DATA_T_INT32,
27 SPOE_DATA_T_UINT32,
28 SPOE_DATA_T_INT64,
29 SPOE_DATA_T_UINT64,
30 SPOE_DATA_T_IPV4,
31 SPOE_DATA_T_IPV6,
32 SPOE_DATA_T_STR,
33 SPOE_DATA_T_BIN,
34 SPOE_DATA_TYPES
35};
36
37/* Scopes used for variables set by agents. It is a way to be agnotic to vars
38 * scope. */
39enum spoe_vars_scope {
40 SPOE_SCOPE_PROC = 0, /* <=> SCOPE_PROC */
41 SPOE_SCOPE_SESS, /* <=> SCOPE_SESS */
42 SPOE_SCOPE_TXN, /* <=> SCOPE_TXN */
43 SPOE_SCOPE_REQ, /* <=> SCOPE_REQ */
44 SPOE_SCOPE_RES, /* <=> SCOPE_RES */
45};
46
47struct worker {
48 unsigned int id;
49 char buf[MAX_FRAME_SIZE];
50 unsigned int len;
51 unsigned int size;
52 int status_code;
53 unsigned int stream_id;
54 unsigned int frame_id;
55 bool healthcheck;
56 int ip_score; /* -1 if unset, else between 0 and 100 */
57};
58
59struct chunk {
60 char *str; /* beginning of the string itself. Might not be 0-terminated */
61 int len; /* current size of the string from first to last char */
62};
63
64union spoe_value {
65 bool boolean; /* use for boolean */
66 int32_t sint32; /* used for signed 32bits integers */
67 uint32_t uint32; /* used for signed 32bits integers */
68 int32_t sint64; /* used for signed 64bits integers */
69 uint32_t uint64; /* used for signed 64bits integers */
70 struct in_addr ipv4; /* used for ipv4 addresses */
71 struct in6_addr ipv6; /* used for ipv6 addresses */
72 struct chunk buffer; /* used for char strings or buffers */
73};
74
75/* Used to store sample constant */
76struct spoe_data {
77 enum spoe_data_type type; /* SPOE_DATA_T_* */
78 union spoe_value u; /* spoe data value */
79};
80
81#endif /* __SPOA_H__ */