Add IPv6 support to player and RAOP for device discovery
This commit is contained in:
parent
c9818e9269
commit
b8238e6a78
85
src/player.c
85
src/player.c
|
@ -1046,7 +1046,12 @@ static void
|
||||||
device_free(struct raop_device *dev)
|
device_free(struct raop_device *dev)
|
||||||
{
|
{
|
||||||
free(dev->name);
|
free(dev->name);
|
||||||
free(dev->address);
|
|
||||||
|
if (dev->v4_address)
|
||||||
|
free(dev->v4_address);
|
||||||
|
|
||||||
|
if (dev->v6_address)
|
||||||
|
free(dev->v6_address);
|
||||||
|
|
||||||
free(dev);
|
free(dev);
|
||||||
}
|
}
|
||||||
|
@ -2762,9 +2767,6 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
||||||
int has_password;
|
int has_password;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (family != AF_INET)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ret = safe_hextou64(name, &id);
|
ret = safe_hextou64(name, &id);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
@ -2807,18 +2809,40 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rd->advertised = 0;
|
switch (family)
|
||||||
|
|
||||||
if (!rd->session)
|
|
||||||
{
|
{
|
||||||
if (!prev)
|
case AF_INET:
|
||||||
dev_list = rd->next;
|
if (rd->v4_address)
|
||||||
else
|
{
|
||||||
prev->next = rd->next;
|
free(rd->v4_address);
|
||||||
|
rd->v4_address = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
device_free(rd);
|
case AF_INET6:
|
||||||
|
if (rd->v6_address)
|
||||||
|
{
|
||||||
|
free(rd->v6_address);
|
||||||
|
rd->v6_address = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_PLAYER, "Removed AirTunes device %s; stopped advertising\n", name);
|
if (!rd->v4_address && !rd->v6_address)
|
||||||
|
{
|
||||||
|
rd->advertised = 0;
|
||||||
|
|
||||||
|
if (!rd->session)
|
||||||
|
{
|
||||||
|
if (!prev)
|
||||||
|
dev_list = rd->next;
|
||||||
|
else
|
||||||
|
prev->next = rd->next;
|
||||||
|
|
||||||
|
device_free(rd);
|
||||||
|
|
||||||
|
DPRINTF(E_DBG, L_PLAYER, "Removed AirTunes device %s; stopped advertising\n", name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&dev_lck);
|
pthread_mutex_unlock(&dev_lck);
|
||||||
|
@ -2872,7 +2896,25 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
||||||
DPRINTF(E_DBG, L_PLAYER, "Updating AirTunes device %s already in list, updating\n", name);
|
DPRINTF(E_DBG, L_PLAYER, "Updating AirTunes device %s already in list, updating\n", name);
|
||||||
|
|
||||||
free(rd->name);
|
free(rd->name);
|
||||||
free(rd->address);
|
|
||||||
|
switch (family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
if (rd->v4_address)
|
||||||
|
{
|
||||||
|
free(rd->v4_address);
|
||||||
|
rd->v4_address = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
if (rd->v6_address)
|
||||||
|
{
|
||||||
|
free(rd->v6_address);
|
||||||
|
rd->v6_address = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2897,10 +2939,21 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
||||||
}
|
}
|
||||||
|
|
||||||
rd->advertised = 1;
|
rd->advertised = 1;
|
||||||
rd->port = port;
|
|
||||||
|
switch (family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
rd->v4_address = strdup(address);
|
||||||
|
rd->v4_port = port;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
rd->v6_address = strdup(address);
|
||||||
|
rd->v6_port = port;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
rd->name = strdup(at_name);
|
rd->name = strdup(at_name);
|
||||||
rd->address = strdup(address);
|
|
||||||
|
|
||||||
rd->has_password = has_password;
|
rd->has_password = has_password;
|
||||||
rd->password = val;
|
rd->password = val;
|
||||||
|
|
11
src/raop.c
11
src/raop.c
|
@ -1341,6 +1341,9 @@ raop_session_make(struct raop_device *rd, raop_status_cb cb)
|
||||||
struct raop_session *rs;
|
struct raop_session *rs;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!rd->v4_address)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
rs = (struct raop_session *)malloc(sizeof(struct raop_session));
|
rs = (struct raop_session *)malloc(sizeof(struct raop_session));
|
||||||
if (!rs)
|
if (!rs)
|
||||||
{
|
{
|
||||||
|
@ -1360,15 +1363,15 @@ raop_session_make(struct raop_device *rd, raop_status_cb cb)
|
||||||
rs->password = rd->password;
|
rs->password = rd->password;
|
||||||
|
|
||||||
rs->sa.sin.sin_family = AF_INET;
|
rs->sa.sin.sin_family = AF_INET;
|
||||||
ret = inet_pton(AF_INET, rd->address, &rs->sa.sin.sin_addr.s_addr);
|
ret = inet_pton(AF_INET, rd->v4_address, &rs->sa.sin.sin_addr.s_addr);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_RAOP, "Device address not valid (%s)\n", rd->address);
|
DPRINTF(E_LOG, L_RAOP, "Device address not valid (%s)\n", rd->v4_address);
|
||||||
|
|
||||||
goto out_free_rs;
|
goto out_free_rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
rs->ctrl = evrtsp_connection_new(rd->address, rd->port);
|
rs->ctrl = evrtsp_connection_new(rd->v4_address, rd->v4_port);
|
||||||
if (!rs->ctrl)
|
if (!rs->ctrl)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_RAOP, "Could not create control connection\n");
|
DPRINTF(E_LOG, L_RAOP, "Could not create control connection\n");
|
||||||
|
@ -1379,7 +1382,7 @@ raop_session_make(struct raop_device *rd, raop_status_cb cb)
|
||||||
evrtsp_connection_set_base(rs->ctrl, evbase_player);
|
evrtsp_connection_set_base(rs->ctrl, evbase_player);
|
||||||
|
|
||||||
rs->devname = strdup(rd->name);
|
rs->devname = strdup(rd->name);
|
||||||
rs->address = strdup(rd->address);
|
rs->address = strdup(rd->v4_address);
|
||||||
|
|
||||||
rs->next = sessions;
|
rs->next = sessions;
|
||||||
sessions = rs;
|
sessions = rs;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
union sockaddr_all
|
union sockaddr_all
|
||||||
{
|
{
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
|
struct sockaddr_in6 sin6;
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
};
|
};
|
||||||
|
@ -22,8 +23,10 @@ struct raop_device
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
char *address;
|
char *v4_address;
|
||||||
short port;
|
char *v6_address;
|
||||||
|
short v4_port;
|
||||||
|
short v6_port;
|
||||||
|
|
||||||
char selected;
|
char selected;
|
||||||
char advertised;
|
char advertised;
|
||||||
|
|
Loading…
Reference in New Issue