mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-15 16:53:18 -05:00
evrtsp: Handle IPv6 scoped addresses
This commit is contained in:
parent
01cde2c50c
commit
deae610965
@ -1237,18 +1237,33 @@ struct evrtsp_connection *
|
|||||||
evrtsp_connection_new(const char *address, unsigned short port)
|
evrtsp_connection_new(const char *address, unsigned short port)
|
||||||
{
|
{
|
||||||
struct evrtsp_connection *evcon = NULL;
|
struct evrtsp_connection *evcon = NULL;
|
||||||
|
char *intf;
|
||||||
|
char *addr;
|
||||||
unsigned char scratch[16];
|
unsigned char scratch[16];
|
||||||
int family;
|
int family;
|
||||||
|
|
||||||
if (inet_pton(AF_INET6, address, scratch) == 1)
|
if ((addr = strdup(address)) == NULL) {
|
||||||
|
event_warn("%s: strdup failed", __func__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
intf = strchr(addr, '%');
|
||||||
|
if (intf)
|
||||||
|
*intf = '\0';
|
||||||
|
|
||||||
|
if (inet_pton(AF_INET6, addr, scratch) == 1)
|
||||||
family = AF_INET6;
|
family = AF_INET6;
|
||||||
else if (inet_pton(AF_INET, address, scratch) == 1)
|
else if (inet_pton(AF_INET, addr, scratch) == 1)
|
||||||
family = AF_INET;
|
family = AF_INET;
|
||||||
else {
|
else {
|
||||||
|
free(addr);
|
||||||
event_warn("%s: address is neither IPv6 nor IPv4", __func__);
|
event_warn("%s: address is neither IPv6 nor IPv4", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (intf)
|
||||||
|
*intf = '%';
|
||||||
|
|
||||||
event_debug(("Attempting connection to %s:%d\n", address, port));
|
event_debug(("Attempting connection to %s:%d\n", address, port));
|
||||||
|
|
||||||
if ((evcon = calloc(1, sizeof(struct evrtsp_connection))) == NULL) {
|
if ((evcon = calloc(1, sizeof(struct evrtsp_connection))) == NULL) {
|
||||||
@ -1264,11 +1279,7 @@ evrtsp_connection_new(const char *address, unsigned short port)
|
|||||||
evcon->cseq = 1;
|
evcon->cseq = 1;
|
||||||
|
|
||||||
evcon->family = family;
|
evcon->family = family;
|
||||||
|
evcon->address = addr;
|
||||||
if ((evcon->address = strdup(address)) == NULL) {
|
|
||||||
event_warn("%s: strdup failed", __func__);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((evcon->input_buffer = evbuffer_new()) == NULL) {
|
if ((evcon->input_buffer = evbuffer_new()) == NULL) {
|
||||||
event_warn("%s: evbuffer_new failed", __func__);
|
event_warn("%s: evbuffer_new failed", __func__);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user