comparison libfdcore/messages.c @ 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 e72c9dad62ac
children 25fad6714991
comparison
equal deleted inserted replaced
1249:4ad4d614acfa 1250:446683efbb1f
236 236
237 /* Now add the optavp in a FailedAVP if provided */ 237 /* Now add the optavp in a FailedAVP if provided */
238 if (optavp) { 238 if (optavp) {
239 struct avp * optavp_cpy = NULL; 239 struct avp * optavp_cpy = NULL;
240 struct avp_hdr *opt_hdr, *optcpy_hdr; 240 struct avp_hdr *opt_hdr, *optcpy_hdr;
241 struct dict_object * opt_model = NULL;
242 int is_grouped = 0;
241 243
242 /* Create the Failed-AVP AVP */ 244 /* Create the Failed-AVP AVP */
243 CHECK_FCT( fd_msg_avp_new( dict_avp_FAVP, 0, &avp_FAVP ) ); 245 CHECK_FCT( fd_msg_avp_new( dict_avp_FAVP, 0, &avp_FAVP ) );
244 246
247 /* Was this AVP a grouped one? Best effort only here */
248 if (!fd_msg_model ( optavp, &opt_model ) && (opt_model != NULL)) {
249 struct dict_avp_data dictdata;
250 CHECK_FCT( fd_dict_getval(opt_model, &dictdata) );
251 if (dictdata.avp_basetype == AVP_TYPE_GROUPED)
252 is_grouped = 1;
253 }
254
245 /* Create a new AVP with a copy of the data of the invalid or missing AVP */ 255 /* Create a new AVP with a copy of the data of the invalid or missing AVP */
246 optavp_cpy = optavp; 256 optavp_cpy = optavp;
247 CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE | AVPFL_SET_RAWDATA_FROM_AVP, &optavp_cpy) ); 257
248 258 if (is_grouped) {
249 CHECK_FCT( fd_msg_avp_hdr(optavp, &opt_hdr) ); 259 CHECK_FCT( fd_msg_avp_new( opt_model, 0, &optavp_cpy) );
250 CHECK_FCT( fd_msg_avp_hdr(optavp_cpy, &optcpy_hdr) ); 260 } else {
251 memcpy(optcpy_hdr, opt_hdr, sizeof(struct avp_hdr)); 261 CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE | AVPFL_SET_RAWDATA_FROM_AVP, &optavp_cpy) );
262
263 CHECK_FCT( fd_msg_avp_hdr(optavp, &opt_hdr) );
264 CHECK_FCT( fd_msg_avp_hdr(optavp_cpy, &optcpy_hdr) );
265 memcpy(optcpy_hdr, opt_hdr, sizeof(struct avp_hdr));
266 }
252 267
253 /* Add the passed AVP inside it */ 268 /* Add the passed AVP inside it */
254 CHECK_FCT( fd_msg_avp_add( avp_FAVP, MSG_BRW_LAST_CHILD, optavp_cpy ) ); 269 CHECK_FCT( fd_msg_avp_add( avp_FAVP, MSG_BRW_LAST_CHILD, optavp_cpy ) );
255 270
256 /* And add to the message */ 271 /* And add to the message */
"Welcome to our mercurial repository"