printf ("ENTRY-GROUP: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata);
}
+static void avahi_entry_group2_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
+ printf ("ENTRY-GROUP2: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata);
+}
+
+
static void avahi_domain_browser_callback(
AvahiDomainBrowser *b,
AvahiIfIndex interface,
int main (int argc, char *argv[]) {
AvahiClient *avahi;
- AvahiEntryGroup *group;
+ AvahiEntryGroup *group, *group2;
AvahiDomainBrowser *domain;
AvahiServiceBrowser *sb;
AvahiServiceTypeBrowser *st;
AvahiHostNameResolver *hnr;
+ AvahiAddress *aar;
const char *ret;
int error;
uint32_t cookie;
else
printf ("Successfully created hostname resolver object\n");
+ aar = avahi_address_parse ("224.0.0.251", AF_UNSPEC, aar);
+ if (aar == NULL) {
+ printf ("failed to create address object\n");
+ } else {
+ group2 = avahi_entry_group_new (avahi, avahi_entry_group2_callback, "omghai222");
+ if ((error = avahi_entry_group_add_address (group2, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "test-mdns.local.", aar)) < 0)
+ {
+ printf ("*** failed to add address to entry group: %s\n", avahi_strerror (ret));
+ avahi_entry_group_free (group2);
+ } else {
+ printf ("*** success, added address\n");
+ avahi_entry_group_commit (group2);
+ }
+
+ }
+
avahi_elapse_time(&tv, 8000, 0);
poll_api->timeout_new(poll_api, &tv, test_entry_group_reset, group);
}
+/** Add a host/address pair */
+int avahi_entry_group_add_address(
+ AvahiEntryGroup *group,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiPublishFlags flags,
+ const char *name,
+ const AvahiAddress *a) {
+
+ DBusMessage *message = NULL, *reply = NULL;
+ int r = AVAHI_OK;
+ DBusError error;
+ AvahiClient *client;
+ int32_t i_interface, i_protocol;
+ uint32_t u_flags;
+ char s_address[AVAHI_ADDRESS_STR_MAX];
+ char *p_address = s_address;
+
+ assert(name);
+
+ client = group->client;
+
+ if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED)
+ return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
+
+ dbus_error_init(&error);
+
+ if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress"))) {
+ r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
+ goto fail;
+ }
+
+ i_interface = (int32_t) interface;
+ i_protocol = (int32_t) protocol;
+ u_flags = (uint32_t) flags;
+
+ if (!avahi_address_snprint (s_address, sizeof (s_address), a))
+ {
+ r = avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS);
+ goto fail;
+ }
+
+ if (!dbus_message_append_args(
+ message,
+ DBUS_TYPE_INT32, &i_interface,
+ DBUS_TYPE_INT32, &i_protocol,
+ DBUS_TYPE_UINT32, &u_flags,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &p_address,
+ DBUS_TYPE_INVALID)) {
+ r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY);
+ goto fail;
+ }
+
+ if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
+ dbus_error_is_set (&error)) {
+ r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
+ goto fail;
+ }
+
+ if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
+ dbus_error_is_set (&error)) {
+ r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
+ goto fail;
+ }
+
+ dbus_message_unref(message);
+ dbus_message_unref(reply);
+
+ return AVAHI_OK;
+
+fail:
+
+ if (dbus_error_is_set(&error)) {
+ r = avahi_client_set_dbus_error(client, &error);
+ dbus_error_free(&error);
+ }
+
+ if (message)
+ dbus_message_unref(message);
+
+ if (reply)
+ dbus_message_unref(reply);
+
+ return r;
+}
const char *domain,
va_list va);
+/** Add a host/address pair */
+int avahi_entry_group_add_address(
+ AvahiEntryGroup *group,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiPublishFlags flags,
+ const char *name,
+ const AvahiAddress *a);
+
#ifndef DOXYGEN_SHOULD_SKIP_THIS
AVAHI_C_DECL_END
#endif
AvahiAddressResolverCallback callback,
void *userdata) {
- char addr[64];
+ char addr[AVAHI_ADDRESS_STR_MAX];
assert (a);
AVAHI_IF_UNSPEC = -1 /**< Unspecified/all interface(s) */
};
+/** Maximum size of an address in string form */
+#define AVAHI_ADDRESS_STR_MAX 40 /* IPv6 Max = 4*8 + 7 + 1 for NUL */
+
/** Return TRUE if the specified interface index is valid */
#define AVAHI_IF_VALID(ifindex) (((ifindex) >= 0) || ((ifindex) == AVAHI_PROTO_UNSPEC))
/** Compare two addresses. Returns 0 when equal, a negative value when a < b, a positive value when a > b. */
int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b);
-/** Convert the specified address *a to a human readable character string */
+/** Convert the specified address *a to a human readable character string, use AVAHI_ADDRESS_STR_MAX to allocate an array of the right size */
char *avahi_address_snprint(char *ret_s, size_t length, const AvahiAddress *a);
/** Convert the specifeid human readable character string to an
const AvahiAddress *a,
AvahiLookupResultFlags flags,
void* userdata) {
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
if (a)
avahi_address_snprint(t, sizeof(t), a);
const char *hostname,
AvahiLookupResultFlags flags,
void* userdata) {
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
avahi_address_snprint(t, sizeof(t), a);
if (event != AVAHI_RESOLVER_FOUND)
avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain_name, resolver_event_to_string(event));
else {
- char t[64], *s;
+ char t[AVAHI_ADDRESS_STR_MAX], *s;
avahi_address_snprint(t, sizeof(t), a);
AvahiLookupResultFlags flags,
void* userdata) {
- char t[64] = "n/a";
+ char t[AVAHI_ADDRESS_STR_MAX] = "n/a";
if (a)
avahi_address_snprint(t, sizeof(t), a);
return;
if (avahi_s_entry_group_is_empty(a->entry_group)) {
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
avahi_address_snprint(t, sizeof(t), &a->address);
avahi_log_info("Registering new address %s on %s.", t, a->interface->hardware->name);
/* Clear the entry group */
if (a->entry_group && !avahi_s_entry_group_is_empty(a->entry_group)) {
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
avahi_address_snprint(t, sizeof(t), &a->address);
if (avahi_s_entry_group_get_state(a->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING &&
void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port) {
assert(i);
assert(p);
-/* char t[64]; */
+/* char t[AVAHI_ADDRESS_STR_MAX]; */
if (!avahi_interface_is_relevant(i))
return;
assert(i);
if (event == AVAHI_RESOLVER_FOUND) {
- char t[256], *pt = t;
+ char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
DBusMessage *reply;
assert(i);
if (event == AVAHI_RESOLVER_FOUND) {
- char t[256], *pt = t;
+ char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
DBusMessage *reply;
assert(i);
if (event == AVAHI_RESOLVER_FOUND) {
- char t[256], *pt = t;
+ char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
DBusMessage *reply;
reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, map_resolve_signal_name(event));
if (event == AVAHI_RESOLVER_FOUND) {
- char t[256], *pt = t;
+ char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, map_resolve_signal_name(event));
if (event == AVAHI_RESOLVER_FOUND) {
- char t[256], *pt = t;
+ char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, map_resolve_signal_name(event));
if (event == AVAHI_RESOLVER_FOUND) {
- char t[256], *pt = t;
+ char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
if (event == AVAHI_RESOLVER_FAILURE)
client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server)));
else if (event == AVAHI_RESOLVER_FOUND) {
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
avahi_address_snprint(t, sizeof(t), a);
client_output_printf(c, "+ %i %u %s %s\n", iface, protocol, hostname, t);
}
void* userdata) {
Client *c = userdata;
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
assert(c);
gchar t[512], address[64], *txt_s;
if (a && hostname) {
- char na[256];
+ char na[AVAHI_ADDRESS_STR_MAX];
avahi_address_snprint(na, sizeof(na), a);
snprintf(address, sizeof(address), "%s/%s:%u", hostname, na, port);
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-CFLAGS="$CFLAGS -g -O0" exec ./autogen.sh --sysconfdir=/etc --localstatedir=/var "$@"
+FLAGS="--sysconfdir=/etc --localstatedir=/var"
+
+# Feel free to add your own custom flags in here -Lathiat
+case "$USER" in
+ lathiat|sebest)
+ FLAGS="$FLAGS --disable-monodoc"
+ ;;
+esac
+
+CFLAGS="$CFLAGS -g -O0" exec ./autogen.sh $FLAGS "$@"
break;
case AVAHI_RESOLVER_FOUND: {
- char a[128], *t;
+ char a[AVAHI_ADDRESS_STR_MAX], *t;
fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
break;
case AVAHI_RESOLVER_FOUND: {
- char a[128], *t;
+ char a[AVAHI_ADDRESS_STR_MAX], *t;
fprintf(stderr, "(Resolver) Service '%s' of type '%s' in domain '%s':\n", name, type, domain);