[MAJOR] session: add track-counters to track counters related to the session

This patch adds the ability to set a pointer in the session to an
entry in a stick table which holds various counters related to a
specific pattern.

Right now the syntax matches the target syntax and only the "src"
pattern can be specified, to track counters related to the session's
IPv4 source address. There is a special function to extract it and
convert it to a key. But the goal is to be able to later support as
many patterns as for the stick rules, and get rid of the specific
function.

The "track-counters" directive may only be set in a "tcp-request"
statement right now. Only the first one applies. Probably that later
we'll support multi-criteria tracking for a single session and that
we'll have to name tracking pointers.

No counter is updated right now, only the refcount is. Some subsequent
patches will have to bring that feature.
diff --git a/include/types/proto_tcp.h b/include/types/proto_tcp.h
index 54d12a7..a7ca56a 100644
--- a/include/types/proto_tcp.h
+++ b/include/types/proto_tcp.h
@@ -1,23 +1,23 @@
 /*
-  include/types/proto_tcp.h
-  This file contains TCP protocol definitions.
-
-  Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
-  
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation, version 2.1
-  exclusively.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+ * include/types/proto_tcp.h
+ * This file contains TCP protocol definitions.
+ *
+ * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 #ifndef _TYPES_PROTO_TCP_H
 #define _TYPES_PROTO_TCP_H
@@ -26,17 +26,22 @@
 #include <common/mini-clist.h>
 
 #include <types/acl.h>
+#include <types/session.h>
 
 /* Layer4 accept/reject rules */
 enum {
 	TCP_ACT_ACCEPT = 1,
 	TCP_ACT_REJECT = 2,
+	TCP_ACT_TRK_CTR = 3,
 };
 
 struct tcp_rule {
 	struct list list;
 	struct acl_cond *cond;
 	int action;
+	union {
+		struct track_ctr_prm trk_ctr;
+	} act_prm;
 };
 
 #endif /* _TYPES_PROTO_TCP_H */
diff --git a/include/types/session.h b/include/types/session.h
index fdccc7b..222c30f 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -184,7 +184,8 @@
 		int flags;
 	} store[8];				/* tracked stickiness values to store */
 	int store_count;
-	struct stksess *tracked_src_counters;	/* tracked counters for this source */
+	struct stksess *tracked_counters;       /* counters currently being tracked by this session */
+	struct stktable *tracked_table;         /* table the counters above belong to (undefined if counters are null) */
 
 	struct {
 		int logwait;			/* log fields waiting to be collected : LW_* */
@@ -236,6 +237,15 @@
 	unsigned int uniq_id;			/* unique ID used for the traces */
 };
 
+/* parameters to configure tracked counters */
+struct track_ctr_prm {
+	int type;				/* type of the key */
+	union {
+		struct stktable *t;		/* a pointer to the table */
+		char *n;			/* or its name during parsing. */
+	} table;
+};
+
 
 #endif /* _TYPES_SESSION_H */