[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] 2 commits: rtp-send: Use getaddrinfo to improve support for ipv6 on source address
PulseAudio Marge Bot (@pulseaudio-merge-bot)
gitlab at gitlab.freedesktop.org
Wed Feb 8 21:04:26 UTC 2023
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
f44cb363 by Alistair Leslie-Hughes at 2023-02-08T20:50:48+00:00
rtp-send: Use getaddrinfo to improve support for ipv6 on source address
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/774>
- - - - -
5cefef59 by Alistair Leslie-Hughes at 2023-02-08T20:50:48+00:00
rtp-recv: Use getaddrinfo to improve support for ipv6.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/774>
- - - - -
2 changed files:
- src/modules/rtp/module-rtp-recv.c
- src/modules/rtp/module-rtp-send.c
Changes:
=====================================
src/modules/rtp/module-rtp-recv.c
=====================================
@@ -29,6 +29,9 @@
#include <string.h>
#include <unistd.h>
#include <math.h>
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
#include <pulse/rtclock.h>
#include <pulse/timeval.h>
@@ -677,9 +680,13 @@ static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const str
int pa__init(pa_module*m) {
struct userdata *u;
pa_modargs *ma = NULL;
+#if defined(HAVE_GETADDRINFO)
+ struct addrinfo *sap_addrinfo = NULL;
+#else
struct sockaddr_in sa4;
#ifdef HAVE_IPV6
struct sockaddr_in6 sa6;
+#endif
#endif
struct sockaddr *sa;
socklen_t salen;
@@ -696,6 +703,27 @@ int pa__init(pa_module*m) {
sap_address = pa_modargs_get_value(ma, "sap_address", DEFAULT_SAP_ADDRESS);
+#if defined(HAVE_GETADDRINFO)
+ {
+ struct addrinfo hints;
+ char *service;
+
+ pa_zero(hints);
+
+ service = pa_sprintf_malloc("%d", htons(SAP_PORT));
+
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo(sap_address, service, &hints, &sap_addrinfo) != 0) {
+ pa_xfree(service);
+ pa_log("Invalid SAP address '%s'", sap_address);
+ goto fail;
+ }
+ pa_xfree(service);
+
+ sa = sap_addrinfo->ai_addr;
+ salen = sap_addrinfo->ai_addrlen;
+ }
+#else
if (inet_pton(AF_INET, sap_address, &sa4.sin_addr) > 0) {
sa4.sin_family = AF_INET;
sa4.sin_port = htons(SAP_PORT);
@@ -712,6 +740,7 @@ int pa__init(pa_module*m) {
pa_log("Invalid SAP address '%s'", sap_address);
goto fail;
}
+#endif
latency_msec = DEFAULT_LATENCY_MSEC;
if (pa_modargs_get_value_u32(ma, "latency_msec", &latency_msec) < 0 || latency_msec < 1 || latency_msec > 300000) {
@@ -739,9 +768,18 @@ int pa__init(pa_module*m) {
pa_modargs_free(ma);
+#if defined(HAVE_GETADDRINFO)
+ freeaddrinfo(sap_addrinfo);
+#endif
+
return 0;
fail:
+#if defined(HAVE_GETADDRINFO)
+ if (sap_addrinfo)
+ freeaddrinfo(sap_addrinfo);
+#endif
+
if (ma)
pa_modargs_free(ma);
=====================================
src/modules/rtp/module-rtp-send.c
=====================================
@@ -319,6 +319,42 @@ int pa__init(pa_module*m) {
src_addr = pa_modargs_get_value(ma, "source_ip", DEFAULT_SOURCE_IP);
+#if defined(HAVE_GETADDRINFO)
+ {
+ struct addrinfo *src_addrinfo = NULL;
+ struct addrinfo hints;
+
+ pa_zero(hints);
+
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo(src_addr, NULL, &hints, &src_addrinfo) != 0) {
+ pa_log("Invalid source '%s'", src_addr);
+ goto fail;
+ }
+
+ af = src_addrinfo->ai_family;
+ if (af == AF_INET) {
+ memcpy(&src_sa4, src_addrinfo->ai_addr, src_addrinfo->ai_addrlen);
+ src_sa4.sin_port = htons(0);
+ src_sap_sa4 = src_sa4;
+ }
+#ifdef HAVE_IPV6
+ else if (af == AF_INET6) {
+ memcpy(&src_sa6, src_addrinfo->ai_addr, src_addrinfo->ai_addrlen);
+ src_sa6.sin6_port = htons(0);
+ src_sap_sa6 = src_sa6;
+ }
+#endif
+ else
+ {
+ freeaddrinfo(src_addrinfo);
+ pa_log("Invalid source '%s'", src_addr);
+ goto fail;
+ }
+
+ freeaddrinfo(src_addrinfo);
+ }
+#else
if (inet_pton(AF_INET, src_addr, &src_sa4.sin_addr) > 0) {
src_sa4.sin_family = af = AF_INET;
src_sa4.sin_port = htons(0);
@@ -336,6 +372,7 @@ int pa__init(pa_module*m) {
pa_log("Invalid source address '%s'", src_addr);
goto fail;
}
+#endif /* HAVE_GETADDRINFO */
dst_addr = pa_modargs_get_value(ma, "destination", NULL);
if (dst_addr == NULL)
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/1cfa7378236b3cf9daf3be09d3227b92df69cc53...5cefef591ef6c0fd1c514202b0fcfbe466cab873
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/1cfa7378236b3cf9daf3be09d3227b92df69cc53...5cefef591ef6c0fd1c514202b0fcfbe466cab873
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20230208/2e51e1e6/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list