[MEDIUM] session: tell analysers what bit they were called for

Some stream analysers might become generic enough to be called
for several bits. So we cannot have the analyser bit hard coded
into the analyser itself. Let's make the caller inform the callee.
diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index 8620bf4..d70603c 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -61,10 +61,10 @@
 int process_cli(struct session *t);
 int process_srv_data(struct session *t);
 int process_srv_conn(struct session *t);
-int http_wait_for_request(struct session *s, struct buffer *req);
-int http_process_request(struct session *t, struct buffer *req);
-int http_process_tarpit(struct session *s, struct buffer *req);
-int http_process_request_body(struct session *s, struct buffer *req);
+int http_wait_for_request(struct session *s, struct buffer *req, int an_bit);
+int http_process_request(struct session *t, struct buffer *req, int an_bit);
+int http_process_tarpit(struct session *s, struct buffer *req, int an_bit);
+int http_process_request_body(struct session *s, struct buffer *req, int an_bit);
 int process_response(struct session *t);
 
 void produce_content(struct session *s, struct buffer *rep);
diff --git a/include/proto/proto_tcp.h b/include/proto/proto_tcp.h
index 109bc09..61ec0bd 100644
--- a/include/proto/proto_tcp.h
+++ b/include/proto/proto_tcp.h
@@ -32,7 +32,7 @@
 void tcpv4_add_listener(struct listener *listener);
 void tcpv6_add_listener(struct listener *listener);
 int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen);
-int tcp_inspect_request(struct session *s, struct buffer *req);
+int tcp_inspect_request(struct session *s, struct buffer *req, int an_bit);
 
 #endif /* _PROTO_PROTO_TCP_H */
 
diff --git a/src/proto_http.c b/src/proto_http.c
index 7d43770..33e9466 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -1509,7 +1509,7 @@
  * when it has nothing left to do, and may remove any analyser when it wants to
  * abort.
  */
-int http_wait_for_request(struct session *s, struct buffer *req)
+int http_wait_for_request(struct session *s, struct buffer *req, int an_bit)
 {
 	/*
 	 * We will parse the partial (or complete) lines.
@@ -1780,7 +1780,7 @@
 				txn->req.cap, s->fe->req_cap);
 
 	/* end of job, return OK */
-	req->analysers &= ~AN_REQ_WAIT_HTTP;
+	req->analysers &= ~an_bit;
 	req->analyse_exp = TICK_ETERNITY;
 	return 1;
 
@@ -1814,14 +1814,14 @@
  * needs more data, encounters an error, or wants to immediately abort the
  * request. It relies on buffers flags, and updates s->req->analysers.
  */
-int http_process_request(struct session *s, struct buffer *req)
+int http_process_request(struct session *s, struct buffer *req, int an_bit)
 {
 	int cur_idx;
 	struct http_txn *txn = &s->txn;
 	struct http_msg *msg = &txn->req;
 	struct proxy *cur_proxy;
 
-	req->analysers &= ~AN_REQ_HTTP_HDR;
+	req->analysers &= ~an_bit;
 	req->analyse_exp = TICK_ETERNITY;
 
 	DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bl=%d analysers=%02x\n",
@@ -2448,7 +2448,7 @@
  * returns zero, at the beginning because it prevents any other processing
  * from occurring, and at the end because it terminates the request.
  */
-int http_process_tarpit(struct session *s, struct buffer *req)
+int http_process_tarpit(struct session *s, struct buffer *req, int an_bit)
 {
 	struct http_txn *txn = &s->txn;
 
@@ -2490,7 +2490,7 @@
  * because it expects the request to be parsed. It returns zero if it needs to
  * read more data, or 1 once it has completed its analysis.
  */
-int http_process_request_body(struct session *s, struct buffer *req)
+int http_process_request_body(struct session *s, struct buffer *req, int an_bit)
 {
 	struct http_msg *msg = &s->txn.req;
 	unsigned long body = msg->sol[msg->eoh] == '\r' ? msg->eoh + 2 : msg->eoh + 1;
@@ -2551,7 +2551,7 @@
 	    tick_is_expired(req->analyse_exp, now_ms)) {
 		/* The situation will not evolve, so let's give up on the analysis. */
 		s->logs.tv_request = now;  /* update the request timer to reflect full request */
-		req->analysers &= ~AN_REQ_HTTP_BODY;
+		req->analysers &= ~an_bit;
 		req->analyse_exp = TICK_ETERNITY;
 		return 1;
 	}
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 4a84186..59f76c4 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -373,7 +373,7 @@
  * called after XXX bytes have been received (or transfered), and the min of
  * all's wishes will be used to ring back (unless a special condition occurs).
  */
-int tcp_inspect_request(struct session *s, struct buffer *req)
+int tcp_inspect_request(struct session *s, struct buffer *req, int an_bit)
 {
 	struct tcp_rule *rule;
 	int partial;
@@ -441,7 +441,7 @@
 	/* if we get there, it means we have no rule which matches, or
 	 * we have an explicit accept, so we apply the default accept.
 	 */
-	req->analysers &= ~AN_REQ_INSPECT;
+	req->analysers &= ~an_bit;
 	req->analyse_exp = TICK_ETERNITY;
 	return 1;
 }
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 8af3d5a..a450217 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -640,7 +640,7 @@
  * STATS_ST_CLOSE. It removes the AN_REQ_UNIX_STATS bit from req->analysers
  * once done. It always returns 0.
  */
-int uxst_req_analyser_stats(struct session *s, struct buffer *req)
+int uxst_req_analyser_stats(struct session *s, struct buffer *req, int an_bit)
 {
 	char *line, *p;
 
@@ -694,7 +694,7 @@
 
 	case STATS_ST_CLOSE:
 		/* end of dump */
-		s->req->analysers &= ~AN_REQ_UNIX_STATS;
+		s->req->analysers &= ~an_bit;
 		s->ana_state = 0;
 		break;
 	}
@@ -793,7 +793,7 @@
 			 */
 			while (s->req->analysers) {
 				if (s->req->analysers & AN_REQ_UNIX_STATS)
-					if (!uxst_req_analyser_stats(s, s->req))
+					if (!uxst_req_analyser_stats(s, s->req, AN_REQ_UNIX_STATS))
 						break;
 
 				/* Just make sure that nobody set a wrong flag causing an endless loop */
diff --git a/src/session.c b/src/session.c
index 0f82639..1d223d0 100644
--- a/src/session.c
+++ b/src/session.c
@@ -726,31 +726,31 @@
 
 				if (s->req->analysers & AN_REQ_INSPECT) {
 					last_ana |= AN_REQ_INSPECT;
-					if (!tcp_inspect_request(s, s->req))
+					if (!tcp_inspect_request(s, s->req, AN_REQ_INSPECT))
 						break;
 				}
 
 				if (s->req->analysers & AN_REQ_WAIT_HTTP) {
 					last_ana |= AN_REQ_WAIT_HTTP;
-					if (!http_wait_for_request(s, s->req))
+					if (!http_wait_for_request(s, s->req, AN_REQ_WAIT_HTTP))
 						break;
 				}
 
 				if (s->req->analysers & AN_REQ_HTTP_HDR) {
 					last_ana |= AN_REQ_HTTP_HDR;
-					if (!http_process_request(s, s->req))
+					if (!http_process_request(s, s->req, AN_REQ_HTTP_HDR))
 						break;
 				}
 
 				if (s->req->analysers & AN_REQ_HTTP_TARPIT) {
 					last_ana |= AN_REQ_HTTP_TARPIT;
-					if (!http_process_tarpit(s, s->req))
+					if (!http_process_tarpit(s, s->req, AN_REQ_HTTP_TARPIT))
 						break;
 				}
 
 				if (s->req->analysers & AN_REQ_HTTP_BODY) {
 					last_ana |= AN_REQ_HTTP_BODY;
-					if (!http_process_request_body(s, s->req))
+					if (!http_process_request_body(s, s->req, AN_REQ_HTTP_BODY))
 						break;
 				}
 			}