mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
allow IPV6 clients (untested)
This commit is contained in:
@@ -70,7 +70,7 @@ struct raop_callbacks_s {
|
||||
void (*video_report_size)(void *cls, float *width_source, float *height_source, float *width, float *height);
|
||||
};
|
||||
typedef struct raop_callbacks_s raop_callbacks_t;
|
||||
raop_ntp_t *raop_ntp_init(logger_t *logger, raop_callbacks_t *callbacks, const unsigned char *remote_addr, int remote_addr_len,
|
||||
raop_ntp_t *raop_ntp_init(logger_t *logger, raop_callbacks_t *callbacks, const char *remote, int remote_addr_len,
|
||||
unsigned short timing_rport, timing_protocol_t *time_protocol);
|
||||
|
||||
RAOP_API raop_t *raop_init(int max_clients, raop_callbacks_t *callbacks);
|
||||
|
||||
@@ -481,14 +481,34 @@ raop_handler_setup(raop_conn_t *conn,
|
||||
" may be using unsupported AirPlay2 \"Remote Control\" protocol");
|
||||
}
|
||||
unsigned short timing_lport = conn->raop->timing_lport;
|
||||
conn->raop_ntp = raop_ntp_init(conn->raop->logger, &conn->raop->callbacks, conn->remote,
|
||||
conn->remotelen, (unsigned short) timing_rport, &time_protocol);
|
||||
raop_ntp_start(conn->raop_ntp, &timing_lport, conn->raop->max_ntp_timeouts);
|
||||
|
||||
conn->raop_rtp = raop_rtp_init(conn->raop->logger, &conn->raop->callbacks, conn->raop_ntp,
|
||||
conn->remote, conn->remotelen, aeskey, aesiv);
|
||||
conn->raop_rtp_mirror = raop_rtp_mirror_init(conn->raop->logger, &conn->raop->callbacks,
|
||||
conn->raop_ntp, conn->remote, conn->remotelen, aeskey);
|
||||
conn->raop_ntp = NULL;
|
||||
conn->raop_rtp = NULL;
|
||||
conn->raop_rtp_mirror = NULL;
|
||||
if (conn->remotelen == 4 || conn->remotelen == 16) {
|
||||
char remote[40];
|
||||
memset(remote, 0, sizeof(remote));
|
||||
if (conn->remotelen == 4) {
|
||||
/* IPV4 */
|
||||
snprintf(remote, sizeof(remote), "%d.%d.%d.%d", conn->remote[0], conn->remote[1],
|
||||
conn->remote[2], conn->remote[3]);
|
||||
} else {
|
||||
/*IPV6*/
|
||||
logger_log(conn->raop->logger, LOGGER_INFO, "client is using IPV6 (untested!)");
|
||||
snprintf(remote, sizeof(remote), "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
|
||||
conn->remote[0], conn->remote[1], conn->remote[2], conn->remote[3],
|
||||
conn->remote[4], conn->remote[5], conn->remote[6], conn->remote[7],
|
||||
conn->remote[8], conn->remote[9], conn->remote[10], conn->remote[11],
|
||||
conn->remote[12], conn->remote[13], conn->remote[14], conn->remote[15]);
|
||||
}
|
||||
conn->raop_ntp = raop_ntp_init(conn->raop->logger, &conn->raop->callbacks, remote,
|
||||
conn->remotelen, (unsigned short) timing_rport, &time_protocol);
|
||||
raop_ntp_start(conn->raop_ntp, &timing_lport, conn->raop->max_ntp_timeouts);
|
||||
conn->raop_rtp = raop_rtp_init(conn->raop->logger, &conn->raop->callbacks, conn->raop_ntp,
|
||||
remote, conn->remotelen, aeskey, aesiv);
|
||||
conn->raop_rtp_mirror = raop_rtp_mirror_init(conn->raop->logger, &conn->raop->callbacks,
|
||||
conn->raop_ntp, remote, conn->remotelen, aeskey);
|
||||
}
|
||||
|
||||
plist_t res_event_port_node = plist_new_uint(conn->raop->port);
|
||||
plist_t res_timing_port_node = plist_new_uint(timing_lport);
|
||||
|
||||
@@ -114,9 +114,8 @@ raop_ntp_compare(const void* av, const void* bv)
|
||||
}
|
||||
|
||||
static int
|
||||
raop_ntp_parse_remote_address(raop_ntp_t *raop_ntp, const unsigned char *remote_addr, int remote_addr_len)
|
||||
raop_ntp_parse_remote(raop_ntp_t *raop_ntp, const char *remote, int remote_addr_len)
|
||||
{
|
||||
char current[25];
|
||||
int family;
|
||||
int ret;
|
||||
assert(raop_ntp);
|
||||
@@ -127,11 +126,8 @@ raop_ntp_parse_remote_address(raop_ntp_t *raop_ntp, const unsigned char *remote_
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
memset(current, 0, sizeof(current));
|
||||
snprintf(current, sizeof(current), "%d.%d.%d.%d", remote_addr[0], remote_addr[1],
|
||||
remote_addr[2], remote_addr[3]);
|
||||
logger_log(raop_ntp->logger, LOGGER_DEBUG, "raop_ntp parse remote ip = %s", current);
|
||||
ret = netutils_parse_address(family, current,
|
||||
logger_log(raop_ntp->logger, LOGGER_DEBUG, "raop_ntp parse remote ip = %s", remote);
|
||||
ret = netutils_parse_address(family, remote,
|
||||
&raop_ntp->remote_saddr,
|
||||
sizeof(raop_ntp->remote_saddr));
|
||||
if (ret < 0) {
|
||||
@@ -141,7 +137,7 @@ raop_ntp_parse_remote_address(raop_ntp_t *raop_ntp, const unsigned char *remote_
|
||||
return 0;
|
||||
}
|
||||
|
||||
raop_ntp_t *raop_ntp_init(logger_t *logger, raop_callbacks_t *callbacks, const unsigned char *remote_addr,
|
||||
raop_ntp_t *raop_ntp_init(logger_t *logger, raop_callbacks_t *callbacks, const char *remote,
|
||||
int remote_addr_len, unsigned short timing_rport, timing_protocol_t *time_protocol) {
|
||||
raop_ntp_t *raop_ntp;
|
||||
|
||||
@@ -157,7 +153,7 @@ raop_ntp_t *raop_ntp_init(logger_t *logger, raop_callbacks_t *callbacks, const u
|
||||
memcpy(&raop_ntp->callbacks, callbacks, sizeof(raop_callbacks_t));
|
||||
raop_ntp->timing_rport = timing_rport;
|
||||
|
||||
if (raop_ntp_parse_remote_address(raop_ntp, remote_addr, remote_addr_len) < 0) {
|
||||
if (raop_ntp_parse_remote(raop_ntp, remote, remote_addr_len) < 0) {
|
||||
free(raop_ntp);
|
||||
return NULL;
|
||||
}
|
||||
@@ -418,7 +414,7 @@ raop_ntp_start(raop_ntp_t *raop_ntp, unsigned short *timing_lport, int max_ntp_t
|
||||
if (raop_ntp->remote_saddr.ss_family == AF_INET6) {
|
||||
use_ipv6 = 1;
|
||||
}
|
||||
use_ipv6 = 0;
|
||||
//use_ipv6 = 0;
|
||||
if (raop_ntp_init_socket(raop_ntp, use_ipv6) < 0) {
|
||||
logger_log(raop_ntp->logger, LOGGER_ERR, "raop_ntp initializing timing socket failed");
|
||||
MUTEX_UNLOCK(raop_ntp->run_mutex);
|
||||
|
||||
@@ -122,9 +122,8 @@ struct raop_rtp_s {
|
||||
};
|
||||
|
||||
static int
|
||||
raop_rtp_parse_remote(raop_rtp_t *raop_rtp, const unsigned char *remote, int remotelen)
|
||||
raop_rtp_parse_remote(raop_rtp_t *raop_rtp, const char *remote, int remotelen)
|
||||
{
|
||||
char current[25];
|
||||
int family;
|
||||
int ret;
|
||||
assert(raop_rtp);
|
||||
@@ -135,10 +134,8 @@ raop_rtp_parse_remote(raop_rtp_t *raop_rtp, const unsigned char *remote, int rem
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
memset(current, 0, sizeof(current));
|
||||
snprintf(current, sizeof(current), "%d.%d.%d.%d", remote[0], remote[1], remote[2], remote[3]);
|
||||
logger_log(raop_rtp->logger, LOGGER_DEBUG, "raop_rtp parse remote ip = %s", current);
|
||||
ret = netutils_parse_address(family, current,
|
||||
logger_log(raop_rtp->logger, LOGGER_DEBUG, "raop_rtp parse remote ip = %s", remote);
|
||||
ret = netutils_parse_address(family, remote,
|
||||
&raop_rtp->remote_saddr,
|
||||
sizeof(raop_rtp->remote_saddr));
|
||||
if (ret < 0) {
|
||||
@@ -149,7 +146,7 @@ raop_rtp_parse_remote(raop_rtp_t *raop_rtp, const unsigned char *remote, int rem
|
||||
}
|
||||
|
||||
raop_rtp_t *
|
||||
raop_rtp_init(logger_t *logger, raop_callbacks_t *callbacks, raop_ntp_t *ntp, const unsigned char *remote,
|
||||
raop_rtp_init(logger_t *logger, raop_callbacks_t *callbacks, raop_ntp_t *ntp, const char *remote,
|
||||
int remotelen, const unsigned char *aeskey, const unsigned char *aesiv)
|
||||
{
|
||||
raop_rtp_t *raop_rtp;
|
||||
@@ -753,7 +750,7 @@ raop_rtp_start_audio(raop_rtp_t *raop_rtp, int use_udp, unsigned short *control_
|
||||
if (raop_rtp->remote_saddr.ss_family == AF_INET6) {
|
||||
use_ipv6 = 1;
|
||||
}
|
||||
use_ipv6 = 0;
|
||||
//use_ipv6 = 0;
|
||||
if (raop_rtp_init_sockets(raop_rtp, use_ipv6, use_udp) < 0) {
|
||||
logger_log(raop_rtp->logger, LOGGER_ERR, "raop_rtp initializing sockets failed");
|
||||
MUTEX_UNLOCK(raop_rtp->run_mutex);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
typedef struct raop_rtp_s raop_rtp_t;
|
||||
|
||||
raop_rtp_t *raop_rtp_init(logger_t *logger, raop_callbacks_t *callbacks, raop_ntp_t *ntp, const unsigned char *remote,
|
||||
raop_rtp_t *raop_rtp_init(logger_t *logger, raop_callbacks_t *callbacks, raop_ntp_t *ntp, const char *remote,
|
||||
int remotelen, const unsigned char *aeskey, const unsigned char *aesiv);
|
||||
|
||||
void raop_rtp_start_audio(raop_rtp_t *raop_rtp, int use_udp, unsigned short *control_rport, unsigned short *control_lport,
|
||||
|
||||
@@ -107,9 +107,8 @@ struct raop_rtp_mirror_s {
|
||||
};
|
||||
|
||||
static int
|
||||
raop_rtp_parse_remote(raop_rtp_mirror_t *raop_rtp_mirror, const unsigned char *remote, int remotelen)
|
||||
raop_rtp_mirror_parse_remote(raop_rtp_mirror_t *raop_rtp_mirror, const char *remote, int remotelen)
|
||||
{
|
||||
char current[25];
|
||||
int family;
|
||||
int ret;
|
||||
assert(raop_rtp_mirror);
|
||||
@@ -120,10 +119,8 @@ raop_rtp_parse_remote(raop_rtp_mirror_t *raop_rtp_mirror, const unsigned char *r
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
memset(current, 0, sizeof(current));
|
||||
snprintf(current, sizeof(current), "%d.%d.%d.%d", remote[0], remote[1], remote[2], remote[3]);
|
||||
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror parse remote ip = %s", current);
|
||||
ret = netutils_parse_address(family, current,
|
||||
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror parse remote ip = %s", remote);
|
||||
ret = netutils_parse_address(family, remote,
|
||||
&raop_rtp_mirror->remote_saddr,
|
||||
sizeof(raop_rtp_mirror->remote_saddr));
|
||||
if (ret < 0) {
|
||||
@@ -135,7 +132,7 @@ raop_rtp_parse_remote(raop_rtp_mirror_t *raop_rtp_mirror, const unsigned char *r
|
||||
|
||||
#define NO_FLUSH (-42)
|
||||
raop_rtp_mirror_t *raop_rtp_mirror_init(logger_t *logger, raop_callbacks_t *callbacks, raop_ntp_t *ntp,
|
||||
const unsigned char *remote, int remotelen, const unsigned char *aeskey)
|
||||
const char *remote, int remotelen, const unsigned char *aeskey)
|
||||
{
|
||||
raop_rtp_mirror_t *raop_rtp_mirror;
|
||||
|
||||
@@ -155,7 +152,7 @@ raop_rtp_mirror_t *raop_rtp_mirror_init(logger_t *logger, raop_callbacks_t *call
|
||||
free(raop_rtp_mirror);
|
||||
return NULL;
|
||||
}
|
||||
if (raop_rtp_parse_remote(raop_rtp_mirror, remote, remotelen) < 0) {
|
||||
if (raop_rtp_mirror_parse_remote(raop_rtp_mirror, remote, remotelen) < 0) {
|
||||
free(raop_rtp_mirror);
|
||||
return NULL;
|
||||
}
|
||||
@@ -723,7 +720,7 @@ raop_rtp_start_mirror(raop_rtp_mirror_t *raop_rtp_mirror, int use_udp, unsigned
|
||||
if (raop_rtp_mirror->remote_saddr.ss_family == AF_INET6) {
|
||||
use_ipv6 = 1;
|
||||
}
|
||||
use_ipv6 = 0;
|
||||
//use_ipv6 = 0;
|
||||
|
||||
raop_rtp_mirror->mirror_data_lport = *mirror_data_lport;
|
||||
if (raop_rtp_init_mirror_sockets(raop_rtp_mirror, use_ipv6) < 0) {
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct raop_rtp_mirror_s raop_rtp_mirror_t;
|
||||
typedef struct h264codec_s h264codec_t;
|
||||
|
||||
raop_rtp_mirror_t *raop_rtp_mirror_init(logger_t *logger, raop_callbacks_t *callbacks, raop_ntp_t *ntp,
|
||||
const unsigned char *remote, int remotelen, const unsigned char *aeskey);
|
||||
const char *remote, int remotelen, const unsigned char *aeskey);
|
||||
void raop_rtp_init_mirror_aes(raop_rtp_mirror_t *raop_rtp_mirror, uint64_t *streamConnectionID);
|
||||
void raop_rtp_start_mirror(raop_rtp_mirror_t *raop_rtp_mirror, int use_udp, unsigned short *mirror_data_lport, uint8_t show_client_FPS_data);
|
||||
void raop_rtp_mirror_stop(raop_rtp_mirror_t *raop_rtp_mirror);
|
||||
|
||||
Reference in New Issue
Block a user