X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fiface.h;h=4106ea7b717739096d9c8fd911af437f1412d56b;hb=c7ecad8fa467b8be2b34064020e2c541c480645e;hp=25eb3247515483e6bba0b4f5dcf0993425df5baf;hpb=1ffedb586bd2fb6daa3970304fac7c5b415cd38f;p=catta diff --git a/avahi-core/iface.h b/avahi-core/iface.h index 25eb324..4106ea7 100644 --- a/avahi-core/iface.h +++ b/avahi-core/iface.h @@ -30,8 +30,7 @@ typedef struct AvahiHwInterface AvahiHwInterface; #include #include -#include "server.h" -#include "netlink.h" +#include "internal.h" #include "cache.h" #include "response-sched.h" #include "query-sched.h" @@ -41,16 +40,14 @@ typedef struct AvahiHwInterface AvahiHwInterface; #include "browse.h" #include "querier.h" -#define AVAHI_MAX_MAC_ADDRESS 32 - -struct AvahiInterfaceMonitor { - AvahiServer *server; - AvahiNetlink *netlink; - AvahiHashmap *hashmap; - - AVAHI_LLIST_HEAD(AvahiInterface, interfaces); - AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces); - +#ifdef HAVE_NETLINK +#include "iface-linux.h" +#elif defined(HAVE_PF_ROUTE) +#include "iface-pfroute.h" +#else +typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep; +struct AvahiInterfaceMonitorOSDep { + unsigned query_addr_seq, query_link_seq; enum { @@ -59,17 +56,33 @@ struct AvahiInterfaceMonitor { LIST_DONE } list; }; +#endif + +#define AVAHI_MAC_ADDRESS_MAX 32 + +struct AvahiInterfaceMonitor { + AvahiServer *server; + AvahiHashmap *hashmap; + + AVAHI_LLIST_HEAD(AvahiInterface, interfaces); + AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces); + + int list_complete; + AvahiInterfaceMonitorOSDep osdep; +}; struct AvahiHwInterface { - AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware); AvahiInterfaceMonitor *monitor; + AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware); + char *name; AvahiIfIndex index; - unsigned flags; + int flags_ok; + unsigned mtu; - uint8_t mac_address[AVAHI_MAX_MAC_ADDRESS]; + uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX]; size_t mac_address_size; AvahiSEntryGroup *entry_group; @@ -78,13 +91,16 @@ struct AvahiHwInterface { }; struct AvahiInterface { + AvahiInterfaceMonitor *monitor; + AvahiHwInterface *hardware; + AVAHI_LLIST_FIELDS(AvahiInterface, interface); AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware); - AvahiInterfaceMonitor *monitor; - AvahiHwInterface *hardware; AvahiProtocol protocol; int announcing; + AvahiAddress local_mcast_address; + int mcast_joined; AvahiCache *cache; @@ -93,57 +109,84 @@ struct AvahiInterface { AvahiProbeScheduler *probe_scheduler; AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses); - AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements); + AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers); AvahiHashmap *queriers_by_key; AVAHI_LLIST_HEAD(AvahiQuerier, queriers); }; struct AvahiInterfaceAddress { - AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address); AvahiInterfaceMonitor *monitor; - - unsigned char flags; - unsigned char scope; - unsigned char prefix_len; + AvahiInterface *interface; + + AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address); + AvahiAddress address; + unsigned prefix_len; + + int global_scope; AvahiSEntryGroup *entry_group; - AvahiInterface *interface; }; AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server); void avahi_interface_monitor_free(AvahiInterfaceMonitor *m); +int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m); +void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m); void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m); -AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol); +typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata); +void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata); +int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata); + +void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs); +int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a); +void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m); + +/* AvahiHwInterface */ + +AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx); +void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye); + +void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs); +void avahi_hw_interface_check_relevant(AvahiHwInterface *hw); + AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx); +/* AvahiInterface */ + +AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol); +void avahi_interface_free(AvahiInterface *i, int send_goodbye); + +void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs); +void avahi_interface_check_relevant(AvahiInterface *i); +int avahi_interface_is_relevant(AvahiInterface *i); + void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p); void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port); -int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately); +int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately, unsigned *ret_id); +int avahi_interface_withraw_query(AvahiInterface *i, unsigned id); int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately); int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately); -int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata); - -int avahi_interface_relevant(AvahiInterface *i); -int avahi_interface_address_relevant(AvahiInterfaceAddress *a); - int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol); +int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a); +int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a); -typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata); - -void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata); +AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol); -void avahi_update_host_rrs(AvahiInterfaceMonitor *m, int remove_rrs); +/* AvahiInterfaceAddress */ -int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a); +AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len); +void avahi_interface_address_free(AvahiInterfaceAddress *a); -int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a); +void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs); +int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a); -int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a); +AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr); + +AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const AvahiAddress *a); #endif