MINOR: frontend: rename sample fetch functions and declare the sample keywords
The following sample fetch functions were only usable by ACLs but are now
usable by sample fetches too :
fe_conn, fe_id, fe_sess_rate
The fetch functions have been renamed "smp_fetch_*".
diff --git a/src/frontend.c b/src/frontend.c
index e7779e4..d7b0939 100644
--- a/src/frontend.c
+++ b/src/frontend.c
@@ -1,7 +1,7 @@
/*
* Frontend variables and functions.
*
- * Copyright 2000-2011 Willy Tarreau <w@1wt.eu>
+ * Copyright 2000-2013 Willy Tarreau <w@1wt.eu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -41,6 +41,7 @@
#include <proto/proto_tcp.h>
#include <proto/proto_http.h>
#include <proto/proxy.h>
+#include <proto/sample.h>
#include <proto/session.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
@@ -208,9 +209,13 @@
return -1;
}
+/************************************************************************/
+/* All supported sample and ACL keywords must be declared here. */
+/************************************************************************/
+
/* set temp integer to the id of the frontend */
static int
-acl_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_SESS;
@@ -224,7 +229,7 @@
* an undefined behaviour.
*/
static int
-acl_fetch_fe_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
@@ -238,7 +243,7 @@
* an undefined behaviour.
*/
static int
-acl_fetch_fe_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
@@ -251,17 +256,29 @@
/* Note: must not be declared <const> as its list will be overwritten.
* Please take care of keeping this list alphabetically sorted.
*/
+static struct sample_fetch_kw_list smp_kws = {{ },{
+ { "fe_conn", smp_fetch_fe_conn, ARG1(1,FE), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+ { "fe_id", smp_fetch_fe_id, 0, NULL, SMP_T_UINT, SMP_USE_FTEND, },
+ { "fe_sess_rate", smp_fetch_fe_sess_rate, ARG1(1,FE), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+ { /* END */ },
+}};
+
+
+/* Note: must not be declared <const> as its list will be overwritten.
+ * Please take care of keeping this list alphabetically sorted.
+ */
static struct acl_kw_list acl_kws = {{ },{
- { "fe_conn", acl_parse_int, acl_fetch_fe_conn, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
- { "fe_id", acl_parse_int, acl_fetch_fe_id, acl_match_int, ACL_USE_NOTHING, 0 },
- { "fe_sess_rate", acl_parse_int, acl_fetch_fe_sess_rate, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
- { NULL, NULL, NULL, NULL },
+ { "fe_conn", acl_parse_int, smp_fetch_fe_conn, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
+ { "fe_id", acl_parse_int, smp_fetch_fe_id, acl_match_int, ACL_USE_NOTHING, 0 },
+ { "fe_sess_rate", acl_parse_int, smp_fetch_fe_sess_rate, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
+ { /* END */ },
}};
__attribute__((constructor))
static void __frontend_init(void)
{
+ sample_register_fetches(&smp_kws);
acl_register_keywords(&acl_kws);
}