mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-09 19:52:41 +02:00
This makes use of the generic command context allocation so that the appctx doesn't have to declare a specific one anymore. The context is created during parsing (both in the CLI and HTTP). The change looks large but it's particularly mechanical. The context initialization appears in stats.c and http_ana.c. The context is used in stats.c and resolvers.c since "show stat resolvers" points there. That's the reason why the definition moved to stats.h. "show info" and "show stat" continue to share the same state definition for now. Nothing else was modified.
186 lines
7.8 KiB
C
186 lines
7.8 KiB
C
/*
|
|
* include/haproxy/applet-t.h
|
|
* This file describes the applet struct and associated constants.
|
|
*
|
|
* Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
* exclusively.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _HAPROXY_APPLET_T_H
|
|
#define _HAPROXY_APPLET_T_H
|
|
|
|
#include <haproxy/api-t.h>
|
|
#include <haproxy/buf-t.h>
|
|
#include <haproxy/dynbuf-t.h>
|
|
#include <haproxy/freq_ctr-t.h>
|
|
#include <haproxy/obj_type-t.h>
|
|
#include <haproxy/xref-t.h>
|
|
|
|
/* flags for appctx->state */
|
|
#define APPLET_WANT_DIE 0x01 /* applet was running and requested to die */
|
|
|
|
/* Room for per-command context (mostly CLI commands but not only) */
|
|
#define APPLET_MAX_SVCCTX 88
|
|
|
|
struct appctx;
|
|
struct proxy;
|
|
struct conn_stream;
|
|
struct cs_endpoint;
|
|
|
|
/* Applet descriptor */
|
|
struct applet {
|
|
enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */
|
|
/* 3 unused bytes here */
|
|
char *name; /* applet's name to report in logs */
|
|
int (*init)(struct appctx *); /* callback to init resources, may be NULL.
|
|
expect 1 if ok, 0 if an error occurs, -1 if miss data. */
|
|
void (*fct)(struct appctx *); /* internal I/O handler, may never be NULL */
|
|
void (*release)(struct appctx *); /* callback to release resources, may be NULL */
|
|
unsigned int timeout; /* execution timeout. */
|
|
};
|
|
|
|
/* Context of a running applet. */
|
|
struct appctx {
|
|
enum obj_type obj_type; /* OBJ_TYPE_APPCTX */
|
|
/* 3 unused bytes here */
|
|
unsigned short state; /* Internal appctx state */
|
|
unsigned int st0; /* CLI state for stats, session state for peers */
|
|
unsigned int st1; /* prompt/payload (bitwise OR of APPCTX_CLI_ST1_*) for stats, session error for peers */
|
|
struct buffer *chunk; /* used to store unfinished commands */
|
|
unsigned int st2; /* output state for stats, unused by peers */
|
|
struct applet *applet; /* applet this context refers to */
|
|
struct conn_stream *owner;
|
|
struct cs_endpoint *endp;
|
|
struct act_rule *rule; /* rule associated with the applet. */
|
|
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 */
|
|
int cli_severity_output; /* used within the cli_io_handler to format severity output of informational feedback */
|
|
int cli_level; /* the level of CLI which can be lowered dynamically */
|
|
struct buffer_wait buffer_wait; /* position in the list of objects waiting for a buffer */
|
|
struct task *t; /* task associated to the applet */
|
|
struct freq_ctr call_rate; /* appctx call rate */
|
|
struct list wait_entry; /* entry in a list of waiters for an event (e.g. ring events) */
|
|
|
|
/* This anonymous union is temporary for 2.6 to avoid a new API change
|
|
* after 2.6 while keeping the compatibility with pre-2.7 code.
|
|
* The pointer seen by application code is appctx->svcctx. In 2.7 the
|
|
* anonymous union will disappear and the struct "svc" will become
|
|
* svc_storage, which is never accessed directly by application code.
|
|
* The compatibility with the old appctx->ctx.* is preserved for now
|
|
* and this union will disappear in 2.7
|
|
*/
|
|
union {
|
|
/* here we have the service's context (CLI command, applet, etc) */
|
|
void *svcctx; /* pointer to a context used by the command, e.g. <storage> below */
|
|
struct {
|
|
void *shadow; /* shadow of svcctx above, do not use! */
|
|
char storage[APPLET_MAX_SVCCTX]; /* storage of svcctx above */
|
|
} svc; /* generic storage for most commands */
|
|
union {
|
|
struct {
|
|
void *ptr; /* current peer or NULL, do not use for something else */
|
|
} peers; /* used by the peers applet */
|
|
struct {
|
|
int connected;
|
|
struct xref xref; /* cross reference with the Lua object owner. */
|
|
struct list wake_on_read;
|
|
struct list wake_on_write;
|
|
int die;
|
|
} hlua_cosocket; /* used by the Lua cosockets */
|
|
struct {
|
|
struct hlua *hlua;
|
|
int flags;
|
|
struct task *task;
|
|
} hlua_apptcp; /* used by the Lua TCP services */
|
|
struct {
|
|
struct hlua *hlua;
|
|
int left_bytes; /* The max amount of bytes that we can read. */
|
|
int flags;
|
|
int status;
|
|
const char *reason;
|
|
struct task *task;
|
|
} hlua_apphttp; /* used by the Lua HTTP services */
|
|
struct {
|
|
void *ptr; /* private pointer for SPOE filter */
|
|
} spoe; /* used by SPOE filter */
|
|
struct {
|
|
const char *msg; /* pointer to a persistent message to be returned in CLI_ST_PRINT state */
|
|
int severity; /* severity of the message to be returned according to (syslog) rfc5424 */
|
|
char *err; /* pointer to a 'must free' message to be returned in CLI_ST_PRINT_FREE state */
|
|
void *p0, *p1, *p2; /* ...registered commands, initialized to 0 by the CLI before first... */
|
|
size_t o0, o1; /* ...invocation of the keyword parser, except for the list element which... */
|
|
int i0, i1; /* ...is initialized with LIST_INIT(). */
|
|
} cli; /* context used by the CLI */
|
|
struct {
|
|
struct cache_entry *entry; /* Entry to be sent from cache. */
|
|
unsigned int sent; /* The number of bytes already sent for this cache entry. */
|
|
unsigned int offset; /* start offset of remaining data relative to beginning of the next block */
|
|
unsigned int rem_data; /* Remaining bytes for the last data block (HTX only, 0 means process next block) */
|
|
unsigned int send_notmodified:1; /* In case of conditional request, we might want to send a "304 Not Modified"
|
|
* response instead of the stored data. */
|
|
unsigned int unused:31;
|
|
struct shared_block *next; /* The next block of data to be sent for this cache entry. */
|
|
} cache;
|
|
/* all entries below are used by various CLI commands, please
|
|
* keep the grouped together and avoid adding new ones.
|
|
*/
|
|
struct {
|
|
struct hlua *hlua;
|
|
struct task *task;
|
|
struct hlua_function *fcn;
|
|
} hlua_cli;
|
|
struct {
|
|
char *path;
|
|
struct ckch_store *old_ckchs;
|
|
struct ckch_store *new_ckchs;
|
|
struct ckch_inst *next_ckchi;
|
|
struct ckch_store *cur_ckchs;
|
|
|
|
struct ckch_inst_link *next_ckchi_link;
|
|
struct cafile_entry *old_cafile_entry;
|
|
struct cafile_entry *new_cafile_entry;
|
|
struct cafile_entry *cur_cafile_entry;
|
|
|
|
struct cafile_entry *old_crlfile_entry;
|
|
struct cafile_entry *new_crlfile_entry;
|
|
int cafile_type; /* either CA or CRL, depending on the current command */
|
|
int index;
|
|
int show_all;
|
|
} ssl;
|
|
struct {
|
|
void *ptr;
|
|
} sft; /* sink forward target */
|
|
struct {
|
|
struct httpclient *ptr;
|
|
} httpclient;
|
|
|
|
/* NOTE: please add regular applet contexts (ie: not
|
|
* CLI-specific ones) above, before "cli".
|
|
*/
|
|
} ctx; /* context-specific variables used by any applet */
|
|
}; /* end of anon union */
|
|
};
|
|
|
|
#endif /* _HAPROXY_APPLET_T_H */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*/
|