Package: asterisk / 1:13.14.1~dfsg-2+deb9u4

859911-pjsip-set-rtp-source-address.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 139bc3495f8f46201b4aac6c84a5f0d04822f9da Mon Sep 17 00:00:00 2001
From: Richard Begg <asterisk@meric.id.au>
Date: Wed, 15 Mar 2017 08:22:42 +1100
Subject: [PATCH] res_pjsip_sdp_rtp: RTP instance does not use same IP as
 explicit transport

Currently a wildcard address is used for the local RTP socket, which
will not always result in the same address as used by the SIP socket
(e.g. if explicit transport addresses are configured).
Use the transport's host address when binding new local RTP sockets if
available.

ASTERISK-26851

Change-Id: I098c29c9d1f79a4f970d72ba894874ac75954f1a
---
 res/res_pjsip_sdp_rtp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index b27050ed86..2b31d146ea 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -179,6 +179,20 @@ static int create_rtp(struct ast_sip_session *session, struct ast_sip_session_me
 	if (session->endpoint->media.bind_rtp_to_media_address && !ast_strlen_zero(session->endpoint->media.address)) {
 		ast_sockaddr_parse(&temp_media_address, session->endpoint->media.address, 0);
 		media_address = &temp_media_address;
+	} else {
+		struct ast_sip_transport *transport =
+			ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
+									   session->endpoint->transport);
+
+		if (transport && transport->state) {
+			char hoststr[PJ_INET6_ADDRSTRLEN];
+
+			pj_sockaddr_print(&transport->state->host, hoststr, sizeof(hoststr), 0);
+			ast_debug(1, "Transport: %s bound to host: %s, using this for media.\n",
+					  session->endpoint->transport, hoststr);
+			ast_sockaddr_parse(media_address, hoststr, 0);
+		}
+		ao2_cleanup(transport);
 	}
 
 	if (!(session_media->rtp = ast_rtp_instance_new(session->endpoint->media.rtp.engine, sched, media_address, NULL))) {
-- 
2.11.0