mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
Support IPv6 link-local addresses
Use `getaddrinfo` in `parse_address` instead of `inet_pton`. Display Ipv6 addresses with scope identifiers correctly in `get_ip` functions using `if_indextoname`.
This commit is contained in:
parent
c3d3e6f48b
commit
4888b35284
9 changed files with 107 additions and 275 deletions
|
|
@ -30,6 +30,7 @@
|
|||
#include <pipewire/impl.h>
|
||||
|
||||
#include <module-vban/stream.h>
|
||||
#include "network-utils.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define ifr_ifindex ifr_index
|
||||
|
|
@ -189,26 +190,6 @@ short_packet:
|
|||
return;
|
||||
}
|
||||
|
||||
static int parse_address(const char *address, uint16_t port,
|
||||
struct sockaddr_storage *addr, socklen_t *len)
|
||||
{
|
||||
struct sockaddr_in *sa4 = (struct sockaddr_in*)addr;
|
||||
struct sockaddr_in6 *sa6 = (struct sockaddr_in6*)addr;
|
||||
|
||||
if (inet_pton(AF_INET, address, &sa4->sin_addr) > 0) {
|
||||
sa4->sin_family = AF_INET;
|
||||
sa4->sin_port = htons(port);
|
||||
*len = sizeof(*sa4);
|
||||
} else if (inet_pton(AF_INET6, address, &sa6->sin6_addr) > 0) {
|
||||
sa6->sin6_family = AF_INET6;
|
||||
sa6->sin6_port = htons(port);
|
||||
*len = sizeof(*sa6);
|
||||
} else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int make_socket(const struct sockaddr* sa, socklen_t salen, char *ifname)
|
||||
{
|
||||
int af, fd, val, res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue