William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 1 | /* |
| 2 | * include/proto/cli.h |
| 3 | * This file contains definitions of some primitives to dedicated to |
| 4 | * statistics output. |
| 5 | * |
| 6 | * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu |
| 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation, version 2.1 |
| 11 | * exclusively. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ |
| 22 | |
| 23 | #ifndef _PROTO_CLI_H |
| 24 | #define _PROTO_CLI_H |
| 25 | |
Willy Tarreau | 17306b9 | 2018-11-22 11:45:04 +0100 | [diff] [blame] | 26 | #include <types/applet.h> |
| 27 | #include <types/channel.h> |
| 28 | #include <types/cli.h> |
| 29 | #include <types/global.h> |
| 30 | #include <types/stream.h> |
| 31 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 32 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 33 | void cli_register_kw(struct cli_kw_list *kw_list); |
| 34 | |
Willy Tarreau | de57a57 | 2016-11-23 17:01:39 +0100 | [diff] [blame] | 35 | int cli_has_level(struct appctx *appctx, int level); |
| 36 | |
William Lallemand | 7175e68 | 2019-04-01 11:30:00 +0200 | [diff] [blame] | 37 | int cli_parse_default(char **args, char *payload, struct appctx *appctx, void *private); |
| 38 | |
William Lallemand | 309dc9a | 2018-10-26 14:47:45 +0200 | [diff] [blame] | 39 | /* mworker proxy functions */ |
| 40 | |
William Lallemand | 8a02257 | 2018-10-26 14:47:35 +0200 | [diff] [blame] | 41 | int mworker_cli_proxy_create(); |
William Lallemand | e736115 | 2018-10-26 14:47:36 +0200 | [diff] [blame] | 42 | int mworker_cli_proxy_new_listener(char *line); |
William Lallemand | ce83b4a | 2018-10-26 14:47:30 +0200 | [diff] [blame] | 43 | int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc); |
William Lallemand | 309dc9a | 2018-10-26 14:47:45 +0200 | [diff] [blame] | 44 | void mworker_cli_proxy_stop(); |
William Lallemand | ce83b4a | 2018-10-26 14:47:30 +0200 | [diff] [blame] | 45 | |
William Lallemand | cf62f7e | 2018-10-26 14:47:40 +0200 | [diff] [blame] | 46 | /* proxy mode cli functions */ |
| 47 | |
| 48 | /* analyzers */ |
| 49 | int pcli_wait_for_request(struct stream *s, struct channel *req, int an_bit); |
| 50 | int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit); |
| 51 | |
Willy Tarreau | edb91ad | 2019-08-08 19:09:21 +0200 | [diff] [blame] | 52 | /* updates the CLI's context to log <msg> at <severity> and returns 1. This is |
| 53 | * for use in CLI parsers to deal with quick response messages. |
| 54 | */ |
| 55 | static inline int cli_msg(struct appctx *appctx, int severity, const char *msg) |
| 56 | { |
| 57 | appctx->ctx.cli.severity = severity; |
| 58 | appctx->ctx.cli.msg = msg; |
| 59 | appctx->st0 = CLI_ST_PRINT; |
| 60 | return 1; |
| 61 | } |
| 62 | |
| 63 | /* updates the CLI's context to log error message <err> and returns 1. The |
| 64 | * message will be logged at level LOG_ERR. This is for use in CLI parsers to |
| 65 | * deal with quick response messages. |
| 66 | */ |
| 67 | static inline int cli_err(struct appctx *appctx, const char *err) |
| 68 | { |
| 69 | appctx->ctx.cli.msg = err; |
| 70 | appctx->st0 = CLI_ST_PRINT_ERR; |
| 71 | return 1; |
| 72 | } |
| 73 | |
| 74 | /* updates the CLI's context to log <msg> at <severity> and returns 1. The |
| 75 | * message must have been dynamically allocated and will be freed. This is |
| 76 | * for use in CLI parsers to deal with quick response messages. |
| 77 | */ |
| 78 | static inline int cli_dynmsg(struct appctx *appctx, int severity, char *msg) |
| 79 | { |
| 80 | appctx->ctx.cli.severity = severity; |
| 81 | appctx->ctx.cli.err = msg; |
| 82 | appctx->st0 = CLI_ST_PRINT_DYN; |
| 83 | return 1; |
| 84 | } |
| 85 | |
| 86 | /* updates the CLI's context to log error message <err> and returns 1. The |
| 87 | * message must have been dynamically allocated and will be freed. The message |
| 88 | * will be logged at level LOG_ERR. This is for use in CLI parsers to deal with |
| 89 | * quick response messages. |
| 90 | */ |
| 91 | static inline int cli_dynerr(struct appctx *appctx, char *err) |
| 92 | { |
| 93 | appctx->ctx.cli.err = err; |
| 94 | appctx->st0 = CLI_ST_PRINT_FREE; |
| 95 | return 1; |
| 96 | } |
| 97 | |
William Lallemand | cf62f7e | 2018-10-26 14:47:40 +0200 | [diff] [blame] | 98 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 99 | #endif /* _PROTO_CLI_H */ |
| 100 | |