Index: extensions/dbg_interactive/routing.i
===================================================================
--- extensions/dbg_interactive/routing.i	(revision 1013)
+++ extensions/dbg_interactive/routing.i	(revision 1019)
@@ -66,9 +66,11 @@
 		fd_rtd_candidate_del($self, (os0_t)STRING, LENGTH);
 	}
-	void error(char * peerid, size_t peeridlen, char * STRING, size_t LENGTH, uint32_t rcode) {
-		int ret =  fd_rtd_error_add($self, peerid, peeridlen, (os0_t)STRING, LENGTH, rcode);
-		if (ret != 0) {
-			DI_ERROR(ret, NULL, NULL);
-		}
+	int error(char * peerid, size_t peeridlen, char * STRING, size_t LENGTH, uint32_t rcode) {
+		int n;
+		int ret =  fd_rtd_error_add($self, peerid, peeridlen, (os0_t)STRING, LENGTH, rcode, NULL, &n);
+		if (ret != 0) {
+			DI_ERROR(ret, NULL, NULL);
+		}
+		return n;
 	}
 	struct fd_list * extract(int score = 0) {
Index: extensions/rt_redirect/redir_fwd.c
===================================================================
--- extensions/rt_redirect/redir_fwd.c	(revision 740)
+++ extensions/rt_redirect/redir_fwd.c	(revision 1019)
@@ -238,5 +238,5 @@
 	CHECK_FCT( fd_msg_rt_get(q, &rtd) );
 	CHECK_FCT( fd_msg_source_get( m, &nh, &nhlen ) );
-	CHECK_FCT( fd_rtd_error_add(rtd, nh, nhlen, a_oh->os.data, a_oh->os.len, a_rc->u32) );
+	CHECK_FCT( fd_rtd_error_add(rtd, nh, nhlen, a_oh->os.data, a_oh->os.len, a_rc->u32, NULL, NULL) );
 	
 	/* Create a redir_rule  */
Index: include/freeDiameter/libfdproto.h
===================================================================
--- include/freeDiameter/libfdproto.h	(revision 1014)
+++ include/freeDiameter/libfdproto.h	(revision 1019)
@@ -2048,10 +2048,10 @@
 void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates, int ini_score);
 
-/* If a peer returned a protocol error for this message, save it so that we don't try to send it there again */
-int  fd_rtd_error_add(struct rt_data * rtd, DiamId_t sentto, size_t senttolen, uint8_t * origin, size_t originsz, uint32_t rcode);
+/* If a peer returned a protocol error for this message, save it so that we don't try to send it there again. Optionally retrieve the current list of candidates. */
+int  fd_rtd_error_add(struct rt_data * rtd, DiamId_t sentto, size_t senttolen, uint8_t * origin, size_t originsz, uint32_t rcode, struct fd_list ** candidates, int * sendingattemtps);
 
 /* The extracted list items have the following structure: */
 struct rtd_candidate {
-	struct fd_list	chain;	/* link in the list returned by the previous fct */
+	struct fd_list	chain;	/* link in the list returned by the previous fcts */
 	DiamId_t	diamid;	/* the diameter Id of the peer */
 	size_t		diamidlen; /* cached size of the diamid string */
Index: libfdproto/rt_data.c
===================================================================
--- libfdproto/rt_data.c	(revision 740)
+++ libfdproto/rt_data.c	(revision 1019)
@@ -43,5 +43,5 @@
 /* Structure that contains the routing data for a message */
 struct rt_data {
-	int		extracted;	/* if 0, candidates is ordered by diamid, otherwise the order is unspecified */
+	int		extracted;	/* if 0, candidates is ordered by diamid, otherwise the order is unspecified. This also counts the number of times the message was (re-)sent, as a side effect */
 	struct fd_list	candidates;	/* All the candidates. Items are struct rtd_candidate. */
 	struct fd_list	errors;		/* All errors received from other peers for this message */
@@ -185,10 +185,10 @@
 /* If a peer returned a protocol error for this message, save it so that we don't try to send it there again.
  Case insensitive search since the names are received from other peers*/
-int  fd_rtd_error_add(struct rt_data * rtd, DiamId_t sentto, size_t senttolen, uint8_t * origin, size_t originsz, uint32_t rcode)
+int  fd_rtd_error_add(struct rt_data * rtd, DiamId_t sentto, size_t senttolen, uint8_t * origin, size_t originsz, uint32_t rcode, struct fd_list ** candidates, int * sendingattemtps)
 {
 	struct fd_list * li;
 	int match = 0;
 	
-	TRACE_ENTRY("%p %p %zd %p %zd %u", rtd, sentto, senttolen, origin, originsz, rcode);
+	TRACE_ENTRY("%p %p %zd %p %zd %u %p %p", rtd, sentto, senttolen, origin, originsz, rcode, candidates, sendingattemtps);
 	CHECK_PARAMS( rtd && sentto && senttolen ); /* origin may be NULL */
 	
@@ -239,4 +239,10 @@
 		fd_rtd_candidate_del(rtd, origin, originsz);
 	
+	if (candidates)
+		*candidates = &rtd->candidates;
+	
+	if (sendingattemtps)
+		*sendingattemtps = rtd->extracted;
+	
 	/* Done! */
 	return 0;
@@ -260,5 +266,5 @@
 	}
 	
-	rtd->extracted = 1;
+	rtd->extracted += 1;
 	return;
 }
