# HG changeset patch # User Sebastien Decugis # Date 1353189170 -3600 # Node ID 4a299daed8b22228f4a758d9f3a2fdb99b49727b # Parent 63931db83e96554c3e10c7e70c9402b70d075a81 Add information about parsing errors diff -r 63931db83e96 -r 4a299daed8b2 libfdproto/messages.c --- a/libfdproto/messages.c Sat Nov 17 22:52:09 2012 +0100 +++ b/libfdproto/messages.c Sat Nov 17 22:52:50 2012 +0100 @@ -1685,6 +1685,8 @@ static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info); +static char error_message[256]; + /* Process an AVP. If we are not in recheck, the avp_source must be set. */ static int parsedict_do_avp(struct dictionary * dict, struct avp * avp, int mandatory, struct fd_pei *error_info) { @@ -1768,10 +1770,13 @@ /* Check the size is valid */ if ((avp_value_sizes[dictdata.avp_basetype] != 0) && (avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ) != avp_value_sizes[dictdata.avp_basetype])) { - TRACE_DEBUG(INFO, "The AVP size is not suitable for the type."); + TRACE_DEBUG(INFO, "The AVP size is not suitable for the type:"); + fd_msg_dump_one(INFO, avp); if (error_info) { error_info->pei_errcode = "DIAMETER_INVALID_AVP_LENGTH"; error_info->pei_avp = avp; + snprintf(error_message, sizeof(error_message), "I expected a size of %d for this AVP according to my dictionary", avp_value_sizes[dictdata.avp_basetype]); + error_info->pei_message = error_message; } return EBADMSG; } @@ -1787,6 +1792,8 @@ if ((ret == EBADMSG) && (error_info)) { error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE"; error_info->pei_avp = avp; + snprintf(error_message, sizeof(error_message), "I cannot parse this AVP as a Grouped AVP"); + error_info->pei_message = error_message; } return ret; } );