[Asterisk-code-review] chan_rtp: Accept hostname as well as ip address as destination (...asterisk[16])
George Joseph
asteriskteam at digium.com
Thu Aug 22 19:01:51 CDT 2019
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/12769 )
Change subject: chan_rtp: Accept hostname as well as ip address as destination
......................................................................
chan_rtp: Accept hostname as well as ip address as destination
The UnicastRTP channel driver provided by chan_rtp now accepts
"<hostname>:<port>" as an alternative to "<ip_address>:<port>"
in the destination. The first AAAA (preferred) or A record resolved
will be used as the destination. The lookup is synchronous so beware
of possible dialplan delays if you specify a hostname.
Change-Id: Ie6f95b983a8792bf0dacc64c7953a41032dba677
---
M channels/chan_rtp.c
A doc/CHANGES-staging/chan_rtp.txt
2 files changed, 24 insertions(+), 2 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/channels/chan_rtp.c b/channels/chan_rtp.c
index 7d9e26d..d8f7324 100644
--- a/channels/chan_rtp.c
+++ b/channels/chan_rtp.c
@@ -43,6 +43,7 @@
#include "asterisk/causes.h"
#include "asterisk/format_cache.h"
#include "asterisk/multicast_rtp.h"
+#include "asterisk/dns_core.h"
/* Forward declarations */
static struct ast_channel *multicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause);
@@ -293,9 +294,23 @@
ast_log(LOG_ERROR, "Destination is required for the 'UnicastRTP' channel\n");
goto failure;
}
+
if (!ast_sockaddr_parse(&address, args.destination, PARSE_PORT_REQUIRE)) {
- ast_log(LOG_ERROR, "Destination '%s' could not be parsed\n", args.destination);
- goto failure;
+ int rc;
+ char *host;
+ char *port;
+
+ rc = ast_sockaddr_split_hostport(args.destination, &host, &port, PARSE_PORT_REQUIRE);
+ if (!rc) {
+ ast_log(LOG_ERROR, "Unable to parse destination '%s' into host and port\n", args.destination);
+ goto failure;
+ }
+
+ rc = ast_dns_resolve_ipv6_and_ipv4(&address, host, port);
+ if (rc != 0) {
+ ast_log(LOG_ERROR, "Unable to resolve host '%s'\n", host);
+ goto failure;
+ }
}
if (!ast_strlen_zero(args.options)
diff --git a/doc/CHANGES-staging/chan_rtp.txt b/doc/CHANGES-staging/chan_rtp.txt
new file mode 100644
index 0000000..ce908ee
--- /dev/null
+++ b/doc/CHANGES-staging/chan_rtp.txt
@@ -0,0 +1,7 @@
+Subject: chan_rtp
+
+The UnicastRTP channel driver provided by chan_rtp now accepts
+"<hostname>:<port>" as an alternative to "<ip_address>:<port>" in the destination.
+The first AAAA (preferred) or A record resolved will be used as the destination.
+The lookup is synchronous so beware of possible dialplan delays if you specify a
+hostname.
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/12769
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ie6f95b983a8792bf0dacc64c7953a41032dba677
Gerrit-Change-Number: 12769
Gerrit-PatchSet: 4
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190822/af2bad67/attachment-0001.html>
More information about the asterisk-code-review
mailing list