make AirPlay work in AP mode

This commit is contained in:
philippe44
2020-03-08 16:51:24 -07:00
parent ca702d1b90
commit 1a5f5283bb
3 changed files with 28 additions and 9 deletions

View File

@@ -437,6 +437,12 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
LOG_INFO("[%p]: received %s", ctx, method);
}
if ((buf = kd_lookup(headers, "Apple-Challenge")) != NULL) {
int n;
char *buf_pad, *p, *data_b64 = NULL, data[32];
LOG_INFO("[%p]: challenge %s", ctx, buf);
// try to re-acquire IP address if we were missing it
if (S_ADDR(ctx->host) == INADDR_ANY) {
S_ADDR(ctx->host) = get_localhost(NULL);

View File

@@ -163,7 +163,7 @@ void raop_sink_init(raop_cmd_vcb_t cmd_cb, raop_data_cb_t data_cb) {
free(sink_name_buffer);
}
LOG_INFO( "mdns hostname set to: [%s] with servicename %s", hostname, sink_name);
LOG_INFO( "mdns hostname for ip %s set to: [%s] with servicename %s", inet_ntoa(host), hostname, sink_name);
// create RAOP instance, latency is set by controller
uint8_t mac[6];

View File

@@ -23,12 +23,7 @@
#ifdef WIN32
#include <iphlpapi.h>
#else
/*
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <netdb.h>
*/
#include "tcpip_adapter.h"
#include <ctype.h>
#endif
@@ -84,8 +79,26 @@ in_addr_t get_localhost(char **name)
}
else return INADDR_ANY;
#else
// missing platform here ...
return INADDR_ANY;
tcpip_adapter_ip_info_t ipInfo;
tcpip_adapter_if_t if_type = TCPIP_ADAPTER_IF_STA;
// then get IP address
tcpip_adapter_get_ip_info(if_type, &ipInfo);
// we might be in AP mode
if (ipInfo.ip.addr == INADDR_ANY) {
if_type = TCPIP_ADAPTER_IF_AP;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ipInfo);
}
// get hostname if required
if (name) {
const char *hostname;
tcpip_adapter_get_hostname(if_type, &hostname);
*name = strdup(hostname);
}
return ipInfo.ip.addr;
#endif
}