mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
modules: prefix network-utils methods with pw_net
This commit is contained in:
parent
4888b35284
commit
c0966f026a
9 changed files with 44 additions and 46 deletions
|
|
@ -927,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_fmt(&impl->dst_addr, buffer, sizeof(buffer)));
|
||||
pw_log_info("sending AVAILABLE to %s", pw_net_get_ip_fmt(&impl->dst_addr, buffer, sizeof(buffer)));
|
||||
|
||||
client_name = pw_properties_get(impl->props, "netjack2.client-name");
|
||||
if (client_name == NULL)
|
||||
|
|
@ -964,11 +964,11 @@ static int create_netjack2_socket(struct impl *impl)
|
|||
port = DEFAULT_NET_PORT;
|
||||
if ((str = pw_properties_get(impl->props, "net.ip")) == NULL)
|
||||
str = DEFAULT_NET_IP;
|
||||
if ((res = parse_address(str, port, &impl->dst_addr, &impl->dst_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, port, &impl->dst_addr, &impl->dst_len)) < 0) {
|
||||
pw_log_error("invalid net.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
if ((res = parse_address("0.0.0.0", 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
if ((res = pw_net_parse_address("0.0.0.0", 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
pw_log_error("invalid source.ip: %s", spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1006,7 +1006,8 @@ static int handle_follower_available(struct impl *impl, struct nj2_session_param
|
|||
|
||||
nj2_session_params_hton(params, &peer->params);
|
||||
params->packet_id = htonl(NJ2_ID_FOLLOWER_SETUP);
|
||||
pw_log_info("sending follower setup to %s", get_ip_fmt(addr, buffer, sizeof(buffer)));
|
||||
pw_log_info("sending follower setup to %s",
|
||||
pw_net_get_ip_fmt(addr, buffer, sizeof(buffer)));
|
||||
nj2_dump_session_params(params);
|
||||
send(follower->socket->fd, params, sizeof(*params), 0);
|
||||
|
||||
|
|
@ -1079,7 +1080,7 @@ static int create_netjack2_socket(struct impl *impl)
|
|||
if ((str = pw_properties_get(impl->props, "net.ip")) == NULL)
|
||||
str = DEFAULT_NET_IP;
|
||||
|
||||
if ((res = parse_address(str, port, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, port, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
pw_log_error("invalid net.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1105,7 +1106,7 @@ static int create_netjack2_socket(struct impl *impl)
|
|||
goto out;
|
||||
}
|
||||
pw_log_info("listening for AVAILABLE on %s",
|
||||
get_ip_fmt(&impl->src_addr, buffer, sizeof(buffer)));
|
||||
pw_net_get_ip_fmt(&impl->src_addr, buffer, sizeof(buffer)));
|
||||
return 0;
|
||||
out:
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ static int make_recv_socket(struct sockaddr_storage *sa, socklen_t salen,
|
|||
memset(&mr4, 0, sizeof(mr4));
|
||||
mr4.imr_multiaddr = sa4->sin_addr;
|
||||
mr4.imr_ifindex = req.ifr_ifindex;
|
||||
get_ip(sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_log_info("join IPv4 group: %s iface:%d", addr, req.ifr_ifindex);
|
||||
res = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mr4, sizeof(mr4));
|
||||
} else {
|
||||
|
|
@ -489,7 +489,7 @@ static int make_recv_socket(struct sockaddr_storage *sa, socklen_t salen,
|
|||
memset(&mr6, 0, sizeof(mr6));
|
||||
mr6.ipv6mr_multiaddr = sa6->sin6_addr;
|
||||
mr6.ipv6mr_interface = req.ifr_ifindex;
|
||||
get_ip(sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_log_info("join IPv6 group: %s iface:%d", addr, req.ifr_ifindex);
|
||||
res = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mr6, sizeof(mr6));
|
||||
} else {
|
||||
|
|
@ -653,7 +653,7 @@ static int send_sap(struct impl *impl, struct session *sess, bool bye)
|
|||
iov[0].iov_base = &header;
|
||||
iov[0].iov_len = sizeof(header);
|
||||
|
||||
if ((res = get_ip(&impl->src_addr, src_addr, sizeof(src_addr), &src_ip4, NULL)) < 0)
|
||||
if ((res = pw_net_get_ip(&impl->src_addr, src_addr, sizeof(src_addr), &src_ip4, NULL)) < 0)
|
||||
return res;
|
||||
|
||||
if (src_ip4) {
|
||||
|
|
@ -667,7 +667,7 @@ static int send_sap(struct impl *impl, struct session *sess, bool bye)
|
|||
iov[2].iov_base = SAP_MIME_TYPE;
|
||||
iov[2].iov_len = sizeof(SAP_MIME_TYPE);
|
||||
|
||||
if ((res = get_ip(&sdp->dst_addr, dst_addr, sizeof(dst_addr), &dst_ip4, NULL)) < 0)
|
||||
if ((res = pw_net_get_ip(&sdp->dst_addr, dst_addr, sizeof(dst_addr), &dst_ip4, NULL)) < 0)
|
||||
return res;
|
||||
|
||||
if ((user_name = pw_get_user_name()) == NULL)
|
||||
|
|
@ -864,7 +864,7 @@ static struct session *session_new_announce(struct impl *impl, struct node *node
|
|||
|
||||
if ((str = pw_properties_get(props, "rtp.destination.ip")) == NULL)
|
||||
goto error_free;
|
||||
if ((res = parse_address(str, sdp->dst_port, &sdp->dst_addr, &sdp->dst_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, sdp->dst_port, &sdp->dst_addr, &sdp->dst_len)) < 0) {
|
||||
pw_log_error("invalid destination.ip %s: %s", str, spa_strerror(res));
|
||||
goto error_free;
|
||||
}
|
||||
|
|
@ -1107,7 +1107,7 @@ static struct session *session_new(struct impl *impl, struct sdp_info *info)
|
|||
pw_properties_set(props, PW_KEY_MEDIA_NAME, "RTP Stream");
|
||||
}
|
||||
|
||||
get_ip(&info->dst_addr, dst_addr, sizeof(dst_addr), NULL, NULL);
|
||||
pw_net_get_ip(&info->dst_addr, dst_addr, sizeof(dst_addr), NULL, NULL);
|
||||
pw_properties_setf(props, "rtp.destination.ip", "%s", dst_addr);
|
||||
pw_properties_setf(props, "rtp.destination.port", "%u", info->dst_port);
|
||||
pw_properties_setf(props, "rtp.payload", "%u", info->payload);
|
||||
|
|
@ -1477,7 +1477,7 @@ static int start_sap(struct impl *impl)
|
|||
if ((fd = make_recv_socket(&impl->sap_addr, impl->sap_len, impl->ifname)) < 0)
|
||||
return fd;
|
||||
|
||||
get_ip(&impl->sap_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(&impl->sap_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_log_info("starting SAP listener on %s", addr);
|
||||
impl->sap_source = pw_loop_add_io(impl->loop, fd,
|
||||
SPA_IO_IN, true, on_sap_io, impl);
|
||||
|
|
@ -1709,7 +1709,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
if ((str = pw_properties_get(props, "sap.ip")) == NULL)
|
||||
str = DEFAULT_SAP_IP;
|
||||
port = pw_properties_get_uint32(props, "sap.port", DEFAULT_SAP_PORT);
|
||||
if ((res = parse_address(str, port, &impl->sap_addr, &impl->sap_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, port, &impl->sap_addr, &impl->sap_len)) < 0) {
|
||||
pw_log_error("invalid sap.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1742,7 +1742,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
str = impl->sap_addr.ss_family == AF_INET ?
|
||||
DEFAULT_SOURCE_IP : DEFAULT_SOURCE_IP6;
|
||||
}
|
||||
if ((res = parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -715,7 +715,7 @@ static void parse_apple_midi_cmd_in(struct impl *impl, bool ctrl, uint8_t *buffe
|
|||
initiator = ntohl(hdr->initiator);
|
||||
ssrc = ntohl(hdr->ssrc);
|
||||
|
||||
get_ip(sa, addr, sizeof(addr), NULL, &port);
|
||||
pw_net_get_ip(sa, addr, sizeof(addr), NULL, &port);
|
||||
pw_log_info("IN from %s:%d %s ssrc:%08x initiator:%08x",
|
||||
addr, port, hdr->name, ssrc, initiator);
|
||||
|
||||
|
|
@ -1405,10 +1405,10 @@ static struct service *make_service(struct impl *impl, const struct service_info
|
|||
}
|
||||
s->sess = sess;
|
||||
|
||||
if ((res = parse_address(at, s->info.port, &sess->ctrl_addr, &sess->ctrl_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(at, s->info.port, &sess->ctrl_addr, &sess->ctrl_len)) < 0) {
|
||||
pw_log_error("invalid address %s: %s", at, spa_strerror(res));
|
||||
}
|
||||
if ((res = parse_address(at, s->info.port+1, &sess->data_addr, &sess->data_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(at, s->info.port+1, &sess->data_addr, &sess->data_len)) < 0) {
|
||||
pw_log_error("invalid address %s: %s", at, spa_strerror(res));
|
||||
}
|
||||
return s;
|
||||
|
|
@ -1748,11 +1748,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
impl->ctrl_port = port;
|
||||
|
||||
if ((res = parse_address(str, port, &impl->ctrl_addr, &impl->ctrl_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, port, &impl->ctrl_addr, &impl->ctrl_len)) < 0) {
|
||||
pw_log_error("invalid control.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
if ((res = parse_address(str, port ? port+1 : 0, &impl->data_addr, &impl->data_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, port ? port+1 : 0, &impl->data_addr, &impl->data_len)) < 0) {
|
||||
pw_log_error("invalid data.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp
|
|||
pw_log_info("key '%s', value '%s'", key, value);
|
||||
if (!spa_streq(key, "destination.ip"))
|
||||
continue;
|
||||
if (parse_address(value, impl->dst_port, &impl->dst_addr,
|
||||
if (pw_net_parse_address(value, impl->dst_port, &impl->dst_addr,
|
||||
&impl->dst_len) < 0) {
|
||||
pw_log_error("invalid destination.ip: '%s'", value);
|
||||
break;
|
||||
|
|
@ -536,14 +536,14 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->dst_port = pw_properties_get_uint32(props, "destination.port", impl->dst_port);
|
||||
if ((str = pw_properties_get(props, "destination.ip")) == NULL)
|
||||
str = DEFAULT_DESTINATION_IP;
|
||||
if ((res = parse_address(str, impl->dst_port, &impl->dst_addr, &impl->dst_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, impl->dst_port, &impl->dst_addr, &impl->dst_len)) < 0) {
|
||||
pw_log_error("invalid destination.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
if ((str = pw_properties_get(props, "source.ip")) == NULL)
|
||||
str = impl->dst_addr.ss_family == AF_INET ?
|
||||
DEFAULT_SOURCE_IP : DEFAULT_SOURCE_IP6;
|
||||
if ((res = parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -557,9 +557,9 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
ts_offset = pw_rand32();
|
||||
pw_properties_setf(stream_props, "rtp.sender-ts-offset", "%u", (uint32_t)ts_offset);
|
||||
|
||||
get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_properties_set(stream_props, "rtp.source.ip", addr);
|
||||
get_ip(&impl->dst_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(&impl->dst_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_properties_set(stream_props, "rtp.destination.ip", addr);
|
||||
pw_properties_setf(stream_props, "rtp.destination.port", "%u", impl->dst_port);
|
||||
pw_properties_setf(stream_props, "rtp.ttl", "%u", impl->ttl);
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ static int make_socket(const struct sockaddr* sa, socklen_t salen, char *ifname)
|
|||
memset(&mr4, 0, sizeof(mr4));
|
||||
mr4.imr_multiaddr = sa4->sin_addr;
|
||||
mr4.imr_ifindex = req.ifr_ifindex;
|
||||
get_ip((struct sockaddr_storage*)sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip((struct sockaddr_storage*)sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_log_info("join IPv4 group: %s", addr);
|
||||
res = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mr4, sizeof(mr4));
|
||||
} else {
|
||||
|
|
@ -257,7 +257,7 @@ static int make_socket(const struct sockaddr* sa, socklen_t salen, char *ifname)
|
|||
memset(&mr6, 0, sizeof(mr6));
|
||||
mr6.ipv6mr_multiaddr = sa6->sin6_addr;
|
||||
mr6.ipv6mr_interface = req.ifr_ifindex;
|
||||
get_ip((struct sockaddr_storage*)sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip((struct sockaddr_storage*)sa, addr, sizeof(addr), NULL, NULL);
|
||||
pw_log_info("join IPv6 group: %s", addr);
|
||||
res = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mr6, sizeof(mr6));
|
||||
} else {
|
||||
|
|
@ -385,7 +385,7 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp
|
|||
pw_log_info("key '%s', value '%s'", key, value);
|
||||
if (!spa_streq(key, "source.ip"))
|
||||
continue;
|
||||
if (parse_address(value, impl->src_port, &impl->src_addr,
|
||||
if (pw_net_parse_address(value, impl->src_port, &impl->src_addr,
|
||||
&impl->src_len) < 0) {
|
||||
pw_log_error("invalid source.ip: '%s'", value);
|
||||
break;
|
||||
|
|
@ -581,11 +581,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
}
|
||||
if ((str = pw_properties_get(props, "source.ip")) == NULL)
|
||||
str = DEFAULT_SOURCE_IP;
|
||||
if ((res = parse_address(str, impl->src_port, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, impl->src_port, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_properties_set(stream_props, "rtp.source.ip", addr);
|
||||
pw_properties_setf(stream_props, "rtp.source.port", "%u", impl->src_port);
|
||||
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
}
|
||||
if ((str = pw_properties_get(props, "source.ip")) == NULL)
|
||||
str = DEFAULT_SOURCE_IP;
|
||||
if ((res = parse_address(str, impl->src_port, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, impl->src_port, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
if ((str = pw_properties_get(props, "source.ip")) == NULL)
|
||||
str = DEFAULT_SOURCE_IP;
|
||||
if ((res = parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
|
||||
pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -436,7 +436,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->dst_port = pw_properties_get_uint32(props, "destination.port", DEFAULT_PORT);
|
||||
if ((str = pw_properties_get(props, "destination.ip")) == NULL)
|
||||
str = DEFAULT_DESTINATION_IP;
|
||||
if ((res = parse_address(str, impl->dst_port, &impl->dst_addr, &impl->dst_len)) < 0) {
|
||||
if ((res = pw_net_parse_address(str, impl->dst_port, &impl->dst_addr, &impl->dst_len)) < 0) {
|
||||
pw_log_error("invalid destination.ip %s: %s", str, spa_strerror(res));
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -445,9 +445,9 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->mcast_loop = pw_properties_get_bool(props, "net.loop", DEFAULT_LOOP);
|
||||
impl->dscp = pw_properties_get_uint32(props, "net.dscp", DEFAULT_DSCP);
|
||||
|
||||
get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_properties_set(stream_props, "vban.source.ip", addr);
|
||||
get_ip(&impl->dst_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_net_get_ip(&impl->dst_addr, addr, sizeof(addr), NULL, NULL);
|
||||
pw_properties_set(stream_props, "vban.destination.ip", addr);
|
||||
pw_properties_setf(stream_props, "vban.destination.port", "%u", impl->dst_port);
|
||||
pw_properties_setf(stream_props, "vban.ttl", "%u", impl->ttl);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <net/if.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int parse_address(const char *address, uint16_t port,
|
||||
static int pw_net_parse_address(const char *address, uint16_t port,
|
||||
struct sockaddr_storage *addr, socklen_t *len)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
|
@ -25,9 +25,8 @@ static int parse_address(const char *address, uint16_t port,
|
|||
|
||||
res = getaddrinfo(address, port_str, &hints, &result);
|
||||
|
||||
if (res != 0) {
|
||||
if (res != 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||
memcpy(addr, rp->ai_addr, rp->ai_addrlen);
|
||||
|
|
@ -39,7 +38,7 @@ static int parse_address(const char *address, uint16_t port,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_ip(const struct sockaddr_storage *sa, char *ip, size_t len, bool *ip4, uint16_t *port)
|
||||
static int pw_net_get_ip(const struct sockaddr_storage *sa, char *ip, size_t len, bool *ip4, uint16_t *port)
|
||||
{
|
||||
if (sa->ss_family == AF_INET) {
|
||||
struct sockaddr_in *in = (struct sockaddr_in*)sa;
|
||||
|
|
@ -51,16 +50,15 @@ static int get_ip(const struct sockaddr_storage *sa, char *ip, size_t len, bool
|
|||
inet_ntop(sa->ss_family, &in->sin6_addr, ip, len);
|
||||
if (port)
|
||||
*port = ntohs(in->sin6_port);
|
||||
if (in->sin6_scope_id == 0 || len <= 1) {
|
||||
if (in->sin6_scope_id == 0 || len <= 1)
|
||||
goto finish;
|
||||
}
|
||||
|
||||
size_t curlen = strlen(ip);
|
||||
if (len-(curlen+1) >= IFNAMSIZ) {
|
||||
ip += curlen+1;
|
||||
ip[-1] = '%';
|
||||
if (if_indextoname(in->sin6_scope_id, ip) == NULL) {
|
||||
if (if_indextoname(in->sin6_scope_id, ip) == NULL)
|
||||
ip[-1] = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
return -EINVAL;
|
||||
|
|
@ -70,11 +68,10 @@ finish:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline char *get_ip_fmt(const struct sockaddr_storage *sa, char *ip, size_t len)
|
||||
static inline char *pw_net_get_ip_fmt(const struct sockaddr_storage *sa, char *ip, size_t len)
|
||||
{
|
||||
if (get_ip(sa, ip, len, NULL, NULL) != 0) {
|
||||
if (pw_net_get_ip(sa, ip, len, NULL, NULL) != 0)
|
||||
snprintf(ip, len, "invalid ip");
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue