Mercurial > hg > freeDiameter
changeset 1250:446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sun, 12 Jan 2014 23:01:21 +0800 |
parents | 4ad4d614acfa |
children | bdd7bf840c8d 3734341ad03b |
files | libfdcore/messages.c |
diffstat | 1 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libfdcore/messages.c Mon Dec 16 15:55:36 2013 +0100 +++ b/libfdcore/messages.c Sun Jan 12 23:01:21 2014 +0800 @@ -238,17 +238,32 @@ if (optavp) { struct avp * optavp_cpy = NULL; struct avp_hdr *opt_hdr, *optcpy_hdr; + struct dict_object * opt_model = NULL; + int is_grouped = 0; /* Create the Failed-AVP AVP */ CHECK_FCT( fd_msg_avp_new( dict_avp_FAVP, 0, &avp_FAVP ) ); + /* Was this AVP a grouped one? Best effort only here */ + if (!fd_msg_model ( optavp, &opt_model ) && (opt_model != NULL)) { + struct dict_avp_data dictdata; + CHECK_FCT( fd_dict_getval(opt_model, &dictdata) ); + if (dictdata.avp_basetype == AVP_TYPE_GROUPED) + is_grouped = 1; + } + /* Create a new AVP with a copy of the data of the invalid or missing AVP */ optavp_cpy = optavp; - CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE | AVPFL_SET_RAWDATA_FROM_AVP, &optavp_cpy) ); - CHECK_FCT( fd_msg_avp_hdr(optavp, &opt_hdr) ); - CHECK_FCT( fd_msg_avp_hdr(optavp_cpy, &optcpy_hdr) ); - memcpy(optcpy_hdr, opt_hdr, sizeof(struct avp_hdr)); + if (is_grouped) { + CHECK_FCT( fd_msg_avp_new( opt_model, 0, &optavp_cpy) ); + } else { + CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE | AVPFL_SET_RAWDATA_FROM_AVP, &optavp_cpy) ); + + CHECK_FCT( fd_msg_avp_hdr(optavp, &opt_hdr) ); + CHECK_FCT( fd_msg_avp_hdr(optavp_cpy, &optcpy_hdr) ); + memcpy(optcpy_hdr, opt_hdr, sizeof(struct avp_hdr)); + } /* Add the passed AVP inside it */ CHECK_FCT( fd_msg_avp_add( avp_FAVP, MSG_BRW_LAST_CHILD, optavp_cpy ) );