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