Browse code

rtpengine: extract call-id/from-tag/to-tag only from sip messages

- they can be provided via flags in function parameters
- fix using functions in non-sip routing blocks (e.g., xhttp processing)

(cherry picked from commit 0a2450e62d77020243530e18d93c9aa8181a5701)

Daniel-Constantin Mierla authored on 30/04/2021 06:31:34
Showing 1 changed files
... ...
@@ -2477,17 +2477,19 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
2477 2477
 
2478 2478
 	memset(&ng_flags, 0, sizeof(ng_flags));
2479 2479
 
2480
-	if (get_callid(msg, &ng_flags.call_id) == -1 || ng_flags.call_id.len == 0) {
2481
-		LM_ERR("can't get Call-Id field\n");
2482
-		return NULL;
2483
-	}
2484
-	if (get_to_tag(msg, &ng_flags.to_tag) == -1) {
2485
-		LM_ERR("can't get To tag\n");
2486
-		return NULL;
2487
-	}
2488
-	if (get_from_tag(msg, &ng_flags.from_tag) == -1 || ng_flags.from_tag.len == 0) {
2489
-		LM_ERR("can't get From tag\n");
2490
-		return NULL;
2480
+	if(IS_SIP(msg) || IS_SIP_REPLY(msg)) {
2481
+		if (get_callid(msg, &ng_flags.call_id) == -1 || ng_flags.call_id.len == 0) {
2482
+			LM_ERR("can't get Call-Id field\n");
2483
+			return NULL;
2484
+		}
2485
+		if (get_to_tag(msg, &ng_flags.to_tag) == -1) {
2486
+			LM_ERR("can't get To tag\n");
2487
+			return NULL;
2488
+		}
2489
+		if (get_from_tag(msg, &ng_flags.from_tag) == -1 || ng_flags.from_tag.len == 0) {
2490
+			LM_ERR("can't get From tag\n");
2491
+			return NULL;
2492
+		}
2491 2493
 	}
2492 2494
 	if (bencode_buffer_init(bencbuf)) {
2493 2495
 		LM_ERR("could not initialize bencode_buffer_t\n");
... ...
@@ -2535,6 +2537,18 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
2535 2537
 	if (parse_flags(&ng_flags, msg, &op, flags_str))
2536 2538
 		goto error;
2537 2539
 
2540
+	if(!IS_SIP(msg) && !IS_SIP_REPLY(msg)) {
2541
+		/* check required values */
2542
+		if (ng_flags.call_id.len == 0) {
2543
+			LM_ERR("can't get Call-Id field\n");
2544
+			return NULL;
2545
+		}
2546
+		if (ng_flags.from_tag.len == 0) {
2547
+			LM_ERR("can't get From tag\n");
2548
+			return NULL;
2549
+		}
2550
+	}
2551
+
2538 2552
 	/* trickle ice sdp fragment? */
2539 2553
 	if (cont_type == 3)
2540 2554
 		bencode_list_add_string(ng_flags.flags, "fragment");