Modify the generation of the 12-digit classic AirPlay service name prefix so that it depends on the service name as well as the hardware address.
This commit is contained in:
@@ -48,6 +48,19 @@ extern mdns_backend mdns_external_avahi;
|
||||
extern mdns_backend mdns_external_dns_sd;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MBEDTLS
|
||||
#include <mbedtls/md5.h>
|
||||
#include <mbedtls/version.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_POLARSSL
|
||||
#include <polarssl/md5.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_OPENSSL
|
||||
#include <openssl/md5.h>
|
||||
#endif
|
||||
|
||||
static mdns_backend *mdns_backends[] = {
|
||||
#ifdef CONFIG_AVAHI
|
||||
&mdns_avahi,
|
||||
@@ -65,11 +78,48 @@ static mdns_backend *mdns_backends[] = {
|
||||
NULL};
|
||||
|
||||
void mdns_register(char **txt_records, char **secondary_txt_records) {
|
||||
|
||||
// calculate the 12-hex-digit prefix by hashing the service name.
|
||||
uint8_t ap_md5[16];
|
||||
|
||||
debug(1,"size of hw_addr is %u.", sizeof(config.hw_addr));
|
||||
#ifdef CONFIG_OPENSSL
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, config.service_name, strlen(config.service_name));
|
||||
MD5_Update(&ctx, config.hw_addr, sizeof(config.hw_addr));
|
||||
MD5_Final(ap_md5, &ctx);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MBEDTLS
|
||||
#if MBEDTLS_VERSION_MINOR >= 7
|
||||
mbedtls_md5_context tctx;
|
||||
mbedtls_md5_starts_ret(&tctx);
|
||||
mbedtls_md5_update_ret(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
|
||||
mbedtls_md5_update_ret(&tctx, (unsigned char *)config.hw_addr, sizeof(config.hw_addr));
|
||||
mbedtls_md5_finish_ret(&tctx, ap_md5);
|
||||
#else
|
||||
mbedtls_md5_context tctx;
|
||||
mbedtls_md5_starts(&tctx);
|
||||
mbedtls_md5_update(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
|
||||
mbedtls_md5_update(&tctx, (unsigned char *)config.hw_addr, sizeof(config.hw_addr));
|
||||
mbedtls_md5_finish(&tctx, ap_md5);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_POLARSSL
|
||||
md5_context tctx;
|
||||
md5_starts(&tctx);
|
||||
md5_update(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
|
||||
md5_update(&tctx, (unsigned char *)config.hw_addr, sizeof(config.hw_addr));
|
||||
md5_finish(&tctx, ap_md5);
|
||||
#endif
|
||||
|
||||
char *ap1_service_name = alloca(strlen(config.service_name) + 14);
|
||||
char *p = ap1_service_name;
|
||||
int i;
|
||||
for (i = 0; i < 6; i++) {
|
||||
snprintf(p, 3, "%02X", config.hw_addr[i]);
|
||||
snprintf(p, 3, "%02X", ap_md5[i]);
|
||||
p += 2;
|
||||
}
|
||||
*p++ = '@';
|
||||
|
||||
+3
-34
@@ -2454,35 +2454,6 @@ int main(int argc, char **argv) {
|
||||
soxr_time_check_thread_started = 1;
|
||||
#endif
|
||||
|
||||
/*
|
||||
uint8_t ap_md5[16];
|
||||
|
||||
#ifdef CONFIG_OPENSSL
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, config.service_name, strlen(config.service_name));
|
||||
MD5_Final(ap_md5, &ctx);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MBEDTLS
|
||||
#if MBEDTLS_VERSION_MINOR >= 7
|
||||
mbedtls_md5_context tctx;
|
||||
mbedtls_md5_starts_ret(&tctx);
|
||||
mbedtls_md5_update_ret(&tctx, (unsigned char *)config.service_name,
|
||||
strlen(config.service_name)); mbedtls_md5_finish_ret(&tctx, ap_md5); #else mbedtls_md5_context
|
||||
tctx; mbedtls_md5_starts(&tctx); mbedtls_md5_update(&tctx, (unsigned char *)config.service_name,
|
||||
strlen(config.service_name)); mbedtls_md5_finish(&tctx, ap_md5); #endif #endif
|
||||
|
||||
#ifdef CONFIG_POLARSSL
|
||||
md5_context tctx;
|
||||
md5_starts(&tctx);
|
||||
md5_update(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
|
||||
md5_finish(&tctx, ap_md5);
|
||||
#endif
|
||||
|
||||
memcpy(config.hw_addr, ap_md5, sizeof(config.hw_addr));
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_METADATA
|
||||
metadata_init(); // create the metadata pipe if necessary
|
||||
#endif
|
||||
@@ -2540,12 +2511,10 @@ int main(int argc, char **argv) {
|
||||
#ifdef CONFIG_METADATA
|
||||
send_ssnc_metadata('svna', config.service_name, strlen(config.service_name), 1);
|
||||
char buffer[256] = "";
|
||||
snprintf(buffer, sizeof(buffer), "%d",
|
||||
config.output_rate);
|
||||
snprintf(buffer, sizeof(buffer), "%d", config.output_rate);
|
||||
send_ssnc_metadata('ofps', buffer, strlen(buffer), 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s",
|
||||
sps_format_description_string(config.output_format));
|
||||
send_ssnc_metadata('ofmt', buffer, strlen(buffer), 1);
|
||||
snprintf(buffer, sizeof(buffer), "%s", sps_format_description_string(config.output_format));
|
||||
send_ssnc_metadata('ofmt', buffer, strlen(buffer), 1);
|
||||
#endif
|
||||
|
||||
activity_monitor_start(); // not yet for AP2
|
||||
|
||||
Reference in New Issue
Block a user