blob: ff82ef3c50a6ad698ecf34572b3fd5782488ae7c [file] [log] [blame]
Willy Tarreau8a8d83b2015-04-13 13:24:54 +02001/*
2 * include/types/applet.h
3 * This file describes the applet struct and associated constants.
4 *
5 * Copyright (C) 2000-2015 Willy Tarreau - w@1wt.eu
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _TYPES_APPLET_H
23#define _TYPES_APPLET_H
24
25#include <types/hlua.h>
26#include <types/obj_type.h>
27#include <common/chunk.h>
28#include <common/config.h>
29
30struct appctx;
31
32/* Applet descriptor */
Willy Tarreau30576452015-04-13 13:50:30 +020033struct applet {
Willy Tarreau8a8d83b2015-04-13 13:24:54 +020034 enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */
35 /* 3 unused bytes here */
36 char *name; /* applet's name to report in logs */
37 void (*fct)(struct appctx *); /* internal I/O handler, may never be NULL */
38 void (*release)(struct appctx *); /* callback to release resources, may be NULL */
39};
40
41/* Context of a running applet. */
42struct appctx {
Willy Tarreau81f38d62015-04-13 17:11:11 +020043 struct list runq; /* chaining in the applet run queue */
Willy Tarreau8a8d83b2015-04-13 13:24:54 +020044 enum obj_type obj_type; /* OBJ_TYPE_APPCTX */
45 /* 3 unused bytes here */
46 unsigned int st0; /* CLI state for stats, session state for peers */
47 unsigned int st1; /* prompt for stats, session error for peers */
48 unsigned int st2; /* output state for stats, unused by peers */
Willy Tarreau30576452015-04-13 13:50:30 +020049 struct applet *applet; /* applet this context refers to */
Willy Tarreau8a8d83b2015-04-13 13:24:54 +020050 void *owner; /* pointer to upper layer's entity (eg: stream interface) */
51
52 union {
53 struct {
54 struct proxy *px;
55 struct server *sv;
56 void *l;
57 int scope_str; /* limit scope to a frontend/backend substring */
58 int scope_len; /* length of the string above in the buffer */
59 int px_st; /* STAT_PX_ST* */
60 unsigned int flags; /* STAT_* */
61 int iid, type, sid; /* proxy id, type and service id if bounding of stats is enabled */
62 int st_code; /* the status code returned by an action */
63 } stats;
64 struct {
65 struct bref bref; /* back-reference from the session being dumped */
66 void *target; /* session we want to dump, or NULL for all */
67 unsigned int uid; /* if non-null, the uniq_id of the session being dumped */
68 int section; /* section of the session being dumped */
69 int pos; /* last position of the current session's buffer */
70 } sess;
71 struct {
72 int iid; /* if >= 0, ID of the proxy to filter on */
73 struct proxy *px; /* current proxy being dumped, NULL = not started yet. */
74 unsigned int buf; /* buffer being dumped, 0 = req, 1 = rep */
75 unsigned int sid; /* session ID of error being dumped */
76 int ptr; /* <0: headers, >=0 : text pointer to restart from */
77 int bol; /* pointer to beginning of current line */
78 } errors;
79 struct {
80 void *target; /* table we want to dump, or NULL for all */
81 struct proxy *proxy; /* table being currently dumped (first if NULL) */
82 struct stksess *entry; /* last entry we were trying to dump (or first if NULL) */
83 long long value; /* value to compare against */
84 signed char data_type; /* type of data to compare, or -1 if none */
85 signed char data_op; /* operator (STD_OP_*) when data_type set */
86 } table;
87 struct {
88 const char *msg; /* pointer to a persistent message to be returned in PRINT state */
89 char *err; /* pointer to a 'must free' message to be returned in PRINT_FREE state */
90 } cli;
91 struct {
92 void *ptr; /* multi-purpose pointer for peers */
93 } peers;
94 struct {
95 unsigned int display_flags;
96 struct pat_ref *ref;
97 struct pat_ref_elt *elt;
98 struct map_descriptor *desc;
99 struct pattern_expr *expr;
100 struct chunk chunk;
101 } map;
Nenad Merdanovic200b0fa2015-05-09 08:46:01 +0200102#if (defined SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB && TLS_TICKETS_NO > 0)
103 struct {
104 struct tls_keys_ref *ref;
105 } tlskeys;
106#endif
Willy Tarreau8a8d83b2015-04-13 13:24:54 +0200107 struct {
108 int connected;
109 struct hlua_socket *socket;
110 struct list wake_on_read;
111 struct list wake_on_write;
112 } hlua;
Baptiste Assmann3863f972015-05-17 00:33:24 +0200113 struct {
114 struct dns_resolvers *ptr;
115 } resolvers;
Willy Tarreau8a8d83b2015-04-13 13:24:54 +0200116 } ctx; /* used by stats I/O handlers to dump the stats */
117};
118
119#endif /* _TYPES_APPLET_H */
120
121/*
122 * Local variables:
123 * c-indent-level: 8
124 * c-basic-offset: 8
125 * End:
126 */