[avahi] Problems adding a CNAME record to my device
jaf at meyersound.com
Fri Oct 15 16:08:44 PDT 2010
I'm trying to write a little program that will add mDNS CNAME aliases to my device, so that it can be accessed via more than one "something.local." domain name.
This program's intended function is the same as the Python script at the following link, but in order to avoid a Python dependency, I'm trying to implement it in C++ instead.
I've based my code (for now) on the client-publish-service.c example that is included in the Avahi source distribution. When I run that example unchanged, it works as expected: in particular, I see "MegaPrinter" show up in Bonjour Browser on my Mac, etc.
My next step is to modify the example code to add a CNAME record instead of adding services. So I #ifdef out the avahi_entry_group_add_service() calls and put this in instead:
================= BEGIN CODE ===================
const int TTL = 60;
char rdata = "\0msli-10135114\0local"; // "msli10135114.local." is the device's normal FQDN, which I want to make aliases to
rdata = 13;
rdata = 5;
printf("rdata=[%s] _moduleName=[%s]\n", rdata, _moduleName);
printf("add_record: %s\n", avahi_strerror(avahi_entry_group_add_record (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, (AvahiPublishFlags)0, "TestX", 0x01, 0x10, 120, "\5booya", 6)));
if ((ret = avahi_entry_group_add_record(
group, //AvahiEntryGroup *group,
AVAHI_IF_UNSPEC, //AvahiIfIndex interface,
AVAHI_PROTO_UNSPEC, //AvahiProtocol protocol,
(AvahiPublishFlags)0, //AvahiPublishFlags flags,
_moduleName, //const char *name,
AVAHI_DNS_CLASS_IN, //uint16_t clazz,
AVAHI_DNS_TYPE_CNAME, //uint16_t type,
TTL, //uint32_t ttl,
rdata, //const void *rdata,
sizeof(rdata) //size_t size
)) < 0)
if (ret == AVAHI_ERR_COLLISION) goto collision;
fprintf(stderr, "Failed to add module record: %s\n", avahi_strerror(ret));
================= END CODE =======================
.... but it doesn't work; in particular, running the routine only gives me this output:
add_record: Not supported
Failed to add module record: Not supported
What's strange is, not only does my own call to avahi_entry_group_add_record() fail with code AVAHI_ERR_NOT_SUPPORTED, but also my throw-away test call (inside the printf("add_record")) also fails with the same error code. But that call is copied verbatim out of the avahi-client/client-test.c file that comes with Avahi, so it seems like it should be a valid call.
Can anyone suggest why these calls might be failing, or what I am doing wrong here?
In case it helps, the complete source code for the test is here:
More information about the avahi