changeset 1019:6fcd30ce3ce7

Retrieve additional information when adding a routing error
author Sebastien Decugis <sdecugis@freediameter.net>
date Mon, 01 Apr 2013 16:16:28 +0800
parents d67fec731a12
children 8110a781116a
files extensions/dbg_interactive/routing.i extensions/rt_redirect/redir_fwd.c include/freeDiameter/libfdproto.h libfdproto/rt_data.c
diffstat 4 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/dbg_interactive/routing.i	Mon Apr 01 16:14:35 2013 +0800
+++ b/extensions/dbg_interactive/routing.i	Mon Apr 01 16:16:28 2013 +0800
@@ -65,11 +65,13 @@
 	void remove(char * STRING, size_t LENGTH) {
 		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);
+	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) {
 		struct fd_list * li = NULL;
--- a/extensions/rt_redirect/redir_fwd.c	Mon Apr 01 16:14:35 2013 +0800
+++ b/extensions/rt_redirect/redir_fwd.c	Mon Apr 01 16:16:28 2013 +0800
@@ -237,7 +237,7 @@
 	CHECK_FCT( fd_msg_answ_getq(m, &q) );
 	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  */
 	CHECK_FCT( redir_entry_new(&entry, &task.rh, task.rhu, q, nh, nhlen, a_oh->os.data, a_oh->os.len) );
--- a/include/freeDiameter/libfdproto.h	Mon Apr 01 16:14:35 2013 +0800
+++ b/include/freeDiameter/libfdproto.h	Mon Apr 01 16:16:28 2013 +0800
@@ -2047,12 +2047,12 @@
 /* Extract the list of valid candidates, and initialize their scores to 0 */
 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 */
 	DiamId_t	realm;	/* the diameter realm of the peer */
--- a/libfdproto/rt_data.c	Mon Apr 01 16:14:35 2013 +0800
+++ b/libfdproto/rt_data.c	Mon Apr 01 16:16:28 2013 +0800
@@ -42,7 +42,7 @@
 
 /* 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 */
 };
@@ -184,12 +184,12 @@
 
 /* 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 */
 	
 	/* First add the new error entry */
@@ -238,6 +238,12 @@
 	if (origin)
 		fd_rtd_candidate_del(rtd, origin, originsz);
 	
+	if (candidates)
+		*candidates = &rtd->candidates;
+	
+	if (sendingattemtps)
+		*sendingattemtps = rtd->extracted;
+	
 	/* Done! */
 	return 0;
 }
@@ -259,7 +265,7 @@
 		c->score = ini_score;
 	}
 	
-	rtd->extracted = 1;
+	rtd->extracted += 1;
 	return;
 }
 
"Welcome to our mercurial repository"