static void next_state(AvahiAnnouncement *a);
-void avahi_entry_group_check_probed(AvahiEntryGroup *g, int immediately) {
+void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately) {
AvahiEntry *e;
assert(g);
assert(!g->dead);
if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
return;
- avahi_entry_group_change_state(g, AVAHI_ENTRY_GROUP_ESTABLISHED);
+ avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_ESTABLISHED);
if (g->dead)
return;
assert(a->entry->group);
- avahi_entry_group_check_probed(a->entry->group, 1);
+ avahi_s_entry_group_check_probed(a->entry->group, 1);
} else if (a->state == AVAHI_PROBING) {
avahi_interface_monitor_walk(s->monitor, e->interface, e->protocol, announce_walk_callback, e);
}
-void avahi_announce_group(AvahiServer *s, AvahiEntryGroup *g) {
+void avahi_announce_group(AvahiServer *s, AvahiSEntryGroup *g) {
AvahiEntry *e;
assert(s);
void avahi_announce_interface(AvahiServer *s, AvahiInterface *i);
void avahi_announce_entry(AvahiServer *s, AvahiEntry *e);
-void avahi_announce_group(AvahiServer *s, AvahiEntryGroup *g);
+void avahi_announce_group(AvahiServer *s, AvahiSEntryGroup *g);
void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i);
-void avahi_entry_group_check_probed(AvahiEntryGroup *g, int immediately);
+void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately);
int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i);
int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i);
#include <avahi-core/log.h>
-static AvahiEntryGroup *group = NULL;
+static AvahiSEntryGroup *group = NULL;
static AvahiServer *server = NULL;
static char *service_name = NULL;
return 1;
}
-static void record_browser_callback(AvahiRecordBrowser *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+static void record_browser_callback(AvahiSRecordBrowser *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
char *t;
assert(r);
static void remove_entries(void);
static void create_entries(int new_name);
-static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata) {
+static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata) {
avahi_log_debug("entry group state: %i", state);
if (state == AVAHI_ENTRY_GROUP_COLLISION) {
static void remove_entries(void) {
if (group)
- avahi_entry_group_reset(group);
+ avahi_s_entry_group_reset(group);
}
static void create_entries(int new_name) {
remove_entries();
if (!group)
- group = avahi_entry_group_new(server, entry_group_callback, NULL);
+ group = avahi_s_entry_group_new(server, entry_group_callback, NULL);
- assert(avahi_entry_group_is_empty(group));
+ assert(avahi_s_entry_group_is_empty(group));
if (!service_name)
service_name = g_strdup("Test Service");
goto fail;
}
- avahi_entry_group_commit(group);
+ avahi_s_entry_group_commit(group);
return;
fail:
if (group)
- avahi_entry_group_free(group);
+ avahi_s_entry_group_free(group);
group = NULL;
}
-static void hnr_callback(AvahiHostNameResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const char *hostname, const AvahiAddress *a, void* userdata) {
+static void hnr_callback(AvahiSHostNameResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const char *hostname, const AvahiAddress *a, void* userdata) {
char t[64];
if (a)
avahi_log_debug("HNR: (%i.%i) <%s> -> %s [%s]", iface, protocol, hostname, a ? t : "n/a", event == AVAHI_RESOLVER_FOUND ? "found" : "timeout");
}
-static void ar_callback(AvahiAddressResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *a, const char *hostname, void* userdata) {
+static void ar_callback(AvahiSAddressResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *a, const char *hostname, void* userdata) {
char t[64];
avahi_address_snprint(t, sizeof(t), a);
avahi_log_debug("AR: (%i.%i) %s -> <%s> [%s]", iface, protocol, t, hostname ? hostname : "n/a", event == AVAHI_RESOLVER_FOUND ? "found" : "timeout");
}
-static void db_callback(AvahiDomainBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void* userdata) {
+static void db_callback(AvahiSDomainBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void* userdata) {
avahi_log_debug("DB: (%i.%i) <%s> [%s]", iface, protocol, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
}
-static void stb_callback(AvahiServiceTypeBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *service_type, const char *domain, void* userdata) {
+static void stb_callback(AvahiSServiceTypeBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *service_type, const char *domain, void* userdata) {
avahi_log_debug("STB: (%i.%i) %s in <%s> [%s]", iface, protocol, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
}
-static void sb_callback(AvahiServiceBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *service_type, const char *domain, void* userdata) {
+static void sb_callback(AvahiSServiceBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *service_type, const char *domain, void* userdata) {
avahi_log_debug("SB: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
}
-static void sr_callback(AvahiServiceResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char*service_type, const char*domain_name, const char*hostname, const AvahiAddress *a, uint16_t port, AvahiStringList *txt, void* userdata) {
+static void sr_callback(AvahiSServiceResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char*service_type, const char*domain_name, const char*hostname, const AvahiAddress *a, uint16_t port, AvahiStringList *txt, void* userdata) {
if (event == AVAHI_RESOLVER_TIMEOUT)
avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [timeout]", iface, protocol, name, service_type, domain_name);
}
}
-static void dsb_callback(AvahiDNSServerBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char*hostname, const AvahiAddress *a, uint16_t port, void* userdata) {
+static void dsb_callback(AvahiSDNSServerBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char*hostname, const AvahiAddress *a, uint16_t port, void* userdata) {
char t[64];
avahi_address_snprint(t, sizeof(t), a);
avahi_log_debug("DSB: (%i.%i): %s/%s:%i [%s]", iface, protocol, hostname, t, port, event == AVAHI_BROWSER_NEW ? "new" : "remove");
int main(int argc, char *argv[]) {
GMainLoop *loop = NULL;
- AvahiRecordBrowser *r;
- AvahiHostNameResolver *hnr;
- AvahiAddressResolver *ar;
+ AvahiSRecordBrowser *r;
+ AvahiSHostNameResolver *hnr;
+ AvahiSAddressResolver *ar;
AvahiKey *k;
AvahiServerConfig config;
AvahiAddress a;
- AvahiDomainBrowser *db;
- AvahiServiceTypeBrowser *stb;
- AvahiServiceBrowser *sb;
- AvahiServiceResolver *sr;
- AvahiDNSServerBrowser *dsb;
+ AvahiSDomainBrowser *db;
+ AvahiSServiceTypeBrowser *stb;
+ AvahiSServiceBrowser *sb;
+ AvahiSServiceResolver *sr;
+ AvahiSDNSServerBrowser *dsb;
AvahiGLibPoll *glib_poll;
int error;
avahi_server_config_free(&config);
k = avahi_key_new("_http._tcp.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
- r = avahi_record_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, k, record_browser_callback, NULL);
+ r = avahi_s_record_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, k, record_browser_callback, NULL);
avahi_key_unref(k);
- hnr = avahi_host_name_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "codes-CompUTER.local", AVAHI_PROTO_UNSPEC, hnr_callback, NULL);
+ hnr = avahi_s_host_name_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "codes-CompUTER.local", AVAHI_PROTO_UNSPEC, hnr_callback, NULL);
- ar = avahi_address_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, avahi_address_parse("192.168.50.15", AVAHI_PROTO_INET, &a), ar_callback, NULL);
+ ar = avahi_s_address_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, avahi_address_parse("192.168.50.15", AVAHI_PROTO_INET, &a), ar_callback, NULL);
- db = avahi_domain_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, db_callback, NULL);
+ db = avahi_s_domain_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, db_callback, NULL);
- stb = avahi_service_type_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, stb_callback, NULL);
+ stb = avahi_s_service_type_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, stb_callback, NULL);
- sb = avahi_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, sb_callback, NULL);
+ sb = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, sb_callback, NULL);
- sr = avahi_service_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "Ecstasy HTTP", "_http._tcp", "local", AVAHI_PROTO_UNSPEC, sr_callback, NULL);
+ sr = avahi_s_service_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "Ecstasy HTTP", "_http._tcp", "local", AVAHI_PROTO_UNSPEC, sr_callback, NULL);
- dsb = avahi_dns_server_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "local", AVAHI_DNS_SERVER_RESOLVE, AVAHI_PROTO_UNSPEC, dsb_callback, NULL);
+ dsb = avahi_s_dns_server_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "local", AVAHI_DNS_SERVER_RESOLVE, AVAHI_PROTO_UNSPEC, dsb_callback, NULL);
g_timeout_add(1000*5, dump_timeout, server);
g_main_loop_run(loop);
g_main_loop_unref(loop);
- avahi_record_browser_free(r);
- avahi_host_name_resolver_free(hnr);
- avahi_address_resolver_free(ar);
- avahi_service_type_browser_free(stb);
- avahi_service_browser_free(sb);
- avahi_service_resolver_free(sr);
- avahi_dns_server_browser_free(dsb);
+ avahi_s_record_browser_free(r);
+ avahi_s_host_name_resolver_free(hnr);
+ avahi_s_address_resolver_free(ar);
+ avahi_s_service_type_browser_free(stb);
+ avahi_s_service_browser_free(sb);
+ avahi_s_service_resolver_free(sr);
+ avahi_s_dns_server_browser_free(dsb);
if (group)
- avahi_entry_group_free(group);
+ avahi_s_entry_group_free(group);
if (server)
avahi_server_free(server);
typedef struct AvahiDNSServerInfo AvahiDNSServerInfo;
struct AvahiDNSServerInfo {
- AvahiDNSServerBrowser *browser;
+ AvahiSDNSServerBrowser *browser;
AvahiIfIndex interface;
AvahiProtocol protocol;
AvahiRecord *srv_record;
- AvahiHostNameResolver *host_name_resolver;
+ AvahiSHostNameResolver *host_name_resolver;
AvahiAddress address;
AVAHI_LLIST_FIELDS(AvahiDNSServerInfo, info);
};
-struct AvahiDNSServerBrowser {
+struct AvahiSDNSServerBrowser {
AvahiServer *server;
char *domain_name;
- AvahiRecordBrowser *record_browser;
- AvahiDNSServerBrowserCallback callback;
+ AvahiSRecordBrowser *record_browser;
+ AvahiSDNSServerBrowserCallback callback;
void* userdata;
AvahiProtocol aprotocol;
unsigned n_info;
- AVAHI_LLIST_FIELDS(AvahiDNSServerBrowser, browser);
+ AVAHI_LLIST_FIELDS(AvahiSDNSServerBrowser, browser);
AVAHI_LLIST_HEAD(AvahiDNSServerInfo, info);
};
-static AvahiDNSServerInfo* get_server_info(AvahiDNSServerBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r) {
+static AvahiDNSServerInfo* get_server_info(AvahiSDNSServerBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r) {
AvahiDNSServerInfo *i;
assert(b);
return NULL;
}
-static void server_info_free(AvahiDNSServerBrowser *b, AvahiDNSServerInfo *i) {
+static void server_info_free(AvahiSDNSServerBrowser *b, AvahiDNSServerInfo *i) {
assert(b);
assert(i);
avahi_record_unref(i->srv_record);
if (i->host_name_resolver)
- avahi_host_name_resolver_free(i->host_name_resolver);
+ avahi_s_host_name_resolver_free(i->host_name_resolver);
AVAHI_LLIST_REMOVE(AvahiDNSServerInfo, info, b->info, i);
avahi_free(i);
}
-static void host_name_resolver_callback(AvahiHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, void* userdata) {
+static void host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, void* userdata) {
AvahiDNSServerInfo *i = userdata;
assert(r);
i->browser->callback(i->browser, i->interface, i->protocol, AVAHI_BROWSER_NEW, i->srv_record->data.srv.name, &i->address, i->srv_record->data.srv.port, i->browser->userdata);
}
- avahi_host_name_resolver_free(i->host_name_resolver);
+ avahi_s_host_name_resolver_free(i->host_name_resolver);
i->host_name_resolver = NULL;
}
-static void record_browser_callback(AvahiRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
- AvahiDNSServerBrowser *b = userdata;
+static void record_browser_callback(AvahiSRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+ AvahiSDNSServerBrowser *b = userdata;
assert(rr);
assert(record);
i->interface = interface;
i->protocol = protocol;
i->srv_record = avahi_record_ref(record);
- i->host_name_resolver = avahi_host_name_resolver_new(b->server, interface, protocol, record->data.srv.name, b->aprotocol, host_name_resolver_callback, i);
+ i->host_name_resolver = avahi_s_host_name_resolver_new(b->server, interface, protocol, record->data.srv.name, b->aprotocol, host_name_resolver_callback, i);
AVAHI_LLIST_PREPEND(AvahiDNSServerInfo, info, b->info, i);
}
}
-AvahiDNSServerBrowser *avahi_dns_server_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, AvahiDNSServerType type, AvahiProtocol aprotocol, AvahiDNSServerBrowserCallback callback, void* userdata) {
- AvahiDNSServerBrowser *b;
+AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, AvahiDNSServerType type, AvahiProtocol aprotocol, AvahiSDNSServerBrowserCallback callback, void* userdata) {
+ AvahiSDNSServerBrowser *b;
AvahiKey *k;
char *n = NULL;
return NULL;
}
- if (!(b = avahi_new(AvahiDNSServerBrowser, 1))) {
+ if (!(b = avahi_new(AvahiSDNSServerBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
b->n_info = 0;
AVAHI_LLIST_HEAD_INIT(AvahiDNSServerInfo, b->info);
- AVAHI_LLIST_PREPEND(AvahiDNSServerBrowser, browser, server->dns_server_browsers, b);
+ AVAHI_LLIST_PREPEND(AvahiSDNSServerBrowser, browser, server->dns_server_browsers, b);
n = avahi_strdup_printf("%s.%s",type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", b->domain_name);
k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV);
avahi_free(n);
- b->record_browser = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
+ b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
avahi_key_unref(k);
if (!b->record_browser) {
- avahi_dns_server_browser_free(b);
+ avahi_s_dns_server_browser_free(b);
return NULL;
}
return b;
}
-void avahi_dns_server_browser_free(AvahiDNSServerBrowser *b) {
+void avahi_s_dns_server_browser_free(AvahiSDNSServerBrowser *b) {
assert(b);
while (b->info)
server_info_free(b, b->info);
- AVAHI_LLIST_REMOVE(AvahiDNSServerBrowser, browser, b->server->dns_server_browsers, b);
+ AVAHI_LLIST_REMOVE(AvahiSDNSServerBrowser, browser, b->server->dns_server_browsers, b);
if (b->record_browser)
- avahi_record_browser_free(b->record_browser);
+ avahi_s_record_browser_free(b->record_browser);
avahi_free(b->domain_name);
avahi_free(b);
}
#include "browse.h"
-struct AvahiDomainBrowser {
+struct AvahiSDomainBrowser {
AvahiServer *server;
char *domain_name;
- AvahiRecordBrowser *record_browser;
+ AvahiSRecordBrowser *record_browser;
- AvahiDomainBrowserCallback callback;
+ AvahiSDomainBrowserCallback callback;
void* userdata;
- AVAHI_LLIST_FIELDS(AvahiDomainBrowser, browser);
+ AVAHI_LLIST_FIELDS(AvahiSDomainBrowser, browser);
};
-static void record_browser_callback(AvahiRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
- AvahiDomainBrowser *b = userdata;
+static void record_browser_callback(AvahiSRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+ AvahiSDomainBrowser *b = userdata;
char *n;
assert(rr);
avahi_free(n);
}
-AvahiDomainBrowser *avahi_domain_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, AvahiDomainBrowserType type, AvahiDomainBrowserCallback callback, void* userdata) {
- AvahiDomainBrowser *b;
+AvahiSDomainBrowser *avahi_s_domain_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, AvahiDomainBrowserType type, AvahiSDomainBrowserCallback callback, void* userdata) {
+ AvahiSDomainBrowser *b;
AvahiKey *k;
char *n = NULL;
return NULL;
}
- if (!(b = avahi_new(AvahiDomainBrowser, 1))) {
+ if (!(b = avahi_new(AvahiSDomainBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
b->callback = callback;
b->userdata = userdata;
- AVAHI_LLIST_PREPEND(AvahiDomainBrowser, browser, server->domain_browsers, b);
+ AVAHI_LLIST_PREPEND(AvahiSDomainBrowser, browser, server->domain_browsers, b);
switch (type) {
case AVAHI_DOMAIN_BROWSER_BROWSE:
k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
avahi_free(n);
- b->record_browser = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
+ b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
avahi_key_unref(k);
if (!b->record_browser) {
- avahi_domain_browser_free(b);
+ avahi_s_domain_browser_free(b);
return NULL;
}
return b;
}
-void avahi_domain_browser_free(AvahiDomainBrowser *b) {
+void avahi_s_domain_browser_free(AvahiSDomainBrowser *b) {
assert(b);
- AVAHI_LLIST_REMOVE(AvahiDomainBrowser, browser, b->server->domain_browsers, b);
+ AVAHI_LLIST_REMOVE(AvahiSDomainBrowser, browser, b->server->domain_browsers, b);
if (b->record_browser)
- avahi_record_browser_free(b->record_browser);
+ avahi_s_record_browser_free(b->record_browser);
avahi_free(b->domain_name);
avahi_free(b);
#include "browse.h"
#include "log.h"
-struct AvahiServiceTypeBrowser {
+struct AvahiSServiceTypeBrowser {
AvahiServer *server;
char *domain_name;
- AvahiRecordBrowser *record_browser;
+ AvahiSRecordBrowser *record_browser;
- AvahiServiceTypeBrowserCallback callback;
+ AvahiSServiceTypeBrowserCallback callback;
void* userdata;
- AVAHI_LLIST_FIELDS(AvahiServiceTypeBrowser, browser);
+ AVAHI_LLIST_FIELDS(AvahiSServiceTypeBrowser, browser);
};
-static void record_browser_callback(AvahiRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
- AvahiServiceTypeBrowser *b = userdata;
+static void record_browser_callback(AvahiSRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+ AvahiSServiceTypeBrowser *b = userdata;
char *n, *e, *c;
assert(rr);
avahi_free(n);
}
-AvahiServiceTypeBrowser *avahi_service_type_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, AvahiServiceTypeBrowserCallback callback, void* userdata) {
- AvahiServiceTypeBrowser *b;
+AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, AvahiSServiceTypeBrowserCallback callback, void* userdata) {
+ AvahiSServiceTypeBrowser *b;
AvahiKey *k;
char *n = NULL;
return NULL;
}
- if (!(b = avahi_new(AvahiServiceTypeBrowser, 1))) {
+ if (!(b = avahi_new(AvahiSServiceTypeBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
b->callback = callback;
b->userdata = userdata;
- AVAHI_LLIST_PREPEND(AvahiServiceTypeBrowser, browser, server->service_type_browsers, b);
+ AVAHI_LLIST_PREPEND(AvahiSServiceTypeBrowser, browser, server->service_type_browsers, b);
n = avahi_strdup_printf("_services._dns-sd._udp.%s", b->domain_name);
k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
avahi_free(n);
- b->record_browser = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
+ b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
avahi_key_unref(k);
if (!b->record_browser)
return b;
}
-void avahi_service_type_browser_free(AvahiServiceTypeBrowser *b) {
+void avahi_s_service_type_browser_free(AvahiSServiceTypeBrowser *b) {
assert(b);
- AVAHI_LLIST_REMOVE(AvahiServiceTypeBrowser, browser, b->server->service_type_browsers, b);
+ AVAHI_LLIST_REMOVE(AvahiSServiceTypeBrowser, browser, b->server->service_type_browsers, b);
if (b->record_browser)
- avahi_record_browser_free(b->record_browser);
+ avahi_s_record_browser_free(b->record_browser);
avahi_free(b->domain_name);
avahi_free(b);
#include "browse.h"
#include "log.h"
-struct AvahiServiceBrowser {
+struct AvahiSServiceBrowser {
AvahiServer *server;
char *domain_name;
char *service_type;
- AvahiRecordBrowser *record_browser;
+ AvahiSRecordBrowser *record_browser;
- AvahiServiceBrowserCallback callback;
+ AvahiSServiceBrowserCallback callback;
void* userdata;
- AVAHI_LLIST_FIELDS(AvahiServiceBrowser, browser);
+ AVAHI_LLIST_FIELDS(AvahiSServiceBrowser, browser);
};
-static void record_browser_callback(AvahiRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
- AvahiServiceBrowser *b = userdata;
+static void record_browser_callback(AvahiSRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+ AvahiSServiceBrowser *b = userdata;
char *n, *e, *c, *s;
char service[128];
avahi_free(n);
}
-AvahiServiceBrowser *avahi_service_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *service_type, const char *domain, AvahiServiceBrowserCallback callback, void* userdata) {
- AvahiServiceBrowser *b;
+AvahiSServiceBrowser *avahi_s_service_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *service_type, const char *domain, AvahiSServiceBrowserCallback callback, void* userdata) {
+ AvahiSServiceBrowser *b;
AvahiKey *k;
char *n = NULL;
return NULL;
}
- if (!(b = avahi_new(AvahiServiceBrowser, 1))) {
+ if (!(b = avahi_new(AvahiSServiceBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
b->service_type = avahi_normalize_name(service_type);
b->callback = callback;
b->userdata = userdata;
- AVAHI_LLIST_PREPEND(AvahiServiceBrowser, browser, server->service_browsers, b);
+ AVAHI_LLIST_PREPEND(AvahiSServiceBrowser, browser, server->service_browsers, b);
n = avahi_strdup_printf("%s.%s", b->service_type, b->domain_name);
k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
avahi_free(n);
- b->record_browser = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
+ b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, b);
avahi_key_unref(k);
if (!b->record_browser) {
- avahi_service_browser_free(b);
+ avahi_s_service_browser_free(b);
return NULL;
}
return b;
}
-void avahi_service_browser_free(AvahiServiceBrowser *b) {
+void avahi_s_service_browser_free(AvahiSServiceBrowser *b) {
assert(b);
- AVAHI_LLIST_REMOVE(AvahiServiceBrowser, browser, b->server->service_browsers, b);
+ AVAHI_LLIST_REMOVE(AvahiSServiceBrowser, browser, b->server->service_browsers, b);
if (b->record_browser)
- avahi_record_browser_free(b->record_browser);
+ avahi_s_record_browser_free(b->record_browser);
avahi_free(b->domain_name);
avahi_free(b->service_type);
#include "browse.h"
#include "log.h"
-struct AvahiRecordBrowser {
+struct AvahiSRecordBrowser {
int dead;
AvahiServer *server;
AvahiTimeEvent *query_time_event;
AvahiTimeEvent *scan_time_event;
- AvahiRecordBrowserCallback callback;
+ AvahiSRecordBrowserCallback callback;
void* userdata;
- AVAHI_LLIST_FIELDS(AvahiRecordBrowser, browser);
- AVAHI_LLIST_FIELDS(AvahiRecordBrowser, by_key);
+ AVAHI_LLIST_FIELDS(AvahiSRecordBrowser, browser);
+ AVAHI_LLIST_FIELDS(AvahiSRecordBrowser, by_key);
};
static void elapse_callback(AvahiTimeEvent *e, void *userdata) {
- AvahiRecordBrowser *s = userdata;
+ AvahiSRecordBrowser *s = userdata;
struct timeval tv;
/* char *t; */
}
struct cbdata {
- AvahiRecordBrowser *record_browser;
+ AvahiSRecordBrowser *record_browser;
AvahiInterface *interface;
};
}
static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
- AvahiRecordBrowser *b = userdata;
+ AvahiSRecordBrowser *b = userdata;
struct cbdata cbdata = { b, i };
assert(m);
}
static void scan_callback(AvahiTimeEvent *e, void *userdata) {
- AvahiRecordBrowser *b = userdata;
+ AvahiSRecordBrowser *b = userdata;
assert(b);
/* Scan the caches */
}
}
-AvahiRecordBrowser *avahi_record_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key, AvahiRecordBrowserCallback callback, void* userdata) {
- AvahiRecordBrowser *b, *t;
+AvahiSRecordBrowser *avahi_s_record_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key, AvahiSRecordBrowserCallback callback, void* userdata) {
+ AvahiSRecordBrowser *b, *t;
struct timeval tv;
assert(server);
return NULL;
}
- if (!(b = avahi_new(AvahiRecordBrowser, 1))) {
+ if (!(b = avahi_new(AvahiSRecordBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
avahi_elapse_time(&tv, b->sec_delay*1000, 0);
b->query_time_event = avahi_time_event_new(server->time_event_queue, &tv, elapse_callback, b);
- AVAHI_LLIST_PREPEND(AvahiRecordBrowser, browser, server->record_browsers, b);
+ AVAHI_LLIST_PREPEND(AvahiSRecordBrowser, browser, server->record_browsers, b);
/* Add the new entry to the record_browser hash table */
t = avahi_hashmap_lookup(server->record_browser_hashmap, key);
- AVAHI_LLIST_PREPEND(AvahiRecordBrowser, by_key, t, b);
+ AVAHI_LLIST_PREPEND(AvahiSRecordBrowser, by_key, t, b);
avahi_hashmap_replace(server->record_browser_hashmap, key, t);
/* The currenlty cached entries are scanned a bit later */
return b;
}
-void avahi_record_browser_free(AvahiRecordBrowser *b) {
+void avahi_s_record_browser_free(AvahiSRecordBrowser *b) {
assert(b);
assert(!b->dead);
}
}
-void avahi_record_browser_destroy(AvahiRecordBrowser *b) {
- AvahiRecordBrowser *t;
+void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) {
+ AvahiSRecordBrowser *t;
assert(b);
- AVAHI_LLIST_REMOVE(AvahiRecordBrowser, browser, b->server->record_browsers, b);
+ AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, browser, b->server->record_browsers, b);
t = avahi_hashmap_lookup(b->server->record_browser_hashmap, b->key);
- AVAHI_LLIST_REMOVE(AvahiRecordBrowser, by_key, t, b);
+ AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, by_key, t, b);
if (t)
avahi_hashmap_replace(b->server->record_browser_hashmap, t->key, t);
else
}
void avahi_browser_cleanup(AvahiServer *server) {
- AvahiRecordBrowser *b;
- AvahiRecordBrowser *n;
+ AvahiSRecordBrowser *b;
+ AvahiSRecordBrowser *n;
assert(server);
n = b->browser_next;
if (b->dead)
- avahi_record_browser_destroy(b);
+ avahi_s_record_browser_destroy(b);
}
server->need_browser_cleanup = 0;
}
void avahi_browser_notify(AvahiServer *server, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event) {
- AvahiRecordBrowser *b;
+ AvahiSRecordBrowser *b;
assert(server);
assert(record);
}
int avahi_is_subscribed(AvahiServer *server, AvahiInterface *i, AvahiKey *k) {
- AvahiRecordBrowser *b;
+ AvahiSRecordBrowser *b;
assert(server);
assert(k);
}
void avahi_browser_new_interface(AvahiServer*s, AvahiInterface *i) {
- AvahiRecordBrowser *b;
+ AvahiSRecordBrowser *b;
assert(s);
assert(i);
int avahi_is_subscribed(AvahiServer *s, AvahiInterface *i, AvahiKey *k);
-void avahi_record_browser_destroy(AvahiRecordBrowser *b);
+void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b);
void avahi_browser_new_interface(AvahiServer*s, AvahiInterface *i);
#include "log.h"
static char *name = NULL;
-static AvahiEntryGroup *group = NULL;
+static AvahiSEntryGroup *group = NULL;
static int try = 0;
static AvahiServer *avahi = NULL;
return 1;
}
-static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
+static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata);
static void create_service(const char *t) {
char *n;
name = n;
if (group)
- avahi_entry_group_reset(group);
+ avahi_s_entry_group_reset(group);
else
- group = avahi_entry_group_new(avahi, entry_group_callback, NULL);
+ group = avahi_s_entry_group_new(avahi, entry_group_callback, NULL);
avahi_server_add_service(avahi, group, 0, AF_UNSPEC, name, "_http._tcp", NULL, NULL, 80, "foo", NULL);
- avahi_entry_group_commit(group);
+ avahi_s_entry_group_commit(group);
try++;
}
return 1;
}
-static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata) {
+static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata) {
if (state == AVAHI_ENTRY_GROUP_COLLISION)
create_service(NULL);
else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
g_main_loop_unref(loop);
if (group)
- avahi_entry_group_free(group);
+ avahi_s_entry_group_free(group);
avahi_server_free(avahi);
avahi_glib_poll_free(glib_poll);
/** An mDNS responder object */
typedef struct AvahiServer AvahiServer;
-/** A locally registered DNS resource record */
-typedef struct AvahiEntry AvahiEntry;
-
/** A group of locally registered DNS RRs */
-typedef struct AvahiEntryGroup AvahiEntryGroup;
+typedef struct AvahiSEntryGroup AvahiSEntryGroup;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
AVAHI_C_DECL_END
/** Prototype for callback functions which are called whenever the state of an AvahiServer object changes */
typedef void (*AvahiServerCallback) (AvahiServer *s, AvahiServerState state, void* userdata);
-/** Prototype for callback functions which are called whenever the state of an AvahiEntryGroup object changes */
-typedef void (*AvahiEntryGroupCallback) (AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
+/** Prototype for callback functions which are called whenever the state of an AvahiSEntryGroup object changes */
+typedef void (*AvahiSEntryGroupCallback) (AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata);
/** Stores configuration options for a server instance */
typedef struct AvahiServerConfig {
* the current iteration. It is not safe to call any other
* avahi_server_xxx() function during the iteration. If the last entry
* has been read, NULL is returned. */
-const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiEntryGroup *g, void **state);
+const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, void **state);
/** Callback prototype for avahi_server_dump() */
typedef void (*AvahiDumpCallback)(const char *text, void* userdata);
/** Create a new entry group. The specified callback function is
* called whenever the state of the group changes. Use entry group
* objects to keep track of you RRs. Add new RRs to a group using
- * avahi_server_add_xxx(). Make sure to call avahi_entry_group_commit()
+ * avahi_server_add_xxx(). Make sure to call avahi_s_entry_group_commit()
* to start the registration process for your RRs */
-AvahiEntryGroup *avahi_entry_group_new(AvahiServer *s, AvahiEntryGroupCallback callback, void* userdata);
+AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallback callback, void* userdata);
/** Free an entry group. All RRs assigned to the group are removed from the server */
-void avahi_entry_group_free(AvahiEntryGroup *g);
+void avahi_s_entry_group_free(AvahiSEntryGroup *g);
/** Commit an entry group. This starts the probing and registration process for all RRs in the group */
-int avahi_entry_group_commit(AvahiEntryGroup *g);
+int avahi_s_entry_group_commit(AvahiSEntryGroup *g);
/** Remove all entries from the entry group and reset the state to AVAHI_ENTRY_GROUP_UNCOMMITED. */
-void avahi_entry_group_reset(AvahiEntryGroup *g);
+void avahi_s_entry_group_reset(AvahiSEntryGroup *g);
/** Return 1 if the entry group is empty, i.e. has no records attached. */
-int avahi_entry_group_is_empty(AvahiEntryGroup *g);
+int avahi_s_entry_group_is_empty(AvahiSEntryGroup *g);
/** Return the current state of the specified entry group */
-AvahiEntryGroupState avahi_entry_group_get_state(AvahiEntryGroup *g);
+AvahiEntryGroupState avahi_s_entry_group_get_state(AvahiSEntryGroup *g);
/** Change the opaque user data pointer attached to an entry group object */
-void avahi_entry_group_set_data(AvahiEntryGroup *g, void* userdata);
+void avahi_s_entry_group_set_data(AvahiSEntryGroup *g, void* userdata);
/** Return the opaque user data pointer currently set for the entry group object */
-void* avahi_entry_group_get_data(AvahiEntryGroup *g);
+void* avahi_s_entry_group_get_data(AvahiSEntryGroup *g);
/** Add a new resource record to the server. Returns 0 on success, negative otherwise. */
int avahi_server_add(
AvahiServer *s, /**< The server object to add this record to */
- AvahiEntryGroup *g, /**< An entry group object if this new record shall be attached to one, or NULL. If you plan to remove the record sometime later you a required to pass an entry group object here. */
+ AvahiSEntryGroup *g, /**< An entry group object if this new record shall be attached to one, or NULL. If you plan to remove the record sometime later you a required to pass an entry group object here. */
AvahiIfIndex interface, /**< A numeric index of a network interface to attach this record to, or AVAHI_IF_UNSPEC to attach this record to all interfaces */
AvahiProtocol protocol, /**< A protocol family to attach this record to. One of the AVAHI_PROTO_xxx constants. Use AVAHI_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */
AvahiEntryFlags flags, /**< Special flags for this record */
/** Add a PTR RR to the server. See avahi_server_add() for more information. */
int avahi_server_add_ptr(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
/** Add a PTR RR to the server. See avahi_server_add() for more information. */
int avahi_server_add_txt(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
* number of arguments */
int avahi_server_add_txt_va(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
* number of arguments. */
int avahi_server_add_txt_strlst(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
* avahi_server_add() for more information. If adding one of the RRs
* fails, the function returns with an error, but it is not defined if
* the other RR is deleted from the server or not. Therefore, you have
- * to free the AvahiEntryGroup and create a new one before
+ * to free the AvahiSEntryGroup and create a new one before
* proceeding. */
int avahi_server_add_address(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
* RRs to the server. See avahi_server_add() for more information. If
* adding one of the RRs fails, the function returns with an error,
* but it is not defined if the other RR is deleted from the server or
- * not. Therefore, you have to free the AvahiEntryGroup and create a
+ * not. Therefore, you have to free the AvahiSEntryGroup and create a
* new one before proceeding. */
int avahi_server_add_service(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *name, /**< Service name, e.g. "Lennart's Files" */
/** Mostly identical to avahi_server_add_service(), but takes an va_list for the TXT records. */
int avahi_server_add_service_va(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *name,
/** Mostly identical to avahi_server_add_service(), but takes an AvahiStringList object for the TXT records. The AvahiStringList object is copied. */
int avahi_server_add_service_strlst(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *name,
/** Publish the specified unicast DNS server address via mDNS. You may
* browse for records create this way wit
- * avahi_dns_server_browser_new(). */
+ * avahi_s_dns_server_browser_new(). */
int avahi_server_add_dns_server_address(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
resolvable via mDNS */
int avahi_server_add_dns_server_name(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
uint16_t port /** should be 53 */);
/** A browsing object for arbitrary RRs */
-typedef struct AvahiRecordBrowser AvahiRecordBrowser;
+typedef struct AvahiSRecordBrowser AvahiSRecordBrowser;
-/** Callback prototype for AvahiRecordBrowser events */
-typedef void (*AvahiRecordBrowserCallback)(
- AvahiRecordBrowser *b, /**< The AvahiRecordBrowser object that is emitting this callback */
+/** Callback prototype for AvahiSRecordBrowser events */
+typedef void (*AvahiSRecordBrowserCallback)(
+ AvahiSRecordBrowser *b, /**< The AvahiSRecordBrowser object that is emitting this callback */
AvahiIfIndex interface, /**< Logical OS network interface number the record was found on */
AvahiProtocol protocol, /**< Protocol number the record was found. */
AvahiBrowserEvent event, /**< Browsing event, either AVAHI_BROWSER_NEW or AVAHI_BROWSER_REMOVE */
AvahiRecord *record, /**< The record that was found */
- void* userdata /**< Arbitrary user data passed to avahi_record_browser_new() */ );
+ void* userdata /**< Arbitrary user data passed to avahi_s_record_browser_new() */ );
/** Create a new browsing object for arbitrary RRs */
-AvahiRecordBrowser *avahi_record_browser_new(
+AvahiSRecordBrowser *avahi_s_record_browser_new(
AvahiServer *server, /**< The server object to which attach this query */
AvahiIfIndex interface, /**< Logical OS interface number where to look for the records, or AVAHI_IF_UNSPEC to look on interfaces */
AvahiProtocol protocol, /**< Protocol number to use when looking for the record, or AVAHI_PROTO_UNSPEC to look on all protocols */
AvahiKey *key, /**< The search key */
- AvahiRecordBrowserCallback callback, /**< The callback to call on browsing events */
+ AvahiSRecordBrowserCallback callback, /**< The callback to call on browsing events */
void* userdata /**< Arbitrary use suppliable data which is passed to the callback */);
-/** Free an AvahiRecordBrowser object */
-void avahi_record_browser_free(AvahiRecordBrowser *b);
+/** Free an AvahiSRecordBrowser object */
+void avahi_s_record_browser_free(AvahiSRecordBrowser *b);
/** A host name to IP adddress resolver object */
-typedef struct AvahiHostNameResolver AvahiHostNameResolver;
+typedef struct AvahiSHostNameResolver AvahiSHostNameResolver;
-/** Callback prototype for AvahiHostNameResolver events */
-typedef void (*AvahiHostNameResolverCallback)(
- AvahiHostNameResolver *r,
+/** Callback prototype for AvahiSHostNameResolver events */
+typedef void (*AvahiSHostNameResolverCallback)(
+ AvahiSHostNameResolver *r,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiResolverEvent event, /**< Resolving event */
const AvahiAddress *a, /**< The address, or NULL if the host name couldn't be resolved. */
void* userdata);
-/** Create an AvahiHostNameResolver object for resolving a host name to an adddress. See AvahiRecordBrowser for more info on the paramters. */
-AvahiHostNameResolver *avahi_host_name_resolver_new(
+/** Create an AvahiSHostNameResolver object for resolving a host name to an adddress. See AvahiSRecordBrowser for more info on the paramters. */
+AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
AvahiServer *server,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *host_name, /**< The host name to look for */
AvahiProtocol aprotocol, /**< The address family of the desired address or AVAHI_PROTO_UNSPEC if doesn't matter. */
- AvahiHostNameResolverCallback calback,
+ AvahiSHostNameResolverCallback calback,
void* userdata);
-/** Free a AvahiHostNameResolver object */
-void avahi_host_name_resolver_free(AvahiHostNameResolver *r);
+/** Free a AvahiSHostNameResolver object */
+void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r);
/** An IP address to host name resolver object ("reverse lookup") */
-typedef struct AvahiAddressResolver AvahiAddressResolver;
+typedef struct AvahiSAddressResolver AvahiSAddressResolver;
-/** Callback prototype for AvahiAddressResolver events */
-typedef void (*AvahiAddressResolverCallback)(
- AvahiAddressResolver *r,
+/** Callback prototype for AvahiSAddressResolver events */
+typedef void (*AvahiSAddressResolverCallback)(
+ AvahiSAddressResolver *r,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiResolverEvent event,
const char *host_name, /**< A host name for the specified address, if one was found, i.e. event == AVAHI_RESOLVER_FOUND */
void* userdata);
-/** Create an AvahiAddressResolver object. See AvahiRecordBrowser for more info on the paramters. */
-AvahiAddressResolver *avahi_address_resolver_new(
+/** Create an AvahiSAddressResolver object. See AvahiSRecordBrowser for more info on the paramters. */
+AvahiSAddressResolver *avahi_s_address_resolver_new(
AvahiServer *server,
AvahiIfIndex interface,
AvahiProtocol protocol,
const AvahiAddress *address,
- AvahiAddressResolverCallback calback,
+ AvahiSAddressResolverCallback calback,
void* userdata);
-/** Free an AvahiAddressResolver object */
-void avahi_address_resolver_free(AvahiAddressResolver *r);
+/** Free an AvahiSAddressResolver object */
+void avahi_s_address_resolver_free(AvahiSAddressResolver *r);
/** A local domain browsing object. May be used to enumerate domains used on the local LAN */
-typedef struct AvahiDomainBrowser AvahiDomainBrowser;
+typedef struct AvahiSDomainBrowser AvahiSDomainBrowser;
-/** Callback prototype for AvahiDomainBrowser events */
-typedef void (*AvahiDomainBrowserCallback)(
- AvahiDomainBrowser *b,
+/** Callback prototype for AvahiSDomainBrowser events */
+typedef void (*AvahiSDomainBrowserCallback)(
+ AvahiSDomainBrowser *b,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiBrowserEvent event,
const char *domain,
void* userdata);
-/** Create a new AvahiDomainBrowser object */
-AvahiDomainBrowser *avahi_domain_browser_new(
+/** Create a new AvahiSDomainBrowser object */
+AvahiSDomainBrowser *avahi_s_domain_browser_new(
AvahiServer *server,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
AvahiDomainBrowserType type,
- AvahiDomainBrowserCallback callback,
+ AvahiSDomainBrowserCallback callback,
void* userdata);
-/** Free an AvahiDomainBrowser object */
-void avahi_domain_browser_free(AvahiDomainBrowser *b);
+/** Free an AvahiSDomainBrowser object */
+void avahi_s_domain_browser_free(AvahiSDomainBrowser *b);
/** A DNS-SD service type browsing object. May be used to enumerate the service types of all available services on the local LAN */
-typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
+typedef struct AvahiSServiceTypeBrowser AvahiSServiceTypeBrowser;
-/** Callback prototype for AvahiServiceTypeBrowser events */
-typedef void (*AvahiServiceTypeBrowserCallback)(
- AvahiServiceTypeBrowser *b,
+/** Callback prototype for AvahiSServiceTypeBrowser events */
+typedef void (*AvahiSServiceTypeBrowserCallback)(
+ AvahiSServiceTypeBrowser *b,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiBrowserEvent event,
const char *domain,
void* userdata);
-/** Create a new AvahiServiceTypeBrowser object. */
-AvahiServiceTypeBrowser *avahi_service_type_browser_new(
+/** Create a new AvahiSServiceTypeBrowser object. */
+AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
AvahiServer *server,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
- AvahiServiceTypeBrowserCallback callback,
+ AvahiSServiceTypeBrowserCallback callback,
void* userdata);
-/** Free an AvahiServiceTypeBrowser object */
-void avahi_service_type_browser_free(AvahiServiceTypeBrowser *b);
+/** Free an AvahiSServiceTypeBrowser object */
+void avahi_s_service_type_browser_free(AvahiSServiceTypeBrowser *b);
-/** A DNS-SD service browser. Use this to enumerate available services of a certain kind on the local LAN. Use AvahiServiceResolver to get specific service data like address and port for a service. */
-typedef struct AvahiServiceBrowser AvahiServiceBrowser;
+/** A DNS-SD service browser. Use this to enumerate available services of a certain kind on the local LAN. Use AvahiSServiceResolver to get specific service data like address and port for a service. */
+typedef struct AvahiSServiceBrowser AvahiSServiceBrowser;
-/** Callback prototype for AvahiServiceBrowser events */
-typedef void (*AvahiServiceBrowserCallback)(
- AvahiServiceBrowser *b,
+/** Callback prototype for AvahiSServiceBrowser events */
+typedef void (*AvahiSServiceBrowserCallback)(
+ AvahiSServiceBrowser *b,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiBrowserEvent event,
const char *domain /**< Domain of this service, e.g. "local" */,
void* userdata);
-/** Create a new AvahiServiceBrowser object. */
-AvahiServiceBrowser *avahi_service_browser_new(
+/** Create a new AvahiSServiceBrowser object. */
+AvahiSServiceBrowser *avahi_s_service_browser_new(
AvahiServer *server,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *service_type /** DNS-SD service type, e.g. "_http._tcp" */,
const char *domain,
- AvahiServiceBrowserCallback callback,
+ AvahiSServiceBrowserCallback callback,
void* userdata);
-/** Free an AvahiServiceBrowser object */
-void avahi_service_browser_free(AvahiServiceBrowser *b);
+/** Free an AvahiSServiceBrowser object */
+void avahi_s_service_browser_free(AvahiSServiceBrowser *b);
/** A DNS-SD service resolver. Use this to retrieve addres, port and TXT data for a DNS-SD service */
-typedef struct AvahiServiceResolver AvahiServiceResolver;
+typedef struct AvahiSServiceResolver AvahiSServiceResolver;
-/** Callback prototype for AvahiServiceResolver events */
-typedef void (*AvahiServiceResolverCallback)(
- AvahiServiceResolver *r,
+/** Callback prototype for AvahiSServiceResolver events */
+typedef void (*AvahiSServiceResolverCallback)(
+ AvahiSServiceResolver *r,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiResolverEvent event,
AvahiStringList *txt, /**< TXT record data */
void* userdata);
-/** Create a new AvahiServiceResolver object */
-AvahiServiceResolver *avahi_service_resolver_new(
+/** Create a new AvahiSServiceResolver object */
+AvahiSServiceResolver *avahi_s_service_resolver_new(
AvahiServer *server,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *type,
const char *domain,
AvahiProtocol aprotocol, /**< Address family of the desired service address. Use AVAHI_PROTO_UNSPEC if you don't care */
- AvahiServiceResolverCallback calback,
+ AvahiSServiceResolverCallback calback,
void* userdata);
-/** Free an AvahiServiceResolver object */
-void avahi_service_resolver_free(AvahiServiceResolver *r);
+/** Free an AvahiSServiceResolver object */
+void avahi_s_service_resolver_free(AvahiSServiceResolver *r);
/** A domain service browser object. Use this to browse for
* conventional unicast DNS servers which may be used to resolve
* conventional domain names */
-typedef struct AvahiDNSServerBrowser AvahiDNSServerBrowser;
+typedef struct AvahiSDNSServerBrowser AvahiSDNSServerBrowser;
-/** Callback prototype for AvahiDNSServerBrowser events */
-typedef void (*AvahiDNSServerBrowserCallback)(
- AvahiDNSServerBrowser *b,
+/** Callback prototype for AvahiSDNSServerBrowser events */
+typedef void (*AvahiSDNSServerBrowserCallback)(
+ AvahiSDNSServerBrowser *b,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiBrowserEvent event,
uint16_t port, /**< Port number of the DNS servers, probably 53 */
void* userdata);
-/** Create a new AvahiDNSServerBrowser object */
-AvahiDNSServerBrowser *avahi_dns_server_browser_new(
+/** Create a new AvahiSDNSServerBrowser object */
+AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(
AvahiServer *server,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
AvahiDNSServerType type,
AvahiProtocol aprotocol, /**< Address protocol for the DNS server */
- AvahiDNSServerBrowserCallback callback,
+ AvahiSDNSServerBrowserCallback callback,
void* userdata);
-/** Free an AvahiDNSServerBrowser object */
-void avahi_dns_server_browser_free(AvahiDNSServerBrowser *b);
+/** Free an AvahiSDNSServerBrowser object */
+void avahi_s_dns_server_browser_free(AvahiSDNSServerBrowser *b);
/** Return the last error code */
int avahi_server_errno(AvahiServer *s);
/* Fill the entry group */
if (!a->entry_group)
- a->entry_group = avahi_entry_group_new(m->server, avahi_host_rr_entry_group_callback, NULL);
+ a->entry_group = avahi_s_entry_group_new(m->server, avahi_host_rr_entry_group_callback, NULL);
if (!a->entry_group) /* OOM */
return;
- if (avahi_entry_group_is_empty(a->entry_group)) {
+ if (avahi_s_entry_group_is_empty(a->entry_group)) {
if (avahi_server_add_address(m->server, a->entry_group, a->interface->hardware->index, a->interface->protocol, 0, NULL, &a->address) < 0) {
avahi_log_warn(__FILE__": avahi_server_add_address() failed: %s", avahi_strerror(m->server->error));
- avahi_entry_group_free(a->entry_group);
+ avahi_s_entry_group_free(a->entry_group);
a->entry_group = NULL;
return;
}
- avahi_entry_group_commit(a->entry_group);
+ avahi_s_entry_group_commit(a->entry_group);
}
} else {
/* Clear the entry group */
- if (a->entry_group && !avahi_entry_group_is_empty(a->entry_group)) {
+ if (a->entry_group && !avahi_s_entry_group_is_empty(a->entry_group)) {
- if (avahi_entry_group_get_state(a->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING)
+ if (avahi_s_entry_group_get_state(a->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING)
avahi_server_decrease_host_rr_pending(m->server);
- avahi_entry_group_reset(a->entry_group);
+ avahi_s_entry_group_reset(a->entry_group);
}
}
}
m->server->state == AVAHI_SERVER_REGISTERING)) {
if (!hw->entry_group)
- hw->entry_group = avahi_entry_group_new(m->server, avahi_host_rr_entry_group_callback, NULL);
+ hw->entry_group = avahi_s_entry_group_new(m->server, avahi_host_rr_entry_group_callback, NULL);
if (!hw->entry_group)
return; /* OOM */
- if (avahi_entry_group_is_empty(hw->entry_group)) {
+ if (avahi_s_entry_group_is_empty(hw->entry_group)) {
char *name;
char *t;
if (avahi_server_add_service(m->server, hw->entry_group, hw->index, AVAHI_PROTO_UNSPEC, name, "_workstation._tcp", NULL, NULL, 9, NULL) < 0) {
avahi_log_warn(__FILE__": avahi_server_add_service() failed.");
- avahi_entry_group_free(hw->entry_group);
+ avahi_s_entry_group_free(hw->entry_group);
hw->entry_group = NULL;
} else
- avahi_entry_group_commit(hw->entry_group);
+ avahi_s_entry_group_commit(hw->entry_group);
avahi_free(name);
}
} else {
- if (hw->entry_group && !avahi_entry_group_is_empty(hw->entry_group)) {
+ if (hw->entry_group && !avahi_s_entry_group_is_empty(hw->entry_group)) {
- if (avahi_entry_group_get_state(hw->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING)
+ if (avahi_s_entry_group_get_state(hw->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING)
avahi_server_decrease_host_rr_pending(m->server);
- avahi_entry_group_reset(hw->entry_group);
+ avahi_s_entry_group_reset(hw->entry_group);
}
}
}
AVAHI_LLIST_REMOVE(AvahiInterfaceAddress, address, a->interface->addresses, a);
if (a->entry_group)
- avahi_entry_group_free(a->entry_group);
+ avahi_s_entry_group_free(a->entry_group);
avahi_free(a);
}
free_interface(m, hw->interfaces, send_goodbye);
if (hw->entry_group)
- avahi_entry_group_free(hw->entry_group);
+ avahi_s_entry_group_free(hw->entry_group);
AVAHI_LLIST_REMOVE(AvahiHwInterface, hardware, m->hw_interfaces, hw);
avahi_hashmap_remove(m->hashmap, &hw->index);
uint8_t mac_address[AVAHI_MAX_MAC_ADDRESS];
size_t mac_address_size;
- AvahiEntryGroup *entry_group;
+ AvahiSEntryGroup *entry_group;
AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
};
unsigned char prefix_len;
AvahiAddress address;
- AvahiEntryGroup *entry_group;
+ AvahiSEntryGroup *entry_group;
AvahiInterface *interface;
};
#include "browse.h"
-struct AvahiAddressResolver {
+struct AvahiSAddressResolver {
AvahiServer *server;
AvahiAddress address;
- AvahiRecordBrowser *record_browser;
+ AvahiSRecordBrowser *record_browser;
- AvahiAddressResolverCallback callback;
+ AvahiSAddressResolverCallback callback;
void* userdata;
AvahiTimeEvent *time_event;
- AVAHI_LLIST_FIELDS(AvahiAddressResolver, resolver);
+ AVAHI_LLIST_FIELDS(AvahiSAddressResolver, resolver);
};
-static void finish(AvahiAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, AvahiRecord *record) {
+static void finish(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, AvahiRecord *record) {
assert(r);
- avahi_record_browser_free(r->record_browser);
+ avahi_s_record_browser_free(r->record_browser);
r->record_browser = NULL;
if (r->time_event) {
r->callback(r, interface, protocol, event, &r->address, record ? record->data.ptr.name : NULL, r->userdata);
}
-static void record_browser_callback(AvahiRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
- AvahiAddressResolver *r = userdata;
+static void record_browser_callback(AvahiSRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+ AvahiSAddressResolver *r = userdata;
assert(rr);
assert(record);
}
static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
- AvahiAddressResolver *r = userdata;
+ AvahiSAddressResolver *r = userdata;
assert(e);
assert(r);
finish(r, -1, AVAHI_PROTO_UNSPEC, AVAHI_RESOLVER_TIMEOUT, NULL);
}
-AvahiAddressResolver *avahi_address_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const AvahiAddress *address, AvahiAddressResolverCallback callback, void* userdata) {
- AvahiAddressResolver *r;
+AvahiSAddressResolver *avahi_s_address_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const AvahiAddress *address, AvahiSAddressResolverCallback callback, void* userdata) {
+ AvahiSAddressResolver *r;
AvahiKey *k;
char *n;
struct timeval tv;
return NULL;
}
- if (!(r = avahi_new(AvahiAddressResolver, 1))) {
+ if (!(r = avahi_new(AvahiSAddressResolver, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
avahi_key_unref(k);
return NULL;
r->userdata = userdata;
r->record_browser = NULL;
- AVAHI_LLIST_PREPEND(AvahiAddressResolver, resolver, server->address_resolvers, r);
+ AVAHI_LLIST_PREPEND(AvahiSAddressResolver, resolver, server->address_resolvers, r);
avahi_elapse_time(&tv, 1000, 0);
if (!(r->time_event = avahi_time_event_new(server->time_event_queue, &tv, time_event_callback, r))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
- avahi_address_resolver_free(r);
+ avahi_s_address_resolver_free(r);
avahi_key_unref(k);
return NULL;
}
- r->record_browser = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
+ r->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
avahi_key_unref(k);
if (!r->record_browser) {
- avahi_address_resolver_free(r);
+ avahi_s_address_resolver_free(r);
return NULL;
}
return r;
}
-void avahi_address_resolver_free(AvahiAddressResolver *r) {
+void avahi_s_address_resolver_free(AvahiSAddressResolver *r) {
assert(r);
- AVAHI_LLIST_REMOVE(AvahiAddressResolver, resolver, r->server->address_resolvers, r);
+ AVAHI_LLIST_REMOVE(AvahiSAddressResolver, resolver, r->server->address_resolvers, r);
if (r->record_browser)
- avahi_record_browser_free(r->record_browser);
+ avahi_s_record_browser_free(r->record_browser);
if (r->time_event)
avahi_time_event_free(r->time_event);
#include "browse.h"
#include "log.h"
-struct AvahiHostNameResolver {
+struct AvahiSHostNameResolver {
AvahiServer *server;
char *host_name;
- AvahiRecordBrowser *record_browser_a;
- AvahiRecordBrowser *record_browser_aaaa;
+ AvahiSRecordBrowser *record_browser_a;
+ AvahiSRecordBrowser *record_browser_aaaa;
- AvahiHostNameResolverCallback callback;
+ AvahiSHostNameResolverCallback callback;
void* userdata;
AvahiTimeEvent *time_event;
- AVAHI_LLIST_FIELDS(AvahiHostNameResolver, resolver);
+ AVAHI_LLIST_FIELDS(AvahiSHostNameResolver, resolver);
};
-static void finish(AvahiHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, AvahiRecord *record) {
+static void finish(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, AvahiRecord *record) {
AvahiAddress a;
assert(r);
if (r->record_browser_a) {
- avahi_record_browser_free(r->record_browser_a);
+ avahi_s_record_browser_free(r->record_browser_a);
r->record_browser_a = NULL;
}
if (r->record_browser_aaaa) {
- avahi_record_browser_free(r->record_browser_aaaa);
+ avahi_s_record_browser_free(r->record_browser_aaaa);
r->record_browser_aaaa = NULL;
}
r->callback(r, interface, protocol, event, record ? record->key->name : r->host_name, record ? &a : NULL, r->userdata);
}
-static void record_browser_callback(AvahiRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
- AvahiHostNameResolver *r = userdata;
+static void record_browser_callback(AvahiSRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+ AvahiSHostNameResolver *r = userdata;
assert(rr);
assert(record);
}
static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
- AvahiHostNameResolver *r = userdata;
+ AvahiSHostNameResolver *r = userdata;
assert(e);
assert(r);
finish(r, -1, AVAHI_PROTO_UNSPEC, AVAHI_RESOLVER_TIMEOUT, NULL);
}
-AvahiHostNameResolver *avahi_host_name_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *host_name, AvahiProtocol aprotocol, AvahiHostNameResolverCallback callback, void* userdata) {
- AvahiHostNameResolver *r;
+AvahiSHostNameResolver *avahi_s_host_name_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *host_name, AvahiProtocol aprotocol, AvahiSHostNameResolverCallback callback, void* userdata) {
+ AvahiSHostNameResolver *r;
AvahiKey *k;
struct timeval tv;
return NULL;
}
- if (!(r = avahi_new(AvahiHostNameResolver, 1))) {
+ if (!(r = avahi_new(AvahiSHostNameResolver, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
avahi_elapse_time(&tv, 1000, 0);
r->time_event = avahi_time_event_new(server->time_event_queue, &tv, time_event_callback, r);
- AVAHI_LLIST_PREPEND(AvahiHostNameResolver, resolver, server->host_name_resolvers, r);
+ AVAHI_LLIST_PREPEND(AvahiSHostNameResolver, resolver, server->host_name_resolvers, r);
r->record_browser_aaaa = r->record_browser_a = NULL;
if (aprotocol == AVAHI_PROTO_INET || aprotocol == AVAHI_PROTO_UNSPEC) {
k = avahi_key_new(host_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A);
- r->record_browser_a = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
+ r->record_browser_a = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
avahi_key_unref(k);
if (!r->record_browser_a)
if (aprotocol == AVAHI_PROTO_INET6 || aprotocol == AVAHI_PROTO_UNSPEC) {
k = avahi_key_new(host_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA);
- r->record_browser_aaaa = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
+ r->record_browser_aaaa = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
avahi_key_unref(k);
if (!r->record_browser_aaaa)
return r;
fail:
- avahi_host_name_resolver_free(r);
+ avahi_s_host_name_resolver_free(r);
return NULL;
}
-void avahi_host_name_resolver_free(AvahiHostNameResolver *r) {
+void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r) {
assert(r);
- AVAHI_LLIST_REMOVE(AvahiHostNameResolver, resolver, r->server->host_name_resolvers, r);
+ AVAHI_LLIST_REMOVE(AvahiSHostNameResolver, resolver, r->server->host_name_resolvers, r);
if (r->record_browser_a)
- avahi_record_browser_free(r->record_browser_a);
+ avahi_s_record_browser_free(r->record_browser_a);
if (r->record_browser_aaaa)
- avahi_record_browser_free(r->record_browser_aaaa);
+ avahi_s_record_browser_free(r->record_browser_aaaa);
if (r->time_event)
avahi_time_event_free(r->time_event);
#include "browse.h"
-struct AvahiServiceResolver {
+struct AvahiSServiceResolver {
AvahiServer *server;
char *service_name;
char *service_type;
AvahiIfIndex interface;
AvahiProtocol protocol;
- AvahiRecordBrowser *record_browser_srv;
- AvahiRecordBrowser *record_browser_txt;
- AvahiRecordBrowser *record_browser_a;
- AvahiRecordBrowser *record_browser_aaaa;
+ AvahiSRecordBrowser *record_browser_srv;
+ AvahiSRecordBrowser *record_browser_txt;
+ AvahiSRecordBrowser *record_browser_a;
+ AvahiSRecordBrowser *record_browser_aaaa;
AvahiRecord *srv_record, *txt_record, *address_record;
- AvahiServiceResolverCallback callback;
+ AvahiSServiceResolverCallback callback;
void* userdata;
AvahiTimeEvent *time_event;
- AVAHI_LLIST_FIELDS(AvahiServiceResolver, resolver);
+ AVAHI_LLIST_FIELDS(AvahiSServiceResolver, resolver);
};
-static void finish(AvahiServiceResolver *r, AvahiResolverEvent event) {
+static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) {
assert(r);
if (r->record_browser_a) {
- avahi_record_browser_free(r->record_browser_a);
+ avahi_s_record_browser_free(r->record_browser_a);
r->record_browser_a = NULL;
}
if (r->record_browser_aaaa) {
- avahi_record_browser_free(r->record_browser_aaaa);
+ avahi_s_record_browser_free(r->record_browser_aaaa);
r->record_browser_aaaa = NULL;
}
if (r->record_browser_srv) {
- avahi_record_browser_free(r->record_browser_srv);
+ avahi_s_record_browser_free(r->record_browser_srv);
r->record_browser_srv = NULL;
}
if (r->record_browser_txt) {
- avahi_record_browser_free(r->record_browser_txt);
+ avahi_s_record_browser_free(r->record_browser_txt);
r->record_browser_txt = NULL;
}
}
}
-static void record_browser_callback(AvahiRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
- AvahiServiceResolver *r = userdata;
+static void record_browser_callback(AvahiSRecordBrowser*rr, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
+ AvahiSServiceResolver *r = userdata;
assert(rr);
assert(record);
if (r->address_protocol == AVAHI_PROTO_INET || r->address_protocol == AVAHI_PROTO_UNSPEC) {
AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A);
- r->record_browser_a = avahi_record_browser_new(r->server, r->interface, r->protocol, k, record_browser_callback, r);
+ r->record_browser_a = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, record_browser_callback, r);
avahi_key_unref(k);
}
if (r->address_protocol == AVAHI_PROTO_INET6 || r->address_protocol == AVAHI_PROTO_UNSPEC) {
AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA);
- r->record_browser_aaaa = avahi_record_browser_new(r->server, r->interface, r->protocol, k, record_browser_callback, r);
+ r->record_browser_aaaa = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, record_browser_callback, r);
avahi_key_unref(k);
}
}
}
static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
- AvahiServiceResolver *r = userdata;
+ AvahiSServiceResolver *r = userdata;
assert(e);
assert(r);
finish(r, AVAHI_RESOLVER_TIMEOUT);
}
-AvahiServiceResolver *avahi_service_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, AvahiProtocol aprotocol, AvahiServiceResolverCallback callback, void* userdata) {
- AvahiServiceResolver *r;
+AvahiSServiceResolver *avahi_s_service_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, AvahiProtocol aprotocol, AvahiSServiceResolverCallback callback, void* userdata) {
+ AvahiSServiceResolver *r;
AvahiKey *k;
struct timeval tv;
char t[256], *n;
return NULL;
}
- if (!(r = avahi_new(AvahiServiceResolver, 1))) {
+ if (!(r = avahi_new(AvahiSServiceResolver, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
avahi_elapse_time(&tv, 1000, 0);
r->time_event = avahi_time_event_new(server->time_event_queue, &tv, time_event_callback, r);
- AVAHI_LLIST_PREPEND(AvahiServiceResolver, resolver, server->service_resolvers, r);
+ AVAHI_LLIST_PREPEND(AvahiSServiceResolver, resolver, server->service_resolvers, r);
r->record_browser_a = r->record_browser_aaaa = r->record_browser_srv = r->record_browser_txt = NULL;
k = avahi_key_new(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV);
- r->record_browser_srv = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
+ r->record_browser_srv = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
avahi_key_unref(k);
if (!r->record_browser_srv) {
- avahi_service_resolver_free(r);
+ avahi_s_service_resolver_free(r);
return NULL;
}
k = avahi_key_new(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT);
- r->record_browser_txt = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
+ r->record_browser_txt = avahi_s_record_browser_new(server, interface, protocol, k, record_browser_callback, r);
avahi_key_unref(k);
if (!r->record_browser_txt) {
- avahi_service_resolver_free(r);
+ avahi_s_service_resolver_free(r);
return NULL;
}
return r;
}
-void avahi_service_resolver_free(AvahiServiceResolver *r) {
+void avahi_s_service_resolver_free(AvahiSServiceResolver *r) {
assert(r);
- AVAHI_LLIST_REMOVE(AvahiServiceResolver, resolver, r->server->service_resolvers, r);
+ AVAHI_LLIST_REMOVE(AvahiSServiceResolver, resolver, r->server->service_resolvers, r);
if (r->time_event)
avahi_time_event_free(r->time_event);
if (r->record_browser_srv)
- avahi_record_browser_free(r->record_browser_srv);
+ avahi_s_record_browser_free(r->record_browser_srv);
if (r->record_browser_txt)
- avahi_record_browser_free(r->record_browser_txt);
+ avahi_s_record_browser_free(r->record_browser_txt);
if (r->record_browser_a)
- avahi_record_browser_free(r->record_browser_a);
+ avahi_s_record_browser_free(r->record_browser_a);
if (r->record_browser_aaaa)
- avahi_record_browser_free(r->record_browser_aaaa);
+ avahi_s_record_browser_free(r->record_browser_aaaa);
if (r->srv_record)
avahi_record_unref(r->srv_record);
avahi_free(e);
}
-static void free_group(AvahiServer *s, AvahiEntryGroup *g) {
+static void free_group(AvahiServer *s, AvahiSEntryGroup *g) {
assert(s);
assert(g);
if (g->register_time_event)
avahi_time_event_free(g->register_time_event);
- AVAHI_LLIST_REMOVE(AvahiEntryGroup, groups, s->groups, g);
+ AVAHI_LLIST_REMOVE(AvahiSEntryGroup, groups, s->groups, g);
avahi_free(g);
}
assert(s);
if (s->need_group_cleanup) {
- AvahiEntryGroup *g, *next;
+ AvahiSEntryGroup *g, *next;
for (g = s->groups; g; g = next) {
next = g->groups_next;
e->group->n_probing = 0;
- avahi_entry_group_change_state(e->group, AVAHI_ENTRY_GROUP_COLLISION);
+ avahi_s_entry_group_change_state(e->group, AVAHI_ENTRY_GROUP_COLLISION);
} else {
avahi_goodbye_entry(s, e, 0);
e->dead = 1;
assert(s);
if (s->hinfo_entry_group)
- avahi_entry_group_reset(s->hinfo_entry_group);
+ avahi_s_entry_group_reset(s->hinfo_entry_group);
if (s->browse_domain_entry_group)
- avahi_entry_group_reset(s->browse_domain_entry_group);
+ avahi_s_entry_group_reset(s->browse_domain_entry_group);
avahi_update_host_rrs(s->monitor, 1);
s->n_host_rr_pending = 0;
s->n_host_rr_pending ++;
}
-void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
+void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
assert(s);
assert(g);
return;
if (s->hinfo_entry_group)
- assert(avahi_entry_group_is_empty(s->hinfo_entry_group));
+ assert(avahi_s_entry_group_is_empty(s->hinfo_entry_group));
else
- s->hinfo_entry_group = avahi_entry_group_new(s, avahi_host_rr_entry_group_callback, NULL);
+ s->hinfo_entry_group = avahi_s_entry_group_new(s, avahi_host_rr_entry_group_callback, NULL);
if (!s->hinfo_entry_group) {
avahi_log_warn("Failed to create HINFO entry group: %s", avahi_strerror(s->error));
avahi_record_unref(r);
}
- if (avahi_entry_group_commit(s->hinfo_entry_group) < 0)
+ if (avahi_s_entry_group_commit(s->hinfo_entry_group) < 0)
avahi_log_warn("Failed to commit HINFO entry group: %s", avahi_strerror(s->error));
}
return;
if (s->browse_domain_entry_group)
- assert(avahi_entry_group_is_empty(s->browse_domain_entry_group));
+ assert(avahi_s_entry_group_is_empty(s->browse_domain_entry_group));
else
- s->browse_domain_entry_group = avahi_entry_group_new(s, NULL, NULL);
+ s->browse_domain_entry_group = avahi_s_entry_group_new(s, NULL, NULL);
if (!s->browse_domain_entry_group) {
avahi_log_warn("Failed to create browse domain entry group: %s", avahi_strerror(s->error));
return;
}
- if (avahi_entry_group_commit(s->browse_domain_entry_group) < 0)
+ if (avahi_s_entry_group_commit(s->browse_domain_entry_group) < 0)
avahi_log_warn("Failed to commit browse domain entry group: %s", avahi_strerror(s->error));
}
AVAHI_LLIST_HEAD_INIT(AvahiGroup, s->groups);
s->record_browser_hashmap = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, NULL, NULL);
- AVAHI_LLIST_HEAD_INIT(AvahiRecordBrowser, s->record_browsers);
- AVAHI_LLIST_HEAD_INIT(AvahiHostNameResolver, s->host_name_resolvers);
- AVAHI_LLIST_HEAD_INIT(AvahiAddressResolver, s->address_resolvers);
- AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, s->domain_browsers);
- AVAHI_LLIST_HEAD_INIT(AvahiServiceTypeBrowser, s->service_type_browsers);
- AVAHI_LLIST_HEAD_INIT(AvahiServiceBrowser, s->service_browsers);
- AVAHI_LLIST_HEAD_INIT(AvahiServiceResolver, s->service_resolvers);
- AVAHI_LLIST_HEAD_INIT(AvahiDNSServerBrowser, s->dns_server_browsers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSRecordBrowser, s->record_browsers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSHostNameResolver, s->host_name_resolvers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSAddressResolver, s->address_resolvers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSDomainBrowser, s->domain_browsers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSServiceTypeBrowser, s->service_type_browsers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSServiceBrowser, s->service_browsers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSServiceResolver, s->service_resolvers);
+ AVAHI_LLIST_HEAD_INIT(AvahiSDNSServerBrowser, s->dns_server_browsers);
s->legacy_unicast_reflect_slots = NULL;
s->legacy_unicast_reflect_id = 0;
free_slots(s);
while (s->dns_server_browsers)
- avahi_dns_server_browser_free(s->dns_server_browsers);
+ avahi_s_dns_server_browser_free(s->dns_server_browsers);
while (s->host_name_resolvers)
- avahi_host_name_resolver_free(s->host_name_resolvers);
+ avahi_s_host_name_resolver_free(s->host_name_resolvers);
while (s->address_resolvers)
- avahi_address_resolver_free(s->address_resolvers);
+ avahi_s_address_resolver_free(s->address_resolvers);
while (s->domain_browsers)
- avahi_domain_browser_free(s->domain_browsers);
+ avahi_s_domain_browser_free(s->domain_browsers);
while (s->service_type_browsers)
- avahi_service_type_browser_free(s->service_type_browsers);
+ avahi_s_service_type_browser_free(s->service_type_browsers);
while (s->service_browsers)
- avahi_service_browser_free(s->service_browsers);
+ avahi_s_service_browser_free(s->service_browsers);
while (s->service_resolvers)
- avahi_service_resolver_free(s->service_resolvers);
+ avahi_s_service_resolver_free(s->service_resolvers);
while (s->record_browsers)
- avahi_record_browser_destroy(s->record_browsers);
+ avahi_s_record_browser_destroy(s->record_browsers);
avahi_hashmap_free(s->record_browser_hashmap);
avahi_hashmap_free(s->entries_by_key);
int avahi_server_add(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
return 0;
}
-const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiEntryGroup *g, void **state) {
+const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, void **state) {
AvahiEntry **e = (AvahiEntry**) state;
assert(s);
assert(e);
int avahi_server_add_ptr(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
int avahi_server_add_address(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
static int server_add_txt_strlst_nocopy(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
int avahi_server_add_txt_strlst(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
int avahi_server_add_txt_va(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
int avahi_server_add_txt(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiEntryFlags flags,
static int server_add_service_strlst_nocopy(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *name,
int avahi_server_add_service_strlst(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *name,
int avahi_server_add_service_va(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *name,
int avahi_server_add_service(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *name,
int avahi_server_add_dns_server_address(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
int avahi_server_add_dns_server_name(
AvahiServer *s,
- AvahiEntryGroup *g,
+ AvahiSEntryGroup *g,
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
avahi_interface_monitor_walk(s->monitor, interface, protocol, post_query_callback, key);
}
-void avahi_entry_group_change_state(AvahiEntryGroup *g, AvahiEntryGroupState state) {
+void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState state) {
assert(g);
if (g->state == state)
g->callback(g->server, g, state, g->userdata);
}
-AvahiEntryGroup *avahi_entry_group_new(AvahiServer *s, AvahiEntryGroupCallback callback, void* userdata) {
- AvahiEntryGroup *g;
+AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallback callback, void* userdata) {
+ AvahiSEntryGroup *g;
assert(s);
- if (!(g = avahi_new(AvahiEntryGroup, 1))) {
+ if (!(g = avahi_new(AvahiSEntryGroup, 1))) {
avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
return NULL;
}
g->register_time.tv_usec = 0;
AVAHI_LLIST_HEAD_INIT(AvahiEntry, g->entries);
- AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, s->groups, g);
+ AVAHI_LLIST_PREPEND(AvahiSEntryGroup, groups, s->groups, g);
return g;
}
-void avahi_entry_group_free(AvahiEntryGroup *g) {
+void avahi_s_entry_group_free(AvahiSEntryGroup *g) {
AvahiEntry *e;
assert(g);
g->server->need_entry_cleanup = 1;
}
-static void entry_group_commit_real(AvahiEntryGroup *g) {
+static void entry_group_commit_real(AvahiSEntryGroup *g) {
assert(g);
gettimeofday(&g->register_time, NULL);
- avahi_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
+ avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
if (!g->dead) {
avahi_announce_group(g->server, g);
- avahi_entry_group_check_probed(g, 0);
+ avahi_s_entry_group_check_probed(g, 0);
}
}
static void entry_group_register_time_event_callback(AvahiTimeEvent *e, void* userdata) {
- AvahiEntryGroup *g = userdata;
+ AvahiSEntryGroup *g = userdata;
assert(g);
/* avahi_log_debug("Holdoff passed, waking up and going on."); */
entry_group_commit_real(g);
}
-int avahi_entry_group_commit(AvahiEntryGroup *g) {
+int avahi_s_entry_group_commit(AvahiSEntryGroup *g) {
struct timeval now;
assert(g);
assert(!g->register_time_event);
g->register_time_event = avahi_time_event_new(g->server->time_event_queue, &g->register_time, entry_group_register_time_event_callback, g);
- avahi_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
+ avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
}
return AVAHI_OK;
}
-void avahi_entry_group_reset(AvahiEntryGroup *g) {
+void avahi_s_entry_group_reset(AvahiSEntryGroup *g) {
AvahiEntry *e;
assert(g);
g->server->need_entry_cleanup = 1;
g->n_probing = 0;
- avahi_entry_group_change_state(g, AVAHI_ENTRY_GROUP_UNCOMMITED);
+ avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_UNCOMMITED);
}
int avahi_entry_is_commited(AvahiEntry *e) {
e->group->state == AVAHI_ENTRY_GROUP_ESTABLISHED;
}
-AvahiEntryGroupState avahi_entry_group_get_state(AvahiEntryGroup *g) {
+AvahiEntryGroupState avahi_s_entry_group_get_state(AvahiSEntryGroup *g) {
assert(g);
assert(!g->dead);
return g->state;
}
-void avahi_entry_group_set_data(AvahiEntryGroup *g, void* userdata) {
+void avahi_s_entry_group_set_data(AvahiSEntryGroup *g, void* userdata) {
assert(g);
g->userdata = userdata;
}
-void* avahi_entry_group_get_data(AvahiEntryGroup *g) {
+void* avahi_s_entry_group_get_data(AvahiSEntryGroup *g) {
assert(g);
return g->userdata;
}
-int avahi_entry_group_is_empty(AvahiEntryGroup *g) {
+int avahi_s_entry_group_is_empty(AvahiSEntryGroup *g) {
AvahiEntry *e;
assert(g);
#include <avahi-common/llist.h>
#include <avahi-common/watch.h>
+/** A locally registered DNS resource record */
+typedef struct AvahiEntry AvahiEntry;
+
#include "core.h"
#include "iface.h"
#include "prioq.h"
struct AvahiEntry {
AvahiServer *server;
- AvahiEntryGroup *group;
+ AvahiSEntryGroup *group;
int dead;
AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
};
-struct AvahiEntryGroup {
+struct AvahiSEntryGroup {
AvahiServer *server;
int dead;
AvahiEntryGroupState state;
void* userdata;
- AvahiEntryGroupCallback callback;
+ AvahiSEntryGroupCallback callback;
unsigned n_probing;
struct timeval register_time;
AvahiTimeEvent *register_time_event;
- AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups);
+ AVAHI_LLIST_FIELDS(AvahiSEntryGroup, groups);
AVAHI_LLIST_HEAD(AvahiEntry, entries);
};
AVAHI_LLIST_HEAD(AvahiEntry, entries);
AvahiHashmap *entries_by_key;
- AVAHI_LLIST_HEAD(AvahiEntryGroup, groups);
+ AVAHI_LLIST_HEAD(AvahiSEntryGroup, groups);
- AVAHI_LLIST_HEAD(AvahiRecordBrowser, record_browsers);
+ AVAHI_LLIST_HEAD(AvahiSRecordBrowser, record_browsers);
AvahiHashmap *record_browser_hashmap;
- AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers);
- AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers);
- AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers);
- AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers);
- AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers);
- AVAHI_LLIST_HEAD(AvahiServiceResolver, service_resolvers);
- AVAHI_LLIST_HEAD(AvahiDNSServerBrowser, dns_server_browsers);
+ AVAHI_LLIST_HEAD(AvahiSHostNameResolver, host_name_resolvers);
+ AVAHI_LLIST_HEAD(AvahiSAddressResolver, address_resolvers);
+ AVAHI_LLIST_HEAD(AvahiSDomainBrowser, domain_browsers);
+ AVAHI_LLIST_HEAD(AvahiSServiceTypeBrowser, service_type_browsers);
+ AVAHI_LLIST_HEAD(AvahiSServiceBrowser, service_browsers);
+ AVAHI_LLIST_HEAD(AvahiSServiceResolver, service_resolvers);
+ AVAHI_LLIST_HEAD(AvahiSDNSServerBrowser, dns_server_browsers);
int need_entry_cleanup, need_group_cleanup, need_browser_cleanup;
AvahiServerCallback callback;
void* userdata;
- AvahiEntryGroup *hinfo_entry_group;
- AvahiEntryGroup *browse_domain_entry_group;
+ AvahiSEntryGroup *hinfo_entry_group;
+ AvahiSEntryGroup *browse_domain_entry_group;
unsigned n_host_rr_pending;
/* Used for assembling responses */
void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, int unicast_response);
void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port, int legacy_unicast, int is_probe);
-void avahi_entry_group_change_state(AvahiEntryGroup *g, AvahiEntryGroupState state);
+void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState state);
int avahi_entry_is_commited(AvahiEntry *e);
void avahi_server_enumerate_aux_records(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata);
-void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata);
+void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void *userdata);
void avahi_server_decrease_host_rr_pending(AvahiServer *s);
void avahi_server_increase_host_rr_pending(AvahiServer *s);
struct EntryGroupInfo {
guint id;
Client *client;
- AvahiEntryGroup *entry_group;
+ AvahiSEntryGroup *entry_group;
gchar *path;
gint n_entries;
struct HostNameResolverInfo {
Client *client;
- AvahiHostNameResolver *host_name_resolver;
+ AvahiSHostNameResolver *host_name_resolver;
DBusMessage *message;
AVAHI_LLIST_FIELDS(HostNameResolverInfo, host_name_resolvers);
struct AddressResolverInfo {
Client *client;
- AvahiAddressResolver *address_resolver;
+ AvahiSAddressResolver *address_resolver;
DBusMessage *message;
AVAHI_LLIST_FIELDS(AddressResolverInfo, address_resolvers);
struct DomainBrowserInfo {
guint id;
Client *client;
- AvahiDomainBrowser *domain_browser;
+ AvahiSDomainBrowser *domain_browser;
gchar *path;
AVAHI_LLIST_FIELDS(DomainBrowserInfo, domain_browsers);
struct ServiceTypeBrowserInfo {
guint id;
Client *client;
- AvahiServiceTypeBrowser *service_type_browser;
+ AvahiSServiceTypeBrowser *service_type_browser;
gchar *path;
AVAHI_LLIST_FIELDS(ServiceTypeBrowserInfo, service_type_browsers);
struct ServiceBrowserInfo {
guint id;
Client *client;
- AvahiServiceBrowser *service_browser;
+ AvahiSServiceBrowser *service_browser;
gchar *path;
AVAHI_LLIST_FIELDS(ServiceBrowserInfo, service_browsers);
struct ServiceResolverInfo {
Client *client;
- AvahiServiceResolver *service_resolver;
+ AvahiSServiceResolver *service_resolver;
DBusMessage *message;
AVAHI_LLIST_FIELDS(ServiceResolverInfo, service_resolvers);
g_assert(i);
if (i->entry_group)
- avahi_entry_group_free(i->entry_group);
+ avahi_s_entry_group_free(i->entry_group);
dbus_connection_unregister_object_path(server->bus, i->path);
g_free(i->path);
AVAHI_LLIST_REMOVE(EntryGroupInfo, entry_groups, i->client->entry_groups, i);
g_assert(i);
if (i->host_name_resolver)
- avahi_host_name_resolver_free(i->host_name_resolver);
+ avahi_s_host_name_resolver_free(i->host_name_resolver);
dbus_message_unref(i->message);
AVAHI_LLIST_REMOVE(HostNameResolverInfo, host_name_resolvers, i->client->host_name_resolvers, i);
g_assert(i);
if (i->address_resolver)
- avahi_address_resolver_free(i->address_resolver);
+ avahi_s_address_resolver_free(i->address_resolver);
dbus_message_unref(i->message);
AVAHI_LLIST_REMOVE(AddressResolverInfo, address_resolvers, i->client->address_resolvers, i);
g_assert(i);
if (i->domain_browser)
- avahi_domain_browser_free(i->domain_browser);
+ avahi_s_domain_browser_free(i->domain_browser);
dbus_connection_unregister_object_path(server->bus, i->path);
g_free(i->path);
AVAHI_LLIST_REMOVE(DomainBrowserInfo, domain_browsers, i->client->domain_browsers, i);
g_assert(i);
if (i->service_type_browser)
- avahi_service_type_browser_free(i->service_type_browser);
+ avahi_s_service_type_browser_free(i->service_type_browser);
dbus_connection_unregister_object_path(server->bus, i->path);
g_free(i->path);
AVAHI_LLIST_REMOVE(ServiceTypeBrowserInfo, service_type_browsers, i->client->service_type_browsers, i);
g_assert(i);
if (i->service_browser)
- avahi_service_browser_free(i->service_browser);
+ avahi_s_service_browser_free(i->service_browser);
dbus_connection_unregister_object_path(server->bus, i->path);
g_free(i->path);
AVAHI_LLIST_REMOVE(ServiceBrowserInfo, service_browsers, i->client->service_browsers, i);
g_assert(i);
if (i->service_resolver)
- avahi_service_resolver_free(i->service_resolver);
+ avahi_s_service_resolver_free(i->service_resolver);
dbus_message_unref(i->message);
AVAHI_LLIST_REMOVE(ServiceResolverInfo, service_resolvers, i->client->service_resolvers, i);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata) {
+static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, gpointer userdata) {
EntryGroupInfo *i = userdata;
DBusMessage *m;
gint32 t;
goto fail;
}
- avahi_entry_group_commit(i->entry_group);
+ avahi_s_entry_group_commit(i->entry_group);
return respond_ok(c, m);
goto fail;
}
- avahi_entry_group_reset(i->entry_group);
+ avahi_s_entry_group_reset(i->entry_group);
return respond_ok(c, m);
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty")) {
goto fail;
}
- b = !!avahi_entry_group_is_empty(i->entry_group);
+ b = !!avahi_s_entry_group_is_empty(i->entry_group);
reply = dbus_message_new_method_return(m);
dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID);
goto fail;
}
- state = avahi_entry_group_get_state(i->entry_group);
+ state = avahi_s_entry_group_get_state(i->entry_group);
return respond_int32(c, m, (gint32) state);
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService")) {
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static void host_name_resolver_callback(AvahiHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const gchar *host_name, const AvahiAddress *a, gpointer userdata) {
+static void host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const gchar *host_name, const AvahiAddress *a, gpointer userdata) {
HostNameResolverInfo *i = userdata;
g_assert(r);
host_name_resolver_free(i);
}
-static void address_resolver_callback(AvahiAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const gchar *host_name, gpointer userdata) {
+static void address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const gchar *host_name, gpointer userdata) {
AddressResolverInfo *i = userdata;
g_assert(r);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static void domain_browser_callback(AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *domain, gpointer userdata) {
+static void domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *domain, gpointer userdata) {
DomainBrowserInfo *i = userdata;
DBusMessage *m;
gint32 i_interface, i_protocol;
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static void service_type_browser_callback(AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *type, const gchar *domain, gpointer userdata) {
+static void service_type_browser_callback(AvahiSServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *type, const gchar *domain, gpointer userdata) {
ServiceTypeBrowserInfo *i = userdata;
DBusMessage *m;
gint32 i_interface, i_protocol;
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static void service_browser_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *name, const gchar *type, const gchar *domain, gpointer userdata) {
+static void service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *name, const gchar *type, const gchar *domain, gpointer userdata) {
ServiceBrowserInfo *i = userdata;
DBusMessage *m;
gint32 i_interface, i_protocol;
}
static void service_resolver_callback(
- AvahiServiceResolver *r,
+ AvahiSServiceResolver *r,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiResolverEvent event,
AVAHI_LLIST_PREPEND(EntryGroupInfo, entry_groups, client->entry_groups, i);
client->n_objects++;
- if (!(i->entry_group = avahi_entry_group_new(avahi_server, entry_group_callback, i))) {
+ if (!(i->entry_group = avahi_s_entry_group_new(avahi_server, entry_group_callback, i))) {
entry_group_free(i);
return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
AVAHI_LLIST_PREPEND(HostNameResolverInfo, host_name_resolvers, client->host_name_resolvers, i);
client->n_objects++;
- if (!(i->host_name_resolver = avahi_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, (AvahiProtocol) aprotocol, host_name_resolver_callback, i))) {
+ if (!(i->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, (AvahiProtocol) aprotocol, host_name_resolver_callback, i))) {
host_name_resolver_free(i);
return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
AVAHI_LLIST_PREPEND(AddressResolverInfo, address_resolvers, client->address_resolvers, i);
client->n_objects++;
- if (!(i->address_resolver = avahi_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, address_resolver_callback, i))) {
+ if (!(i->address_resolver = avahi_s_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, address_resolver_callback, i))) {
address_resolver_free(i);
return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
AVAHI_LLIST_PREPEND(DomainBrowserInfo, domain_browsers, client->domain_browsers, i);
client->n_objects++;
- if (!(i->domain_browser = avahi_domain_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, (AvahiDomainBrowserType) type, domain_browser_callback, i))) {
+ if (!(i->domain_browser = avahi_s_domain_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, (AvahiDomainBrowserType) type, domain_browser_callback, i))) {
domain_browser_free(i);
return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
AVAHI_LLIST_PREPEND(ServiceTypeBrowserInfo, service_type_browsers, client->service_type_browsers, i);
client->n_objects++;
- if (!(i->service_type_browser = avahi_service_type_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, service_type_browser_callback, i))) {
+ if (!(i->service_type_browser = avahi_s_service_type_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, service_type_browser_callback, i))) {
service_type_browser_free(i);
return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
AVAHI_LLIST_PREPEND(ServiceBrowserInfo, service_browsers, client->service_browsers, i);
client->n_objects++;
- if (!(i->service_browser = avahi_service_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, type, domain, service_browser_callback, i))) {
+ if (!(i->service_browser = avahi_s_service_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, type, domain, service_browser_callback, i))) {
service_browser_free(i);
return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
AVAHI_LLIST_PREPEND(ServiceResolverInfo, service_resolvers, client->service_resolvers, i);
client->n_objects++;
- if (!(i->service_resolver = avahi_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, service_resolver_callback, i))) {
+ if (!(i->service_resolver = avahi_s_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, service_resolver_callback, i))) {
service_resolver_free(i);
return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
#define RESOLV_CONF "/etc/resolv.conf"
-static AvahiEntryGroup *dns_servers_entry_group = NULL;
-static AvahiEntryGroup *resolv_conf_entry_group = NULL;
+static AvahiSEntryGroup *dns_servers_entry_group = NULL;
+static AvahiSEntryGroup *resolv_conf_entry_group = NULL;
static gchar **resolv_conf = NULL;
return ret;
}
-static AvahiEntryGroup* add_dns_servers(AvahiServer *s, AvahiEntryGroup* g, gchar **l) {
+static AvahiSEntryGroup* add_dns_servers(AvahiServer *s, AvahiSEntryGroup* g, gchar **l) {
gchar **p;
g_assert(s);
g_assert(l);
if (!g)
- g = avahi_entry_group_new(s, NULL, NULL);
+ g = avahi_s_entry_group_new(s, NULL, NULL);
- g_assert(avahi_entry_group_is_empty(g));
+ g_assert(avahi_s_entry_group_is_empty(g));
for (p = l; *p; p++) {
AvahiAddress a;
avahi_log_warn("Failed to parse address '%s', ignoring.", *p);
else
if (avahi_server_add_dns_server_address(s, g, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, &a, 53) < 0) {
- avahi_entry_group_free(g);
+ avahi_s_entry_group_free(g);
avahi_log_error("Failed to add DNS server address: %s", avahi_strerror(avahi_server_errno(s)));
return NULL;
}
}
- avahi_entry_group_commit(g);
+ avahi_s_entry_group_commit(g);
return g;
}
static void remove_dns_server_entry_groups(void) {
if (resolv_conf_entry_group)
- avahi_entry_group_reset(resolv_conf_entry_group);
+ avahi_s_entry_group_reset(resolv_conf_entry_group);
if (dns_servers_entry_group)
- avahi_entry_group_reset(dns_servers_entry_group);
+ avahi_s_entry_group_reset(dns_servers_entry_group);
}
static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) {
static_service_add_to_server();
if (resolv_conf_entry_group)
- avahi_entry_group_reset(resolv_conf_entry_group);
+ avahi_s_entry_group_reset(resolv_conf_entry_group);
load_resolv_conf(&config);
gchar inbuf[BUFFER_SIZE], outbuf[BUFFER_SIZE];
guint inbuf_length, outbuf_length;
- AvahiHostNameResolver *host_name_resolver;
- AvahiAddressResolver *address_resolver;
- AvahiDNSServerBrowser *dns_server_browser;
+ AvahiSHostNameResolver *host_name_resolver;
+ AvahiSAddressResolver *address_resolver;
+ AvahiSDNSServerBrowser *dns_server_browser;
AvahiProtocol afquery;
c->server->n_clients--;
if (c->host_name_resolver)
- avahi_host_name_resolver_free(c->host_name_resolver);
+ avahi_s_host_name_resolver_free(c->host_name_resolver);
if (c->address_resolver)
- avahi_address_resolver_free(c->address_resolver);
+ avahi_s_address_resolver_free(c->address_resolver);
if (c->dns_server_browser)
- avahi_dns_server_browser_free(c->dns_server_browser);
+ avahi_s_dns_server_browser_free(c->dns_server_browser);
g_source_remove_poll(&c->server->source, &c->poll_fd);
close(c->fd);
static void host_name_resolver_callback(
- AvahiHostNameResolver *r,
+ AvahiSHostNameResolver *r,
AvahiIfIndex iface,
AvahiProtocol protocol,
AvahiResolverEvent event,
}
static void address_resolver_callback(
- AvahiAddressResolver *r,
+ AvahiSAddressResolver *r,
AvahiIfIndex iface,
AvahiProtocol protocol,
AvahiResolverEvent event,
c->state = CLIENT_DEAD;
}
-static void dns_server_browser_callback(AvahiDNSServerBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *host_name, const AvahiAddress *a, uint16_t port, void* userdata) {
+static void dns_server_browser_callback(
+ AvahiSDNSServerBrowser *b,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const char *host_name,
+ const AvahiAddress *a,
+ uint16_t port,
+ void* userdata) {
+
Client *c = userdata;
gchar t[64];
c->state = CLIENT_DEAD;
} else if (strcmp(cmd, "RESOLVE-HOSTNAME-IPV4") == 0 && n_args == 2) {
c->state = CLIENT_RESOLVE_HOSTNAME;
- if (!(c->host_name_resolver = avahi_host_name_resolver_new(avahi_server, -1, AF_UNSPEC, arg, c->afquery = AF_INET, host_name_resolver_callback, c)))
+ if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, -1, AF_UNSPEC, arg, c->afquery = AF_INET, host_name_resolver_callback, c)))
goto fail;
} else if (strcmp(cmd, "RESOLVE-HOSTNAME-IPV6") == 0 && n_args == 2) {
c->state = CLIENT_RESOLVE_HOSTNAME;
- if (!(c->host_name_resolver = avahi_host_name_resolver_new(avahi_server, -1, AF_UNSPEC, arg, c->afquery = AF_INET6, host_name_resolver_callback, c)))
+ if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, -1, AF_UNSPEC, arg, c->afquery = AF_INET6, host_name_resolver_callback, c)))
goto fail;
} else if (strcmp(cmd, "RESOLVE-HOSTNAME") == 0 && n_args == 2) {
c->state = CLIENT_RESOLVE_HOSTNAME;
- if (!(c->host_name_resolver = avahi_host_name_resolver_new(avahi_server, -1, AF_UNSPEC, arg, c->afquery = AF_UNSPEC, host_name_resolver_callback, c)))
+ if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, -1, AF_UNSPEC, arg, c->afquery = AF_UNSPEC, host_name_resolver_callback, c)))
goto fail;
} else if (strcmp(cmd, "RESOLVE-ADDRESS") == 0 && n_args == 2) {
AvahiAddress addr;
c->state = CLIENT_DEAD;
} else {
c->state = CLIENT_RESOLVE_ADDRESS;
- if (!(c->address_resolver = avahi_address_resolver_new(avahi_server, -1, AF_UNSPEC, &addr, address_resolver_callback, c)))
+ if (!(c->address_resolver = avahi_s_address_resolver_new(avahi_server, -1, AF_UNSPEC, &addr, address_resolver_callback, c)))
goto fail;
}
} else if (strcmp(cmd, "BROWSE-DNS-SERVERS-IPV4") == 0 && n_args == 1) {
c->state = CLIENT_BROWSE_DNS_SERVERS;
- if (!(c->dns_server_browser = avahi_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_INET, dns_server_browser_callback, c)))
+ if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_INET, dns_server_browser_callback, c)))
goto fail;
client_output_printf(c, "+ Browsing ...\n");
} else if (strcmp(cmd, "BROWSE-DNS-SERVERS-IPV6") == 0 && n_args == 1) {
c->state = CLIENT_BROWSE_DNS_SERVERS;
- if (!(c->dns_server_browser = avahi_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_INET6, dns_server_browser_callback, c)))
+ if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_INET6, dns_server_browser_callback, c)))
goto fail;
client_output_printf(c, "+ Browsing ...\n");
} else if (strcmp(cmd, "BROWSE-DNS-SERVERS") == 0 && n_args == 1) {
c->state = CLIENT_BROWSE_DNS_SERVERS;
- if (!(c->dns_server_browser = avahi_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_UNSPEC, dns_server_browser_callback, c)))
+ if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AF_UNSPEC, dns_server_browser_callback, c)))
goto fail;
client_output_printf(c, "+ Browsing ...\n");
} else {
for (c = server->clients; c; c = c->clients_next)
if (c->state == CLIENT_BROWSE_DNS_SERVERS && c->dns_server_browser) {
- avahi_dns_server_browser_free(c->dns_server_browser);
- c->dns_server_browser = avahi_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery, dns_server_browser_callback, c);
+ avahi_s_dns_server_browser_free(c->dns_server_browser);
+ c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery, dns_server_browser_callback, c);
}
}
gchar *name, *chosen_name;
gboolean replace_wildcards;
- AvahiEntryGroup *entry_group;
+ AvahiSEntryGroup *entry_group;
AVAHI_LLIST_HEAD(StaticService, services);
AVAHI_LLIST_FIELDS(StaticServiceGroup, groups);
};
g_assert(g);
if (g->entry_group)
- avahi_entry_group_free(g->entry_group);
+ avahi_s_entry_group_free(g->entry_group);
while (g->services)
static_service_free(g->services);
g_free(g);
}
-static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *eg, AvahiEntryGroupState state, gpointer userdata) {
+static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *eg, AvahiEntryGroupState state, gpointer userdata) {
StaticServiceGroup *g = userdata;
g_assert(s);
g->chosen_name = g_strdup(g->name);
if (!g->entry_group)
- g->entry_group = avahi_entry_group_new(avahi_server, entry_group_callback, g);
+ g->entry_group = avahi_s_entry_group_new(avahi_server, entry_group_callback, g);
- g_assert(avahi_entry_group_is_empty(g->entry_group));
+ g_assert(avahi_s_entry_group_is_empty(g->entry_group));
for (s = g->services; s; s = s->services_next) {
}
}
- avahi_entry_group_commit(g->entry_group);
+ avahi_s_entry_group_commit(g->entry_group);
}
static void remove_static_service_group_from_server(StaticServiceGroup *g) {
g_assert(g);
if (g->entry_group)
- avahi_entry_group_reset(g->entry_group);
+ avahi_s_entry_group_reset(g->entry_group);
}
typedef enum {
struct ServiceType {
gchar *service_type;
- AvahiServiceBrowser *browser;
+ AvahiSServiceBrowser *browser;
GList *services;
GtkTreeRowReference *tree_ref;
static GtkTreeStore *tree_store = NULL;
static GtkLabel *info_label = NULL;
static AvahiServer *server = NULL;
-static AvahiServiceTypeBrowser *service_type_browser = NULL;
+static AvahiSServiceTypeBrowser *service_type_browser = NULL;
static GHashTable *service_type_hash_table = NULL;
-static AvahiServiceResolver *service_resolver = NULL;
+static AvahiSServiceResolver *service_resolver = NULL;
static struct Service *current_service = NULL;
static struct Service *get_service(const gchar *service_type, const gchar *service_name, const gchar*domain_name, AvahiIfIndex interface, AvahiProtocol protocol) {
current_service = NULL;
if (service_resolver) {
- avahi_service_resolver_free(service_resolver);
+ avahi_s_service_resolver_free(service_resolver);
service_resolver = NULL;
}
g_free(s);
}
-static void service_browser_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *service_name, const gchar *service_type, const gchar *domain_name, gpointer userdata) {
+static void service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *service_name, const gchar *service_type, const gchar *domain_name, gpointer userdata) {
if (event == AVAHI_BROWSER_NEW) {
struct Service *s;
}
}
-static void service_type_browser_callback(AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *service_type, const gchar *domain, gpointer userdata) {
+static void service_type_browser_callback(AvahiSServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *service_type, const gchar *domain, gpointer userdata) {
struct ServiceType *st;
GtkTreePath *path;
GtkTreeIter iter;
g_hash_table_insert(service_type_hash_table, st->service_type, st);
- st->browser = avahi_service_browser_new(server, -1, AF_UNSPEC, st->service_type, domain, service_browser_callback, NULL);
+ st->browser = avahi_s_service_browser_new(server, -1, AF_UNSPEC, st->service_type, domain, service_browser_callback, NULL);
}
static void update_label(struct Service *s, const gchar *hostname, const AvahiAddress *a, guint16 port, AvahiStringList *txt) {
}
-static void service_resolver_callback(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const gchar *name, const gchar *type, const gchar *domain, const gchar *host_name, const AvahiAddress *a, guint16 port, AvahiStringList *txt, gpointer userdata) {
+static void service_resolver_callback(AvahiSServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const gchar *name, const gchar *type, const gchar *domain, const gchar *host_name, const AvahiAddress *a, guint16 port, AvahiStringList *txt, gpointer userdata) {
struct Service *s;
g_assert(r);
if (!(s = get_service_on_cursor()) || userdata != s) {
g_assert(r == service_resolver);
- avahi_service_resolver_free(service_resolver);
+ avahi_s_service_resolver_free(service_resolver);
service_resolver = NULL;
}
return;
if (service_resolver)
- avahi_service_resolver_free(service_resolver);
+ avahi_s_service_resolver_free(service_resolver);
update_label(s, NULL, NULL, 0, NULL);
- service_resolver = avahi_service_resolver_new(server, s->interface, s->protocol, s->service_name, s->service_type->service_type, s->domain_name, AF_UNSPEC, service_resolver_callback, s);
+ service_resolver = avahi_s_service_resolver_new(server, s->interface, s->protocol, s->service_name, s->service_type->service_type, s->domain_name, AF_UNSPEC, service_resolver_callback, s);
}
static gboolean main_window_on_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
g_assert(server);
- service_type_browser = avahi_service_type_browser_new(server, -1, AF_UNSPEC, argc >= 2 ? argv[1] : NULL, service_type_browser_callback, NULL);
+ service_type_browser = avahi_s_service_type_browser_new(server, -1, AF_UNSPEC, argc >= 2 ? argv[1] : NULL, service_type_browser_callback, NULL);
gtk_main();
static AvahiSimplePoll *simple_poll = NULL;
static void resolve_callback(
- AvahiServiceResolver *r,
+ AvahiSServiceResolver *r,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiResolverEvent event,
avahi_free(t);
}
- avahi_service_resolver_free(r);
+ avahi_s_service_resolver_free(r);
}
static void browse_callback(
- AvahiServiceBrowser *b,
+ AvahiSServiceBrowser *b,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiBrowserEvent event,
we free it. If the server is terminated before the callback
function is called the server will free the resolver for us. */
- if (!(avahi_service_resolver_new(s, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, resolve_callback, s)))
+ if (!(avahi_s_service_resolver_new(s, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, resolve_callback, s)))
fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_server_errno(s)));
}
int main(int argc, char*argv[]) {
AvahiServerConfig config;
AvahiServer *server = NULL;
- AvahiServiceBrowser *sb;
+ AvahiSServiceBrowser *sb;
int error;
int ret = 1;
}
/* Create the service browser */
- if (!(sb = avahi_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, browse_callback, server))) {
+ if (!(sb = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, browse_callback, server))) {
fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_server_errno(server)));
goto fail;
}
/* Cleanup things */
if (sb)
- avahi_service_browser_free(sb);
+ avahi_s_service_browser_free(sb);
if (server)
avahi_server_free(server);
#include <avahi-common/simple-watch.h>
#include <avahi-common/malloc.h>
-static AvahiEntryGroup *group = NULL;
+static AvahiSEntryGroup *group = NULL;
static AvahiSimplePoll *simple_poll = NULL;
static char *name = NULL;
static void create_services(AvahiServer *s);
-static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
+static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
assert(s);
assert(g == group);
/* If this is the first time we're called, let's create a new entry group */
if (!group) {
- if (!(group = avahi_entry_group_new(s, entry_group_callback, NULL))) {
+ if (!(group = avahi_s_entry_group_new(s, entry_group_callback, NULL))) {
fprintf(stderr, "avahi_entry_group_new() failed: %s\n", avahi_strerror(avahi_server_errno(s)));
goto fail;
}
}
/* Tell the server to register the service */
- if ((ret = avahi_entry_group_commit(group)) < 0) {
+ if ((ret = avahi_s_entry_group_commit(group)) < 0) {
fprintf(stderr, "Failed to commit entry_group: %s\n", avahi_strerror(ret));
goto fail;
}
* in AVAHI_SERVER_RUNNING state we will register them
* again with the new host name. */
if (group)
- avahi_entry_group_reset(group);
+ avahi_s_entry_group_reset(group);
}
}
/* Cleanup things */
if (group)
- avahi_entry_group_free(group);
+ avahi_s_entry_group_free(group);
if (server)
avahi_server_free(server);