MINOR: checks: Add support of be_id, be_name, srv_id and srv_name sample fetches

It is now possible to call be_id, be_name, srv_id and srv_name sample fetches
from any sample expression or log-format string in a tcp-check based ruleset.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 763e4ad..86f3f1a 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -15648,11 +15648,13 @@
 
 be_id : integer
   Returns an integer containing the current backend's id. It can be used in
-  frontends with responses to check which backend processed the request.
+  frontends with responses to check which backend processed the request. It can
+  also be used in a tcp-check or an http-check ruleset.
 
 be_name : string
   Returns a string containing the current backend's name. It can be used in
-  frontends with responses to check which backend processed the request.
+  frontends with responses to check which backend processed the request. It can
+  also be used in a tcp-check or an http-check ruleset.
 
 dst : ip
   This is the destination IPv4 address of the connection on the client side,
@@ -16243,12 +16245,12 @@
 srv_id : integer
   Returns an integer containing the server's id when processing the response.
   While it's almost only used with ACLs, it may be used for logging or
-  debugging.
+  debugging. It can also be used in a tcp-check or an http-check ruleset.
 
 srv_name : string
   Returns a string containing the server's name when processing the response.
   While it's almost only used with ACLs, it may be used for logging or
-  debugging.
+  debugging. It can also be used in a tcp-check or an http-check ruleset.
 
 7.3.4. Fetching samples at Layer 5
 ----------------------------------
diff --git a/src/backend.c b/src/backend.c
index ccf06b8..472d905 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -2544,12 +2544,18 @@
 static int
 smp_fetch_be_id(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
-	if (!smp->strm)
+	struct proxy *px = NULL;
+
+	if (smp->strm)
+		px = smp->strm->be;
+	else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+		px = __objt_check(smp->sess->origin)->proxy;
+	if (!px)
 		return 0;
 
 	smp->flags = SMP_F_VOL_TXN;
 	smp->data.type = SMP_T_SINT;
-	smp->data.u.sint = smp->strm->be->uuid;
+	smp->data.u.sint = px->uuid;
 	return 1;
 }
 
@@ -2557,10 +2563,16 @@
 static int
 smp_fetch_be_name(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
-	if (!smp->strm)
+	struct proxy *px = NULL;
+
+	if (smp->strm)
+		px = smp->strm->be;
+	else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+		px = __objt_check(smp->sess->origin)->proxy;
+	if (!px)
 		return 0;
 
-	smp->data.u.str.area = (char *)smp->strm->be->id;
+	smp->data.u.str.area = (char *)px->id;
 	if (!smp->data.u.str.area)
 	        return 0;
 
@@ -2575,14 +2587,17 @@
 static int
 smp_fetch_srv_id(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
-	if (!smp->strm)
-		return 0;
+	struct server *srv = NULL;
 
-	if (!objt_server(smp->strm->target))
+	if (smp->strm)
+		srv = objt_server(smp->strm->target);
+	else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+		srv = __objt_check(smp->sess->origin)->server;
+	if (!srv)
 		return 0;
 
 	smp->data.type = SMP_T_SINT;
-	smp->data.u.sint = __objt_server(smp->strm->target)->puid;
+	smp->data.u.sint = srv->puid;
 
 	return 1;
 }
@@ -2591,13 +2606,16 @@
 static int
 smp_fetch_srv_name(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
-	if (!smp->strm)
-		return 0;
+	struct server *srv = NULL;
 
-	if (!objt_server(smp->strm->target))
+	if (smp->strm)
+		srv = objt_server(smp->strm->target);
+	else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+		srv = __objt_check(smp->sess->origin)->server;
+	if (!srv)
 		return 0;
 
-	smp->data.u.str.area = (char *)__objt_server(smp->strm->target)->id;
+	smp->data.u.str.area = srv->id;
 	if (!smp->data.u.str.area)
 	        return 0;