1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| int dnssd_register_raop(dnssd_t *dnssd, const char *name, unsigned short port, const char *hwaddr, int hwaddrlen, int password) { TXTRecordRef txtRecord; char servname[MAX_SERVNAME]; int ret;
assert(dnssd); assert(name); assert(hwaddr);
dnssd->TXTRecordCreate(&txtRecord, 0, NULL); dnssd->TXTRecordSetValue(&txtRecord, "txtvers", strlen(RAOP_TXTVERS), RAOP_TXTVERS); dnssd->TXTRecordSetValue(&txtRecord, "ch", strlen(RAOP_CH), RAOP_CH); dnssd->TXTRecordSetValue(&txtRecord, "cn", strlen(RAOP_CN), RAOP_CN); dnssd->TXTRecordSetValue(&txtRecord, "et", strlen(RAOP_ET), RAOP_ET); dnssd->TXTRecordSetValue(&txtRecord, "sv", strlen(RAOP_SV), RAOP_SV); dnssd->TXTRecordSetValue(&txtRecord, "da", strlen(RAOP_DA), RAOP_DA); dnssd->TXTRecordSetValue(&txtRecord, "sr", strlen(RAOP_SR), RAOP_SR); dnssd->TXTRecordSetValue(&txtRecord, "ss", strlen(RAOP_SS), RAOP_SS); if (password) { dnssd->TXTRecordSetValue(&txtRecord, "pw", strlen("true"), "true"); } else { dnssd->TXTRecordSetValue(&txtRecord, "pw", strlen("false"), "false"); } dnssd->TXTRecordSetValue(&txtRecord, "vn", strlen(RAOP_VN), RAOP_VN); dnssd->TXTRecordSetValue(&txtRecord, "tp", strlen(RAOP_TP), RAOP_TP); dnssd->TXTRecordSetValue(&txtRecord, "md", strlen(RAOP_MD), RAOP_MD); dnssd->TXTRecordSetValue(&txtRecord, "vs", strlen(GLOBAL_VERSION), GLOBAL_VERSION); dnssd->TXTRecordSetValue(&txtRecord, "sm", strlen(RAOP_SM), RAOP_SM); dnssd->TXTRecordSetValue(&txtRecord, "ek", strlen(RAOP_EK), RAOP_EK); dnssd->TXTRecordSetValue(&txtRecord, "sf", strlen(RAOP_SF), RAOP_SF); dnssd->TXTRecordSetValue(&txtRecord, "am", strlen(GLOBAL_MODEL), GLOBAL_MODEL);
ret = utils_hwaddr_raop(servname, sizeof(servname), hwaddr, hwaddrlen); if (ret < 0) { return -1; }
if (sizeof(servname) < strlen(servname)+1+strlen(name)+1) { return -2; }
strncat(servname, "@", sizeof(servname)-strlen(servname)-1); strncat(servname, name, sizeof(servname)-strlen(servname)-1);
ret = dnssd->DNSServiceRegister(&dnssd->raopService, 0, 0, servname, "_raop._tcp", NULL, NULL, htons(port), dnssd->TXTRecordGetLength(&txtRecord), dnssd->TXTRecordGetBytesPtr(&txtRecord), MyRegisterServiceReply, NULL);
dnssd->TXTRecordDeallocate(&txtRecord); return 1; }
|