From b4b70502d420e626192e6d8c51b3647b76e0557a Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 11 May 2014 17:16:27 +0200 Subject: [PATCH] SAT>IP: Fix the --satip_xml parameter (local IP address) --- src/input/mpegts/satip/satip.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/input/mpegts/satip/satip.c b/src/input/mpegts/satip/satip.c index 313ed747..7d53fbdb 100644 --- a/src/input/mpegts/satip/satip.c +++ b/src/input/mpegts/satip/satip.c @@ -562,6 +562,19 @@ satip_discovery_http_closed(http_client_t *hc, int errn) tvhlog_hexdump("satip", hc->hc_data, hc->hc_data_size); #endif + if (d->myaddr == NULL || d->myaddr[0] == '\0') { + struct sockaddr_storage ip; + socklen_t addrlen = sizeof(ip); + errbuf[0] = '\0'; + getsockname(hc->hc_fd, (struct sockaddr *)&ip, &addrlen); + if (ip.ss_family == AF_INET6) + inet_ntop(AF_INET6, &IP_AS_V6(ip, addr), errbuf, sizeof(errbuf)); + else + inet_ntop(AF_INET, &IP_AS_V4(ip, addr), errbuf, sizeof(errbuf)); + free(d->myaddr); + d->myaddr = strdup(errbuf); + } + s = hc->hc_data + hc->hc_data_size - 1; while (s != hc->hc_data && *s != '/') s--; @@ -828,7 +841,7 @@ satip_discovery_static(const char *descurl) satip_discovery_destroy(d, 0); return; } - d->myaddr = strdup(d->url.host); + d->myaddr = strdup(""); d->location = strdup(descurl); d->server = strdup(""); d->uuid = strdup("");