int tcp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_is_foreign(int fd, sa_family_t family);
-/* Export some samples. */
-int smp_fetch_src(const struct arg *args, struct sample *smp, const char *kw, void *private);
-
#endif /* _HAPROXY_PROTO_TCP_H */
/*
/************************************************************************/
/* fetch the connection's source IPv4/IPv6 address */
-int smp_fetch_src(const struct arg *args, struct sample *smp, const char *kw, void *private)
+static int
+smp_fetch_src(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *cli_conn = objt_conn(smp->sess->origin);
/* structure used to return a table key built from a sample */
static THREAD_LOCAL struct stktable_key static_table_key;
+static int (*smp_fetch_src)(const struct arg *, struct sample *, const char *, void *);
struct stktable *stktables_list;
struct eb_root stktable_by_name = EB_ROOT;
smp.px = NULL;
smp.sess = sess;
smp.strm = strm;
- if (!smp_fetch_src(NULL, &smp, NULL, NULL))
+ if (!smp_fetch_src || !smp_fetch_src(NULL, &smp, NULL, NULL))
return NULL;
/* Converts into key. */
smp.px = NULL;
smp.sess = sess;
smp.strm = strm;
- if (!smp_fetch_src(NULL, &smp, NULL, NULL))
+ if (!smp_fetch_src || !smp_fetch_src(NULL, &smp, NULL, NULL))
return NULL;
/* Converts into key. */
return 0;
/* Fetch source address in a sample. */
- if (!smp_fetch_src(NULL, smp, NULL, NULL))
+ if (!smp_fetch_src || !smp_fetch_src(NULL, smp, NULL, NULL))
return 0;
/* Converts into key. */
}
}
+static void stkt_late_init(void)
+{
+ struct sample_fetch *f;
+
+ f = find_sample_fetch("src", strlen("src"));
+ if (f)
+ smp_fetch_src = f->process;
+}
+
+INITCALL0(STG_INIT, stkt_late_init);
+
/* register cli keywords */
static struct cli_kw_list cli_kws = {{ },{
{ { "clear", "table", NULL }, "clear table : remove an entry from a table", cli_parse_table_req, cli_io_handler_table, cli_release_show_table, (void *)STK_CLI_ACT_CLR },