]> git.meshlink.io Git - catta/commitdiff
* Add custom user-specific configure flags to bootstrap.sh
authorTrent Lloyd <lathiat@bur.st>
Mon, 17 Oct 2005 20:07:43 +0000 (20:07 +0000)
committerTrent Lloyd <lathiat@bur.st>
Mon, 17 Oct 2005 20:07:43 +0000 (20:07 +0000)
 * 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

13 files changed:
avahi-client/client-test.c
avahi-client/entrygroup.c
avahi-client/publish.h
avahi-client/resolver.c
avahi-common/address.h
avahi-core/avahi-test.c
avahi-core/iface.c
avahi-daemon/dbus-protocol.c
avahi-daemon/simple-protocol.c
avahi-discover-standalone/main.c
bootstrap.sh
examples/client-browse-services.c
examples/core-browse-services.c

index 14b9e84d3e37700424ad2fce805c03c0577886f2..076fb3b4f7e36df85a6aaf25e67cef87db5715e0 100644 (file)
@@ -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);
index 2d882e67fcb33d3910b8a4a562d317e11d6b8baa..0b7d2176874efbc19facda0e89224441161f6a0a 100644 (file)
@@ -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;
+}
index 7c678a9551771948dca9c213a1a869466624b834..cdce887ed2103d5f9032d68f6f5f883b166665aa 100644 (file)
@@ -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
index 37965cef482a78349b667d7c052efd08bf68fc0c..14d6acadee4d1178f2b57394880ccf2b16811510 100644 (file)
@@ -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);
 
index 665c9c7dc76b56cd16772d599692cebad4e75083..72a0e5e2d88de0e2e05cffef1feb9178bb85c1f6 100644 (file)
@@ -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
index cf8bd3b83c232aedb05913ff8b6bdced499acc12..8cf1d34853e23c641277187309d32fb4d90e8f70 100644 (file)
@@ -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);
index 2b11e5ffee2619d3aa03c19e7fe2376264b2057b..39d26c3a72d53779de41e2a1fcd28d04093e194e 100644 (file)
@@ -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;
index 3b2c76a38cd2d979fb71ba689dd5465613f82aee..d2d2d8ff5385cc3ddabf8cc1a34ec8bd0f975766 100644 (file)
@@ -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;
     
index 4844ca49f1094bb2e7a5814ec0a75f7185d3f4c3..aa81cd75974cc1171833866c669c8eb8b58b3e41 100644 (file)
@@ -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);
 
index 296b56db59405c460494cf3b33ccdad911939e31..bfc270d9e28a9a4a1b2fdf7a1c3e391cda3818e7 100644 (file)
@@ -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);
 
index 3157b5d278d34553d1f58b8ef7554f064a276826..11b724d321a938999045235faa94020e0f88df1c 100755 (executable)
 # 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 "$@"
index 7918cade7d3c346236ba882cf2a315c947c36d4a..3bbed112fa9d56ce30a0c0d16fdec6cf4c978438 100644 (file)
@@ -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);
             
index 5de47b3ae2e4399ed4849b6295b9018a42d55611..57fafe46f3263f6b4aff3cfdefa4437ee02e8a2f 100644 (file)
@@ -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);