mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-13 04:27:51 -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
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "module-netjack2/packets.h"
|
||||
#include "module-netjack2/peer.c"
|
||||
#include "network-utils.h"
|
||||
|
||||
#ifndef IPTOS_DSCP
|
||||
#define IPTOS_DSCP_MASK 0xfc
|
||||
|
|
@ -689,26 +690,6 @@ on_data_io(void *data, int fd, uint32_t mask)
|
|||
}
|
||||
}
|
||||
|
||||
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 bool is_multicast(struct sockaddr *sa, socklen_t salen)
|
||||
{
|
||||
if (sa->sa_family == AF_INET) {
|
||||
|
|
@ -777,19 +758,6 @@ error:
|
|||
return res;
|
||||
}
|
||||
|
||||
static const char *get_ip(const struct sockaddr_storage *sa, char *ip, size_t len)
|
||||
{
|
||||
if (sa->ss_family == AF_INET) {
|
||||
struct sockaddr_in *in = (struct sockaddr_in*)sa;
|
||||
inet_ntop(sa->ss_family, &in->sin_addr, ip, len);
|
||||
} else if (sa->ss_family == AF_INET6) {
|
||||
struct sockaddr_in6 *in = (struct sockaddr_in6*)sa;
|
||||
inet_ntop(sa->ss_family, &in->sin6_addr, ip, len);
|
||||
} else
|
||||
snprintf(ip, len, "invalid ip");
|
||||
return ip;
|
||||
}
|
||||
|
||||
static void update_timer(struct impl *impl, uint64_t timeout)
|
||||
{
|
||||
struct timespec value, interval;
|
||||
|
|
@ -959,7 +927,7 @@ static int send_follower_available(struct impl *impl)
|
|||
|
||||
pw_loop_update_io(impl->main_loop, impl->setup_socket, SPA_IO_IN);
|
||||
|
||||
pw_log_info("sending AVAILABLE to %s", get_ip(&impl->dst_addr, buffer, sizeof(buffer)));
|
||||
pw_log_info("sending AVAILABLE to %s", get_ip_fmt(&impl->dst_addr, buffer, sizeof(buffer)));
|
||||
|
||||
client_name = pw_properties_get(impl->props, "netjack2.client-name");
|
||||
if (client_name == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue