Index: .hgtags
===================================================================
--- .hgtags	(revision 1293)
+++ .hgtags	(revision 1282)
@@ -69,5 +69,2 @@
 f937feb727347445f8afb7759a97e34c76c0ba7b 1.2.0
 ab6457399be2762b3e85bd173ba754ff758ef060 1.2.1-rc1
-043b894b0511b6beb155576e9e2c509a21be8360 proposed_merged
-0000000000000000000000000000000000000000 proposed_merged
-13948c684c354d8c891ca5e2a5f1d76d1f176afe 1.2.1-rc2
Index: contrib/debian/changelog
===================================================================
--- contrib/debian/changelog	(revision 1304)
+++ contrib/debian/changelog	(revision 1234)
@@ -1,21 +1,2 @@
-freediameter (1.2.1) UNRELEASED; urgency=low
-
-  * New extension: rt_randomize (load-balancing on possible destinations)
-  * New contrib: Gx extension.
-  * rt_redirect.fdx and rt_load_balance.fdx improvement: use a hash table. Thanks Thomas.
-  * New hook HOOK_MESSAGE_SENDING to give a last chance to edit messages before they are sent.
-    This will be mostly used for enforcing interoperability constraints on non-compliant peers.
-  * Simplified log output. Old output can be recovered with DEBUG_WITH_META build option.
-  * Updated the internal counters for finer control on the load.
-  * Fixes in message expiry mechanism.
-  * Bug fixes in error messages generation.
-  * Improvements on shutdown sequence handling.
-  * Improvements to the dict_dcca_* extensions.
-  * Improved default CMake configuration.
-  * Fixes for a few newer operating systems compatibility.
-  * Fixed default secure Diameter port number 5868 instead of5658 (errata of RFC 6733)
-
- -- Sebastien Decugis <sdecugis@freediameter.net>  Sat, 30 Jan 2016 23:38:03 +0800
-
 freediameter (1.2.0) UNRELEASED; urgency=low
 
Index: doc/freediameter.conf.sample
===================================================================
--- doc/freediameter.conf.sample	(revision 1304)
+++ doc/freediameter.conf.sample	(revision 1246)
@@ -32,6 +32,6 @@
 # See TLS_old_method for more information about TLS flavours.
 # Note: we use TLS/SCTP instead of DTLS/SCTP at the moment. This will change in future version of freeDiameter.
-# Default: 5868. Use 0 to disable.
-#SecPort = 5868;
+# Default: 5658. Use 0 to disable.
+#SecPort = 5658;
 
 # Use RFC3588 method for TLS protection, where TLS is negociated after CER/CEA exchange is completed 
@@ -238,5 +238,5 @@
 #  No_TCP; No_SCTP; No_IP; No_IPv6; Prefer_TCP; TLS_old_method;
 #  No_TLS;       # assume transparent security instead of TLS. DTLS is not supported yet (will change in future versions).
-#  Port = 5868;  # The port to connect to
+#  Port = 5658;  # The port to connect to
 #  TcTimer = 30;
 #  TwTimer = 30;
Index: extensions/app_radgw/md5.c
===================================================================
--- extensions/app_radgw/md5.c	(revision 1291)
+++ extensions/app_radgw/md5.c	(revision 972)
@@ -293,5 +293,5 @@
     byteReverse((unsigned char *) ctx->buf, 4);
     os_memcpy(digest, ctx->buf, 16);
-    os_memset(ctx, 0, sizeof(*ctx));	/* In case it's sensitive */
+    os_memset(ctx, 0, sizeof(ctx));	/* In case it's sensitive */
 }
 
Index: extensions/app_sip/md5.c
===================================================================
--- extensions/app_sip/md5.c	(revision 1291)
+++ extensions/app_sip/md5.c	(revision 972)
@@ -316,5 +316,5 @@
     byteReverse((unsigned char *) ctx->buf, 4);
     os_memcpy(digest, ctx->buf, 16);
-    os_memset(ctx, 0, sizeof(*ctx));	/* In case it's sensitive */
+    os_memset(ctx, 0, sizeof(ctx));	/* In case it's sensitive */
 }
 
Index: extensions/dbg_msg_dumps/dbg_msg_dumps.c
===================================================================
--- extensions/dbg_msg_dumps/dbg_msg_dumps.c	(revision 1305)
+++ extensions/dbg_msg_dumps/dbg_msg_dumps.c	(revision 1306)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -93,5 +93,5 @@
 		if (msg) {
 			DiamId_t id = NULL;
-			if (!fd_msg_source_get( msg, &id, NULL ))
+			if (fd_msg_source_get( msg, &id, NULL ))
 				id = (DiamId_t)"<error getting source>";
 			if (!id)
@@ -105,8 +105,4 @@
 		}
 		break;
-	case HOOK_MESSAGE_PARSING_ERROR2:
-		LOG_E("PARSING ERROR, returning:");
-		LOG_SPLIT(FD_LOG_ERROR, "     ", buf, NULL);
-		break;
 	case HOOK_MESSAGE_ROUTING_ERROR:
 		LOG_E("ROUTING ERROR '%s' for: ", (char *)other);
@@ -121,8 +117,4 @@
 	case HOOK_MESSAGE_RECEIVED:
 		LOG_N("RCV from '%s':", peer_name);
-		LOG_SPLIT(FD_LOG_NOTICE, "     ", buf, NULL);
-		break;
-	case HOOK_MESSAGE_SENDING:
-		LOG_N("SNDING to '%s':", peer_name);
 		LOG_SPLIT(FD_LOG_NOTICE, "     ", buf, NULL);
 		break;
@@ -191,5 +183,5 @@
 		if (msg) {
 			DiamId_t id = NULL;
-			if (!fd_msg_source_get( msg, &id, NULL ))
+			if (fd_msg_source_get( msg, &id, NULL ))
 				id = (DiamId_t)"<error getting source>";
 			if (!id)
@@ -202,7 +194,4 @@
 		}
 		break;
-	case HOOK_MESSAGE_PARSING_ERROR2:
-		LOG_E("PARSING ERROR, returning: %s", buf);
-		break;
 	case HOOK_MESSAGE_ROUTING_ERROR:
 		LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf);
@@ -215,7 +204,4 @@
 	case HOOK_MESSAGE_RECEIVED:
 		LOG_N("RCV from '%s': %s", peer_name, buf);
-		break;
-	case HOOK_MESSAGE_SENDING:
-		LOG_N("SNDING to '%s': %s", peer_name, buf);
 		break;
 	case HOOK_MESSAGE_SENT:
@@ -276,5 +262,5 @@
 		if (msg) {
 			DiamId_t id = NULL;
-			if (!fd_msg_source_get( msg, &id, NULL ))
+			if (fd_msg_source_get( msg, &id, NULL ))
 				id = (DiamId_t)"<error getting source>";
 			if (!id)
@@ -287,7 +273,4 @@
 		}
 		break;
-	case HOOK_MESSAGE_PARSING_ERROR2:
-		LOG_E("PARSING ERROR, returning: %s", buf);
-		break;
 	case HOOK_MESSAGE_ROUTING_ERROR:
 		LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf);
@@ -300,7 +283,4 @@
 	case HOOK_MESSAGE_RECEIVED:
 		LOG_N("RCV from '%s': %s", peer_name, buf);
-		break;
-	case HOOK_MESSAGE_SENDING:
-		LOG_N("SNDING to '%s': %s", peer_name, buf);
 		break;
 	case HOOK_MESSAGE_SENT:
@@ -361,6 +341,6 @@
 	}
 	
-	mask_errors = HOOK_MASK( HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_PARSING_ERROR, HOOK_MESSAGE_PARSING_ERROR2, HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED  );
-	mask_sndrcv = HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT ); /* We don t access SENDING hook here */
+	mask_errors = HOOK_MASK( HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_PARSING_ERROR, HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED  );
+	mask_sndrcv = HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT );
 	mask_routing= HOOK_MASK( HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL );
 	mask_peers  = HOOK_MASK( HOOK_PEER_CONNECT_FAILED, HOOK_PEER_CONNECT_SUCCESS );
Index: extensions/test_app/ta_bench.c
===================================================================
--- extensions/test_app/ta_bench.c	(revision 1294)
+++ extensions/test_app/ta_bench.c	(revision 1206)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -37,57 +37,7 @@
 
 #include "test_app.h"
+
+#include <semaphore.h>
 #include <stdio.h>
-
-#ifndef __APPLE__ /* they deprecated the semaphore there... */
-#include <semaphore.h>
-
-#define my_sem_t sem_t
-#define my_sem_init sem_init
-#define my_sem_destroy sem_destroy
-#define my_sem_timedwait sem_timedwait
-#define my_sem_post sem_post
-
-#else // on APPLE
-#include <sched.h>
-#include <dispatch/dispatch.h>
-
-#define my_sem_t dispatch_semaphore_t
-
-static int my_sem_init(my_sem_t * s, int pshared, unsigned int value ) {
-	*s = dispatch_semaphore_create(value);
-	if (*s == NULL)
-		return ENOMEM;
-	return 0;
-}
-
-static int my_sem_destroy(my_sem_t *s) {
-	dispatch_release(*s);
-	*s = NULL;
-	return 0;
-}
-
-static int my_sem_timedwait(my_sem_t * s, struct timespec *ts) {
-	struct timespec tsn;
-	int64_t nsec;
-	dispatch_time_t when;
-	
-	CHECK_SYS( clock_gettime(CLOCK_REALTIME, &tsn) );
-	
-	nsec = (ts->tv_sec * 1000000000) + ts->tv_nsec
-		- (tsn.tv_sec * 1000000000) - tsn.tv_nsec;
-	
-	when = dispatch_time (  DISPATCH_TIME_NOW, nsec );
-	
-	return dispatch_semaphore_wait ( *s, when ) ? ETIMEDOUT : 0;
-}
-
-static int my_sem_post(my_sem_t *s) {
-	dispatch_semaphore_signal(*s);
-	return 0;
-}
-
-#endif // APPLE
-
-
 
 struct ta_mess_info {
@@ -96,5 +46,5 @@
 };
 
-static my_sem_t ta_sem; /* To handle the concurrency */
+static sem_t ta_sem; /* To handle the concurrency */
 
 /* Cb called when an answer is received */
@@ -160,5 +110,5 @@
 	
 	/* Post the semaphore */
-	CHECK_SYS_DO( my_sem_post(&ta_sem), );
+	CHECK_SYS_DO( sem_post(&ta_sem), );
 	
 	return;
@@ -264,5 +214,5 @@
 	do {
 		/* Do not create more that NB_CONCURRENT_MESSAGES in paralel */
-		int ret = my_sem_timedwait(&ta_sem, &end_time);
+		int ret = sem_timedwait(&ta_sem, &end_time);
 		if (ret == -1) {
 			ret = errno;
@@ -320,5 +270,5 @@
 int ta_bench_init(void)
 {
-	CHECK_SYS( my_sem_init( &ta_sem, 0, ta_conf->bench_concur) );
+	CHECK_SYS( sem_init( &ta_sem, 0, ta_conf->bench_concur) );
 
 	CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.bench", ta_bench_start ) );
@@ -331,5 +281,5 @@
 	// CHECK_FCT_DO( fd_sig_unregister(ta_conf->signal), /* continue */ );
 	
-	CHECK_SYS_DO( my_sem_destroy(&ta_sem), );
+	CHECK_SYS_DO( sem_destroy(&ta_sem), );
 	
 	return;
Index: extensions/test_app/ta_cli.c
===================================================================
--- extensions/test_app/ta_cli.c	(revision 1305)
+++ extensions/test_app/ta_cli.c	(revision 1214)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -71,4 +71,5 @@
 		
 		CHECK_FCT_DO( fd_sess_state_retrieve( ta_cli_reg, sess, &mi ), return );
+		TRACE_DEBUG( INFO, "%p %p", mi, data);
 		ASSERT( (void *)mi == data );
 	}
Index: freeDiameterd/main.c
===================================================================
--- freeDiameterd/main.c	(revision 1305)
+++ freeDiameterd/main.c	(revision 1182)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -172,5 +172,5 @@
 	/* Loop on arguments */
 	while (1) {
-		c = getopt_long (argc, argv, "hVc:dql:f:F:g:", long_options, &option_index);
+		c = getopt_long (argc, argv, "hVc:dql:M:", long_options, &option_index);
 		if (c == -1) 
 			break;	/* Exit from the loop.  */
@@ -208,5 +208,4 @@
 				#ifdef DEBUG
 				fd_debug_one_function = optarg;
-				fd_g_debug_lvl = FD_LOG_DEBUG;
 				#else /* DEBUG */
 				fprintf(stderr, "Error: must compile with DEBUG support to use --dbg_func feature!\n");
@@ -218,5 +217,4 @@
 				#ifdef DEBUG
 				fd_debug_one_file = basename(optarg);
-				fd_g_debug_lvl = FD_LOG_DEBUG;
 				#else /* DEBUG */
 				fprintf(stderr, "Error: must compile with DEBUG support to use --dbg_file feature!\n");
Index: include/freeDiameter/CMakeLists.txt
===================================================================
--- include/freeDiameter/CMakeLists.txt	(revision 1295)
+++ include/freeDiameter/CMakeLists.txt	(revision 1289)
@@ -16,6 +16,6 @@
 OPTION(ERRORS_ON_TODO "(development) Generate compilation errors on TODO items ?" OFF)
 
-# In DEBUG mode, each log can contain pid, calling function and file for easy debug. Set to ON to display this information.
-OPTION(DEBUG_WITH_META "Show calling location in logs?" OFF)
+# In DEBUG mode, each log contains pid, calling function and file for easy debug. Set to ON to strip this information.
+OPTION(DEBUG_WITHOUT_META "Strip calling location in logs?" OFF)
 	
 # Create the absolute path for searching extensions
@@ -37,5 +37,5 @@
 OPTION(WORKAROUND_ACCEPT_INVALID_VSAI "Do not reject a CER/CEA with a Vendor-Specific-Application-Id AVP containing both Auth- and Acct- application AVPs?" OFF)
 
-MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DEBUG_WITH_META DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI)
+MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DEBUG_WITHOUT_META DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI)
 
 ########################
Index: include/freeDiameter/freeDiameter-host.h.in
===================================================================
--- include/freeDiameter/freeDiameter-host.h.in	(revision 1305)
+++ include/freeDiameter/freeDiameter-host.h.in	(revision 1237)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -54,5 +54,5 @@
 #cmakedefine DISABLE_SCTP
 #cmakedefine DEBUG_SCTP
-#cmakedefine DEBUG_WITH_META
+#cmakedefine DEBUG_WITHOUT_META
 #cmakedefine SCTP_USE_MAPPED_ADDRESSES
 #cmakedefine SCTP_CONNECTX_4_ARGS
Index: include/freeDiameter/libfdcore.h
===================================================================
--- include/freeDiameter/libfdcore.h	(revision 1305)
+++ include/freeDiameter/libfdcore.h	(revision 1220)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2016, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -128,5 +128,5 @@
 	
 	uint16_t	 cnf_port;	/* the local port for legacy Diameter (default: 3868) in host byte order */
-	uint16_t	 cnf_port_tls;	/* the local port for Diameter/TLS (default: 5868) in host byte order */
+	uint16_t	 cnf_port_tls;	/* the local port for Diameter/TLS (default: 5658) in host byte order */
 	uint16_t	 cnf_port_3436; /* Open an additional server port to listen to old TLS/SCTP clients (RFC3436, freeDiameter versions < 1.2.0) */
 	uint16_t	 cnf_sctp_str;	/* default max number of streams for SCTP associations (def: 30) */
@@ -965,14 +965,4 @@
 		 */
 	
-	HOOK_MESSAGE_SENDING,
-		/* Hook called when a message is about to be sent to a peer. The message pointer cannot be modified here, but the content of the message
-		  could still be changed (for example add or remove some AVP. This is the last chance.
-		 - {msg} points to the message. Some objects may not have been dictionary resolved. If you
-		   try to call fd_msg_parse_dict, it will slow down the operation of the instance.
-		 - {peer} is the one the message is being sent to.
-		 - {other} is NULL.
-		 - {permsgdata} points to existing structure if any, or a new structure otherwise. 
-		 */
-	
 	HOOK_MESSAGE_SENT,
 		/* Hook called when a message has been sent to a peer. The message might be freed as soon as the hook function returns,
@@ -1003,5 +993,5 @@
 		 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered). 
 		 */
-		 
+	
 	HOOK_MESSAGE_ROUTING_ERROR,
 		/* Hook called when a message being processed by the routing thread meets an error such as no remaining available peer for sending, based on routing callbacks decisions (maybe after retries).
@@ -1059,14 +1049,5 @@
 		 */
 	
-	HOOK_MESSAGE_PARSING_ERROR2,
-		/* Hook called after an error message has been generated due to a dictionary parsing error.
-		 - {msg} points to the error message that has been generated.
-		 - {peer} is NULL. You can still retrieve the source from the message itself.
-		 - {other} is NULL
-		 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered). 
-		 Use this hook if you need to populate more data in the error being returned, from the error message. 
-		 (e.g. some AVP need to be added to replies even if error case.
-		 */
-#define HOOK_LAST	HOOK_MESSAGE_PARSING_ERROR2
+#define HOOK_LAST	HOOK_PEER_CONNECT_SUCCESS
 };
 
Index: include/freeDiameter/libfdproto.h
===================================================================
--- include/freeDiameter/libfdproto.h	(revision 1304)
+++ include/freeDiameter/libfdproto.h	(revision 1281)
@@ -110,5 +110,5 @@
 
 #define DIAMETER_PORT		3868
-#define DIAMETER_SECURE_PORT	5868
+#define DIAMETER_SECURE_PORT	5658
 
 
@@ -290,5 +290,5 @@
 #endif /* __PRETTY_FUNCTION__ */
 
-/* A version of __FILE__ without the full path. This is specific to each C file being compiled */
+/* A version of __FILE__ without the full path */
 static char * file_bname = NULL;
 static char * file_bname_init(char * full) { file_bname = basename(full); return file_bname; }
@@ -298,11 +298,11 @@
 
 /* In DEBUG mode, we add meta-information along each trace. This makes multi-threading problems easier to debug. */
-#if (defined(DEBUG) && defined(DEBUG_WITH_META))
+#if (defined(DEBUG) && !defined(DEBUG_WITHOUT_META))
 # define STD_TRACE_FMT_STRING "pid:%s in %s@%s:%d: "
 # define STD_TRACE_FMT_ARGS   , ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed"), __PRETTY_FUNCTION__, __STRIPPED_FILE__, __LINE__
-#else /* DEBUG && DEBUG_WITH_META */
+#else /* DEBUG && !DEBUG_WITHOUT_META */
 # define STD_TRACE_FMT_STRING ""
 # define STD_TRACE_FMT_ARGS
-#endif /* DEBUG && DEBUG_WITH_META */
+#endif /* DEBUG && !DEBUG_WITHOUT_META */
 
 /*************************
@@ -1259,26 +1259,4 @@
 typedef int (*dict_avpdata_encode) (void * data, union avp_value * val);
 
-/*
- * CALLBACK:	dict_avpdata_check
- *
- * PARAMETERS:
- *   val	: Pointer to the AVP value that was received and needs to be sanity checked.
- *   data      : a parameter stored in the type structure (to enable more generic check functions)
- *   error_msg: upon erroneous value, a string describing the error can be returned here (it will be strcpy by caller). This description will be returned in the error message, if any. 
- *
- * DESCRIPTION: 
- *   This callback can be provided with a derived type in order to improve the operation of the
- *  fd_msg_parse_dict function. When this callback is present, the value of the AVP that has
- * been parsed is passed to this function for finer granularity check. For example for some 
- * speccific AVP, the format of an OCTETSTRING value can be further checked, or the
- * interger value can be verified.
- *
- * RETURN VALUE:
- *  0      	: The value is valid.
- *  !0          : An error occurred, the error code is returned. It is advised to return EINVAL on incorrect val
- */
-typedef int (*dict_avpdata_check) (void * data, union avp_value * val, char ** error_msg);
-
-
 
 /* Type to hold data associated to a derived AVP data type */
@@ -1289,6 +1267,4 @@
 	dict_avpdata_encode	 type_encode;	/* cb to convert formatted data into an AVP value (or NULL) */
 	DECLARE_FD_DUMP_PROTOTYPE((*type_dump), union avp_value * val); /* cb called by fd_msg_dump_* for this type of data (if != NULL). Returned string must be freed.  */
-	dict_avpdata_check       type_check;
-	void  *                          type_check_param;
 };
 
@@ -1317,7 +1293,4 @@
 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value);
 
-
-/* For string AVP, the following type_check function provides simple basic check for specific characters presence, e.g. use "@." for trivial email address check */
-int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg);
 
 
Index: libfdcore/hooks.c
===================================================================
--- libfdcore/hooks.c	(revision 1305)
+++ libfdcore/hooks.c	(revision 1306)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -345,9 +345,4 @@
 			}
 			
-			case HOOK_MESSAGE_SENDING: {
-				LOG_A("SENDING message to '%s'", peer ? peer->p_hdr.info.pi_diamid : "<unknown>");
-				break;
-			}
-			
 			case HOOK_MESSAGE_SENT: {
 				CHECK_MALLOC_DO(fd_msg_dump_summary(&hook_default_buf, &hook_default_len, NULL, msg, NULL, 0, 1), break);
@@ -365,5 +360,5 @@
 				if (msg) {
 					DiamId_t id = NULL;
-					if (!fd_msg_source_get( msg, &id, NULL ))
+					if (fd_msg_source_get( msg, &id, NULL ))
 						id = (DiamId_t)"<error getting source>";
 					
@@ -380,12 +375,4 @@
 					LOG_E("Parsing error: cannot parse %zdB buffer from '%s': %s",  rcv_data->length, peer ? peer->p_hdr.info.pi_diamid : "<unknown>", hook_default_buf);
 				}
-				break;
-			}
-			
-			case HOOK_MESSAGE_PARSING_ERROR2: {
-				CHECK_MALLOC_DO(fd_msg_dump_treeview(&hook_default_buf, &hook_default_len, NULL, msg, NULL, 0, 1), break);
-
-				LOG_E("Returning following message after parsing error:");
-				LOG_SPLIT(FD_LOG_ERROR, "   ", hook_default_buf, NULL);
 				break;
 			}
Index: libfdcore/p_out.c
===================================================================
--- libfdcore/p_out.c	(revision 1305)
+++ libfdcore/p_out.c	(revision 1238)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -166,6 +166,4 @@
 	TRACE_ENTRY("%p %p %p", msg, cnx, peer);
 	CHECK_PARAMS( msg && *msg && (cnx || (peer && peer->p_cnxctx)));
-
-	fd_hook_call(HOOK_MESSAGE_SENDING, *msg, peer, NULL, fd_msg_pmdl_get(*msg));
 	
 	if (update_reqin_cnt && peer) {
Index: libfdcore/routing_dispatch.c
===================================================================
--- libfdcore/routing_dispatch.c	(revision 1301)
+++ libfdcore/routing_dispatch.c	(revision 1283)
@@ -454,5 +454,4 @@
 			} else {
 				if (!msgptr) {
-					fd_hook_call(HOOK_MESSAGE_PARSING_ERROR2, error, NULL, NULL, fd_msg_pmdl_get(error));
 					/* error now contains the answer message to send back */
 					CHECK_FCT( fd_fifo_post(fd_g_outgoing, &error) );
Index: libfdproto/dictionary_functions.c
===================================================================
--- libfdproto/dictionary_functions.c	(revision 1300)
+++ libfdproto/dictionary_functions.c	(revision 1284)
@@ -359,29 +359,2 @@
 }
 
-/* Check that a given AVP value contains all the characters from data in the same order */
-static char error_message[80];
-int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg)
-{
-	char * inChar = data;
-	char * inData = (char *)val->os.data;
-	int i = 0;
-	CHECK_PARAMS(data);
-	while (*inChar != '\0') {
-		while (i < val->os.len) {
-			if (*inChar == inData[i++]) {
-				inChar++;
-				break;
-			}
-		}
-		if (i >= val->os.len)
-			break;
-	}
-	if (*inChar == '\0')
-		return 0;
-	
-	if (error_msg) {
-		snprintf(error_message, sizeof(error_message), "Could not find '%c' in AVP", *inChar);
-		*error_msg = error_message;
-	}
-	return EBADMSG;
-}
Index: libfdproto/log.c
===================================================================
--- libfdproto/log.c	(revision 1305)
+++ libfdproto/log.c	(revision 1243)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -96,9 +96,9 @@
     /* add timestamp */
     printf("%s  ", fd_log_time(NULL, buf, sizeof(buf), 
-#if (defined(DEBUG) && defined(DEBUG_WITH_META))
+#if (defined(DEBUG) && !defined(DEBUG_WITHOUT_META))
     	1, 1
-#else /* (defined(DEBUG) && defined(DEBUG_WITH_META)) */
+#else /* (defined(DEBUG) && !defined(DEBUG_WITHOUT_META)) */
         0, 0
-#endif /* (defined(DEBUG) && defined(DEBUG_WITH_META)) */
+#endif /* (defined(DEBUG) && !defined(DEBUG_WITHOUT_META)) */
 	    ));
     /* Use colors on stdout ? */
Index: libfdproto/messages.c
===================================================================
--- libfdproto/messages.c	(revision 1305)
+++ libfdproto/messages.c	(revision 1248)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2015, WIDE Project and NICT								 *
+* Copyright (c) 2013, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -232,5 +232,5 @@
 		struct dict_avp_data dictdata;
 		
-		CHECK_FCT_DO(  fd_dict_getval(model, &dictdata), { free(new); return __ret__; }  );
+		CHECK_FCT(  fd_dict_getval(model, &dictdata)  );
 	
 		new->avp_model = model;
@@ -248,5 +248,5 @@
 		new->avp_rawlen = (*avp)->avp_public.avp_len - GETAVPHDRSZ( (*avp)->avp_public.avp_flags );
 		if (new->avp_rawlen) {
-			CHECK_MALLOC_DO(  new->avp_rawdata = malloc(new->avp_rawlen), { free(new); return __ret__; }  );
+			CHECK_MALLOC(  new->avp_rawdata = malloc(new->avp_rawlen)  );
 			memset(new->avp_rawdata, 0x00, new->avp_rawlen);
 		}
@@ -286,6 +286,6 @@
 		struct dict_object     	*dictappl;
 		
-		CHECK_FCT_DO( fd_dict_getdict(model, &dict), { free(new); return __ret__; } );
-		CHECK_FCT_DO( fd_dict_getval(model, &dictdata), { free(new); return __ret__; }  );
+		CHECK_FCT( fd_dict_getdict(model, &dict) );
+		CHECK_FCT( fd_dict_getval(model, &dictdata)  );
 		
 		new->msg_model = model;
@@ -294,8 +294,8 @@
 
 		/* Initialize application from the parent, if any */
-		CHECK_FCT_DO(  fd_dict_search( dict, DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0), { free(new); return __ret__; }  );
+		CHECK_FCT(  fd_dict_search( dict, DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0)  );
 		if (dictappl != NULL) {
 			struct dict_application_data appdata;
-			CHECK_FCT_DO(  fd_dict_getval(dictappl, &appdata), { free(new); return __ret__; }  );
+			CHECK_FCT(  fd_dict_getval(dictappl, &appdata)  );
 			new->msg_public.msg_appl = appdata.application_id;
 		}
@@ -365,14 +365,14 @@
 		
 		if (!sess_id_avp) {
-			CHECK_FCT_DO( fd_dict_search( dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &sess_id_avp, ENOENT), { free(ans); return __ret__; } );
-		}
-		CHECK_FCT_DO( fd_sess_getsid ( sess, &sid, &sidlen ), { free(ans); return __ret__; } );
-		CHECK_FCT_DO( fd_msg_avp_new ( sess_id_avp, 0, &avp ), { free(ans); return __ret__; } );
+			CHECK_FCT( fd_dict_search( dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &sess_id_avp, ENOENT) );
+		}
+		CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ) );
+		CHECK_FCT( fd_msg_avp_new ( sess_id_avp, 0, &avp ) );
 		val.os.data = sid;
 		val.os.len  = sidlen;
-		CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), { free(avp); free(ans); return __ret__; } );
-		CHECK_FCT_DO( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ), { free(avp); free(ans); return __ret__; } );
+		CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) );
+		CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ) );
 		ans->msg_sess = sess;
-		CHECK_FCT_DO( fd_sess_ref_msg(sess), { free(ans); return __ret__; }  );
+		CHECK_FCT( fd_sess_ref_msg(sess) );
 	}
 	
@@ -383,5 +383,5 @@
 		struct fd_list avpcpylist = FD_LIST_INITIALIZER(avpcpylist);
 		
-		CHECK_FCT_DO(  fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL) , { free(ans); return __ret__; } );
+		CHECK_FCT(  fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL)  );
 		while (avp) {
 			if ( (avp->avp_public.avp_code   == AC_PROXY_INFO)
@@ -394,13 +394,13 @@
 
 				/* Create a buffer with the content of the AVP. This is easier than going through the list */
-				CHECK_FCT_DO(  fd_msg_update_length(avp), { free(ans); return __ret__; }  );
-				CHECK_MALLOC_DO(  buf = malloc(avp->avp_public.avp_len), { free(ans); return __ret__; }  );
-				CHECK_FCT_DO( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp), { free(buf); free(ans); return __ret__; }  );
+				CHECK_FCT(  fd_msg_update_length(avp)  );
+				CHECK_MALLOC(  buf = malloc(avp->avp_public.avp_len)  );
+				CHECK_FCT( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp)  );
 
 				/* Now we parse this buffer to create a copy AVP */
-				CHECK_FCT_DO( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist), { free(buf); free(ans); return __ret__; } );
+				CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist) );
 				
 				/* Parse dictionary objects now to remove the dependency on the buffer */
-				CHECK_FCT_DO( parsedict_do_chain(dict, &avpcpylist, 0, &pei), { /* leaking the avpcpylist -- this should never happen anyway */ free(buf); free(ans); return __ret__; } );
+				CHECK_FCT( parsedict_do_chain(dict, &avpcpylist, 0, &pei) );
 
 				/* Done for this AVP */
@@ -411,5 +411,5 @@
 			}
 			/* move to next AVP in the message, we can have several Proxy-Info instances */
-			CHECK_FCT_DO( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL), { free(ans); return __ret__; } );
+			CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) );
 		}
 	}
@@ -2037,6 +2037,4 @@
 {
 	struct dict_avp_data dictdata;
-	struct dict_type_data derivedtypedata;
-	struct dict_object * avp_derived_type = NULL;
 	uint8_t * source;
 	
@@ -2219,31 +2217,4 @@
 			break;
 	
-	}
-	
-	/* Is there a derived type check function ? */
-	CHECK_FCT ( fd_dict_search ( dict, DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &avp_derived_type, 0) );
-	if (avp_derived_type) {
-		CHECK_FCT(  fd_dict_getval(avp_derived_type, &derivedtypedata)  );
-		if (derivedtypedata.type_check != NULL) {
-			char * err;
-			int ret = (*derivedtypedata.type_check)( derivedtypedata.type_check_param, &avp->avp_storage, &err );
-
-			if (ret != 0) {
-				TRACE_DEBUG(INFO, "The AVP failed to pass the dictionary validation");
-				if (error_info) {				
-						error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE";
-						error_info->pei_avp = avp;
-						strncpy(error_message, err, sizeof(error_message));
-						error_info->pei_message = error_message;
-				} else {
-					char * buf = NULL;
-					size_t buflen;
-					CHECK_MALLOC(fd_msg_dump_treeview(&buf, &buflen, NULL, avp, NULL, 0, 0));
-					LOG_E("Invalid AVP: %s", buf);
-					free(buf);
-				}
-				return ret; /* should we just return EBADMSG? */
-			}
-		}
 	}
 	
Index: tests/testmesg.c
===================================================================
--- tests/testmesg.c	(revision 1300)
+++ tests/testmesg.c	(revision 1281)
@@ -309,13 +309,4 @@
 			#endif
 		}
-
-		{ 
-			struct dict_object  * type = NULL;
-			struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test2", NULL, NULL, NULL, fd_dictfct_CharInOS_check, "@." };
-			struct dict_avp_data  avp_data = { 73575, 73565, "AVP Test - os2", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING };
-			CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );
-			CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );
-		}
-		
 		#if 0
 		{
@@ -762,46 +753,4 @@
 				/* reset */
 				CHECK( 0, fd_msg_free ( msg ) );
-			}
-			
-			/* Test with a type verifier */
-			{
-				struct fd_pei error_info;
-				CPYBUF();
-				buf_cpy[103] = 0x67;	/* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
-				
-				/* Check that we cannot support this message now */
-				CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
-				CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
-				
-				/* reset */
-				CHECK( 0, fd_msg_free ( msg ) );
-
-				CPYBUF();
-				buf_cpy[103] = 0x67;	/* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
-				
-				/* Check error reporting works */
-				CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
-				CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, &error_info ) );
-				
-				#if 1
-				fd_log_debug("Error reported: %s\n in AVP: %s", error_info.pei_message, fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, error_info.pei_avp, fd_g_config->cnf_dict, 0, 1));
-				#endif
-				
-				/* reset */
-				CHECK( 0, fd_msg_free ( msg ) );
-				
-				CPYBUF();
-				buf_cpy[103] = 0x67;	/* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
-				buf_cpy[130] = '@';
-				buf_cpy[140] = '.';     /* now we comply to the constraints */
-				
-				/* Check that we cannot support this message now */
-				CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
-				CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
-				
-				/* reset */
-				CHECK( 0, fd_msg_free ( msg ) );
-				
-				
 			}
 			
@@ -1450,4 +1399,5 @@
 	}
 	
+
 	/* That's all for the tests yet */
 	PASSTEST();
