#include "log.h"
#include "querier.h"
-#define AVAHI_MAX_LOOKUPS_PER_BROWSER 15
+#define AVAHI_LOOKUPS_PER_BROWSER_MAX 15
struct AvahiSRBLookup {
AvahiSRecordBrowser *record_browser;
assert(AVAHI_IF_VALID(interface));
assert(AVAHI_PROTO_VALID(protocol));
- if (b->n_lookups >= AVAHI_MAX_LOOKUPS_PER_BROWSER)
+ if (b->n_lookups >= AVAHI_LOOKUPS_PER_BROWSER_MAX)
/* We don't like cyclic CNAMEs */
return NULL;
#include "cache.h"
#include "log.h"
-#define AVAHI_MAX_CACHE_ENTRIES 500
+#define AVAHI_CACHE_ENTRIES_MAX 500
static void remove_entry(AvahiCache *c, AvahiCacheEntry *e) {
AvahiCacheEntry *t;
/* avahi_log_debug("cache: couldn't find matching cache entry for %s", txt); */
- if (c->n_entries >= AVAHI_MAX_CACHE_ENTRIES)
+ if (c->n_entries >= AVAHI_CACHE_ENTRIES_MAX)
return;
if (!(e = avahi_new(AvahiCacheEntry, 1))) {
#endif
/** Maximum number of defined DNS servers for wide area DNS */
-#define AVAHI_MAX_WIDE_AREA_SERVERS 4
+#define AVAHI_WIDE_AREA_SERVERS_MAX 4
/** Prototype for callback functions which are called whenever the state of an AvahiServer object changes */
typedef void (*AvahiServerCallback) (AvahiServer *s, AvahiServerState state, void* userdata);
int reflect_ipv; /**< if enable_reflector is 1, enable/disable reflecting between IPv4 and IPv6 */
int add_service_cookie; /**< Add magic service cookie to all locally generated records implicitly */
int enable_wide_area; /**< Enable wide area support */
- AvahiAddress wide_area_servers[AVAHI_MAX_WIDE_AREA_SERVERS]; /** Unicast DNS server to use for wide area lookup */
+ AvahiAddress wide_area_servers[AVAHI_WIDE_AREA_SERVERS_MAX]; /** Unicast DNS server to use for wide area lookup */
unsigned n_wide_area_servers; /**< Number of servers in wide_area_servers[] */
int disallow_other_stacks; /**< Make sure that only one mDNS responder is run at the same time on the local machine. If this is enable Avahi will not set SO_REUSADDR on its sockets, effectively preventing other stacks from running on the local machine */
} AvahiServerConfig;
size_t max_size;
if (mtu <= 0)
- max_size = AVAHI_DNS_PACKET_MAX_SIZE;
+ max_size = AVAHI_DNS_PACKET_SIZE_MAX;
else if (mtu >= AVAHI_DNS_PACKET_EXTRA_SIZE)
max_size = mtu - AVAHI_DNS_PACKET_EXTRA_SIZE;
else
#include "rr.h"
#include "hashmap.h"
-#define AVAHI_DNS_PACKET_MAX_SIZE 9000
+#define AVAHI_DNS_PACKET_SIZE_MAX 9000
#define AVAHI_DNS_PACKET_HEADER_SIZE 12
#define AVAHI_DNS_PACKET_EXTRA_SIZE 48
/* Fill in hardware (MAC) address */
hw->mac_address_size = RTA_PAYLOAD(a);
- if (hw->mac_address_size > AVAHI_MAX_MAC_ADDRESS)
- hw->mac_address_size = AVAHI_MAX_MAC_ADDRESS;
+ if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX)
+ hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX;
memcpy(hw->mac_address, RTA_DATA(a), hw->mac_address_size);
break;
hw->mtu = ifm->ifm_data.ifi_mtu;
hw->mac_address_size = sdl->sdl_alen;
- if (hw->mac_address_size > AVAHI_MAX_MAC_ADDRESS)
- hw->mac_address_size = AVAHI_MAX_MAC_ADDRESS;
+ if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX)
+ hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX;
memcpy(hw->mac_address, sdl->sdl_data + sdl->sdl_nlen, hw->mac_address_size);
#error "No network configuration notification system available"
#endif
-#define AVAHI_MAX_MAC_ADDRESS 32
+#define AVAHI_MAC_ADDRESS_MAX 32
struct AvahiInterfaceMonitor {
AvahiServer *server;
unsigned mtu;
- uint8_t mac_address[AVAHI_MAX_MAC_ADDRESS];
+ uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX];
size_t mac_address_size;
AvahiSEntryGroup *entry_group;
#include "multicast-lookup.h"
#include "dns-srv-rr.h"
-#define AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS 100
+#define AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX 100
#define AVAHI_FLAGS_VALID(flags, max) (!((flags) & ~(max)))
avahi_record_get_estimate_size(pj->record) +
AVAHI_DNS_PACKET_HEADER_SIZE;
- if (size > AVAHI_DNS_PACKET_MAX_SIZE)
- size = AVAHI_DNS_PACKET_MAX_SIZE;
+ if (size > AVAHI_DNS_PACKET_SIZE_MAX)
+ size = AVAHI_DNS_PACKET_SIZE_MAX;
if (!(p = avahi_dns_packet_new_query(size)))
return; /* OOM */
/* OK, the packet was too small, so create one that fits */
size = avahi_record_get_estimate_size(rj->record) + AVAHI_DNS_PACKET_HEADER_SIZE;
- if (size > AVAHI_DNS_PACKET_MAX_SIZE)
- size = AVAHI_DNS_PACKET_MAX_SIZE;
+ if (size > AVAHI_DNS_PACKET_SIZE_MAX)
+ size = AVAHI_DNS_PACKET_SIZE_MAX;
if (!(p = avahi_dns_packet_new_response(size, 1)))
return; /* OOM */
avahi_dns_packet_free(reply);
size = avahi_record_get_estimate_size(r) + AVAHI_DNS_PACKET_HEADER_SIZE;
- if (size > AVAHI_DNS_PACKET_MAX_SIZE)
- size = AVAHI_DNS_PACKET_MAX_SIZE;
+ if (size > AVAHI_DNS_PACKET_SIZE_MAX)
+ size = AVAHI_DNS_PACKET_SIZE_MAX;
if (!(reply = avahi_dns_packet_new_reply(p, size, 0, 1)))
break; /* OOM */
assert(s);
if (!s->legacy_unicast_reflect_slots)
- s->legacy_unicast_reflect_slots = avahi_new0(AvahiLegacyUnicastReflectSlot*, AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS);
+ s->legacy_unicast_reflect_slots = avahi_new0(AvahiLegacyUnicastReflectSlot*, AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX);
- for (n = 0; n < AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; n++, s->legacy_unicast_reflect_id++) {
- idx = s->legacy_unicast_reflect_id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS;
+ for (n = 0; n < AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX; n++, s->legacy_unicast_reflect_id++) {
+ idx = s->legacy_unicast_reflect_id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
if (!s->legacy_unicast_reflect_slots[idx])
break;
assert(s);
assert(slot);
- idx = slot->id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS;
+ idx = slot->id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
assert(s->legacy_unicast_reflect_slots[idx] == slot);
if (!s->legacy_unicast_reflect_slots)
return;
- for (idx = 0; idx < AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; idx ++)
+ for (idx = 0; idx < AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX; idx ++)
if (s->legacy_unicast_reflect_slots[idx])
deallocate_slot(s, s->legacy_unicast_reflect_slots[idx]);
if (!s->legacy_unicast_reflect_slots)
return NULL;
- idx = id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS;
+ idx = id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
if (!s->legacy_unicast_reflect_slots[idx] || s->legacy_unicast_reflect_slots[idx]->id != id)
return NULL;
return;
}
-/* avahi_log_debug("new packet recieved on interface '%s.%i'.", i->hardware->name, i->protocol); */
+/* avahi_log_debug("new packet received on interface '%s.%i'.", i->hardware->name, i->protocol); */
port = avahi_port_from_sockaddr(sa);
avahi_address_from_sockaddr(sa, &a);
if (!is_mdns_mcast_address(dest) &&
!avahi_interface_address_on_link(i, &a)) {
- avahi_log_warn("Recivied non-local response on interface '%s.%i'.", i->hardware->name, i->protocol);
+ avahi_log_warn("Received non-local response on interface '%s.%i'.", i->hardware->name, i->protocol);
return;
}
return;
}
-/* avahi_log_debug("new legacy unicast packet recieved on interface '%s.%i'.", i->hardware->name, i->protocol); */
+/* avahi_log_debug("new legacy unicast packet received on interface '%s.%i'.", i->hardware->name, i->protocol); */
avahi_address_from_sockaddr(sa, &a);
#include "hashmap.h"
#include "wide-area.h"
-#define MAX_CACHE_ENTRIES 500
+#define CACHE_ENTRIES_MAX 500
typedef struct AvahiWideAreaCacheEntry AvahiWideAreaCacheEntry;
int cleanup_dead;
- AvahiAddress dns_servers[AVAHI_MAX_WIDE_AREA_SERVERS];
+ AvahiAddress dns_servers[AVAHI_WIDE_AREA_SERVERS_MAX];
unsigned n_dns_servers;
unsigned current_dns_server;
};
is_new = 1;
/* Enforce cache size */
- if (e->cache_n_entries >= MAX_CACHE_ENTRIES)
+ if (e->cache_n_entries >= CACHE_ENTRIES_MAX)
/* Eventually we should improve the caching algorithm here */
goto finish;
assert(e);
if (a) {
- for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_MAX_WIDE_AREA_SERVERS; a++, n--)
+ for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_WIDE_AREA_SERVERS_MAX; a++, n--)
if ((a->proto == AVAHI_PROTO_INET && e->fd_ipv4 >= 0) || (a->proto == AVAHI_PROTO_INET6 && e->fd_ipv6 >= 0))
e->dns_servers[e->n_dns_servers++] = *a;
} else {
typedef struct SyncServiceResolverInfo SyncServiceResolverInfo;
typedef struct AsyncServiceResolverInfo AsyncServiceResolverInfo;
-#define MAX_CLIENTS 256
-#define MAX_OBJECTS_PER_CLIENT 50
-#define MAX_ENTRIES_PER_ENTRY_GROUP 20
+#define CLIENTS_MAX 256
+#define OBJECTS_PER_CLIENT_MAX 50
+#define ENTRIES_PER_ENTRY_GROUP_MAX 20
/* #define VALGRIND_WORKAROUND 1 */
if (!create)
return NULL;
- if (server->n_clients >= MAX_CLIENTS)
+ if (server->n_clients >= CLIENTS_MAX)
return NULL;
/* If not existant yet, create a new entry */
goto fail;
}
- if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= MAX_ENTRIES_PER_ENTRY_GROUP) {
+ if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX) {
avahi_string_list_free(strlst);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
}
goto fail;
}
- if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= MAX_ENTRIES_PER_ENTRY_GROUP)
+ if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX)
return respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
if (domain && !*domain)
goto fail;
}
- if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= MAX_ENTRIES_PER_ENTRY_GROUP)
+ if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX)
return respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
if (!(avahi_address_parse(address, AVAHI_PROTO_UNSPEC, &a)))
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
return respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= MAX_OBJECTS_PER_CLIENT) {
+ if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name);
return respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
goto finish;
}
- resolv_conf = avahi_new0(char*, AVAHI_MAX_WIDE_AREA_SERVERS+1);
+ resolv_conf = avahi_new0(char*, AVAHI_WIDE_AREA_SERVERS_MAX+1);
- while (!feof(f) && i < AVAHI_MAX_WIDE_AREA_SERVERS) {
+ while (!feof(f) && i < AVAHI_WIDE_AREA_SERVERS_MAX) {
char ln[128];
char *p;
}
static void update_wide_area_servers(void) {
- AvahiAddress a[AVAHI_MAX_WIDE_AREA_SERVERS];
+ AvahiAddress a[AVAHI_WIDE_AREA_SERVERS_MAX];
unsigned n = 0;
char **p;
- for (p = resolv_conf; *p && n < AVAHI_MAX_WIDE_AREA_SERVERS; p++) {
+ for (p = resolv_conf; *p && n < AVAHI_WIDE_AREA_SERVERS_MAX; p++) {
if (!avahi_address_parse(*p, AVAHI_PROTO_UNSPEC, &a[n]))
avahi_log_warn("Failed to parse address '%s', ignoring.", *p);
else
/** Parent **/
if ((ret = daemon_retval_wait(20)) < 0) {
- avahi_log_error("Could not recieve return value from daemon process.");
+ avahi_log_error("Could not receive return value from daemon process.");
goto finish;
}
/** Parent **/
if ((ret = daemon_retval_wait(20)) < 0) {
- daemon_log(LOG_ERR, "Could not recieve return value from daemon process.");
+ daemon_log(LOG_ERR, "Could not receive return value from daemon process.");
goto finish;
}
* add support for subtypes in static services
* Add static host configuration like static services [lathiat]
* wrap avahi_server_add_record() via DBUS and in avahi-client [lathiat]
-* make sure that all limit definitions end with _MAX
* unify argument oder of functions returning a string in a user supplied buffer
later:
* replace avahi_server_is_service_local() by AVAHI_PUBLISH flag
* drop partially created created entries on failure
* add error state for server and entry group
+* make sure that all limit definitions end with _MAX