Browse code

tm: use internal function tm_xdata_swap instead of manually copy X/AVPs

Henning Westerholt authored on 09/08/2022 13:52:42
Showing 1 changed files
... ...
@@ -226,27 +226,10 @@ void run_trans_callbacks_internal(struct tmcb_head_list* cb_lst, int type,
226 226
 									struct cell *trans,
227 227
 									struct tmcb_params *params)
228 228
 {
229
-	struct tm_callback    *cbp;
230
-	avp_list_t* backup_from, *backup_to, *backup_dom_from, *backup_dom_to, *backup_uri_from, *backup_uri_to;
231
-	sr_xavp_t **backup_xavps;
232
-	sr_xavp_t **backup_xavus;
233
-	sr_xavp_t **backup_xavis;
234
-
235
-	backup_uri_from = set_avp_list(AVP_CLASS_URI | AVP_TRACK_FROM,
236
-			&trans->uri_avps_from );
237
-	backup_uri_to = set_avp_list(AVP_CLASS_URI | AVP_TRACK_TO,
238
-			&trans->uri_avps_to );
239
-	backup_from = set_avp_list(AVP_CLASS_USER | AVP_TRACK_FROM,
240
-			&trans->user_avps_from );
241
-	backup_to = set_avp_list(AVP_CLASS_USER | AVP_TRACK_TO,
242
-			&trans->user_avps_to );
243
-	backup_dom_from = set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_FROM,
244
-			&trans->domain_avps_from);
245
-	backup_dom_to = set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_TO,
246
-			&trans->domain_avps_to);
247
-	backup_xavps = xavp_set_list(&trans->xavps_list);
248
-	backup_xavus = xavu_set_list(&trans->xavus_list);
249
-	backup_xavis = xavi_set_list(&trans->xavis_list);
229
+	struct tm_callback *cbp;
230
+	tm_xlinks_t backup_xd;
231
+
232
+	tm_xdata_swap(trans, &backup_xd, 0);
250 233
 
251 234
 	cbp=(struct tm_callback*)cb_lst->first;
252 235
 	while(cbp){
... ...
@@ -259,15 +242,8 @@ void run_trans_callbacks_internal(struct tmcb_head_list* cb_lst, int type,
259 242
 		}
260 243
 		cbp=cbp->next;
261 244
 	}
262
-	set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_TO, backup_dom_to );
263
-	set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_FROM, backup_dom_from );
264
-	set_avp_list(AVP_CLASS_USER | AVP_TRACK_TO, backup_to );
265
-	set_avp_list(AVP_CLASS_USER | AVP_TRACK_FROM, backup_from );
266
-	set_avp_list(AVP_CLASS_URI | AVP_TRACK_TO, backup_uri_to );
267
-	set_avp_list(AVP_CLASS_URI | AVP_TRACK_FROM, backup_uri_from );
268
-	xavp_set_list(backup_xavps);
269
-	xavu_set_list(backup_xavus);
270
-	xavi_set_list(backup_xavis);
245
+
246
+	tm_xdata_swap(trans, &backup_xd, 1);
271 247
 }
272 248
 
273 249
 
... ...
@@ -319,44 +295,21 @@ void run_trans_callbacks_off_params(int type, struct cell* trans,
319 295
 static void run_reqin_callbacks_internal(struct tmcb_head_list* hl,
320 296
 							struct cell *trans, struct tmcb_params* params)
321 297
 {
322
-	struct tm_callback    *cbp;
323
-	avp_list_t* backup_from, *backup_to, *backup_dom_from, *backup_dom_to,
324
-				*backup_uri_from, *backup_uri_to;
325
-	sr_xavp_t **backup_xavps;
326
-	sr_xavp_t **backup_xavus;
327
-	sr_xavp_t **backup_xavis;
298
+	struct tm_callback *cbp;
299
+	tm_xlinks_t backup_xd;
328 300
 
329 301
 	if (hl==0 || hl->first==0) return;
330
-	backup_uri_from = set_avp_list(AVP_CLASS_URI | AVP_TRACK_FROM,
331
-			&trans->uri_avps_from );
332
-	backup_uri_to = set_avp_list(AVP_CLASS_URI | AVP_TRACK_TO,
333
-			&trans->uri_avps_to );
334
-	backup_from = set_avp_list(AVP_CLASS_USER | AVP_TRACK_FROM,
335
-			&trans->user_avps_from );
336
-	backup_to = set_avp_list(AVP_CLASS_USER | AVP_TRACK_TO,
337
-			&trans->user_avps_to );
338
-	backup_dom_from = set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_FROM,
339
-			&trans->domain_avps_from);
340
-	backup_dom_to = set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_TO,
341
-			&trans->domain_avps_to);
342
-	backup_xavps = xavp_set_list(&trans->xavps_list);
343
-	backup_xavus = xavu_set_list(&trans->xavus_list);
344
-	backup_xavis = xavi_set_list(&trans->xavis_list);
302
+
303
+	tm_xdata_swap(trans, &backup_xd, 0);
304
+
345 305
 	for (cbp=(struct tm_callback*)hl->first; cbp; cbp=cbp->next)  {
346 306
 		LM_DBG("trans=%p, callback type %d, id %d entered\n",
347 307
 			trans, cbp->types, cbp->id );
348 308
 		params->param = &(cbp->param);
349 309
 		cbp->callback( trans, cbp->types, params );
350 310
 	}
351
-	set_avp_list(AVP_CLASS_URI | AVP_TRACK_TO, backup_uri_to );
352
-	set_avp_list(AVP_CLASS_URI | AVP_TRACK_FROM, backup_uri_from );
353
-	set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_TO, backup_dom_to );
354
-	set_avp_list(AVP_CLASS_DOMAIN | AVP_TRACK_FROM, backup_dom_from );
355
-	set_avp_list(AVP_CLASS_USER | AVP_TRACK_TO, backup_to );
356
-	set_avp_list(AVP_CLASS_USER | AVP_TRACK_FROM, backup_from );
357
-	xavp_set_list(backup_xavps);
358
-	xavu_set_list(backup_xavus);
359
-	xavi_set_list(backup_xavis);
311
+
312
+	tm_xdata_swap(trans, &backup_xd, 1);
360 313
 }
361 314
 
362 315