[avahi] Register service on other domain than local??
Versteeg Marcel (ST-CO/ENG1.4)
Marcel.Versteeg at nl.bosch.com
Fri Oct 28 01:06:43 PDT 2011
Hi all,
I am trying to register a service via Avahi on a domain other than the default .local. This causes some issues. I am running on Fedora 13 and have seen the same behavior using Avahi version 0.6.25 AND using 0.6.30 (the latest version).
In the configuration file of Avahi I do not explicitly specify a host name or a domain (these lines are commented out). Doing so will cause a registration of another service running on the same computer on the domain configured in the file. That registration needs to be done on .local otherwise it cannot be discovered by the external tools for that service.
When I run the code below, I also see that when I call avahi_entry_group_add_service that the Avahi daemon will suddenly disappear (it doesn't show up anymore when executing the ps-command) and needs to be restarted manually. It seems that I am doing a call that the daemon doesn't like. In the program below, the disappearance of the daemon is noticed by an error code -49 returned ("Not supported") by the API call.
When I change the code below and replace the parameter values "mydomain.com" and "myhost.mydomain.com" with NULL and the flags (AVAHI_PUBLISH_USE_WIDE_AREA and AVAHI_PUBLISH_USE_MULTICAST) with 0, the service "myservice._mytype._tcp.local." is registered on the network and can be resolved using Apple's Bonjour service on another computer.
Is there something I am overlooking? As I said, changing the configuration file of Avahi will cause problems with another service, but additionally, it will not solve my issue. Also when I set the host and domain in the configuration file, the Avahi daemon suddenly disappears and needs to be restarted. When the daemon disappears, there are no messages logged by Avahi in /var/log/messages.
In the code file I removed all other error detection and handling to prevent a large code file which might be harder to understand.
--------------- CODE START -------------------
#include <avahi-client/publish.h>
#include <avahi-common/error.h>
#include <avahi-common/thread-watch.h>
static AvahiThreadedPoll* g_poll = NULL;
static AvahiClient* g_client = NULL;
static AvahiEntryGroup* g_group = NULL;
void OnAvahiClientState(AvahiClient* client, AvahiClientState state, void* userdata)
{
switch (state)
{
case AVAHI_CLIENT_S_RUNNING:
if (NULL == group)
{
g_group = avahi_entry_group_new(client, OnAvahiEntryGroupState, userdata);
}
if ((NULL != group) && avahi_entry_group_is_empty(g_group))
{
int avahiError = avahi_entry_group_add_service(g_group,
AVAHI_IF_UNSPEC,
AVAHI_PUBLISH_USE_WIDE_AREA | AVAHI_PUBLISH_USE_MULTICAST,
"myservice",
"_mytype._tcp",
"mydomain.com",
"myhost.mydomain.com",
9999,
"txt=value",
NULL);
/* THIS IS WHERE avahiError IS -49 (AVAHI_ERR_NOT_SUPPORTED) */
}
}
}
void OnAvahiEntryGroupState(AvahiEntryGroup* group, AvahiEntryGroupState state, void* userdata)
{
/* NOT RELEVANT FOR THIS EXAMPLE, JUST NEEDED FOR COMPILATION ;) */
}
void main()
{
int avahiError = AVAHI_OK;
g_poll = avahi_threaded_poll_new();
g_client = avahi_client_new(avahi_threaded_poll_get(g_poll,
AVAHI_CLIENT_NO_FAIL,
OnAvahiClientState,
NULL,
&avahiError);
avahiError = avahi_threaded_poll_start(g_poll);
}
--------------- CODE END -------------------
Marcel Versteeg
Bosch Security System BV
LOB Communication Systems, Software Competence Team (ST-CO/ENG1.4)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/avahi/attachments/20111028/0094ef9a/attachment.html>
More information about the avahi
mailing list