Mercurial > hg > freeDiameter
comparison libfdproto/messages.c @ 889:4a299daed8b2
Add information about parsing errors
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sat, 17 Nov 2012 22:52:50 +0100 |
parents | 254d81d21d0b |
children | 9432ac55823c |
comparison
equal
deleted
inserted
replaced
888:63931db83e96 | 889:4a299daed8b2 |
---|---|
1683 * For command, if the dictionary model is not found, an error is returned. | 1683 * For command, if the dictionary model is not found, an error is returned. |
1684 */ | 1684 */ |
1685 | 1685 |
1686 static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info); | 1686 static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info); |
1687 | 1687 |
1688 static char error_message[256]; | |
1689 | |
1688 /* Process an AVP. If we are not in recheck, the avp_source must be set. */ | 1690 /* Process an AVP. If we are not in recheck, the avp_source must be set. */ |
1689 static int parsedict_do_avp(struct dictionary * dict, struct avp * avp, int mandatory, struct fd_pei *error_info) | 1691 static int parsedict_do_avp(struct dictionary * dict, struct avp * avp, int mandatory, struct fd_pei *error_info) |
1690 { | 1692 { |
1691 struct dict_avp_data dictdata; | 1693 struct dict_avp_data dictdata; |
1692 | 1694 |
1766 ASSERT(CHECK_BASETYPE(dictdata.avp_basetype)); | 1768 ASSERT(CHECK_BASETYPE(dictdata.avp_basetype)); |
1767 | 1769 |
1768 /* Check the size is valid */ | 1770 /* Check the size is valid */ |
1769 if ((avp_value_sizes[dictdata.avp_basetype] != 0) && | 1771 if ((avp_value_sizes[dictdata.avp_basetype] != 0) && |
1770 (avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ) != avp_value_sizes[dictdata.avp_basetype])) { | 1772 (avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ) != avp_value_sizes[dictdata.avp_basetype])) { |
1771 TRACE_DEBUG(INFO, "The AVP size is not suitable for the type."); | 1773 TRACE_DEBUG(INFO, "The AVP size is not suitable for the type:"); |
1774 fd_msg_dump_one(INFO, avp); | |
1772 if (error_info) { | 1775 if (error_info) { |
1773 error_info->pei_errcode = "DIAMETER_INVALID_AVP_LENGTH"; | 1776 error_info->pei_errcode = "DIAMETER_INVALID_AVP_LENGTH"; |
1774 error_info->pei_avp = avp; | 1777 error_info->pei_avp = avp; |
1778 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]); | |
1779 error_info->pei_message = error_message; | |
1775 } | 1780 } |
1776 return EBADMSG; | 1781 return EBADMSG; |
1777 } | 1782 } |
1778 | 1783 |
1779 /* Now get the value inside */ | 1784 /* Now get the value inside */ |
1785 CHECK_FCT_DO( ret = parsebuf_list(avp->avp_source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ), &avp->avp_chain.children), | 1790 CHECK_FCT_DO( ret = parsebuf_list(avp->avp_source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ), &avp->avp_chain.children), |
1786 { | 1791 { |
1787 if ((ret == EBADMSG) && (error_info)) { | 1792 if ((ret == EBADMSG) && (error_info)) { |
1788 error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE"; | 1793 error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE"; |
1789 error_info->pei_avp = avp; | 1794 error_info->pei_avp = avp; |
1795 snprintf(error_message, sizeof(error_message), "I cannot parse this AVP as a Grouped AVP"); | |
1796 error_info->pei_message = error_message; | |
1790 } | 1797 } |
1791 return ret; | 1798 return ret; |
1792 } ); | 1799 } ); |
1793 | 1800 |
1794 return parsedict_do_chain(dict, &avp->avp_chain.children, mandatory && (avp->avp_public.avp_flags & AVP_FLAG_MANDATORY), error_info); | 1801 return parsedict_do_chain(dict, &avp->avp_chain.children, mandatory && (avp->avp_public.avp_flags & AVP_FLAG_MANDATORY), error_info); |