Index: extensions/CMakeLists.txt
===================================================================
--- extensions/CMakeLists.txt	(revision 1436)
+++ extensions/CMakeLists.txt	(revision 1452)
@@ -90,4 +90,5 @@
 
 FD_EXTENSION_SUBDIR(dbg_dict_dump   "Log dictionary dump"                            ON)
+FD_EXTENSION_SUBDIR(dbg_dict_dump_json   "Dump dictionary as JSON"                            ON)
 FD_EXTENSION_SUBDIR(dbg_loglevel "Read loglevel from file -- allows runtime change"  ON)
 FD_EXTENSION_SUBDIR(dbg_monitor     "Outputs periodical status information"              ON)
Index: extensions/dbg_dict_dump_json/CMakeLists.txt
===================================================================
--- extensions/dbg_dict_dump_json/CMakeLists.txt	(revision 1452)
+++ extensions/dbg_dict_dump_json/CMakeLists.txt	(revision 1452)
@@ -0,0 +1,21 @@
+PROJECT("Dictionary dump to JSON extension" C)
+FD_ADD_EXTENSION(dbg_dict_dump_json dbg_dict_dump_json.cc)
+
+# sneakily uses dictionary-internal.h
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../libfdproto)
+
+INCLUDE(FindPkgConfig)
+
+# Uses JSONCPP to write JSON files
+PKG_CHECK_MODULES(JSONCPP REQUIRED jsoncpp)
+INCLUDE_DIRECTORIES(${JSONCPP_INCLUDE_DIR})
+LINK_DIRECTORIES(${JSONCPP_LIBRDIR})
+TARGET_LINK_LIBRARIES(dbg_dict_dump_json ${JSONCPP_LINK_LIBRARIES})
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS dbg_dict_dump_json
+	LIBRARY DESTINATION ${INSTALL_EXTENSIONS_SUFFIX}
+	COMPONENT freeDiameter-debug-tools)
+
Index: extensions/dbg_dict_dump_json/dbg_dict_dump_json.cc
===================================================================
--- extensions/dbg_dict_dump_json/dbg_dict_dump_json.cc	(revision 1452)
+++ extensions/dbg_dict_dump_json/dbg_dict_dump_json.cc	(revision 1452)
@@ -0,0 +1,439 @@
+/**********************************************************************************************************
+ * Software License Agreement (BSD License)                                                               *
+ * Author: Thomas Klausner <tk@giga.or.at>                                                                *
+ *                                                                                                        *
+ * Copyright (c) 2020 Thomas Klausner                                                                     *
+ * All rights reserved.                                                                                   *
+ *                                                                                                        *
+ * Written under contract by nfotex IT GmbH, http://nfotex.com/                                           *
+ *                                                                                                        *
+ * Redistribution and use of this software in source and binary forms, with or without modification, are  *
+ * permitted provided that the following conditions are met:                                              *
+ *                                                                                                        *
+ * * Redistributions of source code must retain the above                                                 *
+ *   copyright notice, this list of conditions and the                                                    *
+ *   following disclaimer.                                                                                *
+ *                                                                                                        *
+ * * Redistributions in binary form must reproduce the above                                              *
+ *   copyright notice, this list of conditions and the                                                    *
+ *   following disclaimer in the documentation and/or other                                               *
+ *   materials provided with the distribution.                                                            *
+ *                                                                                                        *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT     *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS    *
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                                             *
+ **********************************************************************************************************/
+
+
+/*
+ * Dump Diameter dictionary to JSON file.
+ *
+ * TODO: find out reason for many warnings in log
+ */
+
+#include <freeDiameter/extension.h>
+#include "dictionary-internal.h"
+#include <json/json.h>
+#include <sys/stat.h>
+
+#include <iomanip>
+#include <sstream>
+
+
+void
+dump_vendor(dict_object *self, struct dict_vendor_data *data, struct dict_object *parent, int depth, Json::Value &main)
+{
+        Json::Value vendor;
+
+        vendor["Code"] = Json::Value(data->vendor_id);
+        vendor["Name"] = Json::Value(data->vendor_name);
+        main["Vendors"].append(vendor);
+}
+
+void
+dump_application(dict_object *self, struct dict_application_data *data, struct dict_object *parent, int depth, Json::Value &main)
+{
+        Json::Value application;
+
+        application["Code"] = Json::Value(data->application_id);
+        application["Name"] = Json::Value(data->application_name);
+        main["Applications"].append(application);
+}
+
+void
+dump_enumval(dict_object *self, struct dict_enumval_data *data, struct dict_object *parent, int depth, Json::Value &main)
+{
+        enum dict_avp_basetype type;
+        struct dict_type_data type_data;
+        Json::Value enumval;
+        bool is_printable;
+
+        type = parent->data.type.type_base;
+
+        /* Standard only allows Integer32 Enumerated values, but freeDiameter is more permissive */
+        switch (type) {
+        case AVP_TYPE_OCTETSTRING:
+                is_printable = true;
+                for (size_t i = 0; i < data->enum_value.os.len; i++) {
+                        if (isprint(data->enum_value.os.data[i]) == 0) {
+                                is_printable = false;
+                                break;
+                        }
+                }
+                if (is_printable) {
+                        std::string output((const char*)data->enum_value.os.data, (size_t)data->enum_value.os.len);
+                        enumval["Code"] = Json::Value(output);
+                } else {
+                        std::stringstream quoted_string;
+                        quoted_string << "<";
+                        for (size_t i = 0; i < data->enum_value.os.len; i++) {
+                                quoted_string << std::hex << std::setfill('0') << std::setw(2) << (int)data->enum_value.os.data[i];
+                        }
+                        quoted_string << ">";
+                        enumval["Code"] = Json::Value(quoted_string.str());
+                }
+                break;
+
+        case AVP_TYPE_INTEGER32:
+                enumval["Code"] = Json::Value(data->enum_value.i32);
+                break;
+
+        case AVP_TYPE_INTEGER64:
+                enumval["Code"] = Json::Value(data->enum_value.i64);
+                break;
+
+        case AVP_TYPE_UNSIGNED32:
+                enumval["Code"] = Json::Value(data->enum_value.u32);
+                break;
+
+        case AVP_TYPE_UNSIGNED64:
+                enumval["Code"] = Json::Value(data->enum_value.u64);
+                break;
+
+        case AVP_TYPE_FLOAT32:
+                enumval["Code"] = Json::Value(data->enum_value.f32);
+                break;
+
+        case AVP_TYPE_FLOAT64:
+                enumval["Code"] = Json::Value(data->enum_value.f64);
+                break;
+
+        default:
+                printf("??? (ERROR unknown type %d)", type);
+                break;
+        }
+        if (fd_dict_getval(parent, &type_data) != 0) {
+                /* TODO: fd_dict_getval error */
+                return;
+        }
+        if (!main.isMember("Types") || !main["Types"].isMember(type_data.type_name)) {
+                /* TODO: missing type error */
+                return;
+        }
+
+        enumval["Name"] = Json::Value(data->enum_name);
+        main["Types"][type_data.type_name]["EnumValues"].append(enumval);
+}
+
+void
+dump_type(dict_object *self, struct dict_type_data *data, struct dict_object *parent, int depth, Json::Value &main)
+{
+        Json::Value type;
+
+        type["Name"] = Json::Value(data->type_name);
+        type["Base"] = Json::Value(type_base_name[data->type_base]);
+        main["Types"][data->type_name] = type;
+}
+
+#define AVPFL_str "%s%s"
+#define AVPFL_val(_val) (_val & AVP_FLAG_VENDOR)?"V":"" , (_val & AVP_FLAG_MANDATORY)?"M":""
+
+void
+dump_avp(dict_object *self, struct dict_avp_data *data, struct dict_object *parent, int depth, Json::Value &main)
+{
+        struct dict_object *type = NULL;
+        struct dict_type_data type_data;
+        Json::Value avp;
+        char flags[10];
+
+        fd_dict_search(fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, self, &type, ENOENT);
+        if (fd_dict_getval(type, &type_data) != 0) {
+                avp["Type"] = Json::Value(type_base_name[data->avp_basetype]);
+        } else {
+                if (strstr(type_data.type_name, "Enumerated") != 0) {
+                        if (data->avp_basetype == AVP_TYPE_INTEGER32) {
+                                avp["Type"] = "Enumerated";
+                        } else {
+                                /* freeDiameter allows enumerated types not based on integer32;
+                                 * write those out with their basic type for dict_json */
+                                avp["Type"] = Json::Value(type_base_name[data->avp_basetype]);
+                        }
+                } else {
+                        avp["Type"] = Json::Value(type_data.type_name);
+                }
+                if (main["Types"].isMember(type_data.type_name) && main["Types"][type_data.type_name].isMember("EnumValues")) {
+                        avp["EnumValues"] = main["Types"][type_data.type_name]["EnumValues"];
+                }
+        }
+
+        avp["Code"] = Json::Value(data->avp_code);
+        if (data->avp_vendor != 0) {
+                avp["Vendor"] = Json::Value(data->avp_vendor);
+        }
+        avp["Name"] = Json::Value(data->avp_name);
+        snprintf(flags, sizeof(flags), AVPFL_str, AVPFL_val(data->avp_flag_val));
+        avp["Flags"]["Must"] = Json::Value(flags);
+        snprintf(flags, sizeof(flags), AVPFL_str, AVPFL_val(data->avp_flag_mask & ~data->avp_flag_val));
+        avp["Flags"]["MustNot"] = Json::Value(flags);
+
+        main["AVPs"].append(avp);
+}
+
+#define CMDFL_str "%s%s%s%s"
+#define CMDFL_val(_val) (_val & CMD_FLAG_REQUEST)?"R":"" , (_val & CMD_FLAG_PROXIABLE)?"P":"" , (_val & CMD_FLAG_ERROR)?"E":"" , (_val & CMD_FLAG_RETRANSMIT)?"T":""
+
+void
+dump_command(dict_object *self, struct dict_cmd_data *data, struct dict_object *parent, int depth, Json::Value &main)
+{
+        Json::Value command;
+        char flags[10];
+
+        command["Code"] = Json::Value(data->cmd_code);
+        command["Name"] = Json::Value(data->cmd_name);
+        snprintf(flags, sizeof(flags), CMDFL_str, CMDFL_val(data->cmd_flag_val));
+        command["Flags"]["Must"] = Json::Value(flags);
+        snprintf(flags, sizeof(flags), CMDFL_str, CMDFL_val(data->cmd_flag_mask & ~data->cmd_flag_val));
+        command["Flags"]["MustNot"] = Json::Value(flags);
+        main["Commands"].append(command);
+}
+
+bool dump_object(dict_object *self, int depth, Json::Value &main);
+
+void
+dump_rule(dict_object *self, struct dict_rule_data *data, struct dict_object *parent, int depth, Json::Value &main)
+{
+        Json::Value avp_rule;
+        struct dict_avp_data avp_data;
+        const char *slot, *entry, *parent_avp_name;
+        vendor_id_t parent_avp_vendor;
+        unsigned int i;
+        bool found = false;
+        enum dict_object_type parent_type;
+
+        if (fd_dict_getval(data->rule_avp, &avp_data) != 0) {
+                /* TODO: fd_dict_getval error */
+                return;
+        }
+
+        if (avp_data.avp_vendor != 0) {
+                avp_rule["Vendor"] = Json::Value(avp_data.avp_vendor);
+        }
+        avp_rule["AVP"] = Json::Value(avp_data.avp_name);
+        /* TODO is this correct? what does rule_order specify? */
+        if (data->rule_position == RULE_FIXED_HEAD) {
+                avp_rule["First"] = Json::Value(true);
+        }
+        /* TODO: insert "unbounded" for -1? */
+        if (data->rule_min != -1) {
+                avp_rule["Min"] = Json::Value(data->rule_min);
+        }
+        if (data->rule_max != -1) {
+                avp_rule["Max"] = Json::Value(data->rule_max);
+        }
+
+        int ret = fd_dict_gettype(parent, &parent_type);
+        if (ret != 0) {
+                /* TODO: fd_dict_gettype error */
+                return;
+        }
+
+        if (parent_type == DICT_AVP) {
+                struct dict_avp_data parent_data;
+
+                slot = "AVPRules";
+                entry = "AVP";
+                if (fd_dict_getval(parent, &parent_data) != 0) {
+                        /* TODO: fd_dict_getval error */
+                        return;
+                }
+                parent_avp_name = parent_data.avp_name;
+                parent_avp_vendor = parent_data.avp_vendor;
+        } else if (parent_type == DICT_COMMAND) {
+                struct dict_cmd_data parent_data;
+
+                slot = "CommandRules";
+                entry = "Command";
+                if (fd_dict_getval(parent, &parent_data) != 0) {
+                        /* TODO: fd_dict_getval error */
+                        return;
+                }
+                parent_avp_name = parent_data.cmd_name;
+                parent_avp_vendor = 0;
+        } else {
+                /* TODO: error, unknown case */
+                return;
+        }
+
+        for (i=0; i<main[slot].size(); i++) {
+                if (main[slot][i][entry] == parent_avp_name
+                    && (parent_avp_vendor == 0 || !main[slot][i].isMember("Vendor") || parent_avp_vendor == main[slot][i]["Vendor"].asUInt())) {
+                        found = true;
+                        main[slot][i]["Content"].append(avp_rule);
+                        break;
+                }
+        }
+        if (!found) {
+                Json::Value parent_avp;
+                parent_avp[entry] = parent_avp_name;
+                if (parent_avp_vendor != 0) {
+                        parent_avp["Vendor"] = Json::Value(parent_avp_vendor);
+                }
+                parent_avp["Content"].append(avp_rule);
+                main[slot].append(parent_avp);
+        }
+
+}
+
+bool
+dump_list(struct fd_list *list, const char *type, int depth, Json::Value &main) {
+        fd_list *li;
+        for (li = list->next; li != list; li = li->next) {
+                if (!dump_object((dict_object *)li->o, depth, main)) {
+                        LOG_E("error dumping %s", type);
+                        return false;
+                }
+        }
+        return true;
+}
+
+bool
+dump_object(dict_object *self, int depth, Json::Value &main)
+{
+        enum dict_object_type t;
+        int ret = fd_dict_gettype (self, &t);
+        if (ret != 0) {
+                return false;
+        }
+
+        switch (t) {
+#define DUMP_OBJECT_CASE(TYPE, STRUCT, DUMP_FUNCTION)                   \
+                case TYPE: {                                            \
+                        struct STRUCT * data = NULL;                    \
+                        int i;                                          \
+                        data = (struct STRUCT *)malloc(sizeof(struct STRUCT)); \
+                        if (!data) {                                    \
+                                /* TODO: malloc error */                \
+                                return false;                           \
+                        }                                               \
+                        ret = fd_dict_getval(self, data);               \
+                        if (ret != 0) {                                 \
+                                /* TODO: fd_dict_getval error */        \
+                                free(data);                             \
+                                return false;                           \
+                        }                                               \
+                        DUMP_FUNCTION(self, data, self->parent, depth, main); \
+                        if (depth > 0) {                                \
+                                for (i=0; i<NB_LISTS_PER_OBJ; i++) {    \
+                                        if ((self->list[i].o == NULL) && (self->list[i].next != &self->list[i])) { \
+                                                dump_list(&self->list[i], 0, depth-1, main); \
+                                                break;                  \
+                                        }                               \
+                                }                                       \
+                        }                                               \
+                }                                                       \
+                        break;
+
+                DUMP_OBJECT_CASE(DICT_VENDOR, dict_vendor_data, dump_vendor);
+                DUMP_OBJECT_CASE(DICT_APPLICATION, dict_application_data, dump_application);
+                DUMP_OBJECT_CASE(DICT_TYPE, dict_type_data, dump_type);
+                DUMP_OBJECT_CASE(DICT_ENUMVAL, dict_enumval_data, dump_enumval);
+                DUMP_OBJECT_CASE(DICT_AVP, dict_avp_data, dump_avp);
+                DUMP_OBJECT_CASE(DICT_COMMAND, dict_cmd_data, dump_command);
+                DUMP_OBJECT_CASE(DICT_RULE, dict_rule_data, dump_rule);
+        default:
+                /* TODO: unhandled type error */
+                return false;
+        }
+        return true;
+}
+
+bool
+dump_dictionary_to_json(dictionary *dict, Json::Value &main)
+{
+        if (dict == NULL) {
+                return false;
+        }
+
+        if (pthread_rwlock_rdlock(&dict->dict_lock) != 0) {
+                return false;
+        }
+
+        dump_list(&(dict->dict_types), "types", 2, main);
+        dump_object(&(dict->dict_vendors), 3, main);
+        dump_list(&(dict->dict_vendors.list[0]), "vendors", 3, main);
+        dump_object(&(dict->dict_applications), 1, main);
+        dump_list(&(dict->dict_applications.list[0]), "applications", 1, main);
+        dump_list(&(dict->dict_cmd_code), "commands", 1, main);
+
+        if (pthread_rwlock_unlock( &dict->dict_lock) != 0) {
+                return false;
+        }
+
+        return true;
+}
+
+
+static int
+dbg_dict_dump_json_entry(char * conffile)
+{
+        TRACE_ENTRY("%p", conffile);
+        Json::Value main;
+        Json::Value types = Json::Value::null;
+        Json::StyledWriter writer;
+        FILE *out = stdout;
+
+        if (conffile) {
+                if ((out=fopen(conffile, "w")) == NULL) {
+                        LOG_E("cannot open output file '%s' for writing", conffile);
+                        return EINVAL;
+                }
+        }
+
+        /* get main dictionary */
+        struct dictionary * dict = fd_g_config->cnf_dict;
+        if (!dump_dictionary_to_json(dict, main)) {
+                LOG_E("error dumping dictionary to JSON");
+                return EINVAL;
+        }
+        /* remove enumerated types before dumping, they are in AVPs */
+        /* convert remaining ones to array */
+        Json::Value::Members members = main["Types"].getMemberNames();
+        for (auto it = members.begin() ; it != members.end(); ++it) {
+                if (strncmp("Enumerated", main["Types"][*it]["Name"].asCString(), strlen("Enumerated")) == 0) {
+                        main["Types"].removeMember(*it);
+                } else {
+                        types.append(main["Types"][*it]);
+                }
+        }
+        main.removeMember("Types");
+        main["Types"] = types;
+
+        std::string value_str = writer.write(main);
+        fprintf(out, "%s\n", value_str.c_str());
+
+        if (conffile) {
+                fclose(out);
+        }
+
+        LOG_N("Extension 'Dump dictionaries to JSON' initialized");
+        return 0;
+}
+
+extern "C" {
+        EXTENSION_ENTRY("dbg_dict_dump_json", dbg_dict_dump_json_entry);
+}
Index: freeDiameterd/main.c
===================================================================
--- freeDiameterd/main.c	(revision 1412)
+++ freeDiameterd/main.c	(revision 1450)
@@ -91,5 +91,5 @@
 	}
 
-	/* Cleaup pidfile on exit */
+	/* Cleanup pidfile on exit */
 	if (atexit(pidfile_cleanup) != 0) {
 		LOG_F("Unable to setup pidfile cleanup");
Index: libfdproto/dictionary-internal.h
===================================================================
--- libfdproto/dictionary-internal.h	(revision 1451)
+++ libfdproto/dictionary-internal.h	(revision 1451)
@@ -0,0 +1,136 @@
+/*********************************************************************************************************
+* Software License Agreement (BSD License)                                                               *
+* Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
+*													 *
+* Copyright (c) 2015, WIDE Project and NICT								 *
+* All rights reserved.											 *
+* 													 *
+* Redistribution and use of this software in source and binary forms, with or without modification, are  *
+* permitted provided that the following conditions are met:						 *
+* 													 *
+* * Redistributions of source code must retain the above 						 *
+*   copyright notice, this list of conditions and the 							 *
+*   following disclaimer.										 *
+*    													 *
+* * Redistributions in binary form must reproduce the above 						 *
+*   copyright notice, this list of conditions and the 							 *
+*   following disclaimer in the documentation and/or other						 *
+*   materials provided with the distribution.								 *
+* 													 *
+* * Neither the name of the WIDE Project or NICT nor the 						 *
+*   names of its contributors may be used to endorse or 						 *
+*   promote products derived from this software without 						 *
+*   specific prior written permission of WIDE Project and 						 *
+*   NICT.												 *
+* 													 *
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
+* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
+* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 	 *
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 	 *
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
+* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
+* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.								 *
+*********************************************************************************************************/
+
+#ifndef HAD_DICTIONARY_INTERNAL_H
+#define HAD_DICTIONARY_INTERNAL_H
+
+/* Names of the base types */
+extern const char * type_base_name[];
+
+/* The number of lists in an object */
+#define NB_LISTS_PER_OBJ	3
+
+/* Definition of the dictionary objects */
+struct dict_object {
+	enum dict_object_type	type;	/* What type of object is this? */
+	int			objeyec;/* eyecatcher for this object */
+	int			typeyec;/* eyecatcher for this type of object */
+	struct dictionary	*dico;  /* The dictionary this object belongs to */
+
+	union {
+		struct dict_vendor_data		vendor;		/* datastr_len = strlen(vendor_name) */
+		struct dict_application_data	application;	/* datastr_len = strlen(application_name) */
+		struct dict_type_data		type;		/* datastr_len = strlen(type_name) */
+		struct dict_enumval_data	enumval;	/* datastr_len = strlen(enum_name) */
+		struct dict_avp_data		avp;		/* datastr_len = strlen(avp_name) */
+		struct dict_cmd_data		cmd;		/* datastr_len = strlen(cmd_name) */
+		struct dict_rule_data		rule;		/* datastr_len = 0 */
+	} data;				/* The data of this object */
+
+	size_t			datastr_len; /* cached length of the string inside the data. Saved when the object is created. */
+
+	struct dict_object *	parent; /* The parent of this object, if any */
+
+	struct fd_list		list[NB_LISTS_PER_OBJ];/* used to chain objects.*/
+	/* More information about the lists :
+
+	 - the use for each list depends on the type of object. See detail below.
+
+	 - a sentinel for a list has its 'o' field cleared. (this is the criteria to detect end of a loop)
+
+	 - The lists are always ordered. The criteria are described below. the functions to order them are referenced in dict_obj_info
+
+	 - The dict_lock must be held for any list operation.
+
+	 => VENDORS:
+	 list[0]: list of the vendors, ordered by their id. The sentinel is g_dict_vendors (vendor with id 0)
+	 list[1]: sentinel for the list of AVPs from this vendor, ordered by AVP code.
+	 list[2]: sentinel for the list of AVPs from this vendor, ordered by AVP name (fd_os_cmp).
+
+	 => APPLICATIONS:
+	 list[0]: list of the applications, ordered by their id. The sentinel is g_dict_applications (application with id 0)
+	 list[1]: not used
+	 list[2]: not used.
+
+	 => TYPES:
+	 list[0]: list of the types, ordered by their names. The sentinel is g_list_types.
+	 list[1]: sentinel for the type_enum list of this type, ordered by their constant name (fd_os_cmp).
+	 list[2]: sentinel for the type_enum list of this type, ordered by their constant value.
+
+	 => TYPE_ENUMS:
+	 list[0]: list of the contants for a given type, ordered by the constant name (fd_os_cmp). Sentinel is a (list[1]) element of a TYPE object.
+	 list[1]: list of the contants for a given type, ordered by the constant value. Sentinel is a (list[2]) element of a TYPE object.
+	 list[2]: not used
+
+	 => AVPS:
+	 list[0]: list of the AVP from a given vendor, ordered by avp code. Sentinel is a list[1] element of a VENDOR object.
+	 list[1]: list of the AVP from a given vendor, ordered by avp name (fd_os_cmp). Sentinel is a list[2] element of a VENDOR object.
+	 list[2]: sentinel for the rule list that apply to this AVP.
+
+	 => COMMANDS:
+	 list[0]: list of the commands, ordered by their names (fd_os_cmp). The sentinel is g_list_cmd_name.
+	 list[1]: list of the commands, ordered by their command code and 'R' flag. The sentinel is g_list_cmd_code.
+	 list[2]: sentinel for the rule list that apply to this command.
+
+	 => RULES:
+	 list[0]: list of the rules for a given (grouped) AVP or Command, ordered by the AVP vendor & code to which they refer. sentinel is list[2] of a command or (grouped) avp.
+	 list[1]: not used
+	 list[2]: not used.
+
+	 */
+
+	 /* Sentinel for the dispatch callbacks */
+	 struct fd_list		disp_cbs;
+
+};
+
+/* Definition of the dictionary structure */
+struct dictionary {
+	int		 	dict_eyec;		/* Eye-catcher for the dictionary (DICT_EYECATCHER) */
+
+	pthread_rwlock_t 	dict_lock;		/* The global rwlock for the dictionary */
+
+	struct dict_object	dict_vendors;		/* Sentinel for the list of vendors, corresponding to vendor 0 */
+	struct dict_object	dict_applications;	/* Sentinel for the list of applications, corresponding to app 0 */
+	struct fd_list		dict_types;		/* Sentinel for the list of types */
+	struct fd_list		dict_cmd_name;		/* Sentinel for the list of commands, ordered by names */
+	struct fd_list		dict_cmd_code;		/* Sentinel for the list of commands, ordered by codes */
+
+	struct dict_object	dict_cmd_error;		/* Special command object for answers with the 'E' bit set */
+
+	int			dict_count[DICT_TYPE_MAX + 1]; /* Number of objects of each type */
+};
+
+#endif /* HAD_DICTIONARY_INTERNAL_H */
Index: libfdproto/dictionary.c
===================================================================
--- libfdproto/dictionary.c	(revision 1444)
+++ libfdproto/dictionary.c	(revision 1451)
@@ -35,4 +35,5 @@
 
 #include "fdproto-internal.h"
+#include "dictionary-internal.h"
 #include <inttypes.h>
 
@@ -49,101 +50,7 @@
 	};
 
-/* The number of lists in an object */
-#define NB_LISTS_PER_OBJ	3
-
 /* Some eye catchers definitions */
 #define OBJECT_EYECATCHER	(0x0b13c7)
 #define DICT_EYECATCHER		(0x00d1c7)
-
-/* Definition of the dictionary objects */
-struct dict_object {
-	enum dict_object_type	type;	/* What type of object is this? */
-	int			objeyec;/* eyecatcher for this object */
-	int			typeyec;/* eyecatcher for this type of object */
-	struct dictionary	*dico;  /* The dictionary this object belongs to */
-	
-	union {
-		struct dict_vendor_data		vendor;		/* datastr_len = strlen(vendor_name) */
-		struct dict_application_data	application;	/* datastr_len = strlen(application_name) */
-		struct dict_type_data		type;		/* datastr_len = strlen(type_name) */
-		struct dict_enumval_data	enumval;	/* datastr_len = strlen(enum_name) */
-		struct dict_avp_data		avp;		/* datastr_len = strlen(avp_name) */
-		struct dict_cmd_data		cmd;		/* datastr_len = strlen(cmd_name) */
-		struct dict_rule_data		rule;		/* datastr_len = 0 */
-	} data;				/* The data of this object */
-	
-	size_t			datastr_len; /* cached length of the string inside the data. Saved when the object is created. */
-	
-	struct dict_object *	parent; /* The parent of this object, if any */
-	
-	struct fd_list		list[NB_LISTS_PER_OBJ];/* used to chain objects.*/
-	/* More information about the lists :
-	
-	 - the use for each list depends on the type of object. See detail below.
-	 
-	 - a sentinel for a list has its 'o' field cleared. (this is the criteria to detect end of a loop)
-	 
-	 - The lists are always ordered. The criteria are described below. the functions to order them are referenced in dict_obj_info
-	 
-	 - The dict_lock must be held for any list operation.
-	 
-	 => VENDORS:
-	 list[0]: list of the vendors, ordered by their id. The sentinel is g_dict_vendors (vendor with id 0)
-	 list[1]: sentinel for the list of AVPs from this vendor, ordered by AVP code.
-	 list[2]: sentinel for the list of AVPs from this vendor, ordered by AVP name (fd_os_cmp).
-	 
-	 => APPLICATIONS:
-	 list[0]: list of the applications, ordered by their id. The sentinel is g_dict_applications (application with id 0)
-	 list[1]: not used
-	 list[2]: not used.
-	 
-	 => TYPES:
-	 list[0]: list of the types, ordered by their names. The sentinel is g_list_types.
-	 list[1]: sentinel for the type_enum list of this type, ordered by their constant name (fd_os_cmp).
-	 list[2]: sentinel for the type_enum list of this type, ordered by their constant value.
-	 
-	 => TYPE_ENUMS:
-	 list[0]: list of the contants for a given type, ordered by the constant name (fd_os_cmp). Sentinel is a (list[1]) element of a TYPE object.
-	 list[1]: list of the contants for a given type, ordered by the constant value. Sentinel is a (list[2]) element of a TYPE object.
-	 list[2]: not used
-	 
-	 => AVPS:
-	 list[0]: list of the AVP from a given vendor, ordered by avp code. Sentinel is a list[1] element of a VENDOR object.
-	 list[1]: list of the AVP from a given vendor, ordered by avp name (fd_os_cmp). Sentinel is a list[2] element of a VENDOR object.
-	 list[2]: sentinel for the rule list that apply to this AVP.
-	 
-	 => COMMANDS:
-	 list[0]: list of the commands, ordered by their names (fd_os_cmp). The sentinel is g_list_cmd_name.
-	 list[1]: list of the commands, ordered by their command code and 'R' flag. The sentinel is g_list_cmd_code.
-	 list[2]: sentinel for the rule list that apply to this command.
-	 
-	 => RULES:
-	 list[0]: list of the rules for a given (grouped) AVP or Command, ordered by the AVP vendor & code to which they refer. sentinel is list[2] of a command or (grouped) avp.
-	 list[1]: not used
-	 list[2]: not used.
-	 
-	 */
-	 
-	 /* Sentinel for the dispatch callbacks */
-	 struct fd_list		disp_cbs;
-	
-};
-
-/* Definition of the dictionary structure */
-struct dictionary {
-	int		 	dict_eyec;		/* Eye-catcher for the dictionary (DICT_EYECATCHER) */
-	
-	pthread_rwlock_t 	dict_lock;		/* The global rwlock for the dictionary */
-	
-	struct dict_object	dict_vendors;		/* Sentinel for the list of vendors, corresponding to vendor 0 */
-	struct dict_object	dict_applications;	/* Sentinel for the list of applications, corresponding to app 0 */
-	struct fd_list		dict_types;		/* Sentinel for the list of types */
-	struct fd_list		dict_cmd_name;		/* Sentinel for the list of commands, ordered by names */
-	struct fd_list		dict_cmd_code;		/* Sentinel for the list of commands, ordered by codes */
-	
-	struct dict_object	dict_cmd_error;		/* Special command object for answers with the 'E' bit set */
-	
-	int			dict_count[DICT_TYPE_MAX + 1]; /* Number of objects of each type */
-};
 
 /* Forward declarations of dump functions */
@@ -178,30 +85,30 @@
 } dict_obj_info[] = { { 0, "(error)", 0, 0, 0, 0, NULL, NULL, {0, 0, 0} }
 
-	/* type			 name		datasize		   	  parent  	parenttype 
+	/* type			 name		datasize		   	  parent  	parenttype
 			eyecatcher		dump_data	  	search_fct,		haslist[] 	*/
 
 	,{ DICT_VENDOR,		"VENDOR",	sizeof(struct dict_vendor_data),	0, 	0,
 			OBJECT_EYECATCHER + 1, 	dump_vendor_data, 	search_vendor, 		{ 1, 0, 0 } }
-	
+
 	,{ DICT_APPLICATION,	"APPLICATION",	sizeof(struct dict_application_data),	1, 	DICT_VENDOR,
 			OBJECT_EYECATCHER + 2,	dump_application_data,	search_application,	{ 1, 0, 0 } }
-	
+
 	,{ DICT_TYPE,		"TYPE",		sizeof(struct dict_type_data),		1, 	DICT_APPLICATION,
 			OBJECT_EYECATCHER + 3,	dump_type_data,		search_type,		{ 1, 0, 0 } }
-	
+
 	,{ DICT_ENUMVAL,	"ENUMVAL",	sizeof(struct dict_enumval_data),	2, 	DICT_TYPE,
 			OBJECT_EYECATCHER + 4,	NULL,			search_enumval,	{ 1, 1, 0 } }
-	
+
 	,{ DICT_AVP,		"AVP",		sizeof(struct dict_avp_data),		1, 	DICT_TYPE,
 			OBJECT_EYECATCHER + 5,	dump_avp_data,		search_avp,		{ 1, 1,	0 } }
-	
+
 	,{ DICT_COMMAND,	"COMMAND",	sizeof(struct dict_cmd_data),		1, 	DICT_APPLICATION,
 			OBJECT_EYECATCHER + 6,	dump_command_data,	search_cmd,		{ 1, 1, 0 } }
-	
+
 	,{ DICT_RULE,		"RULE",		sizeof(struct dict_rule_data),		2, 	-1 /* special case: grouped avp or command */,
 			OBJECT_EYECATCHER + 7,	dump_rule_data,		search_rule,		{ 1, 0, 0 } }
-	
+
 };
-	
+
 /* Macro to verify a "type" value */
 #define CHECK_TYPE( type ) ( ((type) > 0) && ((type) <= DICT_TYPE_MAX) )
@@ -231,15 +138,15 @@
 	str = os0dup( str, *(plen));		\
 }
-	
+
 /* Initialize an object */
 static void init_object( struct dict_object * obj, enum dict_object_type type )
 {
 	int i;
-	
+
 	TRACE_ENTRY("%p %d", obj, type);
-	
+
 	/* Clean the object first */
 	memset ( obj, 0, sizeof(struct dict_object));
-	
+
 	CHECK_PARAMS_DO(  CHECK_TYPE(type),  return  );
 
@@ -249,13 +156,13 @@
 
 	/* We don't initialize the data nor the parent here */
-	
+
 	/* Now init the lists */
 	for (i=0; i<NB_LISTS_PER_OBJ; i++) {
-		if (_OBINFO(obj).haslist[i] != 0) 
+		if (_OBINFO(obj).haslist[i] != 0)
 			fd_list_init(&obj->list[i], obj);
 		else
 			fd_list_init(&obj->list[i], NULL);
 	}
-	
+
 	fd_list_init(&obj->disp_cbs, NULL);
 }
@@ -266,8 +173,8 @@
 	TRACE_ENTRY("%p %p %d", dest, source, type);
 	CHECK_PARAMS( dest && source && CHECK_TYPE(type) );
-	
-	/* Generic: copy the full data structure */	
+
+	/* Generic: copy the full data structure */
 	memcpy( &dest->data, source, dict_obj_info[type].datasize );
-	
+
 	/* Then strings must be duplicated, not copied */
 	/* This function might be simplified by always defining the "name" field as the first field of the structures, but... it's error-prone */
@@ -276,19 +183,19 @@
 			DUP_string_len( dest->data.vendor.vendor_name, &dest->datastr_len );
 			break;
-		
+
 		case DICT_APPLICATION:
 			DUP_string_len( dest->data.application.application_name, &dest->datastr_len );
 			break;
-			
+
 		case DICT_TYPE:
 			DUP_string_len( dest->data.type.type_name, &dest->datastr_len );
 			break;
-			
+
 		case DICT_ENUMVAL:
 			DUP_string_len( dest->data.enumval.enum_name, &dest->datastr_len );
 			if (dupos) {
 				// we also need to duplicate the octetstring constant value since it is a pointer.
-				dest->data.enumval.enum_value.os.data = os0dup( 
-						((struct dict_enumval_data *)source)->enum_value.os.data, 
+				dest->data.enumval.enum_value.os.data = os0dup(
+						((struct dict_enumval_data *)source)->enum_value.os.data,
 						((struct dict_enumval_data *)source)->enum_value.os.len
 					);
@@ -299,14 +206,14 @@
 			DUP_string_len( dest->data.avp.avp_name, &dest->datastr_len );
 			break;
-			
+
 		case DICT_COMMAND:
 			DUP_string_len( dest->data.cmd.cmd_name, &dest->datastr_len );
 			break;
-		
+
 		default:
 			/* Nothing to do for RULES */
 			;
 	}
-	
+
 	return 0;
 }
@@ -316,5 +223,5 @@
 {
 	TRACE_ENTRY("%p", obj);
-	
+
 	CHECK_PARAMS_DO(  obj
 			&& (obj->objeyec == OBJECT_EYECATCHER)
@@ -334,5 +241,5 @@
 			return 0;
 		}  );
-	
+
 	/* The object is probably valid. */
 	return 1;
@@ -343,18 +250,18 @@
 {
 	/* TRACE_ENTRY("%p", obj); */
-	
+
 	switch (obj->type) {
 		case DICT_VENDOR:
 			free( obj->data.vendor.vendor_name );
 			break;
-		
+
 		case DICT_APPLICATION:
 			free( obj->data.application.application_name );
 			break;
-			
+
 		case DICT_TYPE:
 			free( obj->data.type.type_name );
 			break;
-			
+
 		case DICT_ENUMVAL:
 			free( obj->data.enumval.enum_name );
@@ -364,9 +271,9 @@
 			free( obj->data.avp.avp_name );
 			break;
-			
+
 		case DICT_COMMAND:
 			free( obj->data.cmd.cmd_name );
 			break;
-		
+
 		default:
 			/* nothing to do */
@@ -379,8 +286,8 @@
 
 /* Destroy all objects in a list - the lock must be held */
-static void destroy_list(struct fd_list * head) 
+static void destroy_list(struct fd_list * head)
 {
 	/* TRACE_ENTRY("%p", head); */
-	
+
 	/* loop in the list */
 	while (!FD_IS_LIST_EMPTY(head))
@@ -390,22 +297,22 @@
 	}
 }
-	
+
 /* Free an object and its sublists */
 static void destroy_object(struct dict_object * obj)
 {
 	int i;
-	
+
 	/* TRACE_ENTRY("%p", obj); */
-	
+
 	/* Update global count */
-	if (obj->dico) 
+	if (obj->dico)
 		obj->dico->dict_count[obj->type]--;
-	
+
 	/* Mark the object as invalid */
 	obj->objeyec = 0xdead;
-	
+
 	/* First, destroy the data associated to the object */
 	destroy_object_data(obj);
-	
+
 	for (i=0; i<NB_LISTS_PER_OBJ; i++) {
 		if (_OBINFO(obj).haslist[i])
@@ -416,5 +323,5 @@
 			destroy_list( &obj->list[i] );
 	}
-	
+
 	/* Unlink all elements from the dispatch list; they will be freed when callback is unregistered */
 	CHECK_POSIX_DO( pthread_rwlock_wrlock(&fd_disp_lock), /* continue */ );
@@ -423,5 +330,5 @@
 	}
 	CHECK_POSIX_DO( pthread_rwlock_unlock(&fd_disp_lock), /* continue */ );
-	
+
 	/* Last, destroy the object */
 	free(obj);
@@ -438,5 +345,5 @@
 /* Compare two values */
 #define ORDER_scalar( i1, i2 ) \
-	((i1 < i2 ) ? -1 : ( i1 > i2 ? 1 : 0 )) 
+	((i1 < i2 ) ? -1 : ( i1 > i2 ? 1 : 0 ))
 
 
@@ -445,5 +352,5 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	return ORDER_scalar( o1->data.vendor.vendor_id, o2->data.vendor.vendor_id );
 }
@@ -453,5 +360,5 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	return ORDER_scalar( o1->data.application.application_id, o2->data.application.application_id );
 }
@@ -461,5 +368,5 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	return fd_os_cmp( o1->data.type.type_name, o1->datastr_len, o2->data.type.type_name, o2->datastr_len );
 }
@@ -469,5 +376,5 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	return fd_os_cmp( o1->data.enumval.enum_name, o1->datastr_len, o2->data.enumval.enum_name, o2->datastr_len );
 }
@@ -477,11 +384,11 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	/* The comparison function depends on the type of data */
 	switch ( o1->parent->data.type.type_base ) {
 		case AVP_TYPE_OCTETSTRING:
-			return fd_os_cmp( o1->data.enumval.enum_value.os.data, o1->data.enumval.enum_value.os.len, 
+			return fd_os_cmp( o1->data.enumval.enum_value.os.data, o1->data.enumval.enum_value.os.len,
 					  o2->data.enumval.enum_value.os.data, o2->data.enumval.enum_value.os.len);
-		
+
 		case AVP_TYPE_INTEGER32:
 			return ORDER_scalar( o1->data.enumval.enum_value.i32, o2->data.enumval.enum_value.i32 );
@@ -513,5 +420,5 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	return ORDER_scalar( o1->data.avp.avp_code, o2->data.avp.avp_code );
 }
@@ -521,5 +428,5 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	return fd_os_cmp( o1->data.avp.avp_name, o1->datastr_len, o2->data.avp.avp_name, o2->datastr_len );
 }
@@ -529,5 +436,5 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	return fd_os_cmp( o1->data.cmd.cmd_name, o1->datastr_len, o2->data.cmd.cmd_name, o2->datastr_len );
 }
@@ -538,18 +445,18 @@
 	uint8_t fl1, fl2;
 	int cmp = 0;
-	
+
 	TRACE_ENTRY("%p %p", o1, o2);
-	
+
 	cmp = ORDER_scalar( o1->data.cmd.cmd_code, o2->data.cmd.cmd_code );
-	if (cmp) 
+	if (cmp)
 		return cmp;
-	
+
 	/* Same command code, we must compare the value of the 'R' flag */
 	fl1 = o1->data.cmd.cmd_flag_val & CMD_FLAG_REQUEST;
 	fl2 = o2->data.cmd.cmd_flag_val & CMD_FLAG_REQUEST;
-	
+
 	/* We want requests first, so we reverse the operators here */
 	return ORDER_scalar(fl2, fl1);
-		
+
 }
 
@@ -558,6 +465,6 @@
 {
 	TRACE_ENTRY("%p %p", o1, o2);
-	
-	return ORDER_scalar(o1->data.rule.rule_avp->data.avp.avp_vendor, o2->data.rule.rule_avp->data.avp.avp_vendor) 
+
+	return ORDER_scalar(o1->data.rule.rule_avp->data.avp.avp_vendor, o2->data.rule.rule_avp->data.avp.avp_vendor)
 		?: ORDER_scalar(o1->data.rule.rule_avp->data.avp.avp_code, o2->data.rule.rule_avp->data.avp.avp_code) ;
 }
@@ -745,7 +652,7 @@
 	int ret = 0;
 	vendor_id_t id;
-	
+
 	TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result);
-	
+
 	switch (criteria) {
 		case VENDOR_BY_ID:
@@ -753,20 +660,20 @@
 			SEARCH_scalar( id, &dict->dict_vendors.list[0], vendor.vendor_id, 1, &dict->dict_vendors );
 			break;
-				
+
 		case VENDOR_BY_NAME:
 			/* "what" is a vendor name */
 			SEARCH_os0( what, &dict->dict_vendors.list[0], vendor.vendor_name, 0);
 			break;
-			
+
 		case VENDOR_OF_APPLICATION:
 			/* "what" should be an application object */
 			SEARCH_childs_parent( DICT_APPLICATION, &dict->dict_vendors );
 			break;
-		
+
 		case VENDOR_OF_AVP:
 			/* "what" should be an avp object */
 			SEARCH_sentinel( DICT_AVP, 0, 1 );
 			break;
-		
+
 		default:
 			/* Invalid criteria */
@@ -781,7 +688,7 @@
 	int ret = 0;
 	application_id_t id;
-	
+
 	TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result);
-	
+
 	switch (criteria) {
 		case APPLICATION_BY_ID:
@@ -790,20 +697,20 @@
 			SEARCH_scalar( id, &dict->dict_applications.list[0],  application.application_id, 1, &dict->dict_applications );
 			break;
-				
+
 		case APPLICATION_BY_NAME:
 			/* "what" is an application name */
 			SEARCH_os0( what, &dict->dict_applications.list[0], application.application_name, 0);
 			break;
-			
+
 		case APPLICATION_OF_TYPE:
 			/* "what" should be a type object */
 			SEARCH_childs_parent( DICT_TYPE, &dict->dict_applications );
 			break;
-		
+
 		case APPLICATION_OF_COMMAND:
 			/* "what" should be a command object */
 			SEARCH_childs_parent( DICT_COMMAND, &dict->dict_applications );
 			break;
-		
+
 		default:
 			/* Invalid criteria */
@@ -817,7 +724,7 @@
 {
 	int ret = 0;
-	
+
 	TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result);
-	
+
 	switch (criteria) {
 		case TYPE_BY_NAME:
@@ -825,16 +732,16 @@
 			SEARCH_os0( what, &dict->dict_types, type.type_name, 1);
 			break;
-			
+
 		case TYPE_OF_ENUMVAL:
 			/* "what" should be a type_enum object */
 			SEARCH_childs_parent( DICT_ENUMVAL, NULL );
 			break;
-		
+
 		case TYPE_OF_AVP:
 			/* "what" should be an avp object */
 			SEARCH_childs_parent( DICT_AVP, NULL );
 			break;
-		
-				
+
+
 		default:
 			/* Invalid criteria */
@@ -848,7 +755,7 @@
 {
 	int ret = 0;
-	
+
 	TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result);
-	
+
 	switch (criteria) {
 		case ENUMVAL_BY_STRUCT:
@@ -856,7 +763,7 @@
 				struct dict_object * parent = NULL;
 				struct dict_enumval_request * _what = (struct dict_enumval_request *) what;
-				
+
 				CHECK_PARAMS(  _what  &&  ( _what->type_obj || _what->type_name )  );
-				
+
 				if (_what->type_obj != NULL) {
 					parent = _what->type_obj;
@@ -867,7 +774,7 @@
 							CHECK_PARAMS( 0 ) );
 				}
-				
+
 				/* From here the "parent" object is valid */
-				
+
 				if ( _what->search.enum_name != NULL ) {
 					/* We are looking for this string */
@@ -877,8 +784,8 @@
 					switch (parent->data.type.type_base) {
 						case AVP_TYPE_OCTETSTRING:
-							SEARCH_os(	 _what->search.enum_value.os.data, 
-									 _what->search.enum_value.os.len, 
-									 &parent->list[2], 
-									 enumval.enum_value.os , 
+							SEARCH_os(	 _what->search.enum_value.os.data,
+									 _what->search.enum_value.os.len,
+									 &parent->list[2],
+									 enumval.enum_value.os ,
 									 1 );
 							break;
@@ -891,5 +798,5 @@
 									(struct dict_object *)NULL);
 							break;
-							
+
 						case AVP_TYPE_INTEGER64:
 							SEARCH_scalar(	_what->search.enum_value.i64,
@@ -899,5 +806,5 @@
 									(struct dict_object *)NULL);
 							break;
-							
+
 						case AVP_TYPE_UNSIGNED32:
 							SEARCH_scalar(	_what->search.enum_value.u32,
@@ -907,5 +814,5 @@
 									(struct dict_object *)NULL);
 							break;
-							
+
 						case AVP_TYPE_UNSIGNED64:
 							SEARCH_scalar(	_what->search.enum_value.u64,
@@ -915,5 +822,5 @@
 									(struct dict_object *)NULL);
 							break;
-							
+
 						case AVP_TYPE_FLOAT32:
 							SEARCH_scalar(	_what->search.enum_value.f32,
@@ -923,5 +830,5 @@
 									(struct dict_object *)NULL);
 							break;
-							
+
 						case AVP_TYPE_FLOAT64:
 							SEARCH_scalar(	_what->search.enum_value.f64,
@@ -931,5 +838,5 @@
 									(struct dict_object *)NULL);
 							break;
-							
+
 						default:
 							/* Invalid parent type basetype */
@@ -937,9 +844,9 @@
 					}
 				}
-				
+
 			}
 			break;
-		
-				
+
+
 		default:
 			/* Invalid criteria */
@@ -953,7 +860,7 @@
 {
 	int ret = 0;
-	
+
 	TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result);
-	
+
 	switch (criteria) {
 		case AVP_BY_CODE:
@@ -965,10 +872,10 @@
 			}
 			break;
-				
+
 		case AVP_BY_NAME:
 			/* "what" is the AVP name, vendor 0 */
 			SEARCH_os0( what, &dict->dict_vendors.list[2], avp.avp_name, 1);
 			break;
-			
+
 		case AVP_BY_CODE_AND_VENDOR:
 		case AVP_BY_NAME_AND_VENDOR:
@@ -976,7 +883,7 @@
 				struct dict_avp_request * _what = (struct dict_avp_request *) what;
 				struct dict_object * vendor = NULL;
-				
+
 				CHECK_PARAMS( (criteria != AVP_BY_NAME_AND_VENDOR) || _what->avp_name  );
-				
+
 				/* Now look for the vendor first */
 				CHECK_FCT( search_vendor( dict, VENDOR_BY_ID, &_what->avp_vendor, &vendor ) );
@@ -988,5 +895,5 @@
 					goto end;
 				}
-				
+
 				/* We now have our vendor = head of the appropriate avp list */
 				if (criteria == AVP_BY_NAME_AND_VENDOR) {
@@ -998,13 +905,13 @@
 			}
 			break;
-		
+
 		case AVP_BY_STRUCT:
 			{
 				struct dict_avp_request_ex * _what = (struct dict_avp_request_ex *) what;
 				struct dict_object * vendor = NULL;
-				
+
 				CHECK_PARAMS( _what->avp_vendor.vendor || _what->avp_vendor.vendor_id || _what->avp_vendor.vendor_name );
 				CHECK_PARAMS( _what->avp_data.avp_code || _what->avp_data.avp_name );
-				
+
 				/* Now look for the vendor first */
 				if (_what->avp_vendor.vendor) {
@@ -1017,5 +924,5 @@
 					CHECK_FCT( search_vendor( dict, VENDOR_BY_NAME, _what->avp_vendor.vendor_name, &vendor ) );
 				}
-				
+
 				if (vendor == NULL) {
 					if (result)
@@ -1025,5 +932,5 @@
 					goto end;
 				}
-				
+
 				/* We now have our vendor = head of the appropriate avp list */
 				if (_what->avp_data.avp_code) {
@@ -1035,13 +942,13 @@
 			}
 			break;
-		
+
 		case AVP_BY_NAME_ALL_VENDORS:
 			{
 				struct fd_list * li;
 				size_t wl = strlen((char *)what);
-				
+
 				/* First, search for vendor 0 */
 				SEARCH_os0_l( what, wl, &dict->dict_vendors.list[2], avp.avp_name, 1);
-				
+
 				/* If not found, loop for all vendors, until found */
 				for (li = dict->dict_vendors.list[0].next; li != &dict->dict_vendors.list[0]; li = li->next) {
@@ -1050,5 +957,5 @@
 			}
 			break;
-		
+
 		default:
 			/* Invalid criteria */
@@ -1062,7 +969,7 @@
 {
 	int ret = 0;
-	
+
 	TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result);
-	
+
 	switch (criteria) {
 		case CMD_BY_NAME:
@@ -1070,5 +977,5 @@
 			SEARCH_os0( what, &dict->dict_cmd_name, cmd.cmd_name, 1);
 			break;
-			
+
 		case CMD_BY_CODE_R:
 		case CMD_BY_CODE_A:
@@ -1076,18 +983,18 @@
 				command_code_t code;
 				uint8_t searchfl = 0;
-				
+
 				/* The command code that we are searching */
 				code = *(command_code_t *) what;
-				
+
 				/* The flag (request or answer) of the command we are searching */
 				if (criteria == CMD_BY_CODE_R) {
 					searchfl = CMD_FLAG_REQUEST;
 				}
-				
+
 				/* perform the search */
 				SEARCH_codefl( code, searchfl, &dict->dict_cmd_code );
 			}
 			break;
-				
+
 		case CMD_ANSWER:
 			{
@@ -1095,10 +1002,10 @@
 				struct dict_object * req = (struct dict_object *) what;
 				struct dict_object * ans = NULL;
-				
-				CHECK_PARAMS( verify_object(req) 
+
+				CHECK_PARAMS( verify_object(req)
 						&& (req->type == DICT_COMMAND)
 						&& (req->data.cmd.cmd_flag_mask & CMD_FLAG_REQUEST)
 						&& (req->data.cmd.cmd_flag_val  & CMD_FLAG_REQUEST) );
-				
+
 				/* The answer is supposed to be the next element in the list, if it exists */
 				ans = req->list[1].next->o;
@@ -1108,5 +1015,5 @@
 					goto end;
 				}
-				
+
 				/* Now check that the ans element is really the correct one */
 				if (  (ans->data.cmd.cmd_code != req->data.cmd.cmd_code)
@@ -1117,11 +1024,11 @@
 					goto end;
 				}
-				
+
 				if (result)
 					*result = ans;
 				ret = 0;
-			}						
-			break;
-			
+			}
+			break;
+
 		default:
 			/* Invalid criteria */
@@ -1135,7 +1042,7 @@
 {
 	int ret = 0;
-	
+
 	TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result);
-	
+
 	switch (criteria) {
 		case RULE_BY_AVP_AND_PARENT:
@@ -1144,21 +1051,21 @@
 				struct dict_object * avp = NULL;
 				struct dict_rule_request * _what = (struct dict_rule_request *) what;
-				
-				CHECK_PARAMS( _what 
+
+				CHECK_PARAMS( _what
 						&& (parent = _what->rule_parent)
 						&& (avp    = _what->rule_avp   ) );
-				
-				CHECK_PARAMS( verify_object(parent) 
-						&& ((parent->type == DICT_COMMAND) 
+
+				CHECK_PARAMS( verify_object(parent)
+						&& ((parent->type == DICT_COMMAND)
 						 || ((parent->type == DICT_AVP) && (parent->data.avp.avp_basetype == AVP_TYPE_GROUPED))) );
-				
+
 				CHECK_PARAMS( verify_object(avp) && (avp->type == DICT_AVP) );
-				
+
 				/* Perform the search */
 				SEARCH_ruleavpname( avp->data.avp.avp_name, avp->datastr_len, &parent->list[2]);
-				
+
 			}
 			break;
-			
+
 		default:
 			/* Invalid criteria */
@@ -1180,5 +1087,5 @@
 {
 	struct dict_vendor_data * vendor = (struct dict_vendor_data *)data;
-	
+
 	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: %-6u \"%s\"", vendor->vendor_id, vendor->vendor_name);
 }
@@ -1191,7 +1098,7 @@
 {
 	struct dict_type_data * type = ( struct dict_type_data * ) data;
-	
-	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: %-12s \"%s\"", 
-			type_base_name[type->type_base], 
+
+	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: %-12s \"%s\"",
+			type_base_name[type->type_base],
 			type->type_name);
 }
@@ -1212,5 +1119,5 @@
 			}
 			break;
-		
+
 		case AVP_TYPE_INTEGER32:
 			CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%i", enumval->enum_value.i32), return NULL);
@@ -1236,5 +1143,5 @@
 			CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%g", enumval->enum_value.f64), return NULL);
 			break;
-		
+
 		default:
 			CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "??? (ERROR unknown type %d)", type), return NULL);
@@ -1245,9 +1152,9 @@
 {
 	struct dict_avp_data * avp = (struct dict_avp_data * ) data;
-	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: v/m:" DUMP_AVPFL_str "/" DUMP_AVPFL_str ", %12s, %-6u \"%s\"", 
-			DUMP_AVPFL_val(avp->avp_flag_val), 
-			DUMP_AVPFL_val(avp->avp_flag_mask), 
-			type_base_name[avp->avp_basetype], 
-			avp->avp_code, 
+	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: v/m:" DUMP_AVPFL_str "/" DUMP_AVPFL_str ", %12s, %-6u \"%s\"",
+			DUMP_AVPFL_val(avp->avp_flag_val),
+			DUMP_AVPFL_val(avp->avp_flag_mask),
+			type_base_name[avp->avp_basetype],
+			avp->avp_code,
 			avp->avp_name );
 }
@@ -1255,5 +1162,5 @@
 {
 	struct dict_cmd_data * cmd = (struct dict_cmd_data *) data;
-	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: v/m:" DUMP_CMDFL_str "/" DUMP_CMDFL_str ", %-6u \"%s\"", 
+	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: v/m:" DUMP_CMDFL_str "/" DUMP_CMDFL_str ", %-6u \"%s\"",
 			DUMP_CMDFL_val(cmd->cmd_flag_val), DUMP_CMDFL_val(cmd->cmd_flag_mask), cmd->cmd_code, cmd->cmd_name);
 }
@@ -1262,7 +1169,7 @@
 	struct dict_rule_data * rule = (struct dict_rule_data * )data;
 	return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: pos:%d ord:%d m/M:%2d/%2d avp:\"%s\"",
-			rule->rule_position, 
-			rule->rule_order, 
-			rule->rule_min, 
+			rule->rule_position,
+			rule->rule_order,
+			rule->rule_min,
 			rule->rule_max,
 			rule->rule_avp->data.avp.avp_name);
@@ -1291,14 +1198,14 @@
 {
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*s{dictobj}(@%p): ", indent, "", obj), return NULL);
-	
+
 	if (!verify_object(obj)) {
 		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL"), return NULL);
 		return *buf;
 	}
-	
-	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s p:%p ", 
-								_OBINFO(obj).name, 
+
+	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s p:%p ",
+								_OBINFO(obj).name,
 								obj->parent), return NULL);
-	
+
 	if (obj->type == DICT_ENUMVAL) {
 		CHECK_MALLOC_DO( dump_enumval_data ( FD_DUMP_STD_PARAMS, &obj->data.enumval, obj->parent->data.type.type_base ), return NULL);
@@ -1306,10 +1213,10 @@
 		CHECK_MALLOC_DO( _OBINFO(obj).dump_data(FD_DUMP_STD_PARAMS, &obj->data), return NULL);
 	}
-	
+
 	if (parents) {
 		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*sparent:", indent + 1, ""), return NULL);
 		CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, obj->parent, parents-1, 0, 0 ), return NULL);
 	}
-	
+
 	if (depth) {
 		int i;
@@ -1321,5 +1228,5 @@
 		}
 	}
-	
+
 	return *buf;
 }
@@ -1328,7 +1235,7 @@
 {
 	FD_DUMP_HANDLE_OFFSET();
-	
+
 	CHECK_MALLOC_DO( dump_object(FD_DUMP_STD_PARAMS, obj, 1, 2, 0), return NULL);
-	
+
 	return *buf;
 }
@@ -1338,15 +1245,15 @@
 	int i;
 	struct fd_list * li;
-	
+
 	FD_DUMP_HANDLE_OFFSET();
-		
+
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{dictionary}(@%p): ", dict), return NULL);
-	
+
 	if ((dict == NULL) || (dict->dict_eyec != DICT_EYECATCHER)) {
 		return fd_dump_extend(FD_DUMP_STD_PARAMS, "INVALID/NULL");
 	}
-	
+
 	CHECK_POSIX_DO(  pthread_rwlock_rdlock( &dict->dict_lock ), /* ignore */  );
-	
+
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): VENDORS / AVP / RULES\n", dict), goto error);
 	CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, &dict->dict_vendors, 0, 3, 3 ), goto error);
@@ -1355,5 +1262,5 @@
 		CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, li->o, 0, 3, 3 ), goto error);
 	}
-	
+
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): APPLICATIONS\n", dict), goto error);
 	CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, &dict->dict_applications, 0, 1, 3 ), goto error);
@@ -1362,18 +1269,18 @@
 		CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, li->o, 0, 1, 3 ), goto error);
 	}
-	
+
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): TYPES / ENUMVAL", dict), goto error);
 	CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &dict->dict_types, 0, 2, 3 ), goto error);
-	
+
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): COMMANDS / RULES", dict), goto error);
 	CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &dict->dict_cmd_code, 0, 0, 3 ), goto error);
-	
+
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): statistics", dict), goto error);
 	for (i=1; i<=DICT_TYPE_MAX; i++)
 		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n   %5d: %s",  dict->dict_count[i], dict_obj_info[i].name), goto error);
-	
+
 	CHECK_POSIX_DO(  pthread_rwlock_unlock( &dict->dict_lock ), /* ignore */  );
 	return *buf;
-error:	
+error:
 	/* Free the rwlock */
 	CHECK_POSIX_DO(  pthread_rwlock_unlock( &dict->dict_lock ), /* ignore */  );
@@ -1387,5 +1294,5 @@
 {
 	int i;
-	
+
 	CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "<"), return NULL);
 	for (i = 0; i < value->os.len; i++) {
@@ -1436,5 +1343,5 @@
 		case AVP_TYPE_OCTETSTRING:
 			return &dump_val_os;
-		
+
 		case AVP_TYPE_INTEGER32:
 			return &dump_val_i32;
@@ -1454,5 +1361,5 @@
 		case AVP_TYPE_FLOAT64:
 			return &dump_val_f64;
-		
+
 		case AVP_TYPE_GROUPED:
 			TRACE_DEBUG(FULL, "error: grouped AVP with a value!");
@@ -1468,11 +1375,11 @@
 
 /* Formatter for the AVP value dump line */
-static DECLARE_FD_DUMP_PROTOTYPE(dump_avp_val, union avp_value *avp_value, 
-			dump_val_cb_t def_dump_val_cb, 
-			dump_val_cb_t dump_val_cb, 
-			enum dict_avp_basetype datatype, 
-			char * type_name, 
-			char * const_name, 
-			int indent, 
+static DECLARE_FD_DUMP_PROTOTYPE(dump_avp_val, union avp_value *avp_value,
+			dump_val_cb_t def_dump_val_cb,
+			dump_val_cb_t dump_val_cb,
+			enum dict_avp_basetype datatype,
+			char * type_name,
+			char * const_name,
+			int indent,
 		        int header)
 {
@@ -1480,10 +1387,10 @@
 		/* Header for all AVP values dumps: */
 		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, INOBJHDR "value ", INOBJHDRVAL), return NULL);
-	
+
 		/* If the type is provided, write it */
 		if (type_name) {
 			CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "t: '%s' ", type_name), return NULL);
 		}
-	
+
 		/* Always give the base datatype anyway */
 		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(%s) ", type_base_name[datatype]), return NULL);
@@ -1503,5 +1410,5 @@
 		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, ")"), return NULL);
 	}
-	
+
 	/* Done! */
 	return *buf;
@@ -1515,7 +1422,7 @@
 	char * type_name = NULL;
 	char * const_name = NULL;
-	
+
 	FD_DUMP_HANDLE_OFFSET();
-	
+
 	/* Handle invalid parameters */
 	if (!avp_value) {
@@ -1528,10 +1435,10 @@
 		return *buf;
 	}
-	
+
 	if (! (	verify_object(model) && (model->type == DICT_AVP) )) {
 		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(invalid model)"), return NULL);
 		return *buf;
 	}
-	
+
 	/* Get the type definition of this AVP */
 	type = model->parent;
@@ -1539,11 +1446,11 @@
 		struct dict_enumval_request  request;
 		struct dict_object * enumval = NULL;
-		
+
 		type_name = type->data.type.type_name;
-		
+
 		/* overwrite the dump function ? */
 		if (type->data.type.type_dump)
 			dump_val_cb = type->data.type.type_dump;
-		
+
 		/* Now check if the AVP value matches a constant */
 		memset(&request, 0, sizeof(request));
@@ -1556,5 +1463,5 @@
 		}
 	}
-	
+
 	/* And finally, dump the value */
 	CHECK_MALLOC_DO( dump_avp_val(FD_DUMP_STD_PARAMS, avp_value, get_default_dump_val_cb(model->data.avp.avp_basetype), dump_val_cb, model->data.avp.avp_basetype, type_name, const_name, indent, header), return NULL );
@@ -1576,7 +1483,7 @@
 {
 	TRACE_ENTRY("%p %p", object, type);
-	
+
 	CHECK_PARAMS( type && verify_object(object) );
-	
+
 	/* Copy the value and return */
 	*type = object->type;
@@ -1587,7 +1494,7 @@
 {
 	TRACE_ENTRY("%p %p", object, dict);
-	
+
 	CHECK_PARAMS( dict && verify_object(object) );
-	
+
 	/* Copy the value and return */
 	*dict = object->dico;
@@ -1600,7 +1507,7 @@
 {
 	TRACE_ENTRY("%p %p", object, val);
-	
+
 	CHECK_PARAMS( val && verify_object(object) );
-	
+
 	/* Copy the value and return */
 	memcpy(val, &object->data, _OBINFO(object).datasize);;
@@ -1616,24 +1523,24 @@
 	struct dict_object * vendor = NULL;
 	struct dict_object * locref = NULL;
-	
+
 	TRACE_ENTRY("%p %d(%s) %p %p %p", dict, type, dict_obj_info[CHECK_TYPE(type) ? type : 0].name, data, parent, ref);
-	
+
 	/* Check parameters */
 	CHECK_PARAMS( dict && (dict->dict_eyec == DICT_EYECATCHER) && CHECK_TYPE(type) && data  );
-	
+
 	/* Check the "parent" parameter */
 	switch (dict_obj_info[type].parent) {
 		case 0:	/* parent is forbidden */
 			CHECK_PARAMS_DO( parent == NULL, goto error_param );
-		
+
 		case 1:	/* parent is optional */
 			if (parent == NULL)
 				break;
-		
+
 		case 2: /* parent is mandatory */
 			CHECK_PARAMS_DO(  verify_object(parent), goto error_param  );
-			
+
 			if (type == DICT_RULE ) { /* Special case : grouped AVP or Command parents are allowed */
-				CHECK_PARAMS_DO( (parent->type == DICT_COMMAND ) 
+				CHECK_PARAMS_DO( (parent->type == DICT_COMMAND )
 						|| ( (parent->type == DICT_AVP) && (parent->data.avp.avp_basetype == AVP_TYPE_GROUPED ) ), goto error_param );
 			} else {
@@ -1641,10 +1548,10 @@
 			}
 	}
-	
+
 	/* For AVP object, we must also check that the "vendor" referenced exists */
 	if (type == DICT_AVP) {
 		CHECK_FCT_DO(  fd_dict_search( dict, DICT_VENDOR, VENDOR_BY_ID, &(((struct dict_avp_data *)data)->avp_vendor), (void*)&vendor, ENOENT ),
 			{ TRACE_DEBUG(INFO, "Unable to find vendor '%d' referenced in the AVP data", ((struct dict_avp_data *)data)->avp_vendor); goto error_param; }  );
-		
+
 		/* Also check if a parent is provided, that the type are the same */
 		if (parent) {
@@ -1652,5 +1559,5 @@
 		}
 	}
-	
+
 	/* For RULE object, we must also check that the "avp" referenced exists */
 	if (type == DICT_RULE) {
@@ -1658,5 +1565,5 @@
 		CHECK_PARAMS_DO(  ((struct dict_rule_data *)data)->rule_avp->type == DICT_AVP, goto error_param  );
 	}
-	
+
 	/* For COMMAND object, check that the 'R' flag is fixed */
 	if (type == DICT_COMMAND) {
@@ -1669,5 +1576,5 @@
 			dupos = 1;
 	}
-	
+
 	/* We have to check that the new values are not equal to the sentinels */
 	if (type == DICT_VENDOR) {
@@ -1677,8 +1584,8 @@
 		CHECK_PARAMS_DO( ((struct dict_application_data *)data)->application_id != 0, goto error_param   );
 	}
-	
+
 	/* Parameters are valid, create the new object */
 	CHECK_MALLOC(  new = malloc(sizeof(struct dict_object))  );
-	
+
 	/* Initialize the data of the new object */
 	init_object(new, type);
@@ -1686,8 +1593,8 @@
 	new->dico = dict;
 	new->parent = parent;
-	
+
 	/* We will change the dictionary => acquire the write lock */
 	CHECK_POSIX_DO(  ret = pthread_rwlock_wrlock(&dict->dict_lock),  goto error_free  );
-	
+
 	/* Now link the object -- this also checks that no object with same keys already exists */
 	switch (type) {
@@ -1698,5 +1605,5 @@
 				goto error_unlock;
 			break;
-		
+
 		case DICT_APPLICATION:
 			/* An application object is linked in the g_dict_applciations.list[0], by their id */
@@ -1705,5 +1612,5 @@
 				goto error_unlock;
 			break;
-		
+
 		case DICT_TYPE:
 			/* A type object is linked in g_list_types by its name */
@@ -1712,5 +1619,5 @@
 				goto error_unlock;
 			break;
-		
+
 		case DICT_ENUMVAL:
 			/* A type_enum object is linked in it's parent 'type' object lists 1 and 2 by its name and values */
@@ -1718,12 +1625,12 @@
 			if (ret)
 				goto error_unlock;
-			
+
 			ret = fd_list_insert_ordered ( &parent->list[2], &new->list[1], (int (*)(void*, void *))order_enum_by_val, (void **)&locref );
-			if (ret) { 
-				fd_list_unlink(&new->list[0]); 
-				goto error_unlock; 
+			if (ret) {
+				fd_list_unlink(&new->list[0]);
+				goto error_unlock;
 			}
 			break;
-		
+
 		case DICT_AVP:
 			/* An avp object is linked in lists 1 and 2 of its vendor, by code and name */
@@ -1731,5 +1638,5 @@
 			if (ret)
 				goto error_unlock;
-			
+
 			ret = fd_list_insert_ordered ( &vendor->list[2], &new->list[1], (int (*)(void*, void *))order_avp_by_name, (void **)&locref );
 			if (ret) {
@@ -1738,5 +1645,5 @@
 			}
 			break;
-			
+
 		case DICT_COMMAND:
 			/* A command object is linked in g_list_cmd_name and g_list_cmd_code by its name and code */
@@ -1744,5 +1651,5 @@
 			if (ret)
 				goto error_unlock;
-			
+
 			ret = fd_list_insert_ordered ( &dict->dict_cmd_name, &new->list[0], (int (*)(void*, void *))order_cmd_by_name, (void **)&locref );
 			if (ret) {
@@ -1751,5 +1658,5 @@
 			}
 			break;
-		
+
 		case DICT_RULE:
 			/* A rule object is linked in list[2] of its parent command or AVP by the name of the AVP it refers */
@@ -1758,21 +1665,21 @@
 				goto error_unlock;
 			break;
-			
+
 		default:
 			ASSERT(0);
 	}
-	
+
 	/* A new object has been created, increment the global counter */
 	dict->dict_count[type]++;
-	
+
 	/* Unlock the dictionary */
 	CHECK_POSIX_DO(  ret = pthread_rwlock_unlock(&dict->dict_lock),  goto error_free  );
-	
+
 	/* Save the pointer to the new object */
 	if (ref)
 		*ref = new;
-	
+
 	return 0;
-	
+
 error_param:
 	ret = EINVAL;
@@ -1787,5 +1694,5 @@
 				TRACE_DEBUG(FULL, "Vendor %s already in dictionary", new->data.vendor.vendor_name);
 				/* if we are here, it means the two vendors id are identical */
-				if (fd_os_cmp(locref->data.vendor.vendor_name, locref->datastr_len, 
+				if (fd_os_cmp(locref->data.vendor.vendor_name, locref->datastr_len,
 						new->data.vendor.vendor_name, new->datastr_len)) {
 					TRACE_DEBUG(INFO, "Conflicting vendor name: %s", new->data.vendor.vendor_name);
@@ -1793,5 +1700,5 @@
 				}
 				/* Otherwise (same name), we consider the function succeeded, since the (same) object is in the dictionary */
-				ret = 0; 
+				ret = 0;
 				break;
 
@@ -1799,5 +1706,5 @@
 				TRACE_DEBUG(FULL, "Application %s already in dictionary", new->data.application.application_name);
 				/* got same id */
-				if (fd_os_cmp(locref->data.application.application_name, locref->datastr_len, 
+				if (fd_os_cmp(locref->data.application.application_name, locref->datastr_len,
 						new->data.application.application_name, new->datastr_len)) {
 					TRACE_DEBUG(FULL, "Conflicting application name");
@@ -1937,5 +1844,5 @@
 		char * buf = NULL;
 		size_t len = 0, offset=0;
-		
+
 		if (type == DICT_ENUMVAL) {
 			CHECK_MALLOC( dump_enumval_data ( &buf, &len, &offset, data, parent->data.type.type_base ));
@@ -1943,7 +1850,7 @@
 			CHECK_MALLOC( dict_obj_info[CHECK_TYPE(type) ? type : 0].dump_data(&buf, &len, &offset, data) );
 		}
-	
+
 		TRACE_DEBUG(INFO, "An error occurred while adding the following data in the dictionary: %s", buf);
-		
+
 		if (ret == EEXIST) {
 			offset=0;
@@ -1964,5 +1871,5 @@
 	struct dictionary * dict;
 	int ret=0;
-	
+
 	/* check params */
 	CHECK_PARAMS( verify_object(obj) && obj->dico);
@@ -1971,5 +1878,5 @@
 	/* Lock the dictionary for change */
 	CHECK_POSIX(  pthread_rwlock_wrlock(&dict->dict_lock)  );
-	
+
 	/* check the object is not sentinel for another list */
 	for (i=0; i<NB_LISTS_PER_OBJ; i++) {
@@ -1984,12 +1891,12 @@
 		}
 	}
-	
+
 	/* ok, now destroy the object */
 	if (!ret)
 		destroy_object(obj);
-	
+
 	/* Unlock */
 	CHECK_POSIX(  pthread_rwlock_unlock(&dict->dict_lock)  );
-	
+
 	return ret;
 }
@@ -1999,23 +1906,23 @@
 {
 	int ret = 0;
-	
+
 	TRACE_ENTRY("%p %d(%s) %d %p %p %d", dict, type, dict_obj_info[CHECK_TYPE(type) ? type : 0].name, criteria, what, result, retval);
-	
+
 	/* Check param */
 	CHECK_PARAMS( dict && (dict->dict_eyec == DICT_EYECATCHER) && CHECK_TYPE(type) );
-	
+
 	/* Lock the dictionary for reading */
 	CHECK_POSIX(  pthread_rwlock_rdlock(&dict->dict_lock)  );
-	
+
 	/* Now call the type-specific search function */
 	ret = dict_obj_info[type].search_fct (dict, criteria, what, result);
-	
+
 	/* Unlock */
 	CHECK_POSIX(  pthread_rwlock_unlock(&dict->dict_lock)  );
-	
+
 	/* Update the return value as needed */
 	if ((result != NULL) && (*result == NULL))
 		ret = retval;
-	
+
 	return ret;
 }
@@ -2030,12 +1937,12 @@
   }
 
-The following criteria are allowed, with corresponding parent. 
+The following criteria are allowed, with corresponding parent.
 The parent is either struct dictionary * or struct dict_object *
-		
+
 VENDOR_BY_ID : (parent = dictionary) returns list of vendors ordered by ID
 APPLICATION_BY_ID : (parent = dictionary) returns list of applications ordered by ID
-  ** for these two lists, the Vendor with id 0 and applciation with id 0 are excluded. 
+  ** for these two lists, the Vendor with id 0 and applciation with id 0 are excluded.
      You must resolve them separatly with dict_search.
-		
+
 TYPE_BY_NAME : (parent = dictionary) returns list of types ordered by name (osstring order)
 ENUMVAL_BY_NAME : (parent = type object) return list of constants for this type ordered by name (osstring order)
@@ -2053,9 +1960,9 @@
 	struct dictionary * dict = parent;
 	struct dict_object * obj_parent = parent;
-	
+
 	TRACE_ENTRY("%i %p %p", criteria, parent, sentinel);
-	
+
 	CHECK_PARAMS(sentinel && parent);
-	
+
 	switch(criteria) {
 		case VENDOR_BY_ID: /* parent must be the dictionary */
@@ -2063,57 +1970,57 @@
 			*sentinel = &dict->dict_vendors.list[0];
 			break;
-			
+
 		case APPLICATION_BY_ID: /* parent must be the dictionary */
 			CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER);
 			*sentinel = &dict->dict_applications.list[0];
 			break;
-			
+
 		case TYPE_BY_NAME: /* parent must be the dictionary */
 			CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER);
 			*sentinel = &dict->dict_types;
 			break;
-			
+
 		case ENUMVAL_BY_NAME: /* parent must be a type object */
 			CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_TYPE));
 			*sentinel = &obj_parent->list[1];
 			break;
-			
+
 		case ENUMVAL_BY_VALUE: /* parent must be a type object */
 			CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_TYPE));
 			*sentinel = &obj_parent->list[2];
 			break;
-			
+
 		case AVP_BY_NAME: /* parent must be a VENDOR object */
 			CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_VENDOR));
 			*sentinel = &obj_parent->list[2];
 			break;
-			
+
 		case AVP_BY_CODE: /* parent must be a VENDOR object */
 			CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_VENDOR));
 			*sentinel = &obj_parent->list[1];
 			break;
-			
+
 		case CMD_BY_NAME: /* parent must be the dictionary */
 			CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER);
 			*sentinel = &dict->dict_cmd_name;
 			break;
-			
+
 		case CMD_BY_CODE_R: /* parent must be the dictionary */
 			CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER);
 			*sentinel = &dict->dict_cmd_code;
 			break;
-			
+
 		case RULE_BY_AVP_AND_PARENT: /* parent must be command or grouped AVP */
 			CHECK_PARAMS(verify_object(obj_parent));
 			CHECK_PARAMS(	(obj_parent->type == DICT_COMMAND) ||
-					((obj_parent->type == DICT_AVP) 
+					((obj_parent->type == DICT_AVP)
 					  && (obj_parent->data.avp.avp_basetype == AVP_TYPE_GROUPED)) );
 			*sentinel = &obj_parent->list[2];
 			break;
-			
+
 		default:
 			CHECK_PARAMS(0);
 	}
-	
+
 	return 0;
 }
@@ -2131,21 +2038,21 @@
 {
 	struct dictionary * new = NULL;
-	
+
 	TRACE_ENTRY("%p", dict);
-	
+
 	/* Sanity checks */
 	ASSERT( (sizeof(type_base_name) / sizeof(type_base_name[0])) == (AVP_TYPE_MAX + 1) );
 	ASSERT( (sizeof(dict_obj_info)  / sizeof(dict_obj_info[0]))  == (DICT_TYPE_MAX + 1) );
 	CHECK_PARAMS(dict);
-	
+
 	/* Allocate the memory for the dictionary */
 	CHECK_MALLOC( new = malloc(sizeof(struct dictionary)) );
 	memset(new, 0, sizeof(struct dictionary));
-	
+
 	new->dict_eyec = DICT_EYECATCHER;
-	
+
 	/* Initialize the lock for the dictionary */
 	CHECK_POSIX(  pthread_rwlock_init(&new->dict_lock, NULL)  );
-	
+
 	/* Initialize the sentinel for vendors and AVP lists */
 	init_object( &new->dict_vendors, DICT_VENDOR );
@@ -2155,5 +2062,5 @@
 	/* new->dict_vendors.list[0].o = NULL; *//* overwrite since element is also sentinel for this list. */
 	new->dict_vendors.dico = new;
-	
+
 	/* Initialize the sentinel for applications */
 	init_object( &new->dict_applications, DICT_APPLICATION );
@@ -2163,12 +2070,12 @@
 	/* new->dict_applications.list[0].o = NULL; *//* overwrite since since element is also sentinel for this list. */
 	new->dict_applications.dico = new;
-			
+
 	/* Initialize the sentinel for types */
 	fd_list_init ( &new->dict_types, NULL );
-	
+
 	/* Initialize the sentinels for commands */
 	fd_list_init ( &new->dict_cmd_name, NULL );
 	fd_list_init ( &new->dict_cmd_code, NULL );
-	
+
 	/* Initialize the error command object */
 	init_object( &new->dict_cmd_error, DICT_COMMAND );
@@ -2179,7 +2086,7 @@
 	new->dict_cmd_error.data.cmd.cmd_flag_val =CMD_FLAG_ERROR;
 	new->dict_cmd_error.dico = new;
-	
+
 	*dict = new;
-	
+
 	/* Done */
 	return 0;
@@ -2190,11 +2097,11 @@
 {
 	int i;
-	
+
 	TRACE_ENTRY("");
 	CHECK_PARAMS( dict && *dict && ((*dict)->dict_eyec == DICT_EYECATCHER) );
-	
+
 	/* Acquire the write lock to make sure no other operation is ongoing */
 	CHECK_POSIX(  pthread_rwlock_wrlock(&(*dict)->dict_lock)  );
-	
+
 	/* Empty all the lists, free the elements */
 	destroy_list ( &(*dict)->dict_cmd_error.list[2] );
@@ -2206,12 +2113,12 @@
 		destroy_list ( &(*dict)->dict_vendors.list[i] );
 	}
-	
+
 	/* Dictionary is empty, now destroy the lock */
 	CHECK_POSIX(  pthread_rwlock_unlock(&(*dict)->dict_lock)  );
 	CHECK_POSIX(  pthread_rwlock_destroy(&(*dict)->dict_lock)  );
-	
+
 	free(*dict);
 	*dict = NULL;
-	
+
 	return 0;
 }
@@ -2230,20 +2137,20 @@
 	int ret = 0;
 	struct fd_list * li;
-	
+
 	TRACE_ENTRY("%p %p %p", parent, data, cb);
-	
+
 	/* Check parameters */
 	CHECK_PARAMS(  verify_object(parent)  );
-	CHECK_PARAMS(  (parent->type == DICT_COMMAND) 
+	CHECK_PARAMS(  (parent->type == DICT_COMMAND)
 			|| ((parent->type == DICT_AVP) && (parent->data.avp.avp_basetype == AVP_TYPE_GROUPED)) );
-	TRACE_DEBUG (FULL, "Iterating on rules of %s: '%s'.", 
-			_OBINFO(parent).name, 
-			parent->type == DICT_COMMAND ? 
+	TRACE_DEBUG (FULL, "Iterating on rules of %s: '%s'.",
+			_OBINFO(parent).name,
+			parent->type == DICT_COMMAND ?
 				  parent->data.cmd.cmd_name
 				: parent->data.avp.avp_name);
-	
+
 	/* Acquire the read lock  */
 	CHECK_POSIX(  pthread_rwlock_rdlock(&parent->dico->dict_lock)  );
-	
+
 	/* go through the list and call the cb on each rule data */
 	for (li = &(parent->list[2]); li->next != &(parent->list[2]); li = li->next) {
@@ -2252,8 +2159,8 @@
 			break;
 	}
-		
+
 	/* Release the lock */
 	CHECK_POSIX(  pthread_rwlock_unlock(&parent->dico->dict_lock)  );
-	
+
 	return ret;
 }
@@ -2265,13 +2172,13 @@
 	int i = 0;
 	struct fd_list * li;
-	
+
 	TRACE_ENTRY();
-	
+
 	/* Acquire the read lock */
 	CHECK_POSIX_DO(  pthread_rwlock_rdlock(&dict->dict_lock), return NULL  );
-	
+
 	/* Allocate an array to contain all the elements */
 	CHECK_MALLOC_DO( ret = calloc( dict->dict_count[DICT_VENDOR] + 1, sizeof(uint32_t) ), goto out );
-	
+
 	/* Copy the vendors IDs */
 	for (li = dict->dict_vendors.list[0].next; li != &(dict->dict_vendors.list[0]); li = li->next) {
@@ -2280,8 +2187,8 @@
 		ASSERT( i <= dict->dict_count[DICT_VENDOR] );
 	}
-out:	
+out:
 	/* Release the lock */
 	CHECK_POSIX_DO(  pthread_rwlock_unlock(&dict->dict_lock), return NULL  );
-	
+
 	return ret;
 }
