static void resolve_callback(
CattaSServiceResolver *r,
- CATTA_GCC_UNUSED CattaIfIndex interface,
+ CATTA_GCC_UNUSED CattaIfIndex iface,
CATTA_GCC_UNUSED CattaProtocol protocol,
CattaResolverEvent event,
const char *name,
static void browse_callback(
CattaSServiceBrowser *b,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
const char *name,
the callback function is called the server will free
the resolver for us. */
- if (!(catta_s_service_resolver_new(s, interface, protocol, name, type, domain, CATTA_PROTO_UNSPEC, 0, resolve_callback, s)))
+ if (!(catta_s_service_resolver_new(s, iface, protocol, name, type, domain, CATTA_PROTO_UNSPEC, 0, resolve_callback, s)))
fprintf(stderr, "Failed to resolve service '%s': %s\n", name, catta_strerror(catta_server_errno(s)));
break;
#define CATTA_ADDRESS_STR_MAX 40 /* IPv6 Max = 4*8 + 7 + 1 for NUL */
/** Return TRUE if the specified interface index is valid */
-#define CATTA_IF_VALID(ifindex) (((ifindex) >= 0) || ((ifindex) == CATTA_IF_UNSPEC))
+#define CATTA_IF_VALID(iface) (((iface) >= 0) || ((iface) == CATTA_IF_UNSPEC))
/** Return TRUE if the specified protocol is valid */
#define CATTA_PROTO_VALID(protocol) (((protocol) == CATTA_PROTO_INET) || ((protocol) == CATTA_PROTO_INET6) || ((protocol) == CATTA_PROTO_UNSPEC))
/** Callback prototype for CattaSRecordBrowser events */
typedef void (*CattaSRecordBrowserCallback)(
CattaSRecordBrowser *b, /**< The CattaSRecordBrowser object that is emitting this callback */
- CattaIfIndex interface, /**< Logical OS network interface number the record was found on */
+ CattaIfIndex iface, /**< Logical OS network interface number the record was found on */
CattaProtocol protocol, /**< Protocol number the record was found. */
CattaBrowserEvent event, /**< Browsing event, either CATTA_BROWSER_NEW or CATTA_BROWSER_REMOVE */
CattaRecord *record, /**< The record that was found */
/** Create a new browsing object for arbitrary RRs */
CattaSRecordBrowser *catta_s_record_browser_new(
CattaServer *server, /**< The server object to which attach this query */
- CattaIfIndex interface, /**< Logical OS interface number where to look for the records, or CATTA_IF_UNSPEC to look on interfaces */
+ CattaIfIndex iface, /**< Logical OS interface number where to look for the records, or CATTA_IF_UNSPEC to look on interfaces */
CattaProtocol protocol, /**< Protocol number to use when looking for the record, or CATTA_PROTO_UNSPEC to look on all protocols */
CattaKey *key, /**< The search key */
CattaLookupFlags flags, /**< Lookup flags. Must have set either CATTA_LOOKUP_FORCE_WIDE_AREA or CATTA_LOOKUP_FORCE_MULTICAST, since domain based detection is not available here. */
/** Callback prototype for CattaSHostNameResolver events */
typedef void (*CattaSHostNameResolverCallback)(
CattaSHostNameResolver *r,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaResolverEvent event, /**< Resolving event */
const char *host_name, /**< Host name which should be resolved. May differ in case from the query */
/** Create an CattaSHostNameResolver object for resolving a host name to an adddress. See CattaSRecordBrowser for more info on the paramters. */
CattaSHostNameResolver *catta_s_host_name_resolver_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *host_name, /**< The host name to look for */
CattaProtocol aprotocol, /**< The address family of the desired address or CATTA_PROTO_UNSPEC if doesn't matter. */
/** Callback prototype for CattaSAddressResolver events */
typedef void (*CattaSAddressResolverCallback)(
CattaSAddressResolver *r,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaResolverEvent event,
const CattaAddress *a,
/** Create an CattaSAddressResolver object. See CattaSRecordBrowser for more info on the paramters. */
CattaSAddressResolver *catta_s_address_resolver_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const CattaAddress *address,
CattaLookupFlags flags, /**< Lookup flags. */
/** Callback prototype for CattaSDomainBrowser events */
typedef void (*CattaSDomainBrowserCallback)(
CattaSDomainBrowser *b,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
const char *domain,
/** Create a new CattaSDomainBrowser object */
CattaSDomainBrowser *catta_s_domain_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *domain,
CattaDomainBrowserType type,
/** Callback prototype for CattaSServiceTypeBrowser events */
typedef void (*CattaSServiceTypeBrowserCallback)(
CattaSServiceTypeBrowser *b,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
const char *type,
/** Create a new CattaSServiceTypeBrowser object. */
CattaSServiceTypeBrowser *catta_s_service_type_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *domain,
CattaLookupFlags flags, /**< Lookup flags. */
/** Callback prototype for CattaSServiceBrowser events */
typedef void (*CattaSServiceBrowserCallback)(
CattaSServiceBrowser *b,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
const char *name /**< Service name, e.g. "Lennart's Files" */,
/** Create a new CattaSServiceBrowser object. */
CattaSServiceBrowser *catta_s_service_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *service_type /** DNS-SD service type, e.g. "_http._tcp" */,
const char *domain,
/** Callback prototype for CattaSServiceResolver events */
typedef void (*CattaSServiceResolverCallback)(
CattaSServiceResolver *r,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaResolverEvent event, /**< Is CATTA_RESOLVER_FOUND when the service was resolved successfully, and everytime it changes. Is CATTA_RESOLVER_TIMOUT when the service failed to resolve or disappeared. */
const char *name, /**< Service name */
/** Create a new CattaSServiceResolver object. The specified callback function will be called with the resolved service data. */
CattaSServiceResolver *catta_s_service_resolver_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *name,
const char *type,
int catta_server_add(
CattaServer *s, /**< The server object to add this record to */
CattaSEntryGroup *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. */
- CattaIfIndex interface, /**< A numeric index of a network interface to attach this record to, or CATTA_IF_UNSPEC to attach this record to all interfaces */
+ CattaIfIndex iface, /**< A numeric index of a network interface to attach this record to, or CATTA_IF_UNSPEC to attach this record to all interfaces */
CattaProtocol protocol, /**< A protocol family to attach this record to. One of the CATTA_PROTO_xxx constants. Use CATTA_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */
CattaPublishFlags flags, /**< Special flags for this record */
CattaRecord *r /**< The record to add. This function increases the reference counter of this object. */);
int catta_server_add_address(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
int catta_server_add_service(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name, /**< Service name, e.g. "Lennart's Files" */
int catta_server_add_service_strlst(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
int catta_server_add_service_subtype(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name, /**< Specify the name of main service you already added here */
int catta_server_update_service_txt_strlst(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
int catta_server_update_service_txt(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
...) CATTA_GCC_SENTINEL;
/** Check if there is a service locally defined and return the entry group it is attached to. Returns NULL if the service isn't local*/
-int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name, const char *type, const char *domain, CattaSEntryGroup** ret_group);
+int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, const char *name, const char *type, const char *domain, CattaSEntryGroup** ret_group);
CATTA_C_DECL_END
if (a->time_event)
catta_time_event_free(a->time_event);
- CATTA_LLIST_REMOVE(CattaAnnouncer, by_interface, a->interface->announcers, a);
+ CATTA_LLIST_REMOVE(CattaAnnouncer, by_interface, a->iface->announcers, a);
CATTA_LLIST_REMOVE(CattaAnnouncer, by_entry, a->entry->announcers, a);
catta_free(a);
} else {
struct timeval tv;
- catta_interface_post_probe(a->interface, a->entry->record, 0);
+ catta_interface_post_probe(a->iface, a->entry->record, 0);
catta_elapse_time(&tv, CATTA_PROBE_INTERVAL_MSEC, 0);
set_timeout(a, &tv);
if (a->entry->flags & CATTA_PUBLISH_UNIQUE)
/* Send the whole rrset at once */
- catta_server_prepare_matching_responses(a->server, a->interface, a->entry->record->key, 0);
+ catta_server_prepare_matching_responses(a->server, a->iface, a->entry->record->key, 0);
else
- catta_server_prepare_response(a->server, a->interface, a->entry, 0, 0);
+ catta_server_prepare_response(a->server, a->iface, a->entry, 0, 0);
- catta_server_generate_response(a->server, a->interface, NULL, NULL, 0, 0, 0);
+ catta_server_generate_response(a->server, a->iface, NULL, NULL, 0, 0, 0);
if (++a->n_iteration >= 4) {
/* Announcing done */
assert(i);
for (a = e->announcers; a; a = a->by_entry_next)
- if (a->interface == i)
+ if (a->iface == i)
return a;
return NULL;
assert(e);
assert(!e->dead);
- if (!catta_interface_match(i, e->interface, e->protocol) || !i->announcing || !catta_entry_is_commited(e))
+ if (!catta_interface_match(i, e->iface, e->protocol) || !i->announcing || !catta_entry_is_commited(e))
return;
/* We don't want duplicate announcers */
}
a->server = s;
- a->interface = i;
+ a->iface = i;
a->entry = e;
a->time_event = NULL;
assert(e);
assert(!e->dead);
- catta_interface_monitor_walk(s->monitor, e->interface, e->protocol, announce_walk_callback, e);
+ catta_interface_monitor_walk(s->monitor, e->iface, e->protocol, announce_walk_callback, e);
}
void catta_announce_group(CattaServer *s, CattaSEntryGroup *g) {
assert(e);
assert(!e->dead);
- if (!catta_interface_match(i, e->interface, e->protocol))
+ if (!catta_interface_match(i, e->iface, e->protocol))
return;
if (e->flags & CATTA_PUBLISH_NO_ANNOUNCE)
assert(e);
assert(!e->dead);
- catta_interface_monitor_walk(s->monitor, e->interface, e->protocol, reannounce_walk_callback, e);
+ catta_interface_monitor_walk(s->monitor, e->iface, e->protocol, reannounce_walk_callback, e);
}
void catta_goodbye_interface(CattaServer *s, CattaInterface *i, int send_goodbye, int remove) {
struct CattaAnnouncer {
CattaServer *server;
- CattaInterface *interface;
+ CattaInterface *iface;
CattaEntry *entry;
CattaTimeEvent *time_event;
struct CattaDNSServerInfo {
CattaSDNSServerBrowser *browser;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
CattaRecord *srv_record;
CattaSHostNameResolver *host_name_resolver;
CATTA_LLIST_HEAD(CattaDNSServerInfo, info);
};
-static CattaDNSServerInfo* get_server_info(CattaSDNSServerBrowser *b, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *r) {
+static CattaDNSServerInfo* get_server_info(CattaSDNSServerBrowser *b, CattaIfIndex iface, CattaProtocol protocol, CattaRecord *r) {
CattaDNSServerInfo *i;
assert(b);
assert(r);
for (i = b->info; i; i = i->info_next)
- if (i->interface == interface &&
+ if (i->iface == iface &&
i->protocol == protocol &&
catta_record_equal_no_ttl(r, i->srv_record))
return i;
static void host_name_resolver_callback(
CattaSHostNameResolver *r,
- CATTA_GCC_UNUSED CattaIfIndex interface,
+ CATTA_GCC_UNUSED CattaIfIndex iface,
CATTA_GCC_UNUSED CattaProtocol protocol,
CattaResolverEvent event,
const char *host_name,
i->browser->callback(
i->browser,
- i->interface,
+ i->iface,
i->protocol,
CATTA_BROWSER_NEW,
i->srv_record->data.srv.name,
static void record_browser_callback(
CattaSRecordBrowser*rr,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
assert(record);
assert(record->key->type == CATTA_DNS_TYPE_SRV);
- if (get_server_info(b, interface, protocol, record))
+ if (get_server_info(b, iface, protocol, record))
return;
if (b->n_info >= 10)
return; /* OOM */
i->browser = b;
- i->interface = interface;
+ i->iface = iface;
i->protocol = protocol;
i->srv_record = catta_record_ref(record);
i->host_name_resolver = catta_s_host_name_resolver_new(
b->server,
- interface, protocol,
+ iface, protocol,
record->data.srv.name,
b->aprotocol,
b->user_flags,
assert(record);
assert(record->key->type == CATTA_DNS_TYPE_SRV);
- if (!(i = get_server_info(b, interface, protocol, record)))
+ if (!(i = get_server_info(b, iface, protocol, record)))
return;
if (!i->host_name_resolver)
b->callback(
b,
- interface,
+ iface,
protocol,
event,
i->srv_record->data.srv.name,
b->callback(
b,
- interface,
+ iface,
protocol,
event,
NULL,
CattaSDNSServerBrowser *catta_s_dns_server_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *domain,
CattaDNSServerType type,
assert(server);
assert(callback);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(aprotocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
goto fail;
}
- if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+ if (!(b->record_browser = catta_s_record_browser_new(server, iface, protocol, k, flags, record_browser_callback, b)))
goto fail;
catta_key_unref(k);
static void record_browser_callback(
CattaSRecordBrowser*rr,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
}
- b->callback(b, interface, protocol, event, n, flags, b->userdata);
+ b->callback(b, iface, protocol, event, n, flags, b->userdata);
}
static void defer_callback(CattaTimeEvent *e, void *userdata) {
CattaSDomainBrowser *catta_s_domain_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *domain,
CattaDomainBrowserType type,
assert(server);
assert(callback);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, type < CATTA_DOMAIN_BROWSER_MAX, CATTA_ERR_INVALID_FLAGS);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
goto fail;
}
- if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+ if (!(b->record_browser = catta_s_record_browser_new(server, iface, protocol, k, flags, record_browser_callback, b)))
goto fail;
catta_key_unref(k);
static void record_browser_callback(
CattaSRecordBrowser*rr,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
return;
}
- b->callback(b, interface, protocol, event, type, domain, flags, b->userdata);
+ b->callback(b, iface, protocol, event, type, domain, flags, b->userdata);
} else
- b->callback(b, interface, protocol, event, NULL, b->domain_name, flags, b->userdata);
+ b->callback(b, iface, protocol, event, NULL, b->domain_name, flags, b->userdata);
}
CattaSServiceTypeBrowser *catta_s_service_type_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *domain,
CattaLookupFlags flags,
assert(server);
assert(callback);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
goto fail;
}
- if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+ if (!(b->record_browser = catta_s_record_browser_new(server, iface, protocol, k, flags, record_browser_callback, b)))
goto fail;
catta_key_unref(k);
static void record_browser_callback(
CattaSRecordBrowser*rr,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
assert(record->key->type == CATTA_DNS_TYPE_PTR);
- if (event == CATTA_BROWSER_NEW && catta_server_is_service_local(b->server, interface, protocol, record->data.ptr.name))
+ if (event == CATTA_BROWSER_NEW && catta_server_is_service_local(b->server, iface, protocol, record->data.ptr.name))
flags |= CATTA_LOOKUP_RESULT_LOCAL;
if (catta_service_name_split(record->data.ptr.name, service, sizeof(service), type, sizeof(type), domain, sizeof(domain)) < 0) {
return;
}
- b->callback(b, interface, protocol, event, service, type, domain, flags, b->userdata);
+ b->callback(b, iface, protocol, event, service, type, domain, flags, b->userdata);
} else
- b->callback(b, interface, protocol, event, NULL, b->service_type, b->domain_name, flags, b->userdata);
+ b->callback(b, iface, protocol, event, NULL, b->service_type, b->domain_name, flags, b->userdata);
}
CattaSServiceBrowser *catta_s_service_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *service_type,
const char *domain,
assert(callback);
assert(service_type);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
goto fail;
}
- if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+ if (!(b->record_browser = catta_s_record_browser_new(server, iface, protocol, k, flags, record_browser_callback, b)))
goto fail;
catta_key_unref(k);
unsigned ref;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
CattaLookupFlags flags;
CATTA_LLIST_FIELDS(CattaSRBLookup, lookups);
};
-static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r);
-static void lookup_drop_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r);
+static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex iface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r);
+static void lookup_drop_cname(CattaSRBLookup *l, CattaIfIndex iface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r);
static void transport_flags_from_domain(CattaServer *s, CattaLookupFlags *flags, const char *domain) {
assert(flags);
static CattaSRBLookup* lookup_new(
CattaSRecordBrowser *b,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaLookupFlags flags,
CattaKey *key) {
CattaSRBLookup *l;
assert(b);
- assert(CATTA_IF_VALID(interface));
+ assert(CATTA_IF_VALID(iface));
assert(CATTA_PROTO_VALID(protocol));
if (b->n_lookups >= CATTA_LOOKUPS_PER_BROWSER_MAX)
l->ref = 1;
l->record_browser = b;
- l->interface = interface;
+ l->iface = iface;
l->protocol = protocol;
l->key = catta_key_ref(key);
l->wide_area = NULL;
static CattaSRBLookup *lookup_find(
CattaSRecordBrowser *b,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaLookupFlags flags,
CattaKey *key) {
for (l = b->lookups; l; l = l->lookups_next) {
- if ((l->interface == CATTA_IF_UNSPEC || l->interface == interface) &&
- (l->interface == CATTA_PROTO_UNSPEC || l->protocol == protocol) &&
+ if ((l->iface == CATTA_IF_UNSPEC || l->iface == iface) &&
+ (l->iface == CATTA_PROTO_UNSPEC || l->protocol == protocol) &&
l->flags == flags &&
catta_key_equal(l->key, key))
static void lookup_multicast_callback(
CattaMulticastLookupEngine *e,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaLookupResultFlags flags,
if (r->key->clazz == CATTA_DNS_CLASS_IN &&
r->key->type == CATTA_DNS_TYPE_CNAME)
/* It's a CNAME record, so let's follow it. We allow browsing on both multicast and wide area. */
- lookup_handle_cname(l, interface, protocol, b->flags, r);
+ lookup_handle_cname(l, iface, protocol, b->flags, r);
else {
/* It's a normal record, so let's call the user callback */
- if (catta_server_is_record_local(b->server, interface, protocol, r))
+ if (catta_server_is_record_local(b->server, iface, protocol, r))
flags |= CATTA_LOOKUP_RESULT_LOCAL;
- b->callback(b, interface, protocol, event, r, flags, b->userdata);
+ b->callback(b, iface, protocol, event, r, flags, b->userdata);
}
break;
if (r->key->clazz == CATTA_DNS_CLASS_IN &&
r->key->type == CATTA_DNS_TYPE_CNAME)
/* It's a CNAME record, so let's drop that query! */
- lookup_drop_cname(l, interface, protocol, 0, r);
+ lookup_drop_cname(l, iface, protocol, 0, r);
else {
/* It's a normal record, so let's call the user callback */
assert(catta_key_equal(b->key, l->key));
- b->callback(b, interface, protocol, event, r, flags, b->userdata);
+ b->callback(b, iface, protocol, event, r, flags, b->userdata);
}
break;
} else {
assert(l->flags & CATTA_LOOKUP_USE_MULTICAST);
- if (!(l->multicast = catta_multicast_lookup_new(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l)))
+ if (!(l->multicast = catta_multicast_lookup_new(l->record_browser->server->multicast_lookup_engine, l->iface, l->protocol, l->key, lookup_multicast_callback, l)))
return -1;
}
} else {
assert(l->flags & CATTA_LOOKUP_USE_MULTICAST);
- n = (int) catta_multicast_lookup_engine_scan_cache(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l);
+ n = (int) catta_multicast_lookup_engine_scan_cache(l->record_browser->server->multicast_lookup_engine, l->iface, l->protocol, l->key, lookup_multicast_callback, l);
}
return n;
}
-static CattaSRBLookup* lookup_add(CattaSRecordBrowser *b, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaKey *key) {
+static CattaSRBLookup* lookup_add(CattaSRecordBrowser *b, CattaIfIndex iface, CattaProtocol protocol, CattaLookupFlags flags, CattaKey *key) {
CattaSRBLookup *l;
assert(b);
assert(!b->dead);
- if ((l = lookup_find(b, interface, protocol, flags, key)))
+ if ((l = lookup_find(b, iface, protocol, flags, key)))
return lookup_ref(l);
- if (!(l = lookup_new(b, interface, protocol, flags, key)))
+ if (!(l = lookup_new(b, iface, protocol, flags, key)))
return NULL;
return l;
return n;
}
-static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r) {
+static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex iface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r) {
CattaKey *k;
CattaSRBLookup *n;
assert(r->key->type == CATTA_DNS_TYPE_CNAME);
k = catta_key_new(r->data.ptr.name, l->record_browser->key->clazz, l->record_browser->key->type);
- n = lookup_add(l->record_browser, interface, protocol, flags, k);
+ n = lookup_add(l->record_browser, iface, protocol, flags, k);
catta_key_unref(k);
if (!n) {
lookup_unref(n);
}
-static void lookup_drop_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r) {
+static void lookup_drop_cname(CattaSRBLookup *l, CattaIfIndex iface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r) {
CattaKey *k;
CattaSRBLookup *n = NULL;
CattaRList *rl;
assert(n);
- if ((n->interface == CATTA_IF_UNSPEC || n->interface == interface) &&
- (n->interface == CATTA_PROTO_UNSPEC || n->protocol == protocol) &&
+ if ((n->iface == CATTA_IF_UNSPEC || n->iface == iface) &&
+ (n->iface == CATTA_PROTO_UNSPEC || n->protocol == protocol) &&
n->flags == flags &&
catta_key_equal(n->key, k))
break;
/* Create initial query */
assert(!b->root_lookup);
- b->root_lookup = lookup_add(b, b->interface, b->protocol, b->flags, b->key);
+ b->root_lookup = lookup_add(b, b->iface, b->protocol, b->flags, b->key);
assert(b->root_lookup);
n = lookup_go(b->root_lookup);
catta_server_set_errno(b->server, CATTA_ERR_FAILURE);
b->callback(
- b, b->interface, b->protocol, CATTA_BROWSER_FAILURE, NULL,
+ b, b->iface, b->protocol, CATTA_BROWSER_FAILURE, NULL,
b->flags & CATTA_LOOKUP_USE_WIDE_AREA ? CATTA_LOOKUP_RESULT_WIDE_AREA : CATTA_LOOKUP_RESULT_MULTICAST,
b->userdata);
/* Tell the client that we're done with the cache */
b->callback(
- b, b->interface, b->protocol, CATTA_BROWSER_CACHE_EXHAUSTED, NULL,
+ b, b->iface, b->protocol, CATTA_BROWSER_CACHE_EXHAUSTED, NULL,
b->flags & CATTA_LOOKUP_USE_WIDE_AREA ? CATTA_LOOKUP_RESULT_WIDE_AREA : CATTA_LOOKUP_RESULT_MULTICAST,
b->userdata);
* entries, we assume that it is complete, and tell the user
* so by firing ALL_FOR_NOW. */
- b->callback(b, b->interface, b->protocol, CATTA_BROWSER_ALL_FOR_NOW, NULL, CATTA_LOOKUP_RESULT_WIDE_AREA, b->userdata);
+ b->callback(b, b->iface, b->protocol, CATTA_BROWSER_ALL_FOR_NOW, NULL, CATTA_LOOKUP_RESULT_WIDE_AREA, b->userdata);
}
}
CattaSRecordBrowser *catta_s_record_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaKey *key,
CattaLookupFlags flags,
assert(key);
assert(callback);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, !catta_key_is_pattern(key), CATTA_ERR_IS_PATTERN);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, catta_key_is_valid(key), CATTA_ERR_INVALID_KEY);
b->dead = 0;
b->server = server;
- b->interface = interface;
+ b->iface = iface;
b->protocol = protocol;
b->key = catta_key_ref(key);
b->flags = flags;
CattaServer *server;
CattaKey *key;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
CattaLookupFlags flags;
if (e->time_event)
catta_time_event_free(e->time_event);
- catta_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, CATTA_BROWSER_REMOVE);
+ catta_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->iface, e->record, CATTA_BROWSER_REMOVE);
catta_record_unref(e->record);
}
c->server = server;
- c->interface = iface;
+ c->iface = iface;
if (!(c->hashmap = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, NULL, NULL))) {
catta_log_error(__FILE__": Out of memory.");
assert(percent > 0);
/* Request a cache update if we are subscribed to this entry */
- if (catta_querier_shall_refresh_cache(e->cache->interface, e->record->key))
- catta_interface_post_query(e->cache->interface, e->record->key, 0, NULL);
+ if (catta_querier_shall_refresh_cache(e->cache->iface, e->record->key))
+ catta_interface_post_query(e->cache->iface, e->record->key, 0, NULL);
/* Check again later */
next_expiry(e->cache, e, percent);
c->n_entries++;
/* Notify subscribers */
- catta_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, CATTA_BROWSER_NEW);
+ catta_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->iface, e->record, CATTA_BROWSER_NEW);
}
e->origin = *a;
struct CattaCache {
CattaServer *server;
- CattaInterface *interface;
+ CattaInterface *iface;
CattaHashmap *hashmap;
time_t last_rand_timestamp;
};
-CattaCache *catta_cache_new(CattaServer *server, CattaInterface *interface);
+CattaCache *catta_cache_new(CattaServer *server, CattaInterface *iface);
void catta_cache_free(CattaCache *c);
void catta_cache_update(CattaCache *c, CattaRecord *r, int cache_flush, const CattaAddress *a);
int catta_server_add_dns_server_address(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *domain,
/** Callback prototype for CattaSDNSServerBrowser events */
typedef void (*CattaSDNSServerBrowserCallback)(
CattaSDNSServerBrowser *b,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
const char *host_name, /**< Host name of the DNS server, probably useless */
/** Create a new CattaSDNSServerBrowser object */
CattaSDNSServerBrowser *catta_s_dns_server_browser_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *domain,
CattaDNSServerType type,
}
}
-static int check_record_conflict(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *r, CattaPublishFlags flags) {
+static int check_record_conflict(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, CattaRecord *r, CattaPublishFlags flags) {
CattaEntry *e;
assert(s);
continue;
}
- if ((interface <= 0 ||
- e->interface <= 0 ||
- e->interface == interface) &&
+ if ((iface <= 0 ||
+ e->iface <= 0 ||
+ e->iface == iface) &&
(protocol == CATTA_PROTO_UNSPEC ||
e->protocol == CATTA_PROTO_UNSPEC ||
e->protocol == protocol))
static CattaEntry * server_add_internal(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
CattaRecord *r) {
assert(r);
CATTA_CHECK_VALIDITY_RETURN_NULL(s, s->state != CATTA_SERVER_FAILURE && s->state != CATTA_SERVER_INVALID, CATTA_ERR_BAD_STATE);
- CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_FLAGS_VALID(
flags,
/* Find the first matching entry */
for (e = catta_hashmap_lookup(s->entries_by_key, r->key); e; e = e->by_key_next) {
- if (!e->dead && e->group == g && e->interface == interface && e->protocol == protocol)
+ if (!e->dead && e->group == g && e->iface == iface && e->protocol == protocol)
break;
is_first = 0;
/* Add a new record */
- if (check_record_conflict(s, interface, protocol, r, flags) < 0) {
+ if (check_record_conflict(s, iface, protocol, r, flags) < 0) {
catta_server_set_errno(s, CATTA_ERR_COLLISION);
return NULL;
}
e->server = s;
e->record = catta_record_ref(r);
e->group = g;
- e->interface = interface;
+ e->iface = iface;
e->protocol = protocol;
e->flags = flags;
e->dead = 0;
int catta_server_add(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
CattaRecord *r) {
- if (!server_add_internal(s, g, interface, protocol, flags, r))
+ if (!server_add_internal(s, g, iface, protocol, flags, r))
return catta_server_errno(s);
return CATTA_OK;
if (!(t = catta_record_to_string(e->record)))
return catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
- snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->interface, e->protocol);
+ snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->iface, e->protocol);
catta_free(t);
callback(ln, userdata);
static CattaEntry *server_add_ptr_internal(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
uint32_t ttl,
}
r->data.ptr.name = catta_normalize_name_strdup(dest);
- e = server_add_internal(s, g, interface, protocol, flags, r);
+ e = server_add_internal(s, g, iface, protocol, flags, r);
catta_record_unref(r);
return e;
}
int catta_server_add_ptr(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
uint32_t ttl,
assert(s);
- if (!(e = server_add_ptr_internal(s, g, interface, protocol, flags, ttl, name, dest)))
+ if (!(e = server_add_ptr_internal(s, g, iface, protocol, flags, ttl, name, dest)))
return catta_server_errno(s);
return CATTA_OK;
int catta_server_add_address(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
assert(s);
assert(a);
- CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY(s, CATTA_PROTO_VALID(protocol) && CATTA_PROTO_VALID(a->proto), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY(s, CATTA_FLAGS_VALID(flags,
CATTA_PUBLISH_NO_REVERSE|
r->data.aaaa.address = a->data.ipv6;
}
- entry = server_add_internal(s, g, interface, protocol, (flags & ~ CATTA_PUBLISH_NO_REVERSE) | CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_ALLOW_MULTIPLE, r);
+ entry = server_add_internal(s, g, iface, protocol, (flags & ~ CATTA_PUBLISH_NO_REVERSE) | CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_ALLOW_MULTIPLE, r);
catta_record_unref(r);
if (!entry) {
char reverse_n[CATTA_DOMAIN_NAME_MAX];
catta_reverse_lookup_name(a, reverse_n, sizeof(reverse_n));
- if (!(reverse = server_add_ptr_internal(s, g, interface, protocol, flags | CATTA_PUBLISH_UNIQUE, CATTA_DEFAULT_TTL_HOST_NAME, reverse_n, name))) {
+ if (!(reverse = server_add_ptr_internal(s, g, iface, protocol, flags | CATTA_PUBLISH_UNIQUE, CATTA_DEFAULT_TTL_HOST_NAME, reverse_n, name))) {
ret = catta_server_errno(s);
goto finish;
}
static CattaEntry *server_add_txt_strlst_nocopy(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
uint32_t ttl,
}
r->data.txt.string_list = strlst;
- e = server_add_internal(s, g, interface, protocol, flags, r);
+ e = server_add_internal(s, g, iface, protocol, flags, r);
catta_record_unref(r);
return e;
static int server_add_service_strlst_nocopy(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
assert(type);
assert(name);
- CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_FLAGS_VALID(flags,
CATTA_PUBLISH_NO_COOKIE|
/* Add service enumeration PTR record */
- if (!(ptr_entry = server_add_ptr_internal(s, g, interface, protocol, 0, CATTA_DEFAULT_TTL, ptr_name, svc_name))) {
+ if (!(ptr_entry = server_add_ptr_internal(s, g, iface, protocol, 0, CATTA_DEFAULT_TTL, ptr_name, svc_name))) {
ret = catta_server_errno(s);
goto fail;
}
r->data.srv.port = port;
r->data.srv.name = h;
h = NULL;
- srv_entry = server_add_internal(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE, r);
+ srv_entry = server_add_internal(s, g, iface, protocol, CATTA_PUBLISH_UNIQUE, r);
catta_record_unref(r);
if (!srv_entry) {
if (!(flags & CATTA_PUBLISH_NO_COOKIE))
strlst = add_magic_cookie(s, strlst);
- txt_entry = server_add_txt_strlst_nocopy(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE, CATTA_DEFAULT_TTL, svc_name, strlst);
+ txt_entry = server_add_txt_strlst_nocopy(s, g, iface, protocol, CATTA_PUBLISH_UNIQUE, CATTA_DEFAULT_TTL, svc_name, strlst);
strlst = NULL;
if (!txt_entry) {
/* Add service type enumeration record */
- if (!(enum_entry = server_add_ptr_internal(s, g, interface, protocol, 0, CATTA_DEFAULT_TTL, enum_ptr, ptr_name))) {
+ if (!(enum_entry = server_add_ptr_internal(s, g, iface, protocol, 0, CATTA_DEFAULT_TTL, enum_ptr, ptr_name))) {
ret = catta_server_errno(s);
goto fail;
}
int catta_server_add_service_strlst(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
assert(type);
assert(name);
- return server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, catta_string_list_copy(strlst));
+ return server_add_service_strlst_nocopy(s, g, iface, protocol, flags, name, type, domain, host, port, catta_string_list_copy(strlst));
}
int catta_server_add_service(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
int ret;
va_start(va, port);
- ret = server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, catta_string_list_new_va(va));
+ ret = server_add_service_strlst_nocopy(s, g, iface, protocol, flags, name, type, domain, host, port, catta_string_list_new_va(va));
va_end(va);
return ret;
static int server_update_service_txt_strlst_nocopy(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
assert(type);
assert(name);
- CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_FLAGS_VALID(flags,
CATTA_PUBLISH_NO_COOKIE|
if (!(flags & CATTA_PUBLISH_NO_COOKIE))
strlst = add_magic_cookie(s, strlst);
- e = server_add_txt_strlst_nocopy(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_UPDATE, CATTA_DEFAULT_TTL, svc_name, strlst);
+ e = server_add_txt_strlst_nocopy(s, g, iface, protocol, CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_UPDATE, CATTA_DEFAULT_TTL, svc_name, strlst);
strlst = NULL;
if (!e)
int catta_server_update_service_txt_strlst(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
const char *domain,
CattaStringList *strlst) {
- return server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, catta_string_list_copy(strlst));
+ return server_update_service_txt_strlst_nocopy(s, g, iface, protocol, flags, name, type, domain, catta_string_list_copy(strlst));
}
/** Update the TXT record for a service with the NULL termonate list of strings */
int catta_server_update_service_txt(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
int ret;
va_start(va, domain);
- ret = server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, catta_string_list_new_va(va));
+ ret = server_update_service_txt_strlst_nocopy(s, g, iface, protocol, flags, name, type, domain, catta_string_list_new_va(va));
va_end(va);
return ret;
int catta_server_add_service_subtype(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *name,
assert(type);
assert(subtype);
- CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_FLAGS_VALID(flags, CATTA_PUBLISH_USE_MULTICAST|CATTA_PUBLISH_USE_WIDE_AREA), CATTA_ERR_INVALID_FLAGS);
CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_name(name), CATTA_ERR_INVALID_SERVICE_NAME);
goto fail;
}
- if ((ret = catta_server_add_ptr(s, g, interface, protocol, 0, CATTA_DEFAULT_TTL, ptr_name, svc_name)) < 0)
+ if ((ret = catta_server_add_ptr(s, g, iface, protocol, 0, CATTA_DEFAULT_TTL, ptr_name, svc_name)) < 0)
goto fail;
fail:
static CattaEntry *server_add_dns_server_name(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *domain,
r->data.srv.weight = 0;
r->data.srv.port = port;
r->data.srv.name = n;
- e = server_add_internal(s, g, interface, protocol, 0, r);
+ e = server_add_internal(s, g, iface, protocol, 0, r);
catta_record_unref(r);
return e;
int catta_server_add_dns_server_address(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
const char *domain,
assert(s);
assert(address);
- CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY(s, CATTA_PROTO_VALID(protocol) && CATTA_PROTO_VALID(address->proto), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY(s, CATTA_FLAGS_VALID(flags, CATTA_PUBLISH_USE_MULTICAST|CATTA_PUBLISH_USE_WIDE_AREA), CATTA_ERR_INVALID_FLAGS);
CATTA_CHECK_VALIDITY(s, type == CATTA_DNS_SERVER_UPDATE || type == CATTA_DNS_SERVER_RESOLVE, CATTA_ERR_INVALID_FLAGS);
if (!r)
return catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
- a_entry = server_add_internal(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_ALLOW_MULTIPLE, r);
+ a_entry = server_add_internal(s, g, iface, protocol, CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_ALLOW_MULTIPLE, r);
catta_record_unref(r);
if (!a_entry)
return catta_server_errno(s);
- if (!(s_entry = server_add_dns_server_name(s, g, interface, protocol, flags, domain, type, n, port))) {
+ if (!(s_entry = server_add_dns_server_name(s, g, iface, protocol, flags, domain, type, n, port))) {
if (!(flags & CATTA_PUBLISH_UPDATE))
catta_entry_free(s, a_entry);
return catta_server_errno(s);
"Memory exhausted",
"The object passed in was not valid",
"Daemon not running",
- "Invalid interface index",
+ "Invalid iface index",
"Invalid protocol specification",
"Invalid flags",
if (m->list_complete &&
catta_interface_address_is_relevant(a) &&
- catta_interface_is_relevant(a->interface) &&
+ catta_interface_is_relevant(a->iface) &&
!remove_rrs &&
m->server->config.publish_addresses &&
(m->server->state == CATTA_SERVER_RUNNING ||
char t[CATTA_ADDRESS_STR_MAX];
CattaProtocol p;
- p = (a->interface->protocol == CATTA_PROTO_INET && m->server->config.publish_a_on_ipv6) ||
- (a->interface->protocol == CATTA_PROTO_INET6 && m->server->config.publish_aaaa_on_ipv4) ? CATTA_PROTO_UNSPEC : a->interface->protocol;
+ p = (a->iface->protocol == CATTA_PROTO_INET && m->server->config.publish_a_on_ipv6) ||
+ (a->iface->protocol == CATTA_PROTO_INET6 && m->server->config.publish_aaaa_on_ipv4) ? CATTA_PROTO_UNSPEC : a->iface->protocol;
catta_address_snprint(t, sizeof(t), &a->address);
- catta_log_info("Registering new address record for %s on %s.%s.", t, a->interface->hardware->name, p == CATTA_PROTO_UNSPEC ? "*" : catta_proto_to_string(p));
+ catta_log_info("Registering new address record for %s on %s.%s.", t, a->iface->hardware->name, p == CATTA_PROTO_UNSPEC ? "*" : catta_proto_to_string(p));
- if (catta_server_add_address(m->server, a->entry_group, a->interface->hardware->index, p, m->server->config.publish_no_reverse ? CATTA_PUBLISH_NO_REVERSE : 0, NULL, &a->address) < 0) {
+ if (catta_server_add_address(m->server, a->entry_group, a->iface->hardware->index, p, m->server->config.publish_no_reverse ? CATTA_PUBLISH_NO_REVERSE : 0, NULL, &a->address) < 0) {
catta_log_warn(__FILE__": catta_server_add_address() failed: %s", catta_strerror(m->server->error));
catta_s_entry_group_free(a->entry_group);
a->entry_group = NULL;
char t[CATTA_ADDRESS_STR_MAX];
catta_address_snprint(t, sizeof(t), &a->address);
- catta_log_info("Withdrawing address record for %s on %s.", t, a->interface->hardware->name);
+ catta_log_info("Withdrawing address record for %s on %s.", t, a->iface->hardware->name);
if (catta_s_entry_group_get_state(a->entry_group) == CATTA_ENTRY_GROUP_REGISTERING &&
m->server->state == CATTA_SERVER_REGISTERING)
void catta_interface_address_free(CattaInterfaceAddress *a) {
assert(a);
- assert(a->interface);
+ assert(a->iface);
catta_interface_address_update_rrs(a, 1);
- CATTA_LLIST_REMOVE(CattaInterfaceAddress, address, a->interface->addresses, a);
+ CATTA_LLIST_REMOVE(CattaInterfaceAddress, address, a->iface->addresses, a);
if (a->entry_group)
catta_s_entry_group_free(a->entry_group);
- interface_mdns_mcast_rejoin(a->interface);
+ interface_mdns_mcast_rejoin(a->iface);
catta_free(a);
}
catta_probe_scheduler_free(i->probe_scheduler);
catta_cache_free(i->cache);
- CATTA_LLIST_REMOVE(CattaInterface, interface, i->monitor->interfaces, i);
+ CATTA_LLIST_REMOVE(CattaInterface, iface, i->monitor->interfaces, i);
CATTA_LLIST_REMOVE(CattaInterface, by_hardware, i->hardware->interfaces, i);
catta_free(i);
goto fail; /* OOM */
CATTA_LLIST_PREPEND(CattaInterface, by_hardware, hw->interfaces, i);
- CATTA_LLIST_PREPEND(CattaInterface, interface, m->interfaces, i);
+ CATTA_LLIST_PREPEND(CattaInterface, iface, m->interfaces, i);
return i;
if (!(a = catta_new(CattaInterfaceAddress, 1)))
return NULL;
- a->interface = i;
+ a->iface = i;
a->monitor = m;
a->address = *addr;
a->prefix_len = prefix_len;
assert(m);
- for (i = m->interfaces; i; i = i->interface_next)
+ for (i = m->interfaces; i; i = i->iface_next)
catta_interface_check_relevant(i);
}
CattaInterface *i;
assert(m);
- for (i = m->interfaces; i; i = i->interface_next) {
+ for (i = m->interfaces; i; i = i->iface_next) {
if (catta_interface_is_relevant(i)) {
char ln[256];
snprintf(ln, sizeof(ln), ";;; INTERFACE %s.%s ;;;", i->hardware->name, catta_proto_to_string(i->protocol));
/* Publish link-local and deprecated IP addresses only if they are
* the only ones on the link */
- for (b = a->interface->addresses; b; b = b->address_next) {
+ for (b = a->iface->addresses; b; b = b->address_next) {
if (b == a)
continue;
return 1;
}
-void catta_interface_monitor_walk(CattaInterfaceMonitor *m, CattaIfIndex interface, CattaProtocol protocol, CattaInterfaceMonitorWalkCallback callback, void* userdata) {
+void catta_interface_monitor_walk(CattaInterfaceMonitor *m, CattaIfIndex iface, CattaProtocol protocol, CattaInterfaceMonitorWalkCallback callback, void* userdata) {
assert(m);
assert(callback);
- if (interface != CATTA_IF_UNSPEC) {
+ if (iface != CATTA_IF_UNSPEC) {
if (protocol != CATTA_PROTO_UNSPEC) {
CattaInterface *i;
- if ((i = catta_interface_monitor_get_interface(m, interface, protocol)))
+ if ((i = catta_interface_monitor_get_interface(m, iface, protocol)))
callback(m, i, userdata);
} else {
CattaHwInterface *hw;
CattaInterface *i;
- if ((hw = catta_interface_monitor_get_hw_interface(m, interface)))
+ if ((hw = catta_interface_monitor_get_hw_interface(m, iface)))
for (i = hw->interfaces; i; i = i->by_hardware_next)
- if (catta_interface_match(i, interface, protocol))
+ if (catta_interface_match(i, iface, protocol))
callback(m, i, userdata);
}
} else {
CattaInterface *i;
- for (i = m->interfaces; i; i = i->interface_next)
- if (catta_interface_match(i, interface, protocol))
+ for (i = m->interfaces; i; i = i->iface_next)
+ if (catta_interface_match(i, iface, protocol))
callback(m, i, userdata);
}
}
assert(m);
assert(a);
- for (i = m->interfaces; i; i = i->interface_next)
+ for (i = m->interfaces; i; i = i->iface_next)
for (ia = i->addresses; ia; ia = ia->address_next)
if (catta_address_cmp(a, &ia->address) == 0)
return 1;
* attached. This is sometimes ambiguous, but we have to live with
* it. */
- for (i = m->interfaces; i; i = i->interface_next) {
+ for (i = m->interfaces; i; i = i->iface_next) {
CattaInterfaceAddress *ai;
if (i->protocol != a->proto)
CattaInterfaceMonitor *monitor;
CattaHwInterface *hardware;
- CATTA_LLIST_FIELDS(CattaInterface, interface);
+ CATTA_LLIST_FIELDS(CattaInterface, iface);
CATTA_LLIST_FIELDS(CattaInterface, by_hardware);
CattaProtocol protocol;
struct CattaInterfaceAddress {
CattaInterfaceMonitor *monitor;
- CattaInterface *interface;
+ CattaInterface *iface;
CATTA_LLIST_FIELDS(CattaInterfaceAddress, address);
uint16_t id, original_id;
CattaAddress address;
uint16_t port;
- int interface;
+ int iface;
struct timeval elapse_time;
CattaTimeEvent *time_event;
};
CattaPublishFlags flags;
CattaRecord *record;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
CATTA_LLIST_FIELDS(CattaEntry, entries);
int catta_server_set_errno(CattaServer *s, int error);
-int catta_server_is_service_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name);
-int catta_server_is_record_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *record);
+int catta_server_is_service_local(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, const char *name);
+int catta_server_is_record_local(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, CattaRecord *record);
int catta_server_add_ptr(
CattaServer *s,
CattaSEntryGroup *g,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaPublishFlags flags,
uint32_t ttl,
CattaMulticastLookupCallback callback;
void *userdata;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
int queriers_added;
catta_time_event_free(l->all_for_now_event);
l->all_for_now_event = NULL;
- l->callback(l->engine, l->interface, l->protocol, CATTA_BROWSER_ALL_FOR_NOW, CATTA_LOOKUP_RESULT_MULTICAST, NULL, l->userdata);
+ l->callback(l->engine, l->iface, l->protocol, CATTA_BROWSER_ALL_FOR_NOW, CATTA_LOOKUP_RESULT_MULTICAST, NULL, l->userdata);
}
CattaMulticastLookup *catta_multicast_lookup_new(
CattaMulticastLookupEngine *e,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaKey *key,
CattaMulticastLookupCallback callback,
struct timeval tv;
assert(e);
- assert(CATTA_IF_VALID(interface));
+ assert(CATTA_IF_VALID(iface));
assert(CATTA_PROTO_VALID(protocol));
assert(key);
assert(callback);
l->cname_key = catta_key_new_cname(l->key);
l->callback = callback;
l->userdata = userdata;
- l->interface = interface;
+ l->iface = iface;
l->protocol = protocol;
l->all_for_now_event = NULL;
l->queriers_added = 0;
CATTA_LLIST_PREPEND(CattaMulticastLookup, lookups, e->lookups, l);
- catta_querier_add_for_all(e->server, interface, protocol, l->key, &tv);
+ catta_querier_add_for_all(e->server, iface, protocol, l->key, &tv);
l->queriers_added = 1;
/* Add a second */
l->callback = NULL;
if (l->queriers_added) {
- catta_querier_remove_for_all(l->engine->server, l->interface, l->protocol, l->key);
+ catta_querier_remove_for_all(l->engine->server, l->iface, l->protocol, l->key);
l->queriers_added = 0;
}
CattaMulticastLookupCallback callback;
void *userdata;
CattaKey *key, *cname_key;
- CattaInterface *interface;
+ CattaInterface *iface;
unsigned n_found;
};
cbdata->callback(
cbdata->engine,
- cbdata->interface->hardware->index,
- cbdata->interface->protocol,
+ cbdata->iface->hardware->index,
+ cbdata->iface->protocol,
CATTA_BROWSER_NEW,
CATTA_LOOKUP_RESULT_CACHED|CATTA_LOOKUP_RESULT_MULTICAST,
e->record,
assert(i);
assert(cbdata);
- cbdata->interface = i;
+ cbdata->iface = i;
catta_cache_walk(i->cache, cbdata->key, scan_cache_callback, cbdata);
if (cbdata->cname_key)
catta_cache_walk(i->cache, cbdata->cname_key, scan_cache_callback, cbdata);
- cbdata->interface = NULL;
+ cbdata->iface = NULL;
}
unsigned catta_multicast_lookup_engine_scan_cache(
CattaMulticastLookupEngine *e,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaKey *key,
CattaMulticastLookupCallback callback,
assert(key);
assert(callback);
- assert(CATTA_IF_VALID(interface));
+ assert(CATTA_IF_VALID(iface));
assert(CATTA_PROTO_VALID(protocol));
cbdata.engine = e;
cbdata.cname_key = catta_key_new_cname(key);
cbdata.callback = callback;
cbdata.userdata = userdata;
- cbdata.interface = NULL;
+ cbdata.iface = NULL;
cbdata.n_found = 0;
- catta_interface_monitor_walk(e->server->monitor, interface, protocol, scan_interface_callback, &cbdata);
+ catta_interface_monitor_walk(e->server->monitor, iface, protocol, scan_interface_callback, &cbdata);
if (cbdata.cname_key)
catta_key_unref(cbdata.cname_key);
if (l->dead || !l->callback)
continue;
- if (l->queriers_added && catta_interface_match(i, l->interface, l->protocol))
+ if (l->queriers_added && catta_interface_match(i, l->iface, l->protocol))
catta_querier_add(i, l->key, NULL);
}
}
if (l->dead || !l->callback)
continue;
- if (catta_interface_match(i, l->interface, l->protocol))
+ if (catta_interface_match(i, l->iface, l->protocol))
l->callback(e, i->hardware->index, i->protocol, event, CATTA_LOOKUP_RESULT_MULTICAST, record, l->userdata);
}
};
struct CattaProbeScheduler {
- CattaInterface *interface;
+ CattaInterface *iface;
CattaTimeEventQueue *time_event_queue;
CATTA_LLIST_HEAD(CattaProbeJob, jobs);
return NULL;
}
- s->interface = i;
+ s->iface = i;
s->time_event_queue = i->monitor->server->time_event_queue;
CATTA_LLIST_HEAD_INIT(CattaProbeJob, s->jobs);
return;
}
- if (!(p = catta_dns_packet_new_query(s->interface->hardware->mtu)))
+ if (!(p = catta_dns_packet_new_query(s->iface->hardware->mtu)))
return; /* OOM */
n = 1;
if (b) {
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_NSCOUNT, 1);
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_QDCOUNT, 1);
- catta_interface_send_packet(s->interface, p);
+ catta_interface_send_packet(s->iface, p);
} else
catta_log_warn("Probe record too large, cannot send");
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_NSCOUNT, n);
/* Send it now */
- catta_interface_send_packet(s->interface, p);
+ catta_interface_send_packet(s->iface, p);
catta_dns_packet_free(p);
}
#include <catta/log.h>
struct CattaQuerier {
- CattaInterface *interface;
+ CattaInterface *iface;
CattaKey *key;
int n_used;
void catta_querier_free(CattaQuerier *q) {
assert(q);
- CATTA_LLIST_REMOVE(CattaQuerier, queriers, q->interface->queriers, q);
- catta_hashmap_remove(q->interface->queriers_by_key, q->key);
+ CATTA_LLIST_REMOVE(CattaQuerier, queriers, q->iface->queriers, q);
+ catta_hashmap_remove(q->iface->queriers_by_key, q->key);
catta_key_unref(q->key);
catta_time_event_free(q->time_event);
return;
}
- if (catta_interface_post_query(q->interface, q->key, 0, &q->post_id)) {
+ if (catta_interface_post_query(q->iface, q->key, 0, &q->post_id)) {
/* The queue accepted our query. We store the query id here,
* that allows us to drop the query at a later point if the
return; /* OOM */
q->key = catta_key_ref(key);
- q->interface = i;
+ q->iface = i;
q->n_used = 1;
q->sec_delay = 1;
q->post_id_valid = 0;
};
struct CattaQueryScheduler {
- CattaInterface *interface;
+ CattaInterface *iface;
CattaTimeEventQueue *time_event_queue;
unsigned next_id;
return NULL; /* OOM */
}
- s->interface = i;
+ s->iface = i;
s->time_event_queue = i->monitor->server->time_event_queue;
s->next_id = 0;
return 0;
/* Add all matching known answers to the list */
- catta_cache_walk(s->interface->cache, qj->key, known_answer_walk_callback, s);
+ catta_cache_walk(s->iface->cache, qj->key, known_answer_walk_callback, s);
job_mark_done(s, qj);
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_FLAGS, catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS) | CATTA_DNS_FLAG_TC);
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ANCOUNT, n);
- catta_interface_send_packet(s->interface, p);
+ catta_interface_send_packet(s->iface, p);
catta_dns_packet_free(p);
- p = catta_dns_packet_new_query(s->interface->hardware->mtu);
+ p = catta_dns_packet_new_query(s->iface->hardware->mtu);
n = 0;
}
}
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ANCOUNT, n);
- catta_interface_send_packet(s->interface, p);
+ catta_interface_send_packet(s->iface, p);
catta_dns_packet_free(p);
}
assert(!s->known_answers);
- if (!(p = catta_dns_packet_new_query(s->interface->hardware->mtu)))
+ if (!(p = catta_dns_packet_new_query(s->iface->hardware->mtu)))
return; /* OOM */
b = packet_add_query_job(s, p, qj);
void* userdata;
CattaRecord *ptr_record;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
CattaLookupResultFlags flags;
switch (event) {
case CATTA_RESOLVER_FAILURE:
- r->callback(r, r->interface, r->protocol, event, &r->address, NULL, r->flags, r->userdata);
+ r->callback(r, r->iface, r->protocol, event, &r->address, NULL, r->flags, r->userdata);
break;
case CATTA_RESOLVER_FOUND:
assert(r->ptr_record);
- r->callback(r, r->interface, r->protocol, event, &r->address, r->ptr_record->data.ptr.name, r->flags, r->userdata);
+ r->callback(r, r->iface, r->protocol, event, &r->address, r->ptr_record->data.ptr.name, r->flags, r->userdata);
break;
}
}
static void record_browser_callback(
CattaSRecordBrowser*rr,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
assert(record);
assert(record->key->type == CATTA_DNS_TYPE_PTR);
- if (r->interface > 0 && interface != r->interface)
+ if (r->iface > 0 && iface != r->iface)
return;
if (r->protocol != CATTA_PROTO_UNSPEC && protocol != r->protocol)
return;
- if (r->interface <= 0)
- r->interface = interface;
+ if (r->iface <= 0)
+ r->iface = iface;
if (r->protocol == CATTA_PROTO_UNSPEC)
r->protocol = protocol;
r->retry_with_multicast = 0;
catta_s_record_browser_free(r->record_browser);
- r->record_browser = catta_s_record_browser_new(r->server, r->interface, r->protocol, r->key, CATTA_LOOKUP_USE_MULTICAST, record_browser_callback, r);
+ r->record_browser = catta_s_record_browser_new(r->server, r->iface, r->protocol, r->key, CATTA_LOOKUP_USE_MULTICAST, record_browser_callback, r);
if (r->record_browser) {
start_timeout(r);
CattaSAddressResolver *catta_s_address_resolver_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const CattaAddress *address,
CattaLookupFlags flags,
assert(address);
assert(callback);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, address->proto == CATTA_PROTO_INET || address->proto == CATTA_PROTO_INET6, CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
r->callback = callback;
r->userdata = userdata;
r->ptr_record = NULL;
- r->interface = interface;
+ r->iface = iface;
r->protocol = protocol;
r->flags = 0;
r->retry_with_multicast = 0;
}
}
- r->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
+ r->record_browser = catta_s_record_browser_new(server, iface, protocol, k, flags, record_browser_callback, r);
if (!r->record_browser) {
catta_s_address_resolver_free(r);
void* userdata;
CattaRecord *address_record;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
CattaLookupResultFlags flags;
abort();
}
- r->callback(r, r->interface, r->protocol, CATTA_RESOLVER_FOUND, r->address_record->key->name, &a, r->flags, r->userdata);
+ r->callback(r, r->iface, r->protocol, CATTA_RESOLVER_FOUND, r->address_record->key->name, &a, r->flags, r->userdata);
break;
}
case CATTA_RESOLVER_FAILURE:
- r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, r->flags, r->userdata);
+ r->callback(r, r->iface, r->protocol, event, r->host_name, NULL, r->flags, r->userdata);
break;
}
}
static void record_browser_callback(
CattaSRecordBrowser*rr,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
assert(record);
assert(record->key->type == CATTA_DNS_TYPE_A || record->key->type == CATTA_DNS_TYPE_AAAA);
- if (r->interface > 0 && interface != r->interface)
+ if (r->iface > 0 && iface != r->iface)
return;
if (r->protocol != CATTA_PROTO_UNSPEC && protocol != r->protocol)
return;
- if (r->interface <= 0)
- r->interface = interface;
+ if (r->iface <= 0)
+ r->iface = iface;
if (r->protocol == CATTA_PROTO_UNSPEC)
r->protocol = protocol;
CattaSHostNameResolver *catta_s_host_name_resolver_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *host_name,
CattaProtocol aprotocol,
assert(host_name);
assert(callback);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, catta_is_valid_fqdn(host_name), CATTA_ERR_INVALID_HOST_NAME);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(aprotocol), CATTA_ERR_INVALID_PROTOCOL);
r->callback = callback;
r->userdata = userdata;
r->address_record = NULL;
- r->interface = interface;
+ r->iface = iface;
r->protocol = protocol;
r->flags = 0;
if (aprotocol == CATTA_PROTO_INET || aprotocol == CATTA_PROTO_UNSPEC) {
k = catta_key_new(host_name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_A);
- r->record_browser_a = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
+ r->record_browser_a = catta_s_record_browser_new(server, iface, protocol, k, flags, record_browser_callback, r);
catta_key_unref(k);
if (!r->record_browser_a)
if (aprotocol == CATTA_PROTO_INET6 || aprotocol == CATTA_PROTO_UNSPEC) {
k = catta_key_new(host_name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_AAAA);
- r->record_browser_aaaa = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
+ r->record_browser_aaaa = catta_s_record_browser_new(server, iface, protocol, k, flags, record_browser_callback, r);
catta_key_unref(k);
if (!r->record_browser_aaaa)
char *domain_name;
CattaProtocol address_protocol;
- CattaIfIndex interface;
+ CattaIfIndex iface;
CattaProtocol protocol;
CattaSRecordBrowser *record_browser_srv;
r->callback(
r,
- r->interface,
+ r->iface,
r->protocol,
event,
r->service_name,
r->callback(
r,
- r->interface,
+ r->iface,
r->protocol,
event,
r->service_name,
static void record_browser_callback(
CattaSRecordBrowser*rr,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
int changed = 0;
assert(record);
- if (r->interface > 0 && interface > 0 && interface != r->interface)
+ if (r->iface > 0 && iface > 0 && iface != r->iface)
return;
if (r->protocol != CATTA_PROTO_UNSPEC && protocol != CATTA_PROTO_UNSPEC && protocol != r->protocol)
return;
- if (r->interface <= 0)
- r->interface = interface;
+ if (r->iface <= 0)
+ r->iface = iface;
if (r->protocol == CATTA_PROTO_UNSPEC)
r->protocol = protocol;
if (r->address_protocol == CATTA_PROTO_INET || r->address_protocol == CATTA_PROTO_UNSPEC) {
CattaKey *k = catta_key_new(r->srv_record->data.srv.name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_A);
- r->record_browser_a = catta_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
+ r->record_browser_a = catta_s_record_browser_new(r->server, r->iface, r->protocol, k, r->user_flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
catta_key_unref(k);
}
if (r->address_protocol == CATTA_PROTO_INET6 || r->address_protocol == CATTA_PROTO_UNSPEC) {
CattaKey *k = catta_key_new(r->srv_record->data.srv.name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_AAAA);
- r->record_browser_aaaa = catta_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
+ r->record_browser_aaaa = catta_s_record_browser_new(r->server, r->iface, r->protocol, k, r->user_flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
catta_key_unref(k);
}
}
CattaSServiceResolver *catta_s_service_resolver_new(
CattaServer *server,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
const char *name,
const char *type,
assert(type);
assert(callback);
- CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(aprotocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
r->address_protocol = aprotocol;
r->srv_record = r->txt_record = r->address_record = NULL;
r->srv_flags = r->txt_flags = r->address_flags = 0;
- r->interface = interface;
+ r->iface = iface;
r->protocol = protocol;
r->user_flags = flags;
r->record_browser_a = r->record_browser_aaaa = r->record_browser_srv = r->record_browser_txt = NULL;
CATTA_LLIST_PREPEND(CattaSServiceResolver, resolver, server->service_resolvers, r);
k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV);
- r->record_browser_srv = catta_s_record_browser_new(server, interface, protocol, k, flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
+ r->record_browser_srv = catta_s_record_browser_new(server, iface, protocol, k, flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
catta_key_unref(k);
if (!r->record_browser_srv) {
if (!(flags & CATTA_LOOKUP_NO_TXT)) {
k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_TXT);
- r->record_browser_txt = catta_s_record_browser_new(server, interface, protocol, k, flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
+ r->record_browser_txt = catta_s_record_browser_new(server, iface, protocol, k, flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
catta_key_unref(k);
if (!r->record_browser_txt) {
};
struct CattaResponseScheduler {
- CattaInterface *interface;
+ CattaInterface *iface;
CattaTimeEventQueue *time_event_queue;
CATTA_LLIST_HEAD(CattaResponseJob, jobs);
return NULL;
}
- s->interface = i;
+ s->iface = i;
s->time_event_queue = i->monitor->server->time_event_queue;
CATTA_LLIST_HEAD_INIT(CattaResponseJob, s->jobs);
/* Ok, this record will definitely be sent, so schedule the
* auxilliary packets, too */
- catta_server_enumerate_aux_records(s->interface->monitor->server, s->interface, rj->record, enumerate_aux_records_callback, rj);
+ catta_server_enumerate_aux_records(s->iface->monitor->server, s->iface, rj->record, enumerate_aux_records_callback, rj);
job_mark_done(s, rj);
return 1;
assert(s);
assert(rj);
- if (!(p = catta_dns_packet_new_response(s->interface->hardware->mtu, 1)))
+ if (!(p = catta_dns_packet_new_response(s->iface->hardware->mtu, 1)))
return; /* OOM */
n = 1;
}
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ANCOUNT, n);
- catta_interface_send_packet(s->interface, p);
+ catta_interface_send_packet(s->iface, p);
catta_dns_packet_free(p);
}
if (!s->config.enable_reflector)
return;
- for (j = s->monitor->interfaces; j; j = j->interface_next)
+ for (j = s->monitor->interfaces; j; j = j->iface_next)
if (j != i && (s->config.reflect_ipv || j->protocol == i->protocol))
catta_interface_post_response(j, r, flush_cache, NULL, 1);
}
if (!s->config.enable_reflector)
return;
- for (j = s->monitor->interfaces; j; j = j->interface_next)
+ for (j = s->monitor->interfaces; j; j = j->iface_next)
if (j != i && (s->config.reflect_ipv || j->protocol == i->protocol)) {
/* Post the query to other networks */
catta_interface_post_query(j, k, 1, NULL);
if (!s->config.enable_reflector)
return;
- for (j = s->monitor->interfaces; j; j = j->interface_next)
+ for (j = s->monitor->interfaces; j; j = j->iface_next)
if (j != i && (s->config.reflect_ipv || j->protocol == i->protocol))
catta_interface_post_probe(j, r, 1);
}
slot->original_id = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ID);
slot->address = *a;
slot->port = port;
- slot->interface = i->hardware->index;
+ slot->iface = i->hardware->index;
catta_elapse_time(&slot->elapse_time, 2000, 0);
slot->time_event = catta_time_event_new(s->time_event_queue, &slot->elapse_time, legacy_unicast_reflect_slot_timeout, slot);
/* Patch the packet with our new locally generatet id */
catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ID, slot->id);
- for (j = s->monitor->interfaces; j; j = j->interface_next)
+ for (j = s->monitor->interfaces; j; j = j->iface_next)
if (j->announcing &&
j != i &&
(s->config.reflect_ipv || j->protocol == i->protocol)) {
return;
}
- if (!(j = catta_interface_monitor_get_interface(s->monitor, slot->interface, slot->address.proto)) ||
+ if (!(j = catta_interface_monitor_get_interface(s->monitor, slot->iface, slot->address.proto)) ||
!j->announcing)
return;
return s->local_service_cookie;
}
-static CattaEntry *find_entry(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaKey *key) {
+static CattaEntry *find_entry(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, CattaKey *key) {
CattaEntry *e;
assert(s);
for (e = catta_hashmap_lookup(s->entries_by_key, key); e; e = e->by_key_next)
- if ((e->interface == interface || e->interface <= 0 || interface <= 0) &&
+ if ((e->iface == iface || e->iface <= 0 || iface <= 0) &&
(e->protocol == protocol || e->protocol == CATTA_PROTO_UNSPEC || protocol == CATTA_PROTO_UNSPEC) &&
(!e->group || e->group->state == CATTA_ENTRY_GROUP_ESTABLISHED || e->group->state == CATTA_ENTRY_GROUP_REGISTERING))
return NULL;
}
-int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name, const char *type, const char *domain, CattaSEntryGroup** ret_group) {
+int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, const char *name, const char *type, const char *domain, CattaSEntryGroup** ret_group) {
CattaKey *key = NULL;
CattaEntry *e;
int ret;
assert(type);
assert(ret_group);
- CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+ CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(iface), CATTA_ERR_INVALID_INTERFACE);
CATTA_CHECK_VALIDITY(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
CATTA_CHECK_VALIDITY(s, catta_is_valid_service_name(name), CATTA_ERR_INVALID_SERVICE_NAME);
CATTA_CHECK_VALIDITY(s, catta_is_valid_service_type_strict(type), CATTA_ERR_INVALID_SERVICE_TYPE);
if (!(key = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV)))
return catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
- e = find_entry(s, interface, protocol, key);
+ e = find_entry(s, iface, protocol, key);
catta_key_unref(key);
if (e) {
return catta_server_set_errno(s, CATTA_ERR_NOT_FOUND);
}
-int catta_server_is_service_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name) {
+int catta_server_is_service_local(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, const char *name) {
CattaKey *key = NULL;
CattaEntry *e;
if (!(key = catta_key_new(name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV)))
return 0;
- e = find_entry(s, interface, protocol, key);
+ e = find_entry(s, iface, protocol, key);
catta_key_unref(key);
if (!e)
return catta_domain_equal(s->host_name_fqdn, e->record->data.srv.name);
}
-int catta_server_is_record_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *record) {
+int catta_server_is_record_local(CattaServer *s, CattaIfIndex iface, CattaProtocol protocol, CattaRecord *record) {
CattaEntry *e;
assert(s);
for (e = catta_hashmap_lookup(s->entries_by_key, record->key); e; e = e->by_key_next)
- if ((e->interface == interface || e->interface <= 0 || interface <= 0) &&
+ if ((e->iface == iface || e->iface <= 0 || iface <= 0) &&
(e->protocol == protocol || e->protocol == CATTA_PROTO_UNSPEC || protocol == CATTA_PROTO_UNSPEC) &&
(!e->group || e->group->state == CATTA_ENTRY_GROUP_ESTABLISHED || e->group->state == CATTA_ENTRY_GROUP_REGISTERING) &&
catta_record_equal_no_ttl(record, e->record))
int catta_send_dns_packet_ipv4(
int fd,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaDnsPacket *p,
const CattaIPv4Address *src_address,
const CattaIPv4Address *dst_address,
msg.msg_controllen = 0;
#ifdef IP_PKTINFO
- if (interface > 0 || src_address) {
+ if (iface > 0 || src_address) {
struct in_pktinfo *pkti;
memset(cmsg_data, 0, sizeof(cmsg_data));
pkti = (struct in_pktinfo*) CMSG_DATA(cmsg);
- if (interface > 0)
- pkti->ipi_ifindex = interface;
+ if (iface > 0)
+ pkti->ipi_ifindex = iface;
if (src_address)
pkti->ipi_spec_dst.s_addr = src_address->address;
int catta_send_dns_packet_ipv6(
int fd,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaDnsPacket *p,
const CattaIPv6Address *src_address,
const CattaIPv6Address *dst_address,
msg.msg_iovlen = 1;
msg.msg_flags = 0;
- if (interface > 0 || src_address) {
+ if (iface > 0 || src_address) {
struct in6_pktinfo *pkti;
memset(cmsg_data, 0, sizeof(cmsg_data));
pkti = (struct in6_pktinfo*) CMSG_DATA(cmsg);
- if (interface > 0)
- pkti->ipi6_ifindex = interface;
+ if (iface > 0)
+ pkti->ipi6_ifindex = iface;
if (src_address)
memcpy(&pkti->ipi6_addr, src_address->address, sizeof(src_address->address));
static void record_browser_callback(
CattaSRecordBrowser *r,
- CattaIfIndex interface,
+ CattaIfIndex iface,
CattaProtocol protocol,
CattaBrowserEvent event,
CattaRecord *record,
assert(r);
if (record) {
- catta_log_debug("RB: record [%s] on %i.%i is %s", t = catta_record_to_string(record), interface, protocol, browser_event_to_string(event));
+ catta_log_debug("RB: record [%s] on %i.%i is %s", t = catta_record_to_string(record), iface, protocol, browser_event_to_string(event));
catta_free(t);
} else
catta_log_debug("RB: [%s]", browser_event_to_string(event));