/********************************************************************
* helper functions/globals
********************************************************************/
-static void
-spoe_release_placeholder(struct spoe_placeholder *ph)
+static void spoe_release_placeholder(struct spoe_placeholder *ph)
{
if (!ph)
return;
free(ph);
}
-static void
-spoe_release_message(struct spoe_message *msg)
+static void spoe_release_message(struct spoe_message *msg)
{
struct spoe_arg *arg, *argback;
struct acl *acl, *aclback;
free(msg);
}
-static void
-spoe_release_group(struct spoe_group *grp)
+static void spoe_release_group(struct spoe_group *grp)
{
if (!grp)
return;
free(grp);
}
-static void
-spoe_release_agent(struct spoe_agent *agent)
+static void spoe_release_agent(struct spoe_agent *agent)
{
struct spoe_message *msg, *msgback;
struct spoe_group *grp, *grpback;
/* Used to generates a unique id for an engine. On success, it returns a
* allocated string. So it is the caller's responsibility to release it. If the
* allocation failed, it returns NULL. */
-static char *
-generate_pseudo_uuid()
+static char *generate_pseudo_uuid()
{
ha_generate_uuid_v4(&trash);
return my_strndup(trash.area, trash.data);
}
/* set/add to <t> the elapsed time since <since> and now */
-static inline void
-spoe_update_stat_time(ullong *since, long *t)
+static inline void spoe_update_stat_time(ullong *since, long *t)
{
if (*t == -1)
*t = ns_to_ms(now_ns - *since);
/* Encode the NOTIFY frame sent by HAProxy to an agent. It returns the number of
* encoded bytes in the frame on success, 0 if an encoding error occurred and -1
* if a fatal error occurred. */
-static int
-spoe_prepare_hanotify_frame(struct appctx *appctx, char *frame, size_t size)
+static int spoe_prepare_hanotify_frame(struct appctx *appctx, char *frame, size_t size)
{
char *p, *end;
size_t sz;
/* Decode ACK frame sent by an agent. It returns the number of read bytes on
* success, 0 if the frame can be ignored and -1 if an error occurred. */
-static int
-spoe_handle_agentack_frame(struct appctx *appctx, char *frame, size_t size)
+static int spoe_handle_agentack_frame(struct appctx *appctx, char *frame, size_t size)
{
char *p, *end;
int len;
/* Send a SPOE frame to an agent. It returns -1 when an error occurred, 0 when
* the frame can be ignored, 1 to retry later, and the frame length on
* success. */
-static int
-spoe_send_frame(struct appctx *appctx, char *buf, size_t framesz)
+static int spoe_send_frame(struct appctx *appctx, char *buf, size_t framesz)
{
int ret;
/* Receive a SPOE frame from an agent. It return -1 when an error occurred, 0
* when the frame can be ignored, 1 to retry later and the frame length on
* success. */
-static int
-spoe_recv_frame(struct appctx *appctx, char *buf, size_t framesz)
+static int spoe_recv_frame(struct appctx *appctx, char *buf, size_t framesz)
{
struct stconn *sc = appctx_sc(appctx);
int ret;
return spoe_appctx->agent;
}
-static int
-spoe_wakeup_appctx(struct appctx *appctx)
+static int spoe_wakeup_appctx(struct appctx *appctx)
{
applet_will_consume(appctx);
applet_have_more_data(appctx);
return 1;
}
-static int
-spoe_init_appctx(struct appctx *appctx)
+static int spoe_init_appctx(struct appctx *appctx)
{
struct spoe_appctx *spoe_appctx = SPOE_APPCTX(appctx);
struct spoe_agent *agent = spoe_appctx->agent;
/* Callback function that releases a SPOE applet. This happens when the
* connection with the agent is closed. */
-static void
-spoe_release_appctx(struct appctx *appctx)
+static void spoe_release_appctx(struct appctx *appctx)
{
struct spoe_appctx *spoe_appctx = SPOE_APPCTX(appctx);
}
-static int
-spoe_handle_sending_frame_appctx(struct appctx *appctx)
+static int spoe_handle_sending_frame_appctx(struct appctx *appctx)
{
char *frame, *buf;
int ret;
return ret;
}
-static int
-spoe_handle_receiving_frame_appctx(struct appctx *appctx)
+static int spoe_handle_receiving_frame_appctx(struct appctx *appctx)
{
char *frame;
int ret;
return ret;
}
-static int
-spoe_handle_processing_appctx(struct appctx *appctx)
+static int spoe_handle_processing_appctx(struct appctx *appctx)
{
int ret;
}
/* I/O Handler processing messages exchanged with the agent */
-static void
-spoe_handle_appctx(struct appctx *appctx)
+static void spoe_handle_appctx(struct appctx *appctx)
{
struct stconn *sc = appctx_sc(appctx);
/* Create a SPOE applet. On success, the created applet is returned, else
* NULL. */
-static struct appctx *
-spoe_create_appctx(struct spoe_config *conf)
+static struct appctx *spoe_create_appctx(struct spoe_config *conf)
{
struct spoe_agent *agent = conf->agent;
struct spoe_appctx *spoe_appctx;
**************************************************************************/
/* Encode a SPOE message. If the next message can be processed, it returns 0. If
* the message is too big, it returns -1.*/
-static int
-spoe_encode_message(struct stream *s, struct spoe_context *ctx,
- struct spoe_message *msg, int dir,
- char **buf, char *end)
+static int spoe_encode_message(struct stream *s, struct spoe_context *ctx,
+ struct spoe_message *msg, int dir,
+ char **buf, char *end)
{
struct sample *smp;
struct spoe_arg *arg;
/* Encode list of SPOE messages. On success it returns 1. If an error occurred, -1
* is returned. If nothing has been encoded, it returns 0. */
-static int
-spoe_encode_messages(struct stream *s, struct spoe_context *ctx,
- struct list *messages, int dir, int type)
+static int spoe_encode_messages(struct stream *s, struct spoe_context *ctx,
+ struct list *messages, int dir, int type)
{
struct spoe_config *conf = FLT_CONF(ctx->filter);
struct spoe_agent *agent = conf->agent;
* Functions that handle SPOE actions
**************************************************************************/
/* Helper function to set a variable */
-static void
-spoe_set_var(struct spoe_context *ctx, char *scope, char *name, int len,
- struct sample *smp)
+static void spoe_set_var(struct spoe_context *ctx, char *scope, char *name, int len,
+ struct sample *smp)
{
struct spoe_config *conf = FLT_CONF(ctx->filter);
struct spoe_agent *agent = conf->agent;
}
/* Helper function to unset a variable */
-static void
-spoe_unset_var(struct spoe_context *ctx, char *scope, char *name, int len,
- struct sample *smp)
+static void spoe_unset_var(struct spoe_context *ctx, char *scope, char *name, int len,
+ struct sample *smp)
{
struct spoe_config *conf = FLT_CONF(ctx->filter);
struct spoe_agent *agent = conf->agent;
}
-static inline int
-spoe_decode_action_set_var(struct stream *s, struct spoe_context *ctx,
- char **buf, char *end, int dir)
+static inline int spoe_decode_action_set_var(struct stream *s, struct spoe_context *ctx,
+ char **buf, char *end, int dir)
{
char *str, *scope, *p = *buf;
struct sample smp;
return 0;
}
-static inline int
-spoe_decode_action_unset_var(struct stream *s, struct spoe_context *ctx,
- char **buf, char *end, int dir)
+static inline int spoe_decode_action_unset_var(struct stream *s, struct spoe_context *ctx,
+ char **buf, char *end, int dir)
{
char *str, *scope, *p = *buf;
struct sample smp;
/* Process SPOE actions for a specific event. It returns 1 on success. If an
* error occurred, 0 is returned. */
-static int
-spoe_process_actions(struct stream *s, struct spoe_context *ctx, int dir)
+static int spoe_process_actions(struct stream *s, struct spoe_context *ctx, int dir)
{
char *p, *end;
int ret;
/***************************************************************************
* Functions that process SPOE events
**************************************************************************/
-static void
-spoe_update_stats(struct stream *s, struct spoe_agent *agent,
- struct spoe_context *ctx, int dir)
+static void spoe_update_stats(struct stream *s, struct spoe_agent *agent,
+ struct spoe_context *ctx, int dir)
{
if (ctx->stats.start_ts != 0) {
spoe_update_stat_time(&ctx->stats.start_ts, &ctx->stats.t_process);
}
}
-static void
-spoe_handle_processing_error(struct stream *s, struct spoe_agent *agent,
- struct spoe_context *ctx, int dir)
+static void spoe_handle_processing_error(struct stream *s, struct spoe_agent *agent,
+ struct spoe_context *ctx, int dir)
{
if (agent->var_on_error) {
struct sample smp;
: SPOE_CTX_ST_NONE);
}
-static inline int
-spoe_start_processing(struct spoe_agent *agent, struct spoe_context *ctx, int dir)
+static inline int spoe_start_processing(struct spoe_agent *agent, struct spoe_context *ctx, int dir)
{
/* If a process is already started for this SPOE context, retry
* later. */
return 1;
}
-static inline void
-spoe_stop_processing(struct spoe_agent *agent, struct spoe_context *ctx)
+static inline void spoe_stop_processing(struct spoe_agent *agent, struct spoe_context *ctx)
{
struct spoe_appctx *sa = ctx->spoe_appctx;
* to process corresponding actions. During all the processing, it returns 0
* and it returns 1 when the processing is finished. If an error occurred, -1
* is returned. */
-static int
-spoe_process_messages(struct stream *s, struct spoe_context *ctx,
- struct list *messages, int dir, int type)
+static int spoe_process_messages(struct stream *s, struct spoe_context *ctx,
+ struct list *messages, int dir, int type)
{
struct spoe_config *conf = FLT_CONF(ctx->filter);
struct spoe_agent *agent = conf->agent;
/* Process a SPOE group, ie the list of messages attached to the group <grp>.
* See spoe_process_message for details. */
-static int
-spoe_process_group(struct stream *s, struct spoe_context *ctx,
- struct spoe_group *group, int dir)
+static int spoe_process_group(struct stream *s, struct spoe_context *ctx,
+ struct spoe_group *group, int dir)
{
struct spoe_config *conf = FLT_CONF(ctx->filter);
struct spoe_agent *agent = conf->agent;
/* Process a SPOE event, ie the list of messages attached to the event <ev>.
* See spoe_process_message for details. */
-static int
-spoe_process_event(struct stream *s, struct spoe_context *ctx,
- enum spoe_event ev)
+static int spoe_process_event(struct stream *s, struct spoe_context *ctx,
+ enum spoe_event ev)
{
struct spoe_config *conf = FLT_CONF(ctx->filter);
struct spoe_agent *agent = conf->agent;
/***************************************************************************
* Functions that create/destroy SPOE contexts
**************************************************************************/
-static int
-spoe_acquire_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
+static int spoe_acquire_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
{
if (buf->size)
return 1;
return 0;
}
-static void
-spoe_release_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
+static void spoe_release_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
{
b_dequeue(buffer_wait);
}
}
-static int
-spoe_wakeup_context(struct spoe_context *ctx)
+static int spoe_wakeup_context(struct spoe_context *ctx)
{
task_wakeup(ctx->strm->task, TASK_WOKEN_MSG);
return 1;
}
-static struct spoe_context *
-spoe_create_context(struct stream *s, struct filter *filter)
+static struct spoe_context *spoe_create_context(struct stream *s, struct filter *filter)
{
struct spoe_config *conf = FLT_CONF(filter);
struct spoe_context *ctx;
return ctx;
}
-static void
-spoe_destroy_context(struct filter *filter)
+static void spoe_destroy_context(struct filter *filter)
{
struct spoe_config *conf = FLT_CONF(filter);
struct spoe_context *ctx = filter->ctx;
filter->ctx = NULL;
}
-static void
-spoe_reset_context(struct spoe_context *ctx)
+static void spoe_reset_context(struct spoe_context *ctx)
{
ctx->state = SPOE_CTX_ST_READY;
ctx->flags &= ~SPOE_CTX_FL_PROCESS;
* Hooks that manage the filter lifecycle (init/check/deinit)
**************************************************************************/
/* Initialize the SPOE filter. Returns -1 on error, else 0. */
-static int
-spoe_init(struct proxy *px, struct flt_conf *fconf)
+static int spoe_init(struct proxy *px, struct flt_conf *fconf)
{
struct spoe_config *conf = fconf->conf;
}
/* Free resources allocated by the SPOE filter. */
-static void
-spoe_deinit(struct proxy *px, struct flt_conf *fconf)
+static void spoe_deinit(struct proxy *px, struct flt_conf *fconf)
{
struct spoe_config *conf = fconf->conf;
/* Check configuration of a SPOE filter for a specified proxy.
* Return 1 on error, else 0. */
-static int
-spoe_check(struct proxy *px, struct flt_conf *fconf)
+static int spoe_check(struct proxy *px, struct flt_conf *fconf)
{
struct flt_conf *f;
struct spoe_config *conf = fconf->conf;
*************************************************************************/
/* Called when a filter instance is created and attach to a stream. It creates
* the context that will be used to process this stream. */
-static int
-spoe_start(struct stream *s, struct filter *filter)
+static int spoe_start(struct stream *s, struct filter *filter)
{
struct spoe_config *conf = FLT_CONF(filter);
struct spoe_agent *agent = conf->agent;
/* Called when a filter instance is detached from a stream. It release the
* attached SPOE context. */
-static void
-spoe_stop(struct stream *s, struct filter *filter)
+static void spoe_stop(struct stream *s, struct filter *filter)
{
spoe_destroy_context(filter);
}
/*
* Called when the stream is woken up because of expired timer.
*/
-static void
-spoe_check_timeouts(struct stream *s, struct filter *filter)
+static void spoe_check_timeouts(struct stream *s, struct filter *filter)
{
struct spoe_context *ctx = filter->ctx;
}
/* Called when we are ready to filter data on a channel */
-static int
-spoe_start_analyze(struct stream *s, struct filter *filter, struct channel *chn)
+static int spoe_start_analyze(struct stream *s, struct filter *filter, struct channel *chn)
{
struct spoe_context *ctx = filter->ctx;
int ret = 1;
}
/* Called before a processing happens on a given channel */
-static int
-spoe_chn_pre_analyze(struct stream *s, struct filter *filter,
- struct channel *chn, unsigned an_bit)
+static int spoe_chn_pre_analyze(struct stream *s, struct filter *filter,
+ struct channel *chn, unsigned an_bit)
{
struct spoe_context *ctx = filter->ctx;
int ret = 1;
}
/* Called when the filtering on the channel ends. */
-static int
-spoe_end_analyze(struct stream *s, struct filter *filter, struct channel *chn)
+static int spoe_end_analyze(struct stream *s, struct filter *filter, struct channel *chn)
{
struct spoe_context *ctx = filter->ctx;
};
-static int
-cfg_parse_spoe_agent(const char *file, int linenum, char **args, int kwm)
+static int cfg_parse_spoe_agent(const char *file, int linenum, char **args, int kwm)
{
const char *err;
int i, err_code = 0;
out:
return err_code;
}
-static int
-cfg_parse_spoe_group(const char *file, int linenum, char **args, int kwm)
+static int cfg_parse_spoe_group(const char *file, int linenum, char **args, int kwm)
{
struct spoe_group *grp;
const char *err;
return err_code;
}
-static int
-cfg_parse_spoe_message(const char *file, int linenum, char **args, int kwm)
+static int cfg_parse_spoe_message(const char *file, int linenum, char **args, int kwm)
{
struct spoe_message *msg;
struct spoe_arg *arg;
}
/* Return -1 on error, else 0 */
-static int
-parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
- struct flt_conf *fconf, char **err, void *private)
+static int parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
+ struct flt_conf *fconf, char **err, void *private)
{
struct list backup_sections;
struct spoe_config *conf;
*
* It returns ACT_RET_CONT if processing is finished (with error or not), it returns
* ACT_RET_YIELD if the action is in progress. */
-static enum act_return
-spoe_send_group(struct act_rule *rule, struct proxy *px,
- struct session *sess, struct stream *s, int flags)
+static enum act_return spoe_send_group(struct act_rule *rule, struct proxy *px,
+ struct session *sess, struct stream *s, int flags)
{
struct filter *filter;
struct spoe_agent *agent = NULL;
* The function returns 1 in success case, otherwise, it returns 0 and err is
* filled.
*/
-static int
-check_send_spoe_group(struct act_rule *rule, struct proxy *px, char **err)
+static int check_send_spoe_group(struct act_rule *rule, struct proxy *px, char **err)
{
struct flt_conf *fconf;
struct spoe_config *conf;
* message. Otherwise, it returns ACT_RET_PRS_OK and parsing engine and group
* ids are saved and used later, when the rule will be checked.
*/
-static enum act_parse_ret
-parse_send_spoe_group(const char **args, int *orig_arg, struct proxy *px,
- struct act_rule *rule, char **err)
+static enum act_parse_ret parse_send_spoe_group(const char **args, int *orig_arg, struct proxy *px,
+ struct act_rule *rule, char **err)
{
if (!*args[*orig_arg] || !*args[*orig_arg+1] ||
(*args[*orig_arg+2] && strcmp(args[*orig_arg+2], "if") != 0 && strcmp(args[*orig_arg+2], "unless") != 0)) {