Complete IPv6 handling in the timing sync service

This commit adds the missing bits that should have been part of
commit efbea91ed4 when IPv6 support was
introduced. Oops.
This commit is contained in:
Julien BLACHE 2010-07-11 20:24:00 +02:00
parent 98ba2fb63d
commit c4e4db0728
1 changed files with 37 additions and 9 deletions

View File

@ -1760,7 +1760,7 @@ raop_flush(raop_status_cb cb, uint64_t rtptime)
static void static void
raop_v2_timing_cb(int fd, short what, void *arg) raop_v2_timing_cb(int fd, short what, void *arg)
{ {
char address[INET_ADDRSTRLEN]; char address[INET6_ADDRSTRLEN];
union sockaddr_all sa; union sockaddr_all sa;
uint8_t req[32]; uint8_t req[32];
uint8_t res[32]; uint8_t res[32];
@ -1797,20 +1797,48 @@ raop_v2_timing_cb(int fd, short what, void *arg)
goto readd; goto readd;
} }
if ((svc == &timing_4svc) && (len != sizeof(struct sockaddr_in))) switch (sa.ss.ss_family)
goto readd; {
else if ((svc == &timing_6svc) && (len != sizeof(struct sockaddr_in6))) case AF_INET:
if (svc != &timing_4svc)
goto readd; goto readd;
for (rs = sessions; rs; rs = rs->next) for (rs = sessions; rs; rs = rs->next)
{ {
if (sa.sin.sin_addr.s_addr == rs->sa.sin.sin_addr.s_addr) if ((rs->sa.ss.ss_family == AF_INET)
&& (sa.sin.sin_addr.s_addr == rs->sa.sin.sin_addr.s_addr))
break; break;
} }
if (!rs) if (!rs)
ret = (inet_ntop(AF_INET, &sa.sin.sin_addr.s_addr, address, sizeof(address)) != NULL);
break;
case AF_INET6:
if (svc != &timing_6svc)
goto readd;
for (rs = sessions; rs; rs = rs->next)
{ {
if (!inet_ntop(AF_INET, &sa.sin.sin_addr.s_addr, address, sizeof(address))) if ((rs->sa.ss.ss_family == AF_INET6)
&& IN6_ARE_ADDR_EQUAL(sa.sin6.sin6_addr.s6_addr32, rs->sa.sin6.sin6_addr.s6_addr32))
break;
}
if (!rs)
ret = (inet_ntop(AF_INET6, &sa.sin6.sin6_addr.s6_addr, address, sizeof(address)) != NULL);
break;
default:
DPRINTF(E_LOG, L_RAOP, "Time sync: Unknown address family %d\n", sa.ss.ss_family);
goto readd;
}
if (!rs)
{
if (!ret)
DPRINTF(E_LOG, L_RAOP, "Time sync request from [error: %s]; not a RAOP client\n", strerror(errno)); DPRINTF(E_LOG, L_RAOP, "Time sync request from [error: %s]; not a RAOP client\n", strerror(errno));
else else
DPRINTF(E_LOG, L_RAOP, "Time sync request from %s; not a RAOP client\n", address); DPRINTF(E_LOG, L_RAOP, "Time sync request from %s; not a RAOP client\n", address);