Miroslav Zagorac | 70230c6 | 2020-12-09 16:54:31 +0100 | [diff] [blame] | 1 | /*** |
| 2 | * Copyright 2020 HAProxy Technologies |
| 3 | * |
| 4 | * This file is part of the HAProxy OpenTracing filter. |
| 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 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | #ifndef _OPENTRACING_UTIL_H_ |
| 21 | #define _OPENTRACING_UTIL_H_ |
| 22 | |
| 23 | #define HTTP_METH_STR_OPTIONS "OPTIONS" |
| 24 | #define HTTP_METH_STR_GET "GET" |
| 25 | #define HTTP_METH_STR_HEAD "HEAD" |
| 26 | #define HTTP_METH_STR_POST "POST" |
| 27 | #define HTTP_METH_STR_PUT "PUT" |
| 28 | #define HTTP_METH_STR_DELETE "DELETE" |
| 29 | #define HTTP_METH_STR_TRACE "TRACE" |
| 30 | #define HTTP_METH_STR_CONNECT "CONNECT" |
| 31 | |
| 32 | /* Defined in include/haproxy/channel-t.h. */ |
| 33 | #define FLT_OT_AN_DEFINES \ |
| 34 | FLT_OT_AN_DEF(AN_REQ_INSPECT_FE) \ |
| 35 | FLT_OT_AN_DEF(AN_REQ_WAIT_HTTP) \ |
| 36 | FLT_OT_AN_DEF(AN_REQ_HTTP_BODY) \ |
| 37 | FLT_OT_AN_DEF(AN_REQ_HTTP_PROCESS_FE) \ |
| 38 | FLT_OT_AN_DEF(AN_REQ_SWITCHING_RULES) \ |
| 39 | FLT_OT_AN_DEF(AN_REQ_INSPECT_BE) \ |
| 40 | FLT_OT_AN_DEF(AN_REQ_HTTP_PROCESS_BE) \ |
| 41 | FLT_OT_AN_DEF(AN_REQ_HTTP_TARPIT) \ |
| 42 | FLT_OT_AN_DEF(AN_REQ_SRV_RULES) \ |
| 43 | FLT_OT_AN_DEF(AN_REQ_HTTP_INNER) \ |
| 44 | FLT_OT_AN_DEF(AN_REQ_PRST_RDP_COOKIE) \ |
| 45 | FLT_OT_AN_DEF(AN_REQ_STICKING_RULES) \ |
| 46 | FLT_OT_AN_DEF(AN_REQ_HTTP_XFER_BODY) \ |
| 47 | FLT_OT_AN_DEF(AN_REQ_WAIT_CLI) \ |
| 48 | FLT_OT_AN_DEF(AN_RES_INSPECT) \ |
| 49 | FLT_OT_AN_DEF(AN_RES_WAIT_HTTP) \ |
| 50 | FLT_OT_AN_DEF(AN_RES_STORE_RULES) \ |
| 51 | FLT_OT_AN_DEF(AN_RES_HTTP_PROCESS_BE) \ |
| 52 | FLT_OT_AN_DEF(AN_RES_HTTP_PROCESS_FE) \ |
| 53 | FLT_OT_AN_DEF(AN_RES_HTTP_XFER_BODY) \ |
| 54 | FLT_OT_AN_DEF(AN_RES_WAIT_CLI) |
| 55 | |
| 56 | #define FLT_OT_PROXIES_LIST_START() \ |
| 57 | do { \ |
| 58 | struct flt_conf *fconf; \ |
| 59 | struct proxy *px; \ |
| 60 | \ |
| 61 | for (px = proxies_list; px != NULL; px = px->next) \ |
| 62 | list_for_each_entry(fconf, &(px->filter_configs), list) \ |
| 63 | if (fconf->id == ot_flt_id) { \ |
| 64 | struct flt_ot_conf *conf = fconf->conf; |
| 65 | #define FLT_OT_PROXIES_LIST_END() \ |
| 66 | } \ |
| 67 | } while (0) |
| 68 | |
| 69 | #ifdef DEBUG_OT |
| 70 | # define FLT_OT_ARGS_DUMP() do { if (flt_ot_debug.level & (1 << 2)) flt_ot_args_dump(args); } while (0) |
| 71 | #else |
| 72 | # define FLT_OT_ARGS_DUMP() while (0) |
| 73 | #endif |
| 74 | |
| 75 | |
| 76 | #ifndef DEBUG_OT |
| 77 | # define flt_ot_filters_dump() while (0) |
| 78 | #else |
| 79 | void flt_ot_args_dump(char **args); |
| 80 | void flt_ot_filters_dump(void); |
| 81 | const char *flt_ot_chn_label(const struct channel *chn); |
| 82 | const char *flt_ot_pr_mode(const struct stream *s); |
| 83 | const char *flt_ot_stream_pos(const struct stream *s); |
| 84 | const char *flt_ot_type(const struct filter *f); |
| 85 | const char *flt_ot_analyzer(uint an_bit); |
| 86 | const char *flt_ot_str_hex(const void *data, size_t size); |
| 87 | const char *flt_ot_str_ctrl(const void *data, size_t size); |
| 88 | const char *flt_ot_list_debug(const struct list *head); |
| 89 | #endif |
| 90 | |
| 91 | ssize_t flt_ot_chunk_add(struct buffer *chk, const void *src, size_t n, char **err); |
| 92 | int flt_ot_args_count(char **args); |
| 93 | void flt_ot_args_to_str(char **args, int idx, char **str); |
| 94 | double flt_ot_strtod(const char *nptr, double limit_min, double limit_max, char **err); |
| 95 | int64_t flt_ot_strtoll(const char *nptr, int64_t limit_min, int64_t limit_max, char **err); |
| 96 | int flt_ot_sample_to_str(const struct sample_data *data, char *value, size_t size, char **err); |
| 97 | int flt_ot_sample_to_value(const char *key, const struct sample_data *data, struct otc_value *value, char **err); |
| 98 | int flt_ot_sample_add(struct stream *s, uint dir, struct flt_ot_conf_sample *sample, struct flt_ot_scope_data *data, int type, char **err); |
| 99 | |
| 100 | #endif /* _OPENTRACING_UTIL_H_ */ |
| 101 | |
| 102 | /* |
| 103 | * Local variables: |
| 104 | * c-indent-level: 8 |
| 105 | * c-basic-offset: 8 |
| 106 | * End: |
| 107 | * |
| 108 | * vi: noexpandtab shiftwidth=8 tabstop=8 |
| 109 | */ |