1#ifndef foodbusinternalhfoo 2#define foodbusinternalhfoo 3 4/* $Id$ */ 5 6/*** 7 This file is part of avahi. 8 9 avahi is free software; you can redistribute it and/or modify it 10 under the terms of the GNU Lesser General Public License as 11 published by the Free Software Foundation; either version 2.1 of the 12 License, or (at your option) any later version. 13 14 avahi is distributed in the hope that it will be useful, but WITHOUT 15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 17 Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with avahi; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 USA. 23***/ 24 25 26#include <dbus/dbus.h> 27 28#include <avahi-core/core.h> 29#include <avahi-core/publish.h> 30#include <avahi-core/lookup.h> 31 32#include <avahi-common/llist.h> 33 34typedef struct Server Server; 35typedef struct Client Client; 36typedef struct EntryGroupInfo EntryGroupInfo; 37typedef struct SyncHostNameResolverInfo SyncHostNameResolverInfo; 38typedef struct AsyncHostNameResolverInfo AsyncHostNameResolverInfo; 39typedef struct SyncAddressResolverInfo SyncAddressResolverInfo; 40typedef struct AsyncAddressResolverInfo AsyncAddressResolverInfo; 41typedef struct DomainBrowserInfo DomainBrowserInfo; 42typedef struct ServiceTypeBrowserInfo ServiceTypeBrowserInfo; 43typedef struct ServiceBrowserInfo ServiceBrowserInfo; 44typedef struct SyncServiceResolverInfo SyncServiceResolverInfo; 45typedef struct AsyncServiceResolverInfo AsyncServiceResolverInfo; 46typedef struct RecordBrowserInfo RecordBrowserInfo; 47 48#define CLIENTS_MAX 256 49#define OBJECTS_PER_CLIENT_MAX 250 50#define ENTRIES_PER_ENTRY_GROUP_MAX 20 51 52struct EntryGroupInfo { 53 unsigned id; 54 Client *client; 55 AvahiSEntryGroup *entry_group; 56 char *path; 57 58 int n_entries; 59 60 AVAHI_LLIST_FIELDS(EntryGroupInfo, entry_groups); 61}; 62 63struct SyncHostNameResolverInfo { 64 Client *client; 65 AvahiSHostNameResolver *host_name_resolver; 66 DBusMessage *message; 67 68 AVAHI_LLIST_FIELDS(SyncHostNameResolverInfo, sync_host_name_resolvers); 69}; 70 71struct AsyncHostNameResolverInfo { 72 unsigned id; 73 Client *client; 74 AvahiSHostNameResolver *host_name_resolver; 75 char *path; 76 77 AVAHI_LLIST_FIELDS(AsyncHostNameResolverInfo, async_host_name_resolvers); 78}; 79 80struct SyncAddressResolverInfo { 81 Client *client; 82 AvahiSAddressResolver *address_resolver; 83 DBusMessage *message; 84 85 AVAHI_LLIST_FIELDS(SyncAddressResolverInfo, sync_address_resolvers); 86}; 87 88struct AsyncAddressResolverInfo { 89 unsigned id; 90 Client *client; 91 AvahiSAddressResolver *address_resolver; 92 char *path; 93 94 AVAHI_LLIST_FIELDS(AsyncAddressResolverInfo, async_address_resolvers); 95}; 96 97struct DomainBrowserInfo { 98 unsigned id; 99 Client *client; 100 AvahiSDomainBrowser *domain_browser; 101 char *path; 102 103 AVAHI_LLIST_FIELDS(DomainBrowserInfo, domain_browsers); 104}; 105 106struct ServiceTypeBrowserInfo { 107 unsigned id; 108 Client *client; 109 AvahiSServiceTypeBrowser *service_type_browser; 110 char *path; 111 112 AVAHI_LLIST_FIELDS(ServiceTypeBrowserInfo, service_type_browsers); 113}; 114 115struct ServiceBrowserInfo { 116 unsigned id; 117 Client *client; 118 AvahiSServiceBrowser *service_browser; 119 char *path; 120 121 AVAHI_LLIST_FIELDS(ServiceBrowserInfo, service_browsers); 122}; 123 124struct SyncServiceResolverInfo { 125 Client *client; 126 AvahiSServiceResolver *service_resolver; 127 DBusMessage *message; 128 129 AVAHI_LLIST_FIELDS(SyncServiceResolverInfo, sync_service_resolvers); 130}; 131 132struct AsyncServiceResolverInfo { 133 unsigned id; 134 Client *client; 135 AvahiSServiceResolver *service_resolver; 136 char *path; 137 138 AVAHI_LLIST_FIELDS(AsyncServiceResolverInfo, async_service_resolvers); 139}; 140 141struct RecordBrowserInfo { 142 unsigned id; 143 Client *client; 144 AvahiSRecordBrowser *record_browser; 145 char *path; 146 147 AVAHI_LLIST_FIELDS(RecordBrowserInfo, record_browsers); 148}; 149 150struct Client { 151 unsigned id; 152 char *name; 153 unsigned current_id; 154 int n_objects; 155 156 AVAHI_LLIST_FIELDS(Client, clients); 157 AVAHI_LLIST_HEAD(EntryGroupInfo, entry_groups); 158 AVAHI_LLIST_HEAD(SyncHostNameResolverInfo, sync_host_name_resolvers); 159 AVAHI_LLIST_HEAD(AsyncHostNameResolverInfo, async_host_name_resolvers); 160 AVAHI_LLIST_HEAD(SyncAddressResolverInfo, sync_address_resolvers); 161 AVAHI_LLIST_HEAD(AsyncAddressResolverInfo, async_address_resolvers); 162 AVAHI_LLIST_HEAD(DomainBrowserInfo, domain_browsers); 163 AVAHI_LLIST_HEAD(ServiceTypeBrowserInfo, service_type_browsers); 164 AVAHI_LLIST_HEAD(ServiceBrowserInfo, service_browsers); 165 AVAHI_LLIST_HEAD(SyncServiceResolverInfo, sync_service_resolvers); 166 AVAHI_LLIST_HEAD(AsyncServiceResolverInfo, async_service_resolvers); 167 AVAHI_LLIST_HEAD(RecordBrowserInfo, record_browsers); 168}; 169 170struct Server { 171 const AvahiPoll *poll_api; 172 DBusConnection *bus; 173 AVAHI_LLIST_HEAD(Client, clients); 174 int n_clients; 175 unsigned current_id; 176 177 AvahiTimeout *reconnect_timeout; 178 int reconnect; 179}; 180 181extern Server *server; 182 183void avahi_dbus_entry_group_free(EntryGroupInfo *i); 184void avahi_dbus_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata); 185DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage *m, void *userdata); 186 187void avahi_dbus_sync_host_name_resolver_free(SyncHostNameResolverInfo *i); 188void avahi_dbus_sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata); 189 190void avahi_dbus_async_host_name_resolver_free(AsyncHostNameResolverInfo *i); 191void avahi_dbus_async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata); 192DBusHandlerResult avahi_dbus_msg_async_host_name_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata); 193 194void avahi_dbus_sync_address_resolver_free(SyncAddressResolverInfo *i); 195void avahi_dbus_sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata); 196 197void avahi_dbus_async_address_resolver_free(AsyncAddressResolverInfo *i); 198void avahi_dbus_async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata); 199DBusHandlerResult avahi_dbus_msg_async_address_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata); 200 201void avahi_dbus_domain_browser_free(DomainBrowserInfo *i); 202DBusHandlerResult avahi_dbus_msg_domain_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); 203void avahi_dbus_domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void* userdata); 204 205void avahi_dbus_service_type_browser_free(ServiceTypeBrowserInfo *i); 206DBusHandlerResult avahi_dbus_msg_service_type_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); 207void avahi_dbus_service_type_browser_callback(AvahiSServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata); 208 209void avahi_dbus_service_browser_free(ServiceBrowserInfo *i); 210DBusHandlerResult avahi_dbus_msg_service_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); 211void avahi_dbus_service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata); 212 213void avahi_dbus_sync_service_resolver_free(SyncServiceResolverInfo *i); 214 215void avahi_dbus_sync_service_resolver_callback( 216 AvahiSServiceResolver *r, 217 AvahiIfIndex interface, 218 AvahiProtocol protocol, 219 AvahiResolverEvent event, 220 const char *name, 221 const char *type, 222 const char *domain, 223 const char *host_name, 224 const AvahiAddress *a, 225 uint16_t port, 226 AvahiStringList *txt, 227 AvahiLookupResultFlags flags, 228 void* userdata); 229 230void avahi_dbus_async_service_resolver_free(AsyncServiceResolverInfo *i); 231void avahi_dbus_async_service_resolver_callback( 232 AvahiSServiceResolver *r, 233 AvahiIfIndex interface, 234 AvahiProtocol protocol, 235 AvahiResolverEvent event, 236 const char *name, 237 const char *type, 238 const char *domain, 239 const char *host_name, 240 const AvahiAddress *a, 241 uint16_t port, 242 AvahiStringList *txt, 243 AvahiLookupResultFlags flags, 244 void* userdata); 245 246DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata); 247 248void avahi_dbus_record_browser_free(RecordBrowserInfo *i); 249DBusHandlerResult avahi_dbus_msg_record_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); 250void avahi_dbus_record_browser_callback(AvahiSRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata); 251 252#endif 253