From d80c70d36363762e0cf1534e654e122d741fbc5d Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" Date: Tue, 26 Aug 2014 19:11:39 +0200 Subject: [PATCH] rename interface -> iface everywhere --- examples/core-browse-services.c | 6 +-- include/catta/address.h | 2 +- include/catta/lookup.h | 28 +++++----- include/catta/publish.h | 16 +++--- src/announce.c | 22 ++++---- src/announce.h | 2 +- src/browse-dns-server.c | 30 +++++------ src/browse-domain.c | 10 ++-- src/browse-service-type.c | 12 ++--- src/browse-service.c | 14 ++--- src/browse.c | 64 +++++++++++----------- src/browse.h | 2 +- src/cache.c | 10 ++-- src/cache.h | 4 +- src/dns-srv-rr.h | 6 +-- src/entry.c | 96 ++++++++++++++++----------------- src/error.c | 2 +- src/iface.c | 48 ++++++++--------- src/iface.h | 4 +- src/internal.h | 10 ++-- src/multicast-lookup.c | 36 ++++++------- src/probe-sched.c | 10 ++-- src/querier.c | 10 ++-- src/query-sched.c | 14 ++--- src/resolve-address.c | 24 ++++----- src/resolve-host-name.c | 24 ++++----- src/resolve-service.c | 28 +++++----- src/response-sched.c | 10 ++-- src/server.c | 30 +++++------ src/socket.c | 16 +++--- tests/catta-test.c | 4 +- 31 files changed, 297 insertions(+), 297 deletions(-) diff --git a/examples/core-browse-services.c b/examples/core-browse-services.c index 44f8ece..e8f4aad 100644 --- a/examples/core-browse-services.c +++ b/examples/core-browse-services.c @@ -48,7 +48,7 @@ static CattaServer *server = NULL; 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, @@ -101,7 +101,7 @@ static void resolve_callback( static void browse_callback( CattaSServiceBrowser *b, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, const char *name, @@ -131,7 +131,7 @@ static void browse_callback( 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; diff --git a/include/catta/address.h b/include/catta/address.h index f10f33b..ad8e93b 100644 --- a/include/catta/address.h +++ b/include/catta/address.h @@ -51,7 +51,7 @@ enum { #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)) diff --git a/include/catta/lookup.h b/include/catta/lookup.h index ebdc92a..c6d69db 100644 --- a/include/catta/lookup.h +++ b/include/catta/lookup.h @@ -55,7 +55,7 @@ CATTA_C_DECL_BEGIN /** 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 */ @@ -65,7 +65,7 @@ typedef void (*CattaSRecordBrowserCallback)( /** 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. */ @@ -78,7 +78,7 @@ void catta_s_record_browser_free(CattaSRecordBrowser *b); /** 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 */ @@ -89,7 +89,7 @@ typedef void (*CattaSHostNameResolverCallback)( /** 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. */ @@ -103,7 +103,7 @@ void catta_s_host_name_resolver_free(CattaSHostNameResolver *r); /** Callback prototype for CattaSAddressResolver events */ typedef void (*CattaSAddressResolverCallback)( CattaSAddressResolver *r, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaResolverEvent event, const CattaAddress *a, @@ -114,7 +114,7 @@ typedef void (*CattaSAddressResolverCallback)( /** 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. */ @@ -127,7 +127,7 @@ void catta_s_address_resolver_free(CattaSAddressResolver *r); /** Callback prototype for CattaSDomainBrowser events */ typedef void (*CattaSDomainBrowserCallback)( CattaSDomainBrowser *b, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, const char *domain, @@ -137,7 +137,7 @@ typedef void (*CattaSDomainBrowserCallback)( /** Create a new CattaSDomainBrowser object */ CattaSDomainBrowser *catta_s_domain_browser_new( CattaServer *server, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, const char *domain, CattaDomainBrowserType type, @@ -151,7 +151,7 @@ void catta_s_domain_browser_free(CattaSDomainBrowser *b); /** Callback prototype for CattaSServiceTypeBrowser events */ typedef void (*CattaSServiceTypeBrowserCallback)( CattaSServiceTypeBrowser *b, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, const char *type, @@ -162,7 +162,7 @@ typedef void (*CattaSServiceTypeBrowserCallback)( /** 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. */ @@ -175,7 +175,7 @@ void catta_s_service_type_browser_free(CattaSServiceTypeBrowser *b); /** 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" */, @@ -187,7 +187,7 @@ typedef void (*CattaSServiceBrowserCallback)( /** 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, @@ -201,7 +201,7 @@ void catta_s_service_browser_free(CattaSServiceBrowser *b); /** 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 */ @@ -217,7 +217,7 @@ typedef void (*CattaSServiceResolverCallback)( /** 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, diff --git a/include/catta/publish.h b/include/catta/publish.h index 1176b1f..ac39c96 100644 --- a/include/catta/publish.h +++ b/include/catta/publish.h @@ -77,7 +77,7 @@ void* catta_s_entry_group_get_data(CattaSEntryGroup *g); 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. */); @@ -92,7 +92,7 @@ int catta_server_add( int catta_server_add_address( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -107,7 +107,7 @@ int catta_server_add_address( 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" */ @@ -121,7 +121,7 @@ int catta_server_add_service( int catta_server_add_service_strlst( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -135,7 +135,7 @@ int catta_server_add_service_strlst( 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 */ @@ -147,7 +147,7 @@ int catta_server_add_service_subtype( int catta_server_update_service_txt_strlst( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -159,7 +159,7 @@ int catta_server_update_service_txt_strlst( int catta_server_update_service_txt( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -168,7 +168,7 @@ int catta_server_update_service_txt( ...) 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 diff --git a/src/announce.c b/src/announce.c index 06e96e7..e2b0757 100644 --- a/src/announce.c +++ b/src/announce.c @@ -41,7 +41,7 @@ static void remove_announcer(CattaServer *s, CattaAnnouncer *a) { 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); @@ -139,7 +139,7 @@ static void next_state(CattaAnnouncer *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); @@ -151,11 +151,11 @@ static void next_state(CattaAnnouncer *a) { 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 */ @@ -189,7 +189,7 @@ static CattaAnnouncer *get_announcer(CattaServer *s, CattaEntry *e, CattaInterfa assert(i); for (a = e->announcers; a; a = a->by_entry_next) - if (a->interface == i) + if (a->iface == i) return a; return NULL; @@ -236,7 +236,7 @@ static void new_announcer(CattaServer *s, CattaInterface *i, CattaEntry *e) { 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 */ @@ -249,7 +249,7 @@ static void new_announcer(CattaServer *s, CattaInterface *i, CattaEntry *e) { } a->server = s; - a->interface = i; + a->iface = i; a->entry = e; a->time_event = NULL; @@ -289,7 +289,7 @@ void catta_announce_entry(CattaServer *s, CattaEntry *e) { 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) { @@ -395,7 +395,7 @@ static void send_goodbye_callback(CattaInterfaceMonitor *m, CattaInterface *i, v 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) @@ -488,7 +488,7 @@ void catta_reannounce_entry(CattaServer *s, CattaEntry *e) { 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) { diff --git a/src/announce.h b/src/announce.h index e8e62dc..3a2a400 100644 --- a/src/announce.h +++ b/src/announce.h @@ -37,7 +37,7 @@ typedef enum { struct CattaAnnouncer { CattaServer *server; - CattaInterface *interface; + CattaInterface *iface; CattaEntry *entry; CattaTimeEvent *time_event; diff --git a/src/browse-dns-server.c b/src/browse-dns-server.c index 640ec51..12b529f 100644 --- a/src/browse-dns-server.c +++ b/src/browse-dns-server.c @@ -36,7 +36,7 @@ typedef struct CattaDNSServerInfo CattaDNSServerInfo; struct CattaDNSServerInfo { CattaSDNSServerBrowser *browser; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; CattaRecord *srv_record; CattaSHostNameResolver *host_name_resolver; @@ -61,14 +61,14 @@ struct CattaSDNSServerBrowser { 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; @@ -94,7 +94,7 @@ static void server_info_free(CattaSDNSServerBrowser *b, CattaDNSServerInfo *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, @@ -114,7 +114,7 @@ static void host_name_resolver_callback( i->browser->callback( i->browser, - i->interface, + i->iface, i->protocol, CATTA_BROWSER_NEW, i->srv_record->data.srv.name, @@ -137,7 +137,7 @@ static void host_name_resolver_callback( static void record_browser_callback( CattaSRecordBrowser*rr, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -159,7 +159,7 @@ static void record_browser_callback( 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) @@ -169,12 +169,12 @@ static void record_browser_callback( 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, @@ -193,13 +193,13 @@ static void record_browser_callback( 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, @@ -218,7 +218,7 @@ static void record_browser_callback( b->callback( b, - interface, + iface, protocol, event, NULL, @@ -233,7 +233,7 @@ static void record_browser_callback( CattaSDNSServerBrowser *catta_s_dns_server_browser_new( CattaServer *server, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, const char *domain, CattaDNSServerType type, @@ -255,7 +255,7 @@ CattaSDNSServerBrowser *catta_s_dns_server_browser_new( 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); @@ -290,7 +290,7 @@ CattaSDNSServerBrowser *catta_s_dns_server_browser_new( 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); diff --git a/src/browse-domain.c b/src/browse-domain.c index 8ae99e4..691cfba 100644 --- a/src/browse-domain.c +++ b/src/browse-domain.c @@ -57,7 +57,7 @@ static void inc_ref(CattaSDomainBrowser *b) { static void record_browser_callback( CattaSRecordBrowser*rr, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -96,7 +96,7 @@ static void record_browser_callback( } - 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) { @@ -137,7 +137,7 @@ 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, @@ -161,7 +161,7 @@ CattaSDomainBrowser *catta_s_domain_browser_new( 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); @@ -196,7 +196,7 @@ CattaSDomainBrowser *catta_s_domain_browser_new( 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); diff --git a/src/browse-service-type.c b/src/browse-service-type.c index 4d40a82..41c171e 100644 --- a/src/browse-service-type.c +++ b/src/browse-service-type.c @@ -44,7 +44,7 @@ struct CattaSServiceTypeBrowser { static void record_browser_callback( CattaSRecordBrowser*rr, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -69,14 +69,14 @@ static void record_browser_callback( 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, @@ -91,7 +91,7 @@ CattaSServiceTypeBrowser *catta_s_service_type_browser_new( 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); @@ -126,7 +126,7 @@ CattaSServiceTypeBrowser *catta_s_service_type_browser_new( 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); diff --git a/src/browse-service.c b/src/browse-service.c index 4a4c8df..3b09695 100644 --- a/src/browse-service.c +++ b/src/browse-service.c @@ -45,7 +45,7 @@ struct CattaSServiceBrowser { static void record_browser_callback( CattaSRecordBrowser*rr, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -65,7 +65,7 @@ static void record_browser_callback( 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) { @@ -73,16 +73,16 @@ static void record_browser_callback( 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, @@ -99,7 +99,7 @@ CattaSServiceBrowser *catta_s_service_browser_new( 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); @@ -137,7 +137,7 @@ CattaSServiceBrowser *catta_s_service_browser_new( 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); diff --git a/src/browse.c b/src/browse.c index 0324499..d8f70e6 100644 --- a/src/browse.c +++ b/src/browse.c @@ -43,7 +43,7 @@ struct CattaSRBLookup { unsigned ref; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; CattaLookupFlags flags; @@ -57,8 +57,8 @@ struct CattaSRBLookup { 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); @@ -81,7 +81,7 @@ static void transport_flags_from_domain(CattaServer *s, CattaLookupFlags *flags, static CattaSRBLookup* lookup_new( CattaSRecordBrowser *b, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaLookupFlags flags, CattaKey *key) { @@ -89,7 +89,7 @@ static CattaSRBLookup* lookup_new( 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) @@ -101,7 +101,7 @@ static CattaSRBLookup* lookup_new( 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; @@ -157,7 +157,7 @@ static CattaSRBLookup* lookup_ref(CattaSRBLookup *l) { static CattaSRBLookup *lookup_find( CattaSRecordBrowser *b, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaLookupFlags flags, CattaKey *key) { @@ -168,8 +168,8 @@ static CattaSRBLookup *lookup_find( 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)) @@ -248,7 +248,7 @@ static void lookup_wide_area_callback( static void lookup_multicast_callback( CattaMulticastLookupEngine *e, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaLookupResultFlags flags, @@ -275,14 +275,14 @@ static void lookup_multicast_callback( 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; @@ -292,12 +292,12 @@ static void lookup_multicast_callback( 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; @@ -330,7 +330,7 @@ static int lookup_start(CattaSRBLookup *l) { } 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; } @@ -350,22 +350,22 @@ static int lookup_scan_cache(CattaSRBLookup *l) { } 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; @@ -398,7 +398,7 @@ static int lookup_go(CattaSRBLookup *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; @@ -409,7 +409,7 @@ static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex interface, Catta 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) { @@ -423,7 +423,7 @@ static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex interface, Catta 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; @@ -438,8 +438,8 @@ static void lookup_drop_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaPr 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; @@ -468,7 +468,7 @@ static void defer_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void *userdata) { /* 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); @@ -482,7 +482,7 @@ static void defer_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void *userdata) { 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); @@ -492,7 +492,7 @@ static void defer_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void *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); @@ -502,7 +502,7 @@ static void defer_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void *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); } } @@ -521,7 +521,7 @@ void catta_s_record_browser_restart(CattaSRecordBrowser *b) { CattaSRecordBrowser *catta_s_record_browser_new( CattaServer *server, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaKey *key, CattaLookupFlags flags, @@ -534,7 +534,7 @@ CattaSRecordBrowser *catta_s_record_browser_new( 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); @@ -548,7 +548,7 @@ CattaSRecordBrowser *catta_s_record_browser_new( b->dead = 0; b->server = server; - b->interface = interface; + b->iface = iface; b->protocol = protocol; b->key = catta_key_ref(key); b->flags = flags; diff --git a/src/browse.h b/src/browse.h index 76b7a6d..1fccf23 100644 --- a/src/browse.h +++ b/src/browse.h @@ -36,7 +36,7 @@ struct CattaSRecordBrowser { CattaServer *server; CattaKey *key; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; CattaLookupFlags flags; diff --git a/src/cache.c b/src/cache.c index f4203eb..de7b369 100644 --- a/src/cache.c +++ b/src/cache.c @@ -54,7 +54,7 @@ static void remove_entry(CattaCache *c, CattaCacheEntry *e) { 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); @@ -74,7 +74,7 @@ CattaCache *catta_cache_new(CattaServer *server, CattaInterface *iface) { } 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."); @@ -212,8 +212,8 @@ static void elapse_func(CattaTimeEvent *t, void *userdata) { 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); @@ -360,7 +360,7 @@ void catta_cache_update(CattaCache *c, CattaRecord *r, int cache_flush, const Ca 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; diff --git a/src/cache.h b/src/cache.h index a205b70..c3741e1 100644 --- a/src/cache.h +++ b/src/cache.h @@ -65,7 +65,7 @@ struct CattaCacheEntry { struct CattaCache { CattaServer *server; - CattaInterface *interface; + CattaInterface *iface; CattaHashmap *hashmap; @@ -77,7 +77,7 @@ struct CattaCache { 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); diff --git a/src/dns-srv-rr.h b/src/dns-srv-rr.h index e028f2b..d2c0dbf 100644 --- a/src/dns-srv-rr.h +++ b/src/dns-srv-rr.h @@ -47,7 +47,7 @@ typedef enum { int catta_server_add_dns_server_address( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *domain, @@ -58,7 +58,7 @@ int catta_server_add_dns_server_address( /** 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 */ @@ -70,7 +70,7 @@ typedef void (*CattaSDNSServerBrowserCallback)( /** 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, diff --git a/src/entry.c b/src/entry.c index a56e0bd..cd3c6e2 100644 --- a/src/entry.c +++ b/src/entry.c @@ -148,7 +148,7 @@ void catta_cleanup_dead_entries(CattaServer *s) { } } -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); @@ -169,9 +169,9 @@ static int check_record_conflict(CattaServer *s, CattaIfIndex interface, CattaPr 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)) @@ -185,7 +185,7 @@ static int check_record_conflict(CattaServer *s, CattaIfIndex interface, CattaPr static CattaEntry * server_add_internal( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, CattaRecord *r) { @@ -196,7 +196,7 @@ static CattaEntry * server_add_internal( 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, @@ -237,7 +237,7 @@ static CattaEntry * server_add_internal( /* 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; @@ -276,7 +276,7 @@ static CattaEntry * server_add_internal( /* 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; } @@ -289,7 +289,7 @@ static CattaEntry * server_add_internal( 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; @@ -316,12 +316,12 @@ static CattaEntry * server_add_internal( 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; @@ -362,7 +362,7 @@ int catta_server_dump(CattaServer *s, CattaDumpCallback callback, void* userdata 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); @@ -378,7 +378,7 @@ int catta_server_dump(CattaServer *s, CattaDumpCallback callback, void* userdata static CattaEntry *server_add_ptr_internal( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, uint32_t ttl, @@ -403,7 +403,7 @@ static CattaEntry *server_add_ptr_internal( } 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; } @@ -411,7 +411,7 @@ static CattaEntry *server_add_ptr_internal( int catta_server_add_ptr( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, uint32_t ttl, @@ -422,7 +422,7 @@ int catta_server_add_ptr( 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; @@ -431,7 +431,7 @@ int catta_server_add_ptr( int catta_server_add_address( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -445,7 +445,7 @@ int catta_server_add_address( 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| @@ -490,7 +490,7 @@ int catta_server_add_address( 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) { @@ -504,7 +504,7 @@ int catta_server_add_address( 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; } @@ -525,7 +525,7 @@ finish: static CattaEntry *server_add_txt_strlst_nocopy( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, uint32_t ttl, @@ -544,7 +544,7 @@ static CattaEntry *server_add_txt_strlst_nocopy( } 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; @@ -569,7 +569,7 @@ static CattaStringList *add_magic_cookie( static int server_add_service_strlst_nocopy( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -588,7 +588,7 @@ static int server_add_service_strlst_nocopy( 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| @@ -623,7 +623,7 @@ static int server_add_service_strlst_nocopy( /* 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; } @@ -640,7 +640,7 @@ static int server_add_service_strlst_nocopy( 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) { @@ -653,7 +653,7 @@ static int server_add_service_strlst_nocopy( 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) { @@ -663,7 +663,7 @@ static int server_add_service_strlst_nocopy( /* 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; } @@ -689,7 +689,7 @@ fail: int catta_server_add_service_strlst( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -703,13 +703,13 @@ int catta_server_add_service_strlst( 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, @@ -723,7 +723,7 @@ int catta_server_add_service( 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; @@ -732,7 +732,7 @@ int catta_server_add_service( static int server_update_service_txt_strlst_nocopy( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -748,7 +748,7 @@ static int server_update_service_txt_strlst_nocopy( 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| @@ -773,7 +773,7 @@ static int server_update_service_txt_strlst_nocopy( 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) @@ -789,7 +789,7 @@ fail: int catta_server_update_service_txt_strlst( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -797,14 +797,14 @@ int catta_server_update_service_txt_strlst( 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, @@ -816,7 +816,7 @@ int catta_server_update_service_txt( 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; @@ -825,7 +825,7 @@ int catta_server_update_service_txt( int catta_server_add_service_subtype( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *name, @@ -840,7 +840,7 @@ int catta_server_add_service_subtype( 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); @@ -860,7 +860,7 @@ int catta_server_add_service_subtype( 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: @@ -893,7 +893,7 @@ static void hexstring(char *s, size_t sl, const void *p, size_t pl) { static CattaEntry *server_add_dns_server_name( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *domain, @@ -940,7 +940,7 @@ static CattaEntry *server_add_dns_server_name( 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; @@ -949,7 +949,7 @@ static CattaEntry *server_add_dns_server_name( int catta_server_add_dns_server_address( CattaServer *s, CattaSEntryGroup *g, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaPublishFlags flags, const char *domain, @@ -964,7 +964,7 @@ int catta_server_add_dns_server_address( 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); @@ -992,13 +992,13 @@ int catta_server_add_dns_server_address( 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); diff --git a/src/error.c b/src/error.c index 543d1b1..c4199ed 100644 --- a/src/error.c +++ b/src/error.c @@ -55,7 +55,7 @@ const char *catta_strerror(int error) { "Memory exhausted", "The object passed in was not valid", "Daemon not running", - "Invalid interface index", + "Invalid iface index", "Invalid protocol specification", "Invalid flags", diff --git a/src/iface.c b/src/iface.c index 0940d63..8ab84a4 100644 --- a/src/iface.c +++ b/src/iface.c @@ -50,7 +50,7 @@ void catta_interface_address_update_rrs(CattaInterfaceAddress *a, int remove_rrs 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 || @@ -67,13 +67,13 @@ void catta_interface_address_update_rrs(CattaInterfaceAddress *a, int remove_rrs 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; @@ -90,7 +90,7 @@ void catta_interface_address_update_rrs(CattaInterfaceAddress *a, int remove_rrs 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) @@ -260,15 +260,15 @@ static int interface_mdns_mcast_rejoin(CattaInterface *i) { 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); } @@ -299,7 +299,7 @@ void catta_interface_free(CattaInterface *i, int send_goodbye) { 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); @@ -354,7 +354,7 @@ CattaInterface* catta_interface_new(CattaInterfaceMonitor *m, CattaHwInterface * 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; @@ -416,7 +416,7 @@ CattaInterfaceAddress *catta_interface_address_new(CattaInterfaceMonitor *m, Cat 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; @@ -482,7 +482,7 @@ void catta_interface_monitor_check_relevant(CattaInterfaceMonitor *m) { 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); } @@ -647,7 +647,7 @@ int catta_dump_caches(CattaInterfaceMonitor *m, CattaDumpCallback callback, void 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)); @@ -706,7 +706,7 @@ int catta_interface_address_is_relevant(CattaInterfaceAddress *a) { /* 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; @@ -729,32 +729,32 @@ int catta_interface_match(CattaInterface *i, CattaIfIndex idx, CattaProtocol pro 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); } } @@ -766,7 +766,7 @@ int catta_address_is_local(CattaInterfaceMonitor *m, const CattaAddress *a) { 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; @@ -850,7 +850,7 @@ CattaIfIndex catta_find_interface_for_address(CattaInterfaceMonitor *m, const Ca * 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) diff --git a/src/iface.h b/src/iface.h index 22d225e..6cadbdd 100644 --- a/src/iface.h +++ b/src/iface.h @@ -96,7 +96,7 @@ struct CattaInterface { CattaInterfaceMonitor *monitor; CattaHwInterface *hardware; - CATTA_LLIST_FIELDS(CattaInterface, interface); + CATTA_LLIST_FIELDS(CattaInterface, iface); CATTA_LLIST_FIELDS(CattaInterface, by_hardware); CattaProtocol protocol; @@ -119,7 +119,7 @@ struct CattaInterface { struct CattaInterfaceAddress { CattaInterfaceMonitor *monitor; - CattaInterface *interface; + CattaInterface *iface; CATTA_LLIST_FIELDS(CattaInterfaceAddress, address); diff --git a/src/internal.h b/src/internal.h index a7ee95e..6c602d7 100644 --- a/src/internal.h +++ b/src/internal.h @@ -56,7 +56,7 @@ struct CattaLegacyUnicastReflectSlot { uint16_t id, original_id; CattaAddress address; uint16_t port; - int interface; + int iface; struct timeval elapse_time; CattaTimeEvent *time_event; }; @@ -69,7 +69,7 @@ struct CattaEntry { CattaPublishFlags flags; CattaRecord *record; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; CATTA_LLIST_FIELDS(CattaEntry, entries); @@ -182,13 +182,13 @@ void catta_server_decrease_host_rr_pending(CattaServer *s); 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, diff --git a/src/multicast-lookup.c b/src/multicast-lookup.c index 85a1367..213b7b9 100644 --- a/src/multicast-lookup.c +++ b/src/multicast-lookup.c @@ -43,7 +43,7 @@ struct CattaMulticastLookup { CattaMulticastLookupCallback callback; void *userdata; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; int queriers_added; @@ -73,12 +73,12 @@ static void all_for_now_callback(CattaTimeEvent *e, void* userdata) { 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, @@ -88,7 +88,7 @@ CattaMulticastLookup *catta_multicast_lookup_new( struct timeval tv; assert(e); - assert(CATTA_IF_VALID(interface)); + assert(CATTA_IF_VALID(iface)); assert(CATTA_PROTO_VALID(protocol)); assert(key); assert(callback); @@ -100,7 +100,7 @@ CattaMulticastLookup *catta_multicast_lookup_new( 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; @@ -111,7 +111,7 @@ CattaMulticastLookup *catta_multicast_lookup_new( 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 */ @@ -129,7 +129,7 @@ static void lookup_stop(CattaMulticastLookup *l) { 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; } @@ -195,7 +195,7 @@ struct cbdata { CattaMulticastLookupCallback callback; void *userdata; CattaKey *key, *cname_key; - CattaInterface *interface; + CattaInterface *iface; unsigned n_found; }; @@ -209,8 +209,8 @@ static void* scan_cache_callback(CattaCache *c, CattaKey *pattern, CattaCacheEnt 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, @@ -228,19 +228,19 @@ static void scan_interface_callback(CattaInterfaceMonitor *m, CattaInterface *i, 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, @@ -252,7 +252,7 @@ unsigned catta_multicast_lookup_engine_scan_cache( assert(key); assert(callback); - assert(CATTA_IF_VALID(interface)); + assert(CATTA_IF_VALID(iface)); assert(CATTA_PROTO_VALID(protocol)); cbdata.engine = e; @@ -260,10 +260,10 @@ unsigned catta_multicast_lookup_engine_scan_cache( 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); @@ -282,7 +282,7 @@ void catta_multicast_lookup_engine_new_interface(CattaMulticastLookupEngine *e, 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); } } @@ -298,7 +298,7 @@ void catta_multicast_lookup_engine_notify(CattaMulticastLookupEngine *e, CattaIn 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); } diff --git a/src/probe-sched.c b/src/probe-sched.c index f59229a..7d417ad 100644 --- a/src/probe-sched.c +++ b/src/probe-sched.c @@ -50,7 +50,7 @@ struct CattaProbeJob { }; struct CattaProbeScheduler { - CattaInterface *interface; + CattaInterface *iface; CattaTimeEventQueue *time_event_queue; CATTA_LLIST_HEAD(CattaProbeJob, jobs); @@ -137,7 +137,7 @@ CattaProbeScheduler *catta_probe_scheduler_new(CattaInterface *i) { 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); @@ -229,7 +229,7 @@ static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) { 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; @@ -262,7 +262,7 @@ static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) { 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"); @@ -314,7 +314,7 @@ static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) { 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); } diff --git a/src/querier.c b/src/querier.c index dea1aa4..084bc42 100644 --- a/src/querier.c +++ b/src/querier.c @@ -32,7 +32,7 @@ #include struct CattaQuerier { - CattaInterface *interface; + CattaInterface *iface; CattaKey *key; int n_used; @@ -52,8 +52,8 @@ struct CattaQuerier { 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); @@ -77,7 +77,7 @@ static void querier_elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void *us 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 @@ -120,7 +120,7 @@ void catta_querier_add(CattaInterface *i, CattaKey *key, struct timeval *ret_cti 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; diff --git a/src/query-sched.c b/src/query-sched.c index 18c8971..f1bdd12 100644 --- a/src/query-sched.c +++ b/src/query-sched.c @@ -66,7 +66,7 @@ struct CattaKnownAnswer { }; struct CattaQueryScheduler { - CattaInterface *interface; + CattaInterface *iface; CattaTimeEventQueue *time_event_queue; unsigned next_id; @@ -157,7 +157,7 @@ CattaQueryScheduler *catta_query_scheduler_new(CattaInterface *i) { return NULL; /* OOM */ } - s->interface = i; + s->iface = i; s->time_event_queue = i->monitor->server->time_event_queue; s->next_id = 0; @@ -218,7 +218,7 @@ static int packet_add_query_job(CattaQueryScheduler *s, CattaDnsPacket *p, Catta 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); @@ -250,10 +250,10 @@ static void append_known_answers_and_send(CattaQueryScheduler *s, CattaDnsPacket 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; } @@ -266,7 +266,7 @@ static void append_known_answers_and_send(CattaQueryScheduler *s, CattaDnsPacket } 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); } @@ -288,7 +288,7 @@ static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) { 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); diff --git a/src/resolve-address.c b/src/resolve-address.c index 48dba8d..04e988e 100644 --- a/src/resolve-address.c +++ b/src/resolve-address.c @@ -42,7 +42,7 @@ struct CattaSAddressResolver { void* userdata; CattaRecord *ptr_record; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; CattaLookupResultFlags flags; @@ -64,12 +64,12 @@ static void finish(CattaSAddressResolver *r, CattaResolverEvent event) { 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; } } @@ -97,7 +97,7 @@ static void start_timeout(CattaSAddressResolver *r) { static void record_browser_callback( CattaSRecordBrowser*rr, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -114,14 +114,14 @@ static void record_browser_callback( 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; @@ -160,7 +160,7 @@ static void record_browser_callback( 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); @@ -176,7 +176,7 @@ static void record_browser_callback( CattaSAddressResolver *catta_s_address_resolver_new( CattaServer *server, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, const CattaAddress *address, CattaLookupFlags flags, @@ -191,7 +191,7 @@ CattaSAddressResolver *catta_s_address_resolver_new( 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); @@ -214,7 +214,7 @@ CattaSAddressResolver *catta_s_address_resolver_new( 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; @@ -235,7 +235,7 @@ CattaSAddressResolver *catta_s_address_resolver_new( } } - 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); diff --git a/src/resolve-host-name.c b/src/resolve-host-name.c index 24629bc..c9fca47 100644 --- a/src/resolve-host-name.c +++ b/src/resolve-host-name.c @@ -44,7 +44,7 @@ struct CattaSHostNameResolver { void* userdata; CattaRecord *address_record; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; CattaLookupResultFlags flags; @@ -82,14 +82,14 @@ static void finish(CattaSHostNameResolver *r, CattaResolverEvent event) { 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; } } @@ -118,7 +118,7 @@ static void start_timeout(CattaSHostNameResolver *r) { static void record_browser_callback( CattaSRecordBrowser*rr, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -136,14 +136,14 @@ static void record_browser_callback( 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; @@ -203,7 +203,7 @@ static void record_browser_callback( CattaSHostNameResolver *catta_s_host_name_resolver_new( CattaServer *server, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, const char *host_name, CattaProtocol aprotocol, @@ -218,7 +218,7 @@ CattaSHostNameResolver *catta_s_host_name_resolver_new( 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); @@ -234,7 +234,7 @@ CattaSHostNameResolver *catta_s_host_name_resolver_new( r->callback = callback; r->userdata = userdata; r->address_record = NULL; - r->interface = interface; + r->iface = iface; r->protocol = protocol; r->flags = 0; @@ -248,7 +248,7 @@ CattaSHostNameResolver *catta_s_host_name_resolver_new( 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) @@ -257,7 +257,7 @@ CattaSHostNameResolver *catta_s_host_name_resolver_new( 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) diff --git a/src/resolve-service.c b/src/resolve-service.c index 683c85d..0f6177a 100644 --- a/src/resolve-service.c +++ b/src/resolve-service.c @@ -42,7 +42,7 @@ struct CattaSServiceResolver { char *domain_name; CattaProtocol address_protocol; - CattaIfIndex interface; + CattaIfIndex iface; CattaProtocol protocol; CattaSRecordBrowser *record_browser_srv; @@ -82,7 +82,7 @@ static void finish(CattaSServiceResolver *r, CattaResolverEvent event) { r->callback( r, - r->interface, + r->iface, r->protocol, event, r->service_name, @@ -123,7 +123,7 @@ static void finish(CattaSServiceResolver *r, CattaResolverEvent event) { r->callback( r, - r->interface, + r->iface, r->protocol, event, r->service_name, @@ -165,7 +165,7 @@ static void start_timeout(CattaSServiceResolver *r) { static void record_browser_callback( CattaSRecordBrowser*rr, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -190,14 +190,14 @@ static void record_browser_callback( 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; @@ -222,13 +222,13 @@ static void record_browser_callback( 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); } } @@ -377,7 +377,7 @@ static void record_browser_callback( CattaSServiceResolver *catta_s_service_resolver_new( CattaServer *server, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, const char *name, const char *type, @@ -396,7 +396,7 @@ CattaSServiceResolver *catta_s_service_resolver_new( 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); @@ -426,7 +426,7 @@ CattaSServiceResolver *catta_s_service_resolver_new( 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; @@ -434,7 +434,7 @@ CattaSServiceResolver *catta_s_service_resolver_new( 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) { @@ -444,7 +444,7 @@ CattaSServiceResolver *catta_s_service_resolver_new( 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) { diff --git a/src/response-sched.c b/src/response-sched.c index fc3630d..c6fd13c 100644 --- a/src/response-sched.c +++ b/src/response-sched.c @@ -66,7 +66,7 @@ struct CattaResponseJob { }; struct CattaResponseScheduler { - CattaInterface *interface; + CattaInterface *iface; CattaTimeEventQueue *time_event_queue; CATTA_LLIST_HEAD(CattaResponseJob, jobs); @@ -160,7 +160,7 @@ CattaResponseScheduler *catta_response_scheduler_new(CattaInterface *i) { 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); @@ -208,7 +208,7 @@ static int packet_add_response_job(CattaResponseScheduler *s, CattaDnsPacket *p, /* 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; @@ -221,7 +221,7 @@ static void send_response_packet(CattaResponseScheduler *s, CattaResponseJob *rj 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; @@ -258,7 +258,7 @@ static void send_response_packet(CattaResponseScheduler *s, CattaResponseJob *rj } 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); } diff --git a/src/server.c b/src/server.c index 4dc0dd0..a726310 100644 --- a/src/server.c +++ b/src/server.c @@ -506,7 +506,7 @@ static void reflect_response(CattaServer *s, CattaInterface *i, CattaRecord *r, 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); } @@ -541,7 +541,7 @@ static void reflect_query(CattaServer *s, CattaInterface *i, CattaKey *k) { 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); @@ -563,7 +563,7 @@ static void reflect_probe(CattaServer *s, CattaInterface *i, CattaRecord *r) { 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); } @@ -810,7 +810,7 @@ static void reflect_legacy_unicast_query_packet(CattaServer *s, CattaDnsPacket * 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); @@ -818,7 +818,7 @@ static void reflect_legacy_unicast_query_packet(CattaServer *s, CattaDnsPacket * /* 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)) { @@ -1001,7 +1001,7 @@ static void dispatch_legacy_unicast_packet(CattaServer *s, CattaDnsPacket *p) { 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; @@ -1682,7 +1682,7 @@ uint32_t catta_server_get_local_service_cookie(CattaServer *s) { 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); @@ -1690,7 +1690,7 @@ static CattaEntry *find_entry(CattaServer *s, CattaIfIndex interface, CattaProto 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)) @@ -1699,7 +1699,7 @@ static CattaEntry *find_entry(CattaServer *s, CattaIfIndex interface, CattaProto 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; @@ -1710,7 +1710,7 @@ int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex interface, Ca 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); @@ -1722,7 +1722,7 @@ int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex interface, Ca 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) { @@ -1733,7 +1733,7 @@ int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex interface, Ca 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; @@ -1746,7 +1746,7 @@ int catta_server_is_service_local(CattaServer *s, CattaIfIndex interface, CattaP 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) @@ -1755,7 +1755,7 @@ int catta_server_is_service_local(CattaServer *s, CattaIfIndex interface, CattaP 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); @@ -1763,7 +1763,7 @@ int catta_server_is_record_local(CattaServer *s, CattaIfIndex interface, CattaPr 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)) diff --git a/src/socket.c b/src/socket.c index a6dd588..f381561 100644 --- a/src/socket.c +++ b/src/socket.c @@ -469,7 +469,7 @@ static int sendmsg_loop(int fd, struct msghdr *msg, int flags) { int catta_send_dns_packet_ipv4( int fd, - CattaIfIndex interface, + CattaIfIndex iface, CattaDnsPacket *p, const CattaIPv4Address *src_address, const CattaIPv4Address *dst_address, @@ -510,7 +510,7 @@ int catta_send_dns_packet_ipv4( 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)); @@ -524,8 +524,8 @@ int catta_send_dns_packet_ipv4( 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; @@ -563,7 +563,7 @@ int catta_send_dns_packet_ipv4( int catta_send_dns_packet_ipv6( int fd, - CattaIfIndex interface, + CattaIfIndex iface, CattaDnsPacket *p, const CattaIPv6Address *src_address, const CattaIPv6Address *dst_address, @@ -596,7 +596,7 @@ int catta_send_dns_packet_ipv6( 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)); @@ -610,8 +610,8 @@ int catta_send_dns_packet_ipv6( 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)); diff --git a/tests/catta-test.c b/tests/catta-test.c index 0008282..359df9e 100644 --- a/tests/catta-test.c +++ b/tests/catta-test.c @@ -89,7 +89,7 @@ static const char *resolver_event_to_string(CattaResolverEvent event) { static void record_browser_callback( CattaSRecordBrowser *r, - CattaIfIndex interface, + CattaIfIndex iface, CattaProtocol protocol, CattaBrowserEvent event, CattaRecord *record, @@ -100,7 +100,7 @@ static void record_browser_callback( 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)); -- 2.39.5