From: Willy Tarreau Date: Thu, 24 Nov 2016 14:53:53 +0000 (+0100) Subject: CLEANUP: cli: rename STAT_CLI_* to CLI_ST_* X-Git-Tag: v1.7.0~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b6e547be8e3177d6463cdd1b2df05da9959db8b;p=thirdparty%2Fhaproxy.git CLEANUP: cli: rename STAT_CLI_* to CLI_ST_* These are in CLI states, not stats states anymore. STAT_CLI_O_CUSTOM was more appropriately renamed CLI_ST_CALLBACK. --- diff --git a/include/types/applet.h b/include/types/applet.h index cffc832563..26bb4ea572 100644 --- a/include/types/applet.h +++ b/include/types/applet.h @@ -54,8 +54,8 @@ struct appctx { struct applet *applet; /* applet this context refers to */ void *owner; /* pointer to upper layer's entity (eg: stream interface) */ struct act_rule *rule; /* rule associated with the applet. */ - int (*io_handler)(struct appctx *appctx); /* used within the cli_io_handler when st0 = STAT_CLI_O_CUSTOM */ - void (*io_release)(struct appctx *appctx); /* used within the cli_io_handler when st0 = STAT_CLI_O_CUSTOM, + int (*io_handler)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK */ + void (*io_release)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK, if the command is terminated or the session released */ void *private; diff --git a/include/types/cli.h b/include/types/cli.h index 9549237676..80da45db43 100644 --- a/include/types/cli.h +++ b/include/types/cli.h @@ -38,16 +38,16 @@ struct cli_kw_list { struct cli_kw kw[VAR_ARRAY]; }; -/* stats socket states */ +/* CLI states */ enum { - STAT_CLI_INIT = 0, /* initial state, must leave to zero ! */ - STAT_CLI_END, /* final state, let's close */ - STAT_CLI_GETREQ, /* wait for a request */ - STAT_CLI_OUTPUT, /* all states after this one are responses */ - STAT_CLI_PROMPT, /* display the prompt (first output, same code) */ - STAT_CLI_PRINT, /* display message in cli->msg */ - STAT_CLI_PRINT_FREE, /* display message in cli->msg. After the display, free the pointer */ - STAT_CLI_O_CUSTOM, /* custom callback pointer */ + CLI_ST_INIT = 0, /* initial state, must leave to zero ! */ + CLI_ST_END, /* final state, let's close */ + CLI_ST_GETREQ, /* wait for a request */ + CLI_ST_OUTPUT, /* all states after this one are responses */ + CLI_ST_PROMPT, /* display the prompt (first output, same code) */ + CLI_ST_PRINT, /* display message in cli->msg */ + CLI_ST_PRINT_FREE, /* display message in cli->msg. After the display, free the pointer */ + CLI_ST_CALLBACK, /* custom callback pointer */ }; diff --git a/src/cli.c b/src/cli.c index 95ebd704bf..119e087cf5 100644 --- a/src/cli.c +++ b/src/cli.c @@ -384,7 +384,7 @@ int cli_has_level(struct appctx *appctx, int level) if (strm_li(s)->bind_conf->level < level) { appctx->ctx.cli.msg = stats_permission_denied_msg; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 0; } return 1; @@ -453,7 +453,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) if ((kw = cli_find_kw(args))) { if (kw->parse) { if (kw->parse(args, appctx, kw->private) == 0 && kw->io_handler) { - appctx->st0 = STAT_CLI_O_CUSTOM; + appctx->st0 = CLI_ST_CALLBACK; appctx->io_handler = kw->io_handler; appctx->io_release = kw->io_release; } @@ -468,7 +468,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) * state machine handling requests and various responses. We read a request, * then we process it and send the response, and we possibly display a prompt. * Then we can read again. The state is stored in appctx->st0 and is one of the - * STAT_CLI_* constants. appctx->st1 is used to indicate whether prompt is enabled + * CLI_ST_* constants. appctx->st1 is used to indicate whether prompt is enabled * or not. */ static void cli_io_handler(struct appctx *appctx) @@ -483,19 +483,19 @@ static void cli_io_handler(struct appctx *appctx) goto out; while (1) { - if (appctx->st0 == STAT_CLI_INIT) { + if (appctx->st0 == CLI_ST_INIT) { /* Stats output not initialized yet */ memset(&appctx->ctx.stats, 0, sizeof(appctx->ctx.stats)); - appctx->st0 = STAT_CLI_GETREQ; + appctx->st0 = CLI_ST_GETREQ; } - else if (appctx->st0 == STAT_CLI_END) { + else if (appctx->st0 == CLI_ST_END) { /* Let's close for real now. We just close the request * side, the conditions below will complete if needed. */ si_shutw(si); break; } - else if (appctx->st0 == STAT_CLI_GETREQ) { + else if (appctx->st0 == CLI_ST_GETREQ) { /* ensure we have some output room left in the event we * would want to return some info right after parsing. */ @@ -508,7 +508,7 @@ static void cli_io_handler(struct appctx *appctx) if (reql <= 0) { /* closed or EOL not found */ if (reql == 0) break; - appctx->st0 = STAT_CLI_END; + appctx->st0 = CLI_ST_END; continue; } @@ -533,7 +533,7 @@ static void cli_io_handler(struct appctx *appctx) */ len = reql - 1; if (trash.str[len] != '\n') { - appctx->st0 = STAT_CLI_END; + appctx->st0 = CLI_ST_END; continue; } @@ -542,10 +542,10 @@ static void cli_io_handler(struct appctx *appctx) trash.str[len] = '\0'; - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; if (len) { if (strcmp(trash.str, "quit") == 0) { - appctx->st0 = STAT_CLI_END; + appctx->st0 = CLI_ST_END; continue; } else if (strcmp(trash.str, "prompt") == 0) @@ -557,10 +557,10 @@ static void cli_io_handler(struct appctx *appctx) appctx->ctx.cli.msg = dynamic_usage_msg; else appctx->ctx.cli.msg = stats_sock_usage_msg; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } /* NB: stats_sock_parse_request() may have put - * another STAT_CLI_O_* into appctx->st0. + * another CLI_ST_O_* into appctx->st0. */ } else if (!appctx->st1) { @@ -573,7 +573,7 @@ static void cli_io_handler(struct appctx *appctx) appctx->ctx.cli.msg = dynamic_usage_msg; else appctx->ctx.cli.msg = stats_sock_usage_msg; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } /* re-adjust req buffer */ @@ -582,26 +582,26 @@ static void cli_io_handler(struct appctx *appctx) } else { /* output functions */ switch (appctx->st0) { - case STAT_CLI_PROMPT: + case CLI_ST_PROMPT: break; - case STAT_CLI_PRINT: + case CLI_ST_PRINT: if (bi_putstr(si_ic(si), appctx->ctx.cli.msg) != -1) - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; else si_applet_cant_put(si); break; - case STAT_CLI_PRINT_FREE: + case CLI_ST_PRINT_FREE: if (bi_putstr(si_ic(si), appctx->ctx.cli.err) != -1) { free(appctx->ctx.cli.err); - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; } else si_applet_cant_put(si); break; - case STAT_CLI_O_CUSTOM: /* use custom pointer */ + case CLI_ST_CALLBACK: /* use custom pointer */ if (appctx->io_handler) if (appctx->io_handler(appctx)) { - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; if (appctx->io_release) { appctx->io_release(appctx); appctx->io_release = NULL; @@ -614,15 +614,15 @@ static void cli_io_handler(struct appctx *appctx) } /* The post-command prompt is either LF alone or LF + '> ' in interactive mode */ - if (appctx->st0 == STAT_CLI_PROMPT) { + if (appctx->st0 == CLI_ST_PROMPT) { if (bi_putstr(si_ic(si), appctx->st1 ? "\n> " : "\n") != -1) - appctx->st0 = STAT_CLI_GETREQ; + appctx->st0 = CLI_ST_GETREQ; else si_applet_cant_put(si); } /* If the output functions are still there, it means they require more room. */ - if (appctx->st0 >= STAT_CLI_OUTPUT) + if (appctx->st0 >= CLI_ST_OUTPUT) break; /* Now we close the output if one of the writers did so, @@ -631,12 +631,12 @@ static void cli_io_handler(struct appctx *appctx) * to be sent in non-interactive mode. */ if ((res->flags & (CF_SHUTW|CF_SHUTW_NOW)) || (!appctx->st1 && !req->buf->o)) { - appctx->st0 = STAT_CLI_END; + appctx->st0 = CLI_ST_END; continue; } /* switch state back to GETREQ to read next requests */ - appctx->st0 = STAT_CLI_GETREQ; + appctx->st0 = CLI_ST_GETREQ; } } @@ -651,7 +651,7 @@ static void cli_io_handler(struct appctx *appctx) si_shutw(si); } - if ((req->flags & CF_SHUTW) && (si->state == SI_ST_EST) && (appctx->st0 < STAT_CLI_OUTPUT)) { + if ((req->flags & CF_SHUTW) && (si->state == SI_ST_EST) && (appctx->st0 < CLI_ST_OUTPUT)) { DPRINTF(stderr, "%s@%d: buf to si closed. req=%08x, res=%08x, st=%d\n", __FUNCTION__, __LINE__, req->flags, res->flags, si->state); /* We have no more processing to do, and nothing more to send, and @@ -678,7 +678,7 @@ static void cli_release_handler(struct appctx *appctx) appctx->io_release(appctx); appctx->io_release = NULL; } - else if (appctx->st0 == STAT_CLI_PRINT_FREE) { + else if (appctx->st0 == CLI_ST_PRINT_FREE) { free(appctx->ctx.cli.err); appctx->ctx.cli.err = NULL; } @@ -739,7 +739,7 @@ static int cli_parse_show_env(char **args, struct appctx *appctx, void *private) } if (!*appctx->ctx.env.var) { appctx->ctx.cli.msg = "Variable not found\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } appctx->st2 = STAT_ST_END; @@ -759,14 +759,14 @@ static int cli_parse_set_timeout(char **args, struct appctx *appctx, void *priva if (!*args[3]) { appctx->ctx.cli.msg = "Expects an integer value.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } res = parse_time_err(args[3], &timeout, TIME_UNIT_S); if (res || timeout < 1) { appctx->ctx.cli.msg = "Invalid timeout value.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -776,7 +776,7 @@ static int cli_parse_set_timeout(char **args, struct appctx *appctx, void *priva } else { appctx->ctx.cli.msg = "'set timeout' only supports 'cli'.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } @@ -791,14 +791,14 @@ static int cli_parse_set_maxconn_global(char **args, struct appctx *appctx, void if (!*args[3]) { appctx->ctx.cli.msg = "Expects an integer value.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } v = atoi(args[3]); if (v > global.hardmaxconn) { appctx->ctx.cli.msg = "Value out of range.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -846,20 +846,20 @@ static int cli_parse_set_ratelimit(char **args, struct appctx *appctx, void *pri " - 'ssl-session global' to set the per-process maximum SSL session rate\n" #endif " - 'http-compression global' to set the per-process maximum compression speed in kB/s\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!*args[4]) { appctx->ctx.cli.msg = "Expects an integer value.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } v = atoi(args[4]); if (v < 0) { appctx->ctx.cli.msg = "Value out of range.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } diff --git a/src/dns.c b/src/dns.c index b391f4abad..e29c3e4bf5 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1282,7 +1282,7 @@ static int cli_parse_stat_resolvers(char **args, struct appctx *appctx, void *pr } if (appctx->ctx.resolvers.ptr == NULL) { appctx->ctx.cli.msg = "Can't find that resolvers section\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } diff --git a/src/map.c b/src/map.c index aabaa60df2..71d480c5c3 100644 --- a/src/map.c +++ b/src/map.c @@ -551,7 +551,7 @@ static int cli_parse_get_map(char **args, struct appctx *appctx, void *private) appctx->ctx.cli.msg = "Missing map identifier and/or key.\n"; else appctx->ctx.cli.msg = "Missing ACL identifier and/or key.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -562,7 +562,7 @@ static int cli_parse_get_map(char **args, struct appctx *appctx, void *private) appctx->ctx.cli.msg = "Unknown map identifier. Please use # or .\n"; else appctx->ctx.cli.msg = "Unknown ACL identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -575,7 +575,7 @@ static int cli_parse_get_map(char **args, struct appctx *appctx, void *private) appctx->ctx.map.chunk.str = strdup(args[3]); if (!appctx->ctx.map.chunk.str) { appctx->ctx.cli.msg = "Out of memory error.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -598,7 +598,7 @@ static int cli_parse_show_map(char **args, struct appctx *appctx, void *private) /* no parameter: display all map available */ if (!*args[2]) { appctx->st2 = STAT_ST_INIT; - appctx->st0 = STAT_CLI_O_CUSTOM; + appctx->st0 = CLI_ST_CALLBACK; appctx->io_handler = cli_io_handler_pats_list; return 0; } @@ -611,11 +611,11 @@ static int cli_parse_show_map(char **args, struct appctx *appctx, void *private) appctx->ctx.cli.msg = "Unknown map identifier. Please use # or .\n"; else appctx->ctx.cli.msg = "Unknown ACL identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } appctx->st2 = STAT_ST_INIT; - appctx->st0 = STAT_CLI_O_CUSTOM; + appctx->st0 = CLI_ST_CALLBACK; appctx->io_handler = cli_io_handler_pat_list; return 0; } @@ -634,7 +634,7 @@ static int cli_parse_set_map(char **args, struct appctx *appctx, void *private) /* Expect three parameters: map name, key and new value. */ if (!*args[2] || !*args[3] || !*args[4]) { appctx->ctx.cli.msg = "'set map' expects three parameters: map identifier, key and value.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -642,7 +642,7 @@ static int cli_parse_set_map(char **args, struct appctx *appctx, void *private) appctx->ctx.map.ref = pat_ref_lookup_ref(args[2]); if (!appctx->ctx.map.ref) { appctx->ctx.cli.msg = "Unknown map identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -658,7 +658,7 @@ static int cli_parse_set_map(char **args, struct appctx *appctx, void *private) conv = strtoll(&args[3][1], &error, 16); if (*error != '\0') { appctx->ctx.cli.msg = "Malformed identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -666,7 +666,7 @@ static int cli_parse_set_map(char **args, struct appctx *appctx, void *private) ref = (struct pat_ref_elt *)(long)conv; if ((long long int)(long)ref != conv) { appctx->ctx.cli.msg = "Malformed identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -676,7 +676,7 @@ static int cli_parse_set_map(char **args, struct appctx *appctx, void *private) if (err) memprintf(&err, "%s.\n", err); appctx->ctx.cli.err = err; - appctx->st0 = STAT_CLI_PRINT_FREE; + appctx->st0 = CLI_ST_PRINT_FREE; return 1; } } @@ -689,13 +689,13 @@ static int cli_parse_set_map(char **args, struct appctx *appctx, void *private) if (err) memprintf(&err, "%s.\n", err); appctx->ctx.cli.err = err; - appctx->st0 = STAT_CLI_PRINT_FREE; + appctx->st0 = CLI_ST_PRINT_FREE; return 1; } } /* The set is done, send message. */ - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; return 0; } return 1; @@ -720,14 +720,14 @@ static int cli_parse_add_map(char **args, struct appctx *appctx, void *private) if (appctx->ctx.map.display_flags == PAT_REF_MAP) { if (!*args[2] || !*args[3] || !*args[4]) { appctx->ctx.cli.msg = "'add map' expects three parameters: map identifier, key and value.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } else { if (!*args[2] || !*args[3]) { appctx->ctx.cli.msg = "'add acl' expects two parameters: ACL identifier and pattern.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } @@ -739,7 +739,7 @@ static int cli_parse_add_map(char **args, struct appctx *appctx, void *private) appctx->ctx.cli.msg = "Unknown map identifier. Please use # or .\n"; else appctx->ctx.cli.msg = "Unknown ACL identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -750,7 +750,7 @@ static int cli_parse_add_map(char **args, struct appctx *appctx, void *private) (appctx->ctx.map.ref->flags & PAT_REF_SMP)) { appctx->ctx.cli.msg = "This ACL is shared with a map containing samples. " "You must use the command 'add map' to add values.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -764,12 +764,12 @@ static int cli_parse_add_map(char **args, struct appctx *appctx, void *private) if (err) memprintf(&err, "%s.\n", err); appctx->ctx.cli.err = err; - appctx->st0 = STAT_CLI_PRINT_FREE; + appctx->st0 = CLI_ST_PRINT_FREE; return 1; } /* The add is done, send message. */ - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; return 1; } @@ -787,7 +787,7 @@ static int cli_parse_del_map(char **args, struct appctx *appctx, void *private) if (appctx->ctx.map.display_flags == PAT_REF_MAP) { if (!*args[2] || !*args[3]) { appctx->ctx.cli.msg = "This command expects two parameters: map identifier and key.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } @@ -795,7 +795,7 @@ static int cli_parse_del_map(char **args, struct appctx *appctx, void *private) else { if (!*args[2] || !*args[3]) { appctx->ctx.cli.msg = "This command expects two parameters: ACL identifier and key.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } @@ -805,7 +805,7 @@ static int cli_parse_del_map(char **args, struct appctx *appctx, void *private) if (!appctx->ctx.map.ref || !(appctx->ctx.map.ref->flags & appctx->ctx.map.display_flags)) { appctx->ctx.cli.msg = "Unknown map identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -821,7 +821,7 @@ static int cli_parse_del_map(char **args, struct appctx *appctx, void *private) conv = strtoll(&args[3][1], &error, 16); if (*error != '\0') { appctx->ctx.cli.msg = "Malformed identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -829,7 +829,7 @@ static int cli_parse_del_map(char **args, struct appctx *appctx, void *private) ref = (struct pat_ref_elt *)(long)conv; if ((long long int)(long)ref != conv) { appctx->ctx.cli.msg = "Malformed identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -837,7 +837,7 @@ static int cli_parse_del_map(char **args, struct appctx *appctx, void *private) if (!pat_ref_delete_by_id(appctx->ctx.map.ref, ref)) { /* The entry is not found, send message. */ appctx->ctx.cli.msg = "Key not found.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } @@ -848,13 +848,13 @@ static int cli_parse_del_map(char **args, struct appctx *appctx, void *private) if (!pat_ref_delete(appctx->ctx.map.ref, args[3])) { /* The entry is not found, send message. */ appctx->ctx.cli.msg = "Key not found.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } /* The deletion is done, send message. */ - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; return 1; } @@ -874,7 +874,7 @@ static int cli_parse_clear_map(char **args, struct appctx *appctx, void *private appctx->ctx.cli.msg = "Missing map identifier.\n"; else appctx->ctx.cli.msg = "Missing ACL identifier.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -886,7 +886,7 @@ static int cli_parse_clear_map(char **args, struct appctx *appctx, void *private appctx->ctx.cli.msg = "Unknown map identifier. Please use # or .\n"; else appctx->ctx.cli.msg = "Unknown ACL identifier. Please use # or .\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -894,7 +894,7 @@ static int cli_parse_clear_map(char **args, struct appctx *appctx, void *private pat_ref_prune(appctx->ctx.map.ref); /* return response */ - appctx->st0 = STAT_CLI_PROMPT; + appctx->st0 = CLI_ST_PROMPT; return 1; } return 0; diff --git a/src/proxy.c b/src/proxy.c index 6343ac33aa..90e9b23d94 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1231,14 +1231,14 @@ struct proxy *cli_find_frontend(struct appctx *appctx, const char *arg) if (!*arg) { appctx->ctx.cli.msg = "A frontend name is expected.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return NULL; } px = proxy_fe_by_name(arg); if (!px) { appctx->ctx.cli.msg = "No such frontend.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return NULL; } return px; @@ -1260,7 +1260,7 @@ static int cli_parse_show_servers(char **args, struct appctx *appctx, void *priv if (!appctx->ctx.server_state.px) { appctx->ctx.cli.msg = "Can't find backend.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } appctx->ctx.server_state.iid = appctx->ctx.server_state.px->uuid; @@ -1435,14 +1435,14 @@ static int cli_parse_set_maxconn_frontend(char **args, struct appctx *appctx, vo if (!*args[4]) { appctx->ctx.cli.msg = "Integer value expected.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } v = atoi(args[4]); if (v < 0) { appctx->ctx.cli.msg = "Value out of range.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -1476,7 +1476,7 @@ static int cli_parse_shutdown_frontend(char **args, struct appctx *appctx, void if (px->state == PR_STSTOPPED) { appctx->ctx.cli.msg = "Frontend was already shut down.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -1502,19 +1502,19 @@ static int cli_parse_disable_frontend(char **args, struct appctx *appctx, void * if (px->state == PR_STSTOPPED) { appctx->ctx.cli.msg = "Frontend was previously shut down, cannot disable.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (px->state == PR_STPAUSED) { appctx->ctx.cli.msg = "Frontend is already disabled.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!pause_proxy(px)) { appctx->ctx.cli.msg = "Failed to pause frontend, check logs for precise cause.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } return 1; @@ -1534,19 +1534,19 @@ static int cli_parse_enable_frontend(char **args, struct appctx *appctx, void *p if (px->state == PR_STSTOPPED) { appctx->ctx.cli.msg = "Frontend was previously shut down, cannot enable.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (px->state != PR_STPAUSED) { appctx->ctx.cli.msg = "Frontend is already enabled.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!resume_proxy(px)) { appctx->ctx.cli.msg = "Failed to resume frontend, check logs for precise cause (port conflict?).\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } return 1; diff --git a/src/server.c b/src/server.c index 343927b09a..2f539c9993 100644 --- a/src/server.c +++ b/src/server.c @@ -3349,7 +3349,7 @@ int srv_init_addr(void) /* Expects to find a backend and a server in under the form /, * and returns the pointer to the server. Otherwise, display adequate error messages - * on the CLI, sets the CLI's state to STAT_CLI_PRINT and returns NULL. This is only + * on the CLI, sets the CLI's state to CLI_ST_PRINT and returns NULL. This is only * used for CLI commands requiring a server name. * Important: the is modified to remove the '/'. */ @@ -3368,19 +3368,19 @@ struct server *cli_find_server(struct appctx *appctx, char *arg) if (!*line || !*arg) { appctx->ctx.cli.msg = "Require 'backend/server'.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return NULL; } if (!get_backend_server(arg, line, &px, &sv)) { appctx->ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return NULL; } if (px->state == PR_STSTOPPED) { appctx->ctx.cli.msg = "Proxy is disabled.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return NULL; } @@ -3404,7 +3404,7 @@ static int cli_parse_set_server(char **args, struct appctx *appctx, void *privat warning = server_parse_weight_change_request(sv, args[4]); if (warning) { appctx->ctx.cli.msg = warning; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } } else if (strcmp(args[3], "state") == 0) { @@ -3416,13 +3416,13 @@ static int cli_parse_set_server(char **args, struct appctx *appctx, void *privat srv_adm_set_maint(sv); else { appctx->ctx.cli.msg = "'set server state' expects 'ready', 'drain' and 'maint'.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } } else if (strcmp(args[3], "health") == 0) { if (sv->track) { appctx->ctx.cli.msg = "cannot change health on a tracking server.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } else if (strcmp(args[4], "up") == 0) { sv->check.health = sv->check.rise + sv->check.fall - 1; @@ -3438,13 +3438,13 @@ static int cli_parse_set_server(char **args, struct appctx *appctx, void *privat } else { appctx->ctx.cli.msg = "'set server health' expects 'up', 'stopping', or 'down'.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } } else if (strcmp(args[3], "agent") == 0) { if (!(sv->agent.state & CHK_ST_ENABLED)) { appctx->ctx.cli.msg = "agent checks are not enabled on this server.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } else if (strcmp(args[4], "up") == 0) { sv->agent.health = sv->agent.rise + sv->agent.fall - 1; @@ -3456,35 +3456,35 @@ static int cli_parse_set_server(char **args, struct appctx *appctx, void *privat } else { appctx->ctx.cli.msg = "'set server agent' expects 'up' or 'down'.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } } else if (strcmp(args[3], "check-port") == 0) { int i = 0; if (strl2irc(args[4], strlen(args[4]), &i) != 0) { appctx->ctx.cli.msg = "'set server check-port' expects an integer as argument.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } if ((i < 0) || (i > 65535)) { appctx->ctx.cli.msg = "provided port is not valid.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } /* prevent the update of port to 0 if MAPPORTS are in use */ if ((sv->flags & SRV_F_MAPPORTS) && (i == 0)) { appctx->ctx.cli.msg = "can't unset 'port' since MAPPORTS is in use.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } sv->check.port = i; appctx->ctx.cli.msg = "health check port updated.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } else if (strcmp(args[3], "addr") == 0) { char *addr = NULL; char *port = NULL; if (strlen(args[4]) == 0) { appctx->ctx.cli.msg = "set server / addr requires an address and optionally a port.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } else { @@ -3496,13 +3496,13 @@ static int cli_parse_set_server(char **args, struct appctx *appctx, void *privat warning = update_server_addr_port(sv, addr, port, "stats socket command"); if (warning) { appctx->ctx.cli.msg = warning; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } srv_clr_admin_flag(sv, SRV_ADMF_RMAINT); } else { appctx->ctx.cli.msg = "'set server ' only supports 'agent', 'health', 'state', 'weight', 'addr' and 'check-port'.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } return 1; } @@ -3524,13 +3524,13 @@ static int cli_parse_get_weight(char **args, struct appctx *appctx, void *privat if (!*line) { appctx->ctx.cli.msg = "Require 'backend/server'.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!get_backend_server(args[2], line, &px, &sv)) { appctx->ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -3557,7 +3557,7 @@ static int cli_parse_set_weight(char **args, struct appctx *appctx, void *privat warning = server_parse_weight_change_request(sv, args[3]); if (warning) { appctx->ctx.cli.msg = warning; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } return 1; } @@ -3578,7 +3578,7 @@ static int cli_parse_set_maxconn_server(char **args, struct appctx *appctx, void warning = server_parse_maxconn_change_request(sv, args[4]); if (warning) { appctx->ctx.cli.msg = warning; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; } return 1; } @@ -3645,7 +3645,7 @@ static int cli_parse_enable_agent(char **args, struct appctx *appctx, void *priv if (!(sv->agent.state & CHK_ST_CONFIGURED)) { appctx->ctx.cli.msg = "Agent was not configured on this server, cannot enable.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 62c89af9fe..cf2f855267 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -6140,7 +6140,7 @@ static int cli_parse_show_tlskeys(char **args, struct appctx *appctx, void *priv if (!*args[2]) { appctx->ctx.tlskeys.dump_all = 1; appctx->st2 = STAT_ST_INIT; - appctx->st0 = STAT_CLI_O_CUSTOM; + appctx->st0 = CLI_ST_CALLBACK; appctx->io_handler = cli_io_handler_tlskeys_files; return 1; @@ -6154,12 +6154,12 @@ static int cli_parse_show_tlskeys(char **args, struct appctx *appctx, void *priv appctx->ctx.tlskeys.ref = tlskeys_ref_lookup_ref(args[2]); if(!appctx->ctx.tlskeys.ref) { appctx->ctx.cli.msg = "'show tls-keys' unable to locate referenced filename\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } appctx->st2 = STAT_ST_INIT; - appctx->st0 = STAT_CLI_O_CUSTOM; + appctx->st0 = CLI_ST_CALLBACK; appctx->io_handler = cli_io_handler_tlskeys_entries; return 1; } @@ -6170,21 +6170,21 @@ static int cli_parse_set_tlskeys(char **args, struct appctx *appctx, void *priva /* Expect two parameters: the filename and the new new TLS key in encoding */ if (!*args[3] || !*args[4]) { appctx->ctx.cli.msg = "'set ssl tls-key' expects a filename and the new TLS key in base64 encoding.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } appctx->ctx.tlskeys.ref = tlskeys_ref_lookup_ref(args[3]); if(!appctx->ctx.tlskeys.ref) { appctx->ctx.cli.msg = "'set ssl tls-key' unable to locate referenced filename\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } trash.len = base64dec(args[4], strlen(args[4]), trash.str, trash.size); if (trash.len != sizeof(struct tls_sess_key)) { appctx->ctx.cli.msg = "'set ssl tls-key' received invalid base64 encoded TLS key.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -6192,7 +6192,7 @@ static int cli_parse_set_tlskeys(char **args, struct appctx *appctx, void *priva appctx->ctx.tlskeys.ref->tls_ticket_enc_index = (appctx->ctx.tlskeys.ref->tls_ticket_enc_index + 1) % TLS_TICKETS_NO; appctx->ctx.cli.msg = "TLS ticket key updated!"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -6205,14 +6205,14 @@ static int cli_parse_set_ocspresponse(char **args, struct appctx *appctx, void * /* Expect one parameter: the new response in base64 encoding */ if (!*args[3]) { appctx->ctx.cli.msg = "'set ssl ocsp-response' expects response in base64 encoding.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } trash.len = base64dec(args[3], strlen(args[3]), trash.str, trash.size); if (trash.len < 0) { appctx->ctx.cli.msg = "'set ssl ocsp-response' received invalid base64 encoded response.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -6220,16 +6220,16 @@ static int cli_parse_set_ocspresponse(char **args, struct appctx *appctx, void * if (err) { memprintf(&err, "%s.\n", err); appctx->ctx.cli.err = err; - appctx->st0 = STAT_CLI_PRINT_FREE; + appctx->st0 = CLI_ST_PRINT_FREE; } return 1; } appctx->ctx.cli.msg = "OCSP Response updated!"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; #else appctx->ctx.cli.msg = "HAProxy was compiled against a version of OpenSSL that doesn't support OCSP stapling.\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; #endif diff --git a/src/stick_table.c b/src/stick_table.c index dc772ae220..29017d901c 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -1652,7 +1652,7 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) if (!*args[4]) { appctx->ctx.cli.msg = "Key value expected\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -1675,7 +1675,7 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) (errno != 0 && val == 0) || endptr == args[4] || val > 0xffffffff) { appctx->ctx.cli.msg = "Invalid key\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } uint32_key = (uint32_t) val; @@ -1702,7 +1702,7 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) appctx->ctx.cli.msg = "Unknown action\n"; break; } - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -1729,7 +1729,7 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) if (ts->ref_cnt) { /* don't delete an entry which is currently referenced */ appctx->ctx.cli.msg = "Entry currently in use, cannot remove\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } stksess_kill(&px->table, ts); @@ -1743,7 +1743,7 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) if (!ts) { /* don't delete an entry which is currently referenced */ appctx->ctx.cli.msg = "Unable to allocate a new entry\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } stktable_store(&px->table, ts, 1); @@ -1752,26 +1752,26 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) for (cur_arg = 5; *args[cur_arg]; cur_arg += 2) { if (strncmp(args[cur_arg], "data.", 5) != 0) { appctx->ctx.cli.msg = "\"data.\" followed by a value expected\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } data_type = stktable_get_data_type(args[cur_arg] + 5); if (data_type < 0) { appctx->ctx.cli.msg = "Unknown data type\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!px->table.data_ofs[data_type]) { appctx->ctx.cli.msg = "Data type not stored in this table\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!*args[cur_arg+1] || strl2llrc(args[cur_arg+1], strlen(args[cur_arg+1]), &value) != 0) { appctx->ctx.cli.msg = "Require a valid integer value to store\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -1804,7 +1804,7 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) default: appctx->ctx.cli.msg = "Unknown action\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; break; } return 1; @@ -1819,7 +1819,7 @@ static int table_prepare_data_request(struct appctx *appctx, char **args) if (action != STK_CLI_ACT_SHOW && action != STK_CLI_ACT_CLR) { appctx->ctx.cli.msg = "content-based lookup is only supported with the \"show\" and \"clear\" actions"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -1827,26 +1827,26 @@ static int table_prepare_data_request(struct appctx *appctx, char **args) appctx->ctx.table.data_type = stktable_get_data_type(args[3] + 5); if (appctx->ctx.table.data_type < 0) { appctx->ctx.cli.msg = "Unknown data type\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!((struct proxy *)appctx->ctx.table.target)->table.data_ofs[appctx->ctx.table.data_type]) { appctx->ctx.cli.msg = "Data type not stored in this table\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } appctx->ctx.table.data_op = get_std_op(args[4]); if (appctx->ctx.table.data_op < 0) { appctx->ctx.cli.msg = "Require and operator among \"eq\", \"ne\", \"le\", \"ge\", \"lt\", \"gt\"\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } if (!*args[5] || strl2llrc(args[5], strlen(args[5]), &appctx->ctx.table.value) != 0) { appctx->ctx.cli.msg = "Require a valid integer value to compare against\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -1870,7 +1870,7 @@ static int cli_parse_table_req(char **args, struct appctx *appctx, void *private appctx->ctx.table.target = proxy_tbl_by_name(args[2]); if (!appctx->ctx.table.target) { appctx->ctx.cli.msg = "No such table\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } } @@ -1904,7 +1904,7 @@ err_args: appctx->ctx.cli.msg = "Unknown action\n"; break; } - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } diff --git a/src/stream.c b/src/stream.c index 0c0a34f844..8ed3047d75 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3924,7 +3924,7 @@ static int cli_parse_shutdown_session(char **args, struct appctx *appctx, void * if (!*args[2]) { appctx->ctx.cli.msg = "Session pointer expected (use 'show sess').\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; } @@ -3939,7 +3939,7 @@ static int cli_parse_shutdown_session(char **args, struct appctx *appctx, void * /* do we have the stream ? */ if (strm != ptr) { appctx->ctx.cli.msg = "No such session (use 'show sess').\n"; - appctx->st0 = STAT_CLI_PRINT; + appctx->st0 = CLI_ST_PRINT; return 1; }