changeset 1326:afe0ecdb0692

Add config option if Route-Record AVPs should be added in Answers. Some software does not handle them correctly.
author Thomas Klausner <tk@giga.or.at>
date Mon, 27 Nov 2017 15:18:57 +0100
parents ae81cd81ab09
children 82b386714795
files doc/freediameter.conf.sample include/freeDiameter/libfdcore.h libfdcore/config.c libfdcore/fdd.y libfdcore/p_psm.c
diffstat 5 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/doc/freediameter.conf.sample	Mon Nov 27 15:16:30 2017 +0100
+++ b/doc/freediameter.conf.sample	Mon Nov 27 15:18:57 2017 +0100
@@ -250,3 +250,9 @@
 
 
 ##############################################################
+## General settings
+
+# If Route-Record AVPs should be added in Answers.
+# Possible values: Always, Never
+# Default: Always
+#RouteRecordInAnswers = Never;
--- a/include/freeDiameter/libfdcore.h	Mon Nov 27 15:16:30 2017 +0100
+++ b/include/freeDiameter/libfdcore.h	Mon Nov 27 15:18:57 2017 +0100
@@ -134,6 +134,7 @@
 	int		 cnf_thr_srv;	/* Number of threads per servers handling the connection state machines */
 	struct fd_list	 cnf_apps;	/* Applications locally supported (except relay, see flags). Use fd_disp_app_support to add one. list of struct fd_app. */
 	uint16_t	 cnf_dispthr;	/* Number of dispatch threads to create */
+	uint16_t	 cnf_rr_in_answers;	/* include Route-Record AVP in answers */
 	struct {
 		unsigned no_fwd : 1;	/* the peer does not relay messages (0xffffff app id) */
 		unsigned no_ip4 : 1;	/* disable IP */
--- a/libfdcore/config.c	Mon Nov 27 15:16:30 2017 +0100
+++ b/libfdcore/config.c	Mon Nov 27 15:18:57 2017 +0100
@@ -67,6 +67,7 @@
 	#endif /* DISABLE_SCTP */
 	
 	fd_g_config->cnf_orstateid = (uint32_t) time(NULL);
+	fd_g_config->cnf_rr_in_answers = 1;
 	
 	CHECK_FCT( fd_dict_init(&fd_g_config->cnf_dict) );
 	CHECK_FCT( fd_fifo_new(&fd_g_config->cnf_main_ev, 0) );
--- a/libfdcore/fdd.y	Mon Nov 27 15:16:30 2017 +0100
+++ b/libfdcore/fdd.y	Mon Nov 27 15:18:57 2017 +0100
@@ -121,6 +121,9 @@
 %token		TLS_PRIO
 %token		TLS_DH_BITS
 %token		TLS_DH_FILE
+%token		RR_IN_ANSWERS
+%token		ALWAYS
+%token		NEVER
 
 
 /* -------------------------------------- */
@@ -153,6 +156,7 @@
 			| conffile tls_crl
 			| conffile tls_prio
 			| conffile tls_dh
+			| conffile rr_in_answers
 			| conffile errors
 			{
 				yyerror(&yylloc, conf, "An error occurred while parsing the configuration file");
@@ -665,3 +669,16 @@
 				fclose(fd);
 			}
 			;
+
+rr_values:		ALWAYS
+			{
+				conf->cnf_rr_in_answers = 1;
+			}
+			| NEVER
+			{
+				conf->cnf_rr_in_answers = 0;
+			}
+			;
+
+rr_in_answers:		RR_IN_ANSWERS '=' rr_values ';'
+			;
--- a/libfdcore/p_psm.c	Mon Nov 27 15:16:30 2017 +0100
+++ b/libfdcore/p_psm.c	Mon Nov 27 15:18:57 2017 +0100
@@ -552,7 +552,9 @@
 					CHECK_FCT_DO( fd_p_expi_update(peer), goto psm_end );
 
 					/* Set the message source and add the Route-Record */
-					CHECK_FCT_DO( fd_msg_source_setrr( msg, peer->p_hdr.info.pi_diamid, peer->p_hdr.info.pi_diamidlen, fd_g_config->cnf_dict ), goto psm_end);
+					if (fd_g_config->cnf_rr_in_answers || (hdr->msg_flags & CMD_FLAG_REQUEST)) {
+						CHECK_FCT_DO( fd_msg_source_setrr( msg, peer->p_hdr.info.pi_diamid, peer->p_hdr.info.pi_diamidlen, fd_g_config->cnf_dict ), goto psm_end);
+					}
 
 					if ((hdr->msg_flags & CMD_FLAG_REQUEST)) {
 						/* Mark the incoming request so that we know we have pending answers for this peer */
"Welcome to our mercurial repository"