MEDIUM: counters: support looking up a key in an alternate table

sc_* sample fetches now take an optional parameter which allows to look
the key in an alternate table. This is convenient to pass multiple
information for the same key at once (eg: have multiple gpc0 for the
same key, or support being fed complementary information from the CLI).
Example :

    listen front
        bind :8000
        tcp-request content track-sc0 src table local-ip
        http-response set-header src-id %[sc0_get_gpc0]+%[sc0_get_gpc0(global-ip)]
        server dummy 127.0.0.1:8001

    backend local-ip
        stick-table size 1k type ip store gpc0

    backend global-ip
        stick-table size 1k type ip store gpc0
diff --git a/doc/configuration.txt b/doc/configuration.txt
index b7b2949..51c96de 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -8942,7 +8942,9 @@
 the incoming connection. For retrieving a value from a sticky counters, the
 counter number can be explicitly set as 0, 1, or 2 using the pre-defined
 "sc0_", "sc1_", or "sc2_" prefix, or it can be specified as the first integer
-argument when using the "sc_" prefix.
+argument when using the "sc_" prefix. An optional table may be specified with
+the "sc*" form, in which case the currently tracked key will be looked up into
+this alternate table instead of the table currently being tracked.
 
 be_id : integer
   Returns an integer containing the current backend's id. It can be used in
@@ -8978,26 +8980,26 @@
   backends to check from which backend it was called, or to stick all users
   coming via a same frontend to the same server.
 
-sc_bytes_in_rate(<ctr>) : integer
-sc0_bytes_in_rate : integer
-sc1_bytes_in_rate : integer
-sc2_bytes_in_rate : integer
+sc_bytes_in_rate(<ctr>,[<table>]) : integer
+sc0_bytes_in_rate([<table>]) : integer
+sc1_bytes_in_rate([<table>]) : integer
+sc2_bytes_in_rate([<table>]) : integer
   Returns the average client-to-server bytes rate from the currently tracked
   counters, measured in amount of bytes over the period configured in the
   table. See also src_bytes_in_rate.
 
-sc_bytes_out_rate(<ctr>) : integer
-sc0_bytes_out_rate : integer
-sc1_bytes_out_rate : integer
-sc2_bytes_out_rate : integer
+sc_bytes_out_rate(<ctr>,[<table>]) : integer
+sc0_bytes_out_rate([<table>]) : integer
+sc1_bytes_out_rate([<table>]) : integer
+sc2_bytes_out_rate([<table>]) : integer
   Returns the average server-to-client bytes rate from the currently tracked
   counters, measured in amount of bytes over the period configured in the
   table. See also src_bytes_out_rate.
 
-sc_clr_gpc0(<ctr>) : integer
-sc0_clr_gpc0 : integer
-sc1_clr_gpc0 : integer
-sc2_clr_gpc0 : integer
+sc_clr_gpc0(<ctr>,[<table>]) : integer
+sc0_clr_gpc0([<table>]) : integer
+sc1_clr_gpc0([<table>]) : integer
+sc2_clr_gpc0([<table>]) : integer
   Clears the first General Purpose Counter associated to the currently tracked
   counters, and returns its previous value. Before the first invocation, the
   stored value is zero, so first invocation will always return zero. This is
@@ -9012,40 +9014,40 @@
         tcp-request connection accept if !abuse save
         tcp-request connection reject if abuse kill
 
-sc_conn_cnt(<ctr>) : integer
-sc0_conn_cnt : integer
-sc1_conn_cnt : integer
-sc2_conn_cnt : integer
+sc_conn_cnt(<ctr>,[<table>]) : integer
+sc0_conn_cnt([<table>]) : integer
+sc1_conn_cnt([<table>]) : integer
+sc2_conn_cnt([<table>]) : integer
   Returns the cumulated number of incoming connections from currently tracked
   counters. See also src_conn_cnt.
 
-sc_conn_cur(<ctr>) : integer
-sc0_conn_cur : integer
-sc1_conn_cur : integer
-sc2_conn_cur : integer
+sc_conn_cur(<ctr>,[<table>]) : integer
+sc0_conn_cur([<table>]) : integer
+sc1_conn_cur([<table>]) : integer
+sc2_conn_cur([<table>]) : integer
   Returns the current amount of concurrent connections tracking the same
   tracked counters. This number is automatically incremented when tracking
   begins and decremented when tracking stops. See also src_conn_cur.
 
-sc_conn_rate(<ctr>) : integer
-sc0_conn_rate : integer
-sc1_conn_rate : integer
-sc2_conn_rate : integer
+sc_conn_rate(<ctr>,[<table>]) : integer
+sc0_conn_rate([<table>]) : integer
+sc1_conn_rate([<table>]) : integer
+sc2_conn_rate([<table>]) : integer
   Returns the average connection rate from the currently tracked counters,
   measured in amount of connections over the period configured in the table.
   See also src_conn_rate.
 
-sc_get_gpc0(<ctr>) : integer
-sc0_get_gpc0 : integer
-sc1_get_gpc0 : integer
-sc2_get_gpc0 : integer
+sc_get_gpc0(<ctr>,[<table>]) : integer
+sc0_get_gpc0([<table>]) : integer
+sc1_get_gpc0([<table>]) : integer
+sc2_get_gpc0([<table>]) : integer
   Returns the value of the first General Purpose Counter associated to the
   currently tracked counters. See also src_get_gpc0 and sc/sc0/sc1/sc2_inc_gpc0.
 
-sc_gpc0_rate(<ctr>) : integer
-sc0_gpc0_rate : integer
-sc1_gpc0_rate : integer
-sc2_gpc0_rate : integer
+sc_gpc0_rate(<ctr>,[<table>]) : integer
+sc0_gpc0_rate([<table>]) : integer
+sc1_gpc0_rate([<table>]) : integer
+sc2_gpc0_rate([<table>]) : integer
   Returns the average increment rate of the first General Purpose Counter
   associated to the currently tracked counters. It reports the frequency
   which the gpc0 counter was incremented over the configured period. See also
@@ -9053,44 +9055,44 @@
   that the "gpc0_rate" counter must be stored in the stick-table for a value to
   be returned, as "gpc0" only holds the event count.
 
-sc_http_err_cnt(<ctr>) : integer
-sc0_http_err_cnt : integer
-sc1_http_err_cnt : integer
-sc2_http_err_cnt : integer
+sc_http_err_cnt(<ctr>,[<table>]) : integer
+sc0_http_err_cnt([<table>]) : integer
+sc1_http_err_cnt([<table>]) : integer
+sc2_http_err_cnt([<table>]) : integer
   Returns the cumulated number of HTTP errors from the currently tracked
   counters. This includes the both request errors and 4xx error responses.
   See also src_http_err_cnt.
 
-sc_http_err_rate(<ctr>) : integer
-sc0_http_err_rate : integer
-sc1_http_err_rate : integer
-sc2_http_err_rate : integer
+sc_http_err_rate(<ctr>,[<table>]) : integer
+sc0_http_err_rate([<table>]) : integer
+sc1_http_err_rate([<table>]) : integer
+sc2_http_err_rate([<table>]) : integer
   Returns the average rate of HTTP errors from the currently tracked counters,
   measured in amount of errors over the period configured in the table. This
   includes the both request errors and 4xx error responses. See also
   src_http_err_rate.
 
-sc_http_req_cnt(<ctr>) : integer
-sc0_http_req_cnt : integer
-sc1_http_req_cnt : integer
-sc2_http_req_cnt : integer
+sc_http_req_cnt(<ctr>,[<table>]) : integer
+sc0_http_req_cnt([<table>]) : integer
+sc1_http_req_cnt([<table>]) : integer
+sc2_http_req_cnt([<table>]) : integer
   Returns the cumulated number of HTTP requests from the currently tracked
   counters. This includes every started request, valid or not. See also
   src_http_req_cnt.
 
-sc_http_req_rate(<ctr>) : integer
-sc0_http_req_rate : integer
-sc1_http_req_rate : integer
-sc2_http_req_rate : integer
+sc_http_req_rate(<ctr>,[<table>]) : integer
+sc0_http_req_rate([<table>]) : integer
+sc1_http_req_rate([<table>]) : integer
+sc2_http_req_rate([<table>]) : integer
   Returns the average rate of HTTP requests from the currently tracked
   counters, measured in amount of requests over the period configured in
   the table. This includes every started request, valid or not. See also
   src_http_req_rate.
 
-sc_inc_gpc0(<ctr>) : integer
-sc0_inc_gpc0 : integer
-sc1_inc_gpc0 : integer
-sc2_inc_gpc0 : integer
+sc_inc_gpc0(<ctr>,[<table>]) : integer
+sc0_inc_gpc0([<table>]) : integer
+sc1_inc_gpc0([<table>]) : integer
+sc2_inc_gpc0([<table>]) : integer
   Increments the first General Purpose Counter associated to the currently
   tracked counters, and returns its new value. Before the first invocation,
   the stored value is zero, so first invocation will increase it to 1 and will
@@ -9101,28 +9103,28 @@
         acl kill  sc0_inc_gpc0 gt 0
         tcp-request connection reject if abuse kill
 
-sc_kbytes_in(<ctr>) : integer
-sc0_kbytes_in : integer
-sc1_kbytes_in : integer
-sc2_kbytes_in : integer
+sc_kbytes_in(<ctr>,[<table>]) : integer
+sc0_kbytes_in([<table>]) : integer
+sc1_kbytes_in([<table>]) : integer
+sc2_kbytes_in([<table>]) : integer
   Returns the amount of client-to-server data from the currently tracked
   counters, measured in kilobytes over the period configured in the table. The
   test is currently performed on 32-bit integers, which limits values to 4
   terabytes. See also src_kbytes_in.
 
-sc_kbytes_out(<ctr>) : integer
-sc0_kbytes_out : integer
-sc1_kbytes_out : integer
-sc2_kbytes_out : integer
+sc_kbytes_out(<ctr>,[<table>]) : integer
+sc0_kbytes_out([<table>]) : integer
+sc1_kbytes_out([<table>]) : integer
+sc2_kbytes_out([<table>]) : integer
   Returns the amount of server-to-client data from the currently tracked
   counters, measured in kilobytes over the period configured in the table. The
   test is currently performed on 32-bit integers, which limits values to 4
   terabytes. See also src_kbytes_out.
 
-sc_sess_cnt(<ctr>) : integer
-sc0_sess_cnt : integer
-sc1_sess_cnt : integer
-sc2_sess_cnt : integer
+sc_sess_cnt(<ctr>,[<table>]) : integer
+sc0_sess_cnt([<table>]) : integer
+sc1_sess_cnt([<table>]) : integer
+sc2_sess_cnt([<table>]) : integer
   Returns the cumulated number of incoming connections that were transformed
   into sessions, which means that they were accepted by a "tcp-request
   connection" rule, from the currently tracked counters. A backend may count
@@ -9130,10 +9132,10 @@
   backend sessions if some HTTP keep-alive is performed over the connection
   with the client. See also src_sess_cnt.
 
-sc_sess_rate(<ctr>) : integer
-sc0_sess_rate : integer
-sc1_sess_rate : integer
-sc2_sess_rate : integer
+sc_sess_rate(<ctr>,[<table>]) : integer
+sc0_sess_rate([<table>]) : integer
+sc1_sess_rate([<table>]) : integer
+sc2_sess_rate([<table>]) : integer
   Returns the average session rate from the currently tracked counters,
   measured in amount of sessions over the period configured in the table. A
   session is a connection that got past the early "tcp-request connection"
@@ -9141,18 +9143,18 @@
   connection could result in many backend sessions if some HTTP keep-alive is
   performed over the connection with the client. See also src_sess_rate.
 
-sc_tracked(<ctr>) : boolean
-sc0_tracked : boolean
-sc1_tracked : boolean
-sc2_tracked : boolean
+sc_tracked(<ctr>,[<table>]) : boolean
+sc0_tracked([<table>]) : boolean
+sc1_tracked([<table>]) : boolean
+sc2_tracked([<table>]) : boolean
   Returns true if the designated session counter is currently being tracked by
   the current session. This can be useful when deciding whether or not we want
   to set some values in a header passed to the server.
 
-sc_trackers(<ctr>) : integer
-sc0_trackers : integer
-sc1_trackers : integer
-sc2_trackers : integer
+sc_trackers(<ctr>,[<table>]) : integer
+sc0_trackers([<table>]) : integer
+sc1_trackers([<table>]) : integer
+sc2_trackers([<table>]) : integer
   Returns the current amount of concurrent connections tracking the same
   tracked counters. This number is automatically incremented when tracking
   begins and decremented when tracking stops. It differs from sc0_conn_cur in
diff --git a/src/session.c b/src/session.c
index ef96f0e..ed55ca4 100644
--- a/src/session.c
+++ b/src/session.c
@@ -2584,25 +2584,27 @@
  * session <l4>. sc_* requires an UINT argument specifying the stick
  * counter number. src_* will fill a locally allocated structure with
  * the table and entry corresponding to what is specified with src_*.
- * NULL may be returned if the designated stkctr is not tracked.
+ * NULL may be returned if the designated stkctr is not tracked. For
+ * the sc_* and sc[0-9]_* forms, an optional table argument may be
+ * passed. When present, the currently tracked key is then looked up
+ * in the specified table instead of the current table. The purpose is
+ * to be able to convery multiple values per key (eg: have gpc0 from
+ * multiple tables).
  */
 static struct stkctr *
 smp_fetch_sc_stkctr(struct session *l4, const struct arg *args, const char *kw)
 {
 	static struct stkctr stkctr;
 	unsigned int num = kw[2] - '0';
+	int arg = 0;
 
-	if (num <= 9) { /* sc[0-9]_* variant */
-		return l4->stkctr[num].entry ? &l4->stkctr[num] : NULL;
-	}
-	else if (num == '_' - '0') {
-		/* sc_* variant, arg[0] = ctr# (mandatory) */
-		num = args[0].data.uint;
+	if (num == '_' - '0') {
+		/* sc_* variant, args[0] = ctr# (mandatory) */
+		num = args[arg++].data.uint;
 		if (num >= MAX_SESS_STKCTR)
 			return NULL;
-		return l4->stkctr[num].entry ? &l4->stkctr[num] : NULL;
 	}
-	else { /* src_* variant, arg[0] = table */
+	else if (num > 9) { /* src_* variant, args[0] = table */
 		struct stktable_key *key = addr_to_stktable_key(&l4->si[0].conn->addr.from);
 
 		if (!key)
@@ -2611,6 +2613,18 @@
 		stkctr.entry = stktable_lookup_key(stkctr.table, key);
 		return &stkctr;
 	}
+
+	/* Here, <num> contains the counter number from 0 to 9 for
+	 * the sc[0-9]_ form, or even higher using sc_(num) if needed.
+	 * args[arg] is the first optional argument.
+	 */
+	if (unlikely(args[arg].type == ARGT_TAB)) {
+		/* an alternate table was specified, let's look up the same key there */
+		stkctr.table = &args[arg].data.prx->table;
+		stkctr.entry = stktable_lookup(stkctr.table, l4->stkctr[num].entry);
+		return &stkctr;
+	}
+	return l4->stkctr[num].entry ? &l4->stkctr[num] : NULL;
 }
 
 /* set return a boolean indicating if the requested session counter is
@@ -3162,102 +3176,102 @@
  * Please take care of keeping this list alphabetically sorted.
  */
 static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
-	{ "sc_bytes_in_rate",   smp_fetch_sc_bytes_in_rate,  ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_bytes_out_rate",  smp_fetch_sc_bytes_out_rate, ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_clr_gpc0",        smp_fetch_sc_clr_gpc0,       ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_conn_cnt",        smp_fetch_sc_conn_cnt,       ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_conn_cur",        smp_fetch_sc_conn_cur,       ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_conn_rate",       smp_fetch_sc_conn_rate,      ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_get_gpc0",        smp_fetch_sc_get_gpc0,       ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_gpc0_rate",       smp_fetch_sc_gpc0_rate,      ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_http_err_cnt",    smp_fetch_sc_http_err_cnt,   ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_http_err_rate",   smp_fetch_sc_http_err_rate,  ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_http_req_cnt",    smp_fetch_sc_http_req_cnt,   ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_http_req_rate",   smp_fetch_sc_http_req_rate,  ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_inc_gpc0",        smp_fetch_sc_inc_gpc0,       ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_kbytes_in",       smp_fetch_sc_kbytes_in,      ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc_kbytes_out",      smp_fetch_sc_kbytes_out,     ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc_sess_cnt",        smp_fetch_sc_sess_cnt,       ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_sess_rate",       smp_fetch_sc_sess_rate,      ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc_tracked",         smp_fetch_sc_tracked,        ARG1(1,UINT), NULL, SMP_T_BOOL, SMP_USE_INTRN, },
-	{ "sc_trackers",        smp_fetch_sc_trackers,       ARG1(1,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_bytes_out_rate", smp_fetch_sc_bytes_out_rate,  0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_clr_gpc0",       smp_fetch_sc_clr_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_conn_cnt",       smp_fetch_sc_conn_cnt,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_conn_cur",       smp_fetch_sc_conn_cur,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_conn_rate",      smp_fetch_sc_conn_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_get_gpc0",       smp_fetch_sc_get_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_gpc0_rate",      smp_fetch_sc_gpc0_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_http_err_cnt",   smp_fetch_sc_http_err_cnt,    0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_http_err_rate",  smp_fetch_sc_http_err_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_http_req_cnt",   smp_fetch_sc_http_req_cnt,    0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_http_req_rate",  smp_fetch_sc_http_req_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_inc_gpc0",       smp_fetch_sc_inc_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_kbytes_in",      smp_fetch_sc_kbytes_in,       0,           NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc0_kbytes_out",     smp_fetch_sc_kbytes_out,      0,           NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc0_sess_cnt",       smp_fetch_sc_sess_cnt,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_sess_rate",      smp_fetch_sc_sess_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc0_tracked",        smp_fetch_sc_tracked,         0,           NULL, SMP_T_BOOL, SMP_USE_INTRN, },
-	{ "sc0_trackers",       smp_fetch_sc_trackers,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_bytes_out_rate", smp_fetch_sc_bytes_out_rate,  0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_clr_gpc0",       smp_fetch_sc_clr_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_conn_cnt",       smp_fetch_sc_conn_cnt,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_conn_cur",       smp_fetch_sc_conn_cur,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_conn_rate",      smp_fetch_sc_conn_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_get_gpc0",       smp_fetch_sc_get_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_gpc0_rate",      smp_fetch_sc_gpc0_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_http_err_cnt",   smp_fetch_sc_http_err_cnt,    0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_http_err_rate",  smp_fetch_sc_http_err_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_http_req_cnt",   smp_fetch_sc_http_req_cnt,    0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_http_req_rate",  smp_fetch_sc_http_req_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_inc_gpc0",       smp_fetch_sc_inc_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_kbytes_in",      smp_fetch_sc_kbytes_in,       0,           NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc1_kbytes_out",     smp_fetch_sc_kbytes_out,      0,           NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc1_sess_cnt",       smp_fetch_sc_sess_cnt,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_sess_rate",      smp_fetch_sc_sess_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc1_tracked",        smp_fetch_sc_tracked,         0,           NULL, SMP_T_BOOL, SMP_USE_INTRN, },
-	{ "sc1_trackers",       smp_fetch_sc_trackers,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_bytes_out_rate", smp_fetch_sc_bytes_out_rate,  0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_clr_gpc0",       smp_fetch_sc_clr_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_conn_cnt",       smp_fetch_sc_conn_cnt,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_conn_cur",       smp_fetch_sc_conn_cur,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_conn_rate",      smp_fetch_sc_conn_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_get_gpc0",       smp_fetch_sc_get_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_gpc0_rate",      smp_fetch_sc_gpc0_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_http_err_cnt",   smp_fetch_sc_http_err_cnt,    0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_http_err_rate",  smp_fetch_sc_http_err_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_http_req_cnt",   smp_fetch_sc_http_req_cnt,    0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_http_req_rate",  smp_fetch_sc_http_req_rate,   0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_inc_gpc0",       smp_fetch_sc_inc_gpc0,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_kbytes_in",      smp_fetch_sc_kbytes_in,       0,           NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc2_kbytes_out",     smp_fetch_sc_kbytes_out,      0,           NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "sc2_sess_cnt",       smp_fetch_sc_sess_cnt,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_sess_rate",      smp_fetch_sc_sess_rate,       0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "sc2_tracked",        smp_fetch_sc_tracked,         0,           NULL, SMP_T_BOOL, SMP_USE_INTRN, },
-	{ "sc2_trackers",       smp_fetch_sc_trackers,        0,           NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "src_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,   ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_bytes_out_rate", smp_fetch_sc_bytes_out_rate,  ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_clr_gpc0",       smp_fetch_sc_clr_gpc0,        ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_conn_cnt",       smp_fetch_sc_conn_cnt,        ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_conn_cur",       smp_fetch_sc_conn_cur,        ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_conn_rate",      smp_fetch_sc_conn_rate,       ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_get_gpc0",       smp_fetch_sc_get_gpc0,        ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_gpc0_rate",      smp_fetch_sc_gpc0_rate,       ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_http_err_cnt",   smp_fetch_sc_http_err_cnt,    ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_http_err_rate",  smp_fetch_sc_http_err_rate,   ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_http_req_cnt",   smp_fetch_sc_http_req_cnt,    ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_http_req_rate",  smp_fetch_sc_http_req_rate,   ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_inc_gpc0",       smp_fetch_sc_inc_gpc0,        ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_kbytes_in",      smp_fetch_sc_kbytes_in,       ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_kbytes_out",     smp_fetch_sc_kbytes_out,      ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_sess_cnt",       smp_fetch_sc_sess_cnt,        ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_sess_rate",      smp_fetch_sc_sess_rate,       ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "src_updt_conn_cnt",  smp_fetch_src_updt_conn_cnt,  ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
-	{ "table_avl",          smp_fetch_table_avl,          ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
-	{ "table_cnt",          smp_fetch_table_cnt,          ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_bytes_in_rate",   smp_fetch_sc_bytes_in_rate,  ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_bytes_out_rate",  smp_fetch_sc_bytes_out_rate, ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_clr_gpc0",        smp_fetch_sc_clr_gpc0,       ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_conn_cnt",        smp_fetch_sc_conn_cnt,       ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_conn_cur",        smp_fetch_sc_conn_cur,       ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_conn_rate",       smp_fetch_sc_conn_rate,      ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_get_gpc0",        smp_fetch_sc_get_gpc0,       ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_gpc0_rate",       smp_fetch_sc_gpc0_rate,      ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_http_err_cnt",    smp_fetch_sc_http_err_cnt,   ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_http_err_rate",   smp_fetch_sc_http_err_rate,  ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_http_req_cnt",    smp_fetch_sc_http_req_cnt,   ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_http_req_rate",   smp_fetch_sc_http_req_rate,  ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_inc_gpc0",        smp_fetch_sc_inc_gpc0,       ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_kbytes_in",       smp_fetch_sc_kbytes_in,      ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc_kbytes_out",      smp_fetch_sc_kbytes_out,     ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc_sess_cnt",        smp_fetch_sc_sess_cnt,       ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_sess_rate",       smp_fetch_sc_sess_rate,      ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc_tracked",         smp_fetch_sc_tracked,        ARG2(1,UINT,TAB), NULL, SMP_T_BOOL, SMP_USE_INTRN, },
+	{ "sc_trackers",        smp_fetch_sc_trackers,       ARG2(1,UINT,TAB), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_bytes_out_rate", smp_fetch_sc_bytes_out_rate, ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_clr_gpc0",       smp_fetch_sc_clr_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_conn_cnt",       smp_fetch_sc_conn_cnt,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_conn_cur",       smp_fetch_sc_conn_cur,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_conn_rate",      smp_fetch_sc_conn_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_get_gpc0",       smp_fetch_sc_get_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_gpc0_rate",      smp_fetch_sc_gpc0_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_http_err_cnt",   smp_fetch_sc_http_err_cnt,   ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_http_err_rate",  smp_fetch_sc_http_err_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_http_req_cnt",   smp_fetch_sc_http_req_cnt,   ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_http_req_rate",  smp_fetch_sc_http_req_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_inc_gpc0",       smp_fetch_sc_inc_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_kbytes_in",      smp_fetch_sc_kbytes_in,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc0_kbytes_out",     smp_fetch_sc_kbytes_out,     ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc0_sess_cnt",       smp_fetch_sc_sess_cnt,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_sess_rate",      smp_fetch_sc_sess_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc0_tracked",        smp_fetch_sc_tracked,        ARG1(0,TAB),      NULL, SMP_T_BOOL, SMP_USE_INTRN, },
+	{ "sc0_trackers",       smp_fetch_sc_trackers,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_bytes_out_rate", smp_fetch_sc_bytes_out_rate, ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_clr_gpc0",       smp_fetch_sc_clr_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_conn_cnt",       smp_fetch_sc_conn_cnt,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_conn_cur",       smp_fetch_sc_conn_cur,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_conn_rate",      smp_fetch_sc_conn_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_get_gpc0",       smp_fetch_sc_get_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_gpc0_rate",      smp_fetch_sc_gpc0_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_http_err_cnt",   smp_fetch_sc_http_err_cnt,   ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_http_err_rate",  smp_fetch_sc_http_err_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_http_req_cnt",   smp_fetch_sc_http_req_cnt,   ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_http_req_rate",  smp_fetch_sc_http_req_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_inc_gpc0",       smp_fetch_sc_inc_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_kbytes_in",      smp_fetch_sc_kbytes_in,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc1_kbytes_out",     smp_fetch_sc_kbytes_out,     ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc1_sess_cnt",       smp_fetch_sc_sess_cnt,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_sess_rate",      smp_fetch_sc_sess_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc1_tracked",        smp_fetch_sc_tracked,        ARG1(0,TAB),      NULL, SMP_T_BOOL, SMP_USE_INTRN, },
+	{ "sc1_trackers",       smp_fetch_sc_trackers,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_bytes_out_rate", smp_fetch_sc_bytes_out_rate, ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_clr_gpc0",       smp_fetch_sc_clr_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_conn_cnt",       smp_fetch_sc_conn_cnt,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_conn_cur",       smp_fetch_sc_conn_cur,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_conn_rate",      smp_fetch_sc_conn_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_get_gpc0",       smp_fetch_sc_get_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_gpc0_rate",      smp_fetch_sc_gpc0_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_http_err_cnt",   smp_fetch_sc_http_err_cnt,   ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_http_err_rate",  smp_fetch_sc_http_err_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_http_req_cnt",   smp_fetch_sc_http_req_cnt,   ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_http_req_rate",  smp_fetch_sc_http_req_rate,  ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_inc_gpc0",       smp_fetch_sc_inc_gpc0,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_kbytes_in",      smp_fetch_sc_kbytes_in,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc2_kbytes_out",     smp_fetch_sc_kbytes_out,     ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "sc2_sess_cnt",       smp_fetch_sc_sess_cnt,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_sess_rate",      smp_fetch_sc_sess_rate,      ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "sc2_tracked",        smp_fetch_sc_tracked,        ARG1(0,TAB),      NULL, SMP_T_BOOL, SMP_USE_INTRN, },
+	{ "sc2_trackers",       smp_fetch_sc_trackers,       ARG1(0,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "src_bytes_in_rate",  smp_fetch_sc_bytes_in_rate,  ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_bytes_out_rate", smp_fetch_sc_bytes_out_rate, ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_clr_gpc0",       smp_fetch_sc_clr_gpc0,       ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_conn_cnt",       smp_fetch_sc_conn_cnt,       ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_conn_cur",       smp_fetch_sc_conn_cur,       ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_conn_rate",      smp_fetch_sc_conn_rate,      ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_get_gpc0",       smp_fetch_sc_get_gpc0,       ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_gpc0_rate",      smp_fetch_sc_gpc0_rate,      ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_http_err_cnt",   smp_fetch_sc_http_err_cnt,   ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_http_err_rate",  smp_fetch_sc_http_err_rate,  ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_http_req_cnt",   smp_fetch_sc_http_req_cnt,   ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_http_req_rate",  smp_fetch_sc_http_req_rate,  ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_inc_gpc0",       smp_fetch_sc_inc_gpc0,       ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_kbytes_in",      smp_fetch_sc_kbytes_in,      ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_kbytes_out",     smp_fetch_sc_kbytes_out,     ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_sess_cnt",       smp_fetch_sc_sess_cnt,       ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_sess_rate",      smp_fetch_sc_sess_rate,      ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "src_updt_conn_cnt",  smp_fetch_src_updt_conn_cnt, ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_L4CLI, },
+	{ "table_avl",          smp_fetch_table_avl,         ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
+	{ "table_cnt",          smp_fetch_table_cnt,         ARG1(1,TAB),      NULL, SMP_T_UINT, SMP_USE_INTRN, },
 	{ /* END */ },
 }};