summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Lloyd <lathiat@bur.st>2005-10-17 20:07:43 +0000
committerTrent Lloyd <lathiat@bur.st>2005-10-17 20:07:43 +0000
commit3adbda2cd5be48b7c630325f0f92e315d7eb2cfb (patch)
treefa98de69267ed3e7f1a3e915b2632afebe8ddb38
parentc1c236e751d126f3aeffe3ccf5da889dbf853b2f (diff)
* Add custom user-specific configure flags to bootstrap.sh
* Add new constant AVAHI_ADDRESS_STR_MAX for use with avahi_address_snprint arr ays * Update all our code to use AVAHI_ADDRESS_STR_MAX * Add avahi_client_add_address to avahi-client * Add avahi_client_add_address test to avahi-client git-svn-id: file:///home/lennart/svn/public/avahi/trunk@800 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rw-r--r--avahi-client/client-test.c24
-rw-r--r--avahi-client/entrygroup.c86
-rw-r--r--avahi-client/publish.h9
-rw-r--r--avahi-client/resolver.c2
-rw-r--r--avahi-common/address.h5
-rw-r--r--avahi-core/avahi-test.c8
-rw-r--r--avahi-core/iface.c6
-rw-r--r--avahi-daemon/dbus-protocol.c12
-rw-r--r--avahi-daemon/simple-protocol.c4
-rw-r--r--avahi-discover-standalone/main.c2
-rwxr-xr-xbootstrap.sh11
-rw-r--r--examples/client-browse-services.c2
-rw-r--r--examples/core-browse-services.c2
13 files changed, 151 insertions, 22 deletions
diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c
index 14b9e84..076fb3b 100644
--- a/avahi-client/client-test.c
+++ b/avahi-client/client-test.c
@@ -45,6 +45,11 @@ static void avahi_entry_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState
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,
@@ -209,11 +214,12 @@ static void terminate(AvahiTimeout *timeout, void *userdata) {
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;
@@ -280,6 +286,22 @@ int main (int argc, char *argv[]) {
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);
diff --git a/avahi-client/entrygroup.c b/avahi-client/entrygroup.c
index 2d882e6..0b7d217 100644
--- a/avahi-client/entrygroup.c
+++ b/avahi-client/entrygroup.c
@@ -728,3 +728,89 @@ fail:
}
+/** 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;
+}
diff --git a/avahi-client/publish.h b/avahi-client/publish.h
index 7c678a9..cdce887 100644
--- a/avahi-client/publish.h
+++ b/avahi-client/publish.h
@@ -153,6 +153,15 @@ int avahi_entry_group_update_service_txt_va(
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
diff --git a/avahi-client/resolver.c b/avahi-client/resolver.c
index 37965ce..14d6aca 100644
--- a/avahi-client/resolver.c
+++ b/avahi-client/resolver.c
@@ -618,7 +618,7 @@ AvahiAddressResolver * avahi_address_resolver_new_a(
AvahiAddressResolverCallback callback,
void *userdata) {
- char addr[64];
+ char addr[AVAHI_ADDRESS_STR_MAX];
assert (a);
diff --git a/avahi-common/address.h b/avahi-common/address.h
index 665c9c7..72a0e5e 100644
--- a/avahi-common/address.h
+++ b/avahi-common/address.h
@@ -51,6 +51,9 @@ enum {
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))
@@ -85,7 +88,7 @@ size_t avahi_address_get_size(const AvahiAddress *a);
/** 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
diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c
index cf8bd3b..8cf1d34 100644
--- a/avahi-core/avahi-test.c
+++ b/avahi-core/avahi-test.c
@@ -200,7 +200,7 @@ static void hnr_callback(
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);
@@ -217,7 +217,7 @@ static void ar_callback(
const char *hostname,
AvahiLookupResultFlags flags,
void* userdata) {
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
avahi_address_snprint(t, sizeof(t), a);
@@ -280,7 +280,7 @@ static void sr_callback(
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);
@@ -301,7 +301,7 @@ static void dsb_callback(
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);
diff --git a/avahi-core/iface.c b/avahi-core/iface.c
index 2b11e5f..39d26c3 100644
--- a/avahi-core/iface.c
+++ b/avahi-core/iface.c
@@ -63,7 +63,7 @@ void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs
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);
@@ -82,7 +82,7 @@ void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs
/* 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 &&
@@ -471,7 +471,7 @@ AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor
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;
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index 3b2c76a..d2d2d8f 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -997,7 +997,7 @@ static void sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfI
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;
@@ -1039,7 +1039,7 @@ static void sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInde
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;
@@ -1350,7 +1350,7 @@ static void sync_service_resolver_callback(
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;
@@ -1411,7 +1411,7 @@ static void async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfInd
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;
@@ -1498,7 +1498,7 @@ static void async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIf
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;
@@ -1597,7 +1597,7 @@ static void async_service_resolver_callback(
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;
diff --git a/avahi-daemon/simple-protocol.c b/avahi-daemon/simple-protocol.c
index 4844ca4..aa81cd7 100644
--- a/avahi-daemon/simple-protocol.c
+++ b/avahi-daemon/simple-protocol.c
@@ -181,7 +181,7 @@ static void host_name_resolver_callback(
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);
}
@@ -223,7 +223,7 @@ static void dns_server_browser_callback(
void* userdata) {
Client *c = userdata;
- char t[64];
+ char t[AVAHI_ADDRESS_STR_MAX];
assert(c);
diff --git a/avahi-discover-standalone/main.c b/avahi-discover-standalone/main.c
index 296b56d..bfc270d 100644
--- a/avahi-discover-standalone/main.c
+++ b/avahi-discover-standalone/main.c
@@ -242,7 +242,7 @@ static void update_label(struct Service *s, const gchar *hostname, const AvahiAd
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);
diff --git a/bootstrap.sh b/bootstrap.sh
index 3157b5d..11b724d 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -18,4 +18,13 @@
# 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 "$@"
diff --git a/examples/client-browse-services.c b/examples/client-browse-services.c
index 7918cad..3bbed11 100644
--- a/examples/client-browse-services.c
+++ b/examples/client-browse-services.c
@@ -62,7 +62,7 @@ static void resolve_callback(
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);
diff --git a/examples/core-browse-services.c b/examples/core-browse-services.c
index 5de47b3..57fafe4 100644
--- a/examples/core-browse-services.c
+++ b/examples/core-browse-services.c
@@ -73,7 +73,7 @@ static void resolve_callback(
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);