Browse code

sipt: use helper function to check for valid ISUP/ACM/CPG

Henning Westerholt authored on 14/09/2021 15:39:57
Showing 1 changed files
... ...
@@ -264,6 +264,25 @@ static inline int sipt_check_IAM(struct sip_msg *msg, str *body)
264 264
 	return 1;
265 265
 }
266 266
 
267
+static inline int sipt_check_ACM_CPG(struct sip_msg *msg, str *body)
268
+{
269
+	body->s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP, &body->len);
270
+
271
+	if(body->s == NULL)
272
+	{
273
+		LM_INFO("No ISUP Message Found");
274
+		return -1;
275
+	}
276
+
277
+	if((body->s[0] != ISUP_ACM) && (body->s[0] != ISUP_CPG))
278
+	{
279
+		LM_DBG("message not an ACM or CPG\n");
280
+		return -1;
281
+	}
282
+	return 1;
283
+}
284
+
285
+
267 286
 static int sipt_get_hop_counter(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
268 287
 {
269 288
 	str body;
... ...
@@ -353,17 +372,9 @@ static int sipt_get_calling_party(struct sip_msg *msg, pv_param_t *param, pv_val
353 372
 static int sipt_get_redirection_info(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
354 373
 {
355 374
 	str body;
356
-	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
357
-
358
-	if(body.s == NULL)
359
-	{
360
-		LM_INFO("No ISUP Message Found");
361
-		return -1;
362
-	}
363
-
364
-	if((body.s[0] != ISUP_ACM) && (body.s[0] != ISUP_CPG))
375
+	if(sipt_check_ACM_CPG(msg, &body) != 1)
365 376
 	{
366
-		LM_DBG("message not an ACM or CPG\n");
377
+		LM_INFO("could not check ACM or CPG\n");
367 378
 		return -1;
368 379
 	}
369 380
 	
... ...
@@ -374,17 +385,9 @@ static int sipt_get_redirection_info(struct sip_msg *msg, pv_param_t *param, pv_
374 385
 static int sipt_get_redirection_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
375 386
 {
376 387
 	str body;
377
-	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
378
-
379
-	if(body.s == NULL)
380
-	{
381
-		LM_INFO("No ISUP Message Found");
382
-		return -1;
383
-	}
384
-
385
-	if((body.s[0] != ISUP_ACM) && (body.s[0] != ISUP_CPG))
388
+	if(sipt_check_ACM_CPG(msg, &body) != 1)
386 389
 	{
387
-		LM_DBG("message not an ACM or CPG\n");
390
+		LM_INFO("could not check ACM or CPG\n");
388 391
 		return -1;
389 392
 	}
390 393
 	
... ...
@@ -396,18 +399,10 @@ static int sipt_get_redirection_number(struct sip_msg *msg, pv_param_t *param, p
396 399
 {
397 400
 	static char sb_s_buf[26];
398 401
 	str body;
399
-	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
400
-
401 402
 	memset(sb_s_buf, 0, 26);
402
-	if(body.s == NULL)
403
+	if(sipt_check_ACM_CPG(msg, &body) != 1)
403 404
 	{
404
-		LM_INFO("No ISUP Message Found");
405
-		return -1;
406
-	}
407
-
408
-	if((body.s[0] != ISUP_ACM) && (body.s[0] != ISUP_CPG))
409
-	{
410
-		LM_DBG("message not an ACM or CPG\n");
405
+		LM_INFO("could not check ACM or CPG\n");
411 406
 		return -1;
412 407
 	}
413 408