From f726a534b6230de7a5323d811ef375b979f5bddb Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" Date: Mon, 18 Aug 2014 15:02:55 +0200 Subject: [PATCH] remove all but avahi-common and avahi-core and adjust build system accordingly --- Makefile.am | 145 -- autogen.sh | 14 +- avahi-autoipd/.gitignore | 9 - avahi-autoipd/Makefile.am | 94 - avahi-autoipd/avahi-autoipd.action.bsd | 48 - avahi-autoipd/avahi-autoipd.action.linux | 87 - avahi-autoipd/dhclient-enter-hook.in | 31 - avahi-autoipd/dhclient-exit-hook.in | 31 - avahi-autoipd/iface-bsd.c | 440 ----- avahi-autoipd/iface-linux.c | 332 ---- avahi-autoipd/iface.h | 45 - avahi-autoipd/main.c | 1714 ---------------- avahi-autoipd/main.h | 45 - avahi-client.pc.in | 10 - avahi-client/.gitignore | 12 - avahi-client/Makefile.am | 83 - avahi-client/browser.c | 1025 ---------- avahi-client/check-nss-test.c | 31 - avahi-client/check-nss.c | 55 - avahi-client/client-test.c | 328 ---- avahi-client/client.c | 958 --------- avahi-client/client.h | 117 -- avahi-client/entrygroup.c | 890 --------- avahi-client/internal.h | 172 -- avahi-client/lookup.h | 314 --- avahi-client/publish.h | 172 -- avahi-client/resolver.c | 778 -------- avahi-client/rr-test.c | 111 -- avahi-client/srv-test.c | 76 - avahi-client/xdg-config-test.c | 38 - avahi-client/xdg-config.c | 68 - avahi-client/xdg-config.h | 27 - avahi-common/Makefile.am | 8 - avahi-common/dbus-watch-glue.c | 357 ---- avahi-common/dbus-watch-glue.h | 33 - avahi-common/dbus.c | 138 -- avahi-common/dbus.h | 119 -- avahi-compat-howl.pc.in | 10 - avahi-compat-howl/.gitignore | 11 - avahi-compat-howl/Makefile.am | 109 -- avahi-compat-howl/address-test.c | 51 - avahi-compat-howl/address.c | 212 -- avahi-compat-howl/browse-domain-test.c | 74 - avahi-compat-howl/compat.c | 1182 ----------- avahi-compat-howl/funcs.txt | 182 -- avahi-compat-howl/include/corby/buffer.h | 330 ---- avahi-compat-howl/include/corby/channel.h | 186 -- avahi-compat-howl/include/corby/corby.h | 68 - avahi-compat-howl/include/corby/message.h | 60 - avahi-compat-howl/include/corby/object.h | 113 -- avahi-compat-howl/include/corby/orb.h | 199 -- .../include/discovery/discovery.h | 327 ---- .../include/discovery/text_record.h | 143 -- avahi-compat-howl/include/howl.h | 44 - .../include/rendezvous/rendezvous.h | 101 - .../include/rendezvous/text_record.h | 36 - avahi-compat-howl/include/salt/address.h | 128 -- avahi-compat-howl/include/salt/debug.h | 230 --- avahi-compat-howl/include/salt/interface.h | 115 -- avahi-compat-howl/include/salt/platform.h | 438 ----- avahi-compat-howl/include/salt/salt.h | 215 -- avahi-compat-howl/include/salt/signal.h | 61 - avahi-compat-howl/include/salt/socket.h | 263 --- avahi-compat-howl/include/salt/time.h | 100 - avahi-compat-howl/samples/.gitignore | 3 - avahi-compat-howl/samples/Makefile.am | 51 - avahi-compat-howl/samples/browse.c | 184 -- avahi-compat-howl/samples/publish.c | 110 -- avahi-compat-howl/samples/query.c | 98 - avahi-compat-howl/samples/resolve.c | 111 -- avahi-compat-howl/text-test.c | 97 - avahi-compat-howl/text.c | 259 --- avahi-compat-howl/unsupported.c | 1019 ---------- avahi-compat-howl/warn.c | 29 - avahi-compat-howl/warn.h | 33 - avahi-compat-libdns_sd.pc.in | 10 - avahi-compat-libdns_sd/.gitignore | 9 - avahi-compat-libdns_sd/Makefile.am | 73 - avahi-compat-libdns_sd/compat.c | 1372 ------------- avahi-compat-libdns_sd/dns_sd.h | 1722 ----------------- avahi-compat-libdns_sd/funcs.txt | 35 - avahi-compat-libdns_sd/null-test.c | 71 - avahi-compat-libdns_sd/txt-test.c | 128 -- avahi-compat-libdns_sd/txt.c | 489 ----- avahi-compat-libdns_sd/unsupported.c | 90 - avahi-compat-libdns_sd/warn.c | 124 -- avahi-compat-libdns_sd/warn.h | 36 - avahi-daemon/.gitignore | 11 - avahi-daemon/Makefile.am | 176 -- avahi-daemon/avahi-daemon.conf | 68 - avahi-daemon/avahi-daemon.service.in | 32 - avahi-daemon/avahi-daemon.socket.in | 25 - avahi-daemon/avahi-dbus.conf.in | 32 - avahi-daemon/avahi-service.dtd | 18 - avahi-daemon/caps.c | 115 -- avahi-daemon/caps.h | 27 - avahi-daemon/chroot.c | 415 ---- avahi-daemon/chroot.h | 34 - avahi-daemon/dbus-async-address-resolver.c | 142 -- avahi-daemon/dbus-async-host-name-resolver.c | 140 -- avahi-daemon/dbus-async-service-resolver.c | 179 -- avahi-daemon/dbus-domain-browser.c | 132 -- avahi-daemon/dbus-entry-group.c | 369 ---- avahi-daemon/dbus-internal.h | 256 --- avahi-daemon/dbus-protocol.c | 1226 ------------ avahi-daemon/dbus-protocol.h | 32 - avahi-daemon/dbus-record-browser.c | 164 -- avahi-daemon/dbus-service-browser.c | 144 -- avahi-daemon/dbus-service-type-browser.c | 134 -- avahi-daemon/dbus-sync-address-resolver.c | 96 - avahi-daemon/dbus-sync-host-name-resolver.c | 96 - avahi-daemon/dbus-sync-service-resolver.c | 135 -- avahi-daemon/dbus-util.c | 435 ----- avahi-daemon/dbus-util.h | 57 - avahi-daemon/example.service | 50 - avahi-daemon/hosts | 27 - avahi-daemon/ini-file-parser-test.c | 62 - avahi-daemon/ini-file-parser.c | 196 -- avahi-daemon/ini-file-parser.h | 55 - avahi-daemon/introspect.dtd | 37 - avahi-daemon/introspect.xsl | 102 - avahi-daemon/main.c | 1701 ---------------- avahi-daemon/main.h | 31 - .../org.freedesktop.Avahi.AddressResolver.xml | 50 - .../org.freedesktop.Avahi.DomainBrowser.xml | 59 - .../org.freedesktop.Avahi.EntryGroup.xml | 101 - ...org.freedesktop.Avahi.HostNameResolver.xml | 50 - .../org.freedesktop.Avahi.RecordBrowser.xml | 65 - avahi-daemon/org.freedesktop.Avahi.Server.xml | 219 --- .../org.freedesktop.Avahi.ServiceBrowser.xml | 63 - .../org.freedesktop.Avahi.ServiceResolver.xml | 55 - ...g.freedesktop.Avahi.ServiceTypeBrowser.xml | 61 - avahi-daemon/org.freedesktop.Avahi.service | 24 - avahi-daemon/sd-daemon.c | 436 ----- avahi-daemon/sd-daemon.h | 265 --- avahi-daemon/setproctitle.c | 111 -- avahi-daemon/setproctitle.h | 28 - avahi-daemon/sftp-ssh.service | 34 - avahi-daemon/simple-protocol.c | 568 ------ avahi-daemon/simple-protocol.h | 29 - avahi-daemon/ssh.service | 34 - avahi-daemon/static-hosts.c | 278 --- avahi-daemon/static-hosts.h | 28 - avahi-daemon/static-services.c | 744 ------- avahi-daemon/static-services.h | 28 - avahi-discover-standalone/.gitignore | 8 - avahi-discover-standalone/Makefile.am | 69 - avahi-discover-standalone/avahi-discover.ui | 84 - avahi-discover-standalone/main.c | 368 ---- avahi-dnsconfd/.gitignore | 2 - avahi-dnsconfd/Makefile.am | 53 - avahi-dnsconfd/avahi-dnsconfd.action | 80 - avahi-dnsconfd/avahi-dnsconfd.service.in | 29 - avahi-dnsconfd/main.c | 668 ------- avahi-glib.pc.in | 11 - avahi-glib/.gitignore | 8 - avahi-glib/Makefile.am | 53 - avahi-glib/glib-malloc.c | 55 - avahi-glib/glib-malloc.h | 39 - avahi-glib/glib-watch-test.c | 89 - avahi-glib/glib-watch.c | 402 ---- avahi-glib/glib-watch.h | 54 - avahi-gobject.pc.in | 11 - avahi-gobject/.gitignore | 14 - avahi-gobject/AvahiCore-0.6.gir | 61 - avahi-gobject/Makefile.am | 142 -- avahi-gobject/ga-client.c | 256 --- avahi-gobject/ga-client.h | 78 - avahi-gobject/ga-entry-group.c | 626 ------ avahi-gobject/ga-entry-group.h | 174 -- avahi-gobject/ga-enums.h | 70 - avahi-gobject/ga-error.c | 32 - avahi-gobject/ga-error.h | 33 - avahi-gobject/ga-record-browser.c | 381 ---- avahi-gobject/ga-record-browser.h | 74 - avahi-gobject/ga-service-browser.c | 372 ---- avahi-gobject/ga-service-browser.h | 71 - avahi-gobject/ga-service-resolver.c | 403 ---- avahi-gobject/ga-service-resolver.h | 75 - avahi-python/.gitignore | 1 - avahi-python/Makefile.am | 42 - avahi-python/avahi-bookmarks.in | 227 --- avahi-python/avahi-discover/.gitignore | 3 - avahi-python/avahi-discover/Makefile.am | 69 - avahi-python/avahi-discover/__init__.py | 18 - .../avahi-discover.desktop.in.in | 11 - avahi-python/avahi-discover/avahi-discover.py | 288 --- avahi-python/avahi/.gitignore | 1 - avahi-python/avahi/Makefile.am | 61 - avahi-python/avahi/ServiceTypeDatabase.py.in | 161 -- avahi-python/avahi/__init__.py | 112 -- avahi-qt/.gitignore | 9 - avahi-qt/Makefile.am | 68 - avahi-qt/qt-watch.cpp | 198 -- avahi-qt/qt-watch.h | 38 - avahi-qt3.pc.in | 11 - avahi-qt4.pc.in | 11 - avahi-sharp.pc.in | 8 - avahi-sharp/.gitignore | 6 - avahi-sharp/AddressResolver.cs | 190 -- avahi-sharp/AssemblyInfo.cs | 48 - avahi-sharp/AvahiTest.cs | 131 -- avahi-sharp/BrowserBase.cs | 50 - avahi-sharp/Client.cs | 383 ---- avahi-sharp/ClientException.cs | 123 -- avahi-sharp/DomainBrowser.cs | 198 -- avahi-sharp/EntryGroup.cs | 376 ---- avahi-sharp/HostNameResolver.cs | 167 -- avahi-sharp/Makefile.am | 82 - avahi-sharp/RecordBrowser.cs | 225 --- avahi-sharp/ResolverBase.cs | 34 - avahi-sharp/ServiceBrowser.cs | 214 -- avahi-sharp/ServiceResolver.cs | 225 --- avahi-sharp/ServiceTypeBrowser.cs | 197 -- avahi-sharp/Utility.cs | 112 -- avahi-sharp/avahi-sharp-docs.source | 4 - avahi-sharp/avahi-sharp.dll.config.in | 5 - avahi-sharp/avahi.snk | Bin 596 -> 0 bytes avahi-sharp/en/Avahi.xml | 6 - avahi-sharp/en/Avahi/AddressResolver.xml | 113 -- avahi-sharp/en/Avahi/BrowserBase.xml | 59 - avahi-sharp/en/Avahi/Client.xml | 178 -- avahi-sharp/en/Avahi/ClientException.xml | 29 - avahi-sharp/en/Avahi/ClientFlags.xml | 51 - avahi-sharp/en/Avahi/ClientState.xml | 66 - avahi-sharp/en/Avahi/ClientStateArgs.xml | 41 - avahi-sharp/en/Avahi/ClientStateHandler.xml | 23 - avahi-sharp/en/Avahi/DomainBrowser.xml | 101 - avahi-sharp/en/Avahi/DomainBrowserType.xml | 66 - avahi-sharp/en/Avahi/DomainInfo.xml | 61 - avahi-sharp/en/Avahi/DomainInfoArgs.xml | 41 - avahi-sharp/en/Avahi/DomainInfoHandler.xml | 23 - avahi-sharp/en/Avahi/EntryGroup.xml | 491 ----- avahi-sharp/en/Avahi/EntryGroupState.xml | 66 - avahi-sharp/en/Avahi/EntryGroupStateArgs.xml | 41 - .../en/Avahi/EntryGroupStateHandler.xml | 23 - avahi-sharp/en/Avahi/ErrorCode.xml | 526 ----- avahi-sharp/en/Avahi/ErrorCodeArgs.xml | 41 - avahi-sharp/en/Avahi/ErrorCodeHandler.xml | 23 - avahi-sharp/en/Avahi/HostAddressArgs.xml | 55 - avahi-sharp/en/Avahi/HostAddressHandler.xml | 23 - avahi-sharp/en/Avahi/HostNameResolver.xml | 115 -- avahi-sharp/en/Avahi/LookupFlags.xml | 71 - avahi-sharp/en/Avahi/LookupResultFlags.xml | 81 - avahi-sharp/en/Avahi/Protocol.xml | 46 - avahi-sharp/en/Avahi/PublishFlags.xml | 121 -- avahi-sharp/en/Avahi/RecordBrowser.xml | 107 - avahi-sharp/en/Avahi/RecordClass.xml | 26 - avahi-sharp/en/Avahi/RecordInfo.xml | 94 - avahi-sharp/en/Avahi/RecordInfoArgs.xml | 41 - avahi-sharp/en/Avahi/RecordInfoHandler.xml | 23 - avahi-sharp/en/Avahi/RecordType.xml | 116 -- avahi-sharp/en/Avahi/ResolverBase.xml | 37 - avahi-sharp/en/Avahi/ServiceBrowser.xml | 119 -- avahi-sharp/en/Avahi/ServiceInfo.xml | 138 -- avahi-sharp/en/Avahi/ServiceInfoArgs.xml | 41 - avahi-sharp/en/Avahi/ServiceInfoHandler.xml | 23 - avahi-sharp/en/Avahi/ServiceResolver.xml | 125 -- avahi-sharp/en/Avahi/ServiceTypeBrowser.xml | 113 -- avahi-sharp/en/Avahi/ServiceTypeInfo.xml | 72 - avahi-sharp/en/Avahi/ServiceTypeInfoArgs.xml | 41 - .../en/Avahi/ServiceTypeInfoHandler.xml | 23 - avahi-sharp/en/index.xml | 79 - avahi-sharp/gencfg.sh | 12 - avahi-ui-gtk3.pc.in | 11 - avahi-ui-sharp.pc.in | 9 - avahi-ui-sharp/.gitignore | 6 - avahi-ui-sharp/Makefile.am | 70 - avahi-ui-sharp/ServiceDialog.cs | 238 --- avahi-ui-sharp/avahi-ui-sharp-docs.source | 4 - avahi-ui-sharp/avahi-ui-sharp.dll.config.in | 4 - avahi-ui-sharp/bssh.cs | 39 - avahi-ui-sharp/en/Avahi.UI.xml | 6 - avahi-ui-sharp/en/Avahi.UI/ServiceDialog.xml | 171 -- avahi-ui-sharp/en/index.xml | 13 - avahi-ui-sharp/gencfg.sh | 6 - avahi-ui.pc.in | 11 - avahi-ui/.gitignore | 13 - avahi-ui/Makefile.am | 113 -- avahi-ui/avahi-ui.c | 1477 -------------- avahi-ui/avahi-ui.h | 181 -- avahi-ui/bssh.c | 256 --- avahi-ui/bssh.desktop.in.in | 11 - avahi-ui/bvnc.desktop.in.in | 11 - avahi-utils/.gitignore | 10 - avahi-utils/Makefile.am | 66 - avahi-utils/avahi-browse.c | 879 --------- avahi-utils/avahi-publish.c | 429 ---- avahi-utils/avahi-resolve.c | 339 ---- avahi-utils/avahi-set-host-name.c | 211 -- avahi-utils/sigint.c | 144 -- avahi-utils/sigint.h | 28 - avahi-utils/stdb.c | 212 -- avahi-utils/stdb.h | 30 - configure.ac | 843 -------- examples/Makefile.am | 31 - examples/client-browse-services.c | 197 -- examples/client-publish-service.c | 280 --- examples/glib-integration.c | 146 -- initscript/.gitignore | 2 - initscript/Makefile.am | 58 - initscript/archlinux/Makefile.am | 38 - initscript/archlinux/avahi-daemon.in | 72 - initscript/archlinux/avahi-dnsconfd.in | 72 - initscript/darwin/Makefile.am | 36 - .../org.freedesktop.avahi-daemon.plist.in | 16 - .../org.freedesktop.avahi-dnsconfd.plist.in | 16 - initscript/debian/Makefile.am | 44 - initscript/debian/avahi-daemon.in | 178 -- initscript/debian/avahi-dnsconfd.in | 184 -- initscript/fedora/.gitignore | 4 - initscript/fedora/Makefile.am | 38 - initscript/fedora/avahi-daemon.in | 116 -- initscript/fedora/avahi-dnsconfd.in | 113 -- initscript/freebsd/Makefile.am | 41 - initscript/freebsd/avahi-daemon.sh.in | 36 - initscript/freebsd/avahi-dnsconfd.sh.in | 39 - initscript/gentoo/Makefile.am | 43 - initscript/gentoo/avahi-daemon.in | 29 - initscript/gentoo/avahi-dnsconfd.in | 28 - initscript/lfs/Makefile.am | 31 - initscript/lfs/avahi.in | 49 - initscript/mandriva/Makefile.am | 32 - initscript/mandriva/avahi-daemon.in | 94 - initscript/mandriva/avahi-dnsconfd.in | 94 - initscript/slackware/Makefile.am | 32 - initscript/slackware/avahi-daemon.in | 78 - initscript/slackware/avahi-dnsconfd.in | 78 - initscript/suse/Makefile.am | 32 - initscript/suse/avahi-daemon.in | 60 - initscript/suse/avahi-dnsconfd.in | 60 - man/.gitignore | 8 - man/Makefile.am | 154 -- man/avahi-autoipd.8.xml.in | 164 -- man/avahi-autoipd.action.8.xml.in | 83 - man/avahi-bookmarks.1.xml.in | 99 - man/avahi-browse.1.xml.in | 135 -- man/avahi-daemon.8.xml.in | 170 -- man/avahi-daemon.conf.5.xml.in | 385 ---- man/avahi-discover.1.xml.in | 59 - man/avahi-dnsconfd.8.xml.in | 107 - man/avahi-dnsconfd.action.8.xml.in | 90 - man/avahi-publish.1.xml.in | 122 -- man/avahi-resolve.1.xml.in | 105 - man/avahi-set-host-name.1.xml.in | 73 - man/avahi.hosts.5.xml.in | 60 - man/avahi.service.5.xml.in | 122 -- man/bssh.1.xml.in | 88 - man/xmltoman.css | 28 - man/xmltoman.dtd | 37 - man/xmltoman.xsl | 127 -- service-type-database/.gitignore | 4 - service-type-database/Makefile.am | 64 - service-type-database/build-db.in | 44 - service-type-database/service-types | 233 --- tests/.gitignore | 8 - tests/Makefile.am | 53 - tests/c-plus-plus-test-gen.py | 64 - tests/c-plus-plus-test.cc | 82 - tests/fuzz-mdns.py | 8 - 360 files changed, 5 insertions(+), 54349 deletions(-) delete mode 100644 avahi-autoipd/.gitignore delete mode 100644 avahi-autoipd/Makefile.am delete mode 100755 avahi-autoipd/avahi-autoipd.action.bsd delete mode 100755 avahi-autoipd/avahi-autoipd.action.linux delete mode 100755 avahi-autoipd/dhclient-enter-hook.in delete mode 100755 avahi-autoipd/dhclient-exit-hook.in delete mode 100644 avahi-autoipd/iface-bsd.c delete mode 100644 avahi-autoipd/iface-linux.c delete mode 100644 avahi-autoipd/iface.h delete mode 100644 avahi-autoipd/main.c delete mode 100644 avahi-autoipd/main.h delete mode 100644 avahi-client.pc.in delete mode 100644 avahi-client/.gitignore delete mode 100644 avahi-client/Makefile.am delete mode 100644 avahi-client/browser.c delete mode 100644 avahi-client/check-nss-test.c delete mode 100644 avahi-client/check-nss.c delete mode 100644 avahi-client/client-test.c delete mode 100644 avahi-client/client.c delete mode 100644 avahi-client/client.h delete mode 100644 avahi-client/entrygroup.c delete mode 100644 avahi-client/internal.h delete mode 100644 avahi-client/lookup.h delete mode 100644 avahi-client/publish.h delete mode 100644 avahi-client/resolver.c delete mode 100644 avahi-client/rr-test.c delete mode 100644 avahi-client/srv-test.c delete mode 100644 avahi-client/xdg-config-test.c delete mode 100644 avahi-client/xdg-config.c delete mode 100644 avahi-client/xdg-config.h delete mode 100644 avahi-common/dbus-watch-glue.c delete mode 100644 avahi-common/dbus-watch-glue.h delete mode 100644 avahi-common/dbus.c delete mode 100644 avahi-common/dbus.h delete mode 100644 avahi-compat-howl.pc.in delete mode 100644 avahi-compat-howl/.gitignore delete mode 100644 avahi-compat-howl/Makefile.am delete mode 100644 avahi-compat-howl/address-test.c delete mode 100644 avahi-compat-howl/address.c delete mode 100644 avahi-compat-howl/browse-domain-test.c delete mode 100644 avahi-compat-howl/compat.c delete mode 100644 avahi-compat-howl/funcs.txt delete mode 100644 avahi-compat-howl/include/corby/buffer.h delete mode 100644 avahi-compat-howl/include/corby/channel.h delete mode 100644 avahi-compat-howl/include/corby/corby.h delete mode 100644 avahi-compat-howl/include/corby/message.h delete mode 100644 avahi-compat-howl/include/corby/object.h delete mode 100644 avahi-compat-howl/include/corby/orb.h delete mode 100644 avahi-compat-howl/include/discovery/discovery.h delete mode 100644 avahi-compat-howl/include/discovery/text_record.h delete mode 100644 avahi-compat-howl/include/howl.h delete mode 100644 avahi-compat-howl/include/rendezvous/rendezvous.h delete mode 100644 avahi-compat-howl/include/rendezvous/text_record.h delete mode 100644 avahi-compat-howl/include/salt/address.h delete mode 100644 avahi-compat-howl/include/salt/debug.h delete mode 100644 avahi-compat-howl/include/salt/interface.h delete mode 100644 avahi-compat-howl/include/salt/platform.h delete mode 100644 avahi-compat-howl/include/salt/salt.h delete mode 100644 avahi-compat-howl/include/salt/signal.h delete mode 100644 avahi-compat-howl/include/salt/socket.h delete mode 100644 avahi-compat-howl/include/salt/time.h delete mode 100644 avahi-compat-howl/samples/.gitignore delete mode 100644 avahi-compat-howl/samples/Makefile.am delete mode 100644 avahi-compat-howl/samples/browse.c delete mode 100644 avahi-compat-howl/samples/publish.c delete mode 100644 avahi-compat-howl/samples/query.c delete mode 100644 avahi-compat-howl/samples/resolve.c delete mode 100644 avahi-compat-howl/text-test.c delete mode 100644 avahi-compat-howl/text.c delete mode 100644 avahi-compat-howl/unsupported.c delete mode 100644 avahi-compat-howl/warn.c delete mode 100644 avahi-compat-howl/warn.h delete mode 100644 avahi-compat-libdns_sd.pc.in delete mode 100644 avahi-compat-libdns_sd/.gitignore delete mode 100644 avahi-compat-libdns_sd/Makefile.am delete mode 100644 avahi-compat-libdns_sd/compat.c delete mode 100644 avahi-compat-libdns_sd/dns_sd.h delete mode 100644 avahi-compat-libdns_sd/funcs.txt delete mode 100644 avahi-compat-libdns_sd/null-test.c delete mode 100644 avahi-compat-libdns_sd/txt-test.c delete mode 100644 avahi-compat-libdns_sd/txt.c delete mode 100644 avahi-compat-libdns_sd/unsupported.c delete mode 100644 avahi-compat-libdns_sd/warn.c delete mode 100644 avahi-compat-libdns_sd/warn.h delete mode 100644 avahi-daemon/.gitignore delete mode 100644 avahi-daemon/Makefile.am delete mode 100644 avahi-daemon/avahi-daemon.conf delete mode 100644 avahi-daemon/avahi-daemon.service.in delete mode 100644 avahi-daemon/avahi-daemon.socket.in delete mode 100644 avahi-daemon/avahi-dbus.conf.in delete mode 100644 avahi-daemon/avahi-service.dtd delete mode 100644 avahi-daemon/caps.c delete mode 100644 avahi-daemon/caps.h delete mode 100644 avahi-daemon/chroot.c delete mode 100644 avahi-daemon/chroot.h delete mode 100644 avahi-daemon/dbus-async-address-resolver.c delete mode 100644 avahi-daemon/dbus-async-host-name-resolver.c delete mode 100644 avahi-daemon/dbus-async-service-resolver.c delete mode 100644 avahi-daemon/dbus-domain-browser.c delete mode 100644 avahi-daemon/dbus-entry-group.c delete mode 100644 avahi-daemon/dbus-internal.h delete mode 100644 avahi-daemon/dbus-protocol.c delete mode 100644 avahi-daemon/dbus-protocol.h delete mode 100644 avahi-daemon/dbus-record-browser.c delete mode 100644 avahi-daemon/dbus-service-browser.c delete mode 100644 avahi-daemon/dbus-service-type-browser.c delete mode 100644 avahi-daemon/dbus-sync-address-resolver.c delete mode 100644 avahi-daemon/dbus-sync-host-name-resolver.c delete mode 100644 avahi-daemon/dbus-sync-service-resolver.c delete mode 100644 avahi-daemon/dbus-util.c delete mode 100644 avahi-daemon/dbus-util.h delete mode 100644 avahi-daemon/example.service delete mode 100644 avahi-daemon/hosts delete mode 100644 avahi-daemon/ini-file-parser-test.c delete mode 100644 avahi-daemon/ini-file-parser.c delete mode 100644 avahi-daemon/ini-file-parser.h delete mode 100644 avahi-daemon/introspect.dtd delete mode 100644 avahi-daemon/introspect.xsl delete mode 100644 avahi-daemon/main.c delete mode 100644 avahi-daemon/main.h delete mode 100644 avahi-daemon/org.freedesktop.Avahi.AddressResolver.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.DomainBrowser.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.EntryGroup.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.HostNameResolver.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.RecordBrowser.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.Server.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.ServiceBrowser.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.ServiceResolver.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.ServiceTypeBrowser.xml delete mode 100644 avahi-daemon/org.freedesktop.Avahi.service delete mode 100644 avahi-daemon/sd-daemon.c delete mode 100644 avahi-daemon/sd-daemon.h delete mode 100644 avahi-daemon/setproctitle.c delete mode 100644 avahi-daemon/setproctitle.h delete mode 100644 avahi-daemon/sftp-ssh.service delete mode 100644 avahi-daemon/simple-protocol.c delete mode 100644 avahi-daemon/simple-protocol.h delete mode 100644 avahi-daemon/ssh.service delete mode 100644 avahi-daemon/static-hosts.c delete mode 100644 avahi-daemon/static-hosts.h delete mode 100644 avahi-daemon/static-services.c delete mode 100644 avahi-daemon/static-services.h delete mode 100644 avahi-discover-standalone/.gitignore delete mode 100644 avahi-discover-standalone/Makefile.am delete mode 100644 avahi-discover-standalone/avahi-discover.ui delete mode 100644 avahi-discover-standalone/main.c delete mode 100644 avahi-dnsconfd/.gitignore delete mode 100644 avahi-dnsconfd/Makefile.am delete mode 100755 avahi-dnsconfd/avahi-dnsconfd.action delete mode 100644 avahi-dnsconfd/avahi-dnsconfd.service.in delete mode 100644 avahi-dnsconfd/main.c delete mode 100644 avahi-glib.pc.in delete mode 100644 avahi-glib/.gitignore delete mode 100644 avahi-glib/Makefile.am delete mode 100644 avahi-glib/glib-malloc.c delete mode 100644 avahi-glib/glib-malloc.h delete mode 100644 avahi-glib/glib-watch-test.c delete mode 100644 avahi-glib/glib-watch.c delete mode 100644 avahi-glib/glib-watch.h delete mode 100644 avahi-gobject.pc.in delete mode 100644 avahi-gobject/.gitignore delete mode 100644 avahi-gobject/AvahiCore-0.6.gir delete mode 100644 avahi-gobject/Makefile.am delete mode 100644 avahi-gobject/ga-client.c delete mode 100644 avahi-gobject/ga-client.h delete mode 100644 avahi-gobject/ga-entry-group.c delete mode 100644 avahi-gobject/ga-entry-group.h delete mode 100644 avahi-gobject/ga-enums.h delete mode 100644 avahi-gobject/ga-error.c delete mode 100644 avahi-gobject/ga-error.h delete mode 100644 avahi-gobject/ga-record-browser.c delete mode 100644 avahi-gobject/ga-record-browser.h delete mode 100644 avahi-gobject/ga-service-browser.c delete mode 100644 avahi-gobject/ga-service-browser.h delete mode 100644 avahi-gobject/ga-service-resolver.c delete mode 100644 avahi-gobject/ga-service-resolver.h delete mode 100644 avahi-python/.gitignore delete mode 100644 avahi-python/Makefile.am delete mode 100755 avahi-python/avahi-bookmarks.in delete mode 100644 avahi-python/avahi-discover/.gitignore delete mode 100644 avahi-python/avahi-discover/Makefile.am delete mode 100755 avahi-python/avahi-discover/__init__.py delete mode 100644 avahi-python/avahi-discover/avahi-discover.desktop.in.in delete mode 100755 avahi-python/avahi-discover/avahi-discover.py delete mode 100644 avahi-python/avahi/.gitignore delete mode 100644 avahi-python/avahi/Makefile.am delete mode 100644 avahi-python/avahi/ServiceTypeDatabase.py.in delete mode 100644 avahi-python/avahi/__init__.py delete mode 100644 avahi-qt/.gitignore delete mode 100644 avahi-qt/Makefile.am delete mode 100644 avahi-qt/qt-watch.cpp delete mode 100644 avahi-qt/qt-watch.h delete mode 100644 avahi-qt3.pc.in delete mode 100644 avahi-qt4.pc.in delete mode 100644 avahi-sharp.pc.in delete mode 100644 avahi-sharp/.gitignore delete mode 100644 avahi-sharp/AddressResolver.cs delete mode 100644 avahi-sharp/AssemblyInfo.cs delete mode 100644 avahi-sharp/AvahiTest.cs delete mode 100644 avahi-sharp/BrowserBase.cs delete mode 100644 avahi-sharp/Client.cs delete mode 100644 avahi-sharp/ClientException.cs delete mode 100644 avahi-sharp/DomainBrowser.cs delete mode 100644 avahi-sharp/EntryGroup.cs delete mode 100644 avahi-sharp/HostNameResolver.cs delete mode 100644 avahi-sharp/Makefile.am delete mode 100644 avahi-sharp/RecordBrowser.cs delete mode 100644 avahi-sharp/ResolverBase.cs delete mode 100644 avahi-sharp/ServiceBrowser.cs delete mode 100644 avahi-sharp/ServiceResolver.cs delete mode 100644 avahi-sharp/ServiceTypeBrowser.cs delete mode 100644 avahi-sharp/Utility.cs delete mode 100644 avahi-sharp/avahi-sharp-docs.source delete mode 100644 avahi-sharp/avahi-sharp.dll.config.in delete mode 100644 avahi-sharp/avahi.snk delete mode 100644 avahi-sharp/en/Avahi.xml delete mode 100644 avahi-sharp/en/Avahi/AddressResolver.xml delete mode 100644 avahi-sharp/en/Avahi/BrowserBase.xml delete mode 100644 avahi-sharp/en/Avahi/Client.xml delete mode 100644 avahi-sharp/en/Avahi/ClientException.xml delete mode 100644 avahi-sharp/en/Avahi/ClientFlags.xml delete mode 100644 avahi-sharp/en/Avahi/ClientState.xml delete mode 100644 avahi-sharp/en/Avahi/ClientStateArgs.xml delete mode 100644 avahi-sharp/en/Avahi/ClientStateHandler.xml delete mode 100644 avahi-sharp/en/Avahi/DomainBrowser.xml delete mode 100644 avahi-sharp/en/Avahi/DomainBrowserType.xml delete mode 100644 avahi-sharp/en/Avahi/DomainInfo.xml delete mode 100644 avahi-sharp/en/Avahi/DomainInfoArgs.xml delete mode 100644 avahi-sharp/en/Avahi/DomainInfoHandler.xml delete mode 100644 avahi-sharp/en/Avahi/EntryGroup.xml delete mode 100644 avahi-sharp/en/Avahi/EntryGroupState.xml delete mode 100644 avahi-sharp/en/Avahi/EntryGroupStateArgs.xml delete mode 100644 avahi-sharp/en/Avahi/EntryGroupStateHandler.xml delete mode 100644 avahi-sharp/en/Avahi/ErrorCode.xml delete mode 100644 avahi-sharp/en/Avahi/ErrorCodeArgs.xml delete mode 100644 avahi-sharp/en/Avahi/ErrorCodeHandler.xml delete mode 100644 avahi-sharp/en/Avahi/HostAddressArgs.xml delete mode 100644 avahi-sharp/en/Avahi/HostAddressHandler.xml delete mode 100644 avahi-sharp/en/Avahi/HostNameResolver.xml delete mode 100644 avahi-sharp/en/Avahi/LookupFlags.xml delete mode 100644 avahi-sharp/en/Avahi/LookupResultFlags.xml delete mode 100644 avahi-sharp/en/Avahi/Protocol.xml delete mode 100644 avahi-sharp/en/Avahi/PublishFlags.xml delete mode 100644 avahi-sharp/en/Avahi/RecordBrowser.xml delete mode 100644 avahi-sharp/en/Avahi/RecordClass.xml delete mode 100644 avahi-sharp/en/Avahi/RecordInfo.xml delete mode 100644 avahi-sharp/en/Avahi/RecordInfoArgs.xml delete mode 100644 avahi-sharp/en/Avahi/RecordInfoHandler.xml delete mode 100644 avahi-sharp/en/Avahi/RecordType.xml delete mode 100644 avahi-sharp/en/Avahi/ResolverBase.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceBrowser.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceInfo.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceInfoArgs.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceInfoHandler.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceResolver.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceTypeBrowser.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceTypeInfo.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceTypeInfoArgs.xml delete mode 100644 avahi-sharp/en/Avahi/ServiceTypeInfoHandler.xml delete mode 100644 avahi-sharp/en/index.xml delete mode 100755 avahi-sharp/gencfg.sh delete mode 100644 avahi-ui-gtk3.pc.in delete mode 100644 avahi-ui-sharp.pc.in delete mode 100644 avahi-ui-sharp/.gitignore delete mode 100644 avahi-ui-sharp/Makefile.am delete mode 100644 avahi-ui-sharp/ServiceDialog.cs delete mode 100644 avahi-ui-sharp/avahi-ui-sharp-docs.source delete mode 100644 avahi-ui-sharp/avahi-ui-sharp.dll.config.in delete mode 100644 avahi-ui-sharp/bssh.cs delete mode 100644 avahi-ui-sharp/en/Avahi.UI.xml delete mode 100644 avahi-ui-sharp/en/Avahi.UI/ServiceDialog.xml delete mode 100644 avahi-ui-sharp/en/index.xml delete mode 100755 avahi-ui-sharp/gencfg.sh delete mode 100644 avahi-ui.pc.in delete mode 100644 avahi-ui/.gitignore delete mode 100644 avahi-ui/Makefile.am delete mode 100644 avahi-ui/avahi-ui.c delete mode 100644 avahi-ui/avahi-ui.h delete mode 100644 avahi-ui/bssh.c delete mode 100644 avahi-ui/bssh.desktop.in.in delete mode 100644 avahi-ui/bvnc.desktop.in.in delete mode 100644 avahi-utils/.gitignore delete mode 100644 avahi-utils/Makefile.am delete mode 100644 avahi-utils/avahi-browse.c delete mode 100644 avahi-utils/avahi-publish.c delete mode 100644 avahi-utils/avahi-resolve.c delete mode 100644 avahi-utils/avahi-set-host-name.c delete mode 100644 avahi-utils/sigint.c delete mode 100644 avahi-utils/sigint.h delete mode 100644 avahi-utils/stdb.c delete mode 100644 avahi-utils/stdb.h delete mode 100644 examples/client-browse-services.c delete mode 100644 examples/client-publish-service.c delete mode 100644 examples/glib-integration.c delete mode 100644 initscript/.gitignore delete mode 100644 initscript/Makefile.am delete mode 100644 initscript/archlinux/Makefile.am delete mode 100644 initscript/archlinux/avahi-daemon.in delete mode 100755 initscript/archlinux/avahi-dnsconfd.in delete mode 100644 initscript/darwin/Makefile.am delete mode 100644 initscript/darwin/org.freedesktop.avahi-daemon.plist.in delete mode 100644 initscript/darwin/org.freedesktop.avahi-dnsconfd.plist.in delete mode 100644 initscript/debian/Makefile.am delete mode 100755 initscript/debian/avahi-daemon.in delete mode 100755 initscript/debian/avahi-dnsconfd.in delete mode 100644 initscript/fedora/.gitignore delete mode 100644 initscript/fedora/Makefile.am delete mode 100644 initscript/fedora/avahi-daemon.in delete mode 100644 initscript/fedora/avahi-dnsconfd.in delete mode 100644 initscript/freebsd/Makefile.am delete mode 100644 initscript/freebsd/avahi-daemon.sh.in delete mode 100644 initscript/freebsd/avahi-dnsconfd.sh.in delete mode 100644 initscript/gentoo/Makefile.am delete mode 100644 initscript/gentoo/avahi-daemon.in delete mode 100644 initscript/gentoo/avahi-dnsconfd.in delete mode 100644 initscript/lfs/Makefile.am delete mode 100644 initscript/lfs/avahi.in delete mode 100644 initscript/mandriva/Makefile.am delete mode 100644 initscript/mandriva/avahi-daemon.in delete mode 100644 initscript/mandriva/avahi-dnsconfd.in delete mode 100644 initscript/slackware/Makefile.am delete mode 100644 initscript/slackware/avahi-daemon.in delete mode 100644 initscript/slackware/avahi-dnsconfd.in delete mode 100644 initscript/suse/Makefile.am delete mode 100644 initscript/suse/avahi-daemon.in delete mode 100644 initscript/suse/avahi-dnsconfd.in delete mode 100644 man/.gitignore delete mode 100644 man/Makefile.am delete mode 100644 man/avahi-autoipd.8.xml.in delete mode 100644 man/avahi-autoipd.action.8.xml.in delete mode 100644 man/avahi-bookmarks.1.xml.in delete mode 100644 man/avahi-browse.1.xml.in delete mode 100644 man/avahi-daemon.8.xml.in delete mode 100644 man/avahi-daemon.conf.5.xml.in delete mode 100644 man/avahi-discover.1.xml.in delete mode 100644 man/avahi-dnsconfd.8.xml.in delete mode 100644 man/avahi-dnsconfd.action.8.xml.in delete mode 100644 man/avahi-publish.1.xml.in delete mode 100644 man/avahi-resolve.1.xml.in delete mode 100644 man/avahi-set-host-name.1.xml.in delete mode 100644 man/avahi.hosts.5.xml.in delete mode 100644 man/avahi.service.5.xml.in delete mode 100644 man/bssh.1.xml.in delete mode 100644 man/xmltoman.css delete mode 100644 man/xmltoman.dtd delete mode 100644 man/xmltoman.xsl delete mode 100644 service-type-database/.gitignore delete mode 100644 service-type-database/Makefile.am delete mode 100755 service-type-database/build-db.in delete mode 100644 service-type-database/service-types delete mode 100644 tests/.gitignore delete mode 100644 tests/Makefile.am delete mode 100755 tests/c-plus-plus-test-gen.py delete mode 100644 tests/c-plus-plus-test.cc delete mode 100755 tests/fuzz-mdns.py diff --git a/Makefile.am b/Makefile.am index 8234d69..c3cc823 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,17 +38,6 @@ EXTRA_DIST = \ docs/server-states.dia \ docs/avahi-poll.dia \ avahi-core.pc.in \ - avahi-client.pc.in \ - avahi-glib.pc.in \ - avahi-gobject.pc.in \ - avahi-qt3.pc.in \ - avahi-qt4.pc.in \ - avahi-sharp.pc.in \ - avahi-ui-sharp.pc.in \ - avahi-compat-libdns_sd.pc.in \ - avahi-compat-howl.pc.in \ - avahi-ui.pc.in \ - avahi-ui-gtk3.pc.in \ doxygen_to_devhelp.xsl \ common/introspection.m4 @@ -56,26 +45,7 @@ SUBDIRS = \ common \ avahi-common \ avahi-core \ - avahi-qt \ - avahi-client \ - avahi-glib \ - avahi-gobject \ - avahi-discover-standalone \ - avahi-daemon \ - avahi-sharp \ - initscript \ - avahi-dnsconfd \ - avahi-utils \ - avahi-python \ examples \ - man \ - tests \ - service-type-database \ - avahi-compat-libdns_sd \ - avahi-compat-howl \ - avahi-autoipd \ - avahi-ui \ - avahi-ui-sharp \ po DX_INPUT = \ @@ -93,49 +63,6 @@ DX_INPUT = \ DX_EXAMPLE_PATH = $(srcdir)/examples DX_EXAMPLE_PATTERNS = *.c -if HAVE_QT3 -DX_INPUT += \ - $(srcdir)/avahi-qt/qt-watch.h -else -if HAVE_QT4 -DX_INPUT += \ - $(srcdir)/avahi-qt/qt-watch.h -endif -endif - -if HAVE_GLIB -DX_INPUT += \ - $(srcdir)/avahi-glib/glib-watch.h \ - $(srcdir)/avahi-glib/glib-malloc.h - -if HAVE_GOBJECT -if HAVE_DBUS -DX_INPUT += \ - $(srcdir)/avahi-gobject/ga-client.h \ - $(srcdir)/avahi-gobject/ga-entry-group.h \ - $(srcdir)/avahi-gobject/ga-enums.h \ - $(srcdir)/avahi-gobject/ga-error.h \ - $(srcdir)/avahi-gobject/ga-record-browser.h \ - $(srcdir)/avahi-gobject/ga-service-browser.h \ - $(srcdir)/avahi-gobject/ga-service-resolver.h -endif -endif -endif - -if HAVE_DBUS -DX_INPUT += \ - $(srcdir)/avahi-client/client.h \ - $(srcdir)/avahi-client/lookup.h \ - $(srcdir)/avahi-client/publish.h -endif - -if HAVE_DBUS -if HAVE_GTK -DX_INPUT += \ - $(srcdir)/avahi-ui/avahi-ui.h -endif -endif - if ENABLE_CORE_DOCS DX_INPUT += \ $(srcdir)/avahi-core/core.h \ @@ -145,11 +72,6 @@ DX_INPUT += \ $(srcdir)/avahi-core/log.h endif -if HAVE_GTK -DX_INPUT += \ - $(srcdir)/avahi-ui/avahi-ui.h -endif - pkgconfigdir = $(libdir)/pkgconfig %.pc: %.pc.in @@ -160,62 +82,6 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = avahi-core.pc CLEANFILES = avahi-core.pc - -if HAVE_DBUS -pkgconfig_DATA += avahi-client.pc -CLEANFILES += avahi-client.pc - -if ENABLE_COMPAT_HOWL -pkgconfig_DATA += avahi-compat-howl.pc -CLEANFILES += avahi-compat-howl.pc -endif - -if ENABLE_COMPAT_LIBDNS_SD -pkgconfig_DATA += avahi-compat-libdns_sd.pc -CLEANFILES += avahi-compat-libdns_sd.pc -endif - -if HAVE_MONO -pkgconfig_DATA += avahi-sharp.pc avahi-ui-sharp.pc -CLEANFILES += avahi-sharp.pc avahi-ui-sharp.pc -endif - -endif - -if HAVE_GLIB -pkgconfig_DATA += avahi-glib.pc -CLEANFILES += avahi-glib.pc - -if HAVE_GOBJECT -pkgconfig_DATA += avahi-gobject.pc -CLEANFILES += avahi-gobject.pc -endif -endif - -if HAVE_GTK -if HAVE_DBUS -pkgconfig_DATA += avahi-ui.pc -CLEANFILES += avahi-ui.pc -endif -endif - -if HAVE_GTK3 -if HAVE_DBUS -pkgconfig_DATA += avahi-ui-gtk3.pc -CLEANFILES += avahi-ui-gtk3.pc -endif -endif - -if HAVE_QT3 -pkgconfig_DATA += avahi-qt3.pc -CLEANFILES += avahi-qt3.pc -endif - -if HAVE_QT4 -pkgconfig_DATA += avahi-qt4.pc -CLEANFILES += avahi-qt4.pc -endif - CLEANFILES += avahi.devhelp avahi.devhelp: doxygen-run @@ -228,16 +94,5 @@ DISTCHECK_CONFIGURE_FLAGS = \ --enable-introspection \ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) -homepage: - $(MAKE) -C man - scp avahi-daemon/*.xml avahi-daemon/introspect.dtd avahi-daemon/introspect.xsl\ - man/*.xml man/xmltoman.dtd man/xmltoman.xsl \ - tango:www/avahi.org/tree/download/ - scp avahi-$(PACKAGE_VERSION).tar.gz tango:www/avahi.org/tree/download/ - rm -rf doxygen - $(MAKE) doxygen-run - ssh tango rm -rf www/avahi.org/tree/download/doxygen - scp -r doxygen/html tango:www/avahi.org/tree/download/doxygen - DISTCLEANFILES = \ po/.intltool-merge-cache diff --git a/autogen.sh b/autogen.sh index 2c68a6c..d12ba82 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # This file is part of avahi. # @@ -42,13 +42,8 @@ run_versioned() { set -ex -if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then - cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \ - chmod +x .git/hooks/pre-commit && \ - echo "Activated pre-commit hook." -fi - if [ "x$1" = "xam" ] ; then + # re-run only automake (after changes to Makefile.am) run_versioned automake "$AM_VERSION" -a -c --foreign ./config.status else @@ -61,10 +56,11 @@ else test -f Makefile.am~ && mv Makefile.am~ Makefile.am test -f configure.ac~ && mv configure.ac~ configure.ac - test "x$LIBTOOLIZE" = "x" && LIBTOOLIZE=libtoolize - intltoolize --copy --force --automake + + test "x$LIBTOOLIZE" = "x" && LIBTOOLIZE=libtoolize "$LIBTOOLIZE" -c --force + run_versioned aclocal "$AM_VERSION" -I common run_versioned autoconf "$AC_VERSION" -Wall run_versioned autoheader "$AC_VERSION" diff --git a/avahi-autoipd/.gitignore b/avahi-autoipd/.gitignore deleted file mode 100644 index b8d515c..0000000 --- a/avahi-autoipd/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs -avahi-autoipd -avahi-autoipd.action diff --git a/avahi-autoipd/Makefile.am b/avahi-autoipd/Makefile.am deleted file mode 100644 index 56f7a35..0000000 --- a/avahi-autoipd/Makefile.am +++ /dev/null @@ -1,94 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -if ENABLE_AUTOIPD -if HAVE_LIBDAEMON - -pkgsysconfdir=$(sysconfdir)/avahi - -AM_CFLAGS= \ - -I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' \ - -DAVAHI_RUNTIME_DIR=\"$(avahi_runtime_dir)/\" \ - -DAVAHI_IPCONF_SCRIPT=\"$(pkgsysconfdir)/avahi-autoipd.action\" \ - -DAVAHI_IPDATA_DIR=\"$(localstatedir)/lib/avahi-autoipd\" - -sbin_PROGRAMS = avahi-autoipd - -avahi_autoipd_SOURCES = \ - main.c main.h \ - ../avahi-daemon/setproctitle.c ../avahi-daemon/setproctitle.h \ - iface.h \ - ../avahi-common/malloc.h ../avahi-common/malloc.c \ - ../avahi-common/timeval.h ../avahi-common/timeval.c - -avahi_autoipd_CFLAGS = $(AM_CFLAGS) $(LIBDAEMON_CFLAGS) -avahi_autoipd_LDADD = $(AM_LDADD) $(LIBDAEMON_LIBS) - -if TARGET_FREEBSD -avahi_autoipd_SOURCES += iface-bsd.c -avahi_autoipd_LDADD += -lpcap -else -avahi_autoipd_SOURCES += iface-linux.c -endif - -nodist_pkgsysconf_SCRIPTS = avahi-autoipd.action - -if TARGET_FREEBSD -avahi-autoipd.action: avahi-autoipd.action.bsd - $(AM_V_GEN)cp $< $@ -else -avahi-autoipd.action: avahi-autoipd.action.linux - $(AM_V_GEN)cp $< $@ -endif - -if TARGET_DEBIAN - -noinst_SCRIPTS = dhclient-enter-hook dhclient-exit-hook - -dhclient-enter-hook: dhclient-enter-hook.in - $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ && \ - chmod +x $@ - -dhclient-exit-hook: dhclient-exit-hook.in - $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ && \ - chmod +x $@ - -BUILD = dhclient-exit-hook dhclient-enter-hook - -dhcliententerdir = $(sysconfdir)/dhcp/dhclient-enter-hooks.d -dhclientexitdir = $(sysconfdir)/dhcp/dhclient-exit-hooks.d - -install-exec-hook: dhclient-exit-hook dhclient-enter-hook - $(MKDIR_P) $(DESTDIR)$(dhcliententerdir) $(DESTDIR)$(dhclientexitdir) - $(INSTALL) dhclient-enter-hook $(DESTDIR)$(dhcliententerdir)/avahi-autoipd - $(INSTALL) dhclient-exit-hook $(DESTDIR)$(dhclientexitdir)/avahi-autoipd - -uninstall-hook: - rm -f $(DESTDIR)$(dhcliententerdir)/avahi-autoipd $(DESTDIR)$(dhclientexitdir)/avahi-autoipd - -endif - - -endif -endif - -EXTRA_DIST = dhclient-enter-hook.in dhclient-exit-hook.in avahi-autoipd.action.linux avahi-autoipd.action.bsd - -CLEANFILES = dhclient-enter-hook dhclient-exit-hook avahi-autoipd.action diff --git a/avahi-autoipd/avahi-autoipd.action.bsd b/avahi-autoipd/avahi-autoipd.action.bsd deleted file mode 100755 index 06084fb..0000000 --- a/avahi-autoipd/avahi-autoipd.action.bsd +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -set -e - -# Command line arguments: -# $1 event that happened: -# BIND: Successfully claimed address -# CONFLICT: An IP address conflict happened -# UNBIND: The IP address is no longer needed -# STOP: The daemon is terminating -# $2 interface name -# $3 IP adddress - -# We have the BSD ifconfig tool - -case "$1" in -BIND) - ifconfig "$2" "$3"/16 - ;; - -CONFLICT|STOP|UNBIND) - ifconfig "$2" "$3"/16 delete - ;; - -*) - echo "Unknown event $1" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/avahi-autoipd/avahi-autoipd.action.linux b/avahi-autoipd/avahi-autoipd.action.linux deleted file mode 100755 index c2db994..0000000 --- a/avahi-autoipd/avahi-autoipd.action.linux +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -set -e - -# Command line arguments: -# $1 event that happened: -# BIND: Successfully claimed address -# CONFLICT: An IP address conflict happened -# UNBIND: The IP address is no longer needed -# STOP: The daemon is terminating -# $2 interface name -# $3 IP adddress - -PATH="$PATH:/usr/bin:/usr/sbin:/bin:/sbin" - -# Use a different metric for each interface, so that we can set -# identical routes to multiple interfaces. - -METRIC=$((1000 + `cat "/sys/class/net/$2/ifindex" 2>/dev/null || echo 0`)) - -if [ -x /bin/ip -o -x /sbin/ip ] ; then - - # We have the Linux ip tool from the iproute package - - case "$1" in - BIND) - ip addr add "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2" - ip route add default dev "$2" metric "$METRIC" scope link ||: - ;; - - CONFLICT|UNBIND|STOP) - ip route del default dev "$2" metric "$METRIC" scope link ||: - ip addr del "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2" - ;; - - *) - echo "Unknown event $1" >&2 - exit 1 - ;; - esac - -elif [ -x /bin/ifconfig -o -x /sbin/ifconfig ] ; then - - # We have the old ifconfig tool - - case "$1" in - BIND) - ifconfig "$2:avahi" inet "$3" netmask 255.255.0.0 broadcast 169.254.255.255 up - route add default dev "$2:avahi" metric "$METRIC" ||: - ;; - - CONFLICT|STOP|UNBIND) - route del default dev "$2:avahi" metric "$METRIC" ||: - ifconfig "$2:avahi" down - ;; - - *) - echo "Unknown event $1" >&2 - exit 1 - ;; - esac - -else - - echo "No network configuration tool found." >&2 - exit 1 - -fi - -exit 0 diff --git a/avahi-autoipd/dhclient-enter-hook.in b/avahi-autoipd/dhclient-enter-hook.in deleted file mode 100755 index a746856..0000000 --- a/avahi-autoipd/dhclient-enter-hook.in +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -case "$reason" in - MEDIUM|ARPCHECK|ARPSEND|NBI) - ;; - - PREINIT|BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE) - @sbindir@/avahi-autoipd -k $interface 2> /dev/null - ;; - - EXPIRE|FAIL|TIMEOUT) - # Starting avahi-autoipd is left for the exit hook - ;; -esac diff --git a/avahi-autoipd/dhclient-exit-hook.in b/avahi-autoipd/dhclient-exit-hook.in deleted file mode 100755 index 379cb46..0000000 --- a/avahi-autoipd/dhclient-exit-hook.in +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -case "$reason" in - MEDIUM|ARPCHECK|ARPSEND|NBI) - ;; - - PREINIT|BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE) - # Stopping avahi-autoipd is left for the enter hook - ;; - - EXPIRE|FAIL|TIMEOUT) - @sbindir@/avahi-autoipd -wD $interface 2> /dev/null - ;; -esac diff --git a/avahi-autoipd/iface-bsd.c b/avahi-autoipd/iface-bsd.c deleted file mode 100644 index 6a1085c..0000000 --- a/avahi-autoipd/iface-bsd.c +++ /dev/null @@ -1,440 +0,0 @@ -/* rcs tags go here */ -/* Original author: Bruce M. Simpson */ - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include "iface.h" - -#ifndef IN_LINKLOCAL -#define IN_LINKLOCAL(i) (((u_int32_t)(i) & (0xffff0000)) == (0xa9fe0000)) -#endif - -#ifndef elementsof -#define elementsof(array) (sizeof(array)/sizeof(array[0])) -#endif - -#ifndef so_set_nonblock -#define so_set_nonblock(s, val) \ - do { \ - int __flags; \ - __flags = fcntl((s), F_GETFL); \ - if (__flags == -1) \ - break; \ - if (val != 0) \ - __flags |= O_NONBLOCK; \ - else \ - __flags &= ~O_NONBLOCK; \ - (void)fcntl((s), F_SETFL, __flags); \ - } while (0) -#endif - -#define MAX_RTMSG_SIZE 2048 - -struct rtm_dispinfo { - u_char *di_buf; - ssize_t di_buflen; - ssize_t di_len; -}; - -union rtmunion { - struct rt_msghdr rtm; - struct if_msghdr ifm; - struct ifa_msghdr ifam; - struct ifma_msghdr ifmam; - struct if_announcemsghdr ifan; -}; -typedef union rtmunion rtmunion_t; - -struct Address; -typedef struct Address Address; - -struct Address { - in_addr_t address; - AVAHI_LLIST_FIELDS(Address, addresses); -}; - -static int rtm_dispatch(void); -static int rtm_dispatch_newdeladdr(struct rtm_dispinfo *di); -static int rtm_dispatch_ifannounce(struct rtm_dispinfo *di); -static struct sockaddr *next_sa(struct sockaddr *sa); - -static int fd = -1; -static int ifindex = -1; -static AVAHI_LLIST_HEAD(Address, addresses) = NULL; - -int -iface_init(int idx) -{ - - fd = socket(PF_ROUTE, SOCK_RAW, AF_INET); - if (fd == -1) { - daemon_log(LOG_ERR, "socket(PF_ROUTE): %s", strerror(errno)); - return (-1); - } - - so_set_nonblock(fd, 1); - - ifindex = idx; - - return (fd); -} - -int -iface_get_initial_state(State *state) -{ - int mib[6]; - char *buf; - struct if_msghdr *ifm; - struct ifa_msghdr *ifam; - char *lim; - char *next; - struct sockaddr *sa; - size_t len; - int naddrs; - - assert(state != NULL); - assert(fd != -1); - - naddrs = 0; - - mib[0] = CTL_NET; - mib[1] = PF_ROUTE; - mib[2] = 0; - mib[3] = 0; - mib[4] = NET_RT_IFLIST; - mib[5] = ifindex; - - if (sysctl(mib, elementsof(mib), NULL, &len, NULL, 0) != 0) { - daemon_log(LOG_ERR, "sysctl(NET_RT_IFLIST): %s", - strerror(errno)); - return (-1); - } - - buf = malloc(len); - if (buf == NULL) { - daemon_log(LOG_ERR, "malloc(%d): %s", len, strerror(errno)); - return (-1); - } - - if (sysctl(mib, elementsof(mib), buf, &len, NULL, 0) != 0) { - daemon_log(LOG_ERR, "sysctl(NET_RT_IFLIST): %s", - strerror(errno)); - free(buf); - return (-1); - } - - lim = buf + len; - for (next = buf; next < lim; next += ifm->ifm_msglen) { - ifm = (struct if_msghdr *)next; - if (ifm->ifm_type == RTM_NEWADDR) { - ifam = (struct ifa_msghdr *)next; - sa = (struct sockaddr *)(ifam + 1); - if (sa->sa_family != AF_INET) - continue; - ++naddrs; - } - } - free(buf); - - *state = (naddrs > 0) ? STATE_SLEEPING : STATE_START; - - return (0); -} - -int -iface_process(Event *event) -{ - int routable; - - assert(fd != -1); - - routable = !!addresses; - - if (rtm_dispatch() == -1) - return (-1); - - if (routable && !addresses) - *event = EVENT_ROUTABLE_ADDR_UNCONFIGURED; - else if (!routable && addresses) - *event = EVENT_ROUTABLE_ADDR_CONFIGURED; - - return (0); -} - -void -iface_done(void) -{ - Address *a; - - if (fd != -1) { - close(fd); - fd = -1; - } - - while ((a = addresses) != NULL) { - AVAHI_LLIST_REMOVE(Address, addresses, addresses, a); - avahi_free(a); - } -} - -/* - * Dispatch kernel routing socket messages. - */ -static int -rtm_dispatch(void) -{ - struct msghdr mh; - struct iovec iov[1]; - struct rt_msghdr *rtm; - struct rtm_dispinfo *di; - ssize_t len; - int retval; - - di = malloc(sizeof(*di)); - if (di == NULL) { - daemon_log(LOG_ERR, "malloc(%d): %s", sizeof(*di), - strerror(errno)); - return (-1); - } - di->di_buflen = MAX_RTMSG_SIZE; - di->di_buf = calloc(MAX_RTMSG_SIZE, 1); - if (di->di_buf == NULL) { - free(di); - daemon_log(LOG_ERR, "calloc(%d): %s", MAX_RTMSG_SIZE, - strerror(errno)); - return (-1); - } - - memset(&mh, 0, sizeof(mh)); - iov[0].iov_base = di->di_buf; - iov[0].iov_len = di->di_buflen; - mh.msg_iov = iov; - mh.msg_iovlen = 1; - - retval = 0; - for (;;) { - len = recvmsg(fd, &mh, MSG_DONTWAIT); - if (len == -1) { - if (errno == EWOULDBLOCK) - break; - else { - daemon_log(LOG_ERR, "recvmsg(): %s", - strerror(errno)); - retval = -1; - break; - } - } - - rtm = (void *)di->di_buf; - if (rtm->rtm_version != RTM_VERSION) { - daemon_log(LOG_ERR, - "unknown routing socket message (version %d)\n", - rtm->rtm_version); - /* this is non-fatal; just ignore it for now. */ - continue; - } - - switch (rtm->rtm_type) { - case RTM_NEWADDR: - case RTM_DELADDR: - retval = rtm_dispatch_newdeladdr(di); - break; - case RTM_IFANNOUNCE: - retval = rtm_dispatch_ifannounce(di); - break; - default: - daemon_log(LOG_DEBUG, "%s: rtm_type %d ignored", __func__, rtm->rtm_type); - break; - } - - /* - * If we got an error; assume our position on the call - * stack is enclosed by a level-triggered event loop, - * and signal the error condition. - */ - if (retval != 0) - break; - } - free(di->di_buf); - free(di); - - return (retval); -} - -/* handle link coming or going away */ -static int -rtm_dispatch_ifannounce(struct rtm_dispinfo *di) -{ - rtmunion_t *rtm = (void *)di->di_buf; - - assert(rtm->rtm.rtm_type == RTM_IFANNOUNCE); - - daemon_log(LOG_DEBUG, "%s: IFANNOUNCE for ifindex %d", - __func__, rtm->ifan.ifan_index); - - switch (rtm->ifan.ifan_what) { - case IFAN_ARRIVAL: - if (rtm->ifan.ifan_index == ifindex) { - daemon_log(LOG_ERR, -"RTM_IFANNOUNCE IFAN_ARRIVAL, for ifindex %d, which we already manage.", - ifindex); - return (-1); - } - break; - case IFAN_DEPARTURE: - if (rtm->ifan.ifan_index == ifindex) { - daemon_log(LOG_ERR, "Interface vanished."); - return (-1); - } - break; - default: - /* ignore */ - break; - } - - return (0); -} - -static struct sockaddr * -next_sa(struct sockaddr *sa) -{ - void *p; - size_t sa_size; - -#ifdef SA_SIZE - sa_size = SA_SIZE(sa); -#else - /* This is not foolproof, kernel may round. */ - sa_size = sa->sa_len; - if (sa_size < sizeof(u_long)) - sa_size = sizeof(u_long); -#endif - - p = ((char *)sa) + sa_size; - - return (struct sockaddr *)p; -} - -/* handle address coming or going away */ -static int -rtm_dispatch_newdeladdr(struct rtm_dispinfo *di) -{ - Address *ap; - struct ifa_msghdr *ifam; - struct sockaddr *sa; - struct sockaddr_in *sin; - int link_local; - -/* macro to skip to next RTA; has side-effects */ -#define SKIPRTA(ifamsgp, rta, sa) \ - do { \ - if ((ifamsgp)->ifam_addrs & (rta)) \ - (sa) = next_sa((sa)); \ - } while (0) - - ifam = &((rtmunion_t *)di->di_buf)->ifam; - - assert(ifam->ifam_type == RTM_NEWADDR || - ifam->ifam_type == RTM_DELADDR); - - daemon_log(LOG_DEBUG, "%s: %s for iface %d (%s)", __func__, - ifam->ifam_type == RTM_NEWADDR ? "NEWADDR" : "DELADDR", - ifam->ifam_index, (ifam->ifam_index == ifindex) ? "ours" : "not ours"); - - if (ifam->ifam_index != ifindex) - return (0); - - if (!(ifam->ifam_addrs & RTA_IFA)) { - daemon_log(LOG_ERR, "ifa msg has no RTA_IFA."); - return (0); - } - - /* skip over rtmsg padding correctly */ - sa = (struct sockaddr *)(ifam + 1); - SKIPRTA(ifam, RTA_DST, sa); - SKIPRTA(ifam, RTA_GATEWAY, sa); - SKIPRTA(ifam, RTA_NETMASK, sa); - SKIPRTA(ifam, RTA_GENMASK, sa); - SKIPRTA(ifam, RTA_IFP, sa); - - /* - * sa now points to RTA_IFA sockaddr; we are only interested - * in updates for routable addresses. - */ - if (sa->sa_family != AF_INET) { - daemon_log(LOG_DEBUG, "%s: RTA_IFA family not AF_INET (=%d)", __func__, sa->sa_family); - return (0); - } - - sin = (struct sockaddr_in *)sa; - link_local = IN_LINKLOCAL(ntohl(sin->sin_addr.s_addr)); - - daemon_log(LOG_DEBUG, "%s: %s for %s (%s)", __func__, - ifam->ifam_type == RTM_NEWADDR ? "NEWADDR" : "DELADDR", - inet_ntoa(sin->sin_addr), link_local ? "link local" : "routable"); - - if (link_local) - return (0); - - for (ap = addresses; ap; ap = ap->addresses_next) { - if (ap->address == sin->sin_addr.s_addr) - break; - } - if (ifam->ifam_type == RTM_DELADDR && ap != NULL) { - AVAHI_LLIST_REMOVE(Address, addresses, addresses, ap); - avahi_free(ap); - } - if (ifam->ifam_type == RTM_NEWADDR && ap == NULL) { - ap = avahi_new(Address, 1); - ap->address = sin->sin_addr.s_addr; - AVAHI_LLIST_PREPEND(Address, addresses, addresses, ap); - } - - return (0); -#undef SKIPRTA -} diff --git a/avahi-autoipd/iface-linux.c b/avahi-autoipd/iface-linux.c deleted file mode 100644 index 83e9e41..0000000 --- a/avahi-autoipd/iface-linux.c +++ /dev/null @@ -1,332 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#ifndef IFLA_RTA -#include -#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) -#endif - -#ifndef IFA_RTA -#include -#define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) -#endif - -#include "iface.h" - -static int fd = -1; -static int ifindex = -1; - -typedef struct Address Address; - -struct Address { - uint32_t address; - AVAHI_LLIST_FIELDS(Address, addresses); -}; - -AVAHI_LLIST_HEAD(Address, addresses) = NULL; - -int iface_init(int i) { - struct sockaddr_nl addr; - int on = 1; - - if ((fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) { - daemon_log(LOG_ERR, "socket(PF_NETLINK): %s", strerror(errno)); - goto fail; - } - - memset(&addr, 0, sizeof(addr)); - addr.nl_family = AF_NETLINK; - addr.nl_groups = RTMGRP_LINK|RTMGRP_IPV4_IFADDR; - addr.nl_pid = getpid(); - - if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - daemon_log(LOG_ERR, "bind(): %s", strerror(errno)); - goto fail; - } - - if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) { - daemon_log(LOG_ERR, "SO_PASSCRED: %s", strerror(errno)); - goto fail; - } - - ifindex = i; - - return fd; - -fail: - if (fd >= 0) { - close(fd); - fd = -1; - } - - return -1; -} - -static int process_nlmsg(struct nlmsghdr *n) { - assert(n); - - if (n->nlmsg_type == RTM_NEWLINK || n->nlmsg_type == RTM_DELLINK) { - /* A link appeared or was removed */ - - struct ifinfomsg *ifi; - ifi = NLMSG_DATA(n); - - if (ifi->ifi_family != AF_UNSPEC || (int) ifi->ifi_index != ifindex) - return 0; - - if (n->nlmsg_type == RTM_DELLINK) { - daemon_log(LOG_ERR, "Interface vanished."); - return -1; - } - - assert(n->nlmsg_type == RTM_NEWLINK); - - if ((ifi->ifi_flags & IFF_LOOPBACK) || - (ifi->ifi_flags & IFF_NOARP) || - ifi->ifi_type != ARPHRD_ETHER) { - daemon_log(LOG_ERR, "Interface not suitable."); - return -1; - } - - } else if (n->nlmsg_type == RTM_NEWADDR || n->nlmsg_type == RTM_DELADDR) { - - /* An address was added or removed */ - - struct rtattr *a = NULL; - struct ifaddrmsg *ifa; - int l; - uint32_t address = 0; - Address *i; - - ifa = NLMSG_DATA(n); - - if (ifa->ifa_family != AF_INET || (int) ifa->ifa_index != ifindex) - return 0; - - l = NLMSG_PAYLOAD(n, sizeof(*ifa)); - a = IFLA_RTA(ifa); - - while(RTA_OK(a, l)) { - - switch(a->rta_type) { - case IFA_LOCAL: - case IFA_ADDRESS: - assert(RTA_PAYLOAD(a) == 4); - memcpy(&address, RTA_DATA(a), sizeof(uint32_t)); - break; - } - - a = RTA_NEXT(a, l); - } - - if (!address || is_ll_address(address)) - return 0; - - for (i = addresses; i; i = i->addresses_next) - if (i->address == address) - break; - - if (n->nlmsg_type == RTM_DELADDR && i) { - AVAHI_LLIST_REMOVE(Address, addresses, addresses, i); - avahi_free(i); - } if (n->nlmsg_type == RTM_NEWADDR && !i) { - i = avahi_new(Address, 1); - i->address = address; - AVAHI_LLIST_PREPEND(Address, addresses, addresses, i); - } - } - - return 0; -} - -static int process_response(int wait_for_done, unsigned seq) { - assert(fd >= 0); - - do { - size_t bytes; - ssize_t r; - char replybuf[8*1024]; - char cred_msg[CMSG_SPACE(sizeof(struct ucred))]; - struct msghdr msghdr; - struct cmsghdr *cmsghdr; - struct ucred *ucred; - struct iovec iov; - struct nlmsghdr *p = (struct nlmsghdr *) replybuf; - - memset(&iov, 0, sizeof(iov)); - iov.iov_base = replybuf; - iov.iov_len = sizeof(replybuf); - - memset(&msghdr, 0, sizeof(msghdr)); - msghdr.msg_name = (void*) NULL; - msghdr.msg_namelen = 0; - msghdr.msg_iov = &iov; - msghdr.msg_iovlen = 1; - msghdr.msg_control = cred_msg; - msghdr.msg_controllen = sizeof(cred_msg); - msghdr.msg_flags = 0; - - if ((r = recvmsg(fd, &msghdr, 0)) < 0) { - daemon_log(LOG_ERR, "recvmsg() failed: %s", strerror(errno)); - return -1; - } - - if (!(cmsghdr = CMSG_FIRSTHDR(&msghdr)) || cmsghdr->cmsg_type != SCM_CREDENTIALS) { - daemon_log(LOG_WARNING, "No sender credentials received, ignoring data."); - return -1; - } - - ucred = (struct ucred*) CMSG_DATA(cmsghdr); - - if (ucred->uid != 0) - return -1; - - bytes = (size_t) r; - - for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) { - - if (!NLMSG_OK(p, bytes) || bytes < sizeof(struct nlmsghdr) || bytes < p->nlmsg_len) { - daemon_log(LOG_ERR, "Netlink packet too small."); - return -1; - } - - if (p->nlmsg_type == NLMSG_DONE && wait_for_done && p->nlmsg_seq == seq && (pid_t) p->nlmsg_pid == getpid()) - return 0; - - if (p->nlmsg_type == NLMSG_ERROR) { - struct nlmsgerr *e = (struct nlmsgerr *) NLMSG_DATA (p); - - if (e->error) { - daemon_log(LOG_ERR, "Netlink error: %s", strerror(-e->error)); - return -1; - } - } - - if (process_nlmsg(p) < 0) - return -1; - } - } while (wait_for_done); - - return 0; -} - -int iface_get_initial_state(State *state) { - struct nlmsghdr *n; - struct ifinfomsg *ifi; - struct ifaddrmsg *ifa; - uint8_t req[1024]; - int seq = 0; - - assert(fd >= 0); - assert(state); - - memset(&req, 0, sizeof(req)); - n = (struct nlmsghdr*) req; - n->nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)); - n->nlmsg_type = RTM_GETLINK; - n->nlmsg_seq = seq; - n->nlmsg_flags = NLM_F_REQUEST|NLM_F_DUMP; - n->nlmsg_pid = 0; - - ifi = NLMSG_DATA(n); - ifi->ifi_family = AF_UNSPEC; - ifi->ifi_change = -1; - - if (send(fd, n, n->nlmsg_len, 0) < 0) { - daemon_log(LOG_ERR, "send(): %s", strerror(errno)); - return -1; - } - - if (process_response(1, 0) < 0) - return -1; - - n->nlmsg_type = RTM_GETADDR; - n->nlmsg_len = NLMSG_LENGTH(sizeof(*ifa)); - n->nlmsg_seq = ++seq; - - ifa = NLMSG_DATA(n); - ifa->ifa_family = AF_INET; - ifa->ifa_index = ifindex; - - if (send(fd, n, n->nlmsg_len, 0) < 0) { - daemon_log(LOG_ERR, "send(): %s", strerror(errno)); - return -1; - } - - if (process_response(1, seq) < 0) - return -1; - - *state = addresses ? STATE_SLEEPING : STATE_START; - - return 0; -} - -int iface_process(Event *event) { - int b; - assert(fd >= 0); - - b = !!addresses; - - if (process_response(0, 0) < 0) - return -1; - - if (b && !addresses) - *event = EVENT_ROUTABLE_ADDR_UNCONFIGURED; - else if (!b && addresses) - *event = EVENT_ROUTABLE_ADDR_CONFIGURED; - - return 0; -} - -void iface_done(void) { - Address *a; - - if (fd >= 0) { - close(fd); - fd = -1; - } - - while ((a = addresses)) { - AVAHI_LLIST_REMOVE(Address, addresses, addresses, a); - avahi_free(a); - } -} - - diff --git a/avahi-autoipd/iface.h b/avahi-autoipd/iface.h deleted file mode 100644 index 95c97fd..0000000 --- a/avahi-autoipd/iface.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef fooavahiifacehfoo -#define fooavahiifacehfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include "main.h" - -/* Subscribe to network configuration changes. The only events we are - * interested in are when routable addresses are removed/added to the - * monitored interface and when our monitored interface disappears. */ - - -/* Return a valid fd that we listen on for events */ -int iface_init(int ifindex); - -/* Process events */ -int iface_process(Event *event); -void iface_done(void); - -/* Deduce the initial state of our state machine. If a routable - * address is configured for the interface, *state should be set to - * STATE_SLEEPING, otherwise STATE_START */ - -int iface_get_initial_state(State *state); - -#endif diff --git a/avahi-autoipd/main.c b/avahi-autoipd/main.c deleted file mode 100644 index a1bddb2..0000000 --- a/avahi-autoipd/main.c +++ /dev/null @@ -1,1714 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#ifdef __FreeBSD__ -#include -#endif - -#ifdef __linux__ -#include -#endif -#include -#include -#ifdef __FreeBSD__ -#include -#include -#endif -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifndef __linux__ -#include - -/* Old versions of PCAP defined it as D_IN */ -#ifndef PCAP_D_IN -#define PCAP_D_IN D_IN -#endif - -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "main.h" -#include "iface.h" - -/* An implementation of RFC 3927 */ - -/* Constants from the RFC */ -#define PROBE_WAIT 1 -#define PROBE_NUM 3 -#define PROBE_MIN 1 -#define PROBE_MAX 2 -#define ANNOUNCE_WAIT 2 -#define ANNOUNCE_NUM 2 -#define ANNOUNCE_INTERVAL 2 -#define MAX_CONFLICTS 10 -#define RATE_LIMIT_INTERVAL 60 -#define DEFEND_INTERVAL 10 - -#define IPV4LL_NETWORK 0xA9FE0000L -#define IPV4LL_NETMASK 0xFFFF0000L -#define IPV4LL_HOSTMASK 0x0000FFFFL -#define IPV4LL_BROADCAST 0xA9FEFFFFL - -#define ETHER_ADDRLEN 6 -#define ETHER_HDR_SIZE (2+2*ETHER_ADDRLEN) -#define ARP_PACKET_SIZE (8+4+4+2*ETHER_ADDRLEN) - -typedef enum ArpOperation { - ARP_REQUEST = 1, - ARP_RESPONSE = 2 -} ArpOperation; - -typedef struct ArpPacketInfo { - ArpOperation operation; - - uint32_t sender_ip_address, target_ip_address; - uint8_t sender_hw_address[ETHER_ADDRLEN], target_hw_address[ETHER_ADDRLEN]; -} ArpPacketInfo; - -typedef struct ArpPacket { - uint8_t *ether_header; - uint8_t *ether_payload; -} ArpPacket; - -static State state = STATE_START; -static int n_iteration = 0; -static int n_conflict = 0; - -static char *interface_name = NULL; -static char *pid_file_name = NULL; -static uint32_t start_address = 0; -static char *argv0 = NULL; -static int daemonize = 0; -static int wait_for_address = 0; -static int use_syslog = 0; -static int debug = 0; -static int modify_proc_title = 1; -static int force_bind = 0; -#ifdef HAVE_CHROOT -static int no_chroot = 0; -#endif -static int no_drop_root = 0; -static int wrote_pid_file = 0; -static char *action_script = NULL; - -static enum { - DAEMON_RUN, - DAEMON_KILL, - DAEMON_REFRESH, - DAEMON_VERSION, - DAEMON_HELP, - DAEMON_CHECK -} command = DAEMON_RUN; - -typedef enum CalloutEvent { - CALLOUT_BIND, - CALLOUT_CONFLICT, - CALLOUT_UNBIND, - CALLOUT_STOP, - CALLOUT_MAX -} CalloutEvent; - -static const char * const callout_event_table[CALLOUT_MAX] = { - [CALLOUT_BIND] = "BIND", - [CALLOUT_CONFLICT] = "CONFLICT", - [CALLOUT_UNBIND] = "UNBIND", - [CALLOUT_STOP] = "STOP" -}; - -typedef struct CalloutEventInfo { - CalloutEvent event; - uint32_t address; - int ifindex; -} CalloutEventInfo; - -#define RANDOM_DEVICE "/dev/urandom" - -#define DEBUG(x) \ - do { \ - if (debug) { \ - x; \ - } \ - } while (0) - -static void init_rand_seed(void) { - int fd; - unsigned seed = 0; - - /* Try to initialize seed from /dev/urandom, to make it a little - * less predictable, and to make sure that multiple machines - * booted at the same time choose different random seeds. */ - if ((fd = open(RANDOM_DEVICE, O_RDONLY)) >= 0) { - read(fd, &seed, sizeof(seed)); - close(fd); - } - - /* If the initialization failed by some reason, we add the time to the seed */ - seed ^= (unsigned) time(NULL); - - srand(seed); -} - -static uint32_t pick_addr(uint32_t old_addr) { - uint32_t addr; - - do { - unsigned r = (unsigned) rand(); - - /* Reduce to 16 bits */ - while (r > 0xFFFF) - r = (r >> 16) ^ (r & 0xFFFF); - - addr = htonl(IPV4LL_NETWORK | (uint32_t) r); - - } while (addr == old_addr || !is_ll_address(addr)); - - return addr; -} - -static int load_address(const char *fn, uint32_t *addr) { - FILE *f; - unsigned a, b, c, d; - - assert(fn); - assert(addr); - - if (!(f = fopen(fn, "r"))) { - - if (errno == ENOENT) { - *addr = 0; - return 0; - } - - daemon_log(LOG_ERR, "fopen() failed: %s", strerror(errno)); - goto fail; - } - - if (fscanf(f, "%u.%u.%u.%u\n", &a, &b, &c, &d) != 4) { - daemon_log(LOG_ERR, "Parse failure"); - goto fail; - } - - fclose(f); - - *addr = htonl((a << 24) | (b << 16) | (c << 8) | d); - return 0; - -fail: - if (f) - fclose(f); - - return -1; -} - -static int save_address(const char *fn, uint32_t addr) { - FILE *f; - char buf[32]; - mode_t u; - - assert(fn); - - u = umask(0033); - if (!(f = fopen(fn, "w"))) { - daemon_log(LOG_ERR, "fopen() failed: %s", strerror(errno)); - goto fail; - } - umask(u); - - fprintf(f, "%s\n", inet_ntop(AF_INET, &addr, buf, sizeof (buf))); - fclose(f); - - return 0; - -fail: - if (f) - fclose(f); - - umask(u); - - return -1; -} - -/* - * Allocate a buffer with two pointers in front, one of which is - * guaranteed to point ETHER_HDR_SIZE bytes into it. - */ -static ArpPacket* packet_new(size_t packet_len) { - ArpPacket *p; - uint8_t *b; - - assert(packet_len > 0); - -#ifdef __linux__ - b = avahi_new0(uint8_t, sizeof(struct ArpPacket) + packet_len); - p = (ArpPacket*) b; - p->ether_header = NULL; - p->ether_payload = b + sizeof(struct ArpPacket); - -#else - b = avahi_new0(uint8_t, sizeof(struct ArpPacket) + ETHER_HDR_SIZE + packet_len); - p = (ArpPacket*) b; - p->ether_header = b + sizeof(struct ArpPacket); - p->ether_payload = b + sizeof(struct ArpPacket) + ETHER_HDR_SIZE; -#endif - - return p; -} - -static ArpPacket* packet_new_with_info(const ArpPacketInfo *info, size_t *packet_len) { - ArpPacket *p = NULL; - uint8_t *r; - - assert(info); - assert(info->operation == ARP_REQUEST || info->operation == ARP_RESPONSE); - assert(packet_len != NULL); - - *packet_len = ARP_PACKET_SIZE; - p = packet_new(*packet_len); - r = p->ether_payload; - - r[1] = 1; /* HTYPE */ - r[2] = 8; /* PTYPE */ - r[4] = ETHER_ADDRLEN; /* HLEN */ - r[5] = 4; /* PLEN */ - r[7] = (uint8_t) info->operation; - - memcpy(r+8, info->sender_hw_address, ETHER_ADDRLEN); - memcpy(r+14, &info->sender_ip_address, 4); - memcpy(r+18, info->target_hw_address, ETHER_ADDRLEN); - memcpy(r+24, &info->target_ip_address, 4); - - return p; -} - -static ArpPacket *packet_new_probe(uint32_t ip_address, const uint8_t*hw_address, size_t *packet_len) { - ArpPacketInfo info; - - memset(&info, 0, sizeof(info)); - info.operation = ARP_REQUEST; - memcpy(info.sender_hw_address, hw_address, ETHER_ADDRLEN); - info.target_ip_address = ip_address; - - return packet_new_with_info(&info, packet_len); -} - -static ArpPacket *packet_new_announcement(uint32_t ip_address, const uint8_t* hw_address, size_t *packet_len) { - ArpPacketInfo info; - - memset(&info, 0, sizeof(info)); - info.operation = ARP_REQUEST; - memcpy(info.sender_hw_address, hw_address, ETHER_ADDRLEN); - info.target_ip_address = ip_address; - info.sender_ip_address = ip_address; - - return packet_new_with_info(&info, packet_len); -} - -static int packet_parse(const ArpPacket *packet, size_t packet_len, ArpPacketInfo *info) { - const uint8_t *p; - - assert(packet); - p = (uint8_t *)packet->ether_payload; - assert(p); - - if (packet_len < ARP_PACKET_SIZE) - return -1; - - /* Check HTYPE and PTYPE */ - if (p[0] != 0 || p[1] != 1 || p[2] != 8 || p[3] != 0) - return -1; - - /* Check HLEN, PLEN, OPERATION */ - if (p[4] != ETHER_ADDRLEN || p[5] != 4 || p[6] != 0 || (p[7] != 1 && p[7] != 2)) - return -1; - - info->operation = p[7]; - memcpy(info->sender_hw_address, p+8, ETHER_ADDRLEN); - memcpy(&info->sender_ip_address, p+14, 4); - memcpy(info->target_hw_address, p+18, ETHER_ADDRLEN); - memcpy(&info->target_ip_address, p+24, 4); - - return 0; -} - -static void set_state(State st, int reset_counter, uint32_t address) { - static const char* const state_table[] = { - [STATE_START] = "START", - [STATE_WAITING_PROBE] = "WAITING_PROBE", - [STATE_PROBING] = "PROBING", - [STATE_WAITING_ANNOUNCE] = "WAITING_ANNOUNCE", - [STATE_ANNOUNCING] = "ANNOUNCING", - [STATE_RUNNING] = "RUNNING", - [STATE_SLEEPING] = "SLEEPING" - }; - char buf[64]; - - assert(st < STATE_MAX); - - if (st == state && !reset_counter) { - n_iteration++; - DEBUG(daemon_log(LOG_DEBUG, "State iteration %s-%i", state_table[state], n_iteration)); - } else { - DEBUG(daemon_log(LOG_DEBUG, "State transition %s-%i -> %s-0", state_table[state], n_iteration, state_table[st])); - state = st; - n_iteration = 0; - } - - if (state == STATE_SLEEPING) - avahi_set_proc_title(argv0, "%s: [%s] sleeping", argv0, interface_name); - else if (state == STATE_ANNOUNCING) - avahi_set_proc_title(argv0, "%s: [%s] announcing %s", argv0, interface_name, inet_ntop(AF_INET, &address, buf, sizeof(buf))); - else if (state == STATE_RUNNING) - avahi_set_proc_title(argv0, "%s: [%s] bound %s", argv0, interface_name, inet_ntop(AF_INET, &address, buf, sizeof(buf))); - else - avahi_set_proc_title(argv0, "%s: [%s] probing %s", argv0, interface_name, inet_ntop(AF_INET, &address, buf, sizeof(buf))); -} - -static int interface_up(int iface) { - int fd = -1; - struct ifreq ifreq; - - if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { - daemon_log(LOG_ERR, "socket() failed: %s", strerror(errno)); - goto fail; - } - - memset(&ifreq, 0, sizeof(ifreq)); - if (!if_indextoname(iface, ifreq.ifr_name)) { - daemon_log(LOG_ERR, "if_indextoname() failed: %s", strerror(errno)); - goto fail; - } - - if (ioctl(fd, SIOCGIFFLAGS, &ifreq) < 0) { - daemon_log(LOG_ERR, "SIOCGIFFLAGS failed: %s", strerror(errno)); - goto fail; - } - - ifreq.ifr_flags |= IFF_UP; - - if (ioctl(fd, SIOCSIFFLAGS, &ifreq) < 0) { - daemon_log(LOG_ERR, "SIOCSIFFLAGS failed: %s", strerror(errno)); - goto fail; - } - - close(fd); - - return 0; - -fail: - if (fd >= 0) - close(fd); - - return -1; -} - -#ifdef __linux__ - -/* Linux 'packet socket' specific implementation */ - -static int open_socket(int iface, uint8_t *hw_address) { - int fd = -1; - struct sockaddr_ll sa; - socklen_t sa_len; - - if (interface_up(iface) < 0) - goto fail; - - if ((fd = socket(PF_PACKET, SOCK_DGRAM, 0)) < 0) { - daemon_log(LOG_ERR, "socket() failed: %s", strerror(errno)); - goto fail; - } - - memset(&sa, 0, sizeof(sa)); - sa.sll_family = AF_PACKET; - sa.sll_protocol = htons(ETH_P_ARP); - sa.sll_ifindex = iface; - - if (bind(fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) { - daemon_log(LOG_ERR, "bind() failed: %s", strerror(errno)); - goto fail; - } - - sa_len = sizeof(sa); - if (getsockname(fd, (struct sockaddr*) &sa, &sa_len) < 0) { - daemon_log(LOG_ERR, "getsockname() failed: %s", strerror(errno)); - goto fail; - } - - if (sa.sll_halen != ETHER_ADDRLEN) { - daemon_log(LOG_ERR, "getsockname() returned invalid hardware address."); - goto fail; - } - - memcpy(hw_address, sa.sll_addr, ETHER_ADDRLEN); - - return fd; - -fail: - if (fd >= 0) - close(fd); - - return -1; -} - -static int send_packet(int fd, int iface, ArpPacket *packet, size_t packet_len) { - struct sockaddr_ll sa; - - assert(fd >= 0); - assert(packet); - assert(packet_len > 0); - - memset(&sa, 0, sizeof(sa)); - sa.sll_family = AF_PACKET; - sa.sll_protocol = htons(ETH_P_ARP); - sa.sll_ifindex = iface; - sa.sll_halen = ETHER_ADDRLEN; - memset(sa.sll_addr, 0xFF, ETHER_ADDRLEN); - - if (sendto(fd, packet->ether_payload, packet_len, 0, (struct sockaddr*) &sa, sizeof(sa)) < 0) { - daemon_log(LOG_ERR, "sendto() failed: %s", strerror(errno)); - return -1; - } - - return 0; -} - -static int recv_packet(int fd, ArpPacket **packet, size_t *packet_len) { - int s; - struct sockaddr_ll sa; - socklen_t sa_len; - ssize_t r; - - assert(fd >= 0); - assert(packet); - assert(packet_len); - - *packet = NULL; - - if (ioctl(fd, FIONREAD, &s) < 0) { - daemon_log(LOG_ERR, "FIONREAD failed: %s", strerror(errno)); - goto fail; - } - - if (s <= 0) - s = 4096; - - *packet = packet_new(s); - - sa_len = sizeof(sa); - if ((r = recvfrom(fd, (*packet)->ether_payload, s, 0, (struct sockaddr*) &sa, &sa_len)) < 0) { - daemon_log(LOG_ERR, "recvfrom() failed: %s", strerror(errno)); - goto fail; - } - - *packet_len = (size_t) r; - - return 0; - -fail: - if (*packet) { - avahi_free(*packet); - *packet = NULL; - } - - return -1; -} - -static void close_socket(int fd) { - close(fd); -} - -#else /* !__linux__ */ -/* PCAP-based implementation */ - -static pcap_t *__pp; -static char __pcap_errbuf[PCAP_ERRBUF_SIZE]; -static uint8_t __lladdr[ETHER_ADDRLEN]; - -#ifndef elementsof -#define elementsof(array) (sizeof(array)/sizeof(array[0])) -#endif - -static int __get_ether_addr(int ifindex, u_char *lladdr) { - int mib[6]; - char *buf; - struct if_msghdr *ifm; - char *lim; - char *next; - struct sockaddr_dl *sdl; - size_t len; - - mib[0] = CTL_NET; - mib[1] = PF_ROUTE; - mib[2] = 0; - mib[3] = 0; - mib[4] = NET_RT_IFLIST; - mib[5] = ifindex; - - if (sysctl(mib, elementsof(mib), NULL, &len, NULL, 0) != 0) { - daemon_log(LOG_ERR, "sysctl(NET_RT_IFLIST): %s", - strerror(errno)); - return -1; - } - - buf = avahi_malloc(len); - if (sysctl(mib, elementsof(mib), buf, &len, NULL, 0) != 0) { - daemon_log(LOG_ERR, "sysctl(NET_RT_IFLIST): %s", - strerror(errno)); - free(buf); - return -1; - } - - lim = buf + len; - for (next = buf; next < lim; next += ifm->ifm_msglen) { - ifm = (struct if_msghdr *)next; - if (ifm->ifm_type == RTM_IFINFO) { - sdl = (struct sockaddr_dl *)(ifm + 1); - memcpy(lladdr, LLADDR(sdl), ETHER_ADDRLEN); - } - } - avahi_free(buf); - - return 0; -} - -#define PCAP_TIMEOUT 500 /* 0.5s */ - -static int open_socket(int iface, uint8_t *hw_address) { - struct bpf_program bpf; - char *filter; - char ifname[IFNAMSIZ]; - pcap_t *pp; - int err; - int fd; - - assert(__pp == NULL); - - if (interface_up(iface) < 0) - return -1; - - if (__get_ether_addr(iface, __lladdr) == -1) - return -1; - - if (if_indextoname(iface, ifname) == NULL) - return -1; - - /* - * Using a timeout for BPF is fairly portable across BSDs. On most - * modern versions, using the timeout/nonblock/poll method results in - * fairly sane behavior, with the timeout only coming into play during - * the next_ex() call itself (so, for us, that's only when there's - * data). On older versions, it may result in a PCAP_TIMEOUT busy-wait - * on some versions, though, as the poll() may terminate at the - * PCAP_TIMEOUT instead of the poll() timeout. - */ - pp = pcap_open_live(ifname, 1500, 0, PCAP_TIMEOUT, __pcap_errbuf); - if (pp == NULL) { - return (-1); - } - err = pcap_set_datalink(pp, DLT_EN10MB); - if (err == -1) { - daemon_log(LOG_ERR, "pcap_set_datalink: %s", pcap_geterr(pp)); - pcap_close(pp); - return (-1); - } - err = pcap_setdirection(pp, PCAP_D_IN); - if (err == -1) { - daemon_log(LOG_ERR, "pcap_setdirection: %s", pcap_geterr(pp)); - pcap_close(pp); - return (-1); - } - - fd = pcap_get_selectable_fd(pp); - if (fd == -1) { - pcap_close(pp); - return (-1); - } - - /* - * Using setnonblock is a portability stop-gap. Using the timeout in - * combination with setnonblock will ensure on most BSDs that the - * next_ex call returns in a timely fashion. - */ - err = pcap_setnonblock(pp, 1, __pcap_errbuf); - if (err == -1) { - pcap_close(pp); - return (-1); - } - - filter = avahi_strdup_printf("arp and (ether dst ff:ff:ff:ff:ff:ff or " - "%02x:%02x:%02x:%02x:%02x:%02x)", - __lladdr[0], __lladdr[1], - __lladdr[2], __lladdr[3], - __lladdr[4], __lladdr[5]); - DEBUG(daemon_log(LOG_DEBUG, "Using pcap filter '%s'", filter)); - - err = pcap_compile(pp, &bpf, filter, 1, 0); - avahi_free(filter); - if (err == -1) { - daemon_log(LOG_ERR, "pcap_compile: %s", pcap_geterr(pp)); - pcap_close(pp); - return (-1); - } - err = pcap_setfilter(pp, &bpf); - if (err == -1) { - daemon_log(LOG_ERR, "pcap_setfilter: %s", pcap_geterr(pp)); - pcap_close(pp); - return (-1); - } - pcap_freecode(&bpf); - - /* Stash pcap-specific context away. */ - memcpy(hw_address, __lladdr, ETHER_ADDRLEN); - __pp = pp; - - return (fd); -} - -static void close_socket(int fd AVAHI_GCC_UNUSED) { - assert(__pp != NULL); - pcap_close(__pp); - __pp = NULL; -} - -/* - * We trick avahi into allocating sizeof(packet) + sizeof(ether_header), - * and prepend the required ethernet header information before sending. - */ -static int send_packet(int fd AVAHI_GCC_UNUSED, int iface AVAHI_GCC_UNUSED, ArpPacket *packet, size_t packet_len) { - struct ether_header *eh; - - assert(__pp != NULL); - assert(packet != NULL); - - eh = (struct ether_header *)packet->ether_header; - memset(eh->ether_dhost, 0xFF, ETHER_ADDRLEN); - memcpy(eh->ether_shost, __lladdr, ETHER_ADDRLEN); - eh->ether_type = htons(0x0806); - - return (pcap_inject(__pp, (void *)eh, packet_len + sizeof(*eh))); -} - -static int recv_packet(int fd AVAHI_GCC_UNUSED, ArpPacket **packet, size_t *packet_len) { - struct pcap_pkthdr *ph; - u_char *pd; - ArpPacket *ap; - int err; - int retval; - - assert(__pp != NULL); - assert(packet != NULL); - assert(packet_len != NULL); - - *packet = NULL; - *packet_len = 0; - retval = -1; - - err = pcap_next_ex(__pp, &ph, (const u_char **)&pd); - if (err == 1 && ph->caplen <= ph->len) { - ap = packet_new(ph->caplen); - memcpy(ap->ether_header, pd, ph->caplen); - *packet = ap; - *packet_len = (ph->caplen - sizeof(struct ether_header)); - retval = 0; - } else if (err >= 0) { - /* - * err == 1: Just drop bogus packets (>1500 for an arp packet!?) - * on the floor. - * - * err == 0: We might have had traffic on the pcap fd that - * didn't match the filter, in which case we'll get 0 packets. - */ - retval = 0; - } else - daemon_log(LOG_ERR, "pcap_next_ex(%d): %s", - err, pcap_geterr(__pp)); - - return (retval); -} -#endif /* __linux__ */ - -int is_ll_address(uint32_t addr) { - return - ((ntohl(addr) & IPV4LL_NETMASK) == IPV4LL_NETWORK) && - ((ntohl(addr) & 0x0000FF00) != 0x0000) && - ((ntohl(addr) & 0x0000FF00) != 0xFF00); -} - -static struct timeval *elapse_time(struct timeval *tv, unsigned msec, unsigned jitter) { - assert(tv); - - gettimeofday(tv, NULL); - - if (msec) - avahi_timeval_add(tv, (AvahiUsec) msec*1000); - - if (jitter) - avahi_timeval_add(tv, (AvahiUsec) (jitter*1000.0*rand()/(RAND_MAX+1.0))); - - return tv; -} - -static FILE* fork_dispatcher(void) { - FILE *ret; - int fds[2]; - pid_t pid; - - if (pipe(fds) < 0) { - daemon_log(LOG_ERR, "pipe() failed: %s", strerror(errno)); - goto fail; - } - - if ((pid = fork()) < 0) - goto fail; - else if (pid == 0) { - FILE *f = NULL; - int r = 1; - - /* Please note that the signal pipe is not closed at this - * point, signals will thus be dispatched in the main - * process. */ - - daemon_retval_done(); - - avahi_set_proc_title(argv0, "%s: [%s] callout dispatcher", argv0, interface_name); - - close(fds[1]); - - if (!(f = fdopen(fds[0], "r"))) { - daemon_log(LOG_ERR, "fdopen() failed: %s", strerror(errno)); - goto dispatcher_fail; - } - - for (;;) { - CalloutEventInfo info; - char name[IFNAMSIZ], buf[64]; - int k; - - if (fread(&info, sizeof(info), 1, f) != 1) { - if (feof(f)) - break; - - daemon_log(LOG_ERR, "fread() failed: %s", strerror(errno)); - goto dispatcher_fail; - } - - assert(info.event <= CALLOUT_MAX); - - if (!if_indextoname(info.ifindex, name)) { - daemon_log(LOG_ERR, "if_indextoname() failed: %s", strerror(errno)); - continue; - } - - if (daemon_exec("/", &k, - action_script, action_script, - callout_event_table[info.event], - name, - inet_ntop(AF_INET, &info.address, buf, sizeof(buf)), NULL) < 0) { - - daemon_log(LOG_ERR, "Failed to run script: %s", strerror(errno)); - continue; - } - - if (k != 0) - daemon_log(LOG_WARNING, "Script execution failed with return value %i", k); - } - - r = 0; - - dispatcher_fail: - - if (f) - fclose(f); - -#ifdef HAVE_CHROOT - /* If the main process is trapped inside a chroot() we have to - * remove the PID file for it */ - - if (!no_chroot && wrote_pid_file) - daemon_pid_file_remove(); -#endif - - _exit(r); - } - - /* parent */ - - close(fds[0]); - fds[0] = -1; - - if (!(ret = fdopen(fds[1], "w"))) { - daemon_log(LOG_ERR, "fdopen() failed: %s", strerror(errno)); - goto fail; - } - - return ret; - -fail: - if (fds[0] >= 0) - close(fds[0]); - if (fds[1] >= 0) - close(fds[1]); - - return NULL; -} - -static int do_callout(FILE *f, CalloutEvent event, int iface, uint32_t addr) { - CalloutEventInfo info; - char buf[64], ifname[IFNAMSIZ]; - - daemon_log(LOG_INFO, "Callout %s, address %s on interface %s", - callout_event_table[event], - inet_ntop(AF_INET, &addr, buf, sizeof(buf)), - if_indextoname(iface, ifname)); - - info.event = event; - info.ifindex = iface; - info.address = addr; - - if (fwrite(&info, sizeof(info), 1, f) != 1 || fflush(f) != 0) { - daemon_log(LOG_ERR, "Failed to write callout event: %s", strerror(errno)); - return -1; - } - - return 0; -} - -#define set_env(key, value) putenv(avahi_strdup_printf("%s=%s", (key), (value))) - -static int drop_privs(void) { - struct passwd *pw; - struct group * gr; - int r; - mode_t u; - - pw = NULL; - gr = NULL; - - /* Get user/group ID */ - - if (!no_drop_root) { - - if (!(pw = getpwnam(AVAHI_AUTOIPD_USER))) { - daemon_log(LOG_ERR, "Failed to find user '"AVAHI_AUTOIPD_USER"'."); - return -1; - } - - if (!(gr = getgrnam(AVAHI_AUTOIPD_GROUP))) { - daemon_log(LOG_ERR, "Failed to find group '"AVAHI_AUTOIPD_GROUP"'."); - return -1; - } - - daemon_log(LOG_INFO, "Found user '"AVAHI_AUTOIPD_USER"' (UID %lu) and group '"AVAHI_AUTOIPD_GROUP"' (GID %lu).", (unsigned long) pw->pw_uid, (unsigned long) gr->gr_gid); - } - - /* Create directory */ - u = umask(0000); - r = mkdir(AVAHI_IPDATA_DIR, 0755); - umask(u); - - if (r < 0 && errno != EEXIST) { - daemon_log(LOG_ERR, "mkdir(\""AVAHI_IPDATA_DIR"\"): %s", strerror(errno)); - return -1; - } - - /* Convey working directory */ - - if (!no_drop_root) { - struct stat st; - - chown(AVAHI_IPDATA_DIR, pw->pw_uid, gr->gr_gid); - - if (stat(AVAHI_IPDATA_DIR, &st) < 0) { - daemon_log(LOG_ERR, "stat(): %s\n", strerror(errno)); - return -1; - } - - if (!S_ISDIR(st.st_mode) || st.st_uid != pw->pw_uid || st.st_gid != gr->gr_gid) { - daemon_log(LOG_ERR, "Failed to create runtime directory "AVAHI_IPDATA_DIR"."); - return -1; - } - } - -#ifdef HAVE_CHROOT - - if (!no_chroot) { - if (chroot(AVAHI_IPDATA_DIR) < 0) { - daemon_log(LOG_ERR, "Failed to chroot(): %s", strerror(errno)); - return -1; - } - - daemon_log(LOG_INFO, "Successfully called chroot()."); - chdir("/"); - - /* Since we are now trapped inside a chroot we cannot remove - * the pid file anymore, the helper process will do that for us. */ - wrote_pid_file = 0; - } - -#endif - - if (!no_drop_root) { - - if (initgroups(AVAHI_AUTOIPD_USER, gr->gr_gid) != 0) { - daemon_log(LOG_ERR, "Failed to change group list: %s", strerror(errno)); - return -1; - } - -#if defined(HAVE_SETRESGID) - r = setresgid(gr->gr_gid, gr->gr_gid, gr->gr_gid); -#elif defined(HAVE_SETEGID) - if ((r = setgid(gr->gr_gid)) >= 0) - r = setegid(gr->gr_gid); -#elif defined(HAVE_SETREGID) - r = setregid(gr->gr_gid, gr->gr_gid); -#else -#error "No API to drop privileges" -#endif - - if (r < 0) { - daemon_log(LOG_ERR, "Failed to change GID: %s", strerror(errno)); - return -1; - } - -#if defined(HAVE_SETRESUID) - r = setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid); -#elif defined(HAVE_SETEUID) - if ((r = setuid(pw->pw_uid)) >= 0) - r = seteuid(pw->pw_uid); -#elif defined(HAVE_SETREUID) - r = setreuid(pw->pw_uid, pw->pw_uid); -#else -#error "No API to drop privileges" -#endif - - if (r < 0) { - daemon_log(LOG_ERR, "Failed to change UID: %s", strerror(errno)); - return -1; - } - - set_env("USER", pw->pw_name); - set_env("LOGNAME", pw->pw_name); - set_env("HOME", pw->pw_dir); - - daemon_log(LOG_INFO, "Successfully dropped root privileges."); - } - - return 0; -} - -static int loop(int iface, uint32_t addr) { - enum { - FD_ARP, - FD_IFACE, - FD_SIGNAL, - FD_MAX - }; - - int fd = -1, ret = -1; - struct timeval next_wakeup; - int next_wakeup_valid = 0; - char buf[64]; - ArpPacket *in_packet = NULL; - size_t in_packet_len = 0; - ArpPacket *out_packet = NULL; - size_t out_packet_len; - uint8_t hw_address[ETHER_ADDRLEN]; - struct pollfd pollfds[FD_MAX]; - int iface_fd = -1; - Event event = EVENT_NULL; - int retval_sent = !daemonize; - State st; - FILE *dispatcher = NULL; - char *address_fn = NULL; - const char *p; - - daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP, 0); - - if (!(dispatcher = fork_dispatcher())) - goto fail; - - if ((fd = open_socket(iface, hw_address)) < 0) - goto fail; - - if ((iface_fd = iface_init(iface)) < 0) - goto fail; - - if (drop_privs() < 0) - goto fail; - - if (force_bind) - st = STATE_START; - else if (iface_get_initial_state(&st) < 0) - goto fail; - -#ifdef HAVE_CHROOT - if (!no_chroot) - p = ""; - else -#endif - p = AVAHI_IPDATA_DIR; - - address_fn = avahi_strdup_printf( - "%s/%02x:%02x:%02x:%02x:%02x:%02x", p, - hw_address[0], hw_address[1], - hw_address[2], hw_address[3], - hw_address[4], hw_address[5]); - - if (!addr) - load_address(address_fn, &addr); - - if (addr && !is_ll_address(addr)) { - daemon_log(LOG_WARNING, "Requested address %s is not from IPv4LL range 169.254/16 or a reserved address, ignoring.", inet_ntop(AF_INET, &addr, buf, sizeof(buf))); - addr = 0; - } - - if (!addr) { - int i; - uint32_t a = 1; - - for (i = 0; i < ETHER_ADDRLEN; i++) - a += hw_address[i]*i; - - a = (a % 0xFE00) + 0x0100; - - addr = htonl(IPV4LL_NETWORK | (uint32_t) a); - } - - assert(is_ll_address(addr)); - - set_state(st, 1, addr); - - daemon_log(LOG_INFO, "Starting with address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf))); - - if (state == STATE_SLEEPING) - daemon_log(LOG_INFO, "Routable address already assigned, sleeping."); - - if (!retval_sent && (!wait_for_address || state == STATE_SLEEPING)) { - daemon_retval_send(0); - retval_sent = 1; - } - - memset(pollfds, 0, sizeof(pollfds)); - pollfds[FD_ARP].fd = fd; - pollfds[FD_ARP].events = POLLIN; - pollfds[FD_IFACE].fd = iface_fd; - pollfds[FD_IFACE].events = POLLIN; - pollfds[FD_SIGNAL].fd = daemon_signal_fd(); - pollfds[FD_SIGNAL].events = POLLIN; - - for (;;) { - int r, timeout; - AvahiUsec usec; - - if (state == STATE_START) { - - /* First, wait a random time */ - set_state(STATE_WAITING_PROBE, 1, addr); - - elapse_time(&next_wakeup, 0, PROBE_WAIT*1000); - next_wakeup_valid = 1; - - } else if ((state == STATE_WAITING_PROBE && event == EVENT_TIMEOUT) || - (state == STATE_PROBING && event == EVENT_TIMEOUT && n_iteration < PROBE_NUM-2)) { - - /* Send a probe */ - out_packet = packet_new_probe(addr, hw_address, &out_packet_len); - set_state(STATE_PROBING, 0, addr); - - elapse_time(&next_wakeup, PROBE_MIN*1000, (PROBE_MAX-PROBE_MIN)*1000); - next_wakeup_valid = 1; - - } else if (state == STATE_PROBING && event == EVENT_TIMEOUT && n_iteration >= PROBE_NUM-2) { - - /* Send the last probe */ - out_packet = packet_new_probe(addr, hw_address, &out_packet_len); - set_state(STATE_WAITING_ANNOUNCE, 1, addr); - - elapse_time(&next_wakeup, ANNOUNCE_WAIT*1000, 0); - next_wakeup_valid = 1; - - } else if ((state == STATE_WAITING_ANNOUNCE && event == EVENT_TIMEOUT) || - (state == STATE_ANNOUNCING && event == EVENT_TIMEOUT && n_iteration < ANNOUNCE_NUM-1)) { - - /* Send announcement packet */ - out_packet = packet_new_announcement(addr, hw_address, &out_packet_len); - set_state(STATE_ANNOUNCING, 0, addr); - - elapse_time(&next_wakeup, ANNOUNCE_INTERVAL*1000, 0); - next_wakeup_valid = 1; - - if (n_iteration == 0) { - if (do_callout(dispatcher, CALLOUT_BIND, iface, addr) < 0) - goto fail; - - n_conflict = 0; - } - - } else if ((state == STATE_ANNOUNCING && event == EVENT_TIMEOUT && n_iteration >= ANNOUNCE_NUM-1)) { - - daemon_log(LOG_INFO, "Successfully claimed IP address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf))); - set_state(STATE_RUNNING, 0, addr); - - next_wakeup_valid = 0; - - save_address(address_fn, addr); - - if (!retval_sent) { - daemon_retval_send(0); - retval_sent = 1; - } - - } else if (event == EVENT_PACKET) { - ArpPacketInfo info; - - assert(in_packet); - - if (packet_parse(in_packet, in_packet_len, &info) < 0) - daemon_log(LOG_WARNING, "Failed to parse incoming ARP packet."); - else { - int conflict = 0; - - if (info.sender_ip_address == addr) { - - if (memcmp(hw_address, info.sender_hw_address, ETHER_ADDRLEN)) { - /* Normal conflict */ - conflict = 1; - daemon_log(LOG_INFO, "Received conflicting normal ARP packet."); - } else - daemon_log(LOG_DEBUG, "Received ARP packet back on source interface. Ignoring."); - - } else if (state == STATE_WAITING_PROBE || state == STATE_PROBING || state == STATE_WAITING_ANNOUNCE) { - /* Probe conflict */ - conflict = info.target_ip_address == addr && memcmp(hw_address, info.sender_hw_address, ETHER_ADDRLEN); - - if (conflict) - daemon_log(LOG_INFO, "Received conflicting probe ARP packet."); - } - - if (conflict) { - - if (state == STATE_RUNNING || state == STATE_ANNOUNCING) - if (do_callout(dispatcher, CALLOUT_CONFLICT, iface, addr) < 0) - goto fail; - - /* Pick a new address */ - addr = pick_addr(addr); - - daemon_log(LOG_INFO, "Trying address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf))); - - n_conflict++; - - set_state(STATE_WAITING_PROBE, 1, addr); - - if (n_conflict >= MAX_CONFLICTS) { - daemon_log(LOG_WARNING, "Got too many conflicts, rate limiting new probes."); - elapse_time(&next_wakeup, RATE_LIMIT_INTERVAL*1000, PROBE_WAIT*1000); - } else - elapse_time(&next_wakeup, 0, PROBE_WAIT*1000); - - next_wakeup_valid = 1; - } else - DEBUG(daemon_log(LOG_DEBUG, "Ignoring irrelevant ARP packet.")); - } - - } else if (event == EVENT_ROUTABLE_ADDR_CONFIGURED && !force_bind) { - - daemon_log(LOG_INFO, "A routable address has been configured."); - - if (state == STATE_RUNNING || state == STATE_ANNOUNCING) - if (do_callout(dispatcher, CALLOUT_UNBIND, iface, addr) < 0) - goto fail; - - if (!retval_sent) { - daemon_retval_send(0); - retval_sent = 1; - } - - set_state(STATE_SLEEPING, 1, addr); - next_wakeup_valid = 0; - - } else if (event == EVENT_ROUTABLE_ADDR_UNCONFIGURED && state == STATE_SLEEPING && !force_bind) { - - daemon_log(LOG_INFO, "No longer a routable address configured, restarting probe process."); - - set_state(STATE_WAITING_PROBE, 1, addr); - - elapse_time(&next_wakeup, 0, PROBE_WAIT*1000); - next_wakeup_valid = 1; - - } else if (event == EVENT_REFRESH_REQUEST && state == STATE_RUNNING) { - - /* The user requested a reannouncing of the address by a SIGHUP */ - daemon_log(LOG_INFO, "Reannouncing address."); - - /* Send announcement packet */ - out_packet = packet_new_announcement(addr, hw_address, &out_packet_len); - set_state(STATE_ANNOUNCING, 1, addr); - - elapse_time(&next_wakeup, ANNOUNCE_INTERVAL*1000, 0); - next_wakeup_valid = 1; - } - - if (out_packet) { - DEBUG(daemon_log(LOG_DEBUG, "sending...")); - - if (send_packet(fd, iface, out_packet, out_packet_len) < 0) - goto fail; - - avahi_free(out_packet); - out_packet = NULL; - } - - if (in_packet) { - avahi_free(in_packet); - in_packet = NULL; - } - - event = EVENT_NULL; - timeout = -1; - - if (next_wakeup_valid) { - usec = avahi_age(&next_wakeup); - timeout = usec < 0 ? (int) (-usec/1000) : 0; - } - - DEBUG(daemon_log(LOG_DEBUG, "sleeping %ims", timeout)); - - while ((r = poll(pollfds, FD_MAX, timeout)) < 0 && errno == EINTR) - ; - - if (r < 0) { - daemon_log(LOG_ERR, "poll() failed: %s", strerror(r)); - goto fail; - } else if (r == 0) { - event = EVENT_TIMEOUT; - next_wakeup_valid = 0; - } else { - - - if (pollfds[FD_ARP].revents) { - - if (pollfds[FD_ARP].revents == POLLERR) { - /* The interface is probably down, let's recreate our socket */ - - close_socket(fd); - - if ((fd = open_socket(iface, hw_address)) < 0) - goto fail; - - pollfds[FD_ARP].fd = fd; - - } else { - - assert(pollfds[FD_ARP].revents == POLLIN); - - if (recv_packet(fd, &in_packet, &in_packet_len) < 0) - goto fail; - - if (in_packet) - event = EVENT_PACKET; - } - } - - if (event == EVENT_NULL && - pollfds[FD_IFACE].revents) { - - assert(pollfds[FD_IFACE].revents == POLLIN); - - if (iface_process(&event) < 0) - goto fail; - } - - if (event == EVENT_NULL && - pollfds[FD_SIGNAL].revents) { - - int sig; - assert(pollfds[FD_SIGNAL].revents == POLLIN); - - if ((sig = daemon_signal_next()) <= 0) { - daemon_log(LOG_ERR, "daemon_signal_next() failed"); - goto fail; - } - - switch(sig) { - case SIGINT: - case SIGTERM: - daemon_log(LOG_INFO, "Got %s, quitting.", sig == SIGINT ? "SIGINT" : "SIGTERM"); - ret = 0; - goto fail; - - case SIGCHLD: - waitpid(-1, NULL, WNOHANG); - break; - - case SIGHUP: - event = EVENT_REFRESH_REQUEST; - break; - } - - } - } - } - - ret = 0; - -fail: - - if (state == STATE_RUNNING || state == STATE_ANNOUNCING) - do_callout(dispatcher, CALLOUT_STOP, iface, addr); - - avahi_free(out_packet); - avahi_free(in_packet); - - if (fd >= 0) - close_socket(fd); - - if (iface_fd >= 0) - iface_done(); - - if (daemonize && !retval_sent) - daemon_retval_send(ret); - - if (dispatcher) - fclose(dispatcher); - - if (address_fn) - avahi_free(address_fn); - - return ret; -} - - -static void help(FILE *f, const char *a0) { - fprintf(f, - "%s [options] INTERFACE\n" - " -h --help Show this help\n" - " -D --daemonize Daemonize after startup\n" - " -s --syslog Write log messages to syslog(3) instead of STDERR\n" - " -k --kill Kill a running daemon\n" - " -r --refresh Request a running daemon refresh its IP address\n" - " -c --check Return 0 if a daemon is already running\n" - " -V --version Show version\n" - " -S --start=ADDRESS Start with this address from the IPv4LL range\n" - " 169.254.0.0/16\n" - " -t --script=script Action script to run (defaults to\n" - " "AVAHI_IPCONF_SCRIPT")\n" - " -w --wait Wait until an address has been acquired before\n" - " daemonizing\n" - " --force-bind Assign an IPv4LL address even if a routable address\n" - " is already assigned\n" - " --no-drop-root Don't drop privileges\n" -#ifdef HAVE_CHROOT - " --no-chroot Don't chroot()\n" -#endif - " --no-proc-title Don't modify process title\n" - " --debug Increase verbosity\n", - a0); -} - -static int parse_command_line(int argc, char *argv[]) { - int c; - - enum { - OPTION_NO_PROC_TITLE = 256, - OPTION_FORCE_BIND, - OPTION_DEBUG, - OPTION_NO_DROP_ROOT, -#ifdef HAVE_CHROOT - OPTION_NO_CHROOT -#endif - }; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "daemonize", no_argument, NULL, 'D' }, - { "syslog", no_argument, NULL, 's' }, - { "kill", no_argument, NULL, 'k' }, - { "refresh", no_argument, NULL, 'r' }, - { "check", no_argument, NULL, 'c' }, - { "version", no_argument, NULL, 'V' }, - { "start", required_argument, NULL, 'S' }, - { "script", required_argument, NULL, 't' }, - { "wait", no_argument, NULL, 'w' }, - { "force-bind", no_argument, NULL, OPTION_FORCE_BIND }, - { "no-drop-root", no_argument, NULL, OPTION_NO_DROP_ROOT }, -#ifdef HAVE_CHROOT - { "no-chroot", no_argument, NULL, OPTION_NO_CHROOT }, -#endif - { "no-proc-title", no_argument, NULL, OPTION_NO_PROC_TITLE }, - { "debug", no_argument, NULL, OPTION_DEBUG }, - { NULL, 0, NULL, 0 } - }; - - while ((c = getopt_long(argc, argv, "hDskrcVS:t:w", long_options, NULL)) >= 0) { - - switch(c) { - case 's': - use_syslog = 1; - break; - case 'h': - command = DAEMON_HELP; - break; - case 'D': - daemonize = 1; - break; - case 'k': - command = DAEMON_KILL; - break; - case 'V': - command = DAEMON_VERSION; - break; - case 'r': - command = DAEMON_REFRESH; - break; - case 'c': - command = DAEMON_CHECK; - break; - case 'S': - - if ((start_address = inet_addr(optarg)) == (uint32_t) -1) { - fprintf(stderr, "Failed to parse IP address '%s'.", optarg); - return -1; - } - break; - case 't': - avahi_free(action_script); - action_script = avahi_strdup(optarg); - break; - case 'w': - wait_for_address = 1; - break; - - case OPTION_NO_PROC_TITLE: - modify_proc_title = 0; - break; - - case OPTION_DEBUG: - debug = 1; - break; - - case OPTION_FORCE_BIND: - force_bind = 1; - break; - - case OPTION_NO_DROP_ROOT: - no_drop_root = 1; - break; - -#ifdef HAVE_CHROOT - case OPTION_NO_CHROOT: - no_chroot = 1; - break; -#endif - - default: - return -1; - } - } - - if (command == DAEMON_RUN || - command == DAEMON_KILL || - command == DAEMON_REFRESH || - command == DAEMON_CHECK) { - - if (optind >= argc) { - fprintf(stderr, "Missing interface name.\n"); - return -1; - } - - interface_name = avahi_strdup(argv[optind++]); - } - - if (optind != argc) { - fprintf(stderr, "Too many arguments\n"); - return -1; - } - - if (!action_script) - action_script = avahi_strdup(AVAHI_IPCONF_SCRIPT); - - return 0; -} - -static const char* pid_file_proc(void) { - return pid_file_name; -} - -int main(int argc, char*argv[]) { - int r = 1; - char *log_ident = NULL; - - signal(SIGPIPE, SIG_IGN); - - if ((argv0 = strrchr(argv[0], '/'))) - argv0 = avahi_strdup(argv0 + 1); - else - argv0 = avahi_strdup(argv[0]); - - daemon_log_ident = argv0; - - if (parse_command_line(argc, argv) < 0) - goto finish; - - if (modify_proc_title) - avahi_init_proc_title(argc, argv); - - daemon_log_ident = log_ident = avahi_strdup_printf("%s(%s)", argv0, interface_name); - daemon_pid_file_proc = pid_file_proc; - pid_file_name = avahi_strdup_printf(AVAHI_RUNTIME_DIR"/avahi-autoipd.%s.pid", interface_name); - - if (command == DAEMON_RUN) { - pid_t pid; - int ifindex; - - init_rand_seed(); - - if ((ifindex = if_nametoindex(interface_name)) <= 0) { - daemon_log(LOG_ERR, "Failed to get index for interface name '%s': %s", interface_name, strerror(errno)); - goto finish; - } - - if (getuid() != 0) { - daemon_log(LOG_ERR, "This program is intended to be run as root."); - goto finish; - } - - if ((pid = daemon_pid_file_is_running()) >= 0) { - daemon_log(LOG_ERR, "Daemon already running on PID %u", pid); - goto finish; - } - - if (daemonize) { - daemon_retval_init(); - - if ((pid = daemon_fork()) < 0) - goto finish; - else if (pid != 0) { - int ret; - /** Parent **/ - - if ((ret = daemon_retval_wait(20)) < 0) { - daemon_log(LOG_ERR, "Could not receive return value from daemon process."); - goto finish; - } - - r = ret; - goto finish; - } - - /* Child */ - } - - if (use_syslog || daemonize) - daemon_log_use = DAEMON_LOG_SYSLOG; - - chdir("/"); - - if (daemon_pid_file_create() < 0) { - daemon_log(LOG_ERR, "Failed to create PID file: %s", strerror(errno)); - - if (daemonize) - daemon_retval_send(1); - goto finish; - } else - wrote_pid_file = 1; - - avahi_set_proc_title(argv0, "%s: [%s] starting up", argv0, interface_name); - - if (loop(ifindex, start_address) < 0) - goto finish; - - r = 0; - } else if (command == DAEMON_HELP) { - help(stdout, argv0); - - r = 0; - } else if (command == DAEMON_VERSION) { - printf("%s "PACKAGE_VERSION"\n", argv0); - - r = 0; - } else if (command == DAEMON_KILL) { - if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) { - daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno)); - goto finish; - } - - r = 0; - } else if (command == DAEMON_REFRESH) { - if (daemon_pid_file_kill(SIGHUP) < 0) { - daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno)); - goto finish; - } - - r = 0; - } else if (command == DAEMON_CHECK) - r = (daemon_pid_file_is_running() >= 0) ? 0 : 1; - - -finish: - - if (daemonize) - daemon_retval_done(); - - if (wrote_pid_file) - daemon_pid_file_remove(); - - avahi_free(log_ident); - avahi_free(pid_file_name); - avahi_free(argv0); - avahi_free(interface_name); - avahi_free(action_script); - - return r; -} diff --git a/avahi-autoipd/main.h b/avahi-autoipd/main.h deleted file mode 100644 index cc02df7..0000000 --- a/avahi-autoipd/main.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef fooavahimainhfoo -#define fooavahimainhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -typedef enum Event { - EVENT_NULL, - EVENT_PACKET, - EVENT_TIMEOUT, - EVENT_ROUTABLE_ADDR_CONFIGURED, - EVENT_ROUTABLE_ADDR_UNCONFIGURED, - EVENT_REFRESH_REQUEST -} Event; - -typedef enum State { - STATE_START, - STATE_WAITING_PROBE, - STATE_PROBING, - STATE_WAITING_ANNOUNCE, - STATE_ANNOUNCING, - STATE_RUNNING, - STATE_SLEEPING, - STATE_MAX -} State; - -int is_ll_address(uint32_t addr); - -#endif diff --git a/avahi-client.pc.in b/avahi-client.pc.in deleted file mode 100644 index 65ee8d8..0000000 --- a/avahi-client.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include - -Name: avahi-client -Description: Avahi Multicast DNS Responder (Client Support) -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lavahi-common -lavahi-client -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-client/.gitignore b/avahi-client/.gitignore deleted file mode 100644 index 262943b..0000000 --- a/avahi-client/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs -check-nss-test -client-test -rr-test -srv-test -xdg-config-test diff --git a/avahi-client/Makefile.am b/avahi-client/Makefile.am deleted file mode 100644 index f11b11d..0000000 --- a/avahi-client/Makefile.am +++ /dev/null @@ -1,83 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -if HAVE_DBUS - -avahi_clientincludedir=$(includedir)/avahi-client -avahi_clientinclude_HEADERS = client.h lookup.h publish.h - -noinst_HEADERS = internal.h - -if ENABLE_TESTS - -noinst_PROGRAMS = \ - client-test \ - srv-test \ - xdg-config-test \ - rr-test \ - check-nss-test - -endif - -lib_LTLIBRARIES = libavahi-client.la - -libavahi_client_la_SOURCES = \ - client.c client.h \ - entrygroup.c \ - browser.c \ - resolver.c \ - publish.h lookup.h \ - xdg-config.c xdg-config.h \ - check-nss.c \ - ../avahi-common/dbus.c ../avahi-common/dbus.h \ - ../avahi-common/dbus-watch-glue.c ../avahi-common/dbus-watch-glue.h - -libavahi_client_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -DDBUS_SYSTEM_BUS_DEFAULT_ADDRESS=\"$(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)\" -libavahi_client_la_LIBADD = $(AM_LDADD) $(DBUS_LIBS) ../avahi-common/libavahi-common.la -libavahi_client_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_CLIENT_VERSION_INFO) - -client_test_SOURCES = client-test.c -client_test_CFLAGS = $(AM_CFLAGS) -client_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la - -srv_test_SOURCES = srv-test.c -srv_test_CFLAGS = $(AM_CFLAGS) -srv_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la - -rr_test_SOURCES = rr-test.c -rr_test_CFLAGS = $(AM_CFLAGS) -rr_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la - -xdg_config_test_SOURCES = xdg-config-test.c xdg-config.c xdg-config.h -xdg_config_test_CFLAGS = $(AM_CFLAGS) -xdg_config_test_LDADD = $(AM_LDADD) - -check_nss_test_SOURCES = check-nss.c check-nss-test.c client.h -check_nss_test_CFLAGS = $(AM_CFLAGS) -check_nss_test_LDADD = $(AM_LDADD) - -if HAVE_DLOPEN -check_nss_test_LDADD += -ldl -libavahi_client_la_LIBADD += -ldl -endif - -endif diff --git a/avahi-client/browser.c b/avahi-client/browser.c deleted file mode 100644 index c978d94..0000000 --- a/avahi-client/browser.c +++ /dev/null @@ -1,1025 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include "client.h" -#include "internal.h" -#include "xdg-config.h" - -static void parse_environment(AvahiDomainBrowser *b) { - char buf[AVAHI_DOMAIN_NAME_MAX*3], *e, *t, *p; - - assert(b); - - if (!(e = getenv("AVAHI_BROWSE_DOMAINS"))) - return; - - snprintf(buf, sizeof(buf), "%s", e); - - for (t = strtok_r(buf, ":", &p); t; t = strtok_r(NULL, ":", &p)) { - char domain[AVAHI_DOMAIN_NAME_MAX]; - if (avahi_normalize_name(t, domain, sizeof(domain))) - b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain); - } -} - -static void parse_domain_file(AvahiDomainBrowser *b) { - FILE *f; - char buf[AVAHI_DOMAIN_NAME_MAX]; - - assert(b); - - if (!(f = avahi_xdg_config_open("avahi/browse-domains"))) - return; - - - while (fgets(buf, sizeof(buf)-1, f)) { - char domain[AVAHI_DOMAIN_NAME_MAX]; - buf[strcspn(buf, "\n\r")] = 0; - - if (avahi_normalize_name(buf, domain, sizeof(domain))) - b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain); - } -} - -static void domain_browser_ref(AvahiDomainBrowser *db) { - assert(db); - assert(db->ref >= 1); - db->ref++; -} - -static void defer_timeout_callback(AvahiTimeout *t, void *userdata) { - AvahiDomainBrowser *db = userdata; - AvahiStringList *l; - assert(t); - - db->client->poll_api->timeout_free(db->defer_timeout); - db->defer_timeout = NULL; - - domain_browser_ref(db); - - for (l = db->static_browse_domains; l; l = l->next) { - - if (db->ref <= 1) - break; - - db->callback(db, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_NEW, (char*) l->text, AVAHI_LOOKUP_RESULT_STATIC, db->userdata); - } - - avahi_domain_browser_free(db); -} - -AvahiDomainBrowser* avahi_domain_browser_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *domain, - AvahiDomainBrowserType btype, - AvahiLookupFlags flags, - AvahiDomainBrowserCallback callback, - void *userdata) { - - AvahiDomainBrowser *db = NULL; - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - char *path; - int32_t i_interface, i_protocol, bt; - uint32_t u_flags; - - assert(client); - assert(callback); - - dbus_error_init (&error); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!domain) - domain = ""; - - if (!(db = avahi_new (AvahiDomainBrowser, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - db->ref = 1; - db->client = client; - db->callback = callback; - db->userdata = userdata; - db->path = NULL; - db->interface = interface; - db->protocol = protocol; - db->static_browse_domains = NULL; - db->defer_timeout = NULL; - - AVAHI_LLIST_PREPEND(AvahiDomainBrowser, domain_browsers, client->domain_browsers, db); - - if (!(client->flags & AVAHI_CLIENT_IGNORE_USER_CONFIG)) { - parse_environment(db); - parse_domain_file(db); - } - - db->static_browse_domains = avahi_string_list_reverse(db->static_browse_domains); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - bt = btype; - - if (!(dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INT32, &bt, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || - dbus_error_is_set(&error)) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error) || - !path) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(db->path = avahi_strdup(path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (db->static_browse_domains && btype == AVAHI_DOMAIN_BROWSER_BROWSE) { - struct timeval tv = { 0, 0 }; - - if (!(db->defer_timeout = client->poll_api->timeout_new(client->poll_api, &tv, defer_timeout_callback, db))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return db; - -fail: - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (db) - avahi_domain_browser_free(db); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; -} - -AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *b) { - assert(b); - return b->client; -} - -int avahi_domain_browser_free (AvahiDomainBrowser *b) { - AvahiClient *client; - int r = AVAHI_OK; - - assert(b); - assert(b->ref >= 1); - - if (--(b->ref) >= 1) - return AVAHI_OK; - - client = b->client; - - if (b->path && avahi_client_is_connected(b->client)) - r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Free"); - - AVAHI_LLIST_REMOVE(AvahiDomainBrowser, domain_browsers, client->domain_browsers, b); - - if (b->defer_timeout) - b->client->poll_api->timeout_free(b->defer_timeout); - - avahi_string_list_free(b->static_browse_domains); - avahi_free(b->path); - avahi_free(b); - - return r; -} - -DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { - AvahiDomainBrowser *db = NULL; - DBusError error; - const char *path; - char *domain = NULL; - int32_t interface, protocol; - uint32_t flags = 0; - AvahiStringList *l; - - assert(client); - assert(message); - - dbus_error_init (&error); - - if (!(path = dbus_message_get_path(message))) - goto fail; - - for (db = client->domain_browsers; db; db = db->domain_browsers_next) - if (strcmp (db->path, path) == 0) - break; - - if (!db) - goto fail; - - interface = db->interface; - protocol = db->protocol; - - switch (event) { - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE: - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - - case AVAHI_BROWSER_FAILURE: { - char *etxt; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &etxt, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - - avahi_client_set_errno(db->client, avahi_error_dbus_to_number(etxt)); - break; - } - } - - if (domain) - for (l = db->static_browse_domains; l; l = l->next) - if (avahi_domain_equal((char*) l->text, domain)) { - /* We had this entry already in the static entries */ - return DBUS_HANDLER_RESULT_HANDLED; - } - - db->callback(db, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, domain, (AvahiLookupResultFlags) flags, db->userdata); - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - dbus_error_free (&error); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -/* AvahiServiceTypeBrowser */ - -AvahiServiceTypeBrowser* avahi_service_type_browser_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *domain, - AvahiLookupFlags flags, - AvahiServiceTypeBrowserCallback callback, - void *userdata) { - - AvahiServiceTypeBrowser *b = NULL; - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - char *path; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(client); - assert(callback); - - dbus_error_init(&error); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!domain) - domain = ""; - - if (!(b = avahi_new(AvahiServiceTypeBrowser, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - b->client = client; - b->callback = callback; - b->userdata = userdata; - b->path = NULL; - b->domain = NULL; - b->interface = interface; - b->protocol = protocol; - - AVAHI_LLIST_PREPEND(AvahiServiceTypeBrowser, service_type_browsers, client->service_type_browsers, b); - - if (domain[0]) - if (!(b->domain = avahi_strdup(domain))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceTypeBrowserNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID)) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || - dbus_error_is_set(&error)) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error) || - !path) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(b->path = avahi_strdup(path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return b; - -fail: - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (b) - avahi_service_type_browser_free(b); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; -} - -AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *b) { - assert(b); - return b->client; -} - -int avahi_service_type_browser_free (AvahiServiceTypeBrowser *b) { - AvahiClient *client; - int r = AVAHI_OK; - - assert(b); - client = b->client; - - if (b->path && avahi_client_is_connected(b->client)) - r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Free"); - - AVAHI_LLIST_REMOVE(AvahiServiceTypeBrowser, service_type_browsers, b->client->service_type_browsers, b); - - avahi_free(b->path); - avahi_free(b->domain); - avahi_free(b); - return r; -} - -DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { - AvahiServiceTypeBrowser *b = NULL; - DBusError error; - const char *path; - char *domain, *type = NULL; - int32_t interface, protocol; - uint32_t flags = 0; - - assert(client); - assert(message); - - dbus_error_init (&error); - - if (!(path = dbus_message_get_path(message))) - goto fail; - - for (b = client->service_type_browsers; b; b = b->service_type_browsers_next) - if (strcmp (b->path, path) == 0) - break; - - if (!b) - goto fail; - - domain = b->domain; - interface = b->interface; - protocol = b->protocol; - - switch (event) { - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE: - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || - dbus_error_is_set(&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - - case AVAHI_BROWSER_FAILURE: { - char *etxt; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &etxt, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - - avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); - break; - } - } - - b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, type, domain, (AvahiLookupResultFlags) flags, b->userdata); - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - dbus_error_free (&error); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -/* AvahiServiceBrowser */ - -AvahiServiceBrowser* avahi_service_browser_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *type, - const char *domain, - AvahiLookupFlags flags, - AvahiServiceBrowserCallback callback, - void *userdata) { - - AvahiServiceBrowser *b = NULL; - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - char *path; - int32_t i_protocol, i_interface; - uint32_t u_flags; - - assert(client); - assert(type); - assert(callback); - - dbus_error_init(&error); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!domain) - domain = ""; - - if (!(b = avahi_new(AvahiServiceBrowser, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - b->client = client; - b->callback = callback; - b->userdata = userdata; - b->path = NULL; - b->type = b->domain = NULL; - b->interface = interface; - b->protocol = protocol; - - AVAHI_LLIST_PREPEND(AvahiServiceBrowser, service_browsers, client->service_browsers, b); - - if (!(b->type = avahi_strdup(type))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (domain && domain[0]) - if (!(b->domain = avahi_strdup(domain))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID)) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || - dbus_error_is_set(&error)) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error) || - !path) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(b->path = avahi_strdup(path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return b; - -fail: - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (b) - avahi_service_browser_free(b); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; -} - -AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *b) { - assert(b); - return b->client; -} - -int avahi_service_browser_free (AvahiServiceBrowser *b) { - AvahiClient *client; - int r = AVAHI_OK; - - assert(b); - client = b->client; - - if (b->path && avahi_client_is_connected(b->client)) - r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Free"); - - AVAHI_LLIST_REMOVE(AvahiServiceBrowser, service_browsers, b->client->service_browsers, b); - - avahi_free(b->path); - avahi_free(b->type); - avahi_free(b->domain); - avahi_free(b); - return r; -} - -DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { - AvahiServiceBrowser *b = NULL; - DBusError error; - const char *path; - char *name = NULL, *type, *domain; - int32_t interface, protocol; - uint32_t flags = 0; - - dbus_error_init (&error); - - if (!(path = dbus_message_get_path(message))) - goto fail; - - for (b = client->service_browsers; b; b = b->service_browsers_next) - if (strcmp (b->path, path) == 0) - break; - - if (!b) - goto fail; - - type = b->type; - domain = b->domain; - interface = b->interface; - protocol = b->protocol; - - switch (event) { - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE: - - if (!dbus_message_get_args ( - message, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || - dbus_error_is_set(&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - - case AVAHI_BROWSER_FAILURE: { - char *etxt; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &etxt, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - - avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); - break; - } - } - - b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, name, type, domain, (AvahiLookupResultFlags) flags, b->userdata); - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - dbus_error_free (&error); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -/* AvahiRecordBrowser */ - -AvahiRecordBrowser* avahi_record_browser_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *name, - uint16_t clazz, - uint16_t type, - AvahiLookupFlags flags, - AvahiRecordBrowserCallback callback, - void *userdata) { - - AvahiRecordBrowser *b = NULL; - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - char *path; - int32_t i_protocol, i_interface; - uint32_t u_flags; - - assert(client); - assert(name); - assert(callback); - - dbus_error_init(&error); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!(b = avahi_new(AvahiRecordBrowser, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - b->client = client; - b->callback = callback; - b->userdata = userdata; - b->path = NULL; - b->name = NULL; - b->clazz = clazz; - b->type = type; - b->interface = interface; - b->protocol = protocol; - - AVAHI_LLIST_PREPEND(AvahiRecordBrowser, record_browsers, client->record_browsers, b); - - if (!(b->name = avahi_strdup(name))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT16, &clazz, - DBUS_TYPE_UINT16, &type, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID)) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || - dbus_error_is_set(&error)) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error) || - !path) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(b->path = avahi_strdup(path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return b; - -fail: - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (b) - avahi_record_browser_free(b); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; -} - -AvahiClient* avahi_record_browser_get_client (AvahiRecordBrowser *b) { - assert(b); - return b->client; -} - -int avahi_record_browser_free (AvahiRecordBrowser *b) { - AvahiClient *client; - int r = AVAHI_OK; - - assert(b); - client = b->client; - - if (b->path && avahi_client_is_connected(b->client)) - r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Free"); - - AVAHI_LLIST_REMOVE(AvahiRecordBrowser, record_browsers, b->client->record_browsers, b); - - avahi_free(b->path); - avahi_free(b->name); - avahi_free(b); - return r; -} - -DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { - AvahiRecordBrowser *b = NULL; - DBusError error; - const char *path; - char *name; - int32_t interface, protocol; - uint32_t flags = 0; - uint16_t clazz, type; - void *rdata = NULL; - int rdata_size = 0; - - dbus_error_init (&error); - - if (!(path = dbus_message_get_path(message))) - goto fail; - - for (b = client->record_browsers; b; b = b->record_browsers_next) - if (strcmp (b->path, path) == 0) - break; - - if (!b) - goto fail; - - interface = b->interface; - protocol = b->protocol; - clazz = b->clazz; - type = b->type; - name = b->name; - - switch (event) { - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE: { - DBusMessageIter iter, sub; - int j; - - if (!dbus_message_get_args ( - message, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT16, &clazz, - DBUS_TYPE_UINT16, &type, - DBUS_TYPE_INVALID) || - dbus_error_is_set(&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - - - dbus_message_iter_init(message, &iter); - - for (j = 0; j < 5; j++) - dbus_message_iter_next(&iter); - - if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || - dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE) - goto fail; - - dbus_message_iter_recurse(&iter, &sub); - dbus_message_iter_get_fixed_array(&sub, &rdata, &rdata_size); - - dbus_message_iter_next(&iter); - - if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) - goto fail; - - dbus_message_iter_get_basic(&iter, &flags); - - break; - } - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - - case AVAHI_BROWSER_FAILURE: { - char *etxt; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &etxt, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse browser event.\n"); - goto fail; - } - - avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); - break; - } - } - - b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, name, clazz, type, rdata, (size_t) rdata_size, (AvahiLookupResultFlags) flags, b->userdata); - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - dbus_error_free (&error); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} diff --git a/avahi-client/check-nss-test.c b/avahi-client/check-nss-test.c deleted file mode 100644 index 7c15500..0000000 --- a/avahi-client/check-nss-test.c +++ /dev/null @@ -1,31 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - printf("NSS Support available: %s\n", avahi_nss_support() ? "yes" : "no"); - return 0; -} diff --git a/avahi-client/check-nss.c b/avahi-client/check-nss.c deleted file mode 100644 index ea266c4..0000000 --- a/avahi-client/check-nss.c +++ /dev/null @@ -1,55 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_DLOPEN -#include -#endif -#include - -#include "client.h" - -int avahi_nss_support(void) { - int b = 0; - -#ifdef HAVE_DLOPEN - static const char * const libs[] = { - "libnss_mdns.so.2", - "libnss_mdns4.so.2", - "libnss_mdns6.so.2", - NULL }; - - const char * const *l; - - for (l = libs; *l; l++) { - void *dl; - - if ((dl = dlopen(*l, RTLD_LAZY))) { - b = 1; - dlclose(dl); - break; - } - } -#endif - - return b; -} diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c deleted file mode 100644 index 7d04a6a..0000000 --- a/avahi-client/client-test.c +++ /dev/null @@ -1,328 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -static const AvahiPoll *poll_api = NULL; -static AvahiSimplePoll *simple_poll = NULL; - -static void avahi_client_callback (AvahiClient *c, AvahiClientState state, void *userdata) { - printf ("CLIENT: Callback on %p, state -> %d, data -> %s\n", (void*) c, state, (char*)userdata); -} - -static void avahi_entry_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { - printf ("ENTRY-GROUP: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata); -} - -static void avahi_entry_group2_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { - printf ("ENTRY-GROUP2: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata); -} - -static void avahi_domain_browser_callback( - AvahiDomainBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - printf ("DOMAIN-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, domain ? domain : "NULL", (char*)userdata); -} - -static void avahi_service_resolver_callback( - AvahiServiceResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - char addr[64]; - char *txtr; - if (event == AVAHI_RESOLVER_FAILURE) { - printf ("SERVICE-RESOLVER: ServiceResolver %p timed out (%s %s)\n", (void*) r, name, type); - return; - } - avahi_address_snprint (addr, sizeof (addr), a); - txtr = avahi_string_list_to_string (txt); - printf ("SERVICE-RESOLVER: Callback on ServiceResolver, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), host_name (%s), address (%s), port (%d), txtdata (%s), data(%s)\n", interface, protocol, event, name, type, domain, host_name, addr, port, txtr, (char*)userdata); - avahi_free(txtr); -} - -static void avahi_service_browser_callback ( - AvahiServiceBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - const char *type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - AvahiServiceResolver *sr; - - printf ("SERVICE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, name ? name : "NULL", type, domain ? domain : "NULL", (char*)userdata); - - if (b && name) - { - sr = avahi_service_resolver_new (avahi_service_browser_get_client (b), interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, avahi_service_resolver_callback, (char*) "xxXXxx"); - printf("New service resolver %p\n", (void*) sr); - } -} - -static void avahi_service_type_browser_callback ( - AvahiServiceTypeBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - printf ("SERVICE-TYPE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, type ? type : "NULL", domain ? domain : "NULL", (char*)userdata); -} - -static void avahi_address_resolver_callback ( - AVAHI_GCC_UNUSED AvahiAddressResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const AvahiAddress *address, - const char *name, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - char addr[64]; - if (event == AVAHI_RESOLVER_FAILURE) { - printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n"); - return; - } - avahi_address_snprint (addr, sizeof (addr), address); - printf ("ADDRESS-RESOLVER: Callback on AddressResolver, interface (%d), protocol (%d), even (%d), address (%s), name (%s), data(%s)\n", interface, protocol, event, addr, name, (char*) userdata); -} - -static void avahi_host_name_resolver_callback ( - AvahiHostNameResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const AvahiAddress *a, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - AvahiClient *client; - AvahiAddressResolver *ar; - char addr[64]; - - if (event == AVAHI_RESOLVER_FAILURE) { - printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n"); - return; - } - client = avahi_host_name_resolver_get_client (r); -ar = avahi_address_resolver_new(client, interface, protocol, a, 0, avahi_address_resolver_callback, (char*) "omghai6u"); - if (ar) - { - printf ("Succesfully created address resolver object\n"); - } else { - printf ("Failed to create AddressResolver\n"); - } - avahi_address_snprint (addr, sizeof (addr), a); - printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, interface (%d), protocol (%d), event (%d), name (%s), address (%s), data (%s)\n", interface, protocol, event, name, addr, (char*)userdata); -} -static void test_free_domain_browser(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) -{ - AvahiServiceBrowser *b = userdata; - printf ("Freeing domain browser\n"); - avahi_service_browser_free (b); -} - -static void test_free_entry_group (AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) -{ - AvahiEntryGroup *g = userdata; - printf ("Freeing entry group\n"); - avahi_entry_group_free (g); -} - -static void test_entry_group_reset (AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) -{ - AvahiEntryGroup *g = userdata; - - printf ("Resetting entry group\n"); - avahi_entry_group_reset (g); - - avahi_entry_group_add_service (g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar2", NULL); - - avahi_entry_group_commit (g); -} - -static void test_entry_group_update(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) { - AvahiEntryGroup *g = userdata; - - printf ("Updating entry group\n"); - - avahi_entry_group_update_service_txt(g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, "foo=bar3", NULL); -} - -static void terminate(AVAHI_GCC_UNUSED AvahiTimeout *timeout, AVAHI_GCC_UNUSED void *userdata) { - - avahi_simple_poll_quit(simple_poll); -} - -int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - AvahiClient *avahi; - AvahiEntryGroup *group, *group2; - AvahiDomainBrowser *domain; - AvahiServiceBrowser *sb; - AvahiServiceTypeBrowser *st; - AvahiHostNameResolver *hnr; - AvahiAddress *aar; - const char *ret; - int error; - uint32_t cookie; - struct timeval tv; - AvahiAddress a; - - simple_poll = avahi_simple_poll_new(); - poll_api = avahi_simple_poll_get(simple_poll); - - if (!(avahi = avahi_client_new(poll_api, 0, avahi_client_callback, (char*) "omghai2u", &error))) { - fprintf(stderr, "Client failed: %s\n", avahi_strerror(error)); - goto fail; - } - - printf("State: %i\n", avahi_client_get_state(avahi)); - - ret = avahi_client_get_version_string (avahi); - printf("Avahi Server Version: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); - - ret = avahi_client_get_host_name (avahi); - printf("Host Name: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); - - ret = avahi_client_get_domain_name (avahi); - printf("Domain Name: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); - - ret = avahi_client_get_host_name_fqdn (avahi); - printf("FQDN: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); - - cookie = avahi_client_get_local_service_cookie(avahi); - printf("Local service cookie: %u (Error Return: %s)\n", cookie, cookie != AVAHI_SERVICE_COOKIE_INVALID ? "OK" : avahi_strerror(avahi_client_errno(avahi))); - - group = avahi_entry_group_new(avahi, avahi_entry_group_callback, (char*) "omghai"); - printf("Creating entry group: %s\n", group ? "OK" : avahi_strerror(avahi_client_errno (avahi))); - - assert(group); - - printf("Sucessfully created entry group %p\n", (void*) group); - - printf("%s\n", avahi_strerror(avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL))); - printf("add_record: %d\n", avahi_entry_group_add_record (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "TestX", 0x01, 0x10, 120, "\5booya", 6)); - - avahi_entry_group_commit (group); - - domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, (char*) "omghai3u"); - - if (domain == NULL) - printf ("Failed to create domain browser object\n"); - else - printf ("Sucessfully created domain browser %p\n", (void*) domain); - - st = avahi_service_type_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, 0, avahi_service_type_browser_callback, (char*) "omghai3u"); - if (st == NULL) - printf ("Failed to create service type browser object\n"); - else - printf ("Sucessfully created service type browser %p\n", (void*) st); - - sb = avahi_service_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, avahi_service_browser_callback, (char*) "omghai3u"); - if (sb == NULL) - printf ("Failed to create service browser object\n"); - else - printf ("Sucessfully created service browser %p\n", (void*) sb); - - hnr = avahi_host_name_resolver_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "ecstasy.local", AVAHI_PROTO_UNSPEC, 0, avahi_host_name_resolver_callback, (char*) "omghai4u"); - if (hnr == NULL) - printf ("Failed to create hostname resolver object\n"); - else - printf ("Successfully created hostname resolver object\n"); - - aar = avahi_address_parse ("224.0.0.251", AVAHI_PROTO_UNSPEC, &a); - if (aar == NULL) { - printf ("failed to create address object\n"); - } else { - group2 = avahi_entry_group_new (avahi, avahi_entry_group2_callback, (char*) "omghai222"); - if ((error = avahi_entry_group_add_address (group2, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "test-mdns.local.", aar)) < 0) - { - printf ("*** failed to add address to entry group: %s\n", avahi_strerror (error)); - avahi_entry_group_free (group2); - } else { - printf ("*** success, added address\n"); - avahi_entry_group_commit (group2); - } - } - - avahi_elapse_time(&tv, 8000, 0); - poll_api->timeout_new(poll_api, &tv, test_entry_group_reset, group); - avahi_elapse_time(&tv, 15000, 0); - poll_api->timeout_new(poll_api, &tv, test_entry_group_update, group); - avahi_elapse_time(&tv, 20000, 0); - poll_api->timeout_new(poll_api, &tv, test_free_entry_group, group); - avahi_elapse_time(&tv, 25000, 0); - poll_api->timeout_new(poll_api, &tv, test_free_domain_browser, sb); - - avahi_elapse_time(&tv, 30000, 0); - poll_api->timeout_new(poll_api, &tv, terminate, NULL); - - avahi_simple_poll_loop(simple_poll); - - printf("terminating...\n"); - -fail: - - if (avahi) - avahi_client_free (avahi); - - if (simple_poll) - avahi_simple_poll_free(simple_poll); - - return 0; -} diff --git a/avahi-client/client.c b/avahi-client/client.c deleted file mode 100644 index 70cc35d..0000000 --- a/avahi-client/client.c +++ /dev/null @@ -1,958 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "client.h" -#include "internal.h" - -#define AVAHI_CLIENT_DBUS_API_SUPPORTED ((uint32_t) 0x0201) - -static int init_server(AvahiClient *client, int *ret_error); - -int avahi_client_set_errno (AvahiClient *client, int error) { - assert(client); - - return client->error = error; -} - -int avahi_client_set_dbus_error(AvahiClient *client, DBusError *error) { - assert(client); - assert(error); - - return avahi_client_set_errno(client, avahi_error_dbus_to_number(error->name)); -} - -static void client_set_state(AvahiClient *client, AvahiClientState state) { - assert(client); - - if (client->state == state) - return; - - client->state = state; - - switch (client->state) { - case AVAHI_CLIENT_FAILURE: - if (client->bus) { -#ifdef HAVE_DBUS_CONNECTION_CLOSE - dbus_connection_close(client->bus); -#else - dbus_connection_disconnect(client->bus); -#endif - dbus_connection_unref(client->bus); - client->bus = NULL; - } - - /* Fall through */ - - case AVAHI_CLIENT_S_COLLISION: - case AVAHI_CLIENT_S_REGISTERING: - - /* Clear cached strings */ - avahi_free(client->host_name); - avahi_free(client->host_name_fqdn); - avahi_free(client->domain_name); - - client->host_name = NULL; - client->host_name_fqdn = NULL; - client->domain_name = NULL; - break; - - case AVAHI_CLIENT_S_RUNNING: - case AVAHI_CLIENT_CONNECTING: - break; - - } - - if (client->callback) - client->callback (client, state, client->userdata); -} - -static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message, void *userdata) { - AvahiClient *client = userdata; - DBusError error; - - assert(bus); - assert(message); - - dbus_error_init(&error); - -/* fprintf(stderr, "dbus: interface=%s, path=%s, member=%s\n", */ -/* dbus_message_get_interface (message), */ -/* dbus_message_get_path (message), */ -/* dbus_message_get_member (message)); */ - - if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) { - - /* The DBUS server died or kicked us */ - avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED); - goto fail; - - } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameAcquired")) { - - /* Ignore this message */ - - } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { - char *name, *old, *new; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &old, - DBUS_TYPE_STRING, &new, - DBUS_TYPE_INVALID) || dbus_error_is_set(&error)) { - - fprintf(stderr, "WARNING: Failed to parse NameOwnerChanged signal: %s\n", error.message); - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (strcmp(name, AVAHI_DBUS_NAME) == 0) { - - if (old[0] && - avahi_client_is_connected(client)) { - - /* Regardless if the server lost its name or - * if the name was transfered: our services are no longer - * available, so we disconnect ourselves */ - avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED); - goto fail; - - } else if (client->state == AVAHI_CLIENT_CONNECTING && (!old || *old == 0)) { - int ret; - - /* Server appeared */ - - if ((ret = init_server(client, NULL)) < 0) { - avahi_client_set_errno(client, ret); - goto fail; - } - } - } - - } else if (!avahi_client_is_connected(client)) { - - /* Ignore messages we get in unconnected state */ - - } else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_SERVER, "StateChanged")) { - int32_t state; - char *e = NULL; - int c; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_INT32, &state, - DBUS_TYPE_STRING, &e, - DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { - - fprintf(stderr, "WARNING: Failed to parse Server.StateChanged signal: %s\n", error.message); - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK) - avahi_client_set_errno(client, c); - - client_set_state(client, (AvahiClientState) state); - - } else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "StateChanged")) { - const char *path; - AvahiEntryGroup *g; - path = dbus_message_get_path(message); - - for (g = client->groups; g; g = g->groups_next) - if (strcmp(g->path, path) == 0) - break; - - if (g) { - int32_t state; - char *e; - int c; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_INT32, &state, - DBUS_TYPE_STRING, &e, - DBUS_TYPE_INVALID) || - dbus_error_is_set(&error)) { - - fprintf(stderr, "WARNING: Failed to parse EntryGroup.StateChanged signal: %s\n", error.message); - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK) - avahi_client_set_errno(client, c); - - avahi_entry_group_set_state(g, state); - } - - } else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemNew")) - return avahi_domain_browser_event(client, AVAHI_BROWSER_NEW, message); - else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemRemove")) - return avahi_domain_browser_event(client, AVAHI_BROWSER_REMOVE, message); - else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "CacheExhausted")) - return avahi_domain_browser_event(client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); - else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow")) - return avahi_domain_browser_event(client, AVAHI_BROWSER_ALL_FOR_NOW, message); - else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure")) - return avahi_domain_browser_event(client, AVAHI_BROWSER_FAILURE, message); - - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemNew")) - return avahi_service_type_browser_event (client, AVAHI_BROWSER_NEW, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemRemove")) - return avahi_service_type_browser_event (client, AVAHI_BROWSER_REMOVE, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "CacheExhausted")) - return avahi_service_type_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow")) - return avahi_service_type_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure")) - return avahi_service_type_browser_event (client, AVAHI_BROWSER_FAILURE, message); - - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemNew")) - return avahi_service_browser_event (client, AVAHI_BROWSER_NEW, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemRemove")) - return avahi_service_browser_event (client, AVAHI_BROWSER_REMOVE, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "CacheExhausted")) - return avahi_service_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow")) - return avahi_service_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure")) - return avahi_service_browser_event (client, AVAHI_BROWSER_FAILURE, message); - - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found")) - return avahi_service_resolver_event (client, AVAHI_RESOLVER_FOUND, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure")) - return avahi_service_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); - - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found")) - return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FOUND, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure")) - return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); - - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found")) - return avahi_address_resolver_event (client, AVAHI_RESOLVER_FOUND, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure")) - return avahi_address_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); - - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemNew")) - return avahi_record_browser_event (client, AVAHI_BROWSER_NEW, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemRemove")) - return avahi_record_browser_event (client, AVAHI_BROWSER_REMOVE, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "CacheExhausted")) - return avahi_record_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "AllForNow")) - return avahi_record_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); - else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Failure")) - return avahi_record_browser_event (client, AVAHI_BROWSER_FAILURE, message); - - else { - - fprintf(stderr, "WARNING: Unhandled message: interface=%s, path=%s, member=%s\n", - dbus_message_get_interface(message), - dbus_message_get_path(message), - dbus_message_get_member(message)); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - - if (dbus_error_is_set(&error)) { - avahi_client_set_errno(client, avahi_error_dbus_to_number(error.name)); - dbus_error_free(&error); - } - - client_set_state(client, AVAHI_CLIENT_FAILURE); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static int get_server_state(AvahiClient *client, int *ret_error) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - int32_t state; - int e = AVAHI_ERR_NO_MEMORY; - - assert(client); - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetState"))) - goto fail; - - reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); - - if (!reply || dbus_error_is_set (&error)) - goto fail; - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) - goto fail; - - client_set_state(client, (AvahiClientState) state); - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - if (dbus_error_is_set(&error)) { - e = avahi_error_dbus_to_number (error.name); - dbus_error_free(&error); - } - - if (ret_error) - *ret_error = e; - - if (message) - dbus_message_unref(message); - if (reply) - dbus_message_unref(reply); - - return e; -} - -static int check_version(AvahiClient *client, int *ret_error) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - uint32_t version; - int e = AVAHI_ERR_NO_MEMORY; - - assert(client); - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetAPIVersion"))) - goto fail; - - reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); - - if (!reply || dbus_error_is_set (&error)) { - char *version_str; - - if (!dbus_error_is_set(&error) || strcmp(error.name, DBUS_ERROR_UNKNOWN_METHOD)) - goto fail; - - /* If the method GetAPIVersion is not known, we look if - * GetVersionString matches "avahi 0.6" which is the only - * version we support which doesn't have GetAPIVersion() .*/ - - dbus_message_unref(message); - if (reply) dbus_message_unref(reply); - dbus_error_free(&error); - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetVersionString"))) - goto fail; - - reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); - - if (!reply || dbus_error_is_set (&error)) - goto fail; - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &version_str, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) - goto fail; - - version = strcmp(version_str, "avahi 0.6") == 0 ? 0x0201 : 0x0000; - - } else { - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &version, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error)) - goto fail; - } - - /*fprintf(stderr, "API Version 0x%04x\n", version);*/ - - if ((version & 0xFF00) != (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0xFF00) || - (version & 0x00FF) < (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0x00FF)) { - e = AVAHI_ERR_VERSION_MISMATCH; - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - if (dbus_error_is_set(&error)) { - e = avahi_error_dbus_to_number (error.name); - dbus_error_free(&error); - } - - if (ret_error) - *ret_error = e; - - if (message) - dbus_message_unref(message); - if (reply) - dbus_message_unref(reply); - - return e; -} - -static int init_server(AvahiClient *client, int *ret_error) { - int r; - - if ((r = check_version(client, ret_error)) < 0) - return r; - - if ((r = get_server_state(client, ret_error)) < 0) - return r; - - return AVAHI_OK; -} - -/* This function acts like dbus_bus_get but creates a private - * connection instead. */ -static DBusConnection* avahi_dbus_bus_get(DBusError *error) { - DBusConnection *c; - -#ifdef HAVE_DBUS_BUS_GET_PRIVATE - if (!(c = dbus_bus_get_private(DBUS_BUS_SYSTEM, error))) - return NULL; - - dbus_connection_set_exit_on_disconnect(c, FALSE); -#else - const char *a; - - if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a) - a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS; - - if (!(c = dbus_connection_open_private(a, error))) - return NULL; - - dbus_connection_set_exit_on_disconnect(c, FALSE); - - if (!dbus_bus_register(c, error)) { -#ifdef HAVE_DBUS_CONNECTION_CLOSE - dbus_connection_close(c); -#else - dbus_connection_disconnect(c); -#endif - dbus_connection_unref(c); - return NULL; - } -#endif - - return c; -} - -AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags, AvahiClientCallback callback, void *userdata, int *ret_error) { - AvahiClient *client = NULL; - DBusError error; - DBusMessage *message = NULL, *reply = NULL; - - avahi_init_i18n(); - - dbus_error_init(&error); - - if (!(client = avahi_new(AvahiClient, 1))) { - if (ret_error) - *ret_error = AVAHI_ERR_NO_MEMORY; - goto fail; - } - - client->poll_api = poll_api; - client->error = AVAHI_OK; - client->callback = callback; - client->userdata = userdata; - client->state = (AvahiClientState) -1; - client->flags = flags; - - client->host_name = NULL; - client->host_name_fqdn = NULL; - client->domain_name = NULL; - client->version_string = NULL; - client->local_service_cookie_valid = 0; - - AVAHI_LLIST_HEAD_INIT(AvahiEntryGroup, client->groups); - AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, client->domain_browsers); - AVAHI_LLIST_HEAD_INIT(AvahiServiceBrowser, client->service_browsers); - AVAHI_LLIST_HEAD_INIT(AvahiServiceTypeBrowser, client->service_type_browsers); - AVAHI_LLIST_HEAD_INIT(AvahiServiceResolver, client->service_resolvers); - AVAHI_LLIST_HEAD_INIT(AvahiHostNameResolver, client->host_name_resolvers); - AVAHI_LLIST_HEAD_INIT(AvahiAddressResolver, client->address_resolvers); - AVAHI_LLIST_HEAD_INIT(AvahiRecordBrowser, client->record_browsers); - - if (!(client->bus = avahi_dbus_bus_get(&error)) || dbus_error_is_set(&error)) { - if (ret_error) - *ret_error = AVAHI_ERR_DBUS_ERROR; - goto fail; - } - - if (avahi_dbus_connection_glue(client->bus, poll_api) < 0) { - if (ret_error) - *ret_error = AVAHI_ERR_NO_MEMORY; /* Not optimal */ - goto fail; - } - - if (!dbus_connection_add_filter(client->bus, filter_func, client, NULL)) { - if (ret_error) - *ret_error = AVAHI_ERR_NO_MEMORY; - goto fail; - } - - dbus_bus_add_match( - client->bus, - "type='signal', " - "interface='" AVAHI_DBUS_INTERFACE_SERVER "', " - "sender='" AVAHI_DBUS_NAME "', " - "path='" AVAHI_DBUS_PATH_SERVER "'", - &error); - - if (dbus_error_is_set(&error)) - goto fail; - - dbus_bus_add_match ( - client->bus, - "type='signal', " - "interface='" DBUS_INTERFACE_DBUS "', " - "sender='" DBUS_SERVICE_DBUS "', " - "path='" DBUS_PATH_DBUS "'", - &error); - - if (dbus_error_is_set(&error)) - goto fail; - - dbus_bus_add_match( - client->bus, - "type='signal', " - "interface='" DBUS_INTERFACE_LOCAL "'", - &error); - - if (dbus_error_is_set(&error)) - goto fail; - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, "org.freedesktop.DBus.Peer", "Ping"))) - goto fail; - - reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); - - if (!reply || dbus_error_is_set (&error)) { - /* We free the error so its not set, that way the fail target - * will return the NO_DAEMON error rather than a DBUS error */ - dbus_error_free(&error); - - if (!(flags & AVAHI_CLIENT_NO_FAIL)) { - - if (ret_error) - *ret_error = AVAHI_ERR_NO_DAEMON; - - goto fail; - } - - /* The user doesn't want this call to fail if the daemon is not - * available, so let's return succesfully */ - client_set_state(client, AVAHI_CLIENT_CONNECTING); - - } else { - - if (init_server(client, ret_error) < 0) - goto fail; - } - - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return client; - -fail: - - if (message) - dbus_message_unref(message); - if (reply) - dbus_message_unref(reply); - - if (client) - avahi_client_free(client); - - if (dbus_error_is_set(&error)) { - - if (ret_error) { - if (strcmp(error.name, DBUS_ERROR_FILE_NOT_FOUND) == 0) - /* DBUS returns this error when the DBUS daemon is not running */ - *ret_error = AVAHI_ERR_NO_DAEMON; - else - *ret_error = avahi_error_dbus_to_number(error.name); - } - - dbus_error_free(&error); - } - - return NULL; -} - -void avahi_client_free(AvahiClient *client) { - assert(client); - - if (client->bus) - /* Disconnect in advance, so that the free() functions won't - * issue needless server calls */ -#ifdef HAVE_DBUS_CONNECTION_CLOSE - dbus_connection_close(client->bus); -#else - dbus_connection_disconnect(client->bus); -#endif - - while (client->groups) - avahi_entry_group_free(client->groups); - - while (client->domain_browsers) - avahi_domain_browser_free(client->domain_browsers); - - while (client->service_browsers) - avahi_service_browser_free(client->service_browsers); - - while (client->service_type_browsers) - avahi_service_type_browser_free(client->service_type_browsers); - - while (client->service_resolvers) - avahi_service_resolver_free(client->service_resolvers); - - while (client->host_name_resolvers) - avahi_host_name_resolver_free(client->host_name_resolvers); - - while (client->address_resolvers) - avahi_address_resolver_free(client->address_resolvers); - - while (client->record_browsers) - avahi_record_browser_free(client->record_browsers); - - if (client->bus) - dbus_connection_unref(client->bus); - - avahi_free(client->version_string); - avahi_free(client->host_name); - avahi_free(client->host_name_fqdn); - avahi_free(client->domain_name); - - avahi_free(client); -} - -static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const char *method, const char *param) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - char *ret, *n; - - assert(client); - assert(method); - - dbus_error_init (&error); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, method))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (param) { - if (!dbus_message_append_args (message, DBUS_TYPE_STRING, ¶m, DBUS_TYPE_INVALID)) { - avahi_client_set_errno (client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - } - - reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); - - if (!reply || dbus_error_is_set (&error)) - goto fail; - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &ret, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) - goto fail; - - if (!(n = avahi_strdup(ret))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return n; - -fail: - - if (message) - dbus_message_unref(message); - if (reply) - dbus_message_unref(reply); - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - return NULL; -} - -const char* avahi_client_get_version_string(AvahiClient *client) { - assert(client); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - return NULL; - } - - if (!client->version_string) - client->version_string = avahi_client_get_string_reply_and_block(client, "GetVersionString", NULL); - - return client->version_string; -} - -const char* avahi_client_get_domain_name(AvahiClient *client) { - assert(client); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - return NULL; - } - - if (!client->domain_name) - client->domain_name = avahi_client_get_string_reply_and_block(client, "GetDomainName", NULL); - - return client->domain_name; -} - -const char* avahi_client_get_host_name(AvahiClient *client) { - assert(client); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - return NULL; - } - - if (!client->host_name) - client->host_name = avahi_client_get_string_reply_and_block(client, "GetHostName", NULL); - - return client->host_name; -} - -const char* avahi_client_get_host_name_fqdn (AvahiClient *client) { - assert(client); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - return NULL; - } - - if (!client->host_name_fqdn) - client->host_name_fqdn = avahi_client_get_string_reply_and_block(client, "GetHostNameFqdn", NULL); - - return client->host_name_fqdn; -} - -AvahiClientState avahi_client_get_state(AvahiClient *client) { - assert(client); - - return client->state; -} - -int avahi_client_errno(AvahiClient *client) { - assert(client); - - return client->error; -} - -/* Just for internal use */ -int avahi_client_simple_method_call(AvahiClient *client, const char *path, const char *interface, const char *method) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - int r = AVAHI_OK; - - dbus_error_init(&error); - - assert(client); - assert(path); - assert(interface); - assert(method); - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, path, interface, method))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} - -uint32_t avahi_client_get_local_service_cookie(AvahiClient *client) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - assert(client); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - return AVAHI_SERVICE_COOKIE_INVALID; - } - - if (client->local_service_cookie_valid) - return client->local_service_cookie; - - dbus_error_init (&error); - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetLocalServiceCookie"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); - - if (!reply || dbus_error_is_set (&error)) - goto fail; - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &client->local_service_cookie, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) - goto fail; - - dbus_message_unref(message); - dbus_message_unref(reply); - - client->local_service_cookie_valid = 1; - return client->local_service_cookie; - -fail: - - if (message) - dbus_message_unref(message); - if (reply) - dbus_message_unref(reply); - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - return AVAHI_SERVICE_COOKIE_INVALID; -} - -int avahi_client_is_connected(AvahiClient *client) { - assert(client); - - return - client->bus && - dbus_connection_get_is_connected(client->bus) && - (client->state == AVAHI_CLIENT_S_RUNNING || client->state == AVAHI_CLIENT_S_REGISTERING || client->state == AVAHI_CLIENT_S_COLLISION); -} - -int avahi_client_set_host_name(AvahiClient* client, const char *name) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - - assert(client); - - if (!avahi_client_is_connected(client)) - return avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - - dbus_error_init (&error); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "SetHostName"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!dbus_message_append_args (message, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { - avahi_client_set_errno (client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error); - - if (!reply || dbus_error_is_set (&error)) - goto fail; - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) - goto fail; - - dbus_message_unref(message); - dbus_message_unref(reply); - - avahi_free(client->host_name); - client->host_name = NULL; - avahi_free(client->host_name_fqdn); - client->host_name_fqdn = NULL; - - return 0; - -fail: - - if (message) - dbus_message_unref(message); - if (reply) - dbus_message_unref(reply); - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - return client->error; -} diff --git a/avahi-client/client.h b/avahi-client/client.h deleted file mode 100644 index 1039da5..0000000 --- a/avahi-client/client.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef fooclienthfoo -#define fooclienthfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include -#include -#include -#include -#include -#include - -/** \file client.h Definitions and functions for the client API over D-Bus */ - -AVAHI_C_DECL_BEGIN - -/** A connection context */ -typedef struct AvahiClient AvahiClient; - -/** States of a client object, a superset of AvahiServerState */ -typedef enum { - AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, /**< Server state: REGISTERING */ - AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */ - AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */ - AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */ - AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ -} AvahiClientState; - -typedef enum { - AVAHI_CLIENT_IGNORE_USER_CONFIG = 1, /**< Don't read user configuration */ - AVAHI_CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter AVAHI_CLIENT_CONNECTING state and wait for the daemon to appear */ -} AvahiClientFlags; - -/** The function prototype for the callback of an AvahiClient */ -typedef void (*AvahiClientCallback) ( - AvahiClient *s, - AvahiClientState state /**< The new state of the client */, - void* userdata /**< The user data that was passed to avahi_client_new() */); - -/** @{ \name Construction and destruction */ - -/** Creates a new client instance */ -AvahiClient* avahi_client_new ( - const AvahiPoll *poll_api /**< The abstract event loop API to use */, - AvahiClientFlags flags /**< Some flags to modify the behaviour of the client library */, - AvahiClientCallback callback /**< A callback that is called whenever the state of the client changes. This may be NULL. Please note that this function is called for the first time from within the avahi_client_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_client_new(). A common mistake is to store the AvahiClient pointer returned by avahi_client_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiClient pointer passed to the callback function instead of the global pointer. */, - void *userdata /**< Some arbitrary user data pointer that will be passed to the callback function */, - int *error /**< If creation of the client fails, this integer will contain the error cause. May be NULL if you aren't interested in the reason why avahi_client_new() failed. */); - -/** Free a client instance. This will automatically free all - * associated browser, resolve and entry group objects. All pointers - * to such objects become invalid! */ -void avahi_client_free(AvahiClient *client); - -/** @} */ - -/** @{ \name Properties */ - -/** Get the version of the server */ -const char* avahi_client_get_version_string (AvahiClient*); - -/** Get host name */ -const char* avahi_client_get_host_name (AvahiClient*); - -/** Set host name. \since 0.6.13 */ -int avahi_client_set_host_name(AvahiClient*, const char *name); - -/** Get domain name */ -const char* avahi_client_get_domain_name (AvahiClient*); - -/** Get FQDN domain name */ -const char* avahi_client_get_host_name_fqdn (AvahiClient*); - -/** Get state */ -AvahiClientState avahi_client_get_state(AvahiClient *client); - -/** @{ \name Error Handling */ - -/** Get the last error number. See avahi_strerror() for converting this error code into a human readable string. */ -int avahi_client_errno (AvahiClient*); - -/** @} */ - -/** \cond fulldocs */ -/** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */ -uint32_t avahi_client_get_local_service_cookie(AvahiClient *client); -/** \endcond */ - -/** @{ \name Libc NSS Support */ - -/** Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise. \since 0.6.5 */ -int avahi_nss_support(void); - -/** @} */ - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-client/entrygroup.c b/avahi-client/entrygroup.c deleted file mode 100644 index d809d60..0000000 --- a/avahi-client/entrygroup.c +++ /dev/null @@ -1,890 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "client.h" -#include "internal.h" - -void avahi_entry_group_set_state(AvahiEntryGroup *group, AvahiEntryGroupState state) { - assert(group); - - if (group->state_valid && group->state == state) - return; - - group->state = state; - group->state_valid = 1; - - if (group->callback) - group->callback(group, state, group->userdata); -} - -static int retrieve_state(AvahiEntryGroup *group) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - int r = AVAHI_OK; - int32_t state; - AvahiClient *client; - - dbus_error_init(&error); - - assert(group); - client = group->client; - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState"))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return state; - -fail: - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} - -AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCallback callback, void *userdata) { - AvahiEntryGroup *group = NULL; - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - char *path; - int state; - - assert(client); - - dbus_error_init (&error); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!(group = avahi_new(AvahiEntryGroup, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - group->client = client; - group->callback = callback; - group->userdata = userdata; - group->state_valid = 0; - group->path = NULL; - AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, client->groups, group); - - if (!(message = dbus_message_new_method_call( - AVAHI_DBUS_NAME, - AVAHI_DBUS_PATH_SERVER, - AVAHI_DBUS_INTERFACE_SERVER, - "EntryGroupNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(group->path = avahi_strdup (path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if ((state = retrieve_state(group)) < 0) { - avahi_client_set_errno(client, state); - goto fail; - } - - avahi_entry_group_set_state(group, (AvahiEntryGroupState) state); - - dbus_message_unref(message); - dbus_message_unref(reply); - - return group; - -fail: - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (group) - avahi_entry_group_free(group); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; -} - -static int entry_group_simple_method_call(AvahiEntryGroup *group, const char *method) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - int r = AVAHI_OK; - AvahiClient *client; - - dbus_error_init(&error); - - assert(group); - client = group->client; - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, method))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} - -int avahi_entry_group_free(AvahiEntryGroup *group) { - AvahiClient *client = group->client; - int r = AVAHI_OK; - - assert(group); - - if (group->path && avahi_client_is_connected(client)) - r = entry_group_simple_method_call(group, "Free"); - - AVAHI_LLIST_REMOVE(AvahiEntryGroup, groups, client->groups, group); - - avahi_free(group->path); - avahi_free(group); - - return r; -} - -int avahi_entry_group_commit(AvahiEntryGroup *group) { - int ret; - assert(group); - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - if ((ret = entry_group_simple_method_call(group, "Commit")) < 0) - return ret; - - group->state_valid = 0; - return ret; -} - -int avahi_entry_group_reset(AvahiEntryGroup *group) { - int ret; - assert(group); - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - if ((ret = entry_group_simple_method_call(group, "Reset")) < 0) - return ret; - - group->state_valid = 0; - return ret; -} - -int avahi_entry_group_get_state (AvahiEntryGroup *group) { - assert (group); - - if (group->state_valid) - return group->state; - - return retrieve_state(group); -} - -AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup *group) { - assert(group); - - return group->client; -} - -int avahi_entry_group_is_empty (AvahiEntryGroup *group) { - DBusMessage *message = NULL, *reply = NULL; - DBusError error; - int r = AVAHI_OK; - int b; - AvahiClient *client; - - assert(group); - client = group->client; - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty"))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return !!b; - -fail: - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} - -static int append_rdata(DBusMessage *message, const void *rdata, size_t size) { - DBusMessageIter iter, sub; - - assert(message); - - dbus_message_iter_init_append(message, &iter); - - if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) || - !(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) || - !(dbus_message_iter_close_container(&iter, &sub))) - return -1; - - return 0; -} - -static int append_string_list(DBusMessage *message, AvahiStringList *txt) { - DBusMessageIter iter, sub; - int r = -1; - AvahiStringList *p; - - assert(message); - - dbus_message_iter_init_append(message, &iter); - - /* Reverse the string list, so that we can pass it in-order to the server */ - txt = avahi_string_list_reverse(txt); - - if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub)) - goto fail; - - /* Assemble the AvahiStringList into an Array of Array of Bytes to send over dbus */ - for (p = txt; p != NULL; p = p->next) { - DBusMessageIter sub2; - const uint8_t *data = p->text; - - if (!(dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2)) || - !(dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size)) || - !(dbus_message_iter_close_container(&sub, &sub2))) - goto fail; - } - - if (!dbus_message_iter_close_container(&iter, &sub)) - goto fail; - - r = 0; - -fail: - - /* Reverse the string list to the original state */ - txt = avahi_string_list_reverse(txt); - - return r; -} - -int avahi_entry_group_add_service_strlst( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - const char *host, - uint16_t port, - AvahiStringList *txt) { - - DBusMessage *message = NULL, *reply = NULL; - int r = AVAHI_OK; - DBusError error; - AvahiClient *client; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(group); - assert(name); - assert(type); - - client = group->client; - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - if (!domain) - domain = ""; - - if (!host) - host = ""; - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService"))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_STRING, &host, - DBUS_TYPE_UINT16, &port, - DBUS_TYPE_INVALID) || - append_string_list(message, txt) < 0) { - r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} - -int avahi_entry_group_add_service( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - const char *host, - uint16_t port, - ...) { - - va_list va; - int r; - AvahiStringList *txt; - - assert(group); - - va_start(va, port); - txt = avahi_string_list_new_va(va); - r = avahi_entry_group_add_service_strlst(group, interface, protocol, flags, name, type, domain, host, port, txt); - avahi_string_list_free(txt); - va_end(va); - return r; -} - -int avahi_entry_group_add_service_subtype( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - const char *subtype) { - - DBusMessage *message = NULL, *reply = NULL; - int r = AVAHI_OK; - DBusError error; - AvahiClient *client; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(group); - assert(name); - assert(type); - assert(subtype); - - client = group->client; - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - if (!domain) - domain = ""; - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype"))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_STRING, &subtype, - DBUS_TYPE_INVALID)) { - r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; - -} - -int avahi_entry_group_update_service_txt( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - ...) { - - va_list va; - int r; - AvahiStringList *txt; - - va_start(va, domain); - txt = avahi_string_list_new_va(va); - r = avahi_entry_group_update_service_txt_strlst(group, interface, protocol, flags, name, type, domain, txt); - avahi_string_list_free(txt); - va_end(va); - return r; -} - -int avahi_entry_group_update_service_txt_strlst( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - AvahiStringList *txt) { - - DBusMessage *message = NULL, *reply = NULL; - int r = AVAHI_OK; - DBusError error; - AvahiClient *client; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(group); - assert(name); - assert(type); - - client = group->client; - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - if (!domain) - domain = ""; - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt"))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INVALID) || - append_string_list(message, txt) < 0) { - r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} - -/** Add a host/address pair */ -int avahi_entry_group_add_address( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const AvahiAddress *a) { - - DBusMessage *message = NULL, *reply = NULL; - int r = AVAHI_OK; - DBusError error; - AvahiClient *client; - int32_t i_interface, i_protocol; - uint32_t u_flags; - char s_address[AVAHI_ADDRESS_STR_MAX]; - char *p_address = s_address; - - assert(name); - - client = group->client; - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress"))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!avahi_address_snprint (s_address, sizeof (s_address), a)) - { - r = avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS); - goto fail; - } - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &p_address, - DBUS_TYPE_INVALID)) { - r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} - -/** Add an arbitrary record */ -int avahi_entry_group_add_record( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - uint16_t clazz, - uint16_t type, - uint32_t ttl, - const void *rdata, - size_t size) { - - DBusMessage *message = NULL, *reply = NULL; - int r = AVAHI_OK; - DBusError error; - AvahiClient *client; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(name); - - client = group->client; - - if (!group->path || !avahi_client_is_connected(group->client)) - return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); - - dbus_error_init(&error); - - if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord"))) { - r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT16, &clazz, - DBUS_TYPE_UINT16, &type, - DBUS_TYPE_UINT32, &ttl, - DBUS_TYPE_INVALID) || append_rdata(message, rdata, size) < 0) { - r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return AVAHI_OK; - -fail: - - if (dbus_error_is_set(&error)) { - r = avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return r; -} diff --git a/avahi-client/internal.h b/avahi-client/internal.h deleted file mode 100644 index e5f3beb..0000000 --- a/avahi-client/internal.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef foointernalhfoo -#define foointernalhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include "client.h" -#include "lookup.h" -#include "publish.h" - -struct AvahiClient { - const AvahiPoll *poll_api; - DBusConnection *bus; - int error; - AvahiClientState state; - AvahiClientFlags flags; - - /* Cache for some seldom changing server data */ - char *version_string, *host_name, *host_name_fqdn, *domain_name; - uint32_t local_service_cookie; - int local_service_cookie_valid; - - AvahiClientCallback callback; - void *userdata; - - AVAHI_LLIST_HEAD(AvahiEntryGroup, groups); - AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers); - AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers); - AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers); - AVAHI_LLIST_HEAD(AvahiServiceResolver, service_resolvers); - AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers); - AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers); - AVAHI_LLIST_HEAD(AvahiRecordBrowser, record_browsers); -}; - -struct AvahiEntryGroup { - char *path; - AvahiEntryGroupState state; - int state_valid; - AvahiClient *client; - AvahiEntryGroupCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups); -}; - -struct AvahiDomainBrowser { - int ref; - - char *path; - AvahiClient *client; - AvahiDomainBrowserCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiDomainBrowser, domain_browsers); - - AvahiIfIndex interface; - AvahiProtocol protocol; - - AvahiTimeout *defer_timeout; - - AvahiStringList *static_browse_domains; -}; - -struct AvahiServiceBrowser { - char *path; - AvahiClient *client; - AvahiServiceBrowserCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiServiceBrowser, service_browsers); - - char *type, *domain; - AvahiIfIndex interface; - AvahiProtocol protocol; -}; - -struct AvahiServiceTypeBrowser { - char *path; - AvahiClient *client; - AvahiServiceTypeBrowserCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiServiceTypeBrowser, service_type_browsers); - - char *domain; - AvahiIfIndex interface; - AvahiProtocol protocol; -}; - -struct AvahiServiceResolver { - char *path; - AvahiClient *client; - AvahiServiceResolverCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiServiceResolver, service_resolvers); - - char *name, *type, *domain; - AvahiIfIndex interface; - AvahiProtocol protocol; -}; - -struct AvahiHostNameResolver { - char *path; - AvahiClient *client; - AvahiHostNameResolverCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiHostNameResolver, host_name_resolvers); - - char *host_name; - AvahiIfIndex interface; - AvahiProtocol protocol; -}; - -struct AvahiAddressResolver { - char *path; - AvahiClient *client; - AvahiAddressResolverCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiAddressResolver, address_resolvers); - - AvahiAddress address; - AvahiIfIndex interface; - AvahiProtocol protocol; -}; - -struct AvahiRecordBrowser { - char *path; - AvahiClient *client; - AvahiRecordBrowserCallback callback; - void *userdata; - AVAHI_LLIST_FIELDS(AvahiRecordBrowser, record_browsers); - - char *name; - uint16_t clazz, type; - AvahiIfIndex interface; - AvahiProtocol protocol; -}; - -int avahi_client_set_errno (AvahiClient *client, int error); -int avahi_client_set_dbus_error(AvahiClient *client, DBusError *error); - -void avahi_entry_group_set_state(AvahiEntryGroup *group, AvahiEntryGroupState state); - -DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); -DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); -DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); -DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); - -DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message); -DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message); -DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message); - -int avahi_client_simple_method_call(AvahiClient *client, const char *path, const char *interface, const char *method); - -int avahi_client_is_connected(AvahiClient *client); - -#endif diff --git a/avahi-client/lookup.h b/avahi-client/lookup.h deleted file mode 100644 index 52407f4..0000000 --- a/avahi-client/lookup.h +++ /dev/null @@ -1,314 +0,0 @@ -#ifndef fooclientlookuphfoo -#define fooclientlookuphfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include -#include -#include -#include -#include -#include - -#include - -/** \file avahi-client/lookup.h Lookup Client API */ - -/** \example client-browse-services.c Example how to browse for DNS-SD - * services using the client interface to avahi-daemon. */ - -AVAHI_C_DECL_BEGIN - -/** @{ \name Domain Browser */ - -/** A domain browser object */ -typedef struct AvahiDomainBrowser AvahiDomainBrowser; - -/** The function prototype for the callback of an AvahiDomainBrowser */ -typedef void (*AvahiDomainBrowserCallback) ( - AvahiDomainBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *domain, - AvahiLookupResultFlags flags, - void *userdata); - -/** Browse for domains on the local network */ -AvahiDomainBrowser* avahi_domain_browser_new ( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *domain, - AvahiDomainBrowserType btype, - AvahiLookupFlags flags, - AvahiDomainBrowserCallback callback, - void *userdata); - -/** Get the parent client of an AvahiDomainBrowser object */ -AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *); - -/** Cleans up and frees an AvahiDomainBrowser object */ -int avahi_domain_browser_free (AvahiDomainBrowser *); - -/** @} */ - -/** @{ \name Service Browser */ - -/** A service browser object */ -typedef struct AvahiServiceBrowser AvahiServiceBrowser; - -/** The function prototype for the callback of an AvahiServiceBrowser */ -typedef void (*AvahiServiceBrowserCallback) ( - AvahiServiceBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - const char *type, - const char *domain, - AvahiLookupResultFlags flags, - void *userdata); - -/** Browse for services of a type on the network. In most cases you - * probably want to pass AVAHI_IF_UNSPEC and AVAHI_PROTO_UNSPED in - * interface, resp. protocol to browse on all local networks. The - * specified callback will be called whenever a new service appears - * or is removed from the network. Please note that events may be - * collapsed to minimize traffic (i.e. a REMOVED followed by a NEW for - * the same service data is dropped because redundant). If you want to - * subscribe to service data changes, you should use - * avahi_service_resolver_new() and keep it open, in which case you - * will be notified via AVAHI_RESOLVE_FOUND everytime the service data - * changes. */ -AvahiServiceBrowser* avahi_service_browser_new ( - AvahiClient *client, - AvahiIfIndex interface, /**< In most cases pass AVAHI_IF_UNSPEC here */ - AvahiProtocol protocol, /**< In most cases pass AVAHI_PROTO_UNSPEC here */ - const char *type, /**< A service type such as "_http._tcp" */ - const char *domain, /**< A domain to browse in. In most cases you want to pass NULL here for the default domain (usually ".local") */ - AvahiLookupFlags flags, - AvahiServiceBrowserCallback callback, - void *userdata); - -/** Get the parent client of an AvahiServiceBrowser object */ -AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *); - -/** Cleans up and frees an AvahiServiceBrowser object */ -int avahi_service_browser_free (AvahiServiceBrowser *); - -/** @} */ - -/** \cond fulldocs */ -/** A service type browser object */ -typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser; - -/** The function prototype for the callback of an AvahiServiceTypeBrowser */ -typedef void (*AvahiServiceTypeBrowserCallback) ( - AvahiServiceTypeBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *type, - const char *domain, - AvahiLookupResultFlags flags, - void *userdata); - -/** Browse for service types on the local network */ -AvahiServiceTypeBrowser* avahi_service_type_browser_new ( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *domain, - AvahiLookupFlags flags, - AvahiServiceTypeBrowserCallback callback, - void *userdata); - -/** Get the parent client of an AvahiServiceTypeBrowser object */ -AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *); - -/** Cleans up and frees an AvahiServiceTypeBrowser object */ -int avahi_service_type_browser_free (AvahiServiceTypeBrowser *); - -/** \endcond */ - -/** @{ \name Service Resolver */ - -/** A service resolver object */ -typedef struct AvahiServiceResolver AvahiServiceResolver; - -/** The function prototype for the callback of an AvahiServiceResolver */ -typedef void (*AvahiServiceResolverCallback) ( - AvahiServiceResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AvahiLookupResultFlags flags, - void *userdata); - -/** Create a new service resolver object. Please make sure to pass all - * the service data you received via avahi_service_browser_new()'s - * callback function, especially interface and protocol. The protocol - * argument specifies the protocol (IPv4 or IPv6) to use as transport - * for the queries which are sent out by this resolver. The - * aprotocol argument specifies the adress family (IPv4 or IPv6) of - * the address of the service we are looking for. Generally, on - * "protocol" you should only pass what was supplied to you as - * parameter to your AvahiServiceBrowserCallback. In "aprotocol" you - * should pass what your application code can deal with when - * connecting to the service. Or, more technically speaking: protocol - * specifies if the mDNS queries should be sent as UDP/IPv4 - * resp. UDP/IPv6 packets. aprotocol specifies whether the query is for a A - * resp. AAAA resource record. */ -AvahiServiceResolver * avahi_service_resolver_new( - AvahiClient *client, - AvahiIfIndex interface, /**< Pass the interface argument you received in AvahiServiceBrowserCallback here. */ - AvahiProtocol protocol, /**< Pass the protocol argument you received in AvahiServiceBrowserCallback here. */ - const char *name, /**< Pass the name argument you received in AvahiServiceBrowserCallback here. */ - const char *type, /**< Pass the type argument you received in AvahiServiceBrowserCallback here. */ - const char *domain, /**< Pass the domain argument you received in AvahiServiceBrowserCallback here. */ - AvahiProtocol aprotocol, /**< The desired address family of the service address to resolve. AVAHI_PROTO_UNSPEC if your application can deal with both IPv4 and IPv6 */ - AvahiLookupFlags flags, - AvahiServiceResolverCallback callback, - void *userdata); - -/** Get the parent client of an AvahiServiceResolver object */ -AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *); - -/** Free a service resolver object */ -int avahi_service_resolver_free(AvahiServiceResolver *r); - -/** @} */ - -/** \cond fulldocs */ -/** A service resolver object */ -typedef struct AvahiHostNameResolver AvahiHostNameResolver; - -/** The function prototype for the callback of an AvahiHostNameResolver */ -typedef void (*AvahiHostNameResolverCallback) ( - AvahiHostNameResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const AvahiAddress *a, - AvahiLookupResultFlags flags, - void *userdata); - -/** Create a new hostname resolver object */ -AvahiHostNameResolver * avahi_host_name_resolver_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *name, - AvahiProtocol aprotocol, - AvahiLookupFlags flags, - AvahiHostNameResolverCallback callback, - void *userdata); - -/** Get the parent client of an AvahiHostNameResolver object */ -AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *); - -/** Free a hostname resolver object */ -int avahi_host_name_resolver_free(AvahiHostNameResolver *r); - -/** An address resolver object */ -typedef struct AvahiAddressResolver AvahiAddressResolver; - -/** The function prototype for the callback of an AvahiAddressResolver */ -typedef void (*AvahiAddressResolverCallback) ( - AvahiAddressResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const AvahiAddress *a, - const char *name, - AvahiLookupResultFlags flags, - void *userdata); - -/** Create a new address resolver object from an AvahiAddress object */ -AvahiAddressResolver* avahi_address_resolver_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const AvahiAddress *a, - AvahiLookupFlags flags, - AvahiAddressResolverCallback callback, - void *userdata); - -/** Get the parent client of an AvahiAddressResolver object */ -AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *); - -/** Free a AvahiAddressResolver resolver object */ -int avahi_address_resolver_free(AvahiAddressResolver *r); - -/** \endcond */ - -/** @{ \name Record Browser */ - -/** A record browser object */ -typedef struct AvahiRecordBrowser AvahiRecordBrowser; - -/** The function prototype for the callback of an AvahiRecordBrowser */ -typedef void (*AvahiRecordBrowserCallback) ( - AvahiRecordBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - uint16_t clazz, - uint16_t type, - const void *rdata, - size_t size, - AvahiLookupResultFlags flags, - void *userdata); - -/** Browse for records of a type on the local network */ -AvahiRecordBrowser* avahi_record_browser_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *name, - uint16_t clazz, - uint16_t type, - AvahiLookupFlags flags, - AvahiRecordBrowserCallback callback, - void *userdata); - -/** Get the parent client of an AvahiRecordBrowser object */ -AvahiClient* avahi_record_browser_get_client(AvahiRecordBrowser *); - -/** Cleans up and frees an AvahiRecordBrowser object */ -int avahi_record_browser_free(AvahiRecordBrowser *); - -/** @} */ - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-client/publish.h b/avahi-client/publish.h deleted file mode 100644 index ea731f2..0000000 --- a/avahi-client/publish.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef fooclientpublishhfoo -#define fooclientpublishhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include -#include -#include -#include -#include -#include - -#include - -/** \file avahi-client/publish.h Publishing Client API */ - -/** \example client-publish-service.c Example how to register a DNS-SD - * service using the client interface to avahi-daemon. It behaves like a network - * printer registering both an IPP and a BSD LPR service. */ - -AVAHI_C_DECL_BEGIN - -/** An entry group object */ -typedef struct AvahiEntryGroup AvahiEntryGroup; - -/** The function prototype for the callback of an AvahiEntryGroup */ -typedef void (*AvahiEntryGroupCallback) ( - AvahiEntryGroup *g, - AvahiEntryGroupState state /**< The new state of the entry group */, - void* userdata /* The arbitrary user data pointer originally passed to avahi_entry_group_new()*/); - -/** @{ \name Construction and destruction */ - -/** Create a new AvahiEntryGroup object */ -AvahiEntryGroup* avahi_entry_group_new( - AvahiClient* c, - AvahiEntryGroupCallback callback /**< This callback is called whenever the state of this entry group changes. May not be NULL. Please note that this function is called for the first time from within the avahi_entry_group_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_entry_group_new(). A common mistake is to store the AvahiEntryGroup pointer returned by avahi_entry_group_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiEntryGroup pointer passed to the callback function instead of the global pointer. */, - void *userdata /**< This arbitrary user data pointer will be passed to the callback functon */); - -/** Clean up and free an AvahiEntryGroup object */ -int avahi_entry_group_free (AvahiEntryGroup *); - -/** @} */ - -/** @{ \name State */ - -/** Commit an AvahiEntryGroup. The entries in the entry group are now registered on the network. Commiting empty entry groups is considered an error. */ -int avahi_entry_group_commit (AvahiEntryGroup*); - -/** Reset an AvahiEntryGroup. This takes effect immediately. */ -int avahi_entry_group_reset (AvahiEntryGroup*); - -/** Get an AvahiEntryGroup's state */ -int avahi_entry_group_get_state (AvahiEntryGroup*); - -/** Check if an AvahiEntryGroup is empty */ -int avahi_entry_group_is_empty (AvahiEntryGroup*); - -/** Get an AvahiEntryGroup's owning client instance */ -AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*); - -/** @} */ - -/** @{ \name Adding and updating entries */ - -/** Add a service. Takes a variable NULL terminated list of TXT record strings as last arguments. Please note that this service is not announced on the network before avahi_entry_group_commit() is called. */ -int avahi_entry_group_add_service( - AvahiEntryGroup *group, - AvahiIfIndex interface /**< The interface this service shall be announced on. We recommend to pass AVAHI_IF_UNSPEC here, to announce on all interfaces. */, - AvahiProtocol protocol /**< The protocol this service shall be announced with, i.e. MDNS over IPV4 or MDNS over IPV6. We recommend to pass AVAHI_PROTO_UNSPEC here, to announce this service on all protocols the daemon supports. */, - AvahiPublishFlags flags /**< Usually 0, unless you know what you do */, - const char *name /**< The name for the new service. Must be valid service name. i.e. a string shorter than 63 characters and valid UTF-8. May not be NULL. */, - const char *type /**< The service type for the new service, such as _http._tcp. May not be NULL. */, - const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, - const char *host /**< The host this services is residing on. We recommend to pass NULL here, the daemon will than automatically insert the local host name in that case */, - uint16_t port /**< The IP port number of this service */, - ...) AVAHI_GCC_SENTINEL; - -/** Add a service, takes an AvahiStringList for TXT records. Arguments have the same meaning as for avahi_entry_group_add_service(). */ -int avahi_entry_group_add_service_strlst( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - const char *host, - uint16_t port, - AvahiStringList *txt /**< The TXT data for this service. You may free this object after calling this function, it is not referenced any further */); - -/** Add a subtype for a service. The service should already be existent in the entry group. You may add as many subtypes for a service as you wish. */ -int avahi_entry_group_add_service_subtype( - AvahiEntryGroup *group, - AvahiIfIndex interface /**< The interface this subtype shall be announced on. This should match the value passed for the original avahi_entry_group_add_service() call. */, - AvahiProtocol protocol /**< The protocol this subtype shall be announced with. This should match the value passed for the original avahi_entry_group_add_service() call. */, - AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, - const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, - const char *subtype /**< The new subtype to register for the specified service. May not be NULL. */); - -/** Update a TXT record for an existing service. The service should already be existent in the entry group. */ -int avahi_entry_group_update_service_txt( - AvahiEntryGroup *g, - AvahiIfIndex interface /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */, - AvahiProtocol protocol /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */, - AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, - const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, - ...) AVAHI_GCC_SENTINEL; - -/** Update a TXT record for an existing service. Similar to avahi_entry_group_update_service_txt() but takes an AvahiStringList for the TXT strings, instead of a NULL terminated list of arguments. */ -int avahi_entry_group_update_service_txt_strlst( - AvahiEntryGroup *g, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, - AvahiStringList *strlst); - -/** \cond fulldocs */ -/** Add a host/address pair */ -int avahi_entry_group_add_address( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name /**< The FDQN of the new hostname to register */, - const AvahiAddress *a /**< The address this host name shall map to */); -/** \endcond */ - -/** Add an arbitrary record. I hope you know what you do. */ -int avahi_entry_group_add_record( - AvahiEntryGroup *group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const char *name, - uint16_t clazz, - uint16_t type, - uint32_t ttl, - const void *rdata, - size_t size); - -/** @} */ - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-client/resolver.c b/avahi-client/resolver.c deleted file mode 100644 index 6ee15e9..0000000 --- a/avahi-client/resolver.c +++ /dev/null @@ -1,778 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "client.h" -#include "internal.h" - -/* AvahiServiceResolver implementation */ - -DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message) { - AvahiServiceResolver *r = NULL; - DBusError error; - const char *path; - AvahiStringList *strlst = NULL; - - assert(client); - assert(message); - - dbus_error_init (&error); - - if (!(path = dbus_message_get_path(message))) - goto fail; - - for (r = client->service_resolvers; r; r = r->service_resolvers_next) - if (strcmp (r->path, path) == 0) - break; - - if (!r) - goto fail; - - switch (event) { - case AVAHI_RESOLVER_FOUND: { - int j; - int32_t interface, protocol, aprotocol; - uint32_t flags; - char *name, *type, *domain, *host, *address; - uint16_t port; - DBusMessageIter iter, sub; - AvahiAddress a; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_STRING, &host, - DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_STRING, &address, - DBUS_TYPE_UINT16, &port, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - - fprintf(stderr, "Failed to parse resolver event.\n"); - goto fail; - } - - dbus_message_iter_init(message, &iter); - - for (j = 0; j < 9; j++) - dbus_message_iter_next(&iter); - - if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || - dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) { - fprintf(stderr, "Error parsing service resolving message\n"); - goto fail; - } - - strlst = NULL; - dbus_message_iter_recurse(&iter, &sub); - - for (;;) { - DBusMessageIter sub2; - int at; - const uint8_t *k; - int n; - - if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID) - break; - - assert(at == DBUS_TYPE_ARRAY); - - if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) { - fprintf(stderr, "Error parsing service resolving message\n"); - goto fail; - } - - dbus_message_iter_recurse(&sub, &sub2); - - k = NULL; n = 0; - dbus_message_iter_get_fixed_array(&sub2, &k, &n); - if (k && n > 0) - strlst = avahi_string_list_add_arbitrary(strlst, k, n); - - dbus_message_iter_next(&sub); - } - - dbus_message_iter_next(&iter); - - if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) { - fprintf(stderr, "Failed to parse resolver event.\n"); - goto fail; - } - - dbus_message_iter_get_basic(&iter, &flags); - - assert(address); - - if (address[0] == 0) - address = NULL; - else - avahi_address_parse(address, (AvahiProtocol) aprotocol, &a); - - r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, address ? &a : NULL, port, strlst, (AvahiLookupResultFlags) flags, r->userdata); - - avahi_string_list_free(strlst); - break; - } - - case AVAHI_RESOLVER_FAILURE: { - char *etxt; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &etxt, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse resolver event.\n"); - goto fail; - } - - avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); - r->callback(r, r->interface, r->protocol, event, r->name, r->type, r->domain, NULL, NULL, 0, NULL, 0, r->userdata); - break; - } - } - - return DBUS_HANDLER_RESULT_HANDLED; - - -fail: - dbus_error_free (&error); - avahi_string_list_free(strlst); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -AvahiServiceResolver * avahi_service_resolver_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *name, - const char *type, - const char *domain, - AvahiProtocol aprotocol, - AvahiLookupFlags flags, - AvahiServiceResolverCallback callback, - void *userdata) { - - DBusError error; - AvahiServiceResolver *r = NULL; - DBusMessage *message = NULL, *reply = NULL; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - char *path; - - assert(client); - assert(type); - - if (!domain) - domain = ""; - - if (!name) - name = ""; - - dbus_error_init (&error); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!(r = avahi_new(AvahiServiceResolver, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - r->client = client; - r->callback = callback; - r->userdata = userdata; - r->path = NULL; - r->name = r->type = r->domain = NULL; - r->interface = interface; - r->protocol = protocol; - - AVAHI_LLIST_PREPEND(AvahiServiceResolver, service_resolvers, client->service_resolvers, r); - - if (name && name[0]) - if (!(r->name = avahi_strdup(name))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(r->type = avahi_strdup(type))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (domain && domain[0]) - if (!(r->domain = avahi_strdup(domain))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) aprotocol; - u_flags = (uint32_t) flags; - - if (!(dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set(&error)) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error) || - !path) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(r->path = avahi_strdup(path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - - dbus_message_unref(message); - dbus_message_unref(reply); - - return r; - -fail: - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (r) - avahi_service_resolver_free(r); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; - -} - -AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *r) { - assert (r); - - return r->client; -} - -int avahi_service_resolver_free(AvahiServiceResolver *r) { - AvahiClient *client; - int ret = AVAHI_OK; - - assert(r); - client = r->client; - - if (r->path && avahi_client_is_connected(client)) - ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Free"); - - AVAHI_LLIST_REMOVE(AvahiServiceResolver, service_resolvers, client->service_resolvers, r); - - avahi_free(r->path); - avahi_free(r->name); - avahi_free(r->type); - avahi_free(r->domain); - avahi_free(r); - - return ret; -} - -/* AvahiHostNameResolver implementation */ - -DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message) { - AvahiHostNameResolver *r = NULL; - DBusError error; - const char *path; - - assert(client); - assert(message); - - dbus_error_init (&error); - - if (!(path = dbus_message_get_path(message))) - goto fail; - - for (r = client->host_name_resolvers; r; r = r->host_name_resolvers_next) - if (strcmp (r->path, path) == 0) - break; - - if (!r) - goto fail; - - switch (event) { - case AVAHI_RESOLVER_FOUND: { - int32_t interface, protocol, aprotocol; - uint32_t flags; - char *name, *address; - AvahiAddress a; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_STRING, &address, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse resolver event.\n"); - goto fail; - } - - assert(address); - if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { - fprintf(stderr, "Failed to parse address\n"); - goto fail; - } - - r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata); - break; - } - - case AVAHI_RESOLVER_FAILURE: { - char *etxt; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &etxt, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse resolver event.\n"); - goto fail; - } - - avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); - r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, 0, r->userdata); - break; - } - } - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - dbus_error_free (&error); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - - -AvahiHostNameResolver * avahi_host_name_resolver_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const char *name, - AvahiProtocol aprotocol, - AvahiLookupFlags flags, - AvahiHostNameResolverCallback callback, - void *userdata) { - - DBusError error; - AvahiHostNameResolver *r = NULL; - DBusMessage *message = NULL, *reply = NULL; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - char *path; - - assert(client); - assert(name); - - dbus_error_init (&error); - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!(r = avahi_new(AvahiHostNameResolver, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - r->client = client; - r->callback = callback; - r->userdata = userdata; - r->path = NULL; - r->interface = interface; - r->protocol = protocol; - r->host_name = NULL; - - AVAHI_LLIST_PREPEND(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r); - - if (!(r->host_name = avahi_strdup(name))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "HostNameResolverNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) aprotocol; - u_flags = (uint32_t) flags; - - if (!(dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set(&error)) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error) || - !path) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(r->path = avahi_strdup(path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return r; - -fail: - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (r) - avahi_host_name_resolver_free(r); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; - -} - -int avahi_host_name_resolver_free(AvahiHostNameResolver *r) { - int ret = AVAHI_OK; - AvahiClient *client; - - assert(r); - client = r->client; - - if (r->path && avahi_client_is_connected(client)) - ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Free"); - - AVAHI_LLIST_REMOVE(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r); - - avahi_free(r->path); - avahi_free(r->host_name); - avahi_free(r); - - return ret; -} - -AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *r) { - assert (r); - - return r->client; -} - -/* AvahiAddressResolver implementation */ - -DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message) { - AvahiAddressResolver *r = NULL; - DBusError error; - const char *path; - - assert(client); - assert(message); - - dbus_error_init (&error); - - if (!(path = dbus_message_get_path(message))) - goto fail; - - for (r = client->address_resolvers; r; r = r->address_resolvers_next) - if (strcmp (r->path, path) == 0) - break; - - if (!r) - goto fail; - - switch (event) { - case AVAHI_RESOLVER_FOUND: { - int32_t interface, protocol, aprotocol; - uint32_t flags; - char *name, *address; - AvahiAddress a; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_STRING, &address, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse resolver event.\n"); - goto fail; - } - - assert(address); - if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { - fprintf(stderr, "Failed to parse address\n"); - goto fail; - } - - r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, &a, name, (AvahiLookupResultFlags) flags, r->userdata); - break; - } - - case AVAHI_RESOLVER_FAILURE: { - char *etxt; - - if (!dbus_message_get_args( - message, &error, - DBUS_TYPE_STRING, &etxt, - DBUS_TYPE_INVALID) || - dbus_error_is_set (&error)) { - fprintf(stderr, "Failed to parse resolver event.\n"); - goto fail; - } - - avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); - r->callback(r, r->interface, r->protocol, event, &r->address, NULL, 0, r->userdata); - break; - } - } - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - dbus_error_free (&error); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -AvahiAddressResolver * avahi_address_resolver_new( - AvahiClient *client, - AvahiIfIndex interface, - AvahiProtocol protocol, - const AvahiAddress *a, - AvahiLookupFlags flags, - AvahiAddressResolverCallback callback, - void *userdata) { - - DBusError error; - AvahiAddressResolver *r = NULL; - DBusMessage *message = NULL, *reply = NULL; - int32_t i_interface, i_protocol; - uint32_t u_flags; - char *path; - char addr[AVAHI_ADDRESS_STR_MAX], *address = addr; - - assert(client); - assert(a); - - dbus_error_init (&error); - - if (!avahi_address_snprint (addr, sizeof(addr), a)) { - avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS); - return NULL; - } - - if (!avahi_client_is_connected(client)) { - avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); - goto fail; - } - - if (!(r = avahi_new(AvahiAddressResolver, 1))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - r->client = client; - r->callback = callback; - r->userdata = userdata; - r->path = NULL; - r->interface = interface; - r->protocol = protocol; - r->address = *a; - - AVAHI_LLIST_PREPEND(AvahiAddressResolver, address_resolvers, client->address_resolvers, r); - - if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "AddressResolverNew"))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (!(dbus_message_append_args( - message, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &address, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID))) { - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || - dbus_error_is_set(&error)) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || - dbus_error_is_set(&error) || - !path) { - avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); - goto fail; - } - - if (!(r->path = avahi_strdup(path))) { - - /* FIXME: We don't remove the object on the server side */ - - avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); - goto fail; - } - - dbus_message_unref(message); - dbus_message_unref(reply); - - return r; - -fail: - - if (dbus_error_is_set(&error)) { - avahi_client_set_dbus_error(client, &error); - dbus_error_free(&error); - } - - if (r) - avahi_address_resolver_free(r); - - if (message) - dbus_message_unref(message); - - if (reply) - dbus_message_unref(reply); - - return NULL; - -} - -AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *r) { - assert (r); - - return r->client; -} - -int avahi_address_resolver_free(AvahiAddressResolver *r) { - AvahiClient *client; - int ret = AVAHI_OK; - - assert(r); - client = r->client; - - if (r->path && avahi_client_is_connected(client)) - ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Free"); - - AVAHI_LLIST_REMOVE(AvahiAddressResolver, address_resolvers, client->address_resolvers, r); - - avahi_free(r->path); - avahi_free(r); - - return ret; -} - diff --git a/avahi-client/rr-test.c b/avahi-client/rr-test.c deleted file mode 100644 index 0402585..0000000 --- a/avahi-client/rr-test.c +++ /dev/null @@ -1,111 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include -#include -#include - -static void hexdump(const void* p, size_t size) { - const uint8_t *c = p; - assert(p); - - printf("Dumping %lu bytes from %p:\n", (unsigned long) size, p); - - while (size > 0) { - unsigned i; - - for (i = 0; i < 16; i++) { - if (i < size) - printf("%02x ", c[i]); - else - printf(" "); - } - - for (i = 0; i < 16; i++) { - if (i < size) - printf("%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.'); - else - printf(" "); - } - - printf("\n"); - - c += 16; - - if (size <= 16) - break; - - size -= 16; - } -} - -static void callback( - AVAHI_GCC_UNUSED AvahiRecordBrowser *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - uint16_t clazz, - uint16_t type, - const void *rdata, - size_t rdata_size, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void *userdata) { - - fprintf(stderr, "%i name=%s class=%u type=%u\n", event, name, clazz, type); - - if (rdata) - hexdump(rdata, rdata_size); -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - - AvahiSimplePoll *simple_poll; - const AvahiPoll *poll_api; - AvahiClient *client; - AvahiRecordBrowser *r; - - simple_poll = avahi_simple_poll_new(); - assert(simple_poll); - - poll_api = avahi_simple_poll_get(simple_poll); - assert(poll_api); - - client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); - assert(client); - - r = avahi_record_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "ecstasy.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, 0, callback, simple_poll); - assert(r); - - avahi_simple_poll_loop(simple_poll); - - avahi_client_free(client); - avahi_simple_poll_free(simple_poll); - - return 0; -} diff --git a/avahi-client/srv-test.c b/avahi-client/srv-test.c deleted file mode 100644 index 650bd77..0000000 --- a/avahi-client/srv-test.c +++ /dev/null @@ -1,76 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include -#include -#include - -static void callback( - AVAHI_GCC_UNUSED AvahiServiceResolver *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - AVAHI_GCC_UNUSED const AvahiAddress *a, - AVAHI_GCC_UNUSED uint16_t port, - AVAHI_GCC_UNUSED AvahiStringList *txt, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void *userdata) { - - fprintf(stderr, "%i name=%s type=%s domain=%s host=%s\n", event, name, type, domain, host_name); -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - - AvahiSimplePoll *simple_poll; - const AvahiPoll *poll_api; - AvahiClient *client; - AvahiServiceResolver *r; - - simple_poll = avahi_simple_poll_new(); - assert(simple_poll); - - poll_api = avahi_simple_poll_get(simple_poll); - assert(poll_api); - - client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); - assert(client); - - r = avahi_service_resolver_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, "_domain._udp", "0pointer.de", AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_NO_TXT, callback, simple_poll); - assert(r); - - avahi_simple_poll_loop(simple_poll); - - avahi_client_free(client); - avahi_simple_poll_free(simple_poll); - - return 0; -} diff --git a/avahi-client/xdg-config-test.c b/avahi-client/xdg-config-test.c deleted file mode 100644 index a7ee63e..0000000 --- a/avahi-client/xdg-config-test.c +++ /dev/null @@ -1,38 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "xdg-config.h" - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - - FILE *f; - - f = avahi_xdg_config_open("foo"); - - if (f) - fclose(f); - - return 0; -} diff --git a/avahi-client/xdg-config.c b/avahi-client/xdg-config.c deleted file mode 100644 index fc65016..0000000 --- a/avahi-client/xdg-config.c +++ /dev/null @@ -1,68 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "xdg-config.h" - -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - -FILE *avahi_xdg_config_open(const char *filename) { - FILE *f; - const char *e, *d; - char fn[PATH_MAX], *p = NULL, buf[2048], *s = NULL; - - assert(filename); - - if ((e = getenv("XDG_CONFIG_HOME")) && *e) - snprintf(p = fn, sizeof(fn), "%s/%s", e, filename); - else if ((e = getenv("HOME")) && *e) - snprintf(p = fn, sizeof(fn), "%s/.config/%s", e, filename); - - if (p) { - if ((f = fopen(p, "r"))) - return f; - else if (errno != ENOENT) - return NULL; - } - - if (!(d = getenv("XDG_CONFIG_DIRS")) || !*d) - d = "/etc/xdg"; - - snprintf(buf, sizeof(buf), "%s", d); - - for (e = strtok_r(buf, ":", &s); e; e = strtok_r(NULL, ":", &s)) { - snprintf(fn, sizeof(fn), "%s/%s", e, filename); - - if ((f = fopen(fn, "r"))) - return f; - } - - return NULL; -} diff --git a/avahi-client/xdg-config.h b/avahi-client/xdg-config.h deleted file mode 100644 index 6c855ab..0000000 --- a/avahi-client/xdg-config.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef fooxdgconfighfoo -#define fooxdgconfighfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -FILE *avahi_xdg_config_open(const char *filename); - -#endif diff --git a/avahi-common/Makefile.am b/avahi-common/Makefile.am index 79d062f..c78e34a 100644 --- a/avahi-common/Makefile.am +++ b/avahi-common/Makefile.am @@ -119,11 +119,3 @@ utf8_test_SOURCES = \ utf8.c utf8.h utf8_test_CFLAGS = $(AM_CFLAGS) utf8_test_LDADD = $(AM_LDADD) - -if HAVE_DBUS - -noinst_HEADERS = \ - dbus.h \ - dbus-watch-glue.h - -endif diff --git a/avahi-common/dbus-watch-glue.c b/avahi-common/dbus-watch-glue.c deleted file mode 100644 index b18f555..0000000 --- a/avahi-common/dbus-watch-glue.c +++ /dev/null @@ -1,357 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "malloc.h" -#include "timeval.h" -#include "dbus-watch-glue.h" - -static AvahiWatchEvent translate_dbus_to_avahi(unsigned int f) { - AvahiWatchEvent e = 0; - - if (f & DBUS_WATCH_READABLE) - e |= AVAHI_WATCH_IN; - if (f & DBUS_WATCH_WRITABLE) - e |= AVAHI_WATCH_OUT; - if (f & DBUS_WATCH_ERROR) - e |= AVAHI_WATCH_ERR; - if (f & DBUS_WATCH_HANGUP) - e |= AVAHI_WATCH_HUP; - - return e; -} - -static unsigned int translate_avahi_to_dbus(AvahiWatchEvent e) { - unsigned int f = 0; - - if (e & AVAHI_WATCH_IN) - f |= DBUS_WATCH_READABLE; - if (e & AVAHI_WATCH_OUT) - f |= DBUS_WATCH_WRITABLE; - if (e & AVAHI_WATCH_ERR) - f |= DBUS_WATCH_ERROR; - if (e & AVAHI_WATCH_HUP) - f |= DBUS_WATCH_HANGUP; - - return f; -} - -typedef struct { - DBusConnection *connection; - const AvahiPoll *poll_api; - AvahiTimeout *dispatch_timeout; - int ref; -} ConnectionData; - -static ConnectionData *connection_data_ref(ConnectionData *d) { - assert(d); - assert(d->ref >= 1); - - d->ref++; - return d; -} - -static void connection_data_unref(ConnectionData *d) { - assert(d); - assert(d->ref >= 1); - - if (--d->ref <= 0) { - d->poll_api->timeout_free(d->dispatch_timeout); - avahi_free(d); - } -} - -static void request_dispatch(ConnectionData *d, int enable) { - static const struct timeval tv = { 0, 0 }; - assert(d); - - if (enable) { - assert(dbus_connection_get_dispatch_status(d->connection) == DBUS_DISPATCH_DATA_REMAINS); - d->poll_api->timeout_update(d->dispatch_timeout, &tv); - } else - d->poll_api->timeout_update(d->dispatch_timeout, NULL); -} - -static void dispatch_timeout_callback(AvahiTimeout *t, void *userdata) { - ConnectionData *d = userdata; - assert(t); - assert(d); - - connection_data_ref(d); - dbus_connection_ref(d->connection); - - if (dbus_connection_dispatch(d->connection) == DBUS_DISPATCH_DATA_REMAINS) - /* If there's still data, request that this handler is called again */ - request_dispatch(d, 1); - else - request_dispatch(d, 0); - - dbus_connection_unref(d->connection); - connection_data_unref(d); -} - -static void watch_callback(AvahiWatch *avahi_watch, AVAHI_GCC_UNUSED int fd, AvahiWatchEvent events, void *userdata) { - DBusWatch *dbus_watch = userdata; - - assert(avahi_watch); - assert(dbus_watch); - - dbus_watch_handle(dbus_watch, translate_avahi_to_dbus(events)); - /* Ignore the return value */ -} - -static dbus_bool_t update_watch(const AvahiPoll *poll_api, DBusWatch *dbus_watch) { - AvahiWatch *avahi_watch; - dbus_bool_t b; - - assert(dbus_watch); - - avahi_watch = dbus_watch_get_data(dbus_watch); - - b = dbus_watch_get_enabled(dbus_watch); - - if (b && !avahi_watch) { - - if (!(avahi_watch = poll_api->watch_new( - poll_api, -#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR > 1) || (DBUS_VERSION_MAJOR > 1) - dbus_watch_get_unix_fd(dbus_watch), -#else - dbus_watch_get_fd(dbus_watch), -#endif - translate_dbus_to_avahi(dbus_watch_get_flags(dbus_watch)), - watch_callback, - dbus_watch))) - return FALSE; - - dbus_watch_set_data(dbus_watch, avahi_watch, NULL); - - } else if (!b && avahi_watch) { - - poll_api->watch_free(avahi_watch); - dbus_watch_set_data(dbus_watch, NULL, NULL); - - } else if (avahi_watch) { - - /* Update flags */ - poll_api->watch_update(avahi_watch, dbus_watch_get_flags(dbus_watch)); - } - - return TRUE; -} - -static dbus_bool_t add_watch(DBusWatch *dbus_watch, void *userdata) { - ConnectionData *d = userdata; - - assert(dbus_watch); - assert(d); - - return update_watch(d->poll_api, dbus_watch); -} - -static void remove_watch(DBusWatch *dbus_watch, void *userdata) { - ConnectionData *d = userdata; - AvahiWatch *avahi_watch; - - assert(dbus_watch); - assert(d); - - if ((avahi_watch = dbus_watch_get_data(dbus_watch))) { - d->poll_api->watch_free(avahi_watch); - dbus_watch_set_data(dbus_watch, NULL, NULL); - } -} - -static void watch_toggled(DBusWatch *dbus_watch, void *userdata) { - ConnectionData *d = userdata; - - assert(dbus_watch); - assert(d); - - update_watch(d->poll_api, dbus_watch); -} - -typedef struct TimeoutData { - const AvahiPoll *poll_api; - AvahiTimeout *avahi_timeout; - DBusTimeout *dbus_timeout; - int ref; -} TimeoutData; - -static TimeoutData* timeout_data_ref(TimeoutData *t) { - assert(t); - assert(t->ref >= 1); - - t->ref++; - return t; -} - -static void timeout_data_unref(TimeoutData *t) { - assert(t); - assert(t->ref >= 1); - - if (--t->ref <= 0) { - if (t->avahi_timeout) - t->poll_api->timeout_free(t->avahi_timeout); - - avahi_free(t); - } -} - -static void update_timeout(TimeoutData *timeout) { - assert(timeout); - assert(timeout->ref >= 1); - - if (dbus_timeout_get_enabled(timeout->dbus_timeout)) { - struct timeval tv; - avahi_elapse_time(&tv, dbus_timeout_get_interval(timeout->dbus_timeout), 0); - timeout->poll_api->timeout_update(timeout-> - avahi_timeout, &tv); - } else - timeout->poll_api->timeout_update(timeout->avahi_timeout, NULL); - -} - -static void timeout_callback(AvahiTimeout *avahi_timeout, void *userdata) { - TimeoutData *timeout = userdata; - - assert(avahi_timeout); - assert(timeout); - - timeout_data_ref(timeout); - - dbus_timeout_handle(timeout->dbus_timeout); - /* Ignore the return value */ - - if (timeout->avahi_timeout) - update_timeout(timeout); - - timeout_data_unref(timeout); -} - -static dbus_bool_t add_timeout(DBusTimeout *dbus_timeout, void *userdata) { - TimeoutData *timeout; - ConnectionData *d = userdata; - struct timeval tv; - dbus_bool_t b; - - assert(dbus_timeout); - assert(d); - - if (!(timeout = avahi_new(TimeoutData, 1))) - return FALSE; - - timeout->dbus_timeout = dbus_timeout; - timeout->poll_api = d->poll_api; - timeout->ref = 1; - - if ((b = dbus_timeout_get_enabled(dbus_timeout))) - avahi_elapse_time(&tv, dbus_timeout_get_interval(dbus_timeout), 0); - - if (!(timeout->avahi_timeout = d->poll_api->timeout_new( - d->poll_api, - b ? &tv : NULL, - timeout_callback, - timeout))) { - avahi_free(timeout); - return FALSE; - } - - dbus_timeout_set_data(dbus_timeout, timeout, (DBusFreeFunction) timeout_data_unref); - return TRUE; -} - -static void remove_timeout(DBusTimeout *dbus_timeout, void *userdata) { - ConnectionData *d = userdata; - TimeoutData *timeout; - - assert(dbus_timeout); - assert(d); - - timeout = dbus_timeout_get_data(dbus_timeout); - assert(timeout); - - d->poll_api->timeout_free(timeout->avahi_timeout); - timeout->avahi_timeout = NULL; -} - -static void timeout_toggled(DBusTimeout *dbus_timeout, AVAHI_GCC_UNUSED void *userdata) { - TimeoutData *timeout; - - assert(dbus_timeout); - timeout = dbus_timeout_get_data(dbus_timeout); - assert(timeout); - - update_timeout(timeout); -} - -static void dispatch_status(AVAHI_GCC_UNUSED DBusConnection *connection, DBusDispatchStatus new_status, void *userdata) { - ConnectionData *d = userdata; - - if (new_status == DBUS_DISPATCH_DATA_REMAINS) - request_dispatch(d, 1); - } - -int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api) { - ConnectionData *d = NULL; - - assert(c); - assert(poll_api); - - if (!(d = avahi_new(ConnectionData, 1))) - goto fail;; - - d->poll_api = poll_api; - d->connection = c; - d->ref = 1; - - if (!(d->dispatch_timeout = poll_api->timeout_new(poll_api, NULL, dispatch_timeout_callback, d))) - goto fail; - - if (!(dbus_connection_set_watch_functions(c, add_watch, remove_watch, watch_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref))) - goto fail; - - if (!(dbus_connection_set_timeout_functions(c, add_timeout, remove_timeout, timeout_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref))) - goto fail; - - dbus_connection_set_dispatch_status_function(c, dispatch_status, connection_data_ref(d), (DBusFreeFunction)connection_data_unref); - - if (dbus_connection_get_dispatch_status(c) == DBUS_DISPATCH_DATA_REMAINS) - request_dispatch(d, 1); - - connection_data_unref(d); - - return 0; - -fail: - - if (d) { - d->poll_api->timeout_free(d->dispatch_timeout); - - avahi_free(d); - } - - return -1; -} diff --git a/avahi-common/dbus-watch-glue.h b/avahi-common/dbus-watch-glue.h deleted file mode 100644 index 138ea97..0000000 --- a/avahi-common/dbus-watch-glue.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef foodbuswatchgluehfoo -#define foodbuswatchgluehfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include - -AVAHI_C_DECL_BEGIN - -int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api); - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-common/dbus.c b/avahi-common/dbus.c deleted file mode 100644 index f19c77c..0000000 --- a/avahi-common/dbus.c +++ /dev/null @@ -1,138 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include - -static const char * const table[- AVAHI_ERR_MAX] = { - AVAHI_DBUS_ERR_OK, - AVAHI_DBUS_ERR_FAILURE, - AVAHI_DBUS_ERR_BAD_STATE, - AVAHI_DBUS_ERR_INVALID_HOST_NAME, - AVAHI_DBUS_ERR_INVALID_DOMAIN_NAME, - AVAHI_DBUS_ERR_NO_NETWORK, - AVAHI_DBUS_ERR_INVALID_TTL, - AVAHI_DBUS_ERR_IS_PATTERN, - AVAHI_DBUS_ERR_COLLISION, - AVAHI_DBUS_ERR_INVALID_RECORD, - - AVAHI_DBUS_ERR_INVALID_SERVICE_NAME, - AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE, - AVAHI_DBUS_ERR_INVALID_PORT, - AVAHI_DBUS_ERR_INVALID_KEY, - AVAHI_DBUS_ERR_INVALID_ADDRESS, - AVAHI_DBUS_ERR_TIMEOUT, - AVAHI_DBUS_ERR_TOO_MANY_CLIENTS, - AVAHI_DBUS_ERR_TOO_MANY_OBJECTS, - AVAHI_DBUS_ERR_TOO_MANY_ENTRIES, - AVAHI_DBUS_ERR_OS, - - AVAHI_DBUS_ERR_ACCESS_DENIED, - AVAHI_DBUS_ERR_INVALID_OPERATION, - AVAHI_DBUS_ERR_DBUS_ERROR, - AVAHI_DBUS_ERR_DISCONNECTED, - AVAHI_DBUS_ERR_NO_MEMORY, - AVAHI_DBUS_ERR_INVALID_OBJECT, - AVAHI_DBUS_ERR_NO_DAEMON, - AVAHI_DBUS_ERR_INVALID_INTERFACE, - AVAHI_DBUS_ERR_INVALID_PROTOCOL, - AVAHI_DBUS_ERR_INVALID_FLAGS, - - AVAHI_DBUS_ERR_NOT_FOUND, - AVAHI_DBUS_ERR_INVALID_CONFIG, - AVAHI_DBUS_ERR_VERSION_MISMATCH, - AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE, - AVAHI_DBUS_ERR_INVALID_PACKET, - AVAHI_DBUS_ERR_INVALID_DNS_ERROR, - AVAHI_DBUS_ERR_DNS_FORMERR, - AVAHI_DBUS_ERR_DNS_SERVFAIL, - AVAHI_DBUS_ERR_DNS_NXDOMAIN, - AVAHI_DBUS_ERR_DNS_NOTIMP, - - AVAHI_DBUS_ERR_DNS_REFUSED, - AVAHI_DBUS_ERR_DNS_YXDOMAIN, - AVAHI_DBUS_ERR_DNS_YXRRSET, - AVAHI_DBUS_ERR_DNS_NXRRSET, - AVAHI_DBUS_ERR_DNS_NOTAUTH, - AVAHI_DBUS_ERR_DNS_NOTZONE, - AVAHI_DBUS_ERR_INVALID_RDATA, - AVAHI_DBUS_ERR_INVALID_DNS_CLASS, - AVAHI_DBUS_ERR_INVALID_DNS_TYPE, - AVAHI_DBUS_ERR_NOT_SUPPORTED, - - AVAHI_DBUS_ERR_NOT_PERMITTED, - AVAHI_DBUS_ERR_INVALID_ARGUMENT, - AVAHI_DBUS_ERR_IS_EMPTY, - AVAHI_DBUS_ERR_NO_CHANGE -}; - -struct error_map { - const char *dbus_error; - int avahi_error; -}; - -static struct error_map error_map[] = { - { DBUS_ERROR_FAILED, AVAHI_ERR_FAILURE }, - { DBUS_ERROR_NO_MEMORY, AVAHI_ERR_NO_MEMORY }, - { DBUS_ERROR_SERVICE_UNKNOWN, AVAHI_ERR_NO_DAEMON }, - { DBUS_ERROR_BAD_ADDRESS, AVAHI_ERR_NO_DAEMON }, - { DBUS_ERROR_NOT_SUPPORTED, AVAHI_ERR_NOT_SUPPORTED }, - { DBUS_ERROR_LIMITS_EXCEEDED, AVAHI_ERR_TOO_MANY_OBJECTS }, - { DBUS_ERROR_ACCESS_DENIED, AVAHI_ERR_ACCESS_DENIED }, - { DBUS_ERROR_AUTH_FAILED, AVAHI_ERR_ACCESS_DENIED }, - { DBUS_ERROR_NO_SERVER, AVAHI_ERR_NO_DAEMON }, - { DBUS_ERROR_TIMEOUT, AVAHI_ERR_TIMEOUT }, - { DBUS_ERROR_NO_NETWORK, AVAHI_ERR_NO_NETWORK }, - { DBUS_ERROR_DISCONNECTED, AVAHI_ERR_DISCONNECTED }, - { DBUS_ERROR_INVALID_ARGS, AVAHI_ERR_INVALID_ARGUMENT }, - { DBUS_ERROR_TIMED_OUT, AVAHI_ERR_TIMEOUT }, - { NULL, 0 } -}; - -int avahi_error_dbus_to_number(const char *s) { - int e; - const struct error_map *m; - - assert(s); - - for (e = -1; e > AVAHI_ERR_MAX; e--) - if (strcmp(s, table[-e]) == 0) - return e; - - for (m = error_map; m->dbus_error; m++) - if (strcmp(m->dbus_error, s) == 0) - return m->avahi_error; - - return AVAHI_ERR_DBUS_ERROR; -} - -const char *avahi_error_number_to_dbus(int error) { - assert(error > AVAHI_ERR_MAX); - assert(error < 1); - - return table[-error]; -} diff --git a/avahi-common/dbus.h b/avahi-common/dbus.h deleted file mode 100644 index ea3e8a2..0000000 --- a/avahi-common/dbus.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef foodbushfoo -#define foodbushfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -/** \file dbus.h Some definitions for the D-Bus interface */ - -#include -#include - -AVAHI_C_DECL_BEGIN - -#define AVAHI_DBUS_NAME "org.freedesktop.Avahi" -#define AVAHI_DBUS_INTERFACE_SERVER AVAHI_DBUS_NAME".Server" -#define AVAHI_DBUS_PATH_SERVER "/" -#define AVAHI_DBUS_INTERFACE_ENTRY_GROUP AVAHI_DBUS_NAME".EntryGroup" -#define AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER AVAHI_DBUS_NAME".DomainBrowser" -#define AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER AVAHI_DBUS_NAME".ServiceTypeBrowser" -#define AVAHI_DBUS_INTERFACE_SERVICE_BROWSER AVAHI_DBUS_NAME".ServiceBrowser" -#define AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER AVAHI_DBUS_NAME".AddressResolver" -#define AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER AVAHI_DBUS_NAME".HostNameResolver" -#define AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER AVAHI_DBUS_NAME".ServiceResolver" -#define AVAHI_DBUS_INTERFACE_RECORD_BROWSER AVAHI_DBUS_NAME".RecordBrowser" - -/** The D-Bus API version identifier. The first byte specifies the API -release, the second byte specifies the revision. If the revision -number is increased the API has been extended but is downwards -compatible. If the release changes compatibility is lost. - -Avahi 0.6 implements API version 0x0201; -Avahi 0.6.1 implements API version 0x0202 */ -#define AVAHI_DBUS_API_VERSION ((uint32_t) 0x0203) - -#define AVAHI_DBUS_ERR_OK "org.freedesktop.Avahi.Success" -#define AVAHI_DBUS_ERR_FAILURE "org.freedesktop.Avahi.Failure" -#define AVAHI_DBUS_ERR_BAD_STATE "org.freedesktop.Avahi.BadStateError" -#define AVAHI_DBUS_ERR_INVALID_HOST_NAME "org.freedesktop.Avahi.InvalidHostNameError" -#define AVAHI_DBUS_ERR_INVALID_DOMAIN_NAME "org.freedesktop.Avahi.InvalidDomainNameError" -#define AVAHI_DBUS_ERR_NO_NETWORK "org.freedesktop.Avahi.NoNetworkError" -#define AVAHI_DBUS_ERR_INVALID_TTL "org.freedesktop.Avahi.InvalidTTLError" -#define AVAHI_DBUS_ERR_IS_PATTERN "org.freedesktop.Avahi.IsPatternError" -#define AVAHI_DBUS_ERR_COLLISION "org.freedesktop.Avahi.CollisionError" -#define AVAHI_DBUS_ERR_INVALID_RECORD "org.freedesktop.Avahi.InvalidRecordError" - -#define AVAHI_DBUS_ERR_INVALID_SERVICE_NAME "org.freedesktop.Avahi.InvalidServiceNameError" -#define AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE "org.freedesktop.Avahi.InvalidServiceTypeError" -#define AVAHI_DBUS_ERR_INVALID_PORT "org.freedesktop.Avahi.InvalidPortError" -#define AVAHI_DBUS_ERR_INVALID_KEY "org.freedesktop.Avahi.InvalidKeyError" -#define AVAHI_DBUS_ERR_INVALID_ADDRESS "org.freedesktop.Avahi.InvalidAddressError" -#define AVAHI_DBUS_ERR_TIMEOUT "org.freedesktop.Avahi.TimeoutError" -#define AVAHI_DBUS_ERR_TOO_MANY_CLIENTS "org.freedesktop.Avahi.TooManyClientsError" -#define AVAHI_DBUS_ERR_TOO_MANY_OBJECTS "org.freedesktop.Avahi.TooManyObjectsError" -#define AVAHI_DBUS_ERR_TOO_MANY_ENTRIES "org.freedesktop.Avahi.TooManyEntriesError" -#define AVAHI_DBUS_ERR_OS "org.freedesktop.Avahi.OSError" - -#define AVAHI_DBUS_ERR_ACCESS_DENIED DBUS_ERROR_ACCESS_DENIED -#define AVAHI_DBUS_ERR_INVALID_OPERATION "org.freedesktop.Avahi.InvalidOperationError" -#define AVAHI_DBUS_ERR_DBUS_ERROR "org.freedesktop.Avahi.DBusError" -#define AVAHI_DBUS_ERR_DISCONNECTED "org.freedesktop.Avahi.DisconnectedError" -#define AVAHI_DBUS_ERR_NO_MEMORY "org.freedesktop.Avahi.NoMemoryError" -#define AVAHI_DBUS_ERR_INVALID_OBJECT "org.freedesktop.Avahi.InvalidObjectError" -#define AVAHI_DBUS_ERR_NO_DAEMON "org.freedesktop.Avahi.NoDaemonError" -#define AVAHI_DBUS_ERR_INVALID_INTERFACE "org.freedesktop.Avahi.InvalidInterfaceError" -#define AVAHI_DBUS_ERR_INVALID_PROTOCOL "org.freedesktop.Avahi.InvalidInterfaceProtocolError" -#define AVAHI_DBUS_ERR_INVALID_FLAGS "org.freedesktop.Avahi.InvalidFlagsError" - -#define AVAHI_DBUS_ERR_NOT_FOUND "org.freedesktop.Avahi.NotFoundError" -#define AVAHI_DBUS_ERR_INVALID_CONFIG "org.freedesktop.Avahi.InvalidConfigurationError" -#define AVAHI_DBUS_ERR_VERSION_MISMATCH "org.freedesktop.Avahi.VersionMismatchError" -#define AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE "org.freedesktop.Avahi.InvalidServiceSubtypeError" -#define AVAHI_DBUS_ERR_INVALID_PACKET "org.freedesktop.Avahi.InvalidPacketError" -#define AVAHI_DBUS_ERR_INVALID_DNS_ERROR "org.freedesktop.Avahi.InvalidDNSErrorError" -#define AVAHI_DBUS_ERR_DNS_FORMERR "org.freedesktop.Avahi.DNSFORMERR" -#define AVAHI_DBUS_ERR_DNS_SERVFAIL "org.freedesktop.Avahi.DNSSERVFAIL" -#define AVAHI_DBUS_ERR_DNS_NXDOMAIN "org.freedesktop.Avahi.DNSNXDOMAIN" -#define AVAHI_DBUS_ERR_DNS_NOTIMP "org.freedesktop.Avahi.DNSNOTIMP" - -#define AVAHI_DBUS_ERR_DNS_REFUSED "org.freedesktop.Avahi.DNSREFUSED" -#define AVAHI_DBUS_ERR_DNS_YXDOMAIN "org.freedesktop.Avahi.DNSYXDOMAIN" -#define AVAHI_DBUS_ERR_DNS_YXRRSET "org.freedesktop.Avahi.DNSYXRRSET" -#define AVAHI_DBUS_ERR_DNS_NXRRSET "org.freedesktop.Avahi.DNSNXRRSET" -#define AVAHI_DBUS_ERR_DNS_NOTAUTH "org.freedesktop.Avahi.DNSNOTAUTH" -#define AVAHI_DBUS_ERR_DNS_NOTZONE "org.freedesktop.Avahi.DNSNOTZONE" -#define AVAHI_DBUS_ERR_INVALID_RDATA "org.freedesktop.Avahi.InvalidRDataError" -#define AVAHI_DBUS_ERR_INVALID_DNS_CLASS "org.freedesktop.Avahi.InvalidDNSClassError" -#define AVAHI_DBUS_ERR_INVALID_DNS_TYPE "org.freedesktop.Avahi.InvalidDNSTypeError" -#define AVAHI_DBUS_ERR_NOT_SUPPORTED "org.freedesktop.Avahi.NotSupportedError" - -#define AVAHI_DBUS_ERR_NOT_PERMITTED "org.freedesktop.Avahi.NotPermittedError" -#define AVAHI_DBUS_ERR_INVALID_ARGUMENT "org.freedesktop.Avahi.InvalidArgumentError" -#define AVAHI_DBUS_ERR_IS_EMPTY "org.freedesktop.Avahi.IsEmptyError" -#define AVAHI_DBUS_ERR_NO_CHANGE "org.freedesktop.Avahi.NoChangeError" - -/** Convert a DBus error string into an Avahi error number */ -int avahi_error_dbus_to_number(const char *s); - -/** Convert an Avahi error number into a DBus error string. Result should not be freed */ -const char * avahi_error_number_to_dbus(int error); - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-compat-howl.pc.in b/avahi-compat-howl.pc.in deleted file mode 100644 index b3cd02a..0000000 --- a/avahi-compat-howl.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include/avahi-compat-howl/ - -Name: avahi-compat-howl -Description: Avahi Multicast DNS Responder (HOWL Compatibility) -Version: @HOWL_COMPAT_VERSION@ -Libs: -L${libdir} -lhowl -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-compat-howl/.gitignore b/avahi-compat-howl/.gitignore deleted file mode 100644 index 8dffd16..0000000 --- a/avahi-compat-howl/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -address-test -browse-domain-test -samples/resolve -text-test -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs diff --git a/avahi-compat-howl/Makefile.am b/avahi-compat-howl/Makefile.am deleted file mode 100644 index bc67142..0000000 --- a/avahi-compat-howl/Makefile.am +++ /dev/null @@ -1,109 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -SUBDIRS = . samples - -if HAVE_DBUS -if ENABLE_COMPAT_HOWL - -avahi_compat_howldir=$(includedir)/avahi-compat-howl -avahi_compat_howl_rendezvousdir=$(avahi_compat_howldir)/rendezvous -avahi_compat_howl_corbydir=$(avahi_compat_howldir)/corby -avahi_compat_howl_discoverydir=$(avahi_compat_howldir)/discovery -avahi_compat_howl_saltdir=$(avahi_compat_howldir)/salt - -avahi_compat_howl_HEADERS = \ - include/howl.h - -avahi_compat_howl_rendezvous_HEADERS = \ - include/rendezvous/rendezvous.h \ - include/rendezvous/text_record.h - -avahi_compat_howl_corby_HEADERS = \ - include/corby/message.h \ - include/corby/object.h \ - include/corby/orb.h \ - include/corby/corby.h \ - include/corby/channel.h \ - include/corby/buffer.h - -avahi_compat_howl_discovery_HEADERS = \ - include/discovery/discovery.h \ - include/discovery/text_record.h - -avahi_compat_howl_salt_HEADERS = \ - include/salt/socket.h \ - include/salt/address.h \ - include/salt/platform.h \ - include/salt/signal.h \ - include/salt/interface.h \ - include/salt/salt.h \ - include/salt/time.h \ - include/salt/debug.h - -HOWLHEADERS = \ - $(avahi_compat_howl_HEADERS) \ - $(avahi_compat_howl_rendezvous_HEADERS) \ - $(avahi_compat_howl_corby_HEADERS) \ - $(avahi_compat_howl_discovery_HEADERS) \ - $(avahi_compat_howl_salt_HEADERS) - -lib_LTLIBRARIES = libhowl.la - -if ENABLE_TESTS -noinst_PROGRAMS = address-test text-test browse-domain-test -endif - -libhowl_la_SOURCES = \ - $(HOWLHEADERS) \ - warn.c warn.h \ - unsupported.c \ - address.c \ - text.c \ - compat.c -libhowl_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -libhowl_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_COMPAT_HOWL_VERSION_INFO) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la - -address_test_SOURCES = \ - $(HOWLHEADERS) \ - address.c \ - address-test.c \ - warn.c warn.h -address_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -address_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la - -text_test_SOURCES = \ - $(HOWLHEADERS) \ - text.c \ - text-test.c \ - warn.c warn.h -text_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -text_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la - -browse_domain_test_SOURCES = \ - $(HOWLHEADERS) \ - browse-domain-test.c -browse_domain_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -browse_domain_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) libhowl.la - -endif -endif diff --git a/avahi-compat-howl/address-test.c b/avahi-compat-howl/address-test.c deleted file mode 100644 index d9e152f..0000000 --- a/avahi-compat-howl/address-test.c +++ /dev/null @@ -1,51 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include - -#include "howl.h" - -#define ASSERT_SW_OKAY(t) { sw_result r; r = (t); assert(r == SW_OKAY); } -#define ASSERT_NOT_NULL(t) { const void* r; r = (t); assert(r); } - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - sw_ipv4_address a; - char t[256]; - uint8_t a1, a2, a3, a4; - - ASSERT_SW_OKAY(sw_ipv4_address_init_from_name(&a, "heise.de")); - ASSERT_NOT_NULL(sw_ipv4_address_name(a, t, sizeof(t))); - printf("%s\n", t); - - ASSERT_SW_OKAY(sw_ipv4_address_init_from_this_host(&a)); - ASSERT_NOT_NULL(sw_ipv4_address_name(a, t, sizeof(t))); - printf("%s\n", t); - - ASSERT_SW_OKAY(sw_ipv4_address_decompose(a, &a1, &a2, &a3, &a4)); - printf("%i.%i.%i.%i\n", a1, a2, a3, a4); - - return 0; -} diff --git a/avahi-compat-howl/address.c b/avahi-compat-howl/address.c deleted file mode 100644 index 81b6e6b..0000000 --- a/avahi-compat-howl/address.c +++ /dev/null @@ -1,212 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "howl.h" -#include "warn.h" - -sw_ipv4_address sw_ipv4_address_any(void) { - sw_ipv4_address a; - - AVAHI_WARN_LINKAGE; - - a.m_addr = htonl(INADDR_ANY); - return a; -} - -sw_ipv4_address sw_ipv4_address_loopback(void) { - sw_ipv4_address a; - - AVAHI_WARN_LINKAGE; - - a.m_addr = htonl(INADDR_LOOPBACK); - return a; -} - -sw_result sw_ipv4_address_init(sw_ipv4_address * self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - self->m_addr = htonl(INADDR_ANY); - return SW_OKAY; -} - -sw_result sw_ipv4_address_init_from_saddr( - sw_ipv4_address *self, - sw_saddr addr) { - - assert(self); - - AVAHI_WARN_LINKAGE; - - self->m_addr = addr; - return SW_OKAY; -} - -sw_result sw_ipv4_address_init_from_name( - sw_ipv4_address *self, - sw_const_string name) { - - struct hostent *he; - - assert(self); - assert(name); - - AVAHI_WARN_LINKAGE; - - if (!(he = gethostbyname(name))) - return SW_E_UNKNOWN; - - self->m_addr = *(uint32_t*) he->h_addr; - return SW_OKAY; -} - -sw_result sw_ipv4_address_init_from_address( - sw_ipv4_address *self, - sw_ipv4_address addr) { - - assert(self); - - AVAHI_WARN_LINKAGE; - - self->m_addr = addr.m_addr; - return SW_OKAY; -} - -sw_result sw_ipv4_address_init_from_this_host(sw_ipv4_address *self) { - struct sockaddr_in sa; - int fd; - socklen_t l = sizeof(sa); - - assert(self); - - AVAHI_WARN_LINKAGE; - - /* This is so fucked up ... */ - - memset(&sa, 0, sizeof(sa)); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = inet_addr("192.168.1.1"); /* Ouch */ - sa.sin_port = htons(5555); - - if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0 || - connect(fd, (struct sockaddr*) &sa, sizeof(sa)) < 0 || - getsockname(fd, (struct sockaddr*) &sa, &l) < 0) { - if (fd >= 0) - close(fd); - - perror("fuck"); - return SW_E_UNKNOWN; - } - - assert(l == sizeof(sa)); - close(fd); - - self->m_addr = sa.sin_addr.s_addr; - - return SW_OKAY; -} - -sw_result sw_ipv4_address_fina(AVAHI_GCC_UNUSED sw_ipv4_address self) { - - AVAHI_WARN_LINKAGE; - - /* This is ridiculous ... */ - - return SW_OKAY; -} - -sw_bool sw_ipv4_address_is_any(sw_ipv4_address self) { - AVAHI_WARN_LINKAGE; - return self.m_addr == htonl(INADDR_ANY); -} - -sw_saddr sw_ipv4_address_saddr(sw_ipv4_address self) { - AVAHI_WARN_LINKAGE; - return self.m_addr; -} - -sw_string sw_ipv4_address_name( - sw_ipv4_address self, - sw_string name, - sw_uint32 len) { - - assert(name); - assert(len > 0); - - AVAHI_WARN_LINKAGE; - - if (len < INET_ADDRSTRLEN) - return NULL; - - if (!(inet_ntop(AF_INET, &self.m_addr, name, len))) - return NULL; - - return name; -} - -sw_result sw_ipv4_address_decompose( - sw_ipv4_address self, - sw_uint8 * a1, - sw_uint8 * a2, - sw_uint8 * a3, - sw_uint8 * a4) { - - uint32_t a; - - AVAHI_WARN_LINKAGE; - - a = ntohl(self.m_addr); - - assert(a1); - assert(a2); - assert(a3); - assert(a4); - - *a1 = (uint8_t) (a >> 24); - *a2 = (uint8_t) (a >> 16); - *a3 = (uint8_t) (a >> 8); - *a4 = (uint8_t) (a); - - return SW_OKAY; -} - -sw_bool sw_ipv4_address_equals( - sw_ipv4_address self, - sw_ipv4_address addr) { - - AVAHI_WARN_LINKAGE; - - return self.m_addr == addr.m_addr; -} - diff --git a/avahi-compat-howl/browse-domain-test.c b/avahi-compat-howl/browse-domain-test.c deleted file mode 100644 index b5a4a01..0000000 --- a/avahi-compat-howl/browse-domain-test.c +++ /dev/null @@ -1,74 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include "howl.h" - -#define ASSERT_SW_OKAY(t) { sw_result _r; _r = (t); assert(_r == SW_OKAY); } -#define ASSERT_NOT_NULL(t) { const void* _r; r = (t); assert(_r); } - -static sw_result reply( - AVAHI_GCC_UNUSED sw_discovery discovery, - AVAHI_GCC_UNUSED sw_discovery_oid oid, - sw_discovery_browse_status status, - AVAHI_GCC_UNUSED sw_uint32 interface_index, - AVAHI_GCC_UNUSED sw_const_string name, - AVAHI_GCC_UNUSED sw_const_string type, - sw_const_string domain, - AVAHI_GCC_UNUSED sw_opaque extra) { - - switch (status) { - case SW_DISCOVERY_BROWSE_ADD_DOMAIN: - fprintf(stderr, "new domain %s\n", domain); - break; - - case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN: - fprintf(stderr, "removed domain %s\n", domain); - break; - - case SW_DISCOVERY_BROWSE_INVALID: - fprintf(stderr, "some kind of failure happened: %s\n", domain); - break; - - default: - abort(); - } - - return SW_OKAY; -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - sw_discovery discovery; - sw_discovery_oid oid; - - ASSERT_SW_OKAY(sw_discovery_init(&discovery)); - - ASSERT_SW_OKAY(sw_discovery_browse_domains(discovery, 0, reply, NULL, &oid)); - - ASSERT_SW_OKAY(sw_discovery_run(discovery)); - - return 0; -} diff --git a/avahi-compat-howl/compat.c b/avahi-compat-howl/compat.c deleted file mode 100644 index 9b8b18c..0000000 --- a/avahi-compat-howl/compat.c +++ /dev/null @@ -1,1182 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "howl.h" -#include "warn.h" - -#define OID_MAX 50 - -enum { - COMMAND_POLL = 'p', - COMMAND_QUIT = 'q', - COMMAND_POLL_DONE = 'P', - COMMAND_POLL_FAILED = 'F' -}; - -typedef enum { - OID_UNUSED = 0, - OID_SERVICE_BROWSER, - OID_SERVICE_RESOLVER, - OID_DOMAIN_BROWSER, - OID_ENTRY_GROUP -} oid_type; - -typedef struct service_data service_data; - -typedef struct oid_data { - oid_type type; - sw_opaque extra; - sw_discovery discovery; - void *object; - sw_result (*reply)(void); - service_data *service_data; -} oid_data; - - -struct service_data { - char *name, *regtype, *domain, *host; - uint16_t port; - AvahiIfIndex interface; - AvahiStringList *txt; - AVAHI_LLIST_FIELDS(service_data, services); -}; - -struct _sw_discovery { - int n_ref; - AvahiSimplePoll *simple_poll; - AvahiClient *client; - - oid_data oid_table[OID_MAX]; - sw_discovery_oid oid_index; - - int thread_fd, main_fd; - - pthread_t thread; - int thread_running; - - pthread_mutex_t mutex, salt_mutex; - - AVAHI_LLIST_HEAD(service_data, services); -}; - -#define ASSERT_SUCCESS(r) { int __ret = (r); assert(__ret == 0); } - -#define OID_GET_INDEX(data) ((sw_discovery_oid) (((data) - ((data)->discovery->oid_table)))) - -static sw_discovery discovery_ref(sw_discovery self); -static void discovery_unref(sw_discovery self); - -static const char *add_trailing_dot(const char *s, char *buf, size_t buf_len) { - if (!s) - return NULL; - - if (*s == 0) - return s; - - if (s[strlen(s)-1] == '.') - return s; - - snprintf(buf, buf_len, "%s.", s); - return buf; -} - -static sw_result map_error(int error) { - switch (error) { - case AVAHI_OK: - return SW_OKAY; - - case AVAHI_ERR_NO_MEMORY: - return SW_E_MEM; - } - - return SW_E_UNKNOWN; -} - -static int read_command(int fd) { - ssize_t r; - char command; - - assert(fd >= 0); - - if ((r = read(fd, &command, 1)) != 1) { - fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); - return -1; - } - - return command; -} - -static int write_command(int fd, char reply) { - assert(fd >= 0); - - if (write(fd, &reply, 1) != 1) { - fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno)); - return -1; - } - - return 0; -} - -static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) { - sw_discovery self = userdata; - int ret; - - assert(self); - - ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - ret = poll(ufds, nfds, timeout); - ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - - return ret; -} - -static void * thread_func(void *data) { - sw_discovery self = data; - sigset_t mask; - - sigfillset(&mask); - pthread_sigmask(SIG_BLOCK, &mask, NULL); - - self->thread = pthread_self(); - self->thread_running = 1; - - for (;;) { - char command; - - if ((command = read_command(self->thread_fd)) < 0) - break; - -/* fprintf(stderr, "Command: %c\n", command); */ - - switch (command) { - - case COMMAND_POLL: { - int ret; - - ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - - for (;;) { - errno = 0; - - if ((ret = avahi_simple_poll_run(self->simple_poll)) < 0) { - - if (errno == EINTR) - continue; - - fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno)); - } - - break; - } - - ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - - if (write_command(self->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0) - break; - - break; - } - - case COMMAND_QUIT: - return NULL; - } - - } - - return NULL; -} - -static int oid_alloc(sw_discovery self, oid_type type) { - sw_discovery_oid i; - assert(self); - - for (i = 0; i < OID_MAX; i++) { - - while (self->oid_index >= OID_MAX) - self->oid_index -= OID_MAX; - - if (self->oid_table[self->oid_index].type == OID_UNUSED) { - self->oid_table[self->oid_index].type = type; - self->oid_table[self->oid_index].discovery = self; - - assert(OID_GET_INDEX(&self->oid_table[self->oid_index]) == self->oid_index); - - return self->oid_index ++; - } - - self->oid_index ++; - } - - /* No free entry found */ - - return (sw_discovery_oid) -1; -} - -static void oid_release(sw_discovery self, sw_discovery_oid oid) { - assert(self); - assert(oid < OID_MAX); - - assert(self->oid_table[oid].type != OID_UNUSED); - - self->oid_table[oid].type = OID_UNUSED; - self->oid_table[oid].discovery = NULL; - self->oid_table[oid].reply = NULL; - self->oid_table[oid].object = NULL; - self->oid_table[oid].extra = NULL; - self->oid_table[oid].service_data = NULL; -} - -static oid_data* oid_get(sw_discovery self, sw_discovery_oid oid) { - assert(self); - - if (oid >= OID_MAX) - return NULL; - - if (self->oid_table[oid].type == OID_UNUSED) - return NULL; - - return &self->oid_table[oid]; -} - -static service_data* service_data_new(sw_discovery self) { - service_data *sdata; - - assert(self); - - if (!(sdata = avahi_new0(service_data, 1))) - return NULL; - - AVAHI_LLIST_PREPEND(service_data, services, self->services, sdata); - - return sdata; - -} - -static void service_data_free(sw_discovery self, service_data* sdata) { - assert(self); - assert(sdata); - - AVAHI_LLIST_REMOVE(service_data, services, self->services, sdata); - - avahi_free(sdata->name); - avahi_free(sdata->regtype); - avahi_free(sdata->domain); - avahi_free(sdata->host); - avahi_string_list_free(sdata->txt); - avahi_free(sdata); -} - -static void reg_client_callback(oid_data *data, AvahiClientState state); - -static void client_callback(AvahiClient *s, AvahiClientState state, void* userdata) { - sw_discovery self = userdata; - sw_discovery_oid oid; - - assert(s); - assert(self); - - discovery_ref(self); - - for (oid = 0; oid < OID_MAX; oid++) { - - switch (self->oid_table[oid].type) { - - case OID_ENTRY_GROUP: - reg_client_callback(&self->oid_table[oid], state); - break; - - case OID_DOMAIN_BROWSER: - case OID_SERVICE_BROWSER: - ((sw_discovery_browse_reply) self->oid_table[oid].reply)(self, oid, SW_DISCOVERY_BROWSE_INVALID, 0, NULL, NULL, NULL, self->oid_table[oid].extra); - break; - - case OID_SERVICE_RESOLVER: - case OID_UNUSED: - ; - } - } - - discovery_unref(self); -} - -sw_result sw_discovery_init(sw_discovery * self) { - int fd[2] = { -1, -1}; - sw_result result = SW_E_UNKNOWN; - pthread_mutexattr_t mutex_attr; - int error; - - assert(self); - - AVAHI_WARN_LINKAGE; - - *self = NULL; - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) - goto fail; - - if (!(*self = avahi_new(struct _sw_discovery, 1))) { - result = SW_E_MEM; - goto fail; - } - - (*self)->n_ref = 1; - (*self)->thread_fd = fd[0]; - (*self)->main_fd = fd[1]; - - (*self)->client = NULL; - (*self)->simple_poll = NULL; - - memset((*self)->oid_table, 0, sizeof((*self)->oid_table)); - (*self)->oid_index = 0; - - (*self)->thread_running = 0; - - AVAHI_LLIST_HEAD_INIT(service_info, (*self)->services); - - ASSERT_SUCCESS(pthread_mutexattr_init(&mutex_attr)); - pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - ASSERT_SUCCESS(pthread_mutex_init(&(*self)->mutex, &mutex_attr)); - ASSERT_SUCCESS(pthread_mutex_init(&(*self)->salt_mutex, &mutex_attr)); - - if (!((*self)->simple_poll = avahi_simple_poll_new())) - goto fail; - - avahi_simple_poll_set_func((*self)->simple_poll, poll_func, *self); - - if (!((*self)->client = avahi_client_new(avahi_simple_poll_get((*self)->simple_poll), 0, client_callback, *self, &error))) { - result = map_error(error); - goto fail; - } - - /* Start simple poll */ - if (avahi_simple_poll_prepare((*self)->simple_poll, -1) < 0) - goto fail; - - /* Queue an initial POLL command for the thread */ - if (write_command((*self)->main_fd, COMMAND_POLL) < 0) - goto fail; - - if (pthread_create(&(*self)->thread, NULL, thread_func, *self) != 0) - goto fail; - - (*self)->thread_running = 1; - - return SW_OKAY; - -fail: - - if (*self) - sw_discovery_fina(*self); - - return result; -} - -static int stop_thread(sw_discovery self) { - assert(self); - - if (!self->thread_running) - return 0; - - if (write_command(self->main_fd, COMMAND_QUIT) < 0) - return -1; - - avahi_simple_poll_wakeup(self->simple_poll); - - ASSERT_SUCCESS(pthread_join(self->thread, NULL)); - self->thread_running = 0; - return 0; -} - -static sw_discovery discovery_ref(sw_discovery self) { - assert(self); - assert(self->n_ref >= 1); - - self->n_ref++; - - return self; -} - -static void discovery_unref(sw_discovery self) { - assert(self); - assert(self->n_ref >= 1); - - if (--self->n_ref > 0) - return; - - stop_thread(self); - - if (self->client) - avahi_client_free(self->client); - - if (self->simple_poll) - avahi_simple_poll_free(self->simple_poll); - - if (self->thread_fd >= 0) - close(self->thread_fd); - - if (self->main_fd >= 0) - close(self->main_fd); - - ASSERT_SUCCESS(pthread_mutex_destroy(&self->mutex)); - ASSERT_SUCCESS(pthread_mutex_destroy(&self->salt_mutex)); - - while (self->services) - service_data_free(self, self->services); - - avahi_free(self); -} - -sw_result sw_discovery_fina(sw_discovery self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - stop_thread(self); - discovery_unref(self); - - return SW_OKAY; -} - -sw_result sw_discovery_run(sw_discovery self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - return sw_salt_run((sw_salt) self); -} - -sw_result sw_discovery_stop_run(sw_discovery self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - return sw_salt_stop_run((sw_salt) self); -} - -int sw_discovery_socket(sw_discovery self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - return self->main_fd; -} - -sw_result sw_discovery_read_socket(sw_discovery self) { - sw_result result = SW_E_UNKNOWN; - - assert(self); - - discovery_ref(self); - - ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - - /* Cleanup notification socket */ - if (read_command(self->main_fd) != COMMAND_POLL_DONE) - goto finish; - - if (avahi_simple_poll_dispatch(self->simple_poll) < 0) - goto finish; - - if (self->n_ref > 1) /* Perhaps we should die */ - - /* Dispatch events */ - if (avahi_simple_poll_prepare(self->simple_poll, -1) < 0) - goto finish; - - if (self->n_ref > 1) - - /* Request the poll */ - if (write_command(self->main_fd, COMMAND_POLL) < 0) - goto finish; - - result = SW_OKAY; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - - discovery_unref(self); - - return result; -} - -sw_result sw_discovery_salt(sw_discovery self, sw_salt *salt) { - assert(self); - assert(salt); - - AVAHI_WARN_LINKAGE; - - *salt = (sw_salt) self; - - return SW_OKAY; -} - -sw_result sw_salt_step(sw_salt self, sw_uint32 * msec) { - struct pollfd p; - int r; - sw_result result; - - AVAHI_WARN_LINKAGE; - - if (!((sw_discovery) self)->thread_running) - return SW_E_UNKNOWN; - - memset(&p, 0, sizeof(p)); - p.fd = ((sw_discovery) self)->main_fd; - p.events = POLLIN; - - if ((r = poll(&p, 1, msec ? (int) *msec : -1)) < 0) { - - /* Don't treat EINTR as error */ - if (errno == EINTR) - return SW_OKAY; - - return SW_E_UNKNOWN; - - } else if (r == 0) { - - /* Timeoout */ - return SW_OKAY; - - } else { - /* Success */ - - if (p.revents != POLLIN) - return SW_E_UNKNOWN; - - if ((result = sw_discovery_read_socket((sw_discovery) self)) != SW_OKAY) - return result; - } - - return SW_OKAY; -} - -sw_result sw_salt_run(sw_salt self) { - sw_result ret; - - AVAHI_WARN_LINKAGE; - - assert(self); - - for (;;) - if ((ret = sw_salt_step(self, NULL)) != SW_OKAY) - return ret; -} - -sw_result sw_salt_stop_run(sw_salt self) { - AVAHI_WARN_LINKAGE; - - assert(self); - - if (stop_thread((sw_discovery) self) < 0) - return SW_E_UNKNOWN; - - return SW_OKAY; -} - -sw_result sw_salt_lock(sw_salt self) { - AVAHI_WARN_LINKAGE; - - assert(self); - ASSERT_SUCCESS(pthread_mutex_lock(&((sw_discovery) self)->salt_mutex)); - - return SW_OKAY; -} - -sw_result sw_salt_unlock(sw_salt self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - ASSERT_SUCCESS(pthread_mutex_unlock(&((sw_discovery) self)->salt_mutex)); - - return SW_OKAY; -} - -static void reg_report_status(oid_data *data, sw_discovery_publish_status status) { - sw_discovery_publish_reply reply; - - assert(data); - - reply = (sw_discovery_publish_reply) data->reply; - - reply(data->discovery, - OID_GET_INDEX(data), - status, - data->extra); -} - -static int reg_create_service(oid_data *data) { - int ret; - const char *real_type; - - assert(data); - - real_type = avahi_get_type_from_subtype(data->service_data->regtype); - - if ((ret = avahi_entry_group_add_service_strlst( - data->object, - data->service_data->interface, - AVAHI_PROTO_INET, - 0, - data->service_data->name, - real_type ? real_type : data->service_data->regtype, - data->service_data->domain, - data->service_data->host, - data->service_data->port, - data->service_data->txt)) < 0) - return ret; - - if (real_type) { - /* Create a subtype entry */ - - if (avahi_entry_group_add_service_subtype( - data->object, - data->service_data->interface, - AVAHI_PROTO_INET, - 0, - data->service_data->name, - real_type, - data->service_data->domain, - data->service_data->regtype) < 0) - return ret; - - } - - if ((ret = avahi_entry_group_commit(data->object)) < 0) - return ret; - - return 0; -} - -static void reg_client_callback(oid_data *data, AvahiClientState state) { - assert(data); - - /* We've not been setup completely */ - if (!data->object) - return; - - switch (state) { - case AVAHI_CLIENT_FAILURE: - reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID); - break; - - case AVAHI_CLIENT_S_RUNNING: { - int ret; - - /* Register the service */ - if ((ret = reg_create_service(data)) < 0) { - reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID); - return; - } - - break; - } - - case AVAHI_CLIENT_S_COLLISION: - case AVAHI_CLIENT_S_REGISTERING: - - /* Remove our entry */ - avahi_entry_group_reset(data->object); - break; - - case AVAHI_CLIENT_CONNECTING: - /* Ignore */ - break; - } - -} - -static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { - oid_data *data = userdata; - - assert(g); - assert(data); - - switch (state) { - case AVAHI_ENTRY_GROUP_ESTABLISHED: - - reg_report_status(data, SW_DISCOVERY_PUBLISH_STARTED); - break; - - case AVAHI_ENTRY_GROUP_COLLISION: - - reg_report_status(data, SW_DISCOVERY_PUBLISH_NAME_COLLISION); - break; - - case AVAHI_ENTRY_GROUP_REGISTERING: - case AVAHI_ENTRY_GROUP_UNCOMMITED: - /* Ignore */ - break; - - case AVAHI_ENTRY_GROUP_FAILURE: - reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID); - break; - - } -} - -sw_result sw_discovery_publish( - sw_discovery self, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_const_string host, - sw_port port, - sw_octets text_record, - sw_uint32 text_record_len, - sw_discovery_publish_reply reply, - sw_opaque extra, - sw_discovery_oid * oid) { - - oid_data *data; - sw_result result = SW_E_UNKNOWN; - service_data *sdata; - AvahiStringList *txt = NULL; - - assert(self); - assert(name); - assert(type); - assert(reply); - assert(oid); - - AVAHI_WARN_LINKAGE; - - if (text_record && text_record_len > 0) - if (avahi_string_list_parse(text_record, text_record_len, &txt) < 0) - return SW_E_UNKNOWN; - - if ((*oid = oid_alloc(self, OID_ENTRY_GROUP)) == (sw_discovery_oid) -1) { - avahi_string_list_free(txt); - return SW_E_UNKNOWN; - } - - if (!(sdata = service_data_new(self))) { - avahi_string_list_free(txt); - oid_release(self, *oid); - return SW_E_MEM; - } - - data = oid_get(self, *oid); - assert(data); - data->reply = (sw_result (*)(void)) reply; - data->extra = extra; - data->service_data = sdata; - - sdata->interface = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index; - sdata->name = avahi_strdup(name); - sdata->regtype = type ? avahi_normalize_name_strdup(type) : NULL; - sdata->domain = domain ? avahi_normalize_name_strdup(domain) : NULL; - sdata->host = host ? avahi_normalize_name_strdup(host) : NULL; - sdata->port = port; - sdata->txt = txt; - - /* Some OOM checking would be cool here */ - - ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - - if (!(data->object = avahi_entry_group_new(self->client, reg_entry_group_callback, data))) { - result = map_error(avahi_client_errno(self->client)); - goto finish; - } - - if (avahi_client_get_state(self->client) == AVAHI_CLIENT_S_RUNNING) { - int error; - - if ((error = reg_create_service(data)) < 0) { - result = map_error(error); - goto finish; - } - } - - result = SW_OKAY; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - - if (result != SW_OKAY) - if (*oid != (sw_discovery_oid) -1) - sw_discovery_cancel(self, *oid); - - return result; -} - -static void domain_browser_callback( - AvahiDomainBrowser *b, - AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - oid_data* data = userdata; - sw_discovery_browse_reply reply; - static char domain_fixed[AVAHI_DOMAIN_NAME_MAX]; - - assert(b); - assert(data); - - reply = (sw_discovery_browse_reply) data->reply; - - domain = add_trailing_dot(domain, domain_fixed, sizeof(domain_fixed)); - - switch (event) { - case AVAHI_BROWSER_NEW: - reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_ADD_DOMAIN, interface, NULL, NULL, domain, data->extra); - break; - - case AVAHI_BROWSER_REMOVE: - reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_REMOVE_DOMAIN, interface, NULL, NULL, domain, data->extra); - break; - - case AVAHI_BROWSER_FAILURE: - reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, NULL, NULL, domain, data->extra); - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - } -} - -sw_result sw_discovery_browse_domains( - sw_discovery self, - sw_uint32 interface_index, - sw_discovery_browse_reply reply, - sw_opaque extra, - sw_discovery_oid * oid) { - - oid_data *data; - AvahiIfIndex ifindex; - sw_result result = SW_E_UNKNOWN; - - assert(self); - assert(reply); - assert(oid); - - AVAHI_WARN_LINKAGE; - - if ((*oid = oid_alloc(self, OID_DOMAIN_BROWSER)) == (sw_discovery_oid) -1) - return SW_E_UNKNOWN; - - data = oid_get(self, *oid); - assert(data); - data->reply = (sw_result (*)(void)) reply; - data->extra = extra; - - ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index; - - ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - - if (!(data->object = avahi_domain_browser_new(self->client, ifindex, AVAHI_PROTO_INET, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, domain_browser_callback, data))) { - result = map_error(avahi_client_errno(self->client)); - goto finish; - } - - result = SW_OKAY; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - - if (result != SW_OKAY) - if (*oid != (sw_discovery_oid) -1) - sw_discovery_cancel(self, *oid); - - return result; -} - -static void service_resolver_callback( - AvahiServiceResolver *r, - AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - oid_data* data = userdata; - sw_discovery_resolve_reply reply; - - assert(r); - assert(data); - - reply = (sw_discovery_resolve_reply) data->reply; - - switch (event) { - case AVAHI_RESOLVER_FOUND: { - - char host_name_fixed[AVAHI_DOMAIN_NAME_MAX]; - uint8_t *p = NULL; - size_t l = 0; - sw_ipv4_address addr; - - sw_ipv4_address_init_from_saddr(&addr, a->data.ipv4.address); - - host_name = add_trailing_dot(host_name, host_name_fixed, sizeof(host_name_fixed)); - - if ((p = avahi_new0(uint8_t, (l = avahi_string_list_serialize(txt, NULL, 0))+1))) - avahi_string_list_serialize(txt, p, l); - - reply(data->discovery, OID_GET_INDEX(data), interface, name, type, domain, addr, port, p, l, data->extra); - - avahi_free(p); - break; - } - - case AVAHI_RESOLVER_FAILURE: - - /* Apparently there is no way in HOWL to inform about failed resolvings ... */ - - avahi_warn("A service failed to resolve in the HOWL compatiblity layer of Avahi which is used by '%s'. " - "Since the HOWL API doesn't offer any means to inform the application about this, we have to ignore the failure. " - "Please fix your application to use the native API of Avahi!", - avahi_exe_name()); - - break; - } -} - -sw_result sw_discovery_resolve( - sw_discovery self, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_discovery_resolve_reply reply, - sw_opaque extra, - sw_discovery_oid * oid) { - - oid_data *data; - AvahiIfIndex ifindex; - sw_result result = SW_E_UNKNOWN; - - assert(self); - assert(name); - assert(type); - assert(reply); - assert(oid); - - AVAHI_WARN_LINKAGE; - - if ((*oid = oid_alloc(self, OID_SERVICE_RESOLVER)) == (sw_discovery_oid) -1) - return SW_E_UNKNOWN; - - data = oid_get(self, *oid); - assert(data); - data->reply = (sw_result (*)(void)) reply; - data->extra = extra; - - ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index; - - ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - - if (!(data->object = avahi_service_resolver_new(self->client, ifindex, AVAHI_PROTO_INET, name, type, domain, AVAHI_PROTO_INET, 0, service_resolver_callback, data))) { - result = map_error(avahi_client_errno(self->client)); - goto finish; - } - - result = SW_OKAY; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - - if (result != SW_OKAY) - if (*oid != (sw_discovery_oid) -1) - sw_discovery_cancel(self, *oid); - - return result; -} - -static void service_browser_callback( - AvahiServiceBrowser *b, - AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - const char *type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - oid_data* data = userdata; - char type_fixed[AVAHI_DOMAIN_NAME_MAX], domain_fixed[AVAHI_DOMAIN_NAME_MAX]; - sw_discovery_browse_reply reply; - - assert(b); - assert(data); - - reply = (sw_discovery_browse_reply) data->reply; - - type = add_trailing_dot(type, type_fixed, sizeof(type_fixed)); - domain = add_trailing_dot(domain, domain_fixed, sizeof(domain_fixed)); - - switch (event) { - case AVAHI_BROWSER_NEW: - reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_ADD_SERVICE, interface, name, type, domain, data->extra); - break; - - case AVAHI_BROWSER_REMOVE: - reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_REMOVE_SERVICE, interface, name, type, domain, data->extra); - break; - - case AVAHI_BROWSER_FAILURE: - reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, name, type, domain, data->extra); - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - } -} - -sw_result sw_discovery_browse( - sw_discovery self, - sw_uint32 interface_index, - sw_const_string type, - sw_const_string domain, - sw_discovery_browse_reply reply, - sw_opaque extra, - sw_discovery_oid * oid) { - - oid_data *data; - AvahiIfIndex ifindex; - sw_result result = SW_E_UNKNOWN; - - assert(self); - assert(type); - assert(reply); - assert(oid); - - AVAHI_WARN_LINKAGE; - - if ((*oid = oid_alloc(self, OID_SERVICE_BROWSER)) == (sw_discovery_oid) -1) - return SW_E_UNKNOWN; - - data = oid_get(self, *oid); - assert(data); - data->reply = (sw_result (*)(void)) reply; - data->extra = extra; - - ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index; - - ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - - if (!(data->object = avahi_service_browser_new(self->client, ifindex, AVAHI_PROTO_INET, type, domain, 0, service_browser_callback, data))) { - result = map_error(avahi_client_errno(self->client)); - goto finish; - } - - result = SW_OKAY; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - - if (result != SW_OKAY) - if (*oid != (sw_discovery_oid) -1) - sw_discovery_cancel(self, *oid); - - return result; -} - -sw_result sw_discovery_cancel(sw_discovery self, sw_discovery_oid oid) { - oid_data *data; - assert(self); - - AVAHI_WARN_LINKAGE; - - if (!(data = oid_get(self, oid))) - return SW_E_UNKNOWN; - - if (data->object) { - switch (data->type) { - case OID_SERVICE_BROWSER: - avahi_service_browser_free(data->object); - break; - - case OID_SERVICE_RESOLVER: - avahi_service_resolver_free(data->object); - break; - - case OID_DOMAIN_BROWSER: - avahi_domain_browser_free(data->object); - break; - - case OID_ENTRY_GROUP: - avahi_entry_group_free(data->object); - break; - - case OID_UNUSED: - ; - } - } - - if (data->service_data) { - assert(data->type == OID_ENTRY_GROUP); - service_data_free(self, data->service_data); - } - - oid_release(self, oid); - - return SW_OKAY; -} - -sw_result sw_discovery_init_with_flags( - sw_discovery * self, - sw_discovery_init_flags flags) { - - assert(self); - - AVAHI_WARN_LINKAGE; - - if (flags != SW_DISCOVERY_USE_SHARED_SERVICE) - return SW_E_NO_IMPL; - - return sw_discovery_init(self); -} diff --git a/avahi-compat-howl/funcs.txt b/avahi-compat-howl/funcs.txt deleted file mode 100644 index fad8ebf..0000000 --- a/avahi-compat-howl/funcs.txt +++ /dev/null @@ -1,182 +0,0 @@ --- Supported -- - -sw_discovery_init -sw_discovery_init_with_flags -sw_discovery_fina -sw_discovery_publish -sw_discovery_browse_domains -sw_discovery_browse -sw_discovery_resolve -sw_discovery_cancel -sw_discovery_run -sw_discovery_stop_run -sw_discovery_socket -sw_discovery_read_socket -sw_discovery_salt - -sw_text_record_init -sw_text_record_fina -sw_text_record_add_string -sw_text_record_add_key_and_string_value -sw_text_record_add_key_and_binary_value -sw_text_record_bytes -sw_text_record_len -sw_text_record_iterator_init -sw_text_record_iterator_fina -sw_text_record_iterator_next - -sw_ipv4_address_any -sw_ipv4_address_loopback -sw_ipv4_address_init -sw_ipv4_address_init_from_saddr -sw_ipv4_address_init_from_name -sw_ipv4_address_init_from_address -sw_ipv4_address_init_from_this_host -sw_ipv4_address_fina -sw_ipv4_address_is_any -sw_ipv4_address_saddr -sw_ipv4_address_name -sw_ipv4_address_decompose -sw_ipv4_address_equals - -sw_salt_step -sw_salt_lock -sw_salt_unlock -sw_salt_run -sw_salt_stop_run - --- Unsupported but Relevant -- - -sw_discovery_publish_update -sw_discovery_publish_host -sw_discovery_query_record - --- Unsupported and Irrelevant -- - -sw_strdup -sw_strerror -sw_timer_init -sw_timer_fina -sw_time_init -sw_time_init_now -sw_time_fina -sw_time_add -sw_time_sub -sw_time_cmp -sw_salt_init -sw_salt_fina -sw_salt_register_socket -sw_salt_unregister_socket -sw_salt_register_timer -sw_salt_unregister_timer -sw_salt_register_network_interface -sw_salt_unregister_network_interface_handler -sw_salt_register_signal -sw_salt_unregister_signal -sw_print_assert -sw_print_debug -sw_tcp_socket_init -sw_tcp_socket_init_with_desc -sw_udp_socket_init -sw_multicast_socket_init -sw_socket_fina -sw_socket_bind -sw_socket_join_multicast_group -sw_socket_leave_multicast_group -sw_socket_listen -sw_socket_connect -sw_socket_accept -sw_socket_send -sw_socket_sendto -sw_socket_recv -sw_socket_recvfrom -sw_socket_set_blocking_mode -sw_socket_set_options -sw_socket_ipv4_address -sw_socket_port -sw_socket_desc -sw_socket_close -sw_socket_options_init -sw_socket_options_fina -sw_socket_options_set_debug -sw_socket_options_set_nodelay -sw_socket_options_set_dontroute -sw_socket_options_set_keepalive -sw_socket_options_set_linger -sw_socket_options_set_reuseaddr -sw_socket_options_set_rcvbuf -sw_socket_options_set_sndbuf -sw_socket_error_code -sw_corby_orb_init -sw_corby_orb_fina -sw_corby_orb_register_servant -sw_corby_orb_unregister_servant -sw_corby_orb_register_bidirectional_object -sw_corby_orb_register_channel -sw_corby_orb_get_delegate -sw_corby_orb_set_delegate -sw_corby_orb_set_observer -sw_corby_orb_protocol_to_address -sw_corby_orb_protocol_to_url -sw_corby_orb_read_channel -sw_corby_orb_dispatch_message -sw_corby_message_init -sw_corby_message_fina -sw_corby_buffer_init -sw_corby_buffer_init_with_size -sw_corby_buffer_init_with_delegate -sw_corby_buffer_init_with_size_and_delegate -sw_corby_buffer_fina -sw_corby_buffer_reset -sw_corby_buffer_set_octets -sw_corby_buffer_octets -sw_corby_buffer_bytes_used -sw_corby_buffer_size -sw_corby_buffer_put_int8 -sw_corby_buffer_put_uint8 -sw_corby_buffer_put_int16 -sw_corby_buffer_put_uint16 -sw_corby_buffer_put_int32 -sw_corby_buffer_put_uint32 -sw_corby_buffer_put_octets -sw_corby_buffer_put_sized_octets -sw_corby_buffer_put_cstring -sw_corby_buffer_put_object -sw_corby_buffer_put_pad -sw_corby_buffer_get_int8 -sw_corby_buffer_get_uint8 -sw_corby_buffer_get_int16 -sw_corby_buffer_get_uint16 -sw_corby_buffer_get_int32 -sw_corby_buffer_get_uint32 -sw_corby_buffer_get_octets -sw_corby_buffer_allocate_and_get_sized_octets -sw_corby_buffer_get_zerocopy_sized_octets -sw_corby_buffer_get_sized_octets -sw_corby_buffer_allocate_and_get_cstring -sw_corby_buffer_get_zerocopy_cstring -sw_corby_buffer_get_cstring -sw_corby_buffer_get_object -sw_corby_channel_start_request -sw_corby_channel_start_reply -sw_corby_channel_send -sw_corby_channel_recv -sw_corby_channel_last_recv_from -sw_corby_channel_ff -sw_corby_channel_socket -sw_corby_channel_retain -sw_corby_channel_set_delegate -sw_corby_channel_get_delegate -sw_corby_channel_set_app_data -sw_corby_channel_get_app_data -sw_corby_channel_fina -sw_corby_object_init_from_url -sw_corby_object_fina -sw_corby_object_start_request -sw_corby_object_send -sw_corby_object_recv -sw_corby_object_channel -sw_corby_object_set_channel -sw_text_record_string_iterator_init -sw_text_record_string_iterator_fina -sw_text_record_string_iterator_next diff --git a/avahi-compat-howl/include/corby/buffer.h b/avahi-compat-howl/include/corby/buffer.h deleted file mode 100644 index 3c4416e..0000000 --- a/avahi-compat-howl/include/corby/buffer.h +++ /dev/null @@ -1,330 +0,0 @@ -#ifndef _sw_corby_buffer_h -#define _sw_corby_buffer_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -struct _sw_corby_buffer; -typedef struct _sw_corby_buffer * sw_corby_buffer; -struct _sw_corby_object; -typedef sw_opaque sw_corby_buffer_delegate; -typedef sw_opaque sw_corby_buffer_observer; - - -typedef enum _sw_corby_buffer_pad -{ - SW_CORBY_BUFFER_PAD_NONE, - SW_CORBY_BUFFER_PAD_ALIGN_2, - SW_CORBY_BUFFER_PAD_ALIGN_4, - SW_CORBY_BUFFER_PAD_ALIGN_8, - SW_CORBY_BUFFER_PAD_ALIGN_16, - SW_CORBY_BUFFER_PAD_ALIGN_32 -} sw_corby_buffer_pad; - - -typedef sw_result -(HOWL_API* sw_corby_buffer_written_func)( - sw_corby_buffer_observer observer, - sw_corby_buffer buffer, - sw_result result, - sw_size_t bytesWritten, - sw_opaque_t extra); - - -typedef sw_result -(HOWL_API* sw_corby_buffer_overflow_func)( - sw_corby_buffer_delegate delegate, - sw_corby_buffer buffer, - sw_uint8 octet, - sw_uint8 ** base, - sw_uint8 ** bptr, - sw_uint8 ** eptr, - sw_uint8 ** end, - sw_opaque_t extra); - - -typedef sw_result -(HOWL_API* sw_corby_buffer_underflow_func)( - sw_corby_buffer_delegate delegate, - sw_corby_buffer buffer, - sw_uint8 * octet, - sw_uint8 ** base, - sw_uint8 ** bptr, - sw_uint8 ** eptr, - sw_uint8 ** end, - sw_opaque_t extra); - - -sw_result HOWL_API -sw_corby_buffer_init( - sw_corby_buffer * self); - - -sw_result HOWL_API -sw_corby_buffer_init_with_size( - sw_corby_buffer * self, - sw_size_t size); - - -sw_result HOWL_API -sw_corby_buffer_init_with_delegate( - sw_corby_buffer * self, - sw_corby_buffer_delegate delegate, - sw_corby_buffer_overflow_func overflow, - sw_corby_buffer_underflow_func underflow, - sw_opaque_t extra); - - -sw_result HOWL_API -sw_corby_buffer_init_with_size_and_delegate( - sw_corby_buffer * self, - sw_size_t size, - sw_corby_buffer_delegate delegate, - sw_corby_buffer_overflow_func overflow, - sw_corby_buffer_underflow_func underflow, - sw_opaque_t extra); - - -sw_result HOWL_API -sw_corby_buffer_fina( - sw_corby_buffer self); - - -void HOWL_API -sw_corby_buffer_reset( - sw_corby_buffer self); - - -sw_result HOWL_API -sw_corby_buffer_set_octets( - sw_corby_buffer self, - sw_octets octets, - sw_size_t size); - - -sw_octets HOWL_API -sw_corby_buffer_octets( - sw_corby_buffer self); - - -sw_size_t HOWL_API -sw_corby_buffer_bytes_used( - sw_corby_buffer self); - - -sw_size_t HOWL_API -sw_corby_buffer_size( - sw_corby_buffer self); - - -sw_result HOWL_API -sw_corby_buffer_put_int8( - sw_corby_buffer self, - sw_int8 val); - - -sw_result HOWL_API -sw_corby_buffer_put_uint8( - sw_corby_buffer self, - sw_uint8 val); - - -sw_result HOWL_API -sw_corby_buffer_put_int16( - sw_corby_buffer self, - sw_int16 val); - - -sw_result HOWL_API -sw_corby_buffer_put_uint16( - sw_corby_buffer self, - sw_uint16 val); - - -sw_result HOWL_API -sw_corby_buffer_put_int32( - sw_corby_buffer self, - sw_int32 val); - - -sw_result HOWL_API -sw_corby_buffer_put_uint32( - sw_corby_buffer self, - sw_uint32 val); - - -sw_result HOWL_API -sw_corby_buffer_put_octets( - sw_corby_buffer self, - sw_const_octets val, - sw_size_t size); - - -sw_result HOWL_API -sw_corby_buffer_put_sized_octets( - sw_corby_buffer self, - sw_const_octets val, - sw_uint32 len); - - -sw_result HOWL_API -sw_corby_buffer_put_cstring( - sw_corby_buffer self, - sw_const_string val); - - -sw_result HOWL_API -sw_corby_buffer_put_object( - sw_corby_buffer self, - const struct _sw_corby_object * object); - - -sw_result HOWL_API -sw_corby_buffer_put_pad( - sw_corby_buffer self, - sw_corby_buffer_pad pad); - - -sw_result HOWL_API -sw_corby_buffer_get_int8( - sw_corby_buffer self, - sw_int8 * val); - - -sw_result HOWL_API -sw_corby_buffer_get_uint8( - sw_corby_buffer self, - sw_uint8 * val); - - -sw_result HOWL_API -sw_corby_buffer_get_int16( - sw_corby_buffer self, - sw_int16 * val, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_uint16( - sw_corby_buffer self, - sw_uint16 * val, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_int32( - sw_corby_buffer self, - sw_int32 * val, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_uint32( - sw_corby_buffer self, - sw_uint32 * val, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_octets( - sw_corby_buffer self, - sw_octets octets, - sw_size_t size); - - -sw_result HOWL_API -sw_corby_buffer_allocate_and_get_sized_octets( - sw_corby_buffer self, - sw_octets * val, - sw_uint32 * size, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_zerocopy_sized_octets( - sw_corby_buffer self, - sw_octets * val, - sw_uint32 * size, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_sized_octets( - sw_corby_buffer self, - sw_octets val, - sw_uint32 * len, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_allocate_and_get_cstring( - sw_corby_buffer self, - sw_string * val, - sw_uint32 * len, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_zerocopy_cstring( - sw_corby_buffer self, - sw_string * val, - sw_uint32 * len, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_cstring( - sw_corby_buffer self, - sw_string val, - sw_uint32 * len, - sw_uint8 endian); - - -sw_result HOWL_API -sw_corby_buffer_get_object( - sw_corby_buffer self, - struct _sw_corby_object ** object, - sw_uint8 endian); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/corby/channel.h b/avahi-compat-howl/include/corby/channel.h deleted file mode 100644 index 9c91fbb..0000000 --- a/avahi-compat-howl/include/corby/channel.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef _sw_corby_channel_h -#define _sw_corby_channel_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct _sw_corby_channel; -typedef struct _sw_corby_channel * sw_corby_channel; -struct _sw_corby_message; -struct _sw_corby_profile; -typedef struct _sw_corby_profile * sw_corby_profile; -typedef struct _sw_corby_profile const * sw_const_corby_profile; - - -typedef enum _sw_corby_reply_status -{ - SW_CORBY_NO_EXCEPTION = 0, - SW_CORBY_SYSTEM_EXCEPTION = 1, - SW_CORBY_USER_EXCEPTION = 2, - SW_CORBY_LOCATION_FORWARD = 3 -} sw_corby_reply_status; - - -typedef sw_result -(HOWL_API *sw_corby_channel_will_send_func)( - sw_corby_channel channel, - sw_octets bytes, - sw_size_t len, - sw_opaque_t extra); - - -typedef sw_result -(HOWL_API *sw_corby_channel_did_read_func)( - sw_corby_channel channel, - sw_octets bytes, - sw_size_t len, - sw_opaque_t extra); - - -typedef void -(HOWL_API *sw_corby_channel_cleanup_func)( - sw_corby_channel channel); - - -typedef struct _sw_corby_channel_delegate -{ - sw_opaque_t m_delegate; - sw_corby_channel_will_send_func m_will_send_func; - sw_corby_channel_did_read_func m_did_read_func; - sw_corby_channel_cleanup_func m_cleanup_func; - sw_opaque_t m_extra; -} * sw_corby_channel_delegate; - - -sw_result HOWL_API -sw_corby_channel_start_request( - sw_corby_channel self, - sw_const_corby_profile profile, - struct _sw_corby_buffer ** buffer, - sw_const_string op, - sw_uint32 oplen, - sw_bool reply_expected); - - -sw_result HOWL_API -sw_corby_channel_start_reply( - sw_corby_channel self, - struct _sw_corby_buffer ** buffer, - sw_uint32 request_id, - sw_corby_reply_status status); - - -sw_result HOWL_API -sw_corby_channel_send( - sw_corby_channel self, - struct _sw_corby_buffer * buffer, - sw_corby_buffer_observer observer, - sw_corby_buffer_written_func func, - sw_opaque_t extra); - - -sw_result HOWL_API -sw_corby_channel_recv( - sw_corby_channel self, - sw_salt * salt, - struct _sw_corby_message ** message, - sw_uint32 * request_id, - sw_string * op, - sw_uint32 * op_len, - struct _sw_corby_buffer ** buffer, - sw_uint8 * endian, - sw_bool block); - - -sw_result HOWL_API -sw_corby_channel_last_recv_from( - sw_corby_channel self, - sw_ipv4_address * from, - sw_port * from_port); - - -sw_result HOWL_API -sw_corby_channel_ff( - sw_corby_channel self, - struct _sw_corby_buffer * buffer); - - -sw_socket HOWL_API -sw_corby_channel_socket( - sw_corby_channel self); - - -sw_result HOWL_API -sw_corby_channel_retain( - sw_corby_channel self); - - -sw_result HOWL_API -sw_corby_channel_set_delegate( - sw_corby_channel self, - sw_corby_channel_delegate delegate); - - -sw_corby_channel_delegate HOWL_API -sw_corby_channel_get_delegate( - sw_corby_channel self); - - -void HOWL_API -sw_corby_channel_set_app_data( - sw_corby_channel self, - sw_opaque app_data); - - -sw_opaque HOWL_API -sw_corby_channel_get_app_data( - sw_corby_channel self); - - -sw_result HOWL_API -sw_corby_channel_fina( - sw_corby_channel self); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/corby/corby.h b/avahi-compat-howl/include/corby/corby.h deleted file mode 100644 index 5e069ff..0000000 --- a/avahi-compat-howl/include/corby/corby.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _corby_corby_h -#define _corby_corby_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include - -/* - * corby limits - */ -#define SW_CORBY_OID_LEN 32 - - -/* - * protocol tags. the only standard one is TAG_INTERNET_IIOP. - * the others are proprietary pandora corby protocols. - */ -#define SW_TAG_INTERNET_IOP 0 -#define SW_TAG_UIOP 250 -#define SW_TAG_MIOP 251 -#define SW_MIOP_ADDR "231.255.255.250" -typedef sw_uint32 sw_corby_protocol_tag; - - -/* - * error codes - */ -#define SW_E_CORBY_BASE 0x80000500 -#define SW_E_CORBY_UNKNOWN (SW_E_CORBY_BASE + 0) -#define SW_E_CORBY_BAD_CONFIG (SW_E_CORBY_BASE + 1) -#define SW_E_CORBY_NO_INTERFACE (SW_E_CORBY_BASE + 2) -#define SW_E_CORBY_BAD_URL (SW_E_CORBY_BASE + 3) -#define SW_E_CORBY_BAD_NAME (SW_E_CORBY_BASE + 4) -#define SW_E_CORBY_BAD_MESSAGE (SW_E_CORBY_BASE + 5) -#define SW_E_CORBY_BAD_VERSION (SW_E_CORBY_BASE + 6) -#define SW_E_CORBY_BAD_OID (SW_E_CORBY_BASE + 7) -#define SW_E_CORBY_BAD_OPERATION (SW_E_CORBY_BASE + 8) -#define SW_E_CORBY_MARSHAL (SW_E_CORBY_BASE + 10) -#define SW_E_CORBY_OBJECT_NOT_EXIST (SW_E_CORBY_BASE + 11) - - -#endif diff --git a/avahi-compat-howl/include/corby/message.h b/avahi-compat-howl/include/corby/message.h deleted file mode 100644 index a06c358..0000000 --- a/avahi-compat-howl/include/corby/message.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _sw_corby_message_h -#define _sw_corby_message_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -struct _sw_corby_message; -typedef struct _sw_corby_message * sw_corby_message; - - -sw_result HOWL_API -sw_corby_message_init( - sw_corby_message * self); - - -sw_result HOWL_API -sw_corby_message_fina( - sw_corby_message self); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/corby/object.h b/avahi-compat-howl/include/corby/object.h deleted file mode 100644 index 1cfd516..0000000 --- a/avahi-compat-howl/include/corby/object.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef _corby_object_h -#define _corby_object_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include -#include -#include -#include - -#if defined(__cplusplus) -extern "C" -{ -#endif - -struct _sw_corby_orb; -struct _sw_corby_object; -typedef struct _sw_corby_object * sw_corby_object; -typedef sw_opaque sw_corby_object_send_completion_handler; -typedef void -(HOWL_API *sw_corby_object_send_completion_func)( - sw_corby_object object, - sw_corby_buffer buffer, - sw_result result); - - - -sw_result HOWL_API -sw_corby_object_init_from_url( - sw_corby_object * self, - struct _sw_corby_orb * orb, - sw_const_string url, - sw_socket_options options, - sw_uint32 bufsize); - - -sw_result HOWL_API -sw_corby_object_fina( - sw_corby_object self); - - -sw_result HOWL_API -sw_corby_object_start_request( - sw_corby_object self, - sw_const_string op, - sw_uint32 op_len, - sw_bool reply_expected, - sw_corby_buffer * buffer); - - -sw_result HOWL_API -sw_corby_object_send( - sw_corby_object self, - sw_corby_buffer buffer, - sw_corby_buffer_observer observer, - sw_corby_buffer_written_func func, - sw_opaque extra); - - -sw_result HOWL_API -sw_corby_object_recv( - sw_corby_object self, - sw_corby_message * message, - sw_corby_buffer * buffer, - sw_uint8 * endian, - sw_bool block); - - -sw_result HOWL_API -sw_corby_object_channel( - sw_corby_object self, - sw_corby_channel * channel); - - -sw_result HOWL_API -sw_corby_object_set_channel( - sw_corby_object self, - sw_corby_channel channel); - - -#if defined(__cplusplus) -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/corby/orb.h b/avahi-compat-howl/include/corby/orb.h deleted file mode 100644 index 76af578..0000000 --- a/avahi-compat-howl/include/corby/orb.h +++ /dev/null @@ -1,199 +0,0 @@ -#ifndef _corby_orb_h -#define _corby_orb_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -struct _sw_corby_orb; -typedef struct _sw_corby_orb * sw_corby_orb; -typedef sw_opaque sw_corby_orb_observer; -typedef sw_opaque sw_corby_servant; -struct _sw_corby_object; -struct _sw_corby_channel; -struct _sw_corby_message; -struct _sw_corby_buffer; - -typedef sw_result -(HOWL_API *sw_corby_orb_accept_channel_func)( - sw_corby_orb orb, - struct _sw_corby_channel * channel); - - -typedef struct _sw_corby_orb_delegate -{ - sw_opaque m_delegate; - sw_corby_orb_accept_channel_func m_accept_channel_func; - sw_opaque m_extra; -} * sw_corby_orb_delegate; - - -typedef struct _sw_corby_orb_config -{ - sw_string m_name; - sw_uint32 m_tag; - sw_string m_host; - sw_port m_port; - sw_string m_options; -} sw_corby_orb_config; - - -typedef sw_result -(HOWL_API *sw_corby_servant_cb)( - sw_corby_servant servant, - sw_salt salt, - sw_corby_orb orb, - struct _sw_corby_channel * channel, - struct _sw_corby_message * message, - struct _sw_corby_buffer * buffer, - sw_const_string op, - sw_uint32 op_len, - sw_uint32 request_id, - sw_uint8 endian); - - -typedef sw_result -(HOWL_API *sw_corby_orb_observer_func)( - sw_corby_orb_observer handler, - sw_salt salt, - sw_corby_orb orb, - struct _sw_corby_channel * channel, - sw_opaque_t extra); - - -sw_result HOWL_API -sw_corby_orb_init( - sw_corby_orb * self, - sw_salt salt, - const sw_corby_orb_config * config, - sw_corby_orb_observer observer, - sw_corby_orb_observer_func func, - sw_opaque_t extra); - - -sw_result HOWL_API -sw_corby_orb_fina( - sw_corby_orb self); - - -sw_result HOWL_API -sw_corby_orb_register_servant( - sw_corby_orb self, - sw_corby_servant servant, - sw_corby_servant_cb cb, - sw_const_string oid, - struct _sw_corby_object ** object, - sw_const_string protocol_name); - - -sw_result HOWL_API -sw_corby_orb_unregister_servant( - sw_corby_orb self, - sw_const_string oid); - - -sw_result HOWL_API -sw_corby_orb_register_bidirectional_object( - sw_corby_orb self, - struct _sw_corby_object * object); - - -sw_result HOWL_API -sw_corby_orb_register_channel( - sw_corby_orb self, - struct _sw_corby_channel * channel); - - -sw_corby_orb_delegate HOWL_API -sw_corby_orb_get_delegate( - sw_corby_orb self); - - -sw_result HOWL_API -sw_corby_orb_set_delegate( - sw_corby_orb self, - sw_corby_orb_delegate delegate); - - -sw_result HOWL_API -sw_corby_orb_set_observer( - sw_corby_orb self, - sw_corby_orb_observer observer, - sw_corby_orb_observer_func func, - sw_opaque_t extra); - - -sw_result HOWL_API -sw_corby_orb_protocol_to_address( - sw_corby_orb self, - sw_const_string tag, - sw_string addr, - sw_port * port); - - -sw_result HOWL_API -sw_corby_orb_protocol_to_url( - sw_corby_orb self, - sw_const_string tag, - sw_const_string name, - sw_string url, - sw_size_t url_len); - - -sw_result HOWL_API -sw_corby_orb_read_channel( - sw_corby_orb self, - struct _sw_corby_channel * channel); - - -sw_result HOWL_API -sw_corby_orb_dispatch_message( - sw_corby_orb self, - struct _sw_corby_channel * channel, - struct _sw_corby_message * message, - struct _sw_corby_buffer * buffer, - sw_uint8 endian); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/discovery/discovery.h b/avahi-compat-howl/include/discovery/discovery.h deleted file mode 100644 index 082373d..0000000 --- a/avahi-compat-howl/include/discovery/discovery.h +++ /dev/null @@ -1,327 +0,0 @@ -#ifndef _discovery_discovery_h -#define _discovery_discovery_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include - - -#if defined(__cplusplus) -extern "C" -{ -#endif - - -struct _sw_discovery; -typedef struct _sw_discovery * sw_discovery; - - -/* - * keeps track of different discovery operations - */ -typedef sw_uint32 sw_discovery_oid; - - -/* - * For backwards compatibility - */ -#define sw_discovery_publish_host_id sw_discovery_oid -#define sw_discovery_publish_id sw_discovery_oid -#define sw_discovery_browse_id sw_discovery_oid -#define sw_discovery_resolve_id sw_discovery_oid - - -/* - * how to connect to server - */ -typedef enum _sw_discovery_init_flags -{ - SW_DISCOVERY_USE_SHARED_SERVICE = 0x1, - SW_DISCOVERY_USE_PRIVATE_SERVICE = 0x2, - SW_DISCOVERY_SKIP_VERSION_CHECK = 0x4 -} sw_discovery_init_flags; - - -/* - * status for asynchronous registration call - */ -typedef enum _sw_discovery_publish_status -{ - SW_DISCOVERY_PUBLISH_STARTED, - SW_DISCOVERY_PUBLISH_STOPPED, - SW_DISCOVERY_PUBLISH_NAME_COLLISION, - SW_DISCOVERY_PUBLISH_INVALID -} sw_discovery_publish_status; - - -typedef enum _sw_discovery_browse_status -{ - SW_DISCOVERY_BROWSE_INVALID, - SW_DISCOVERY_BROWSE_RELEASE, - SW_DISCOVERY_BROWSE_ADD_DOMAIN, - SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN, - SW_DISCOVERY_BROWSE_REMOVE_DOMAIN, - SW_DISCOVERY_BROWSE_ADD_SERVICE, - SW_DISCOVERY_BROWSE_REMOVE_SERVICE, - SW_DISCOVERY_BROWSE_RESOLVED -} sw_discovery_browse_status; - - -typedef enum _sw_discovery_query_record_status -{ - SW_DISCOVERY_QUERY_RECORD_ADD = 0x1 -} sw_discovery_query_record_status; - - -typedef sw_result -(HOWL_API *sw_discovery_publish_reply)( - sw_discovery session, - sw_discovery_oid oid, - sw_discovery_publish_status status, - sw_opaque extra); - -typedef sw_result -(HOWL_API *sw_discovery_browse_reply)( - sw_discovery session, - sw_discovery_oid oid, - sw_discovery_browse_status status, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_opaque extra); - -typedef sw_result -(HOWL_API *sw_discovery_resolve_reply)( - sw_discovery session, - sw_discovery_oid oid, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_ipv4_address address, - sw_port port, - sw_octets text_record, - sw_uint32 text_record_len, - sw_opaque extra); - - -typedef sw_result -(HOWL_API *sw_discovery_query_record_reply)( - sw_discovery session, - sw_discovery_oid oid, - sw_discovery_query_record_status status, - sw_uint32 interface_index, - sw_const_string fullname, - sw_uint16 rrtype, - sw_uint16 rrclass, - sw_uint16 rrdatalen, - sw_const_octets rrdata, - sw_uint32 ttl, - sw_opaque extra); - - -/* - * API for publishing/browsing/resolving services - */ -sw_result HOWL_API -sw_discovery_init( - sw_discovery * self); - - -sw_result HOWL_API -sw_discovery_init_with_flags( - sw_discovery * self, - sw_discovery_init_flags flags); - - -sw_result HOWL_API -sw_discovery_fina( - sw_discovery self); - - -sw_result HOWL_API -sw_discovery_publish_host( - sw_discovery self, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string domain, - sw_ipv4_address address, - sw_discovery_publish_reply reply, - sw_opaque extra, - sw_discovery_oid * oid); - - -sw_result HOWL_API -sw_discovery_publish( - sw_discovery self, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_const_string host, - sw_port port, - sw_octets text_record, - sw_uint32 text_record_len, - sw_discovery_publish_reply reply, - sw_opaque extra, - sw_discovery_oid * oid); - - -sw_result HOWL_API -sw_discovery_publish_update( - sw_discovery self, - sw_discovery_oid oid, - sw_octets text_record, - sw_uint32 text_record_len); - - - -/* - * API for browsing domains - */ -sw_result HOWL_API -sw_discovery_browse_domains( - sw_discovery self, - sw_uint32 interface_index, - sw_discovery_browse_reply reply, - sw_opaque extra, - sw_discovery_oid * oid); - - - -/* - * API for browsing services - */ -sw_result HOWL_API -sw_discovery_browse( - sw_discovery self, - sw_uint32 interface_index, - sw_const_string type, - sw_const_string domain, - sw_discovery_browse_reply reply, - sw_opaque extra, - sw_discovery_oid * oid); - - -/* - * API for resolving services - */ -sw_result HOWL_API -sw_discovery_resolve( - sw_discovery self, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_discovery_resolve_reply reply, - sw_opaque extra, - sw_discovery_oid * oid); - - -sw_result HOWL_API -sw_discovery_query_record( - sw_discovery self, - sw_uint32 interface_index, - sw_uint32 flags, - sw_const_string fullname, - sw_uint16 rrtype, - sw_uint16 rrclass, - sw_discovery_query_record_reply reply, - sw_opaque extra, - sw_discovery_oid * oid); - - -sw_result HOWL_API -sw_discovery_cancel( - sw_discovery self, - sw_discovery_oid oid); - - - -/* ---------------------------------------------------------- - * - * Event Processing APIs - * - * ---------------------------------------------------------- - */ - - -sw_result HOWL_API -sw_discovery_run( - sw_discovery self); - - -sw_result HOWL_API -sw_discovery_stop_run( - sw_discovery self); - - -int HOWL_API -sw_discovery_socket( - sw_discovery self); - - -sw_result HOWL_API -sw_discovery_read_socket( - sw_discovery self); - - -sw_result HOWL_API -sw_discovery_salt( - sw_discovery self, - sw_salt * salt); - - -/* - * Error codes - */ -#define SW_DISCOVERY_E_BASE 900 -#define SW_DISCOVERY_E_UNKNOWN (SW_DISCOVERY_E_BASE + 2) -#define SW_DISCOVERY_E_NO_SUCH_NAME (SW_DISCOVERY_E_BASE + 3) -#define SW_DISCOVERY_E_NO_MEM (SW_DISCOVERY_E_BASE + 4) -#define SW_DISCOVERY_E_BAD_PARAM (SW_DISCOVERY_E_BASE + 5) -#define SW_DISCOVERY_E_BAD_REFERENCE (SW_DISCOVERY_E_BASE + 6) -#define SW_DISCOVERY_E_BAD_STATE (SW_DISCOVERY_E_BASE + 7) -#define SW_DISCOVERY_E_BAD_FLAGS (SW_DISCOVERY_E_BASE + 8) -#define SW_DISCOVERY_E_NOT_SUPPORTED (SW_DISCOVERY_E_BASE + 9) -#define SW_DISCOVERY_E_NOT_INITIALIZED (SW_DISCOVERY_E_BASE + 10) -#define SW_DISCOVERY_E_NO_CACHE (SW_DISCOVERY_E_BASE + 11) -#define SW_DISCOVERY_E_ALREADY_REGISTERED (SW_DISCOVERY_E_BASE + 12) -#define SW_DISCOVERY_E_NAME_CONFLICT (SW_DISCOVERY_E_BASE + 13) -#define SW_DISCOVERY_E_INVALID (SW_DISCOVERY_E_BASE + 14) - - -#if defined(__cplusplus) -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/discovery/text_record.h b/avahi-compat-howl/include/discovery/text_record.h deleted file mode 100644 index a5ee802..0000000 --- a/avahi-compat-howl/include/discovery/text_record.h +++ /dev/null @@ -1,143 +0,0 @@ -#ifndef _discovery_text_record_h -#define _discovery_text_record_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include - -#if defined(__cplusplus) -extern "C" -{ -#endif - -#define SW_TEXT_RECORD_MAX_LEN 255 - - -struct _sw_text_record; -typedef struct _sw_text_record * sw_text_record; -struct _sw_text_record_iterator; -typedef struct _sw_text_record_iterator * sw_text_record_iterator; -struct _sw_text_record_string_iterator; -typedef struct _sw_text_record_string_iterator * sw_text_record_string_iterator; - - -/* - * Text record APIs - */ -sw_result HOWL_API -sw_text_record_init( - sw_text_record * self); - - -sw_result HOWL_API -sw_text_record_fina( - sw_text_record self); - - -sw_result HOWL_API -sw_text_record_add_string( - sw_text_record self, - sw_const_string string); - - -sw_result HOWL_API -sw_text_record_add_key_and_string_value( - sw_text_record self, - sw_const_string key, - sw_const_string val); - - -sw_result HOWL_API -sw_text_record_add_key_and_binary_value( - sw_text_record self, - sw_const_string key, - sw_octets val, - sw_uint32 len); - - -sw_octets HOWL_API -sw_text_record_bytes( - sw_text_record self); - - -sw_uint32 HOWL_API -sw_text_record_len( - sw_text_record self); - - -/* - * APIs for iterating through raw text records - */ -sw_result HOWL_API -sw_text_record_iterator_init( - sw_text_record_iterator * self, - sw_octets text_record, - sw_uint32 text_record_len); - - -sw_result HOWL_API -sw_text_record_iterator_fina( - sw_text_record_iterator self); - - -sw_result HOWL_API -sw_text_record_iterator_next( - sw_text_record_iterator self, - char key[SW_TEXT_RECORD_MAX_LEN], - sw_uint8 val[SW_TEXT_RECORD_MAX_LEN], - sw_uint32 * val_len); - - -/* - * APIs for iterating through stringified text records - */ -sw_result HOWL_API -sw_text_record_string_iterator_init( - sw_text_record_string_iterator * self, - sw_const_string text_record_string); - - -sw_result HOWL_API -sw_text_record_string_iterator_fina( - sw_text_record_string_iterator self); - - -sw_result HOWL_API -sw_text_record_string_iterator_next( - sw_text_record_string_iterator self, - char key[SW_TEXT_RECORD_MAX_LEN], - char val[SW_TEXT_RECORD_MAX_LEN]); - - -#if defined(__cplusplus) -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/howl.h b/avahi-compat-howl/include/howl.h deleted file mode 100644 index dac6d43..0000000 --- a/avahi-compat-howl/include/howl.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _sw_howl_h -#define _sw_howl_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#endif diff --git a/avahi-compat-howl/include/rendezvous/rendezvous.h b/avahi-compat-howl/include/rendezvous/rendezvous.h deleted file mode 100644 index 12c85e8..0000000 --- a/avahi-compat-howl/include/rendezvous/rendezvous.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef _rendezvous_rendezvous_h -#define _rendezvous_rendezvous_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include - -#define _sw_rendezvous _sw_discovery -#define sw_rendezvous sw_discovery -#define sw_rendezvous_publish_domain_id sw_discovery_publish_domain_id -#define sw_rendezvous_publish_host_id sw_discovery_publish_host_id -#define sw_rendezvous_publish_id sw_discovery_publish_id -#define sw_rendezvous_browse_id sw_discovery_browse_id -#define sw_rendezvous_resolve_id sw_discovery_resolve_id -#define sw_rendezvous_publish_status sw_discovery_publish_status -#define SW_RENDEZVOUS_PUBLISH_STARTED SW_DISCOVERY_PUBLISH_STARTED -#define SW_RENDEZVOUS_PUBLISH_STOPPED SW_DISCOVERY_PUBLISH_STOPPED -#define SW_RENDEZVOUS_PUBLISH_NAME_COLLISION SW_DISCOVERY_PUBLISH_NAME_COLLISION -#define SW_RENDEZVOUS_PUBLISH_INVALID SW_DISCOVERY_PUBLISH_INVALID -#define sw_rendezvous_browse_status sw_discovery_browse_status -#define SW_RENDEZVOUS_BROWSE_INVALID SW_DISCOVERY_BROWSE_INVALID -#define SW_RENDEZVOUS_BROWSE_RELEASE SW_DISCOVERY_BROWSE_RELEASE -#define SW_RENDEZVOUS_BROWSE_ADD_DOMAIN SW_DISCOVERY_BROWSE_ADD_DOMAIN -#define SW_RENDEZVOUS_BROWSE_ADD_DEFAULT_DOMAIN SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN -#define SW_RENDEZVOUS_BROWSE_REMOVE_DOMAIN SW_DISCOVERY_BROWSE_REMOVE_DOMAIN -#define SW_RENDEZVOUS_BROWSE_ADD_SERVICE SW_DISCOVERY_BROWSE_ADD_SERVICE -#define SW_RENDEZVOUS_BROWSE_REMOVE_SERVICE SW_DISCOVERY_BROWSE_REMOVE_SERVICE -#define SW_RENDEZVOUS_BROWSE_RESOLVED SW_DISCOVERY_BROWSE_RESOLVED -#define sw_rendezvous_publish_domain_handler sw_discovery_publish_domain_handler -#define sw_rendezvous_publish_domain_reply sw_discovery_publish_domain_reply -#define sw_rendezvous_publish_host_handler sw_discovery_publish_host_handler -#define sw_rendezvous_publish_host_reply sw_discovery_publish_host_reply -#define sw_rendezvous_publish_handler sw_discovery_publish_handler -#define sw_rendezvous_publish_reply sw_discovery_publish_reply -#define sw_rendezvous_browse_handler sw_discovery_browse_handler -#define sw_rendezvous_browse_reply sw_discovery_browse_reply -#define sw_rendezvous_resolve_handler sw_discovery_resolve_handler -#define sw_rendezvous_resolve_reply sw_discovery_resolve_reply -#define sw_rendezvous_init sw_discovery_init -#define sw_rendezvous_fina sw_discovery_fina -#define sw_rendezvous_publish_domain sw_discovery_publish_domain -#define sw_rendezvous_stop_publish_domain sw_discovery_stop_publish_domain -#define sw_rendezvous_publish_host sw_discovery_publish_host -#define sw_rendezvous_stop_publish_host sw_discovery_stop_publish_host -#define sw_rendezvous_publish sw_discovery_publish -#define sw_rendezvous_publish_update sw_discovery_publish_update -#define sw_rendezvous_stop_publish sw_discovery_stop_publish -#define sw_rendezvous_browse_domains sw_discovery_browse_domains -#define sw_rendezvous_stop_browse_domains sw_discovery_stop_browse_domains -#define sw_rendezvous_browse_services sw_discovery_browse -#define sw_rendezvous_stop_browse_services sw_discovery_stop_browse -#define sw_rendezvous_resolve sw_discovery_resolve -#define sw_rendezvous_stop_resolve sw_discovery_stop_resolve -#define sw_rendezvous_run sw_discovery_run -#define sw_rendezvous_stop_run sw_discovery_stop_run -#define sw_rendezvous_socket sw_discovery_socket -#define sw_rendezvous_read_socket sw_discovery_read_socket -#define sw_rendezvous_salt sw_discovery_salt -#define SW_RENDEZVOUS_E_BASE SW_DISCOVERY_E_BASE -#define SW_RENDEZVOUS_E_UNKNOWN SW_DISCOVERY_E_UNKNOWN -#define SW_RENDEZVOUS_E_NO_SUCH_NAME SW_DISCOVERY_E_NO_SUCH_NAME -#define SW_RENDEZVOUS_E_NO_MEM SW_DISCOVERY_E_NO_MEM -#define SW_RENDEZVOUS_E_BAD_PARAM SW_DISCOVERY_E_BAD_PARAM -#define SW_RENDEZVOUS_E_BAD_REFERENCE SW_DISCOVERY_E_BAD_REFERENCE -#define SW_RENDEZVOUS_E_BAD_STATE SW_DISCOVERY_E_BAD_STATE -#define SW_RENDEZVOUS_E_BAD_FLAGS SW_DISCOVERY_E_BAD_FLAGS -#define SW_RENDEZVOUS_E_NOT_SUPPORTED SW_DISCOVERY_E_NOT_SUPPORTED -#define SW_RENDEZVOUS_E_NOT_INITIALIZED SW_DISCOVERY_E_NOT_INITIALIZED -#define SW_RENDEZVOUS_E_NO_CACHE SW_DISCOVERY_E_NO_CACHE -#define SW_RENDEZVOUS_E_ALREADY_REGISTERED SW_DISCOVERY_E_ALREADY_REGISTERED -#define SW_RENDEZVOUS_E_NAME_CONFLICT SW_DISCOVERY_E_NAME_CONFLICT -#define SW_RENDEZVOUS_E_INVALID SW_DISCOVERY_E_INVALID - - -#endif diff --git a/avahi-compat-howl/include/rendezvous/text_record.h b/avahi-compat-howl/include/rendezvous/text_record.h deleted file mode 100644 index 3e2bfc2..0000000 --- a/avahi-compat-howl/include/rendezvous/text_record.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _rendezvous_text_record_h -#define _rendezvous_text_record_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - - -#include - - -#endif diff --git a/avahi-compat-howl/include/salt/address.h b/avahi-compat-howl/include/salt/address.h deleted file mode 100644 index ea83f8d..0000000 --- a/avahi-compat-howl/include/salt/address.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef _salt_address_h -#define _salt_address_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - - -#include - - -#if defined(__cplusplus) -extern "C" -{ -#endif - - -typedef struct _sw_ipv4_address -{ - sw_uint32 m_addr; -} sw_ipv4_address; - -typedef sw_uint32 sw_saddr; - - -sw_ipv4_address HOWL_API -sw_ipv4_address_any(void); - - -sw_ipv4_address HOWL_API -sw_ipv4_address_loopback(void); - - -sw_result HOWL_API -sw_ipv4_address_init( - sw_ipv4_address * self); - - -sw_result HOWL_API -sw_ipv4_address_init_from_saddr( - sw_ipv4_address * self, - sw_saddr saddr); - - -sw_result HOWL_API -sw_ipv4_address_init_from_name( - sw_ipv4_address * self, - sw_const_string name); - - -sw_result HOWL_API -sw_ipv4_address_init_from_address( - sw_ipv4_address * self, - sw_ipv4_address addr); - - -sw_result HOWL_API -sw_ipv4_address_init_from_this_host( - sw_ipv4_address * self); - - -sw_result HOWL_API -sw_ipv4_address_fina( - sw_ipv4_address self); - - -sw_bool HOWL_API -sw_ipv4_address_is_any( - sw_ipv4_address self); - - -sw_saddr HOWL_API -sw_ipv4_address_saddr( - sw_ipv4_address self); - - -sw_string HOWL_API -sw_ipv4_address_name( - sw_ipv4_address self, - sw_string name, - sw_uint32 len); - - -sw_result HOWL_API -sw_ipv4_address_decompose( - sw_ipv4_address self, - sw_uint8 * a1, - sw_uint8 * a2, - sw_uint8 * a3, - sw_uint8 * a4); - - -sw_bool HOWL_API -sw_ipv4_address_equals( - sw_ipv4_address self, - sw_ipv4_address addr); - - -#if defined(__cplusplus) -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/salt/debug.h b/avahi-compat-howl/include/salt/debug.h deleted file mode 100644 index c53977b..0000000 --- a/avahi-compat-howl/include/salt/debug.h +++ /dev/null @@ -1,230 +0,0 @@ -#ifndef _salt_debug_h -#define _salt_debug_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -#define SW_LOG_WARNING 1 << 0 -#define SW_LOG_ERROR 1 << 1 -#define SW_LOG_NOTICE 1 << 2 -#define SW_LOG_VERBOSE 1 << 3 -#define SW_LOG_OFF 0x0 - - -#if (defined( __GNUC__)) - -# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) - -# define __C99_VA_ARGS__ 1 - -# define __GNU_VA_ARGS__ 0 - -# else - -# define __C99_VA_ARGS__ 0 - -# define __GNU_VA_ARGS__ 1 - -# endif - -#else - -# define __C99_VA_ARGS__ 0 - -# define __GNU_VA_ARGS__ 0 - -#endif - - -# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 9))) - -# define __SW_FUNCTION__ __func__ - -#elif (defined( __GNUC__)) - -# define __SW_FUNCTION__ __PRETTY_FUNCTION__ - -#elif( defined(_MSC_VER ) && !defined(_WIN32_WCE)) - -# define __SW_FUNCTION__ __FUNCTION__ - -#else - -# define __SW_FUNCTION__ "" - -#endif - - -#define sw_check(expr, label, action) \ -do \ -{ \ - if (!(expr)) \ - { \ - { \ - action; \ - } \ - goto label; \ - } \ -} while (0) - - -#define sw_check_log(expr, label, action) \ -do \ -{ \ - if (!(expr)) \ - { \ - sw_print_assert(0, NULL, __FILE__, __SW_FUNCTION__, __LINE__); \ - { \ - action; \ - } \ - goto label; \ - } \ -} while (0) - - -#define sw_check_okay(code, label) \ -do \ -{ \ - if ((int) code != 0) \ - { \ - goto label; \ - } \ -} while (0) - - -#define sw_check_okay_log(code, label) \ -do \ -{ \ - if ((int) code != 0) \ - { \ - sw_print_assert((int) code, NULL, __FILE__, __SW_FUNCTION__, __LINE__); \ - goto label; \ - } \ -} while ( 0 ) - - -#define sw_translate_error(expr, errno) ((expr) ? 0 : (errno)) - - -#if defined(WIN32) - -# define sw_socket_errno() (int) WSAGetLastError() -# define sw_set_socket_errno(X) WSASetLastError(X) -# define sw_system_errno() (int) GetLastError() -# define sw_set_system_errno(X) SetLastError(X) - -#else - -# define sw_socket_errno() errno -# define sw_set_socket_errno(X) errno = X -# define sw_system_errno() errno -# define sw_set_system_errno(X) errno = X - -#endif - - -#if !defined(NDEBUG) - -# define sw_assert(X) \ - \ - do \ - { \ - if (!(X)) \ - { \ - sw_print_assert( 0, #X, __FILE__, __SW_FUNCTION__, __LINE__); \ - } \ - } while( 0 ) - -#else - -# define sw_assert(X) - -#endif - - -void HOWL_API -sw_print_assert( - int code, - sw_const_string assert_string, - sw_const_string file, - sw_const_string func, - int line); - - -#if !defined(NDEBUG) - -void HOWL_API -sw_print_debug( - int level, - sw_const_string format, - ...); - -# if (__C99_VA_ARGS__) - -# define sw_debug(...) sw_print_debug(__VA_ARGS__) - -# else - -# define sw_debug sw_print_debug - -# endif - -#else - -# if (__C99_VA_ARGS__) - -# define sw_debug(...) - -# else - -# define sw_debug while( 0 ) - -# endif - -#endif - - -#define SW_UNUSED_PARAM(X) (void) (X) - - -#if defined(__cplusplus) -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/salt/interface.h b/avahi-compat-howl/include/salt/interface.h deleted file mode 100644 index a4b1b1d..0000000 --- a/avahi-compat-howl/include/salt/interface.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef _sw_interface_h -#define _sw_interface_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include - -struct _sw_network_interface; -typedef struct _sw_network_interface * sw_network_interface; - - -typedef enum _sw_network_interface_state -{ - SW_NETWORK_INTERFACE_RUNNING = 0x1, -} sw_network_interface_state; - - -typedef struct _sw_mac_address -{ - sw_uint8 m_id[6]; -} sw_mac_address; - - -sw_result HOWL_API -sw_network_interfaces( - sw_uint32 * count, - sw_network_interface ** netifs); - - -sw_result HOWL_API -sw_network_interfaces_fina( - sw_uint32 count, - sw_network_interface * netifs); - - -sw_result HOWL_API -sw_network_interface_fina( - sw_network_interface netif); - - -sw_result HOWL_API -sw_network_interface_by_name( - sw_string name, - sw_network_interface * netif); - - -sw_result HOWL_API -sw_network_interface_name( - sw_network_interface netif, - sw_string name, - sw_uint32 len); - - -sw_result HOWL_API -sw_network_interface_mac_address( - sw_network_interface netif, - sw_mac_address * addr); - - -sw_result HOWL_API -sw_network_interface_ipv4_address( - sw_network_interface netif, - sw_ipv4_address * addr); - - -sw_result HOWL_API -sw_network_interface_set_ipv4_address( - sw_network_interface netif, - sw_ipv4_address addr); - - -sw_result HOWL_API -sw_network_interface_index( - sw_network_interface netif, - sw_uint32 * index); - - -sw_result HOWL_API -sw_network_interface_linked( - sw_network_interface netif, - sw_bool * linked); - - -sw_result HOWL_API -sw_network_interface_up( - sw_network_interface netif); - - -#endif diff --git a/avahi-compat-howl/include/salt/platform.h b/avahi-compat-howl/include/salt/platform.h deleted file mode 100644 index 6bb9dcc..0000000 --- a/avahi-compat-howl/include/salt/platform.h +++ /dev/null @@ -1,438 +0,0 @@ -#ifndef _sw_platform_h -#define _sw_platform_h - -/* - * Copyright 2003, 2004 Porchdog Software, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software, Inc. - */ - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -#if defined(__VXWORKS__) - -# define HOWL_API -# include -# include - -# define sw_snooze(SECS) taskDelay(sysClkRateGet() * SECS) - -#elif defined(WIN32) - -# define WIN32_LEAN_AND_MEAN -# define HOWL_API __stdcall -# pragma warning(disable:4127) -# include -# include - -typedef signed char int8_t; -typedef unsigned char u_int8_t; -typedef signed short int16_t; -typedef unsigned short u_int16_t; -typedef signed long int32_t; -typedef unsigned long u_int32_t; -typedef _int64 int64_t; -typedef _int64 u_int64_t; - -# define sw_snooze(SECS) Sleep(SECS * 1000) - -#else - -# define HOWL_API -# if defined(HOWL_KERNEL) -# include -# endif -# include -# include -# include - -# define sw_snooze(SECS) sleep(SECS) - -#endif - -#if defined(__sun) - -# define u_int8_t uint8_t -# define u_int16_t uint16_t -# define u_int32_t uint32_t -# define u_int64_t uint64_t - -#endif - -typedef void * sw_opaque; -typedef void * sw_opaque_t; -typedef int8_t sw_int8; -typedef u_int8_t sw_uint8; -typedef u_int8_t sw_bool; -typedef int16_t sw_int16; -typedef u_int16_t sw_uint16; -typedef int32_t sw_int32; -typedef u_int32_t sw_uint32; -typedef int64_t sw_int64; -typedef u_int64_t sw_uint64; -typedef char * sw_string; -typedef sw_uint8 * sw_octets; -#if !defined(__VXWORKS__) || defined(__cplusplus) -typedef const char * sw_const_string; -typedef const u_int8_t * sw_const_octets; -#else -typedef char * sw_const_string; -typedef u_int8_t * sw_const_octets; -#endif -typedef size_t sw_size_t; -typedef int sw_result; - - - -/* -------------------------------------------------------- - * - * Endian-osity - * - * SW_ENDIAN is 0 for big endian platforms, 1 - * for little endian platforms. - * - * The macro WORDS_BIGENDIAN will be defined - * by autoconf. If you are using Howl on - * a platform that doesn't have autoconf, define - * SW_ENDIAN directly - * -------------------------------------------------------- - */ - -#if !defined(SW_ENDIAN) - -# if defined(WORDS_BIGENDIAN) && WORDS_BIGENDIAN == 1 - -# define SW_ENDIAN 0 - -# else - -# define SW_ENDIAN 1 - -# endif - -#endif - - -/* -------------------------------------------------------- - * - * Strings - * - * These macros supports cross platform string functions - * for the following OSes - * - * Win32 - * *NIX - * PalmOS - * VxWorks - * - * -------------------------------------------------------- - */ - -#if defined(WIN32) - -# include - -# define sw_memset(ARG1, ARG2, ARG3) memset((char*) ARG1, ARG2, ARG3) -# define sw_memcpy(ARG1, ARG2, ARG3) memmove((char*) ARG1, (char*) ARG2, ARG3) -# define sw_memcmp(ARG1, ARG2, ARG3) memcmp((char*) ARG1, ARG2, ARG3) -# define sw_strcasecmp(ARG1, ARG2) stricmp(ARG1, ARG2) -# define sw_strncasecmp(ARG1, ARG2) strnicmp(ARG1, ARG2) -# define sw_strcat(ARG1, ARG2) strcat(ARG1, ARG2) -# define sw_strncat(ARG1, ARG2) strncat(ARG1, ARG2) -# define sw_strchr(ARG1, ARG2) strchr(ARG1, ARG2) -# define sw_strcmp(ARG1, ARG2) strcmp(ARG1, ARG2) -# define sw_strncmp(ARG1, ARG2) strncmp(ARG1, ARG2) -# define sw_strcoll(ARG1, ARG2) strcoll(ARG1, ARG2) -# define sw_strcpy(ARG1, ARG2) (ARG2) ? strcpy(ARG1, ARG2) : strcpy(ARG1, "") -# define sw_strncpy(ARG1, ARG2, N) (ARG2) ? strncpy(ARG1, ARG2, N) : strcpy(ARG1, "") -# define sw_strcspn(ARG1, ARG2) strcspn(ARG1, ARG2) -# define sw_strlen(ARG1) strlen(ARG1) -# define sw_strstr(ARG1, ARG2) strstr(ARG1, ARG2) -# define sw_strtok_r(ARG1, ARG2, ARG3) strtok_r(ARG1, ARG2, ARG3) - -#elif defined(__VXWORKS__) - -# include - -extern sw_int32 -sw_strcasecmp( - sw_const_string arg1, - sw_const_string arg2); - -extern sw_int32 -sw_strncasecmp( - sw_const_string arg1, - sw_const_string arg2, - sw_len n); - -extern sw_string -sw_strtok_r( - sw_string arg1, - sw_const_string arg2, - sw_string * lasts); - -# define sw_memset(ARG1, ARG2, ARG3) memset((char*) ARG1, ARG2, ARG3) -# define sw_memcpy(ARG1, ARG2, ARG3) memcpy((char*) ARG1, (char*) ARG2, ARG3) -# define sw_memcmp(ARG1, ARG2, ARG3) memcmp((char*) ARG1, ARG2, ARG3) -# define sw_strcat(ARG1, ARG2) strcat(ARG1, ARG2) -# define sw_strncat(ARG1, ARG2) strncat(ARG1, ARG2) -# define sw_strchr(ARG1, ARG2) strchr(ARG1, ARG2) -# define sw_strcmp(ARG1, ARG2) strcmp(ARG1, ARG2) -# define sw_strncmp(ARG1, ARG2) strncmp(ARG1, ARG2) -# define sw_strcoll(ARG1, ARG2) strcoll(ARG1, ARG2) -# define sw_strcpy(ARG1, ARG2) ARG2 ? strcpy(ARG1, ARG2) : strcpy(ARG1, "") -# define sw_strncpy(ARG1, ARG2, N) ARG2 ? strncpy(ARG1, ARG2, N) : strcpy(ARG1, "") -# define sw_strcspn(ARG1, ARG2) strcspn(ARG1, ARG2) -# define sw_strlen(ARG1) strlen(ARG1) -# define sw_strstr(ARG1, ARG2) strstr(ARG1, ARG2) - -#elif defined(__PALMOS__) - -# include - -# define sw_strcasecmp(ARG1, ARG2) strcasecmp(ARG1, ARG2) -# define sw_strncasecmp(ARG1, ARG2) strncasecmp(ARG1, ARG2) -# define sw_strcat(ARG1, ARG2) StrCat(ARG1, ARG2) -# define sw_strncat(ARG1, ARG2) StrNCat(ARG1, ARG2) -# define sw_strchr(ARG1, ARG2) StrChr(ARG1, ARG2) -# define sw_strcmp(ARG1, ARG2) StrCampare(ARG1, ARG2) -# define sw_strncmp(ARG1, ARG2) StrNCompare(ARG1, ARG2) -# define sw_strcoll(ARG1, ARG2) strcoll(ARG1, ARG2) -# define sw_strcpy(ARG1, ARG2) ARG2 ? StrCopy(ARG1, ARG2) : StrCopy(ARG1, "") -# define sw_strncpy(ARG1, ARG2, N) ARG2 ? StrNCopy(ARG1, ARG2, N) : StrCopy(ARG1, "") -# define sw_strcspn(ARG1, ARG2) strcspn(ARG1, ARG2) -# define sw_strlen(ARG1) StrLen(ARG1) -# define sw_strstr(ARG1, ARG2) strstr(ARG1, ARG2) -# define sw_strtok_r(ARG1, ARG2, ARG3) strtok_r(ARG1, ARG2, ARG3) - -#else - -# include - -# if defined(__Lynx__) - char * strchr(char*, int); -# endif - -# define sw_memset(ARG1, ARG2, ARG3) memset((char*) ARG1, ARG2, ARG3) -# define sw_memcpy(ARG1, ARG2, ARG3) memcpy((char*) ARG1, (char*) ARG2, ARG3) -# define sw_memcmp(ARG1, ARG2, ARG3) memcmp((char*) ARG1, ARG2, ARG3) -# define sw_strcasecmp(ARG1, ARG2) strcasecmp(ARG1, ARG2) -# define sw_strncasecmp(ARG1, ARG2) strncasecmp(ARG1, ARG2) -# define sw_strcat(ARG1, ARG2) strcat(ARG1, ARG2) -# define sw_strncat(ARG1, ARG2) strncat(ARG1, ARG2) -# define sw_strchr(ARG1, ARG2) strchr(ARG1, ARG2) -# define sw_strcmp(ARG1, ARG2) strcmp(ARG1, ARG2) -# define sw_strncmp(ARG1, ARG2) strncmp(ARG1, ARG2) -# define sw_strcoll(ARG1, ARG2) strcoll(ARG1, ARG2) -# define sw_strcpy(ARG1, ARG2) ARG2 ? strcpy(ARG1, ARG2) : strcpy(ARG1, "") -# define sw_strncpy(ARG1, ARG2, N) ARG2 ? strncpy(ARG1, ARG2, N) : strcpy(ARG1, "") -# define sw_strcspn(ARG1, ARG2) strcspn(ARG1, ARG2) -# define sw_strlen(ARG1) strlen(ARG1) -# define sw_strstr(ARG1, ARG2) strstr(ARG1, ARG2) -# define sw_strtok_r(ARG1, ARG2, ARG3) strtok_r(ARG1, ARG2, ARG3) - -#endif - - -sw_string -sw_strdup( - sw_const_string str); - - -/* -------------------------------------------------------- - * - * Memory - * - * These macros support cross platform heap functions. - * When compiling with DEBUG, some extra checking is - * done which can aid in tracking down heap corruption - * problems - * - * -------------------------------------------------------- - */ - -#if defined(NDEBUG) - -# define sw_malloc(SIZE) malloc(SIZE) -# define sw_realloc(MEM,SIZE) realloc(MEM, SIZE) -# define sw_free(MEM) if (MEM) free(MEM) - -#else - -# define sw_malloc(SIZE) _sw_debug_malloc(SIZE, __SW_FUNCTION__, __FILE__, __LINE__) -# define sw_realloc(MEM,SIZE) _sw_debug_realloc(MEM, SIZE, __SW_FUNCTION__, __FILE__, __LINE__) -# define sw_free(MEM) if (MEM) _sw_debug_free(MEM, __SW_FUNCTION__, __FILE__, __LINE__) - -#endif - - -sw_opaque HOWL_API -_sw_debug_malloc( - sw_size_t size, - sw_const_string function, - sw_const_string file, - sw_uint32 line); - - -sw_opaque HOWL_API -_sw_debug_realloc( - sw_opaque_t mem, - sw_size_t size, - sw_const_string function, - sw_const_string file, - sw_uint32 line); - - -void HOWL_API -_sw_debug_free( - sw_opaque_t mem, - sw_const_string function, - sw_const_string file, - sw_uint32 line); - - - -/* -------------------------------------------------------- - * - * Sockets - * - * These macros and APIs support cross platform socket - * calls. I am relying on BSD APIs, but even with those - * there are subtle and not so subtle platform differences - * - * -------------------------------------------------------- - */ - -#if defined(__VXWORKS__) - -# include -# include -# include -# include -# include - -typedef int sw_sockdesc_t; -typedef socklen_t sw_socklen_t; - -#elif defined(WIN32) - -# include - -typedef SOCKET sw_sockdesc_t; -typedef int sw_socklen_t; - -# define SW_E_WOULDBLOCK WSAEWOULDBLOCK -# define SW_INVALID_SOCKET INVALID_SOCKET -# define SW_SOCKET_ERROR SOCKET_ERROR - -# define sw_close_socket(X) closesocket(X) - -#else - -# if defined(sun) - -# include - -# endif - -# include -# include - -# if defined(__Lynx__) - -# include - -# else - -# include - -# endif - -# include -# include -# include -# include -# include -# include -# include -# include -# include - -typedef sw_int32 sw_sockdesc_t; -typedef socklen_t sw_socklen_t; - -# define SW_E_WOULDBLOCK EWOULDBLOCK -# define SW_INVALID_SOCKET -1 -# define SW_SOCKET_ERROR -1 - -# define sw_close_socket(X) close(X) - -#endif - - -/* -------------------------------------------------------- - * - * strerror() - * - * This function will print a string rep of a system error - * code - * - * -------------------------------------------------------- - */ - -sw_const_string -sw_strerror(); - - -/* - * Obsolete types and macros. - * - * These are here for backwards compatibility, but will - * be removed in the future - */ -#define sw_char sw_int8 -#define sw_uchar sw_uint8 -#define sw_octet sw_uint8 -#define sw_short sw_int16 -#define sw_ushort sw_uint16 -#define sw_long sw_int32 -#define sw_ulong sw_uint32 - - -#define SW_TRY(EXPR) { sw_result result; if ((result = EXPR) != SW_OKAY) return result; } ((void) 0) -#define SW_TRY_GOTO(EXPR) { if ((result = EXPR) != SW_OKAY) goto exit; } ((void) 0) - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/salt/salt.h b/avahi-compat-howl/include/salt/salt.h deleted file mode 100644 index ddb289b..0000000 --- a/avahi-compat-howl/include/salt/salt.h +++ /dev/null @@ -1,215 +0,0 @@ -#ifndef _sw_salt_h -#define _sw_salt_h - -/* - * Copyright 2003, 2004 Porchdog Software, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software, Inc. - */ - -#include -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -typedef enum _sw_socket_event -{ - SW_SOCKET_READ = (1 << 0), - SW_SOCKET_WRITE = (1 << 1), - SW_SOCKET_OOB = (1 << 2) -} sw_socket_event; - - -struct _sw_salt; -typedef struct _sw_salt * sw_salt; -struct _sw_socket; -struct _sw_timer; -struct _sw_network_interface; -struct _sw_signal; - -typedef sw_opaque sw_socket_handler; -typedef sw_result -(HOWL_API *sw_socket_handler_func)( - sw_socket_handler handler, - sw_salt salt, - struct _sw_socket * socket, - sw_socket_event events, - sw_opaque extra); - - -typedef sw_opaque sw_timer_handler; -typedef sw_result -(HOWL_API *sw_timer_handler_func)( - sw_timer_handler handler, - sw_salt salt, - struct _sw_timer * timer, - sw_time timeout, - sw_opaque extra); - -typedef sw_opaque sw_network_interface_handler; -typedef sw_result -(HOWL_API *sw_network_interface_handler_func)( - sw_network_interface_handler handler, - sw_salt salt, - struct _sw_network_interface * netif, - sw_opaque extra); - -typedef sw_opaque sw_signal_handler; -typedef sw_result -(HOWL_API *sw_signal_handler_func)( - sw_signal_handler handler, - sw_salt salt, - struct _sw_signal * signal, - sw_opaque extra); - - -sw_result HOWL_API -sw_salt_init( - sw_salt * self, - int argc, - char ** argv); - - -sw_result HOWL_API -sw_salt_fina( - sw_salt self); - - -sw_result HOWL_API -sw_salt_register_socket( - sw_salt self, - struct _sw_socket * socket, - sw_socket_event events, - sw_socket_handler handler, - sw_socket_handler_func func, - sw_opaque extra); - - -sw_result HOWL_API -sw_salt_unregister_socket( - sw_salt self, - struct _sw_socket * socket); - - -sw_result HOWL_API -sw_salt_register_timer( - sw_salt self, - struct _sw_timer * timer, - sw_time timeout, - sw_timer_handler handler, - sw_timer_handler_func func, - sw_opaque extra); - - -sw_result HOWL_API -sw_salt_unregister_timer( - sw_salt self, - struct _sw_timer * timer); - - -sw_result HOWL_API -sw_salt_register_network_interface( - sw_salt self, - struct _sw_network_interface * netif, - sw_network_interface_handler handler, - sw_network_interface_handler_func func, - sw_opaque extra); - - -sw_result HOWL_API -sw_salt_unregister_network_interface_handler( - sw_salt self); - - -sw_result HOWL_API -sw_salt_register_signal( - sw_salt self, - struct _sw_signal * signal, - sw_signal_handler handler, - sw_signal_handler_func func, - sw_opaque extra); - - -sw_result HOWL_API -sw_salt_unregister_signal( - sw_salt self, - struct _sw_signal * signal); - - -sw_result HOWL_API -sw_salt_lock( - sw_salt self); - - -sw_result HOWL_API -sw_salt_unlock( - sw_salt self); - - -sw_result HOWL_API -sw_salt_step( - sw_salt self, - sw_uint32 * msec); - - -sw_result HOWL_API -sw_salt_run( - sw_salt self); - - -sw_result HOWL_API -sw_salt_stop_run( - sw_salt self); - - -#define SW_FALSE 0 -#define SW_TRUE 1 -#define SW_OKAY 0 - - -/* - * error codes - */ -#define SW_E_CORE_BASE 0x80000000 -#define SW_E_UNKNOWN (SW_E_CORE_BASE) + 1 -#define SW_E_INIT (SW_E_CORE_BASE) + 2 -#define SW_E_MEM (SW_E_CORE_BASE) + 3 -#define SW_E_EOF (SW_E_CORE_BASE) + 4 -#define SW_E_NO_IMPL (SW_E_CORE_BASE) + 5 -#define SW_E_FILE_LOCKED (SW_E_CORE_BASE) + 6 -#define SW_E_PROTOCOL_NOT_FOUND (SW_E_CORE_BASE) + 7 - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/salt/signal.h b/avahi-compat-howl/include/salt/signal.h deleted file mode 100644 index b36e02f..0000000 --- a/avahi-compat-howl/include/salt/signal.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef _salt_signal_h -#define _salt_signal_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -struct _sw_signal; -typedef struct _sw_signal * sw_signal; - - -sw_result HOWL_API -sw_signal_init( - sw_signal * self, - int signal); - - -sw_result HOWL_API -sw_signal_fina( - sw_signal self); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/salt/socket.h b/avahi-compat-howl/include/salt/socket.h deleted file mode 100644 index 9eaa102..0000000 --- a/avahi-compat-howl/include/salt/socket.h +++ /dev/null @@ -1,263 +0,0 @@ -#ifndef _sw_socket_h -#define _sw_socket_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -struct _sw_socket; -typedef struct _sw_socket * sw_socket; -struct _sw_socket_options; -typedef struct _sw_socket_options * sw_socket_options; -typedef sw_uint16 sw_port; - - - -sw_result HOWL_API -sw_tcp_socket_init( - sw_socket * self); - - -sw_result HOWL_API -sw_tcp_socket_init_with_desc( - sw_socket * self, - sw_sockdesc_t desc); - - -sw_result HOWL_API -sw_udp_socket_init( - sw_socket * self); - - -sw_result HOWL_API -sw_multicast_socket_init( - sw_socket * self); - - -sw_result HOWL_API -sw_socket_fina( - sw_socket self); - - -sw_result HOWL_API -sw_socket_bind( - sw_socket self, - sw_ipv4_address address, - sw_port port); - - -sw_result HOWL_API -sw_socket_join_multicast_group( - sw_socket self, - sw_ipv4_address local_address, - sw_ipv4_address multicast_address, - sw_uint32 ttl); - - -sw_result HOWL_API -sw_socket_leave_multicast_group( - sw_socket self); - - -sw_result HOWL_API -sw_socket_listen( - sw_socket self, - int qsize); - - -sw_result HOWL_API -sw_socket_connect( - sw_socket self, - sw_ipv4_address address, - sw_port port); - - -sw_result HOWL_API -sw_socket_accept( - sw_socket self, - sw_socket * socket); - - -sw_result HOWL_API -sw_socket_send( - sw_socket self, - sw_octets buffer, - sw_size_t len, - sw_size_t * bytesWritten); - - -sw_result HOWL_API -sw_socket_sendto( - sw_socket self, - sw_octets buffer, - sw_size_t len, - sw_size_t * bytesWritten, - sw_ipv4_address to, - sw_port port); - - -sw_result HOWL_API -sw_socket_recv( - sw_socket self, - sw_octets buffer, - sw_size_t max, - sw_size_t * len); - - -sw_result HOWL_API -sw_socket_recvfrom( - sw_socket self, - sw_octets buffer, - sw_size_t max, - sw_size_t * len, - sw_ipv4_address * from, - sw_port * port, - sw_ipv4_address * dest, - sw_uint32 * interface_index); - - -sw_result HOWL_API -sw_socket_set_blocking_mode( - sw_socket self, - sw_bool blocking_mode); - - -sw_result HOWL_API -sw_socket_set_options( - sw_socket self, - sw_socket_options options); - - -sw_ipv4_address HOWL_API -sw_socket_ipv4_address( - sw_socket self); - - -sw_port HOWL_API -sw_socket_port( - sw_socket self); - - -sw_sockdesc_t HOWL_API -sw_socket_desc( - sw_socket self); - - -sw_result HOWL_API -sw_socket_close( - sw_socket self); - - -sw_result HOWL_API -sw_socket_options_init( - sw_socket_options * self); - - -sw_result HOWL_API -sw_socket_options_fina( - sw_socket_options self); - - -sw_result HOWL_API -sw_socket_options_set_debug( - sw_socket_options self, - sw_bool val); - - -sw_result HOWL_API -sw_socket_options_set_nodelay( - sw_socket_options self, - sw_bool val); - - -sw_result HOWL_API -sw_socket_options_set_dontroute( - sw_socket_options self, - sw_bool val); - - -sw_result HOWL_API -sw_socket_options_set_keepalive( - sw_socket_options self, - sw_bool val); - - -sw_result HOWL_API -sw_socket_options_set_linger( - sw_socket_options self, - sw_bool onoff, - sw_uint32 linger); - - -sw_result HOWL_API -sw_socket_options_set_reuseaddr( - sw_socket_options self, - sw_bool val); - - -sw_result HOWL_API -sw_socket_options_set_rcvbuf( - sw_socket_options self, - sw_uint32 val); - - -sw_result HOWL_API -sw_socket_options_set_sndbuf( - sw_socket_options self, - sw_uint32 val); - - -int -sw_socket_error_code(void); - - -#define SW_E_SOCKET_BASE 0x80000200 -#define SW_E_SOCKET (SW_E_SOCKET_BASE) + 1 -#define SW_E_BIND (SW_E_SOCKET_BASE) + 2 -#define SW_E_GETSOCKNAME (SW_E_SOCKET_BASE) + 3 -#define SW_E_ADD_MEMBERSHIP (SW_E_SOCKET_BASE) + 4 -#define SW_E_MULTICAST_TTL (SW_E_SOCKET_BASE) + 5 -#define SW_E_NOCONNECTION (SW_E_SOCKET_BASE) + 6 -#define SW_E_INPROGRESS (SW_E_SOCKET_BASE) + 7 - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/include/salt/time.h b/avahi-compat-howl/include/salt/time.h deleted file mode 100644 index 8789b3a..0000000 --- a/avahi-compat-howl/include/salt/time.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef _salt_time_h -#define _salt_time_h - -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - - -struct _sw_timer; -typedef struct _sw_timer * sw_timer; - - -sw_result HOWL_API -sw_timer_init( - sw_timer * self); - - -sw_result HOWL_API -sw_timer_fina( - sw_timer self); - - -typedef struct _sw_time -{ - sw_uint32 m_secs; - sw_uint32 m_usecs; -} sw_time; - - -sw_result HOWL_API -sw_time_init( - sw_time * self); - - -sw_result HOWL_API -sw_time_init_now( - sw_time * self); - - -sw_result HOWL_API -sw_time_fina( - sw_time self); - - -sw_time HOWL_API -sw_time_add( - sw_time self, - sw_time y); - - -sw_time HOWL_API -sw_time_sub( - sw_time self, - sw_time y); - - -sw_int32 HOWL_API -sw_time_cmp( - sw_time self, - sw_time y); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/avahi-compat-howl/samples/.gitignore b/avahi-compat-howl/samples/.gitignore deleted file mode 100644 index 8fca691..0000000 --- a/avahi-compat-howl/samples/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -browse -publish -query diff --git a/avahi-compat-howl/samples/Makefile.am b/avahi-compat-howl/samples/Makefile.am deleted file mode 100644 index 5efa19e..0000000 --- a/avahi-compat-howl/samples/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/avahi-compat-howl/include - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -if HAVE_DBUS -if ENABLE_COMPAT_HOWL - -if ENABLE_TESTS -noinst_PROGRAMS = browse resolve publish query -endif - -browse_SOURCES = \ - browse.c -browse_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -browse_LDADD = $(AM_LDADD) ../libhowl.la - -resolve_SOURCES = \ - resolve.c -resolve_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -resolve_LDADD = $(AM_LDADD) ../libhowl.la - -publish_SOURCES = \ - publish.c -publish_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -publish_LDADD = $(AM_LDADD) ../libhowl.la - -query_SOURCES = \ - query.c -query_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include -query_LDADD = $(AM_LDADD) ../libhowl.la - -endif -endif diff --git a/avahi-compat-howl/samples/browse.c b/avahi-compat-howl/samples/browse.c deleted file mode 100644 index f55b1cf..0000000 --- a/avahi-compat-howl/samples/browse.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2003, 2004, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include -#include - - -static sw_result HOWL_API -my_resolver( - sw_discovery discovery, - sw_discovery_oid oid, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_ipv4_address address, - sw_port port, - sw_octets text_record, - sw_uint32 text_record_len, - sw_opaque_t extra) -{ - sw_text_record_iterator it; - sw_int8 name_buf[16]; - sw_int8 key[SW_TEXT_RECORD_MAX_LEN]; - sw_int8 sval[SW_TEXT_RECORD_MAX_LEN]; - sw_uint8 oval[SW_TEXT_RECORD_MAX_LEN]; - sw_uint32 oval_len; - sw_result err = SW_OKAY; - - sw_discovery_cancel(discovery, oid); - - fprintf(stderr, "resolve reply: 0x%x %s %s %s %s %d\n", interface_index, name, type, domain, sw_ipv4_address_name(address, name_buf, 16), port); - - if ((text_record_len > 0) && (text_record) && (*text_record != '\0')) - { - err = sw_text_record_iterator_init(&it, text_record, text_record_len); - sw_check_okay(err, exit); - - while (sw_text_record_iterator_next(it, key, oval, &oval_len) == SW_OKAY) - { - fprintf(stderr, "Txt: [%s]=[%s] - (%d bytes)\n", key, oval, oval_len); - } - - err = sw_text_record_iterator_fina(it); - sw_check_okay(err, exit); - } - -exit: - - return err; -} - - -static sw_result HOWL_API -my_browser( - sw_discovery discovery, - sw_discovery_oid oid, - sw_discovery_browse_status status, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_opaque_t extra) -{ - sw_discovery_resolve_id rid; - - switch (status) - { - case SW_DISCOVERY_BROWSE_INVALID: - { - fprintf(stderr, "browse reply: Invalid\n"); - } - break; - - case SW_DISCOVERY_BROWSE_RELEASE: - { - fprintf(stderr, "browse reply: Release\n"); - } - break; - - case SW_DISCOVERY_BROWSE_ADD_DOMAIN: - { - fprintf(stderr, "browse reply: Add Domain\n"); - } - break; - - case SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN: - { - fprintf(stderr, "browse reply: Add Default Domain\n"); - } - break; - - case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN: - { - fprintf(stderr, "browse reply: Remove Domain\n"); - } - break; - - case SW_DISCOVERY_BROWSE_ADD_SERVICE: - { - fprintf(stderr, "browse reply: Add Service 0x%x %s %s %s\n", interface_index, name, type, domain); - if (sw_discovery_resolve(discovery, interface_index, name, type, domain, my_resolver, NULL, &rid) != SW_OKAY) - { - fprintf(stderr, "resolve failed\n"); - } - } - break; - - case SW_DISCOVERY_BROWSE_REMOVE_SERVICE: - { - fprintf(stderr, "browse reply: Remove Service\n"); - fprintf(stderr, "remove service: 0x%x %s %s %s\n", interface_index, name, type, domain); - } - break; - - case SW_DISCOVERY_BROWSE_RESOLVED: - { - fprintf(stderr, "browse reply: Resolved\n"); - } - break; - } - - return SW_OKAY; -} - - -#if defined(WIN32) -int __cdecl -#else -int -#endif -main( - int argc, - char ** argv) -{ - sw_discovery discovery; - sw_discovery_oid oid; - sw_result err; - - err = sw_discovery_init(&discovery); - sw_check_okay(err, exit); - - if (argc != 2) - { - fprintf(stderr, "usage: mDNSBrowse \n"); - return -1; - } - - err = sw_discovery_browse(discovery, 0, argv[1], NULL, my_browser, NULL, &oid); - sw_check_okay(err, exit); - - err = sw_discovery_run(discovery); - sw_check_okay(err, exit); - -exit: - - return err; -} diff --git a/avahi-compat-howl/samples/publish.c b/avahi-compat-howl/samples/publish.c deleted file mode 100644 index 931e786..0000000 --- a/avahi-compat-howl/samples/publish.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2003, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include - - -static sw_result HOWL_API -my_service_reply( - sw_discovery discovery, - sw_discovery_oid oid, - sw_discovery_publish_status status, - sw_opaque extra) -{ - static sw_string - status_text[] = - { - "Started", - "Stopped", - "Name Collision", - "Invalid" - }; - - fprintf(stderr, "publish reply: %s\n", status_text[status]); - return SW_OKAY; -} - - -#if defined(WIN32) -int __cdecl -#else -int -#endif -main( - int argc, - char ** argv) -{ - sw_discovery discovery; - sw_text_record text_record; - sw_result result; - sw_discovery_publish_id id; - int i; - - if (sw_discovery_init(&discovery) != SW_OKAY) - { - fprintf(stderr, "sw_discovery_init() failed\n"); - return -1; - } - - if (argc < 4) - { - fprintf(stderr, "usage: mDNSPublish [service text 1]...[service text n]\n"); - return -1; - } - - if (sw_text_record_init(&text_record) != SW_OKAY) - { - fprintf(stderr, "sw_text_record_init() failed\n"); - return -1; - } - - for (i = 4; i < argc; i++) - { - if (sw_text_record_add_string(text_record, argv[i]) != SW_OKAY) - { - fprintf(stderr, "unable to add service text: %s\n", argv[i]); - return -1; - } - } - - printf("%s %s %d\n", argv[1], argv[2], atoi(argv[3])); - - if ((result = sw_discovery_publish(discovery, 0, argv[1], argv[2], NULL, NULL, atoi(argv[3]), sw_text_record_bytes(text_record), sw_text_record_len(text_record), my_service_reply, NULL, &id)) != SW_OKAY) - { - fprintf(stderr, "publish failed: %d\n", result); - sw_text_record_fina(text_record); - return -1; - } - - sw_text_record_fina(text_record); - - sw_discovery_run(discovery); - - return 0; -} diff --git a/avahi-compat-howl/samples/query.c b/avahi-compat-howl/samples/query.c deleted file mode 100644 index b1c30eb..0000000 --- a/avahi-compat-howl/samples/query.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2003, 2004, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include -#include - - -static sw_result HOWL_API -query_record_reply( - sw_discovery session, - sw_discovery_oid oid, - sw_discovery_query_record_status status, - sw_uint32 interface_index, - sw_const_string fullname, - sw_uint16 rrtype, - sw_uint16 rrclass, - sw_uint16 rrdatalen, - sw_const_octets rrdata, - sw_uint32 ttl, - sw_opaque extra) -{ - sw_ipv4_address address; - - fprintf(stderr, "interface index = 0x%x, fullname is %s\n", interface_index, fullname); - - if ((rrtype == 1) && (rrclass == 1)) - { - sw_ipv4_address address; - sw_char name[16]; - - sw_ipv4_address_init_from_saddr(&address, *(sw_saddr*) rrdata); - - fprintf(stderr, "address is %s\n", sw_ipv4_address_name(address, name, sizeof(name))); - } - - return SW_OKAY; -} - - - -#if defined(WIN32) -int __cdecl -#else -int -#endif -main( - int argc, - char ** argv) -{ - sw_discovery discovery; - sw_discovery_oid oid; - sw_result err; - - err = sw_discovery_init(&discovery); - sw_check_okay(err, exit); - - if (argc != 4) - { - fprintf(stderr, "usage: mDNSBrowse \n"); - return -1; - } - - err = sw_discovery_query_record(discovery, 0, 0, argv[1], atoi(argv[2]), atoi(argv[3]), query_record_reply, NULL, &oid); - sw_check_okay(err, exit); - - err = sw_discovery_run(discovery); - sw_check_okay(err, exit); - -exit: - - return err; -} diff --git a/avahi-compat-howl/samples/resolve.c b/avahi-compat-howl/samples/resolve.c deleted file mode 100644 index 1790849..0000000 --- a/avahi-compat-howl/samples/resolve.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2003, 2004, 2004 Porchdog Software. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those - * of the authors and should not be interpreted as representing official policies, - * either expressed or implied, of Porchdog Software. - */ - -#include -#include -#include - - -static sw_result HOWL_API -my_resolver( - sw_discovery discovery, - sw_discovery_oid oid, - sw_uint32 interface_index, - sw_const_string name, - sw_const_string type, - sw_const_string domain, - sw_ipv4_address address, - sw_port port, - sw_octets text_record, - sw_uint32 text_record_len, - sw_opaque_t extra) -{ - sw_text_record_iterator it; - sw_int8 name_buf[16]; - sw_int8 key[SW_TEXT_RECORD_MAX_LEN]; - sw_int8 sval[SW_TEXT_RECORD_MAX_LEN]; - sw_uint8 oval[SW_TEXT_RECORD_MAX_LEN]; - sw_uint32 oval_len; - sw_result err = SW_OKAY; - - sw_discovery_cancel(discovery, oid); - - fprintf(stderr, "resolve reply: 0x%x %s %s %s %s %d\n", interface_index, name, type, domain, sw_ipv4_address_name(address, name_buf, 16), port); - - if ((text_record_len > 0) && (text_record) && (*text_record != '\0')) - { - err = sw_text_record_iterator_init(&it, text_record, text_record_len); - sw_check_okay(err, exit); - - while (sw_text_record_iterator_next(it, key, oval, &oval_len) == SW_OKAY) - { - fprintf(stderr, "key = %s, data is %d bytes\n", key, oval_len); - } - - err = sw_text_record_iterator_fina(it); - sw_check_okay(err, exit); - } - -exit: - - return err; -} - - -#if defined(WIN32) -int __cdecl -#else -int -#endif -main( - int argc, - char ** argv) -{ - sw_discovery discovery; - sw_discovery_oid oid; - sw_result err; - - err = sw_discovery_init(&discovery); - sw_check_okay(err, exit); - - if (argc != 3) - { - fprintf(stderr, "usage: mDNSResolve \n"); - return -1; - } - - err = sw_discovery_resolve(discovery, 0, argv[1], argv[2], "local.", my_resolver, NULL, &oid); - sw_check_okay(err, exit); - - err = sw_discovery_run(discovery); - sw_check_okay(err, exit); - -exit: - - return err; -} diff --git a/avahi-compat-howl/text-test.c b/avahi-compat-howl/text-test.c deleted file mode 100644 index 66ff58b..0000000 --- a/avahi-compat-howl/text-test.c +++ /dev/null @@ -1,97 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include "howl.h" - -#define ASSERT_SW_OKAY(t) { sw_result _r; _r = (t); assert(_r == SW_OKAY); } -#define ASSERT_NOT_NULL(t) { const void* _r; r = (t); assert(_r); } - -static void hexdump(const void* p, size_t size) { - const uint8_t *c = p; - assert(p); - - printf("Dumping %zu bytes from %p:\n", size, p); - - while (size > 0) { - unsigned i; - - for (i = 0; i < 16; i++) { - if (i < size) - printf("%02x ", c[i]); - else - printf(" "); - } - - for (i = 0; i < 16; i++) { - if (i < size) - printf("%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.'); - else - printf(" "); - } - - printf("\n"); - - c += 16; - - if (size <= 16) - break; - - size -= 16; - } -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - sw_text_record r; - sw_text_record_iterator it; - char key[255]; - uint8_t val[255]; - sw_ulong val_len; - - ASSERT_SW_OKAY(sw_text_record_init(&r)); - ASSERT_SW_OKAY(sw_text_record_add_string(r, "foo=bar")); - ASSERT_SW_OKAY(sw_text_record_add_string(r, "waldo=baz")); - ASSERT_SW_OKAY(sw_text_record_add_key_and_string_value(r, "quux", "nimpf")); - ASSERT_SW_OKAY(sw_text_record_add_key_and_binary_value(r, "quux", (void*) "\0\0\0\0", 4)); - - hexdump(sw_text_record_bytes(r), sw_text_record_len(r)); - - ASSERT_SW_OKAY(sw_text_record_iterator_init(&it, sw_text_record_bytes(r), sw_text_record_len(r))); - - while (sw_text_record_iterator_next(it, key, val, &val_len) == SW_OKAY) { - printf("key=%s\n", key); - hexdump(val, val_len); - } - - ASSERT_SW_OKAY(sw_text_record_iterator_fina(it)); - - - - - ASSERT_SW_OKAY(sw_text_record_fina(r)); - - return 0; -} diff --git a/avahi-compat-howl/text.c b/avahi-compat-howl/text.c deleted file mode 100644 index 7ef4df3..0000000 --- a/avahi-compat-howl/text.c +++ /dev/null @@ -1,259 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include - -#include "howl.h" -#include "warn.h" - -struct _sw_text_record { - AvahiStringList *strlst; - uint8_t *buffer; - size_t buffer_size; - int buffer_valid; -}; - -#ifndef HAVE_STRLCPY - -static size_t strlcpy(char *dest, const char *src, size_t n) { - assert(dest); - assert(src); - - if (n > 0) { - strncpy(dest, src, n-1); - dest[n-1] = 0; - } - - return strlen(src); -} - -#endif - -sw_result sw_text_record_init(sw_text_record *self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - if (!(*self = avahi_new(struct _sw_text_record, 1))) { - *self = NULL; - return SW_E_UNKNOWN; - } - - (*self)->strlst = NULL; - (*self)->buffer = NULL; - (*self)->buffer_size = 0; - (*self)->buffer_valid = 0; - - return SW_OKAY; -} - -sw_result sw_text_record_fina(sw_text_record self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - avahi_string_list_free(self->strlst); - avahi_free(self->buffer); - avahi_free(self); - return SW_OKAY; -} - -sw_result sw_text_record_add_string( - sw_text_record self, - sw_const_string string) { - - AvahiStringList *n; - - assert(self); - assert(string); - - AVAHI_WARN_LINKAGE; - - if (!(n = avahi_string_list_add(self->strlst, string))) - return SW_E_UNKNOWN; - - self->strlst = n; - self->buffer_valid = 0; - return SW_OKAY; -} - -sw_result sw_text_record_add_key_and_string_value( - sw_text_record self, - sw_const_string key, - sw_const_string val) { - - AvahiStringList *n; - - assert(self); - assert(key); - - AVAHI_WARN_LINKAGE; - - if (!(n = avahi_string_list_add_pair(self->strlst, key, val))) - return SW_E_UNKNOWN; - - self->strlst = n; - self->buffer_valid = 0; - return SW_OKAY; -} - -sw_result sw_text_record_add_key_and_binary_value( - sw_text_record self, - sw_const_string key, - sw_octets val, - sw_uint32 len) { - - AvahiStringList *n; - - assert(self); - assert(key); - assert(len || !val); - - AVAHI_WARN_LINKAGE; - - if (!(n = avahi_string_list_add_pair_arbitrary(self->strlst, key, val, len))) - return SW_E_UNKNOWN; - - self->strlst = n; - self->buffer_valid = 0; - return SW_OKAY; -} - -static int rebuild(sw_text_record self) { - assert(self); - - if (self->buffer_valid) - return 0; - - self->buffer_size = avahi_string_list_serialize(self->strlst, NULL, 0); - - if (!(self->buffer = avahi_realloc(self->buffer, self->buffer_size + 1))) - return -1; - - avahi_string_list_serialize(self->strlst, self->buffer, self->buffer_size); - self->buffer_valid = 1; - - return 0; -} - -sw_octets sw_text_record_bytes(sw_text_record self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - if (rebuild(self) < 0) - return NULL; - - return self->buffer; -} - -sw_uint32 sw_text_record_len(sw_text_record self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - if (rebuild(self) < 0) - return (uint32_t) -1; - - return self->buffer_size; -} - -struct _sw_text_record_iterator { - AvahiStringList *strlst, *index; - -}; - -sw_result sw_text_record_iterator_init( - sw_text_record_iterator * self, - sw_octets text_record, - sw_uint32 text_record_len) { - - AvahiStringList *txt; - assert(self); - - AVAHI_WARN_LINKAGE; - - if (!(*self = avahi_new(struct _sw_text_record_iterator, 1))) { - *self = NULL; - return SW_E_UNKNOWN; - } - - if (avahi_string_list_parse(text_record, text_record_len, &txt) < 0) { - avahi_free(*self); - *self = NULL; - return SW_E_UNKNOWN; - } - - (*self)->index = (*self)->strlst = avahi_string_list_reverse(txt); - - return SW_OKAY; -} - -sw_result sw_text_record_iterator_fina(sw_text_record_iterator self) { - assert(self); - - AVAHI_WARN_LINKAGE; - - avahi_string_list_free(self->strlst); - avahi_free(self); - - return SW_OKAY; -} - -sw_result sw_text_record_iterator_next( - sw_text_record_iterator self, - char key[SW_TEXT_RECORD_MAX_LEN], - sw_uint8 val[SW_TEXT_RECORD_MAX_LEN], - sw_uint32 * val_len) { - - char *mkey = NULL, *mvalue = NULL; - size_t msize = 0; - - assert(self); - assert(key); - - AVAHI_WARN_LINKAGE; - - if (!self->index) - return SW_E_UNKNOWN; - - if (avahi_string_list_get_pair(self->index, &mkey, &mvalue, &msize) < 0) - return SW_E_UNKNOWN; - - strlcpy(key, mkey, SW_TEXT_RECORD_MAX_LEN); - memset(val, 0, SW_TEXT_RECORD_MAX_LEN); - memcpy(val, mvalue, msize); - *val_len = msize; - - avahi_free(mkey); - avahi_free(mvalue); - - self->index = self->index->next; - - return SW_OKAY; -} - diff --git a/avahi-compat-howl/unsupported.c b/avahi-compat-howl/unsupported.c deleted file mode 100644 index ff440af..0000000 --- a/avahi-compat-howl/unsupported.c +++ /dev/null @@ -1,1019 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "howl.h" -#include "warn.h" - -AVAHI_GCC_NORETURN -sw_string sw_strdup(AVAHI_GCC_UNUSED sw_const_string str) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -AVAHI_GCC_NORETURN -sw_opaque _sw_debug_malloc( - AVAHI_GCC_UNUSED sw_size_t size, - AVAHI_GCC_UNUSED sw_const_string function, - AVAHI_GCC_UNUSED sw_const_string file, - AVAHI_GCC_UNUSED sw_uint32 line) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -AVAHI_GCC_NORETURN -sw_opaque _sw_debug_realloc( - AVAHI_GCC_UNUSED sw_opaque_t mem, - AVAHI_GCC_UNUSED sw_size_t size, - AVAHI_GCC_UNUSED sw_const_string function, - AVAHI_GCC_UNUSED sw_const_string file, - AVAHI_GCC_UNUSED sw_uint32 line) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -void _sw_debug_free( - AVAHI_GCC_UNUSED sw_opaque_t mem, - AVAHI_GCC_UNUSED sw_const_string function, - AVAHI_GCC_UNUSED sw_const_string file, - AVAHI_GCC_UNUSED sw_uint32 line) { - AVAHI_WARN_UNSUPPORTED; -} - -AVAHI_GCC_NORETURN -sw_const_string sw_strerror(/* howl sucks */) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -sw_result sw_timer_init(AVAHI_GCC_UNUSED sw_timer * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_timer_fina(AVAHI_GCC_UNUSED sw_timer self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_time_init(AVAHI_GCC_UNUSED sw_time * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_time_init_now(AVAHI_GCC_UNUSED sw_time * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_time_fina(AVAHI_GCC_UNUSED sw_time self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -AVAHI_GCC_NORETURN -sw_time sw_time_add( - AVAHI_GCC_UNUSED sw_time self, - AVAHI_GCC_UNUSED sw_time y) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -AVAHI_GCC_NORETURN -sw_time sw_time_sub( - AVAHI_GCC_UNUSED sw_time self, - AVAHI_GCC_UNUSED sw_time y) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -AVAHI_GCC_NORETURN -sw_int32 sw_time_cmp( - AVAHI_GCC_UNUSED sw_time self, - AVAHI_GCC_UNUSED sw_time y) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -sw_result sw_salt_init( - AVAHI_GCC_UNUSED sw_salt * self, - AVAHI_GCC_UNUSED int argc, - AVAHI_GCC_UNUSED char ** argv) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_fina(AVAHI_GCC_UNUSED sw_salt self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_register_socket( - AVAHI_GCC_UNUSED sw_salt self, - AVAHI_GCC_UNUSED struct _sw_socket * _socket, - AVAHI_GCC_UNUSED sw_socket_event events, - AVAHI_GCC_UNUSED sw_socket_handler handler, - AVAHI_GCC_UNUSED sw_socket_handler_func func, - AVAHI_GCC_UNUSED sw_opaque extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_unregister_socket( - AVAHI_GCC_UNUSED sw_salt self, - AVAHI_GCC_UNUSED struct _sw_socket * _socket) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - - -sw_result sw_salt_register_timer( - AVAHI_GCC_UNUSED sw_salt self, - AVAHI_GCC_UNUSED struct _sw_timer * timer, - AVAHI_GCC_UNUSED sw_time timeout, - AVAHI_GCC_UNUSED sw_timer_handler handler, - AVAHI_GCC_UNUSED sw_timer_handler_func func, - AVAHI_GCC_UNUSED sw_opaque extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_unregister_timer( - AVAHI_GCC_UNUSED sw_salt self, - AVAHI_GCC_UNUSED struct _sw_timer * timer) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_register_network_interface( - AVAHI_GCC_UNUSED sw_salt self, - AVAHI_GCC_UNUSED struct _sw_network_interface * netif, - AVAHI_GCC_UNUSED sw_network_interface_handler handler, - AVAHI_GCC_UNUSED sw_network_interface_handler_func func, - AVAHI_GCC_UNUSED sw_opaque extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_unregister_network_interface_handler(AVAHI_GCC_UNUSED sw_salt self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_register_signal( - AVAHI_GCC_UNUSED sw_salt self, - AVAHI_GCC_UNUSED struct _sw_signal * _signal, - AVAHI_GCC_UNUSED sw_signal_handler handler, - AVAHI_GCC_UNUSED sw_signal_handler_func func, - AVAHI_GCC_UNUSED sw_opaque extra) { - - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_salt_unregister_signal( - AVAHI_GCC_UNUSED sw_salt self, - AVAHI_GCC_UNUSED struct _sw_signal * _signal) { - - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -void sw_print_assert( - AVAHI_GCC_UNUSED int code, - AVAHI_GCC_UNUSED sw_const_string assert_string, - AVAHI_GCC_UNUSED sw_const_string file, - AVAHI_GCC_UNUSED sw_const_string func, - AVAHI_GCC_UNUSED int line) { - AVAHI_WARN_UNSUPPORTED; -} - -void sw_print_debug( - AVAHI_GCC_UNUSED int level, - AVAHI_GCC_UNUSED sw_const_string format, - ...) { - AVAHI_WARN_UNSUPPORTED; -} - -sw_result sw_tcp_socket_init(AVAHI_GCC_UNUSED sw_socket * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_tcp_socket_init_with_desc( - AVAHI_GCC_UNUSED sw_socket * self, - AVAHI_GCC_UNUSED sw_sockdesc_t desc) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_udp_socket_init(AVAHI_GCC_UNUSED sw_socket * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_multicast_socket_init(AVAHI_GCC_UNUSED sw_socket * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_fina(AVAHI_GCC_UNUSED sw_socket self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_bind( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_ipv4_address address, - AVAHI_GCC_UNUSED sw_port port) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_join_multicast_group( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_ipv4_address local_address, - AVAHI_GCC_UNUSED sw_ipv4_address multicast_address, - AVAHI_GCC_UNUSED sw_uint32 ttl) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_leave_multicast_group(AVAHI_GCC_UNUSED sw_socket self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_listen( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED int qsize) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_connect( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_ipv4_address address, - AVAHI_GCC_UNUSED sw_port port) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_accept( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_socket * _socket) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_send( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_octets buffer, - AVAHI_GCC_UNUSED sw_size_t len, - AVAHI_GCC_UNUSED sw_size_t * bytesWritten) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_sendto( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_octets buffer, - AVAHI_GCC_UNUSED sw_size_t len, - AVAHI_GCC_UNUSED sw_size_t * bytesWritten, - AVAHI_GCC_UNUSED sw_ipv4_address to, - AVAHI_GCC_UNUSED sw_port port) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_recv( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_octets buffer, - AVAHI_GCC_UNUSED sw_size_t max, - AVAHI_GCC_UNUSED sw_size_t * len) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_recvfrom( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_octets buffer, - AVAHI_GCC_UNUSED sw_size_t max, - AVAHI_GCC_UNUSED sw_size_t * len, - AVAHI_GCC_UNUSED sw_ipv4_address * from, - AVAHI_GCC_UNUSED sw_port * port, - AVAHI_GCC_UNUSED sw_ipv4_address * dest, - AVAHI_GCC_UNUSED sw_uint32 * interface_index) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_set_blocking_mode( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_bool blocking_mode) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_set_options( - AVAHI_GCC_UNUSED sw_socket self, - AVAHI_GCC_UNUSED sw_socket_options options) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -AVAHI_GCC_NORETURN -sw_ipv4_address sw_socket_ipv4_address(AVAHI_GCC_UNUSED sw_socket self) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -AVAHI_GCC_NORETURN -sw_port sw_socket_port(AVAHI_GCC_UNUSED sw_socket self) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -AVAHI_GCC_NORETURN -sw_sockdesc_t sw_socket_desc(AVAHI_GCC_UNUSED sw_socket self) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -sw_result sw_socket_close(AVAHI_GCC_UNUSED sw_socket self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_init(AVAHI_GCC_UNUSED sw_socket_options * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_fina(AVAHI_GCC_UNUSED sw_socket_options self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_debug( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_bool val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_nodelay( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_bool val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_dontroute( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_bool val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_keepalive( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_bool val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_linger( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_bool onoff, - AVAHI_GCC_UNUSED sw_uint32 linger) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_reuseaddr( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_bool val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_rcvbuf( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_uint32 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_socket_options_set_sndbuf( - AVAHI_GCC_UNUSED sw_socket_options self, - AVAHI_GCC_UNUSED sw_uint32 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -AVAHI_GCC_NORETURN -int sw_socket_error_code(void) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -sw_result sw_corby_orb_init( - AVAHI_GCC_UNUSED sw_corby_orb * self, - AVAHI_GCC_UNUSED sw_salt salt, - AVAHI_GCC_UNUSED const sw_corby_orb_config * config, - AVAHI_GCC_UNUSED sw_corby_orb_observer observer, - AVAHI_GCC_UNUSED sw_corby_orb_observer_func func, - AVAHI_GCC_UNUSED sw_opaque_t extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_fina(AVAHI_GCC_UNUSED sw_corby_orb self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_register_servant( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED sw_corby_servant servant, - AVAHI_GCC_UNUSED sw_corby_servant_cb cb, - AVAHI_GCC_UNUSED sw_const_string oid, - AVAHI_GCC_UNUSED struct _sw_corby_object ** object, - AVAHI_GCC_UNUSED sw_const_string protocol_name) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_unregister_servant( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED sw_const_string oid) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_register_bidirectional_object( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED struct _sw_corby_object * object) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_register_channel( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED struct _sw_corby_channel * channel) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -AVAHI_GCC_NORETURN -sw_corby_orb_delegate sw_corby_orb_get_delegate(AVAHI_GCC_UNUSED sw_corby_orb self) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -sw_result sw_corby_orb_set_delegate( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED sw_corby_orb_delegate delegate) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_set_observer( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED sw_corby_orb_observer observer, - AVAHI_GCC_UNUSED sw_corby_orb_observer_func func, - AVAHI_GCC_UNUSED sw_opaque_t extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_protocol_to_address( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED sw_const_string tag, - AVAHI_GCC_UNUSED sw_string addr, - AVAHI_GCC_UNUSED sw_port * port) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_protocol_to_url( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED sw_const_string tag, - AVAHI_GCC_UNUSED sw_const_string name, - AVAHI_GCC_UNUSED sw_string url, - AVAHI_GCC_UNUSED sw_size_t url_len) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_read_channel( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED struct _sw_corby_channel * channel) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_orb_dispatch_message( - AVAHI_GCC_UNUSED sw_corby_orb self, - AVAHI_GCC_UNUSED struct _sw_corby_channel * channel, - AVAHI_GCC_UNUSED struct _sw_corby_message * message, - AVAHI_GCC_UNUSED struct _sw_corby_buffer * buffer, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_message_init(AVAHI_GCC_UNUSED sw_corby_message * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_message_fina(AVAHI_GCC_UNUSED sw_corby_message self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_init(AVAHI_GCC_UNUSED sw_corby_buffer * self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_init_with_size( - AVAHI_GCC_UNUSED sw_corby_buffer * self, - AVAHI_GCC_UNUSED sw_size_t size) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_init_with_delegate( - AVAHI_GCC_UNUSED sw_corby_buffer * self, - AVAHI_GCC_UNUSED sw_corby_buffer_delegate delegate, - AVAHI_GCC_UNUSED sw_corby_buffer_overflow_func overflow, - AVAHI_GCC_UNUSED sw_corby_buffer_underflow_func underflow, - AVAHI_GCC_UNUSED sw_opaque_t extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_init_with_size_and_delegate( - AVAHI_GCC_UNUSED sw_corby_buffer * self, - AVAHI_GCC_UNUSED sw_size_t size, - AVAHI_GCC_UNUSED sw_corby_buffer_delegate delegate, - AVAHI_GCC_UNUSED sw_corby_buffer_overflow_func overflow, - AVAHI_GCC_UNUSED sw_corby_buffer_underflow_func underflow, - AVAHI_GCC_UNUSED sw_opaque_t extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_fina(AVAHI_GCC_UNUSED sw_corby_buffer self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -void sw_corby_buffer_reset(AVAHI_GCC_UNUSED sw_corby_buffer self) { - AVAHI_WARN_UNSUPPORTED; -} - -sw_result sw_corby_buffer_set_octets( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_octets octets, - AVAHI_GCC_UNUSED sw_size_t size) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_octets sw_corby_buffer_octets(AVAHI_GCC_UNUSED sw_corby_buffer self) { - AVAHI_WARN_UNSUPPORTED; - return NULL; -} - -sw_size_t sw_corby_buffer_bytes_used(AVAHI_GCC_UNUSED sw_corby_buffer self) { - AVAHI_WARN_UNSUPPORTED; - return 0; -} - -sw_size_t sw_corby_buffer_size(AVAHI_GCC_UNUSED sw_corby_buffer self) { - AVAHI_WARN_UNSUPPORTED; - return 0; -} - -sw_result sw_corby_buffer_put_int8( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_int8 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_uint8( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_uint8 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_int16( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_int16 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_uint16( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_uint16 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_int32( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_int32 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_uint32( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_uint32 val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_octets( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_const_octets val, - AVAHI_GCC_UNUSED sw_size_t size) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_sized_octets( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_const_octets val, - AVAHI_GCC_UNUSED sw_uint32 len) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_cstring( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_const_string val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_object( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED const struct _sw_corby_object * object) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_put_pad( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_corby_buffer_pad pad) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_int8( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_int8 * val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_uint8( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_uint8 * val) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_int16( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_int16 * val, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_uint16( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_uint16 * val, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_int32( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_int32 * val, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_uint32( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_uint32 * val, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_octets( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_octets octets, - AVAHI_GCC_UNUSED sw_size_t size) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_allocate_and_get_sized_octets( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_octets * val, - AVAHI_GCC_UNUSED sw_uint32 * size, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_zerocopy_sized_octets( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_octets * val, - AVAHI_GCC_UNUSED sw_uint32 * size, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_sized_octets( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_octets val, - AVAHI_GCC_UNUSED sw_uint32 * len, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_allocate_and_get_cstring( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_string * val, - AVAHI_GCC_UNUSED sw_uint32 * len, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_zerocopy_cstring( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_string * val, - AVAHI_GCC_UNUSED sw_uint32 * len, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_cstring( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED sw_string val, - AVAHI_GCC_UNUSED sw_uint32 * len, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_buffer_get_object( - AVAHI_GCC_UNUSED sw_corby_buffer self, - AVAHI_GCC_UNUSED struct _sw_corby_object ** object, - AVAHI_GCC_UNUSED sw_uint8 endian) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_channel_start_request( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED sw_const_corby_profile profile, - AVAHI_GCC_UNUSED struct _sw_corby_buffer ** buffer, - AVAHI_GCC_UNUSED sw_const_string op, - AVAHI_GCC_UNUSED sw_uint32 oplen, - AVAHI_GCC_UNUSED sw_bool reply_expected) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_channel_start_reply( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED struct _sw_corby_buffer ** buffer, - AVAHI_GCC_UNUSED sw_uint32 request_id, - AVAHI_GCC_UNUSED sw_corby_reply_status status) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_channel_send( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED struct _sw_corby_buffer * buffer, - AVAHI_GCC_UNUSED sw_corby_buffer_observer observer, - AVAHI_GCC_UNUSED sw_corby_buffer_written_func func, - AVAHI_GCC_UNUSED sw_opaque_t extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_channel_recv( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED sw_salt * salt, - AVAHI_GCC_UNUSED struct _sw_corby_message ** message, - AVAHI_GCC_UNUSED sw_uint32 * request_id, - AVAHI_GCC_UNUSED sw_string * op, - AVAHI_GCC_UNUSED sw_uint32 * op_len, - AVAHI_GCC_UNUSED struct _sw_corby_buffer ** buffer, - AVAHI_GCC_UNUSED sw_uint8 * endian, - AVAHI_GCC_UNUSED sw_bool block) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_channel_last_recv_from( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED sw_ipv4_address * from, - AVAHI_GCC_UNUSED sw_port * from_port) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_channel_ff( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED struct _sw_corby_buffer * buffer) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -AVAHI_GCC_NORETURN -sw_socket sw_corby_channel_socket(AVAHI_GCC_UNUSED sw_corby_channel self) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -sw_result sw_corby_channel_retain(AVAHI_GCC_UNUSED sw_corby_channel self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_channel_set_delegate( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED sw_corby_channel_delegate delegate) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -AVAHI_GCC_NORETURN -sw_corby_channel_delegate sw_corby_channel_get_delegate( - AVAHI_GCC_UNUSED sw_corby_channel self) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -void sw_corby_channel_set_app_data( - AVAHI_GCC_UNUSED sw_corby_channel self, - AVAHI_GCC_UNUSED sw_opaque app_data) { - AVAHI_WARN_UNSUPPORTED; -} - -AVAHI_GCC_NORETURN -sw_opaque sw_corby_channel_get_app_data(AVAHI_GCC_UNUSED sw_corby_channel self) { - AVAHI_WARN_UNSUPPORTED_ABORT; -} - -sw_result sw_corby_channel_fina(AVAHI_GCC_UNUSED sw_corby_channel self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_object_init_from_url( - AVAHI_GCC_UNUSED sw_corby_object * self, - AVAHI_GCC_UNUSED struct _sw_corby_orb * orb, - AVAHI_GCC_UNUSED sw_const_string url, - AVAHI_GCC_UNUSED sw_socket_options options, - AVAHI_GCC_UNUSED sw_uint32 bufsize) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_object_fina( - AVAHI_GCC_UNUSED sw_corby_object self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_object_start_request( - AVAHI_GCC_UNUSED sw_corby_object self, - AVAHI_GCC_UNUSED sw_const_string op, - AVAHI_GCC_UNUSED sw_uint32 op_len, - AVAHI_GCC_UNUSED sw_bool reply_expected, - AVAHI_GCC_UNUSED sw_corby_buffer * buffer) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_object_send( - AVAHI_GCC_UNUSED sw_corby_object self, - AVAHI_GCC_UNUSED sw_corby_buffer buffer, - AVAHI_GCC_UNUSED sw_corby_buffer_observer observer, - AVAHI_GCC_UNUSED sw_corby_buffer_written_func func, - AVAHI_GCC_UNUSED sw_opaque extra) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_object_recv( - AVAHI_GCC_UNUSED sw_corby_object self, - AVAHI_GCC_UNUSED sw_corby_message * message, - AVAHI_GCC_UNUSED sw_corby_buffer * buffer, - AVAHI_GCC_UNUSED sw_uint8 * endian, - AVAHI_GCC_UNUSED sw_bool block) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_object_channel( - AVAHI_GCC_UNUSED sw_corby_object self, - AVAHI_GCC_UNUSED sw_corby_channel * channel) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_corby_object_set_channel( - AVAHI_GCC_UNUSED sw_corby_object self, - AVAHI_GCC_UNUSED sw_corby_channel channel) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_discovery_publish_host( - AVAHI_GCC_UNUSED sw_discovery self, - AVAHI_GCC_UNUSED sw_uint32 interface_index, - AVAHI_GCC_UNUSED sw_const_string name, - AVAHI_GCC_UNUSED sw_const_string domain, - AVAHI_GCC_UNUSED sw_ipv4_address address, - AVAHI_GCC_UNUSED sw_discovery_publish_reply reply, - AVAHI_GCC_UNUSED sw_opaque extra, - AVAHI_GCC_UNUSED sw_discovery_oid * oid) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_discovery_publish_update( - AVAHI_GCC_UNUSED sw_discovery self, - AVAHI_GCC_UNUSED sw_discovery_oid oid, - AVAHI_GCC_UNUSED sw_octets text_record, - AVAHI_GCC_UNUSED sw_uint32 text_record_len) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_discovery_query_record( - AVAHI_GCC_UNUSED sw_discovery self, - AVAHI_GCC_UNUSED sw_uint32 interface_index, - AVAHI_GCC_UNUSED sw_uint32 flags, - AVAHI_GCC_UNUSED sw_const_string fullname, - AVAHI_GCC_UNUSED sw_uint16 rrtype, - AVAHI_GCC_UNUSED sw_uint16 rrclass, - AVAHI_GCC_UNUSED sw_discovery_query_record_reply reply, - AVAHI_GCC_UNUSED sw_opaque extra, - AVAHI_GCC_UNUSED sw_discovery_oid * oid) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_text_record_string_iterator_init( - AVAHI_GCC_UNUSED sw_text_record_string_iterator * self, - AVAHI_GCC_UNUSED sw_const_string text_record_string) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_text_record_string_iterator_fina( - AVAHI_GCC_UNUSED sw_text_record_string_iterator self) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} - -sw_result sw_text_record_string_iterator_next( - AVAHI_GCC_UNUSED sw_text_record_string_iterator self, - AVAHI_GCC_UNUSED char key[255], - AVAHI_GCC_UNUSED char val[255]) { - AVAHI_WARN_UNSUPPORTED; - return SW_E_NO_IMPL; -} diff --git a/avahi-compat-howl/warn.c b/avahi-compat-howl/warn.c deleted file mode 100644 index 235bb59..0000000 --- a/avahi-compat-howl/warn.c +++ /dev/null @@ -1,29 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "warn.h" - -#define COMPAT_LAYER "HOWL" -#define CGI_SUBSYSTEM "howl" - -#include "../avahi-compat-libdns_sd/warn.c" diff --git a/avahi-compat-howl/warn.h b/avahi-compat-howl/warn.h deleted file mode 100644 index 04bd0ed..0000000 --- a/avahi-compat-howl/warn.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef foowarnhhowlfoo -#define foowarnhhowlfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -/* To avoid symbol name clashes when a process links to both our - * compatiblity layers, we move the symbols out of the way here */ - -#define avahi_warn_unsupported avahi_warn_unsupported_HOWL -#define avahi_warn_linkage avahi_warn_linkage_HOWL -#define avahi_warn avahi_warn_HOWL -#define avahi_exe_name avahi_exe_name_HOWL - -#include "../avahi-compat-libdns_sd/warn.h" - -#endif diff --git a/avahi-compat-libdns_sd.pc.in b/avahi-compat-libdns_sd.pc.in deleted file mode 100644 index d619632..0000000 --- a/avahi-compat-libdns_sd.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include/avahi-compat-libdns_sd/ - -Name: avahi-compat-libdns_sd -Description: Avahi Multicast DNS Responder (libdns_sd Compatibility) -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -ldns_sd -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-compat-libdns_sd/.gitignore b/avahi-compat-libdns_sd/.gitignore deleted file mode 100644 index 279828d..0000000 --- a/avahi-compat-libdns_sd/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -null-test -txt-test -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs diff --git a/avahi-compat-libdns_sd/Makefile.am b/avahi-compat-libdns_sd/Makefile.am deleted file mode 100644 index 9a66bc0..0000000 --- a/avahi-compat-libdns_sd/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -if HAVE_DBUS -if ENABLE_COMPAT_LIBDNS_SD - -avahi_compat_libdns_sddir=$(includedir)/avahi-compat-libdns_sd - -avahi_compat_libdns_sd_HEADERS = dns_sd.h - -lib_LTLIBRARIES = libdns_sd.la - -if ENABLE_TESTS -noinst_PROGRAMS = txt-test null-test -endif - -libdns_sd_la_SOURCES = \ - dns_sd.h \ - compat.c \ - txt.c \ - unsupported.c \ - warn.c warn.h -libdns_sd_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -libdns_sd_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_COMPAT_LIBDNS_SD_VERSION_INFO) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la - -txt_test_SOURCES = \ - dns_sd.h \ - txt.c \ - txt-test.c \ - warn.c warn.h -txt_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -txt_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la - -null_test_SOURCES = \ - dns_sd.h \ - compat.c \ - null-test.c \ - warn.c warn.h -null_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -null_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la - -# You can test the compatibility layer by sticking in mDNSResponder's -# dns-sd.c source here, naming it "libdns_sd-test.c" and running "make -# libdns_sd-test" manually. We do not distribute that file due to -# licensing restrictions. - -libdns_sd-test: libdns_sd-test.c libdns_sd.la - $(LIBTOOL) --mode=compile $(CC) $(AM_CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test.o -c libdns_sd-test.c - $(LIBTOOL) --mode=link $(CC) $(AM_CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test libdns_sd-test.o $(PTHREAD_LIBS) ../avahi-common/libavahi-common.la libdns_sd.la - -CLEANFILES = libdns_sd-test.o libdns_sd-test - -endif -endif diff --git a/avahi-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c deleted file mode 100644 index 3ea359e..0000000 --- a/avahi-compat-libdns_sd/compat.c +++ /dev/null @@ -1,1372 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "warn.h" -#include "dns_sd.h" - -enum { - COMMAND_POLL = 'p', - COMMAND_QUIT = 'q', - COMMAND_POLL_DONE = 'P', - COMMAND_POLL_FAILED = 'F' -}; - -struct type_info { - char *type; - AvahiStringList *subtypes; - int n_subtypes; -}; - -struct _DNSServiceRef_t { - int n_ref; - - AvahiSimplePoll *simple_poll; - - int thread_fd, main_fd; - - pthread_t thread; - int thread_running; - - pthread_mutex_t mutex; - - void *context; - DNSServiceBrowseReply service_browser_callback; - DNSServiceResolveReply service_resolver_callback; - DNSServiceDomainEnumReply domain_browser_callback; - DNSServiceRegisterReply service_register_callback; - DNSServiceQueryRecordReply query_resolver_callback; - - AvahiClient *client; - AvahiServiceBrowser *service_browser; - AvahiServiceResolver *service_resolver; - AvahiDomainBrowser *domain_browser; - AvahiRecordBrowser *record_browser; - - struct type_info type_info; - char *service_name, *service_name_chosen, *service_domain, *service_host; - uint16_t service_port; - AvahiIfIndex service_interface; - AvahiStringList *service_txt; - - AvahiEntryGroup *entry_group; -}; - -#define ASSERT_SUCCESS(r) { int __ret = (r); assert(__ret == 0); } - -static DNSServiceErrorType map_error(int error) { - switch (error) { - case AVAHI_OK : - return kDNSServiceErr_NoError; - - case AVAHI_ERR_BAD_STATE : - return kDNSServiceErr_BadState; - - case AVAHI_ERR_INVALID_HOST_NAME: - case AVAHI_ERR_INVALID_DOMAIN_NAME: - case AVAHI_ERR_INVALID_TTL: - case AVAHI_ERR_IS_PATTERN: - case AVAHI_ERR_INVALID_RECORD: - case AVAHI_ERR_INVALID_SERVICE_NAME: - case AVAHI_ERR_INVALID_SERVICE_TYPE: - case AVAHI_ERR_INVALID_PORT: - case AVAHI_ERR_INVALID_KEY: - case AVAHI_ERR_INVALID_ADDRESS: - case AVAHI_ERR_INVALID_SERVICE_SUBTYPE: - return kDNSServiceErr_BadParam; - - - case AVAHI_ERR_COLLISION: - return kDNSServiceErr_NameConflict; - - case AVAHI_ERR_TOO_MANY_CLIENTS: - case AVAHI_ERR_TOO_MANY_OBJECTS: - case AVAHI_ERR_TOO_MANY_ENTRIES: - case AVAHI_ERR_ACCESS_DENIED: - return kDNSServiceErr_Refused; - - case AVAHI_ERR_INVALID_OPERATION: - case AVAHI_ERR_INVALID_OBJECT: - return kDNSServiceErr_Invalid; - - case AVAHI_ERR_NO_MEMORY: - return kDNSServiceErr_NoMemory; - - case AVAHI_ERR_INVALID_INTERFACE: - case AVAHI_ERR_INVALID_PROTOCOL: - return kDNSServiceErr_BadInterfaceIndex; - - case AVAHI_ERR_INVALID_FLAGS: - return kDNSServiceErr_BadFlags; - - case AVAHI_ERR_NOT_FOUND: - return kDNSServiceErr_NoSuchName; - - case AVAHI_ERR_VERSION_MISMATCH: - return kDNSServiceErr_Incompatible; - - case AVAHI_ERR_NO_NETWORK: - case AVAHI_ERR_OS: - case AVAHI_ERR_INVALID_CONFIG: - case AVAHI_ERR_TIMEOUT: - case AVAHI_ERR_DBUS_ERROR: - case AVAHI_ERR_DISCONNECTED: - case AVAHI_ERR_NO_DAEMON: - break; - - } - - return kDNSServiceErr_Unknown; -} - -static void type_info_init(struct type_info *i) { - assert(i); - i->type = NULL; - i->subtypes = NULL; - i->n_subtypes = 0; -} - -static void type_info_free(struct type_info *i) { - assert(i); - - avahi_free(i->type); - avahi_string_list_free(i->subtypes); - - type_info_init(i); -} - -static int type_info_parse(struct type_info *i, const char *t) { - char *token = NULL; - - assert(i); - assert(t); - - type_info_init(i); - - for (;;) { - size_t l; - - if (*t == 0) - break; - - l = strcspn(t, ","); - - if (l <= 0) - goto fail; - - token = avahi_strndup(t, l); - - if (!token) - goto fail; - - if (!i->type) { - /* This is the first token, hence the main type */ - - if (!avahi_is_valid_service_type_strict(token)) - goto fail; - - i->type = token; - token = NULL; - } else { - char *fst; - - /* This is not the first token, hence a subtype */ - - if (!(fst = avahi_strdup_printf("%s._sub.%s", token, i->type))) - goto fail; - - if (!avahi_is_valid_service_subtype(fst)) { - avahi_free(fst); - goto fail; - } - - i->subtypes = avahi_string_list_add(i->subtypes, fst); - avahi_free(fst); - - avahi_free(token); - token = NULL; - - i->n_subtypes++; - } - - t += l; - - if (*t == ',') - t++; - } - - if (i->type) - return 0; - -fail: - type_info_free(i); - avahi_free(token); - return -1; -} - -static const char *add_trailing_dot(const char *s, char *buf, size_t buf_len) { - if (!s) - return NULL; - - if (*s == 0) - return s; - - if (s[strlen(s)-1] == '.') - return s; - - snprintf(buf, buf_len, "%s.", s); - return buf; -} - -static int read_command(int fd) { - ssize_t r; - char command; - - assert(fd >= 0); - - if ((r = read(fd, &command, 1)) != 1) { - fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); - return -1; - } - - return command; -} - -static int write_command(int fd, char reply) { - assert(fd >= 0); - - if (write(fd, &reply, 1) != 1) { - fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno)); - return -1; - } - - return 0; -} - -static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) { - DNSServiceRef sdref = userdata; - int ret; - - assert(sdref); - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - -/* fprintf(stderr, "pre-syscall\n"); */ - ret = poll(ufds, nfds, timeout); -/* fprintf(stderr, "post-syscall\n"); */ - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - return ret; -} - -static void * thread_func(void *data) { - DNSServiceRef sdref = data; - sigset_t mask; - - sigfillset(&mask); - pthread_sigmask(SIG_BLOCK, &mask, NULL); - - sdref->thread = pthread_self(); - sdref->thread_running = 1; - - for (;;) { - char command; - - if ((command = read_command(sdref->thread_fd)) < 0) - break; - -/* fprintf(stderr, "Command: %c\n", command); */ - - switch (command) { - - case COMMAND_POLL: { - int ret; - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - for (;;) { - errno = 0; - - if ((ret = avahi_simple_poll_run(sdref->simple_poll)) < 0) { - - if (errno == EINTR) - continue; - - fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno)); - } - - break; - } - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - if (write_command(sdref->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0) - break; - - break; - } - - case COMMAND_QUIT: - return NULL; - } - - } - - return NULL; -} - -static DNSServiceRef sdref_new(void) { - int fd[2] = { -1, -1 }; - DNSServiceRef sdref = NULL; - pthread_mutexattr_t mutex_attr; - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) - goto fail; - - if (!(sdref = avahi_new(struct _DNSServiceRef_t, 1))) - goto fail; - - sdref->n_ref = 1; - sdref->thread_fd = fd[0]; - sdref->main_fd = fd[1]; - - sdref->client = NULL; - sdref->service_browser = NULL; - sdref->service_resolver = NULL; - sdref->domain_browser = NULL; - sdref->entry_group = NULL; - - sdref->service_name = sdref->service_name_chosen = sdref->service_domain = sdref->service_host = NULL; - sdref->service_txt = NULL; - - type_info_init(&sdref->type_info); - - ASSERT_SUCCESS(pthread_mutexattr_init(&mutex_attr)); - pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - ASSERT_SUCCESS(pthread_mutex_init(&sdref->mutex, &mutex_attr)); - - sdref->thread_running = 0; - - if (!(sdref->simple_poll = avahi_simple_poll_new())) - goto fail; - - avahi_simple_poll_set_func(sdref->simple_poll, poll_func, sdref); - - /* Start simple poll */ - if (avahi_simple_poll_prepare(sdref->simple_poll, -1) < 0) - goto fail; - - /* Queue an initial POLL command for the thread */ - if (write_command(sdref->main_fd, COMMAND_POLL) < 0) - goto fail; - - if (pthread_create(&sdref->thread, NULL, thread_func, sdref) != 0) - goto fail; - - sdref->thread_running = 1; - - return sdref; - -fail: - - if (sdref) - DNSServiceRefDeallocate(sdref); - - return NULL; -} - -static void sdref_free(DNSServiceRef sdref) { - assert(sdref); - - if (sdref->thread_running) { - ASSERT_SUCCESS(write_command(sdref->main_fd, COMMAND_QUIT)); - avahi_simple_poll_wakeup(sdref->simple_poll); - ASSERT_SUCCESS(pthread_join(sdref->thread, NULL)); - } - - if (sdref->client) - avahi_client_free(sdref->client); - - if (sdref->simple_poll) - avahi_simple_poll_free(sdref->simple_poll); - - if (sdref->thread_fd >= 0) - close(sdref->thread_fd); - - if (sdref->main_fd >= 0) - close(sdref->main_fd); - - ASSERT_SUCCESS(pthread_mutex_destroy(&sdref->mutex)); - - avahi_free(sdref->service_name); - avahi_free(sdref->service_name_chosen); - avahi_free(sdref->service_domain); - avahi_free(sdref->service_host); - - type_info_free(&sdref->type_info); - - avahi_string_list_free(sdref->service_txt); - - avahi_free(sdref); -} - -static void sdref_ref(DNSServiceRef sdref) { - assert(sdref); - assert(sdref->n_ref >= 1); - - sdref->n_ref++; -} - -static void sdref_unref(DNSServiceRef sdref) { - assert(sdref); - assert(sdref->n_ref >= 1); - - if (--(sdref->n_ref) <= 0) - sdref_free(sdref); -} - -int DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdref) { - - AVAHI_WARN_LINKAGE; - - if (!sdref || sdref->n_ref <= 0) - return -1; - - return sdref->main_fd; -} - -DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdref) { - DNSServiceErrorType ret = kDNSServiceErr_Unknown; - - AVAHI_WARN_LINKAGE; - - if (!sdref || sdref->n_ref <= 0) - return kDNSServiceErr_BadParam; - - sdref_ref(sdref); - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - /* Cleanup notification socket */ - if (read_command(sdref->main_fd) != COMMAND_POLL_DONE) - goto finish; - - if (avahi_simple_poll_dispatch(sdref->simple_poll) < 0) - goto finish; - - if (sdref->n_ref > 1) /* Perhaps we should die */ - - /* Dispatch events */ - if (avahi_simple_poll_prepare(sdref->simple_poll, -1) < 0) - goto finish; - - if (sdref->n_ref > 1) - - /* Request the poll */ - if (write_command(sdref->main_fd, COMMAND_POLL) < 0) - goto finish; - - ret = kDNSServiceErr_NoError; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - sdref_unref(sdref); - - return ret; -} - -void DNSSD_API DNSServiceRefDeallocate(DNSServiceRef sdref) { - AVAHI_WARN_LINKAGE; - - if (sdref) - sdref_unref(sdref); -} - -static void service_browser_callback( - AvahiServiceBrowser *b, - AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - const char *type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - DNSServiceRef sdref = userdata; - char type_fixed[AVAHI_DOMAIN_NAME_MAX], domain_fixed[AVAHI_DOMAIN_NAME_MAX]; - assert(b); - assert(sdref); - assert(sdref->n_ref >= 1); - - type = add_trailing_dot(type, type_fixed, sizeof(type_fixed)); - domain = add_trailing_dot(domain, domain_fixed, sizeof(domain_fixed)); - - switch (event) { - case AVAHI_BROWSER_NEW: - sdref->service_browser_callback(sdref, kDNSServiceFlagsAdd, interface, kDNSServiceErr_NoError, name, type, domain, sdref->context); - break; - - case AVAHI_BROWSER_REMOVE: - sdref->service_browser_callback(sdref, 0, interface, kDNSServiceErr_NoError, name, type, domain, sdref->context); - break; - - case AVAHI_BROWSER_FAILURE: - sdref->service_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, NULL, sdref->context); - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - } -} - -static void generic_client_callback(AvahiClient *s, AvahiClientState state, void* userdata) { - DNSServiceRef sdref = userdata; - int error = kDNSServiceErr_Unknown; - - assert(s); - assert(sdref); - assert(sdref->n_ref >= 1); - - switch (state) { - - case AVAHI_CLIENT_FAILURE: - - if (sdref->service_browser_callback) - sdref->service_browser_callback(sdref, 0, 0, error, NULL, NULL, NULL, sdref->context); - else if (sdref->service_resolver_callback) - sdref->service_resolver_callback(sdref, 0, 0, error, NULL, NULL, 0, 0, NULL, sdref->context); - else if (sdref->domain_browser_callback) - sdref->domain_browser_callback(sdref, 0, 0, error, NULL, sdref->context); - else if (sdref->query_resolver_callback) - sdref->query_resolver_callback(sdref, 0, 0, error, NULL, 0, 0, 0, NULL, 0, sdref->context); - - break; - - case AVAHI_CLIENT_S_RUNNING: - case AVAHI_CLIENT_S_COLLISION: - case AVAHI_CLIENT_S_REGISTERING: - case AVAHI_CLIENT_CONNECTING: - break; - } -} - -DNSServiceErrorType DNSSD_API DNSServiceBrowse( - DNSServiceRef *ret_sdref, - DNSServiceFlags flags, - uint32_t interface, - const char *regtype, - const char *domain, - DNSServiceBrowseReply callback, - void *context) { - - DNSServiceErrorType ret = kDNSServiceErr_Unknown; - int error; - DNSServiceRef sdref = NULL; - AvahiIfIndex ifindex; - struct type_info type_info; - - AVAHI_WARN_LINKAGE; - - if (!ret_sdref || !regtype) - return kDNSServiceErr_BadParam; - *ret_sdref = NULL; - - if (interface == kDNSServiceInterfaceIndexLocalOnly || flags != 0) { - AVAHI_WARN_UNSUPPORTED; - return kDNSServiceErr_Unsupported; - } - - type_info_init(&type_info); - - if (type_info_parse(&type_info, regtype) < 0 || type_info.n_subtypes > 1) { - type_info_free(&type_info); - - if (!avahi_is_valid_service_type_generic(regtype)) - return kDNSServiceErr_Unsupported; - } else - regtype = type_info.subtypes ? (char*) type_info.subtypes->text : type_info.type; - - if (!(sdref = sdref_new())) { - type_info_free(&type_info); - return kDNSServiceErr_Unknown; - } - - sdref->context = context; - sdref->service_browser_callback = callback; - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) { - ret = map_error(error); - goto finish; - } - - ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - - if (!(sdref->service_browser = avahi_service_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, regtype, domain, 0, service_browser_callback, sdref))) { - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - - ret = kDNSServiceErr_NoError; - *ret_sdref = sdref; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - if (ret != kDNSServiceErr_NoError) - DNSServiceRefDeallocate(sdref); - - type_info_free(&type_info); - - return ret; -} - -static void service_resolver_callback( - AvahiServiceResolver *r, - AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - AVAHI_GCC_UNUSED const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - DNSServiceRef sdref = userdata; - - assert(r); - assert(sdref); - assert(sdref->n_ref >= 1); - - switch (event) { - case AVAHI_RESOLVER_FOUND: { - - char host_name_fixed[AVAHI_DOMAIN_NAME_MAX]; - char full_name[AVAHI_DOMAIN_NAME_MAX]; - int ret; - char *p = NULL; - size_t l = 0; - - host_name = add_trailing_dot(host_name, host_name_fixed, sizeof(host_name_fixed)); - - if ((p = avahi_new0(char, (l = avahi_string_list_serialize(txt, NULL, 0))+1))) - avahi_string_list_serialize(txt, p, l); - - ret = avahi_service_name_join(full_name, sizeof(full_name), name, type, domain); - assert(ret == AVAHI_OK); - - strcat(full_name, "."); - - sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_NoError, full_name, host_name, htons(port), l, (unsigned char*) p, sdref->context); - - avahi_free(p); - break; - } - - case AVAHI_RESOLVER_FAILURE: - sdref->service_resolver_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, 0, 0, NULL, sdref->context); - break; - } -} - -DNSServiceErrorType DNSSD_API DNSServiceResolve( - DNSServiceRef *ret_sdref, - DNSServiceFlags flags, - uint32_t interface, - const char *name, - const char *regtype, - const char *domain, - DNSServiceResolveReply callback, - void *context) { - - DNSServiceErrorType ret = kDNSServiceErr_Unknown; - int error; - DNSServiceRef sdref = NULL; - AvahiIfIndex ifindex; - - AVAHI_WARN_LINKAGE; - - if (!ret_sdref || !name || !regtype || !domain || !callback) - return kDNSServiceErr_BadParam; - *ret_sdref = NULL; - - if (interface == kDNSServiceInterfaceIndexLocalOnly || flags != 0) { - AVAHI_WARN_UNSUPPORTED; - return kDNSServiceErr_Unsupported; - } - - if (!(sdref = sdref_new())) - return kDNSServiceErr_Unknown; - - sdref->context = context; - sdref->service_resolver_callback = callback; - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) { - ret = map_error(error); - goto finish; - } - - ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - - if (!(sdref->service_resolver = avahi_service_resolver_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, name, regtype, domain, AVAHI_PROTO_UNSPEC, 0, service_resolver_callback, sdref))) { - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - - - ret = kDNSServiceErr_NoError; - *ret_sdref = sdref; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - if (ret != kDNSServiceErr_NoError) - DNSServiceRefDeallocate(sdref); - - return ret; -} - -int DNSSD_API DNSServiceConstructFullName ( - char *fullName, - const char *service, - const char *regtype, - const char *domain) { - - AVAHI_WARN_LINKAGE; - - if (!fullName || !regtype || !domain) - return -1; - - if (avahi_service_name_join(fullName, kDNSServiceMaxDomainName, service, regtype, domain) < 0) - return -1; - - return 0; -} - -static void domain_browser_callback( - AvahiDomainBrowser *b, - AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - DNSServiceRef sdref = userdata; - static char domain_fixed[AVAHI_DOMAIN_NAME_MAX]; - - assert(b); - assert(sdref); - assert(sdref->n_ref >= 1); - - domain = add_trailing_dot(domain, domain_fixed, sizeof(domain_fixed)); - - switch (event) { - case AVAHI_BROWSER_NEW: - sdref->domain_browser_callback(sdref, kDNSServiceFlagsAdd, interface, kDNSServiceErr_NoError, domain, sdref->context); - break; - - case AVAHI_BROWSER_REMOVE: - sdref->domain_browser_callback(sdref, 0, interface, kDNSServiceErr_NoError, domain, sdref->context); - break; - - case AVAHI_BROWSER_FAILURE: - sdref->domain_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), domain, sdref->context); - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - case AVAHI_BROWSER_ALL_FOR_NOW: - break; - } -} - -DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains( - DNSServiceRef *ret_sdref, - DNSServiceFlags flags, - uint32_t interface, - DNSServiceDomainEnumReply callback, - void *context) { - - DNSServiceErrorType ret = kDNSServiceErr_Unknown; - int error; - DNSServiceRef sdref = NULL; - AvahiIfIndex ifindex; - - AVAHI_WARN_LINKAGE; - - if (!ret_sdref || !callback) - return kDNSServiceErr_BadParam; - *ret_sdref = NULL; - - if (interface == kDNSServiceInterfaceIndexLocalOnly || - (flags != kDNSServiceFlagsBrowseDomains && flags != kDNSServiceFlagsRegistrationDomains)) { - AVAHI_WARN_UNSUPPORTED; - return kDNSServiceErr_Unsupported; - } - - if (!(sdref = sdref_new())) - return kDNSServiceErr_Unknown; - - sdref->context = context; - sdref->domain_browser_callback = callback; - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) { - ret = map_error(error); - goto finish; - } - - ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - - if (!(sdref->domain_browser = avahi_domain_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, "local", - flags == kDNSServiceFlagsRegistrationDomains ? AVAHI_DOMAIN_BROWSER_REGISTER : AVAHI_DOMAIN_BROWSER_BROWSE, - 0, domain_browser_callback, sdref))) { - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - - ret = kDNSServiceErr_NoError; - *ret_sdref = sdref; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - if (ret != kDNSServiceErr_NoError) - DNSServiceRefDeallocate(sdref); - - return ret; -} - -static void reg_report_error(DNSServiceRef sdref, DNSServiceErrorType error) { - char regtype_fixed[AVAHI_DOMAIN_NAME_MAX], domain_fixed[AVAHI_DOMAIN_NAME_MAX]; - const char *regtype, *domain; - assert(sdref); - assert(sdref->n_ref >= 1); - - if (!sdref->service_register_callback) - return; - - regtype = add_trailing_dot(sdref->type_info.type, regtype_fixed, sizeof(regtype_fixed)); - domain = add_trailing_dot(sdref->service_domain, domain_fixed, sizeof(domain_fixed)); - - sdref->service_register_callback( - sdref, 0, error, - sdref->service_name_chosen ? sdref->service_name_chosen : sdref->service_name, - regtype, - domain, - sdref->context); -} - -static int reg_create_service(DNSServiceRef sdref) { - int ret; - AvahiStringList *l; - - assert(sdref); - assert(sdref->n_ref >= 1); - - if ((ret = avahi_entry_group_add_service_strlst( - sdref->entry_group, - sdref->service_interface, - AVAHI_PROTO_UNSPEC, - 0, - sdref->service_name_chosen, - sdref->type_info.type, - sdref->service_domain, - sdref->service_host, - sdref->service_port, - sdref->service_txt)) < 0) - return ret; - - for (l = sdref->type_info.subtypes; l; l = l->next) { - /* Create a subtype entry */ - - if (avahi_entry_group_add_service_subtype( - sdref->entry_group, - sdref->service_interface, - AVAHI_PROTO_UNSPEC, - 0, - sdref->service_name_chosen, - sdref->type_info.type, - sdref->service_domain, - (const char*) l->text) < 0) - return ret; - } - - if ((ret = avahi_entry_group_commit(sdref->entry_group)) < 0) - return ret; - - return 0; -} - -static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* userdata) { - DNSServiceRef sdref = userdata; - - assert(s); - assert(sdref); - assert(sdref->n_ref >= 1); - - /* We've not been setup completely */ - if (!sdref->entry_group) - return; - - switch (state) { - case AVAHI_CLIENT_FAILURE: - reg_report_error(sdref, kDNSServiceErr_Unknown); - break; - - case AVAHI_CLIENT_S_RUNNING: { - int ret; - - if (!sdref->service_name) { - const char *n; - /* If the service name is taken from the host name, copy that */ - - avahi_free(sdref->service_name_chosen); - sdref->service_name_chosen = NULL; - - if (!(n = avahi_client_get_host_name(sdref->client))) { - reg_report_error(sdref, map_error(avahi_client_errno(sdref->client))); - return; - } - - if (!(sdref->service_name_chosen = avahi_strdup(n))) { - reg_report_error(sdref, kDNSServiceErr_NoMemory); - return; - } - } - - if (!sdref->service_name_chosen) { - - assert(sdref->service_name); - - if (!(sdref->service_name_chosen = avahi_strdup(sdref->service_name))) { - reg_report_error(sdref, kDNSServiceErr_NoMemory); - return; - } - } - - /* Register the service */ - - if ((ret = reg_create_service(sdref)) < 0) { - reg_report_error(sdref, map_error(ret)); - return; - } - - break; - } - - case AVAHI_CLIENT_S_COLLISION: - case AVAHI_CLIENT_S_REGISTERING: - - /* Remove our entry */ - avahi_entry_group_reset(sdref->entry_group); - - break; - - case AVAHI_CLIENT_CONNECTING: - /* Ignore */ - break; - } - -} - -static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { - DNSServiceRef sdref = userdata; - - assert(g); - - switch (state) { - case AVAHI_ENTRY_GROUP_ESTABLISHED: - - /* Inform the user */ - reg_report_error(sdref, kDNSServiceErr_NoError); - - break; - - case AVAHI_ENTRY_GROUP_COLLISION: { - char *n; - int ret; - - /* Remove our entry */ - avahi_entry_group_reset(sdref->entry_group); - - assert(sdref->service_name_chosen); - - /* Pick a new name */ - if (!(n = avahi_alternative_service_name(sdref->service_name_chosen))) { - reg_report_error(sdref, kDNSServiceErr_NoMemory); - return; - } - avahi_free(sdref->service_name_chosen); - sdref->service_name_chosen = n; - - /* Register the service with that new name */ - if ((ret = reg_create_service(sdref)) < 0) { - reg_report_error(sdref, map_error(ret)); - return; - } - - break; - } - - case AVAHI_ENTRY_GROUP_REGISTERING: - case AVAHI_ENTRY_GROUP_UNCOMMITED: - /* Ignore */ - break; - - case AVAHI_ENTRY_GROUP_FAILURE: - /* Inform the user */ - reg_report_error(sdref, map_error(avahi_client_errno(sdref->client))); - break; - - } -} - -DNSServiceErrorType DNSSD_API DNSServiceRegister ( - DNSServiceRef *ret_sdref, - DNSServiceFlags flags, - uint32_t interface, - const char *name, - const char *regtype, - const char *domain, - const char *host, - uint16_t port, - uint16_t txtLen, - const void *txtRecord, - DNSServiceRegisterReply callback, - void *context) { - - DNSServiceErrorType ret = kDNSServiceErr_Unknown; - int error; - DNSServiceRef sdref = NULL; - AvahiStringList *txt = NULL; - struct type_info type_info; - - AVAHI_WARN_LINKAGE; - - if (!ret_sdref || !regtype) - return kDNSServiceErr_BadParam; - *ret_sdref = NULL; - - if (!txtRecord) { - txtLen = 1; - txtRecord = ""; - } - - if (interface == kDNSServiceInterfaceIndexLocalOnly || flags) { - AVAHI_WARN_UNSUPPORTED; - return kDNSServiceErr_Unsupported; - } - - if (txtLen > 0) - if (avahi_string_list_parse(txtRecord, txtLen, &txt) < 0) - return kDNSServiceErr_Invalid; - - if (type_info_parse(&type_info, regtype) < 0) { - avahi_string_list_free(txt); - return kDNSServiceErr_Invalid; - } - - if (!(sdref = sdref_new())) { - avahi_string_list_free(txt); - type_info_free(&type_info); - return kDNSServiceErr_Unknown; - } - - sdref->context = context; - sdref->service_register_callback = callback; - - sdref->type_info = type_info; - sdref->service_name = avahi_strdup(name); - sdref->service_domain = domain ? avahi_normalize_name_strdup(domain) : NULL; - sdref->service_host = host ? avahi_normalize_name_strdup(host) : NULL; - sdref->service_interface = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - sdref->service_port = ntohs(port); - sdref->service_txt = txt; - - /* Some OOM checking would be cool here */ - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, reg_client_callback, sdref, &error))) { - ret = map_error(error); - goto finish; - } - - if (!sdref->service_domain) { - const char *d; - - if (!(d = avahi_client_get_domain_name(sdref->client))) { - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - - if (!(sdref->service_domain = avahi_strdup(d))) { - ret = kDNSServiceErr_NoMemory; - goto finish; - } - } - - if (!(sdref->entry_group = avahi_entry_group_new(sdref->client, reg_entry_group_callback, sdref))) { - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - - if (avahi_client_get_state(sdref->client) == AVAHI_CLIENT_S_RUNNING) { - const char *n; - - if (sdref->service_name) - n = sdref->service_name; - else { - if (!(n = avahi_client_get_host_name(sdref->client))) { - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - } - - if (!(sdref->service_name_chosen = avahi_strdup(n))) { - ret = kDNSServiceErr_NoMemory; - goto finish; - } - - - if ((error = reg_create_service(sdref)) < 0) { - ret = map_error(error); - goto finish; - } - } - - ret = kDNSServiceErr_NoError; - *ret_sdref = sdref; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - if (ret != kDNSServiceErr_NoError) - DNSServiceRefDeallocate(sdref); - - return ret; -} - -DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord( - DNSServiceRef sdref, - DNSRecordRef rref, - DNSServiceFlags flags, - uint16_t rdlen, - const void *rdata, - AVAHI_GCC_UNUSED uint32_t ttl) { - - int ret = kDNSServiceErr_Unknown; - AvahiStringList *txt = NULL; - - AVAHI_WARN_LINKAGE; - - if (!sdref || sdref->n_ref <= 0) - return kDNSServiceErr_BadParam; - - if (flags || rref) { - AVAHI_WARN_UNSUPPORTED; - return kDNSServiceErr_Unsupported; - } - - if (rdlen > 0) - if (avahi_string_list_parse(rdata, rdlen, &txt) < 0) - return kDNSServiceErr_Invalid; - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - if (!avahi_string_list_equal(txt, sdref->service_txt)) { - - avahi_string_list_free(sdref->service_txt); - sdref->service_txt = txt; - - if (avahi_client_get_state(sdref->client) == AVAHI_CLIENT_S_RUNNING && - sdref->entry_group && - (avahi_entry_group_get_state(sdref->entry_group) == AVAHI_ENTRY_GROUP_ESTABLISHED || - avahi_entry_group_get_state(sdref->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING)) - - if (avahi_entry_group_update_service_txt_strlst( - sdref->entry_group, - sdref->service_interface, - AVAHI_PROTO_UNSPEC, - 0, - sdref->service_name_chosen, - sdref->type_info.type, - sdref->service_domain, - sdref->service_txt) < 0) { - - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - - } else - avahi_string_list_free(txt); - - ret = kDNSServiceErr_NoError; - -finish: - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - return ret; -} - -static void query_resolver_callback( - AvahiRecordBrowser *r, - AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - uint16_t clazz, - uint16_t type, - const void* rdata, - size_t size, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - DNSServiceRef sdref = userdata; - - assert(r); - assert(sdref); - assert(sdref->n_ref >= 1); - - switch (event) { - - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE: { - - DNSServiceFlags qflags = 0; - if (event == AVAHI_BROWSER_NEW) - qflags |= kDNSServiceFlagsAdd; - - sdref->query_resolver_callback(sdref, qflags, interface, kDNSServiceErr_NoError, name, type, clazz, size, rdata, 0, sdref->context); - break; - } - - case AVAHI_BROWSER_ALL_FOR_NOW: - case AVAHI_BROWSER_CACHE_EXHAUSTED: - /* not implemented */ - break; - - case AVAHI_BROWSER_FAILURE: - sdref->query_resolver_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, 0, 0, 0, NULL, 0, sdref->context); - break; - } -} - -DNSServiceErrorType DNSSD_API DNSServiceQueryRecord ( - DNSServiceRef *ret_sdref, - DNSServiceFlags flags, - uint32_t interface, - const char *fullname, - uint16_t type, - uint16_t clazz, - DNSServiceQueryRecordReply callback, - void *context) { - - DNSServiceErrorType ret = kDNSServiceErr_Unknown; - int error; - DNSServiceRef sdref = NULL; - AvahiIfIndex ifindex; - - AVAHI_WARN_LINKAGE; - - if (!ret_sdref || !fullname) - return kDNSServiceErr_BadParam; - *ret_sdref = NULL; - - if (interface == kDNSServiceInterfaceIndexLocalOnly || flags != 0) { - AVAHI_WARN_UNSUPPORTED; - return kDNSServiceErr_Unsupported; - } - - if (!(sdref = sdref_new())) - return kDNSServiceErr_Unknown; - - sdref->context = context; - sdref->query_resolver_callback = callback; - - ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) { - ret = map_error(error); - goto finish; - } - - ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - - if (!(sdref->record_browser = avahi_record_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, fullname, clazz, type, 0, query_resolver_callback, sdref))) { - ret = map_error(avahi_client_errno(sdref->client)); - goto finish; - } - - ret = kDNSServiceErr_NoError; - *ret_sdref = sdref; - -finish: - - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - - if (ret != kDNSServiceErr_NoError) - DNSServiceRefDeallocate(sdref); - - return ret; -} diff --git a/avahi-compat-libdns_sd/dns_sd.h b/avahi-compat-libdns_sd/dns_sd.h deleted file mode 100644 index 66e494e..0000000 --- a/avahi-compat-libdns_sd/dns_sd.h +++ /dev/null @@ -1,1722 +0,0 @@ -/* -*- Mode: C; tab-width: 4 -*- - * - * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DNS_SD_H -#define _DNS_SD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* standard calling convention under Win32 is __stdcall */ -/* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */ -/* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */ -#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64) -#define DNSSD_API __stdcall -#else -#define DNSSD_API -#endif - -/* stdint.h does not exist on FreeBSD 4.x; its types are defined in sys/types.h instead */ -#if defined(__FreeBSD__) && (__FreeBSD__ < 5) -#include - -/* Likewise, on Sun, standard integer types are in sys/types.h */ -#elif defined(__sun__) -#include - -/* EFI does not have stdint.h, or anything else equivalent */ -#elif defined(EFI32) || defined(EFI64) -typedef UINT8 uint8_t; -typedef INT8 int8_t; -typedef UINT16 uint16_t; -typedef INT16 int16_t; -typedef UINT32 uint32_t; -typedef INT32 int32_t; - -/* Windows has its own differences */ -#elif defined(_WIN32) -#include -#define _UNUSED -#define bzero(a, b) memset(a, 0, b) -#ifndef _MSL_STDINT_H -typedef UINT8 uint8_t; -typedef INT8 int8_t; -typedef UINT16 uint16_t; -typedef INT16 int16_t; -typedef UINT32 uint32_t; -typedef INT32 int32_t; -#endif - -/* All other Posix platforms use stdint.h */ -#else -#include -#endif - -/* DNSServiceRef, DNSRecordRef - * - * Opaque internal data types. - * Note: client is responsible for serializing access to these structures if - * they are shared between concurrent threads. - */ - -typedef struct _DNSServiceRef_t *DNSServiceRef; -typedef struct _DNSRecordRef_t *DNSRecordRef; - -/* General flags used in functions defined below */ -enum - { - kDNSServiceFlagsMoreComing = 0x1, - /* MoreComing indicates to a callback that at least one more result is - * queued and will be delivered following immediately after this one. - * Applications should not update their UI to display browse - * results when the MoreComing flag is set, because this would - * result in a great deal of ugly flickering on the screen. - * Applications should instead wait until until MoreComing is not set, - * and then update their UI. - * When MoreComing is not set, that doesn't mean there will be no more - * answers EVER, just that there are no more answers immediately - * available right now at this instant. If more answers become available - * in the future they will be delivered as usual. - */ - - kDNSServiceFlagsAdd = 0x2, - kDNSServiceFlagsDefault = 0x4, - /* Flags for domain enumeration and browse/query reply callbacks. - * "Default" applies only to enumeration and is only valid in - * conjuction with "Add". An enumeration callback with the "Add" - * flag NOT set indicates a "Remove", i.e. the domain is no longer - * valid. - */ - - kDNSServiceFlagsNoAutoRename = 0x8, - /* Flag for specifying renaming behavior on name conflict when registering - * non-shared records. By default, name conflicts are automatically handled - * by renaming the service. NoAutoRename overrides this behavior - with this - * flag set, name conflicts will result in a callback. The NoAutorename flag - * is only valid if a name is explicitly specified when registering a service - * (i.e. the default name is not used.) - */ - - kDNSServiceFlagsShared = 0x10, - kDNSServiceFlagsUnique = 0x20, - /* Flag for registering individual records on a connected - * DNSServiceRef. Shared indicates that there may be multiple records - * with this name on the network (e.g. PTR records). Unique indicates that the - * record's name is to be unique on the network (e.g. SRV records). - */ - - kDNSServiceFlagsBrowseDomains = 0x40, - kDNSServiceFlagsRegistrationDomains = 0x80, - /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains. - * BrowseDomains enumerates domains recommended for browsing, RegistrationDomains - * enumerates domains recommended for registration. - */ - - kDNSServiceFlagsLongLivedQuery = 0x100, - /* Flag for creating a long-lived unicast query for the DNSServiceQueryRecord call. */ - - kDNSServiceFlagsAllowRemoteQuery = 0x200, - /* Flag for creating a record for which we will answer remote queries - * (queries from hosts more than one hop away; hosts not directly connected to the local link). - */ - - kDNSServiceFlagsForceMulticast = 0x400, - /* Flag for signifying that a query or registration should be performed exclusively via multicast DNS, - * even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS. - */ - - kDNSServiceFlagsReturnCNAME = 0x800 - /* Flag for returning CNAME records in the DNSServiceQueryRecord call. CNAME records are - * normally followed without indicating to the client that there was a CNAME record. - */ - }; - -/* - * The values for DNS Classes and Types are listed in RFC 1035, and are available - * on every OS in its DNS header file. Unfortunately every OS does not have the - * same header file containing DNS Class and Type constants, and the names of - * the constants are not consistent. For example, BIND 8 uses "T_A", - * BIND 9 uses "ns_t_a", Windows uses "DNS_TYPE_A", etc. - * For this reason, these constants are also listed here, so that code using - * the DNS-SD programming APIs can use these constants, so that the same code - * can compile on all our supported platforms. - */ - -enum - { - kDNSServiceClass_IN = 1 /* Internet */ - }; - -enum - { - kDNSServiceType_A = 1, /* Host address. */ - kDNSServiceType_NS = 2, /* Authoritative server. */ - kDNSServiceType_MD = 3, /* Mail destination. */ - kDNSServiceType_MF = 4, /* Mail forwarder. */ - kDNSServiceType_CNAME = 5, /* Canonical name. */ - kDNSServiceType_SOA = 6, /* Start of authority zone. */ - kDNSServiceType_MB = 7, /* Mailbox domain name. */ - kDNSServiceType_MG = 8, /* Mail group member. */ - kDNSServiceType_MR = 9, /* Mail rename name. */ - kDNSServiceType_NULL = 10, /* Null resource record. */ - kDNSServiceType_WKS = 11, /* Well known service. */ - kDNSServiceType_PTR = 12, /* Domain name pointer. */ - kDNSServiceType_HINFO = 13, /* Host information. */ - kDNSServiceType_MINFO = 14, /* Mailbox information. */ - kDNSServiceType_MX = 15, /* Mail routing information. */ - kDNSServiceType_TXT = 16, /* One or more text strings. */ - kDNSServiceType_RP = 17, /* Responsible person. */ - kDNSServiceType_AFSDB = 18, /* AFS cell database. */ - kDNSServiceType_X25 = 19, /* X_25 calling address. */ - kDNSServiceType_ISDN = 20, /* ISDN calling address. */ - kDNSServiceType_RT = 21, /* Router. */ - kDNSServiceType_NSAP = 22, /* NSAP address. */ - kDNSServiceType_NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated). */ - kDNSServiceType_SIG = 24, /* Security signature. */ - kDNSServiceType_KEY = 25, /* Security key. */ - kDNSServiceType_PX = 26, /* X.400 mail mapping. */ - kDNSServiceType_GPOS = 27, /* Geographical position (withdrawn). */ - kDNSServiceType_AAAA = 28, /* IPv6 Address. */ - kDNSServiceType_LOC = 29, /* Location Information. */ - kDNSServiceType_NXT = 30, /* Next domain (security). */ - kDNSServiceType_EID = 31, /* Endpoint identifier. */ - kDNSServiceType_NIMLOC = 32, /* Nimrod Locator. */ - kDNSServiceType_SRV = 33, /* Server Selection. */ - kDNSServiceType_ATMA = 34, /* ATM Address */ - kDNSServiceType_NAPTR = 35, /* Naming Authority PoinTeR */ - kDNSServiceType_KX = 36, /* Key Exchange */ - kDNSServiceType_CERT = 37, /* Certification record */ - kDNSServiceType_A6 = 38, /* IPv6 Address (deprecated) */ - kDNSServiceType_DNAME = 39, /* Non-terminal DNAME (for IPv6) */ - kDNSServiceType_SINK = 40, /* Kitchen sink (experimentatl) */ - kDNSServiceType_OPT = 41, /* EDNS0 option (meta-RR) */ - kDNSServiceType_TKEY = 249, /* Transaction key */ - kDNSServiceType_TSIG = 250, /* Transaction signature. */ - kDNSServiceType_IXFR = 251, /* Incremental zone transfer. */ - kDNSServiceType_AXFR = 252, /* Transfer zone of authority. */ - kDNSServiceType_MAILB = 253, /* Transfer mailbox records. */ - kDNSServiceType_MAILA = 254, /* Transfer mail agent records. */ - kDNSServiceType_ANY = 255 /* Wildcard match. */ - }; - - -/* possible error code values */ -enum - { - kDNSServiceErr_NoError = 0, - kDNSServiceErr_Unknown = -65537, /* 0xFFFE FFFF */ - kDNSServiceErr_NoSuchName = -65538, - kDNSServiceErr_NoMemory = -65539, - kDNSServiceErr_BadParam = -65540, - kDNSServiceErr_BadReference = -65541, - kDNSServiceErr_BadState = -65542, - kDNSServiceErr_BadFlags = -65543, - kDNSServiceErr_Unsupported = -65544, - kDNSServiceErr_NotInitialized = -65545, - kDNSServiceErr_AlreadyRegistered = -65547, - kDNSServiceErr_NameConflict = -65548, - kDNSServiceErr_Invalid = -65549, - kDNSServiceErr_Firewall = -65550, - kDNSServiceErr_Incompatible = -65551, /* client library incompatible with daemon */ - kDNSServiceErr_BadInterfaceIndex = -65552, - kDNSServiceErr_Refused = -65553, - kDNSServiceErr_NoSuchRecord = -65554, - kDNSServiceErr_NoAuth = -65555, - kDNSServiceErr_NoSuchKey = -65556, - kDNSServiceErr_NATTraversal = -65557, - kDNSServiceErr_DoubleNAT = -65558, - kDNSServiceErr_BadTime = -65559 - /* mDNS Error codes are in the range - * FFFE FF00 (-65792) to FFFE FFFF (-65537) */ - }; - - -/* Maximum length, in bytes, of a service name represented as a */ -/* literal C-String, including the terminating NULL at the end. */ - -#define kDNSServiceMaxServiceName 64 - -/* Maximum length, in bytes, of a domain name represented as an *escaped* C-String */ -/* including the final trailing dot, and the C-String terminating NULL at the end. */ - -#define kDNSServiceMaxDomainName 1005 - -/* - * Notes on DNS Name Escaping - * -- or -- - * "Why is kDNSServiceMaxDomainName 1005, when the maximum legal domain name is 255 bytes?" - * - * All strings used in DNS-SD are UTF-8 strings. - * With few exceptions, most are also escaped using standard DNS escaping rules: - * - * '\\' represents a single literal '\' in the name - * '\.' represents a single literal '.' in the name - * '\ddd', where ddd is a three-digit decimal value from 000 to 255, - * represents a single literal byte with that value. - * A bare unescaped '.' is a label separator, marking a boundary between domain and subdomain. - * - * The exceptions, that do not use escaping, are the routines where the full - * DNS name of a resource is broken, for convenience, into servicename/regtype/domain. - * In these routines, the "servicename" is NOT escaped. It does not need to be, since - * it is, by definition, just a single literal string. Any characters in that string - * represent exactly what they are. The "regtype" portion is, technically speaking, - * escaped, but since legal regtypes are only allowed to contain letters, digits, - * and hyphens, there is nothing to escape, so the issue is moot. The "domain" - * portion is also escaped, though most domains in use on the public Internet - * today, like regtypes, don't contain any characters that need to be escaped. - * As DNS-SD becomes more popular, rich-text domains for service discovery will - * become common, so software should be written to cope with domains with escaping. - * - * The servicename may be up to 63 bytes of UTF-8 text (not counting the C-String - * terminating NULL at the end). The regtype is of the form _service._tcp or - * _service._udp, where the "service" part is 1-14 characters, which may be - * letters, digits, or hyphens. The domain part of the three-part name may be - * any legal domain, providing that the resulting servicename+regtype+domain - * name does not exceed 255 bytes. - * - * For most software, these issues are transparent. When browsing, the discovered - * servicenames should simply be displayed as-is. When resolving, the discovered - * servicename/regtype/domain are simply passed unchanged to DNSServiceResolve(). - * When a DNSServiceResolve() succeeds, the returned fullname is already in - * the correct format to pass to standard system DNS APIs such as res_query(). - * For converting from servicename/regtype/domain to a single properly-escaped - * full DNS name, the helper function DNSServiceConstructFullName() is provided. - * - * The following (highly contrived) example illustrates the escaping process. - * Suppose you have an service called "Dr. Smith\Dr. Johnson", of type "_ftp._tcp" - * in subdomain "4th. Floor" of subdomain "Building 2" of domain "apple.com." - * The full (escaped) DNS name of this service's SRV record would be: - * Dr\.\032Smith\\Dr\.\032Johnson._ftp._tcp.4th\.\032Floor.Building\0322.apple.com. - */ - - -/* - * Constants for specifying an interface index - * - * Specific interface indexes are identified via a 32-bit unsigned integer returned - * by the if_nametoindex() family of calls. - * - * If the client passes 0 for interface index, that means "do the right thing", - * which (at present) means, "if the name is in an mDNS local multicast domain - * (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast - * on all applicable interfaces, otherwise send via unicast to the appropriate - * DNS server." Normally, most clients will use 0 for interface index to - * automatically get the default sensible behaviour. - * - * If the client passes a positive interface index, then for multicast names that - * indicates to do the operation only on that one interface. For unicast names the - * interface index is ignored unless kDNSServiceFlagsForceMulticast is also set. - * - * If the client passes kDNSServiceInterfaceIndexLocalOnly when registering - * a service, then that service will be found *only* by other local clients - * on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly - * or kDNSServiceInterfaceIndexAny. - * If a client has a 'private' service, accessible only to other processes - * running on the same machine, this allows the client to advertise that service - * in a way such that it does not inadvertently appear in service lists on - * all the other machines on the network. - * - * If the client passes kDNSServiceInterfaceIndexLocalOnly when browsing - * then it will find *all* records registered on that same local machine. - * Clients explicitly wishing to discover *only* LocalOnly services can - * accomplish this by inspecting the interfaceIndex of each service reported - * to their DNSServiceBrowseReply() callback function, and discarding those - * where the interface index is not kDNSServiceInterfaceIndexLocalOnly. - */ - -#define kDNSServiceInterfaceIndexAny 0 -#define kDNSServiceInterfaceIndexLocalOnly ( (uint32_t) -1 ) - - -typedef uint32_t DNSServiceFlags; -typedef int32_t DNSServiceErrorType; - - -/********************************************************************************************* - * - * Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions - * - *********************************************************************************************/ - - -/* DNSServiceRefSockFD() - * - * Access underlying Unix domain socket for an initialized DNSServiceRef. - * The DNS Service Discovery implmementation uses this socket to communicate between - * the client and the mDNSResponder daemon. The application MUST NOT directly read from - * or write to this socket. Access to the socket is provided so that it can be used as a - * run loop source, or in a select() loop: when data is available for reading on the socket, - * DNSServiceProcessResult() should be called, which will extract the daemon's reply from - * the socket, and pass it to the appropriate application callback. By using a run loop or - * select(), results from the daemon can be processed asynchronously. Without using these - * constructs, DNSServiceProcessResult() will block until the response from the daemon arrives. - * The client is responsible for ensuring that the data on the socket is processed in a timely - * fashion - the daemon may terminate its connection with a client that does not clear its - * socket buffer. - * - * sdRef: A DNSServiceRef initialized by any of the DNSService calls. - * - * return value: The DNSServiceRef's underlying socket descriptor, or -1 on - * error. - */ - -int DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdRef); - - -/* DNSServiceProcessResult() - * - * Read a reply from the daemon, calling the appropriate application callback. This call will - * block until the daemon's response is received. Use DNSServiceRefSockFD() in - * conjunction with a run loop or select() to determine the presence of a response from the - * server before calling this function to process the reply without blocking. Call this function - * at any point if it is acceptable to block until the daemon's response arrives. Note that the - * client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is - * a reply from the daemon - the daemon may terminate its connection with a client that does not - * process the daemon's responses. - * - * sdRef: A DNSServiceRef initialized by any of the DNSService calls - * that take a callback parameter. - * - * return value: Returns kDNSServiceErr_NoError on success, otherwise returns - * an error code indicating the specific failure that occurred. - */ - -DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdRef); - - -/* DNSServiceRefDeallocate() - * - * Terminate a connection with the daemon and free memory associated with the DNSServiceRef. - * Any services or records registered with this DNSServiceRef will be deregistered. Any - * Browse, Resolve, or Query operations called with this reference will be terminated. - * - * Note: If the reference's underlying socket is used in a run loop or select() call, it should - * be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's - * socket. - * - * Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs - * created via this reference will be invalidated by this call - the resource records are - * deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly, - * if the reference was initialized with DNSServiceRegister, and an extra resource record was - * added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call - * is invalidated when this function is called - the DNSRecordRef may not be used in subsequent - * functions. - * - * Note: This call is to be used only with the DNSServiceRef defined by this API. It is - * not compatible with dns_service_discovery_ref objects defined in the legacy Mach-based - * DNSServiceDiscovery.h API. - * - * sdRef: A DNSServiceRef initialized by any of the DNSService calls. - * - */ - -void DNSSD_API DNSServiceRefDeallocate(DNSServiceRef sdRef); - - -/********************************************************************************************* - * - * Domain Enumeration - * - *********************************************************************************************/ - -/* DNSServiceEnumerateDomains() - * - * Asynchronously enumerate domains available for browsing and registration. - * - * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains - * are to be found. - * - * Note that the names returned are (like all of DNS-SD) UTF-8 strings, - * and are escaped using standard DNS escaping rules. - * (See "Notes on DNS Name Escaping" earlier in this file for more details.) - * A graphical browser displaying a hierarchical tree-structured view should cut - * the names at the bare dots to yield individual labels, then de-escape each - * label according to the escaping rules, and then display the resulting UTF-8 text. - * - * DNSServiceDomainEnumReply Callback Parameters: - * - * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains(). - * - * flags: Possible values are: - * kDNSServiceFlagsMoreComing - * kDNSServiceFlagsAdd - * kDNSServiceFlagsDefault - * - * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given - * interface is determined via the if_nametoindex() family of calls.) - * - * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise indicates - * the failure that occurred (other parameters are undefined if errorCode is nonzero). - * - * replyDomain: The name of the domain. - * - * context: The context pointer passed to DNSServiceEnumerateDomains. - * - */ - -typedef void (DNSSD_API *DNSServiceDomainEnumReply) - ( - DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *replyDomain, - void *context - ); - - -/* DNSServiceEnumerateDomains() Parameters: - * - * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds - * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, - * and the enumeration operation will run indefinitely until the client - * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). - * - * flags: Possible values are: - * kDNSServiceFlagsBrowseDomains to enumerate domains recommended for browsing. - * kDNSServiceFlagsRegistrationDomains to enumerate domains recommended - * for registration. - * - * interfaceIndex: If non-zero, specifies the interface on which to look for domains. - * (the index for a given interface is determined via the if_nametoindex() - * family of calls.) Most applications will pass 0 to enumerate domains on - * all interfaces. See "Constants for specifying an interface index" for more details. - * - * callBack: The function to be called when a domain is found or the call asynchronously - * fails. - * - * context: An application context pointer which is passed to the callback function - * (may be NULL). - * - * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous - * errors are delivered to the callback), otherwise returns an error code indicating - * the error that occurred (the callback is not invoked and the DNSServiceRef - * is not initialized.) - */ - -DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains - ( - DNSServiceRef *sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceDomainEnumReply callBack, - void *context /* may be NULL */ - ); - - -/********************************************************************************************* - * - * Service Registration - * - *********************************************************************************************/ - -/* Register a service that is discovered via Browse() and Resolve() calls. - * - * - * DNSServiceRegisterReply() Callback Parameters: - * - * sdRef: The DNSServiceRef initialized by DNSServiceRegister(). - * - * flags: Currently unused, reserved for future use. - * - * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will - * indicate the failure that occurred (including name conflicts, - * if the kDNSServiceFlagsNoAutoRename flag was used when registering.) - * Other parameters are undefined if errorCode is nonzero. - * - * name: The service name registered (if the application did not specify a name in - * DNSServiceRegister(), this indicates what name was automatically chosen). - * - * regtype: The type of service registered, as it was passed to the callout. - * - * domain: The domain on which the service was registered (if the application did not - * specify a domain in DNSServiceRegister(), this indicates the default domain - * on which the service was registered). - * - * context: The context pointer that was passed to the callout. - * - */ - -typedef void (DNSSD_API *DNSServiceRegisterReply) - ( - DNSServiceRef sdRef, - DNSServiceFlags flags, - DNSServiceErrorType errorCode, - const char *name, - const char *regtype, - const char *domain, - void *context - ); - - -/* DNSServiceRegister() Parameters: - * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds - * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, - * and the registration will remain active indefinitely until the client - * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). - * - * interfaceIndex: If non-zero, specifies the interface on which to register the service - * (the index for a given interface is determined via the if_nametoindex() - * family of calls.) Most applications will pass 0 to register on all - * available interfaces. See "Constants for specifying an interface index" for more details. - * - * flags: Indicates the renaming behavior on name conflict (most applications - * will pass 0). See flag definitions above for details. - * - * name: If non-NULL, specifies the service name to be registered. - * Most applications will not specify a name, in which case the computer - * name is used (this name is communicated to the client via the callback). - * If a name is specified, it must be 1-63 bytes of UTF-8 text. - * If the name is longer than 63 bytes it will be automatically truncated - * to a legal length, unless the NoAutoRename flag is set, - * in which case kDNSServiceErr_BadParam will be returned. - * - * regtype: The service type followed by the protocol, separated by a dot - * (e.g. "_ftp._tcp"). The service type must be an underscore, followed - * by 1-14 characters, which may be letters, digits, or hyphens. - * The transport protocol must be "_tcp" or "_udp". New service types - * should be registered at . - * - * domain: If non-NULL, specifies the domain on which to advertise the service. - * Most applications will not specify a domain, instead automatically - * registering in the default domain(s). - * - * host: If non-NULL, specifies the SRV target host name. Most applications - * will not specify a host, instead automatically using the machine's - * default host name(s). Note that specifying a non-NULL host does NOT - * create an address record for that host - the application is responsible - * for ensuring that the appropriate address record exists, or creating it - * via DNSServiceRegisterRecord(). - * - * port: The port, in network byte order, on which the service accepts connections. - * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered - * by browsing, but will cause a name conflict if another client tries to - * register that same name). Most clients will not use placeholder services. - * - * txtLen: The length of the txtRecord, in bytes. Must be zero if the txtRecord is NULL. - * - * txtRecord: The TXT record rdata. A non-NULL txtRecord MUST be a properly formatted DNS - * TXT record, i.e. ... - * Passing NULL for the txtRecord is allowed as a synonym for txtLen=1, txtRecord="", - * i.e. it creates a TXT record of length one containing a single empty string. - * RFC 1035 doesn't allow a TXT record to contain *zero* strings, so a single empty - * string is the smallest legal DNS TXT record. - * As with the other parameters, the DNSServiceRegister call copies the txtRecord - * data; e.g. if you allocated the storage for the txtRecord parameter with malloc() - * then you can safely free that memory right after the DNSServiceRegister call returns. - * - * callBack: The function to be called when the registration completes or asynchronously - * fails. The client MAY pass NULL for the callback - The client will NOT be notified - * of the default values picked on its behalf, and the client will NOT be notified of any - * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration - * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL. - * The client may still deregister the service at any time via DNSServiceRefDeallocate(). - * - * context: An application context pointer which is passed to the callback function - * (may be NULL). - * - * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous - * errors are delivered to the callback), otherwise returns an error code indicating - * the error that occurred (the callback is never invoked and the DNSServiceRef - * is not initialized.) - */ - -DNSServiceErrorType DNSSD_API DNSServiceRegister - ( - DNSServiceRef *sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - const char *name, /* may be NULL */ - const char *regtype, - const char *domain, /* may be NULL */ - const char *host, /* may be NULL */ - uint16_t port, - uint16_t txtLen, - const void *txtRecord, /* may be NULL */ - DNSServiceRegisterReply callBack, /* may be NULL */ - void *context /* may be NULL */ - ); - - -/* DNSServiceAddRecord() - * - * Add a record to a registered service. The name of the record will be the same as the - * registered service's name. - * The record can later be updated or deregistered by passing the RecordRef initialized - * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). - * - * Note that the DNSServiceAddRecord/UpdateRecord/RemoveRecord are *NOT* thread-safe - * with respect to a single DNSServiceRef. If you plan to have multiple threads - * in your program simultaneously add, update, or remove records from the same - * DNSServiceRef, then it's the caller's responsibility to use a mutext lock - * or take similar appropriate precautions to serialize those calls. - * - * - * Parameters; - * - * sdRef: A DNSServiceRef initialized by DNSServiceRegister(). - * - * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this - * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). - * If the above DNSServiceRef is passed to DNSServiceRefDeallocate(), RecordRef is also - * invalidated and may not be used further. - * - * flags: Currently ignored, reserved for future use. - * - * rrtype: The type of the record (e.g. kDNSServiceType_TXT, kDNSServiceType_SRV, etc) - * - * rdlen: The length, in bytes, of the rdata. - * - * rdata: The raw rdata to be contained in the added resource record. - * - * ttl: The time to live of the resource record, in seconds. Pass 0 to use a default value. - * - * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an - * error code indicating the error that occurred (the RecordRef is not initialized). - */ - -DNSServiceErrorType DNSSD_API DNSServiceAddRecord - ( - DNSServiceRef sdRef, - DNSRecordRef *RecordRef, - DNSServiceFlags flags, - uint16_t rrtype, - uint16_t rdlen, - const void *rdata, - uint32_t ttl - ); - - -/* DNSServiceUpdateRecord - * - * Update a registered resource record. The record must either be: - * - The primary txt record of a service registered via DNSServiceRegister() - * - A record added to a registered service via DNSServiceAddRecord() - * - An individual record registered by DNSServiceRegisterRecord() - * - * - * Parameters: - * - * sdRef: A DNSServiceRef that was initialized by DNSServiceRegister() - * or DNSServiceCreateConnection(). - * - * RecordRef: A DNSRecordRef initialized by DNSServiceAddRecord, or NULL to update the - * service's primary txt record. - * - * flags: Currently ignored, reserved for future use. - * - * rdlen: The length, in bytes, of the new rdata. - * - * rdata: The new rdata to be contained in the updated resource record. - * - * ttl: The time to live of the updated resource record, in seconds. - * - * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an - * error code indicating the error that occurred. - */ - -DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord - ( - DNSServiceRef sdRef, - DNSRecordRef RecordRef, /* may be NULL */ - DNSServiceFlags flags, - uint16_t rdlen, - const void *rdata, - uint32_t ttl - ); - - -/* DNSServiceRemoveRecord - * - * Remove a record previously added to a service record set via DNSServiceAddRecord(), or deregister - * an record registered individually via DNSServiceRegisterRecord(). - * - * Parameters: - * - * sdRef: A DNSServiceRef initialized by DNSServiceRegister() (if the - * record being removed was registered via DNSServiceAddRecord()) or by - * DNSServiceCreateConnection() (if the record being removed was registered via - * DNSServiceRegisterRecord()). - * - * recordRef: A DNSRecordRef initialized by a successful call to DNSServiceAddRecord() - * or DNSServiceRegisterRecord(). - * - * flags: Currently ignored, reserved for future use. - * - * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an - * error code indicating the error that occurred. - */ - -DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord - ( - DNSServiceRef sdRef, - DNSRecordRef RecordRef, - DNSServiceFlags flags - ); - - -/********************************************************************************************* - * - * Service Discovery - * - *********************************************************************************************/ - -/* Browse for instances of a service. - * - * - * DNSServiceBrowseReply() Parameters: - * - * sdRef: The DNSServiceRef initialized by DNSServiceBrowse(). - * - * flags: Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd. - * See flag definitions for details. - * - * interfaceIndex: The interface on which the service is advertised. This index should - * be passed to DNSServiceResolve() when resolving the service. - * - * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will - * indicate the failure that occurred. Other parameters are undefined if - * the errorCode is nonzero. - * - * serviceName: The discovered service name. This name should be displayed to the user, - * and stored for subsequent use in the DNSServiceResolve() call. - * - * regtype: The service type, which is usually (but not always) the same as was passed - * to DNSServiceBrowse(). One case where the discovered service type may - * not be the same as the requested service type is when using subtypes: - * The client may want to browse for only those ftp servers that allow - * anonymous connections. The client will pass the string "_ftp._tcp,_anon" - * to DNSServiceBrowse(), but the type of the service that's discovered - * is simply "_ftp._tcp". The regtype for each discovered service instance - * should be stored along with the name, so that it can be passed to - * DNSServiceResolve() when the service is later resolved. - * - * domain: The domain of the discovered service instance. This may or may not be the - * same as the domain that was passed to DNSServiceBrowse(). The domain for each - * discovered service instance should be stored along with the name, so that - * it can be passed to DNSServiceResolve() when the service is later resolved. - * - * context: The context pointer that was passed to the callout. - * - */ - -typedef void (DNSSD_API *DNSServiceBrowseReply) - ( - DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *serviceName, - const char *regtype, - const char *replyDomain, - void *context - ); - - -/* DNSServiceBrowse() Parameters: - * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds - * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, - * and the browse operation will run indefinitely until the client - * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). - * - * flags: Currently ignored, reserved for future use. - * - * interfaceIndex: If non-zero, specifies the interface on which to browse for services - * (the index for a given interface is determined via the if_nametoindex() - * family of calls.) Most applications will pass 0 to browse on all available - * interfaces. See "Constants for specifying an interface index" for more details. - * - * regtype: The service type being browsed for followed by the protocol, separated by a - * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp". - * - * domain: If non-NULL, specifies the domain on which to browse for services. - * Most applications will not specify a domain, instead browsing on the - * default domain(s). - * - * callBack: The function to be called when an instance of the service being browsed for - * is found, or if the call asynchronously fails. - * - * context: An application context pointer which is passed to the callback function - * (may be NULL). - * - * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous - * errors are delivered to the callback), otherwise returns an error code indicating - * the error that occurred (the callback is not invoked and the DNSServiceRef - * is not initialized.) - */ - -DNSServiceErrorType DNSSD_API DNSServiceBrowse - ( - DNSServiceRef *sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - const char *regtype, - const char *domain, /* may be NULL */ - DNSServiceBrowseReply callBack, - void *context /* may be NULL */ - ); - - -/* DNSServiceResolve() - * - * Resolve a service name discovered via DNSServiceBrowse() to a target host name, port number, and - * txt record. - * - * Note: Applications should NOT use DNSServiceResolve() solely for txt record monitoring - use - * DNSServiceQueryRecord() instead, as it is more efficient for this task. - * - * Note: When the desired results have been returned, the client MUST terminate the resolve by calling - * DNSServiceRefDeallocate(). - * - * Note: DNSServiceResolve() behaves correctly for typical services that have a single SRV record - * and a single TXT record. To resolve non-standard services with multiple SRV or TXT records, - * DNSServiceQueryRecord() should be used. - * - * DNSServiceResolveReply Callback Parameters: - * - * sdRef: The DNSServiceRef initialized by DNSServiceResolve(). - * - * flags: Currently unused, reserved for future use. - * - * interfaceIndex: The interface on which the service was resolved. - * - * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will - * indicate the failure that occurred. Other parameters are undefined if - * the errorCode is nonzero. - * - * fullname: The full service domain name, in the form ... - * (This name is escaped following standard DNS rules, making it suitable for - * passing to standard system DNS APIs such as res_query(), or to the - * special-purpose functions included in this API that take fullname parameters. - * See "Notes on DNS Name Escaping" earlier in this file for more details.) - * - * hosttarget: The target hostname of the machine providing the service. This name can - * be passed to functions like gethostbyname() to identify the host's IP address. - * - * port: The port, in network byte order, on which connections are accepted for this service. - * - * txtLen: The length of the txt record, in bytes. - * - * txtRecord: The service's primary txt record, in standard txt record format. - * - * context: The context pointer that was passed to the callout. - * - * NOTE: In earlier versions of this header file, the txtRecord parameter was declared "const char *" - * This is incorrect, since it contains length bytes which are values in the range 0 to 255, not -128 to +127. - * Depending on your compiler settings, this change may cause signed/unsigned mismatch warnings. - * These should be fixed by updating your own callback function definition to match the corrected - * function signature using "const unsigned char *txtRecord". Making this change may also fix inadvertent - * bugs in your callback function, where it could have incorrectly interpreted a length byte with value 250 - * as being -6 instead, with various bad consequences ranging from incorrect operation to software crashes. - * If you need to maintain portable code that will compile cleanly with both the old and new versions of - * this header file, you should update your callback function definition to use the correct unsigned value, - * and then in the place where you pass your callback function to DNSServiceResolve(), use a cast to eliminate - * the compiler warning, e.g.: - * DNSServiceResolve(sd, flags, index, name, regtype, domain, (DNSServiceResolveReply)MyCallback, context); - * This will ensure that your code compiles cleanly without warnings (and more importantly, works correctly) - * with both the old header and with the new corrected version. - * - */ - -typedef void (DNSSD_API *DNSServiceResolveReply) - ( - DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *fullname, - const char *hosttarget, - uint16_t port, - uint16_t txtLen, - const unsigned char *txtRecord, - void *context - ); - - -/* DNSServiceResolve() Parameters - * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds - * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, - * and the resolve operation will run indefinitely until the client - * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). - * - * flags: Currently ignored, reserved for future use. - * - * interfaceIndex: The interface on which to resolve the service. If this resolve call is - * as a result of a currently active DNSServiceBrowse() operation, then the - * interfaceIndex should be the index reported in the DNSServiceBrowseReply - * callback. If this resolve call is using information previously saved - * (e.g. in a preference file) for later use, then use interfaceIndex 0, because - * the desired service may now be reachable via a different physical interface. - * See "Constants for specifying an interface index" for more details. - * - * name: The name of the service instance to be resolved, as reported to the - * DNSServiceBrowseReply() callback. - * - * regtype: The type of the service instance to be resolved, as reported to the - * DNSServiceBrowseReply() callback. - * - * domain: The domain of the service instance to be resolved, as reported to the - * DNSServiceBrowseReply() callback. - * - * callBack: The function to be called when a result is found, or if the call - * asynchronously fails. - * - * context: An application context pointer which is passed to the callback function - * (may be NULL). - * - * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous - * errors are delivered to the callback), otherwise returns an error code indicating - * the error that occurred (the callback is never invoked and the DNSServiceRef - * is not initialized.) - */ - -DNSServiceErrorType DNSSD_API DNSServiceResolve - ( - DNSServiceRef *sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - const char *name, - const char *regtype, - const char *domain, - DNSServiceResolveReply callBack, - void *context /* may be NULL */ - ); - - -/********************************************************************************************* - * - * Special Purpose Calls (most applications will not use these) - * - *********************************************************************************************/ - -/* DNSServiceCreateConnection() - * - * Create a connection to the daemon allowing efficient registration of - * multiple individual records. - * - * - * Parameters: - * - * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating - * the reference (via DNSServiceRefDeallocate()) severs the - * connection and deregisters all records registered on this connection. - * - * return value: Returns kDNSServiceErr_NoError on success, otherwise returns - * an error code indicating the specific failure that occurred (in which - * case the DNSServiceRef is not initialized). - */ - -DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(DNSServiceRef *sdRef); - - -/* DNSServiceRegisterRecord - * - * Register an individual resource record on a connected DNSServiceRef. - * - * Note that name conflicts occurring for records registered via this call must be handled - * by the client in the callback. - * - * - * DNSServiceRegisterRecordReply() parameters: - * - * sdRef: The connected DNSServiceRef initialized by - * DNSServiceCreateConnection(). - * - * RecordRef: The DNSRecordRef initialized by DNSServiceRegisterRecord(). If the above - * DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is - * invalidated, and may not be used further. - * - * flags: Currently unused, reserved for future use. - * - * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will - * indicate the failure that occurred (including name conflicts.) - * Other parameters are undefined if errorCode is nonzero. - * - * context: The context pointer that was passed to the callout. - * - */ - - typedef void (DNSSD_API *DNSServiceRegisterRecordReply) - ( - DNSServiceRef sdRef, - DNSRecordRef RecordRef, - DNSServiceFlags flags, - DNSServiceErrorType errorCode, - void *context - ); - - -/* DNSServiceRegisterRecord() Parameters: - * - * sdRef: A DNSServiceRef initialized by DNSServiceCreateConnection(). - * - * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this - * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). - * (To deregister ALL records registered on a single connected DNSServiceRef - * and deallocate each of their corresponding DNSServiceRecordRefs, call - * DNSServiceRefDealloocate()). - * - * flags: Possible values are kDNSServiceFlagsShared or kDNSServiceFlagsUnique - * (see flag type definitions for details). - * - * interfaceIndex: If non-zero, specifies the interface on which to register the record - * (the index for a given interface is determined via the if_nametoindex() - * family of calls.) Passing 0 causes the record to be registered on all interfaces. - * See "Constants for specifying an interface index" for more details. - * - * fullname: The full domain name of the resource record. - * - * rrtype: The numerical type of the resource record (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) - * - * rrclass: The class of the resource record (usually kDNSServiceClass_IN) - * - * rdlen: Length, in bytes, of the rdata. - * - * rdata: A pointer to the raw rdata, as it is to appear in the DNS record. - * - * ttl: The time to live of the resource record, in seconds. Pass 0 to use a default value. - * - * callBack: The function to be called when a result is found, or if the call - * asynchronously fails (e.g. because of a name conflict.) - * - * context: An application context pointer which is passed to the callback function - * (may be NULL). - * - * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous - * errors are delivered to the callback), otherwise returns an error code indicating - * the error that occurred (the callback is never invoked and the DNSRecordRef is - * not initialized.) - */ - -DNSServiceErrorType DNSSD_API DNSServiceRegisterRecord - ( - DNSServiceRef sdRef, - DNSRecordRef *RecordRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - const char *fullname, - uint16_t rrtype, - uint16_t rrclass, - uint16_t rdlen, - const void *rdata, - uint32_t ttl, - DNSServiceRegisterRecordReply callBack, - void *context /* may be NULL */ - ); - - -/* DNSServiceQueryRecord - * - * Query for an arbitrary DNS record. - * - * - * DNSServiceQueryRecordReply() Callback Parameters: - * - * sdRef: The DNSServiceRef initialized by DNSServiceQueryRecord(). - * - * flags: Possible values are kDNSServiceFlagsMoreComing and - * kDNSServiceFlagsAdd. The Add flag is NOT set for PTR records - * with a ttl of 0, i.e. "Remove" events. - * - * interfaceIndex: The interface on which the query was resolved (the index for a given - * interface is determined via the if_nametoindex() family of calls). - * See "Constants for specifying an interface index" for more details. - * - * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will - * indicate the failure that occurred. Other parameters are undefined if - * errorCode is nonzero. - * - * fullname: The resource record's full domain name. - * - * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) - * - * rrclass: The class of the resource record (usually kDNSServiceClass_IN). - * - * rdlen: The length, in bytes, of the resource record rdata. - * - * rdata: The raw rdata of the resource record. - * - * ttl: The resource record's time to live, in seconds. - * - * context: The context pointer that was passed to the callout. - * - */ - -typedef void (DNSSD_API *DNSServiceQueryRecordReply) - ( - DNSServiceRef DNSServiceRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *fullname, - uint16_t rrtype, - uint16_t rrclass, - uint16_t rdlen, - const void *rdata, - uint32_t ttl, - void *context - ); - - -/* DNSServiceQueryRecord() Parameters: - * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds - * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, - * and the query operation will run indefinitely until the client - * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). - * - * flags: Pass kDNSServiceFlagsLongLivedQuery to create a "long-lived" unicast - * query in a non-local domain. Without setting this flag, unicast queries - * will be one-shot - that is, only answers available at the time of the call - * will be returned. By setting this flag, answers (including Add and Remove - * events) that become available after the initial call is made will generate - * callbacks. This flag has no effect on link-local multicast queries. - * - * interfaceIndex: If non-zero, specifies the interface on which to issue the query - * (the index for a given interface is determined via the if_nametoindex() - * family of calls.) Passing 0 causes the name to be queried for on all - * interfaces. See "Constants for specifying an interface index" for more details. - * - * fullname: The full domain name of the resource record to be queried for. - * - * rrtype: The numerical type of the resource record to be queried for - * (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) - * - * rrclass: The class of the resource record (usually kDNSServiceClass_IN). - * - * callBack: The function to be called when a result is found, or if the call - * asynchronously fails. - * - * context: An application context pointer which is passed to the callback function - * (may be NULL). - * - * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous - * errors are delivered to the callback), otherwise returns an error code indicating - * the error that occurred (the callback is never invoked and the DNSServiceRef - * is not initialized.) - */ - -DNSServiceErrorType DNSSD_API DNSServiceQueryRecord - ( - DNSServiceRef *sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - const char *fullname, - uint16_t rrtype, - uint16_t rrclass, - DNSServiceQueryRecordReply callBack, - void *context /* may be NULL */ - ); - - -/* DNSServiceReconfirmRecord - * - * Instruct the daemon to verify the validity of a resource record that appears to - * be out of date (e.g. because tcp connection to a service's target failed.) - * Causes the record to be flushed from the daemon's cache (as well as all other - * daemons' caches on the network) if the record is determined to be invalid. - * - * Parameters: - * - * flags: Currently unused, reserved for future use. - * - * interfaceIndex: If non-zero, specifies the interface of the record in question. - * Passing 0 causes all instances of this record to be reconfirmed. - * - * fullname: The resource record's full domain name. - * - * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc) - * - * rrclass: The class of the resource record (usually kDNSServiceClass_IN). - * - * rdlen: The length, in bytes, of the resource record rdata. - * - * rdata: The raw rdata of the resource record. - * - */ - -DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord - ( - DNSServiceFlags flags, - uint32_t interfaceIndex, - const char *fullname, - uint16_t rrtype, - uint16_t rrclass, - uint16_t rdlen, - const void *rdata - ); - - -/********************************************************************************************* - * - * General Utility Functions - * - *********************************************************************************************/ - -/* DNSServiceConstructFullName() - * - * Concatenate a three-part domain name (as returned by the above callbacks) into a - * properly-escaped full domain name. Note that callbacks in the above functions ALREADY ESCAPE - * strings where necessary. - * - * Parameters: - * - * fullName: A pointer to a buffer that where the resulting full domain name is to be written. - * The buffer must be kDNSServiceMaxDomainName (1005) bytes in length to - * accommodate the longest legal domain name without buffer overrun. - * - * service: The service name - any dots or backslashes must NOT be escaped. - * May be NULL (to construct a PTR record name, e.g. - * "_ftp._tcp.apple.com."). - * - * regtype: The service type followed by the protocol, separated by a dot - * (e.g. "_ftp._tcp"). - * - * domain: The domain name, e.g. "apple.com.". Literal dots or backslashes, - * if any, must be escaped, e.g. "1st\. Floor.apple.com." - * - * return value: Returns 0 on success, -1 on error. - * - */ - -int DNSSD_API DNSServiceConstructFullName - ( - char *fullName, - const char *service, /* may be NULL */ - const char *regtype, - const char *domain - ); - - -/********************************************************************************************* - * - * TXT Record Construction Functions - * - *********************************************************************************************/ - -/* - * A typical calling sequence for TXT record construction is something like: - * - * Client allocates storage for TXTRecord data (e.g. declare buffer on the stack) - * TXTRecordCreate(); - * TXTRecordSetValue(); - * TXTRecordSetValue(); - * TXTRecordSetValue(); - * ... - * DNSServiceRegister( ... TXTRecordGetLength(), TXTRecordGetBytesPtr() ... ); - * TXTRecordDeallocate(); - * Explicitly deallocate storage for TXTRecord data (if not allocated on the stack) - */ - - -/* TXTRecordRef - * - * Opaque internal data type. - * Note: Represents a DNS-SD TXT record. - */ - -typedef union _TXTRecordRef_t { char PrivateData[16]; char *ForceNaturalAlignment; } TXTRecordRef; - - -/* TXTRecordCreate() - * - * Creates a new empty TXTRecordRef referencing the specified storage. - * - * If the buffer parameter is NULL, or the specified storage size is not - * large enough to hold a key subsequently added using TXTRecordSetValue(), - * then additional memory will be added as needed using malloc(). - * - * On some platforms, when memory is low, malloc() may fail. In this - * case, TXTRecordSetValue() will return kDNSServiceErr_NoMemory, and this - * error condition will need to be handled as appropriate by the caller. - * - * You can avoid the need to handle this error condition if you ensure - * that the storage you initially provide is large enough to hold all - * the key/value pairs that are to be added to the record. - * The caller can precompute the exact length required for all of the - * key/value pairs to be added, or simply provide a fixed-sized buffer - * known in advance to be large enough. - * A no-value (key-only) key requires (1 + key length) bytes. - * A key with empty value requires (1 + key length + 1) bytes. - * A key with non-empty value requires (1 + key length + 1 + value length). - * For most applications, DNS-SD TXT records are generally - * less than 100 bytes, so in most cases a simple fixed-sized - * 256-byte buffer will be more than sufficient. - * Recommended size limits for DNS-SD TXT Records are discussed in - * - * - * Note: When passing parameters to and from these TXT record APIs, - * the key name does not include the '=' character. The '=' character - * is the separator between the key and value in the on-the-wire - * packet format; it is not part of either the key or the value. - * - * txtRecord: A pointer to an uninitialized TXTRecordRef. - * - * bufferLen: The size of the storage provided in the "buffer" parameter. - * - * buffer: Optional caller-supplied storage used to hold the TXTRecord data. - * This storage must remain valid for as long as - * the TXTRecordRef. - */ - -void DNSSD_API TXTRecordCreate - ( - TXTRecordRef *txtRecord, - uint16_t bufferLen, - void *buffer - ); - - -/* TXTRecordDeallocate() - * - * Releases any resources allocated in the course of preparing a TXT Record - * using TXTRecordCreate()/TXTRecordSetValue()/TXTRecordRemoveValue(). - * Ownership of the buffer provided in TXTRecordCreate() returns to the client. - * - * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). - * - */ - -void DNSSD_API TXTRecordDeallocate - ( - TXTRecordRef *txtRecord - ); - - -/* TXTRecordSetValue() - * - * Adds a key (optionally with value) to a TXTRecordRef. If the "key" already - * exists in the TXTRecordRef, then the current value will be replaced with - * the new value. - * Keys may exist in four states with respect to a given TXT record: - * - Absent (key does not appear at all) - * - Present with no value ("key" appears alone) - * - Present with empty value ("key=" appears in TXT record) - * - Present with non-empty value ("key=value" appears in TXT record) - * For more details refer to "Data Syntax for DNS-SD TXT Records" in - * - * - * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). - * - * key: A null-terminated string which only contains printable ASCII - * values (0x20-0x7E), excluding '=' (0x3D). Keys should be - * 8 characters or less (not counting the terminating null). - * - * valueSize: The size of the value. - * - * value: Any binary value. For values that represent - * textual data, UTF-8 is STRONGLY recommended. - * For values that represent textual data, valueSize - * should NOT include the terminating null (if any) - * at the end of the string. - * If NULL, then "key" will be added with no value. - * If non-NULL but valueSize is zero, then "key=" will be - * added with empty value. - * - * return value: Returns kDNSServiceErr_NoError on success. - * Returns kDNSServiceErr_Invalid if the "key" string contains - * illegal characters. - * Returns kDNSServiceErr_NoMemory if adding this key would - * exceed the available storage. - */ - -DNSServiceErrorType DNSSD_API TXTRecordSetValue - ( - TXTRecordRef *txtRecord, - const char *key, - uint8_t valueSize, /* may be zero */ - const void *value /* may be NULL */ - ); - - -/* TXTRecordRemoveValue() - * - * Removes a key from a TXTRecordRef. The "key" must be an - * ASCII string which exists in the TXTRecordRef. - * - * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). - * - * key: A key name which exists in the TXTRecordRef. - * - * return value: Returns kDNSServiceErr_NoError on success. - * Returns kDNSServiceErr_NoSuchKey if the "key" does not - * exist in the TXTRecordRef. - */ - -DNSServiceErrorType DNSSD_API TXTRecordRemoveValue - ( - TXTRecordRef *txtRecord, - const char *key - ); - - -/* TXTRecordGetLength() - * - * Allows you to determine the length of the raw bytes within a TXTRecordRef. - * - * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). - * - * return value: Returns the size of the raw bytes inside a TXTRecordRef - * which you can pass directly to DNSServiceRegister() or - * to DNSServiceUpdateRecord(). - * Returns 0 if the TXTRecordRef is empty. - */ - -uint16_t DNSSD_API TXTRecordGetLength - ( - const TXTRecordRef *txtRecord - ); - - -/* TXTRecordGetBytesPtr() - * - * Allows you to retrieve a pointer to the raw bytes within a TXTRecordRef. - * - * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate(). - * - * return value: Returns a pointer to the raw bytes inside the TXTRecordRef - * which you can pass directly to DNSServiceRegister() or - * to DNSServiceUpdateRecord(). - */ - -const void * DNSSD_API TXTRecordGetBytesPtr - ( - const TXTRecordRef *txtRecord - ); - - -/********************************************************************************************* - * - * TXT Record Parsing Functions - * - *********************************************************************************************/ - -/* - * A typical calling sequence for TXT record parsing is something like: - * - * Receive TXT record data in DNSServiceResolve() callback - * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something - * val1ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key1", &len1); - * val2ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key2", &len2); - * ... - * bcopy(val1ptr, myval1, len1); - * bcopy(val2ptr, myval2, len2); - * ... - * return; - * - * If you wish to retain the values after return from the DNSServiceResolve() - * callback, then you need to copy the data to your own storage using bcopy() - * or similar, as shown in the example above. - * - * If for some reason you need to parse a TXT record you built yourself - * using the TXT record construction functions above, then you can do - * that using TXTRecordGetLength and TXTRecordGetBytesPtr calls: - * TXTRecordGetValue(TXTRecordGetLength(x), TXTRecordGetBytesPtr(x), key, &len); - * - * Most applications only fetch keys they know about from a TXT record and - * ignore the rest. - * However, some debugging tools wish to fetch and display all keys. - * To do that, use the TXTRecordGetCount() and TXTRecordGetItemAtIndex() calls. - */ - -/* TXTRecordContainsKey() - * - * Allows you to determine if a given TXT Record contains a specified key. - * - * txtLen: The size of the received TXT Record. - * - * txtRecord: Pointer to the received TXT Record bytes. - * - * key: A null-terminated ASCII string containing the key name. - * - * return value: Returns 1 if the TXT Record contains the specified key. - * Otherwise, it returns 0. - */ - -int DNSSD_API TXTRecordContainsKey - ( - uint16_t txtLen, - const void *txtRecord, - const char *key - ); - - -/* TXTRecordGetValuePtr() - * - * Allows you to retrieve the value for a given key from a TXT Record. - * - * txtLen: The size of the received TXT Record - * - * txtRecord: Pointer to the received TXT Record bytes. - * - * key: A null-terminated ASCII string containing the key name. - * - * valueLen: On output, will be set to the size of the "value" data. - * - * return value: Returns NULL if the key does not exist in this TXT record, - * or exists with no value (to differentiate between - * these two cases use TXTRecordContainsKey()). - * Returns pointer to location within TXT Record bytes - * if the key exists with empty or non-empty value. - * For empty value, valueLen will be zero. - * For non-empty value, valueLen will be length of value data. - */ - -const void * DNSSD_API TXTRecordGetValuePtr - ( - uint16_t txtLen, - const void *txtRecord, - const char *key, - uint8_t *valueLen - ); - - -/* TXTRecordGetCount() - * - * Returns the number of keys stored in the TXT Record. The count - * can be used with TXTRecordGetItemAtIndex() to iterate through the keys. - * - * txtLen: The size of the received TXT Record. - * - * txtRecord: Pointer to the received TXT Record bytes. - * - * return value: Returns the total number of keys in the TXT Record. - * - */ - -uint16_t DNSSD_API TXTRecordGetCount - ( - uint16_t txtLen, - const void *txtRecord - ); - - -/* TXTRecordGetItemAtIndex() - * - * Allows you to retrieve a key name and value pointer, given an index into - * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1. - * It's also possible to iterate through keys in a TXT record by simply - * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero - * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid. - * - * On return: - * For keys with no value, *value is set to NULL and *valueLen is zero. - * For keys with empty value, *value is non-NULL and *valueLen is zero. - * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero. - * - * txtLen: The size of the received TXT Record. - * - * txtRecord: Pointer to the received TXT Record bytes. - * - * index: An index into the TXT Record. - * - * keyBufLen: The size of the string buffer being supplied. - * - * key: A string buffer used to store the key name. - * On return, the buffer contains a null-terminated C string - * giving the key name. DNS-SD TXT keys are usually - * 8 characters or less. To hold the maximum possible - * key name, the buffer should be 256 bytes long. - * - * valueLen: On output, will be set to the size of the "value" data. - * - * value: On output, *value is set to point to location within TXT - * Record bytes that holds the value data. - * - * return value: Returns kDNSServiceErr_NoError on success. - * Returns kDNSServiceErr_NoMemory if keyBufLen is too short. - * Returns kDNSServiceErr_Invalid if index is greater than - * TXTRecordGetCount()-1. - */ - -DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex - ( - uint16_t txtLen, - const void *txtRecord, - uint16_t index, - uint16_t keyBufLen, - char *key, - uint8_t *valueLen, - const void **value - ); - -#ifdef __APPLE_API_PRIVATE - -/* - * Mac OS X specific functionality - * 3rd party clients of this API should not depend on future support or availability of this routine - */ - -/* DNSServiceSetDefaultDomainForUser() - * - * Set the default domain for the caller's UID. Future browse and registration - * calls by this user that do not specify an explicit domain will browse and - * register in this wide-area domain in addition to .local. In addition, this - * domain will be returned as a Browse domain via domain enumeration calls. - * - * - * Parameters: - * - * flags: Pass kDNSServiceFlagsAdd to add a domain for a user. Call without - * this flag set to clear a previously added domain. - * - * domain: The domain to be used for the caller's UID. - * - * return value: Returns kDNSServiceErr_NoError on succeses, otherwise returns - * an error code indicating the error that occurred - */ - -DNSServiceErrorType DNSSD_API DNSServiceSetDefaultDomainForUser - ( - DNSServiceFlags flags, - const char *domain - ); - -#endif //__APPLE_API_PRIVATE - -// Some C compiler cleverness. We can make the compiler check certain things for us, -// and report errors at compile-time if anything is wrong. The usual way to do this would -// be to use a run-time "if" statement or the conventional run-time "assert" mechanism, but -// then you don't find out what's wrong until you run the software. This way, if the assertion -// condition is false, the array size is negative, and the complier complains immediately. - -struct DNS_SD_CompileTimeAssertionChecks - { - char assert0[(sizeof(union _TXTRecordRef_t) == 16) ? 1 : -1]; - }; - -#ifdef __cplusplus - } -#endif - -#endif /* _DNS_SD_H */ diff --git a/avahi-compat-libdns_sd/funcs.txt b/avahi-compat-libdns_sd/funcs.txt deleted file mode 100644 index bf96aa5..0000000 --- a/avahi-compat-libdns_sd/funcs.txt +++ /dev/null @@ -1,35 +0,0 @@ --- Supported -- - -DNSServiceRefSockFD -DNSServiceProcessResult -DNSServiceRefDeallocate -DNSServiceEnumerateDomains -DNSServiceRegister -DNSServiceBrowse -DNSServiceResolve -DNSServiceConstructFullName - -TXTRecordCreate -TXTRecordDeallocate -TXTRecordSetValue -TXTRecordRemoveValue -TXTRecordGetLength -TXTRecordGetBytesPtr -TXTRecordContainsKey -TXTRecordGetValuePtr -TXTRecordGetCount -TXTRecordGetItemAtIndex - --- Unsupported but Relevant -- - -DNSServiceRegisterRecord -DNSServiceQueryRecord -DNSServiceReconfirmRecord -DNSServiceCreateConnection -DNSServiceAddRecord -DNSServiceUpdateRecord -DNSServiceRemoveRecord - --- Unsupported and Irrelevant -- - -DNSServiceSetDefaultDomainForUser diff --git a/avahi-compat-libdns_sd/null-test.c b/avahi-compat-libdns_sd/null-test.c deleted file mode 100644 index 8cfb98f..0000000 --- a/avahi-compat-libdns_sd/null-test.c +++ /dev/null @@ -1,71 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include - -static void reply( - AVAHI_GCC_UNUSED DNSServiceRef sdRef, - AVAHI_GCC_UNUSED DNSServiceFlags flags, - AVAHI_GCC_UNUSED uint32_t interfaceIndex, - AVAHI_GCC_UNUSED DNSServiceErrorType errorCode, - AVAHI_GCC_UNUSED const char *serviceName, - AVAHI_GCC_UNUSED const char *regtype, - AVAHI_GCC_UNUSED const char *replyDomain, - AVAHI_GCC_UNUSED void *context) { -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { - - DNSServiceRef ref1, ref2, ref3, ref4 = NULL; - - DNSServiceRegister(&ref1, 0, 0, "simple", "_simple._tcp", NULL, NULL, 4711, 0, NULL, NULL, NULL); - DNSServiceRegister(&ref2, 0, 0, "subtype #1", "_simple._tcp,_subtype1", NULL, NULL, 4711, 0, NULL, NULL, NULL); - DNSServiceRegister(&ref3, 0, 0, "subtype #2", "_simple._tcp,_subtype1,_subtype2", NULL, NULL, 4711, 0, NULL, NULL, NULL); - - DNSServiceRegister(&ref4, 0, 0, "subtype #3", "_simple._tcp,,", NULL, NULL, 4711, 0, NULL, NULL, NULL); - assert(!ref4); - DNSServiceRegister(&ref4, 0, 0, "subtype #3", "", NULL, NULL, 4711, 0, NULL, NULL, NULL); - assert(!ref4); - DNSServiceRegister(&ref4, 0, 0, "subtype #3", ",", NULL, NULL, 4711, 0, NULL, NULL, NULL); - assert(!ref4); - DNSServiceRegister(&ref4, 0, 0, "subtype #3", ",,", NULL, NULL, 4711, 0, NULL, NULL, NULL); - assert(!ref4); - - DNSServiceBrowse(&ref4, 0, 0, "_simple._tcp,_gurke", NULL, reply, NULL); - - sleep(20); - - DNSServiceRefDeallocate(ref1); - DNSServiceRefDeallocate(ref2); - DNSServiceRefDeallocate(ref3); - DNSServiceRefDeallocate(ref4); - - return 0; -} diff --git a/avahi-compat-libdns_sd/txt-test.c b/avahi-compat-libdns_sd/txt-test.c deleted file mode 100644 index 9bf29b4..0000000 --- a/avahi-compat-libdns_sd/txt-test.c +++ /dev/null @@ -1,128 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include - -static void hexdump(const void* p, size_t size) { - const uint8_t *c = p; - assert(p); - - printf("Dumping %zu bytes from %p:\n", size, p); - - while (size > 0) { - unsigned i; - - for (i = 0; i < 16; i++) { - if (i < size) - printf("%02x ", c[i]); - else - printf(" "); - } - - for (i = 0; i < 16; i++) { - if (i < size) - printf("%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.'); - else - printf(" "); - } - - printf("\n"); - - c += 16; - - if (size <= 16) - break; - - size -= 16; - } -} - - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - const char *r; - TXTRecordRef ref; - uint8_t l; - const void *p; - char k[256]; - - TXTRecordCreate(&ref, 0, NULL); - - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "foo", 7, "lennart"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "waldo", 5, "rocks"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "quux", 9, "the_house"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "yeah", 0, NULL); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "waldo", 6, "rocked"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordRemoveValue(&ref, "foo"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordRemoveValue(&ref, "waldo"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "kawumm", 6, "bloerb"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "one", 1, "1"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "two", 1, "2"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - TXTRecordSetValue(&ref, "three", 1, "3"); - hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref)); - - assert(TXTRecordContainsKey(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "two")); - assert(!TXTRecordContainsKey(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "four")); - - r = TXTRecordGetValuePtr(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "kawumm", &l); - - hexdump(r, l); - - assert(TXTRecordGetCount(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref)) == 6); - - TXTRecordGetItemAtIndex(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), 2, sizeof(k), k, &l, &p); - - fprintf(stderr, "key=<%s>\n", k); - - hexdump(p, l); - - assert(TXTRecordGetItemAtIndex(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), 20, sizeof(k), k, &l, &p) == kDNSServiceErr_Invalid); - - TXTRecordDeallocate(&ref); -} diff --git a/avahi-compat-libdns_sd/txt.c b/avahi-compat-libdns_sd/txt.c deleted file mode 100644 index 9d6c116..0000000 --- a/avahi-compat-libdns_sd/txt.c +++ /dev/null @@ -1,489 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include - -#include "dns_sd.h" -#include "warn.h" - -typedef struct TXTRecordInternal { - uint8_t *buffer, *malloc_buffer; - size_t size, max_size; -} TXTRecordInternal; - -#define INTERNAL_PTR(txtref) (* (TXTRecordInternal**) (txtref)) -#define INTERNAL_PTR_CONST(txtref) (* (const TXTRecordInternal* const *) (txtref)) - -void DNSSD_API TXTRecordCreate( - TXTRecordRef *txtref, - uint16_t length, - void *buffer) { - - TXTRecordInternal *t; - - AVAHI_WARN_LINKAGE; - - assert(txtref); - - /* Apple's API design is flawed in so many ways, including the - * fact that it isn't compatible with 64 bit processors. To work - * around this we need some magic here which involves allocating - * our own memory. Please, Apple, do your homework next time - * before designing an API! */ - - if ((t = avahi_new(TXTRecordInternal, 1))) { - t->buffer = buffer; - t->max_size = buffer ? length : (size_t)0; - t->size = 0; - t->malloc_buffer = NULL; - } - - /* If we were unable to allocate memory, we store a NULL pointer - * and return a NoMemory error later, is somewhat unclean, but - * should work. */ - INTERNAL_PTR(txtref) = t; -} - -void DNSSD_API TXTRecordDeallocate(TXTRecordRef *txtref) { - TXTRecordInternal *t; - - AVAHI_WARN_LINKAGE; - - assert(txtref); - t = INTERNAL_PTR(txtref); - if (!t) - return; - - avahi_free(t->malloc_buffer); - avahi_free(t); - - /* Just in case ... */ - INTERNAL_PTR(txtref) = NULL; -} - -static int make_sure_fits_in(TXTRecordInternal *t, size_t size) { - uint8_t *n; - size_t nsize; - - assert(t); - - if (t->size + size <= t->max_size) - return 0; - - nsize = t->size + size + 100; - - if (nsize > 0xFFFF) - return -1; - - if (!(n = avahi_realloc(t->malloc_buffer, nsize))) - return -1; - - if (!t->malloc_buffer && t->size) - memcpy(n, t->buffer, t->size); - - t->buffer = t->malloc_buffer = n; - t->max_size = nsize; - - return 0; -} - -static int remove_key(TXTRecordInternal *t, const char *key) { - size_t i; - uint8_t *p; - size_t key_len; - int found = 0; - - key_len = strlen(key); - assert(key_len <= 0xFF); - - p = t->buffer; - i = 0; - - while (i < t->size) { - - /* Does the item fit in? */ - assert(*p <= t->size - i - 1); - - /* Key longer than buffer */ - if (key_len > t->size - i - 1) - break; - - if (key_len <= *p && - strncmp(key, (char*) p+1, key_len) == 0 && - (key_len == *p || p[1+key_len] == '=')) { - - uint8_t s; - - /* Key matches, so let's remove it */ - - s = *p; - memmove(p, p + 1 + *p, t->size - i - *p -1); - t->size -= s + 1; - - found = 1; - } else { - /* Skip to next */ - - i += *p +1; - p += *p +1; - } - } - - return found; -} - -DNSServiceErrorType DNSSD_API TXTRecordSetValue( - TXTRecordRef *txtref, - const char *key, - uint8_t length, - const void *value) { - - TXTRecordInternal *t; - uint8_t *p; - size_t l, n; - - AVAHI_WARN_LINKAGE; - - assert(key); - assert(txtref); - - l = strlen(key); - - if (*key == 0 || strchr(key, '=') || l > 0xFF) /* Empty or invalid key */ - return kDNSServiceErr_Invalid; - - if (!(t = INTERNAL_PTR(txtref))) - return kDNSServiceErr_NoMemory; - - n = l + (value ? length + 1 : 0); - - if (n > 0xFF) - return kDNSServiceErr_Invalid; - - if (make_sure_fits_in(t, 1 + n) < 0) - return kDNSServiceErr_NoMemory; - - remove_key(t, key); - - p = t->buffer + t->size; - - *(p++) = (uint8_t) n; - t->size ++; - - memcpy(p, key, l); - p += l; - t->size += l; - - if (value) { - *(p++) = '='; - memcpy(p, value, length); - t->size += length + 1; - } - - assert(t->size <= t->max_size); - - return kDNSServiceErr_NoError; -} - -DNSServiceErrorType DNSSD_API TXTRecordRemoveValue(TXTRecordRef *txtref, const char *key) { - TXTRecordInternal *t; - int found; - - AVAHI_WARN_LINKAGE; - - assert(key); - assert(txtref); - - if (*key == 0 || strchr(key, '=') || strlen(key) > 0xFF) /* Empty or invalid key */ - return kDNSServiceErr_Invalid; - - if (!(t = INTERNAL_PTR(txtref))) - return kDNSServiceErr_NoError; - - found = remove_key(t, key); - - return found ? kDNSServiceErr_NoError : kDNSServiceErr_NoSuchKey; -} - -uint16_t DNSSD_API TXTRecordGetLength(const TXTRecordRef *txtref) { - const TXTRecordInternal *t; - - AVAHI_WARN_LINKAGE; - - assert(txtref); - - if (!(t = INTERNAL_PTR_CONST(txtref))) - return 0; - - assert(t->size <= 0xFFFF); - return (uint16_t) t->size; -} - -const void * DNSSD_API TXTRecordGetBytesPtr(const TXTRecordRef *txtref) { - const TXTRecordInternal *t; - - AVAHI_WARN_LINKAGE; - - assert(txtref); - - if (!(t = INTERNAL_PTR_CONST(txtref)) || !t->buffer) - return ""; - - return t->buffer; -} - -static const uint8_t *find_key(const uint8_t *buffer, size_t size, const char *key) { - size_t i; - const uint8_t *p; - size_t key_len; - - key_len = strlen(key); - - assert(key_len <= 0xFF); - - p = buffer; - i = 0; - - while (i < size) { - - /* Does the item fit in? */ - if (*p > size - i - 1) - return NULL; - - /* Key longer than buffer */ - if (key_len > size - i - 1) - return NULL; - - if (key_len <= *p && - strncmp(key, (const char*) p+1, key_len) == 0 && - (key_len == *p || p[1+key_len] == '=')) { - - /* Key matches, so let's return it */ - - return p; - } - - /* Skip to next */ - i += *p +1; - p += *p +1; - } - - return NULL; -} - -int DNSSD_API TXTRecordContainsKey ( - uint16_t size, - const void *buffer, - const char *key) { - - AVAHI_WARN_LINKAGE; - - assert(key); - - if (!size) - return 0; - - assert(buffer); - - if (!(find_key(buffer, size, key))) - return 0; - - return 1; -} - -const void * DNSSD_API TXTRecordGetValuePtr( - uint16_t size, - const void *buffer, - const char *key, - uint8_t *value_len) { - - const uint8_t *p; - size_t n, l; - - AVAHI_WARN_LINKAGE; - - assert(key); - - if (!size) - goto fail; - - if (*key == 0 || strchr(key, '=') || strlen(key) > 0xFF) /* Empty or invalid key */ - return NULL; - - assert(buffer); - - if (!(p = find_key(buffer, size, key))) - goto fail; - - n = *p; - l = strlen(key); - - assert(n >= l); - p += 1 + l; - n -= l; - - if (n <= 0) - goto fail; - - assert(*p == '='); - p++; - n--; - - if (value_len) - *value_len = n; - - return p; - -fail: - if (value_len) - *value_len = 0; - - return NULL; -} - - -uint16_t DNSSD_API TXTRecordGetCount( - uint16_t size, - const void *buffer) { - - const uint8_t *p; - unsigned n = 0; - size_t i; - - AVAHI_WARN_LINKAGE; - - if (!size) - return 0; - - assert(buffer); - - p = buffer; - i = 0; - - while (i < size) { - - /* Does the item fit in? */ - if (*p > size - i - 1) - break; - - n++; - - /* Skip to next */ - i += *p +1; - p += *p +1; - } - - assert(n <= 0xFFFF); - - return (uint16_t) n; -} - -DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex( - uint16_t size, - const void *buffer, - uint16_t idx, - uint16_t key_len, - char *key, - uint8_t *value_len, - const void **value) { - - const uint8_t *p; - size_t i; - unsigned n = 0; - DNSServiceErrorType ret = kDNSServiceErr_Invalid; - - AVAHI_WARN_LINKAGE; - - if (!size) - goto fail; - - assert(buffer); - - p = buffer; - i = 0; - - while (i < size) { - - /* Does the item fit in? */ - if (*p > size - i - 1) - goto fail; - - if (n >= idx) { - size_t l; - const uint8_t *d; - - d = memchr(p+1, '=', *p); - - /* Length of key */ - l = d ? d - p - 1 : *p; - - if (key_len < l+1) { - ret = kDNSServiceErr_NoMemory; - goto fail; - } - - strncpy(key, (const char*) p + 1, l); - key[l] = 0; - - if (d) { - if (value_len) - *value_len = *p - l - 1; - - if (value) - *value = d + 1; - } else { - - if (value_len) - *value_len = 0; - - if (value) - *value = NULL; - } - - return kDNSServiceErr_NoError; - } - - n++; - - /* Skip to next */ - i += *p +1; - p += *p +1; - } - - -fail: - - if (value) - *value = NULL; - - if (value_len) - *value_len = 0; - - return ret; - -} diff --git a/avahi-compat-libdns_sd/unsupported.c b/avahi-compat-libdns_sd/unsupported.c deleted file mode 100644 index 4e94f70..0000000 --- a/avahi-compat-libdns_sd/unsupported.c +++ /dev/null @@ -1,90 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "dns_sd.h" -#include "warn.h" - -DNSServiceErrorType DNSSD_API DNSServiceRegisterRecord ( - AVAHI_GCC_UNUSED DNSServiceRef sdRef, - AVAHI_GCC_UNUSED DNSRecordRef *RecordRef, - AVAHI_GCC_UNUSED DNSServiceFlags flags, - AVAHI_GCC_UNUSED uint32_t interfaceIndex, - AVAHI_GCC_UNUSED const char *fullname, - AVAHI_GCC_UNUSED uint16_t rrtype, - AVAHI_GCC_UNUSED uint16_t rrclass, - AVAHI_GCC_UNUSED uint16_t rdlen, - AVAHI_GCC_UNUSED const void *rdata, - AVAHI_GCC_UNUSED uint32_t ttl, - AVAHI_GCC_UNUSED DNSServiceRegisterRecordReply callBack, - AVAHI_GCC_UNUSED void *context) { - - AVAHI_WARN_UNSUPPORTED; - - return kDNSServiceErr_Unsupported; -} - -DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord ( - AVAHI_GCC_UNUSED DNSServiceFlags flags, - AVAHI_GCC_UNUSED uint32_t interfaceIndex, - AVAHI_GCC_UNUSED const char *fullname, - AVAHI_GCC_UNUSED uint16_t rrtype, - AVAHI_GCC_UNUSED uint16_t rrclass, - AVAHI_GCC_UNUSED uint16_t rdlen, - AVAHI_GCC_UNUSED const void *rdata) { - - AVAHI_WARN_UNSUPPORTED; - - return kDNSServiceErr_Unsupported; -} - -DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(AVAHI_GCC_UNUSED DNSServiceRef *sdRef) { - AVAHI_WARN_UNSUPPORTED; - - return kDNSServiceErr_Unsupported; -} - -DNSServiceErrorType DNSSD_API DNSServiceAddRecord( - AVAHI_GCC_UNUSED DNSServiceRef sdRef, - AVAHI_GCC_UNUSED DNSRecordRef *RecordRef, - AVAHI_GCC_UNUSED DNSServiceFlags flags, - AVAHI_GCC_UNUSED uint16_t rrtype, - AVAHI_GCC_UNUSED uint16_t rdlen, - AVAHI_GCC_UNUSED const void *rdata, - AVAHI_GCC_UNUSED uint32_t ttl) { - - AVAHI_WARN_UNSUPPORTED; - - return kDNSServiceErr_Unsupported; -} - -DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord( - AVAHI_GCC_UNUSED DNSServiceRef sdRef, - AVAHI_GCC_UNUSED DNSRecordRef RecordRef, - AVAHI_GCC_UNUSED DNSServiceFlags flags) { - - AVAHI_WARN_UNSUPPORTED; - - return kDNSServiceErr_Unsupported; -} diff --git a/avahi-compat-libdns_sd/warn.c b/avahi-compat-libdns_sd/warn.c deleted file mode 100644 index b311736..0000000 --- a/avahi-compat-libdns_sd/warn.c +++ /dev/null @@ -1,124 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "warn.h" - -#ifndef COMPAT_LAYER -#define COMPAT_LAYER "Apple Bonjour" -#endif - -#ifndef CGI_SUBSYSTEM -#define CGI_SUBSYSTEM "libdns_sd" -#endif - -static pthread_mutex_t linkage_mutex = PTHREAD_MUTEX_INITIALIZER; -static int linkage_warning = 0; - -const char *avahi_exe_name(void) { -#ifdef HAVE_GETPROGNAME - return getprogname(); -#elif defined(__linux__) - static char exe_name[1024] = ""; - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - - /* Yes, I know, this is not portable. But who cares? It's for - * cosmetics only, anyway. */ - - pthread_mutex_lock(&mutex); - - if (exe_name[0] == 0) { - int k; - - if ((k = readlink("/proc/self/exe", exe_name, sizeof(exe_name)-1)) < 0) - snprintf(exe_name, sizeof(exe_name), "(unknown)"); - else { - char *slash; - - assert((size_t) k <= sizeof(exe_name)-1); - exe_name[k] = 0; - - if ((slash = strrchr(exe_name, '/'))) - memmove(exe_name, slash+1, strlen(slash)+1); - } - } - - pthread_mutex_unlock(&mutex); - - return exe_name; -#else -#ifdef __GNUC__ -#warning "avahi_exe_name() needs to be implemented for your operating system" -#endif - return "(unknown)"; -#endif -} - -void avahi_warn(const char *fmt, ...) { - char msg[512] = "*** WARNING *** "; - va_list ap; - size_t n; - - assert(fmt); - - va_start(ap, fmt); - n = strlen(msg); - vsnprintf(msg + n, sizeof(msg) - n, fmt, ap); - va_end(ap); - - fprintf(stderr, "%s\n", msg); - - openlog(avahi_exe_name(), LOG_PID, LOG_USER); - syslog(LOG_WARNING, "%s", msg); - closelog(); -} - -void avahi_warn_linkage(void) { - int w; - - pthread_mutex_lock(&linkage_mutex); - w = linkage_warning; - linkage_warning = 1; - pthread_mutex_unlock(&linkage_mutex); - - if (!w && !getenv("AVAHI_COMPAT_NOWARN")) { - avahi_warn("The program '%s' uses the "COMPAT_LAYER" compatibility layer of Avahi.", avahi_exe_name()); - avahi_warn("Please fix your application to use the native API of Avahi!"); - avahi_warn("For more information see ", avahi_exe_name()); - } -} - -void avahi_warn_unsupported(const char *function) { - avahi_warn("The program '%s' called '%s()' which is not supported (or only supported partially) in the "COMPAT_LAYER" compatibility layer of Avahi.", avahi_exe_name(), function); - avahi_warn("Please fix your application to use the native API of Avahi!"); - avahi_warn("For more information see ", avahi_exe_name(), function); -} diff --git a/avahi-compat-libdns_sd/warn.h b/avahi-compat-libdns_sd/warn.h deleted file mode 100644 index 0a8c2ba..0000000 --- a/avahi-compat-libdns_sd/warn.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef foowarnhfoo -#define foowarnhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -/* This routine works on Linux only, so don't rely on it */ -const char *avahi_exe_name(void); - -void avahi_warn_unsupported(const char *function); - -void avahi_warn_linkage(void); - -void avahi_warn(const char *fmt, ...); - -#define AVAHI_WARN_LINKAGE do { avahi_warn_linkage(); } while(0) -#define AVAHI_WARN_UNSUPPORTED do { avahi_warn_linkage(); avahi_warn_unsupported(__FUNCTION__); } while(0) -#define AVAHI_WARN_UNSUPPORTED_ABORT do { AVAHI_WARN_UNSUPPORTED; abort(); } while(0) - -#endif diff --git a/avahi-daemon/.gitignore b/avahi-daemon/.gitignore deleted file mode 100644 index f1a6f8d..0000000 --- a/avahi-daemon/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -avahi-daemon.service -avahi-daemon.socket -avahi-daemon -avahi-dbus.conf -ini-file-parser-test -*.o -*.lo -Makefile -Makefile.in -.deps -.libs diff --git a/avahi-daemon/Makefile.am b/avahi-daemon/Makefile.am deleted file mode 100644 index b6b5a77..0000000 --- a/avahi-daemon/Makefile.am +++ /dev/null @@ -1,176 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -if HAVE_LIBDAEMON -if HAVE_XML - -pkgsysconfdir=$(sysconfdir)/avahi -servicedir=$(pkgsysconfdir)/services -introspectiondir=$(datadir)/dbus-1/interfaces -dbussystemservicesdir=$(datadir)/dbus-1/system-services - -AM_CFLAGS+= \ - -DAVAHI_DAEMON_RUNTIME_DIR=\"$(avahi_runtime_dir)/avahi-daemon/\" \ - -DAVAHI_SOCKET=\"$(avahi_socket)\" \ - -DAVAHI_SERVICE_DIR=\"$(servicedir)\" \ - -DAVAHI_CONFIG_FILE=\"$(pkgsysconfdir)/avahi-daemon.conf\" \ - -DAVAHI_HOSTS_FILE=\"$(pkgsysconfdir)/hosts\" \ - -DAVAHI_DBUS_INTROSPECTION_DIR=\"$(introspectiondir)\" \ - -DAVAHI_CONFIG_DIR=\"$(pkgsysconfdir)\" - -sbin_PROGRAMS = \ - avahi-daemon - -if ENABLE_TESTS -noinst_PROGRAMS = \ - ini-file-parser-test -endif - -avahi_daemon_SOURCES = \ - main.c main.h \ - simple-protocol.c simple-protocol.h \ - static-services.c static-services.h \ - static-hosts.c static-hosts.h \ - ini-file-parser.c ini-file-parser.h \ - setproctitle.c setproctitle.h \ - sd-daemon.h sd-daemon.c \ - ../avahi-client/check-nss.c - -avahi_daemon_CFLAGS = $(AM_CFLAGS) $(LIBDAEMON_CFLAGS) $(XML_CFLAGS) -avahi_daemon_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-core/libavahi-core.la $(LIBDAEMON_LIBS) $(XML_LIBS) - -ini_file_parser_test_SOURCES = \ - ini-file-parser.c ini-file-parser.h \ - ini-file-parser-test.c - -ini_file_parser_test_CFLAGS = $(AM_CFLAGS) -ini_file_parser_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-core/libavahi-core.la - -pkgsysconf_DATA = \ - avahi-daemon.conf \ - hosts - -dist_service_DATA = \ - ssh.service \ - sftp-ssh.service - -dist_pkgdata_DATA = \ - avahi-service.dtd - -%.service: %.service.in - $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - -%.socket: %.socket.in - $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' \ - -e 's,@avahi_runtime_dir\@,$(avahi_runtime_dir),g' $< > $@ - -if HAVE_SYSTEMD -systemdsystemunit_DATA = \ - avahi-daemon.service \ - avahi-daemon.socket - -dist_dbussystemservices_DATA = \ - org.freedesktop.Avahi.service -endif - -CLEANFILES = $(systemdsystemunit_DATA) - -if ENABLE_CHROOT - -avahi_daemon_SOURCES += \ - chroot.c chroot.h \ - caps.c caps.h - -avahi_daemon_LDADD += -lcap - -endif - -if HAVE_DLOPEN -avahi_daemon_LDADD += -ldl -endif - -if HAVE_DBUS - -dbusservicedir=$(DBUS_SYS_DIR) - -avahi_daemon_SOURCES += \ - dbus-protocol.c dbus-protocol.h \ - dbus-util.c dbus-util.h \ - dbus-internal.h \ - dbus-async-address-resolver.c \ - dbus-async-host-name-resolver.c \ - dbus-async-service-resolver.c \ - dbus-domain-browser.c \ - dbus-entry-group.c \ - dbus-service-browser.c \ - dbus-service-type-browser.c \ - dbus-sync-address-resolver.c \ - dbus-sync-host-name-resolver.c \ - dbus-sync-service-resolver.c \ - dbus-record-browser.c \ - ../avahi-common/dbus.c ../avahi-common/dbus.h \ - ../avahi-common/dbus-watch-glue.c ../avahi-common/dbus-watch-glue.h - -avahi_daemon_LDADD += \ - $(DBUS_LIBS) - -avahi_daemon_CFLAGS += $(DBUS_CFLAGS) -DDBUS_SYSTEM_BUS_DEFAULT_ADDRESS=\"$(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)\" - -dist_dbusservice_DATA = avahi-dbus.conf - -dist_introspection_DATA = \ - org.freedesktop.Avahi.Server.xml \ - org.freedesktop.Avahi.EntryGroup.xml \ - org.freedesktop.Avahi.DomainBrowser.xml \ - org.freedesktop.Avahi.ServiceTypeBrowser.xml \ - org.freedesktop.Avahi.ServiceBrowser.xml \ - org.freedesktop.Avahi.ServiceResolver.xml \ - org.freedesktop.Avahi.AddressResolver.xml \ - org.freedesktop.Avahi.HostNameResolver.xml \ - org.freedesktop.Avahi.RecordBrowser.xml - -endif -endif -endif - -EXTRA_DIST = \ - avahi-daemon.conf \ - example.service \ - hosts \ - example.service \ - introspect.dtd \ - introspect.xsl \ - avahi-daemon.service.in \ - avahi-daemon.socket.in - -xmllint: - xmllint --noout --valid example.service - for F in $(introspection_DATA) ; do \ - xmllint --noout --valid $$F ; \ - done - -install-data-local: - test -z "$(localstatedir)/run" || $(MKDIR_P) "$(DESTDIR)$(localstatedir)/run" - -update-systemd: - curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c > sd-daemon.c - curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h > sd-daemon.h diff --git a/avahi-daemon/avahi-daemon.conf b/avahi-daemon/avahi-daemon.conf deleted file mode 100644 index 27e240d..0000000 --- a/avahi-daemon/avahi-daemon.conf +++ /dev/null @@ -1,68 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# See avahi-daemon.conf(5) for more information on this configuration -# file! - -[server] -#host-name=foo -#domain-name=local -#browse-domains=0pointer.de, zeroconf.org -use-ipv4=yes -use-ipv6=no -#allow-interfaces=eth0 -#deny-interfaces=eth1 -#check-response-ttl=no -#use-iff-running=no -#enable-dbus=yes -#disallow-other-stacks=no -#allow-point-to-point=no -#cache-entries-max=4096 -#clients-max=4096 -#objects-per-client-max=1024 -#entries-per-entry-group-max=32 -ratelimit-interval-usec=1000000 -ratelimit-burst=1000 - -[wide-area] -enable-wide-area=yes - -[publish] -#disable-publishing=no -#disable-user-service-publishing=no -#add-service-cookie=no -#publish-addresses=yes -publish-hinfo=no -publish-workstation=no -#publish-domain=yes -#publish-dns-servers=192.168.50.1, 192.168.50.2 -#publish-resolv-conf-dns-servers=yes -#publish-aaaa-on-ipv4=yes -#publish-a-on-ipv6=no - -[reflector] -#enable-reflector=no -#reflect-ipv=no - -[rlimits] -#rlimit-as= -rlimit-core=0 -rlimit-data=4194304 -rlimit-fsize=0 -rlimit-nofile=768 -rlimit-stack=4194304 -rlimit-nproc=3 diff --git a/avahi-daemon/avahi-daemon.service.in b/avahi-daemon/avahi-daemon.service.in deleted file mode 100644 index 548c834..0000000 --- a/avahi-daemon/avahi-daemon.service.in +++ /dev/null @@ -1,32 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -[Unit] -Description=Avahi mDNS/DNS-SD Stack -Requires=avahi-daemon.socket - -[Service] -Type=dbus -BusName=org.freedesktop.Avahi -ExecStart=@sbindir@/avahi-daemon -s -ExecReload=@sbindir@/avahi-daemon -r -NotifyAccess=main - -[Install] -WantedBy=multi-user.target -Also=avahi-daemon.socket -Alias=dbus-org.freedesktop.Avahi.service diff --git a/avahi-daemon/avahi-daemon.socket.in b/avahi-daemon/avahi-daemon.socket.in deleted file mode 100644 index 13309b8..0000000 --- a/avahi-daemon/avahi-daemon.socket.in +++ /dev/null @@ -1,25 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -[Unit] -Description=Avahi mDNS/DNS-SD Stack Activation Socket - -[Socket] -ListenStream=@avahi_runtime_dir@/avahi-daemon/socket - -[Install] -WantedBy=sockets.target diff --git a/avahi-daemon/avahi-dbus.conf.in b/avahi-daemon/avahi-dbus.conf.in deleted file mode 100644 index 1df0cc4..0000000 --- a/avahi-daemon/avahi-dbus.conf.in +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/avahi-service.dtd b/avahi-daemon/avahi-service.dtd deleted file mode 100644 index daf9637..0000000 --- a/avahi-daemon/avahi-service.dtd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/caps.c b/avahi-daemon/caps.c deleted file mode 100644 index 0e21acf..0000000 --- a/avahi-daemon/caps.c +++ /dev/null @@ -1,115 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include - -#include "caps.h" - -int avahi_caps_reduce(void) { - int ret = 0; - cap_t caps; - static cap_value_t cap_values[] = { CAP_SYS_CHROOT, CAP_SETUID, CAP_SETGID }; - - /* Let's reduce our caps to the minimum set and tell Linux to keep - * them across setuid(). This is called before we drop - * privileges. */ - - caps = cap_init(); - assert(caps); - cap_clear(caps); - - cap_set_flag(caps, CAP_EFFECTIVE, 3, cap_values, CAP_SET); - cap_set_flag(caps, CAP_PERMITTED, 3, cap_values, CAP_SET); - - if (cap_set_proc(caps) < 0) { - avahi_log_error("cap_set_proc() failed: %s", strerror(errno)); - ret = -1; - } - cap_free(caps); - - /* Retain capabilities across setuid() */ - if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) { - avahi_log_error("prctl(PR_SET_KEEPCAPS) failed: %s", strerror(errno)); - ret = -1; - } - - return ret; -} - -int avahi_caps_reduce2(void) { - int ret = 0; - cap_t caps; - static cap_value_t cap_values[] = { CAP_SYS_CHROOT }; - - /* Reduce our caps to the bare minimum and tell Linux not to keep - * them across setuid(). This is called after we drop - * privileges. */ - - /* No longer retain caps across setuid() */ - if (prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0) < 0) { - avahi_log_error("prctl(PR_SET_KEEPCAPS) failed: %s", strerror(errno)); - ret = -1; - } - - caps = cap_init(); - assert(caps); - cap_clear(caps); - - /* setuid() zeroed our effective caps, let's get them back */ - cap_set_flag(caps, CAP_EFFECTIVE, 1, cap_values, CAP_SET); - cap_set_flag(caps, CAP_PERMITTED, 1, cap_values, CAP_SET); - - if (cap_set_proc(caps) < 0) { - avahi_log_error("cap_set_proc() failed: %s", strerror(errno)); - ret = -1; - } - cap_free(caps); - - return ret; -} - -int avahi_caps_drop_all(void) { - cap_t caps; - int ret = 0; - - /* Drop all capabilities and turn ourselves into a normal user process */ - - caps = cap_init(); - assert(caps); - cap_clear(caps); - - if (cap_set_proc(caps) < 0) { - avahi_log_error("cap_set_proc() failed: %s", strerror(errno)); - ret = -1; - } - cap_free(caps); - - return ret; -} diff --git a/avahi-daemon/caps.h b/avahi-daemon/caps.h deleted file mode 100644 index 5119bd0..0000000 --- a/avahi-daemon/caps.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef foocapshfoo -#define foocapshfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -int avahi_caps_reduce(void); -int avahi_caps_reduce2(void); -int avahi_caps_drop_all(void); - -#endif diff --git a/avahi-daemon/chroot.c b/avahi-daemon/chroot.c deleted file mode 100644 index ccd56be..0000000 --- a/avahi-daemon/chroot.c +++ /dev/null @@ -1,415 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "chroot.h" -#include "caps.h" -#include "setproctitle.h" - -enum { - AVAHI_CHROOT_SUCCESS = 0, - AVAHI_CHROOT_FAILURE, - AVAHI_CHROOT_GET_RESOLV_CONF, -#ifdef HAVE_DBUS - AVAHI_CHROOT_GET_SERVER_INTROSPECT, - AVAHI_CHROOT_GET_ENTRY_GROUP_INTROSPECT, - AVAHI_CHROOT_GET_ADDRESS_RESOLVER_INTROSPECT, - AVAHI_CHROOT_GET_DOMAIN_BROWSER_INTROSPECT, - AVAHI_CHROOT_GET_HOST_NAME_RESOLVER_INTROSPECT, - AVAHI_CHROOT_GET_SERVICE_BROWSER_INTROSPECT, - AVAHI_CHROOT_GET_SERVICE_RESOLVER_INTROSPECT, - AVAHI_CHROOT_GET_SERVICE_TYPE_BROWSER_INTROSPECT, - AVAHI_CHROOT_GET_RECORD_BROWSER_INTROSPECT, -#endif - AVAHI_CHROOT_UNLINK_PID, - AVAHI_CHROOT_UNLINK_SOCKET, - AVAHI_CHROOT_MAX -}; - -static const char* const get_file_name_table[AVAHI_CHROOT_MAX] = { - NULL, - NULL, - "/etc/resolv.conf", -#ifdef HAVE_DBUS - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.Server.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.EntryGroup.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.AddressResolver.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.DomainBrowser.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.HostNameResolver.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.ServiceBrowser.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.ServiceResolver.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.ServiceTypeBrowser.xml", - AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.RecordBrowser.xml", -#endif - NULL, - NULL -}; - -static const char *const unlink_file_name_table[AVAHI_CHROOT_MAX] = { - NULL, - NULL, - NULL, -#ifdef HAVE_DBUS - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, -#endif - AVAHI_DAEMON_RUNTIME_DIR"/pid", - AVAHI_SOCKET -}; - -static int helper_fd = -1; - -static int send_fd(int fd, int payload_fd) { - uint8_t dummy = AVAHI_CHROOT_SUCCESS; - struct iovec iov; - struct msghdr msg; - union { - struct cmsghdr hdr; - char buf[CMSG_SPACE(sizeof(int))]; - } cmsg; - - /* Send a file descriptor over the socket */ - - memset(&iov, 0, sizeof(iov)); - memset(&msg, 0, sizeof(msg)); - memset(&cmsg, 0, sizeof(cmsg)); - - iov.iov_base = &dummy; - iov.iov_len = sizeof(dummy); - - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_name = NULL; - msg.msg_namelen = 0; - - msg.msg_control = &cmsg; - msg.msg_controllen = sizeof(cmsg); - msg.msg_flags = 0; - - cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int)); - cmsg.hdr.cmsg_level = SOL_SOCKET; - cmsg.hdr.cmsg_type = SCM_RIGHTS; - *((int*) CMSG_DATA(&cmsg.hdr)) = payload_fd; - - if (sendmsg(fd, &msg, 0) < 0) { - avahi_log_error("sendmsg() failed: %s", strerror(errno)); - return -1; - } - - return 0; -} - -static int recv_fd(int fd) { - uint8_t dummy; - struct iovec iov; - struct msghdr msg; - union { - struct cmsghdr hdr; - char buf[CMSG_SPACE(sizeof(int))]; - } cmsg; - - /* Receive a file descriptor from a socket */ - - memset(&iov, 0, sizeof(iov)); - memset(&msg, 0, sizeof(msg)); - memset(&cmsg, 0, sizeof(cmsg)); - - iov.iov_base = &dummy; - iov.iov_len = sizeof(dummy); - - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_name = NULL; - msg.msg_namelen = 0; - - msg.msg_control = cmsg.buf; - msg.msg_controllen = sizeof(cmsg); - msg.msg_flags = 0; - - cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int)); - cmsg.hdr.cmsg_level = SOL_SOCKET; - cmsg.hdr.cmsg_type = SCM_RIGHTS; - *((int*) CMSG_DATA(&cmsg.hdr)) = -1; - - if (recvmsg(fd, &msg, 0) <= 0) { - avahi_log_error("recvmsg() failed: %s", strerror(errno)); - return -1; - } else { - struct cmsghdr* h; - - if (dummy != AVAHI_CHROOT_SUCCESS) { - errno = EINVAL; - return -1; - } - - if (!(h = CMSG_FIRSTHDR(&msg))) { - avahi_log_error("recvmsg() sent no fd."); - errno = EINVAL; - return -1; - } - - assert(h->cmsg_len = CMSG_LEN(sizeof(int))); - assert(h->cmsg_level = SOL_SOCKET); - assert(h->cmsg_type == SCM_RIGHTS); - - return *((int*)CMSG_DATA(h)); - } -} - -static int helper_main(int fd) { - int ret = 1; - assert(fd >= 0); - - /* This is the main function of our helper process which is forked - * off to access files outside the chroot environment. Keep in - * mind that this code is security sensitive! */ - - avahi_log_debug(__FILE__": chroot() helper started"); - - for (;;) { - uint8_t command; - ssize_t r; - - if ((r = read(fd, &command, sizeof(command))) <= 0) { - - /* EOF? */ - if (r == 0) - break; - - avahi_log_error(__FILE__": read() failed: %s", strerror(errno)); - goto fail; - } - - assert(r == sizeof(command)); - - avahi_log_debug(__FILE__": chroot() helper got command %02x", command); - - switch (command) { -#ifdef HAVE_DBUS - case AVAHI_CHROOT_GET_SERVER_INTROSPECT: - case AVAHI_CHROOT_GET_ENTRY_GROUP_INTROSPECT: - case AVAHI_CHROOT_GET_ADDRESS_RESOLVER_INTROSPECT: - case AVAHI_CHROOT_GET_DOMAIN_BROWSER_INTROSPECT: - case AVAHI_CHROOT_GET_HOST_NAME_RESOLVER_INTROSPECT: - case AVAHI_CHROOT_GET_SERVICE_BROWSER_INTROSPECT: - case AVAHI_CHROOT_GET_SERVICE_RESOLVER_INTROSPECT: - case AVAHI_CHROOT_GET_SERVICE_TYPE_BROWSER_INTROSPECT: - case AVAHI_CHROOT_GET_RECORD_BROWSER_INTROSPECT: -#endif - case AVAHI_CHROOT_GET_RESOLV_CONF: { - int payload; - - if ((payload = open(get_file_name_table[(int) command], O_RDONLY)) < 0) { - uint8_t c = AVAHI_CHROOT_FAILURE; - - avahi_log_error(__FILE__": open() failed: %s", strerror(errno)); - - if (write(fd, &c, sizeof(c)) != sizeof(c)) { - avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno)); - goto fail; - } - - break; - } - - if (send_fd(fd, payload) < 0) - goto fail; - - close(payload); - - break; - } - - case AVAHI_CHROOT_UNLINK_SOCKET: - case AVAHI_CHROOT_UNLINK_PID: { - uint8_t c = AVAHI_CHROOT_SUCCESS; - - unlink(unlink_file_name_table[(int) command]); - - if (write(fd, &c, sizeof(c)) != sizeof(c)) { - avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno)); - goto fail; - } - - break; - } - - default: - avahi_log_error(__FILE__": Unknown command %02x.", command); - break; - } - } - - ret = 0; - -fail: - - avahi_log_debug(__FILE__": chroot() helper exiting with return value %i", ret); - - return ret; -} - -int avahi_chroot_helper_start(const char *argv0) { - int sock[2]; - pid_t pid; - - assert(helper_fd < 0); - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) < 0) { - avahi_log_error("socketpair() failed: %s", strerror(errno)); - return -1; - } - - if ((pid = fork()) < 0) { - close(sock[0]); - close(sock[1]); - avahi_log_error(__FILE__": fork() failed: %s", strerror(errno)); - return -1; - } else if (pid == 0) { - - /* Drop all remaining capabilities */ - avahi_caps_drop_all(); - - avahi_set_proc_title(argv0, "%s: chroot helper", argv0); - - daemon_retval_done(); - - close(sock[0]); - helper_main(sock[1]); - _exit(0); - } - - close(sock[1]); - helper_fd = sock[0]; - - return 0; -} - -void avahi_chroot_helper_shutdown(void) { - - if (helper_fd <= 0) - return; - - close(helper_fd); - helper_fd = -1; -} - -int avahi_chroot_helper_get_fd(const char *fname) { - - if (helper_fd >= 0) { - uint8_t command; - - for (command = 2; command < AVAHI_CHROOT_MAX; command++) - if (get_file_name_table[(int) command] && - strcmp(fname, get_file_name_table[(int) command]) == 0) - break; - - if (command >= AVAHI_CHROOT_MAX) { - avahi_log_error("chroot() helper accessed for invalid file name"); - errno = EACCES; - return -1; - } - - assert(get_file_name_table[(int) command]); - - if (write(helper_fd, &command, sizeof(command)) < 0) { - avahi_log_error("write() failed: %s\n", strerror(errno)); - return -1; - } - - return recv_fd(helper_fd); - - } else - return open(fname, O_RDONLY); -} - - -FILE *avahi_chroot_helper_get_file(const char *fname) { - FILE *f; - int fd; - - if ((fd = avahi_chroot_helper_get_fd(fname)) < 0) - return NULL; - - f = fdopen(fd, "r"); - assert(f); - - return f; -} - -int avahi_chroot_helper_unlink(const char *fname) { - - if (helper_fd >= 0) { - uint8_t c, command; - ssize_t r; - - for (command = 2; command < AVAHI_CHROOT_MAX; command++) - if (unlink_file_name_table[(int) command] && - strcmp(fname, unlink_file_name_table[(int) command]) == 0) - break; - - if (command >= AVAHI_CHROOT_MAX) { - avahi_log_error("chroot() helper accessed for invalid file name"); - errno = EACCES; - return -1; - } - - if (write(helper_fd, &command, sizeof(command)) < 0 && - (errno != EPIPE && errno != ECONNRESET)) { - avahi_log_error("write() failed: %s\n", strerror(errno)); - return -1; - } - - if ((r = read(helper_fd, &c, sizeof(c))) < 0 && - (errno != EPIPE && errno != ECONNRESET)) { - avahi_log_error("read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); - return -1; - } - - return 0; - - } else - - return unlink(fname); - -} diff --git a/avahi-daemon/chroot.h b/avahi-daemon/chroot.h deleted file mode 100644 index 2828d54..0000000 --- a/avahi-daemon/chroot.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef foochroothelperhfoo -#define foochroothelperhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -int avahi_chroot_helper_start(const char *argv0); -void avahi_chroot_helper_shutdown(void); -int avahi_chroot_helper_get(const char *fname); - -int avahi_chroot_helper_get_fd(const char *fname); -FILE *avahi_chroot_helper_get_file(const char *fname); - -int avahi_chroot_helper_unlink(const char *fname); - -#endif diff --git a/avahi-daemon/dbus-async-address-resolver.c b/avahi-daemon/dbus-async-address-resolver.c deleted file mode 100644 index a77e03c..0000000 --- a/avahi-daemon/dbus-async-address-resolver.c +++ /dev/null @@ -1,142 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" - -void avahi_dbus_async_address_resolver_free(AsyncAddressResolverInfo *i) { - assert(i); - - if (i->address_resolver) - avahi_s_address_resolver_free(i->address_resolver); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - - AVAHI_LLIST_REMOVE(AsyncAddressResolverInfo, async_address_resolvers, i->client->async_address_resolvers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -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) { - AsyncAddressResolverInfo *i = userdata; - DBusMessage *reply; - - assert(r); - assert(i); - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, avahi_dbus_map_resolve_signal_name(event)); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return; - } - - if (event == AVAHI_RESOLVER_FOUND) { - char t[AVAHI_ADDRESS_STR_MAX], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - - assert(address); - assert(host_name); - avahi_address_snprint(t, sizeof(t), address); - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) address->proto; - u_flags = (uint32_t) flags; - - dbus_message_append_args( - reply, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_STRING, &pt, - DBUS_TYPE_STRING, &host_name, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - - } else { - assert(event == AVAHI_RESOLVER_FAILURE); - avahi_dbus_append_server_error(reply); - } - - dbus_message_set_destination(reply, i->client->name); - dbus_connection_send(server->bus, reply, NULL); - dbus_message_unref(reply); -} - -DBusHandlerResult avahi_dbus_msg_async_address_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - AsyncAddressResolverInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.AddressResolver.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing AddressResolver::Free message"); - goto fail; - } - - avahi_dbus_async_address_resolver_free(i); - return avahi_dbus_respond_ok(c, m); - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} diff --git a/avahi-daemon/dbus-async-host-name-resolver.c b/avahi-daemon/dbus-async-host-name-resolver.c deleted file mode 100644 index 7c2d063..0000000 --- a/avahi-daemon/dbus-async-host-name-resolver.c +++ /dev/null @@ -1,140 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" - -void avahi_dbus_async_host_name_resolver_free(AsyncHostNameResolverInfo *i) { - assert(i); - - if (i->host_name_resolver) - avahi_s_host_name_resolver_free(i->host_name_resolver); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - AVAHI_LLIST_REMOVE(AsyncHostNameResolverInfo, async_host_name_resolvers, i->client->async_host_name_resolvers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -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) { - AsyncHostNameResolverInfo *i = userdata; - DBusMessage *reply; - - assert(r); - assert(i); - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, avahi_dbus_map_resolve_signal_name(event)); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return; - } - - if (event == AVAHI_RESOLVER_FOUND) { - char t[AVAHI_ADDRESS_STR_MAX], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - - assert(a); - assert(host_name); - avahi_address_snprint(t, sizeof(t), a); - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) a->proto; - u_flags = (uint32_t) flags; - - dbus_message_append_args( - reply, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &host_name, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_STRING, &pt, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - } else { - assert(event == AVAHI_RESOLVER_FAILURE); - avahi_dbus_append_server_error(reply); - } - - dbus_message_set_destination(reply, i->client->name); - dbus_connection_send(server->bus, reply, NULL); - dbus_message_unref(reply); -} - -DBusHandlerResult avahi_dbus_msg_async_host_name_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - AsyncHostNameResolverInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.HostNameResolver.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing HostNameResolver::Free message"); - goto fail; - } - - avahi_dbus_async_host_name_resolver_free(i); - return avahi_dbus_respond_ok(c, m); - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} diff --git a/avahi-daemon/dbus-async-service-resolver.c b/avahi-daemon/dbus-async-service-resolver.c deleted file mode 100644 index 2b58e2d..0000000 --- a/avahi-daemon/dbus-async-service-resolver.c +++ /dev/null @@ -1,179 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" - -void avahi_dbus_async_service_resolver_free(AsyncServiceResolverInfo *i) { - assert(i); - - if (i->service_resolver) - avahi_s_service_resolver_free(i->service_resolver); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - - AVAHI_LLIST_REMOVE(AsyncServiceResolverInfo, async_service_resolvers, i->client->async_service_resolvers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -void avahi_dbus_async_service_resolver_callback( - AvahiSServiceResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AvahiLookupResultFlags flags, - void* userdata) { - - AsyncServiceResolverInfo *i = userdata; - DBusMessage *reply; - - assert(r); - assert(i); - - reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, avahi_dbus_map_resolve_signal_name(event)); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return; - } - - if (event == AVAHI_RESOLVER_FOUND) { - char t[AVAHI_ADDRESS_STR_MAX], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - - assert(host_name); - -/* avahi_log_debug(__FILE__": [%s] Successfully resolved service <%s.%s.%s>", i->path, name, type, domain); */ - - if (a) - avahi_address_snprint(t, sizeof(t), a); - else - t[0] = 0; - - if (!name) - name = ""; - - if (avahi_dbus_is_our_own_service(i->client, interface, protocol, name, type, domain) > 0) - flags |= AVAHI_LOOKUP_RESULT_OUR_OWN; - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - if (a) - i_aprotocol = (int32_t) a->proto; - else - i_aprotocol = AVAHI_PROTO_UNSPEC; - u_flags = (uint32_t) flags; - - dbus_message_append_args( - reply, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_STRING, &host_name, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_STRING, &pt, - DBUS_TYPE_UINT16, &port, - DBUS_TYPE_INVALID); - - avahi_dbus_append_string_list(reply, txt); - - dbus_message_append_args( - reply, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - } else { - assert(event == AVAHI_RESOLVER_FAILURE); - avahi_dbus_append_server_error(reply); - } - - dbus_message_set_destination(reply, i->client->name); - dbus_connection_send(server->bus, reply, NULL); - dbus_message_unref(reply); -} - -DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - AsyncServiceResolverInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.ServiceResolver.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing ServiceResolver::Free message"); - goto fail; - } - - avahi_dbus_async_service_resolver_free(i); - return avahi_dbus_respond_ok(c, m); - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} diff --git a/avahi-daemon/dbus-domain-browser.c b/avahi-daemon/dbus-domain-browser.c deleted file mode 100644 index e51996f..0000000 --- a/avahi-daemon/dbus-domain-browser.c +++ /dev/null @@ -1,132 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" - -void avahi_dbus_domain_browser_free(DomainBrowserInfo *i) { - assert(i); - - if (i->domain_browser) - avahi_s_domain_browser_free(i->domain_browser); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - - AVAHI_LLIST_REMOVE(DomainBrowserInfo, domain_browsers, i->client->domain_browsers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -DBusHandlerResult avahi_dbus_msg_domain_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - DomainBrowserInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.DomainBrowser.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing DomainBrowser::Free message"); - goto fail; - } - - avahi_dbus_domain_browser_free(i); - return avahi_dbus_respond_ok(c, m); - - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -void avahi_dbus_domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void* userdata) { - DomainBrowserInfo *i = userdata; - DBusMessage *m; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(b); - assert(i); - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, avahi_dbus_map_browse_signal_name(event)); - - if (!m) { - avahi_log_error("Failed allocate message"); - return; - } - - if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { - assert(domain); - dbus_message_append_args( - m, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - } else if (event == AVAHI_BROWSER_FAILURE) - avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); - dbus_connection_send(server->bus, m, NULL); - dbus_message_unref(m); -} diff --git a/avahi-daemon/dbus-entry-group.c b/avahi-daemon/dbus-entry-group.c deleted file mode 100644 index 4e879a5..0000000 --- a/avahi-daemon/dbus-entry-group.c +++ /dev/null @@ -1,369 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" -#include "main.h" - -void avahi_dbus_entry_group_free(EntryGroupInfo *i) { - assert(i); - - if (i->entry_group) - avahi_s_entry_group_free(i->entry_group); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - AVAHI_LLIST_REMOVE(EntryGroupInfo, entry_groups, i->client->entry_groups, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -void avahi_dbus_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata) { - EntryGroupInfo *i = userdata; - DBusMessage *m; - int32_t t; - const char *e; - - assert(s); - assert(g); - assert(i); - - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "StateChanged"); - - if (!m) { - avahi_log_error("Failed allocate message"); - return; - } - - t = (int32_t) state; - if (state == AVAHI_ENTRY_GROUP_FAILURE) - e = avahi_error_number_to_dbus(avahi_server_errno(s)); - else if (state == AVAHI_ENTRY_GROUP_COLLISION) - e = AVAHI_DBUS_ERR_COLLISION; - else - e = AVAHI_DBUS_ERR_OK; - - dbus_message_append_args( - m, - DBUS_TYPE_INT32, &t, - DBUS_TYPE_STRING, &e, - DBUS_TYPE_INVALID); - dbus_message_set_destination(m, i->client->name); - dbus_connection_send(server->bus, m, NULL); - dbus_message_unref(m); -} - -DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - EntryGroupInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.EntryGroup.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing EntryGroup::Free message"); - goto fail; - } - - avahi_dbus_entry_group_free(i); - return avahi_dbus_respond_ok(c, m); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Commit")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing EntryGroup::Commit message"); - goto fail; - } - - if (avahi_s_entry_group_commit(i->entry_group) < 0) - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - - return avahi_dbus_respond_ok(c, m); - - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Reset")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing EntryGroup::Reset message"); - goto fail; - } - - avahi_s_entry_group_reset(i->entry_group); - i->n_entries = 0; - return avahi_dbus_respond_ok(c, m); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing EntryGroup::IsEmpty message"); - goto fail; - } - - return avahi_dbus_respond_boolean(c, m, !!avahi_s_entry_group_is_empty(i->entry_group)); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState")) { - AvahiEntryGroupState state; - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing EntryGroup::GetState message"); - goto fail; - } - - state = avahi_s_entry_group_get_state(i->entry_group); - return avahi_dbus_respond_int32(c, m, (int32_t) state); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService")) { - int32_t interface, protocol; - uint32_t flags; - char *type, *name, *domain, *host; - uint16_t port; - AvahiStringList *strlst = NULL; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_STRING, &host, - DBUS_TYPE_UINT16, &port, - DBUS_TYPE_INVALID) || - !type || !name || - avahi_dbus_read_strlst(m, 8, &strlst) < 0) { - avahi_log_warn("Error parsing EntryGroup::AddService message"); - goto fail; - } - - if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max) { - avahi_string_list_free(strlst); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL); - } - - if (domain && !*domain) - domain = NULL; - - if (host && !*host) - host = NULL; - - if (avahi_server_add_service_strlst(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, host, port, strlst) < 0) { - avahi_string_list_free(strlst); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - if (!(flags & AVAHI_PUBLISH_UPDATE)) - i->n_entries ++; - - avahi_string_list_free(strlst); - - return avahi_dbus_respond_ok(c, m); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype")) { - - int32_t interface, protocol; - uint32_t flags; - char *type, *name, *domain, *subtype; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_STRING, &subtype, - DBUS_TYPE_INVALID) || !type || !name || !subtype) { - avahi_log_warn("Error parsing EntryGroup::AddServiceSubtype message"); - goto fail; - } - - if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL); - - if (domain && !*domain) - domain = NULL; - - if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0) - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - - if (!(flags & AVAHI_PUBLISH_UPDATE)) - i->n_entries ++; - - return avahi_dbus_respond_ok(c, m); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt")) { - int32_t interface, protocol; - uint32_t flags; - char *type, *name, *domain; - AvahiStringList *strlst; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INVALID) || - !type || !name || - avahi_dbus_read_strlst(m, 6, &strlst)) { - avahi_log_warn("Error parsing EntryGroup::UpdateServiceTxt message"); - goto fail; - } - - if (domain && !*domain) - domain = NULL; - - if (avahi_server_update_service_txt_strlst(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, strlst) < 0) { - avahi_string_list_free(strlst); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - avahi_string_list_free(strlst); - - return avahi_dbus_respond_ok(c, m); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) { - int32_t interface, protocol; - uint32_t flags; - char *name, *address; - AvahiAddress a; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &address, - DBUS_TYPE_INVALID) || !name || !address) { - avahi_log_warn("Error parsing EntryGroup::AddAddress message"); - goto fail; - } - - if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL); - - if (!(avahi_address_parse(address, AVAHI_PROTO_UNSPEC, &a))) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_ADDRESS, NULL); - - if (avahi_server_add_address(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, &a) < 0) - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - - if (!(flags & AVAHI_PUBLISH_UPDATE)) - i->n_entries ++; - - return avahi_dbus_respond_ok(c, m); - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord")) { - int32_t interface, protocol; - uint32_t flags, ttl, size; - uint16_t clazz, type; - char *name; - void *rdata; - AvahiRecord *r; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT16, &clazz, - DBUS_TYPE_UINT16, &type, - DBUS_TYPE_UINT32, &ttl, - DBUS_TYPE_INVALID) || !name || - avahi_dbus_read_rdata (m, 7, &rdata, &size)) { - avahi_log_warn("Error parsing EntryGroup::AddRecord message"); - goto fail; - } - - if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL); - - if (!avahi_is_valid_domain_name (name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_DOMAIN_NAME, NULL); - - if (!(r = avahi_record_new_full (name, clazz, type, ttl))) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_NO_MEMORY, NULL); - - if (avahi_rdata_parse (r, rdata, size) < 0) { - avahi_record_unref (r); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_RDATA, NULL); - } - - if (avahi_server_add(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, r) < 0) { - avahi_record_unref (r); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - if (!(flags & AVAHI_PUBLISH_UPDATE)) - i->n_entries ++; - - avahi_record_unref (r); - - return avahi_dbus_respond_ok(c, m); - } - - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} diff --git a/avahi-daemon/dbus-internal.h b/avahi-daemon/dbus-internal.h deleted file mode 100644 index 0b86578..0000000 --- a/avahi-daemon/dbus-internal.h +++ /dev/null @@ -1,256 +0,0 @@ -#ifndef foodbusinternalhfoo -#define foodbusinternalhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - - -#include - -#include -#include -#include - -#include - -typedef struct Server Server; -typedef struct Client Client; -typedef struct EntryGroupInfo EntryGroupInfo; -typedef struct SyncHostNameResolverInfo SyncHostNameResolverInfo; -typedef struct AsyncHostNameResolverInfo AsyncHostNameResolverInfo; -typedef struct SyncAddressResolverInfo SyncAddressResolverInfo; -typedef struct AsyncAddressResolverInfo AsyncAddressResolverInfo; -typedef struct DomainBrowserInfo DomainBrowserInfo; -typedef struct ServiceTypeBrowserInfo ServiceTypeBrowserInfo; -typedef struct ServiceBrowserInfo ServiceBrowserInfo; -typedef struct SyncServiceResolverInfo SyncServiceResolverInfo; -typedef struct AsyncServiceResolverInfo AsyncServiceResolverInfo; -typedef struct RecordBrowserInfo RecordBrowserInfo; - -#define DEFAULT_CLIENTS_MAX 4096 -#define DEFAULT_OBJECTS_PER_CLIENT_MAX 1024 -#define DEFAULT_ENTRIES_PER_ENTRY_GROUP_MAX 32 - -struct EntryGroupInfo { - unsigned id; - Client *client; - AvahiSEntryGroup *entry_group; - char *path; - - unsigned n_entries; - - AVAHI_LLIST_FIELDS(EntryGroupInfo, entry_groups); -}; - -struct SyncHostNameResolverInfo { - Client *client; - AvahiSHostNameResolver *host_name_resolver; - DBusMessage *message; - - AVAHI_LLIST_FIELDS(SyncHostNameResolverInfo, sync_host_name_resolvers); -}; - -struct AsyncHostNameResolverInfo { - unsigned id; - Client *client; - AvahiSHostNameResolver *host_name_resolver; - char *path; - - AVAHI_LLIST_FIELDS(AsyncHostNameResolverInfo, async_host_name_resolvers); -}; - -struct SyncAddressResolverInfo { - Client *client; - AvahiSAddressResolver *address_resolver; - DBusMessage *message; - - AVAHI_LLIST_FIELDS(SyncAddressResolverInfo, sync_address_resolvers); -}; - -struct AsyncAddressResolverInfo { - unsigned id; - Client *client; - AvahiSAddressResolver *address_resolver; - char *path; - - AVAHI_LLIST_FIELDS(AsyncAddressResolverInfo, async_address_resolvers); -}; - -struct DomainBrowserInfo { - unsigned id; - Client *client; - AvahiSDomainBrowser *domain_browser; - char *path; - - AVAHI_LLIST_FIELDS(DomainBrowserInfo, domain_browsers); -}; - -struct ServiceTypeBrowserInfo { - unsigned id; - Client *client; - AvahiSServiceTypeBrowser *service_type_browser; - char *path; - - AVAHI_LLIST_FIELDS(ServiceTypeBrowserInfo, service_type_browsers); -}; - -struct ServiceBrowserInfo { - unsigned id; - Client *client; - AvahiSServiceBrowser *service_browser; - char *path; - - AVAHI_LLIST_FIELDS(ServiceBrowserInfo, service_browsers); -}; - -struct SyncServiceResolverInfo { - Client *client; - AvahiSServiceResolver *service_resolver; - DBusMessage *message; - - AVAHI_LLIST_FIELDS(SyncServiceResolverInfo, sync_service_resolvers); -}; - -struct AsyncServiceResolverInfo { - unsigned id; - Client *client; - AvahiSServiceResolver *service_resolver; - char *path; - - AVAHI_LLIST_FIELDS(AsyncServiceResolverInfo, async_service_resolvers); -}; - -struct RecordBrowserInfo { - unsigned id; - Client *client; - AvahiSRecordBrowser *record_browser; - char *path; - - AVAHI_LLIST_FIELDS(RecordBrowserInfo, record_browsers); -}; - -struct Client { - unsigned id; - char *name; - unsigned current_id; - unsigned n_objects; - - AVAHI_LLIST_FIELDS(Client, clients); - AVAHI_LLIST_HEAD(EntryGroupInfo, entry_groups); - AVAHI_LLIST_HEAD(SyncHostNameResolverInfo, sync_host_name_resolvers); - AVAHI_LLIST_HEAD(AsyncHostNameResolverInfo, async_host_name_resolvers); - AVAHI_LLIST_HEAD(SyncAddressResolverInfo, sync_address_resolvers); - AVAHI_LLIST_HEAD(AsyncAddressResolverInfo, async_address_resolvers); - AVAHI_LLIST_HEAD(DomainBrowserInfo, domain_browsers); - AVAHI_LLIST_HEAD(ServiceTypeBrowserInfo, service_type_browsers); - AVAHI_LLIST_HEAD(ServiceBrowserInfo, service_browsers); - AVAHI_LLIST_HEAD(SyncServiceResolverInfo, sync_service_resolvers); - AVAHI_LLIST_HEAD(AsyncServiceResolverInfo, async_service_resolvers); - AVAHI_LLIST_HEAD(RecordBrowserInfo, record_browsers); -}; - -struct Server { - const AvahiPoll *poll_api; - DBusConnection *bus; - AVAHI_LLIST_HEAD(Client, clients); - unsigned n_clients; - unsigned current_id; - - AvahiTimeout *reconnect_timeout; - int reconnect; - - unsigned n_clients_max; - unsigned n_objects_per_client_max; - unsigned n_entries_per_entry_group_max; - - int disable_user_service_publishing; -}; - -extern Server *server; - -void avahi_dbus_entry_group_free(EntryGroupInfo *i); -void avahi_dbus_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata); -DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage *m, void *userdata); - -void avahi_dbus_sync_host_name_resolver_free(SyncHostNameResolverInfo *i); -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); - -void avahi_dbus_async_host_name_resolver_free(AsyncHostNameResolverInfo *i); -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); -DBusHandlerResult avahi_dbus_msg_async_host_name_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata); - -void avahi_dbus_sync_address_resolver_free(SyncAddressResolverInfo *i); -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); - -void avahi_dbus_async_address_resolver_free(AsyncAddressResolverInfo *i); -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); -DBusHandlerResult avahi_dbus_msg_async_address_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata); - -void avahi_dbus_domain_browser_free(DomainBrowserInfo *i); -DBusHandlerResult avahi_dbus_msg_domain_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); -void avahi_dbus_domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void* userdata); - -void avahi_dbus_service_type_browser_free(ServiceTypeBrowserInfo *i); -DBusHandlerResult avahi_dbus_msg_service_type_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); -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); - -void avahi_dbus_service_browser_free(ServiceBrowserInfo *i); -DBusHandlerResult avahi_dbus_msg_service_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); -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); - -void avahi_dbus_sync_service_resolver_free(SyncServiceResolverInfo *i); - -void avahi_dbus_sync_service_resolver_callback( - AvahiSServiceResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AvahiLookupResultFlags flags, - void* userdata); - -void avahi_dbus_async_service_resolver_free(AsyncServiceResolverInfo *i); -void avahi_dbus_async_service_resolver_callback( - AvahiSServiceResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AvahiLookupResultFlags flags, - void* userdata); - -DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata); - -void avahi_dbus_record_browser_free(RecordBrowserInfo *i); -DBusHandlerResult avahi_dbus_msg_record_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata); -void avahi_dbus_record_browser_callback(AvahiSRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata); - -#endif diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c deleted file mode 100644 index eb8a662..0000000 --- a/avahi-daemon/dbus-protocol.c +++ /dev/null @@ -1,1226 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "dbus-protocol.h" -#include "dbus-util.h" -#include "dbus-internal.h" -#include "main.h" - -/* #define VALGRIND_WORKAROUND 1 */ - -#define RECONNECT_MSEC 3000 - -Server *server = NULL; - -static int dbus_connect(void); -static void dbus_disconnect(void); - -static void client_free(Client *c) { - - assert(server); - assert(c); - - while (c->entry_groups) - avahi_dbus_entry_group_free(c->entry_groups); - - while (c->sync_host_name_resolvers) - avahi_dbus_sync_host_name_resolver_free(c->sync_host_name_resolvers); - - while (c->async_host_name_resolvers) - avahi_dbus_async_host_name_resolver_free(c->async_host_name_resolvers); - - while (c->sync_address_resolvers) - avahi_dbus_sync_address_resolver_free(c->sync_address_resolvers); - - while (c->async_address_resolvers) - avahi_dbus_async_address_resolver_free(c->async_address_resolvers); - - while (c->domain_browsers) - avahi_dbus_domain_browser_free(c->domain_browsers); - - while (c->service_type_browsers) - avahi_dbus_service_type_browser_free(c->service_type_browsers); - - while (c->service_browsers) - avahi_dbus_service_browser_free(c->service_browsers); - - while (c->sync_service_resolvers) - avahi_dbus_sync_service_resolver_free(c->sync_service_resolvers); - - while (c->async_service_resolvers) - avahi_dbus_async_service_resolver_free(c->async_service_resolvers); - - while (c->record_browsers) - avahi_dbus_record_browser_free(c->record_browsers); - - assert(c->n_objects == 0); - - avahi_free(c->name); - AVAHI_LLIST_REMOVE(Client, clients, server->clients, c); - avahi_free(c); - - assert(server->n_clients >= 1); - server->n_clients --; -} - -static Client *client_get(const char *name, int create) { - Client *client; - - assert(server); - assert(name); - - for (client = server->clients; client; client = client->clients_next) - if (!strcmp(name, client->name)) - return client; - - if (!create) - return NULL; - - if (server->n_clients >= server->n_clients_max) - return NULL; - - /* If not existent yet, create a new entry */ - client = avahi_new(Client, 1); - client->id = server->current_id++; - client->name = avahi_strdup(name); - client->current_id = 0; - client->n_objects = 0; - - AVAHI_LLIST_HEAD_INIT(EntryGroupInfo, client->entry_groups); - AVAHI_LLIST_HEAD_INIT(SyncHostNameResolverInfo, client->sync_host_name_resolvers); - AVAHI_LLIST_HEAD_INIT(AsyncHostNameResolverInfo, client->async_host_name_resolvers); - AVAHI_LLIST_HEAD_INIT(SyncAddressResolverInfo, client->sync_address_resolvers); - AVAHI_LLIST_HEAD_INIT(AsyncAddressResolverInfo, client->async_address_resolvers); - AVAHI_LLIST_HEAD_INIT(DomainBrowserInfo, client->domain_browsers); - AVAHI_LLIST_HEAD_INIT(ServiceTypeBrowserInfo, client->service_type_browsers); - AVAHI_LLIST_HEAD_INIT(ServiceBrowserInfo, client->service_browsers); - AVAHI_LLIST_HEAD_INIT(SyncServiceResolverInfo, client->sync_service_resolvers); - AVAHI_LLIST_HEAD_INIT(AsyncServiceResolverInfo, client->async_service_resolvers); - AVAHI_LLIST_HEAD_INIT(RecordBrowserInfo, client->record_browsers); - - AVAHI_LLIST_PREPEND(Client, clients, server->clients, client); - - server->n_clients++; - assert(server->n_clients > 0); - - return client; -} - -static void reconnect_callback(AvahiTimeout *t, AVAHI_GCC_UNUSED void *userdata) { - assert(!server->bus); - - if (dbus_connect() < 0) { - struct timeval tv; - avahi_log_debug(__FILE__": Connection failed, retrying in %ims...", RECONNECT_MSEC); - avahi_elapse_time(&tv, RECONNECT_MSEC, 0); - server->poll_api->timeout_update(t, &tv); - } else { - avahi_log_debug(__FILE__": Successfully reconnected."); - server->poll_api->timeout_update(t, NULL); - } -} - -static DBusHandlerResult msg_signal_filter_impl(AVAHI_GCC_UNUSED DBusConnection *c, DBusMessage *m, AVAHI_GCC_UNUSED void *userdata) { - DBusError error; - - dbus_error_init(&error); - -/* avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", */ -/* dbus_message_get_interface(m), */ -/* dbus_message_get_path(m), */ -/* dbus_message_get_member(m)); */ - - if (dbus_message_is_signal(m, DBUS_INTERFACE_LOCAL, "Disconnected")) { - struct timeval tv; - - if (server->reconnect) { - avahi_log_warn("Disconnected from D-Bus, trying to reconnect in %ims...", RECONNECT_MSEC); - - dbus_disconnect(); - - avahi_elapse_time(&tv, RECONNECT_MSEC, 0); - - if (server->reconnect_timeout) - server->poll_api->timeout_update(server->reconnect_timeout, &tv); - else - server->reconnect_timeout = server->poll_api->timeout_new(server->poll_api, &tv, reconnect_callback, NULL); - } else { - avahi_log_warn("Disconnected from D-Bus, exiting."); - raise(SIGTERM); - } - - return DBUS_HANDLER_RESULT_HANDLED; - - } else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameAcquired")) { - char *name; - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing NameAcquired message"); - goto fail; - } - -/* avahi_log_info(__FILE__": name acquired (%s)", name); */ - return DBUS_HANDLER_RESULT_HANDLED; - - } else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { - char *name, *old, *new; - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &old, DBUS_TYPE_STRING, &new, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing NameOwnerChanged message"); - goto fail; - } - - if (!*new) { - Client *client; - - if ((client = client_get(name, FALSE))) { - avahi_log_debug(__FILE__": client %s vanished.", name); - client_free(client); - } - } - } - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAHI_GCC_UNUSED void *userdata) { - DBusError error; - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.Server.xml"); - - else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostName")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing Server::GetHostName message"); - goto fail; - } - - return avahi_dbus_respond_string(c, m, avahi_server_get_host_name(avahi_server)); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "SetHostName")) { - - char *name; - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing Server::SetHostName message"); - goto fail; - } - - if (avahi_server_set_host_name(avahi_server, name) < 0) - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - - avahi_log_info("Changing host name to '%s'.", name); - - return avahi_dbus_respond_ok(c, m); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetDomainName")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing Server::GetDomainName message"); - goto fail; - } - - return avahi_dbus_respond_string(c, m, avahi_server_get_domain_name(avahi_server)); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostNameFqdn")) { - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { - avahi_log_warn("Error parsing Server::GetHostNameFqdn message"); - goto fail; - } - - return avahi_dbus_respond_string(c, m, avahi_server_get_host_name_fqdn(avahi_server)); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "IsNSSSupportAvailable")) { - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { - avahi_log_warn("Error parsing Server::IsNSSSupportAvailable message"); - goto fail; - } - - return avahi_dbus_respond_boolean(c, m, nss_support); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetVersionString")) { - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { - avahi_log_warn("Error parsing Server::GetVersionString message"); - goto fail; - } - - return avahi_dbus_respond_string(c, m, PACKAGE_STRING); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAPIVersion")) { - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { - avahi_log_warn("Error parsing Server::GetAPIVersion message"); - goto fail; - } - - return avahi_dbus_respond_uint32(c, m, AVAHI_DBUS_API_VERSION); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetState")) { - AvahiServerState state; - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { - avahi_log_warn("Error parsing Server::GetState message"); - goto fail; - } - - state = avahi_server_get_state(avahi_server); - return avahi_dbus_respond_int32(c, m, (int32_t) state); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetLocalServiceCookie")) { - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { - avahi_log_warn("Error parsing Server::GetLocalServiceCookie message"); - goto fail; - } - - return avahi_dbus_respond_uint32(c, m, avahi_server_get_local_service_cookie(avahi_server)); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceNameByIndex")) { - int32_t idx; - char name[IF_NAMESIZE]; - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INT32, &idx, DBUS_TYPE_INVALID))) { - avahi_log_warn("Error parsing Server::GetNetworkInterfaceNameByIndex message"); - goto fail; - } - -#ifdef VALGRIND_WORKAROUND - return respond_string(c, m, "blah"); -#else - if ((!if_indextoname(idx, name))) { - char txt[256]; - snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno)); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_OS, txt); - } - - return avahi_dbus_respond_string(c, m, name); -#endif - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceIndexByName")) { - char *n; - int32_t idx; - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) { - avahi_log_warn("Error parsing Server::GetNetworkInterfaceIndexByName message"); - goto fail; - } - -#ifdef VALGRIND_WORKAROUND - return respond_int32(c, m, 1); -#else - if (!(idx = if_nametoindex(n))) { - char txt[256]; - snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno)); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_OS, txt); - } - - return avahi_dbus_respond_int32(c, m, idx); -#endif - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeHostName")) { - char *n, * t; - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) { - avahi_log_warn("Error parsing Server::GetAlternativeHostName message"); - goto fail; - } - - t = avahi_alternative_host_name(n); - avahi_dbus_respond_string(c, m, t); - avahi_free(t); - - return DBUS_HANDLER_RESULT_HANDLED; - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeServiceName")) { - char *n, *t; - - if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) { - avahi_log_warn("Error parsing Server::GetAlternativeServiceName message"); - goto fail; - } - - t = avahi_alternative_service_name(n); - avahi_dbus_respond_string(c, m, t); - avahi_free(t); - - return DBUS_HANDLER_RESULT_HANDLED; - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "EntryGroupNew")) { - Client *client; - EntryGroupInfo *i; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_entry_group_impl, - NULL, - NULL, - NULL, - NULL - }; - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing Server::EntryGroupNew message"); - goto fail; - } - - if (server->disable_user_service_publishing) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_PERMITTED, NULL); - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - i = avahi_new(EntryGroupInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - i->n_entries = 0; - AVAHI_LLIST_PREPEND(EntryGroupInfo, entry_groups, client->entry_groups, i); - client->n_objects++; - - if (!(i->entry_group = avahi_s_entry_group_new(avahi_server, avahi_dbus_entry_group_callback, i))) { - avahi_dbus_entry_group_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - i->path = avahi_strdup_printf("/Client%u/EntryGroup%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveHostName")) { - Client *client; - int32_t interface, protocol, aprotocol; - uint32_t flags; - char *name; - SyncHostNameResolverInfo *i; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !name) { - avahi_log_warn("Error parsing Server::ResolveHostName message"); - goto fail; - } - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - i = avahi_new(SyncHostNameResolverInfo, 1); - i->client = client; - i->message = dbus_message_ref(m); - AVAHI_LLIST_PREPEND(SyncHostNameResolverInfo, sync_host_name_resolvers, client->sync_host_name_resolvers, i); - client->n_objects++; - - if (!(i->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, (AvahiProtocol) aprotocol, (AvahiLookupFlags) flags, avahi_dbus_sync_host_name_resolver_callback, i))) { - avahi_dbus_sync_host_name_resolver_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - return DBUS_HANDLER_RESULT_HANDLED; - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveAddress")) { - Client *client; - int32_t interface, protocol; - uint32_t flags; - char *address; - SyncAddressResolverInfo *i; - AvahiAddress a; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &address, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !address) { - avahi_log_warn("Error parsing Server::ResolveAddress message"); - goto fail; - } - - if (!avahi_address_parse(address, AVAHI_PROTO_UNSPEC, &a)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_ADDRESS, NULL); - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - i = avahi_new(SyncAddressResolverInfo, 1); - i->client = client; - i->message = dbus_message_ref(m); - AVAHI_LLIST_PREPEND(SyncAddressResolverInfo, sync_address_resolvers, client->sync_address_resolvers, i); - client->n_objects++; - - if (!(i->address_resolver = avahi_s_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, (AvahiLookupFlags) flags, avahi_dbus_sync_address_resolver_callback, i))) { - avahi_dbus_sync_address_resolver_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - return DBUS_HANDLER_RESULT_HANDLED; - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew")) { - Client *client; - DomainBrowserInfo *i; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_domain_browser_impl, - NULL, - NULL, - NULL, - NULL - }; - int32_t interface, protocol, type; - uint32_t flags; - char *domain; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INT32, &type, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || type < 0 || type >= AVAHI_DOMAIN_BROWSER_MAX) { - avahi_log_warn("Error parsing Server::DomainBrowserNew message"); - goto fail; - } - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - if (!*domain) - domain = NULL; - - i = avahi_new(DomainBrowserInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - AVAHI_LLIST_PREPEND(DomainBrowserInfo, domain_browsers, client->domain_browsers, i); - client->n_objects++; - - if (!(i->domain_browser = avahi_s_domain_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, (AvahiDomainBrowserType) type, (AvahiLookupFlags) flags, avahi_dbus_domain_browser_callback, i))) { - avahi_dbus_domain_browser_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - i->path = avahi_strdup_printf("/Client%u/DomainBrowser%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceTypeBrowserNew")) { - Client *client; - ServiceTypeBrowserInfo *i; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_service_type_browser_impl, - NULL, - NULL, - NULL, - NULL - }; - int32_t interface, protocol; - uint32_t flags; - char *domain; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing Server::ServiceTypeBrowserNew message"); - goto fail; - } - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - if (!*domain) - domain = NULL; - - i = avahi_new(ServiceTypeBrowserInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - AVAHI_LLIST_PREPEND(ServiceTypeBrowserInfo, service_type_browsers, client->service_type_browsers, i); - client->n_objects++; - - if (!(i->service_type_browser = avahi_s_service_type_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, domain, (AvahiLookupFlags) flags, avahi_dbus_service_type_browser_callback, i))) { - avahi_dbus_service_type_browser_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - i->path = avahi_strdup_printf("/Client%u/ServiceTypeBrowser%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew")) { - Client *client; - ServiceBrowserInfo *i; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_service_browser_impl, - NULL, - NULL, - NULL, - NULL - }; - int32_t interface, protocol; - uint32_t flags; - char *domain, *type; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !type) { - avahi_log_warn("Error parsing Server::ServiceBrowserNew message"); - goto fail; - } - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - if (!*domain) - domain = NULL; - - i = avahi_new(ServiceBrowserInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - AVAHI_LLIST_PREPEND(ServiceBrowserInfo, service_browsers, client->service_browsers, i); - client->n_objects++; - - if (!(i->service_browser = avahi_s_service_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, type, domain, (AvahiLookupFlags) flags, avahi_dbus_service_browser_callback, i))) { - avahi_dbus_service_browser_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - i->path = avahi_strdup_printf("/Client%u/ServiceBrowser%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveService")) { - Client *client; - int32_t interface, protocol, aprotocol; - uint32_t flags; - char *name, *type, *domain; - SyncServiceResolverInfo *i; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !type) { - avahi_log_warn("Error parsing Server::ResolveService message"); - goto fail; - } - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - if (!*domain) - domain = NULL; - - if (!*name) - name = NULL; - - i = avahi_new(SyncServiceResolverInfo, 1); - i->client = client; - i->message = dbus_message_ref(m); - AVAHI_LLIST_PREPEND(SyncServiceResolverInfo, sync_service_resolvers, client->sync_service_resolvers, i); - client->n_objects++; - - if (!(i->service_resolver = avahi_s_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, (AvahiLookupFlags) flags, avahi_dbus_sync_service_resolver_callback, i))) { - avahi_dbus_sync_service_resolver_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - return DBUS_HANDLER_RESULT_HANDLED; - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew")) { - Client *client; - int32_t interface, protocol, aprotocol; - uint32_t flags; - char *name, *type, *domain; - AsyncServiceResolverInfo *i; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_async_service_resolver_impl, - NULL, - NULL, - NULL, - NULL - }; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !type) { - avahi_log_warn("Error parsing Server::ServiceResolverNew message"); - goto fail; - } - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn(__FILE__": Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - if (!*domain) - domain = NULL; - - if (!*name) - name = NULL; - - i = avahi_new(AsyncServiceResolverInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - AVAHI_LLIST_PREPEND(AsyncServiceResolverInfo, async_service_resolvers, client->async_service_resolvers, i); - client->n_objects++; - - if (!(i->service_resolver = avahi_s_service_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, type, domain, (AvahiProtocol) aprotocol, (AvahiLookupFlags) flags, avahi_dbus_async_service_resolver_callback, i))) { - avahi_dbus_async_service_resolver_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - -/* avahi_log_debug(__FILE__": [%s], new service resolver for <%s.%s.%s>", i->path, name, type, domain); */ - - i->path = avahi_strdup_printf("/Client%u/ServiceResolver%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "HostNameResolverNew")) { - Client *client; - int32_t interface, protocol, aprotocol; - uint32_t flags; - char *name; - AsyncHostNameResolverInfo *i; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_async_host_name_resolver_impl, - NULL, - NULL, - NULL, - NULL - }; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_INT32, &aprotocol, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !name) { - avahi_log_warn("Error parsing Server::HostNameResolverNew message"); - goto fail; - } - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn(__FILE__": Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - i = avahi_new(AsyncHostNameResolverInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - AVAHI_LLIST_PREPEND(AsyncHostNameResolverInfo, async_host_name_resolvers, client->async_host_name_resolvers, i); - client->n_objects++; - - if (!(i->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, name, aprotocol, (AvahiLookupFlags) flags, avahi_dbus_async_host_name_resolver_callback, i))) { - avahi_dbus_async_host_name_resolver_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - i->path = avahi_strdup_printf("/Client%u/HostNameResolver%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "AddressResolverNew")) { - Client *client; - int32_t interface, protocol; - uint32_t flags; - char *address; - AsyncAddressResolverInfo *i; - AvahiAddress a; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_async_address_resolver_impl, - NULL, - NULL, - NULL, - NULL - }; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &address, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !address) { - avahi_log_warn("Error parsing Server::AddressResolverNew message"); - goto fail; - } - - if (!avahi_address_parse(address, AVAHI_PROTO_UNSPEC, &a)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_ADDRESS, NULL); - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn(__FILE__": Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - i = avahi_new(AsyncAddressResolverInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - AVAHI_LLIST_PREPEND(AsyncAddressResolverInfo, async_address_resolvers, client->async_address_resolvers, i); - client->n_objects++; - - if (!(i->address_resolver = avahi_s_address_resolver_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, &a, (AvahiLookupFlags) flags, avahi_dbus_async_address_resolver_callback, i))) { - avahi_dbus_async_address_resolver_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - i->path = avahi_strdup_printf("/Client%u/AddressResolver%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - - } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew")) { - Client *client; - RecordBrowserInfo *i; - static const DBusObjectPathVTable vtable = { - NULL, - avahi_dbus_msg_record_browser_impl, - NULL, - NULL, - NULL, - NULL - }; - int32_t interface, protocol; - uint32_t flags; - char *name; - uint16_t type, clazz; - AvahiKey *key; - - if (!dbus_message_get_args( - m, &error, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT16, &clazz, - DBUS_TYPE_UINT16, &type, - DBUS_TYPE_UINT32, &flags, - DBUS_TYPE_INVALID) || !name) { - avahi_log_warn("Error parsing Server::RecordBrowserNew message"); - goto fail; - } - - if (!avahi_is_valid_domain_name(name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_DOMAIN_NAME, NULL); - - if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { - avahi_log_warn("Too many clients, client request failed."); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); - } - - if (client->n_objects >= server->n_objects_per_client_max) { - avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); - return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); - } - - i = avahi_new(RecordBrowserInfo, 1); - i->id = ++client->current_id; - i->client = client; - i->path = NULL; - AVAHI_LLIST_PREPEND(RecordBrowserInfo, record_browsers, client->record_browsers, i); - client->n_objects++; - - key = avahi_key_new(name, clazz, type); - assert(key); - - if (!(i->record_browser = avahi_s_record_browser_new(avahi_server, (AvahiIfIndex) interface, (AvahiProtocol) protocol, key, (AvahiLookupFlags) flags, avahi_dbus_record_browser_callback, i))) { - avahi_key_unref(key); - avahi_dbus_record_browser_free(i); - return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } - - avahi_key_unref(key); - - i->path = avahi_strdup_printf("/Client%u/RecordBrowser%u", client->id, i->id); - dbus_connection_register_object_path(c, i->path, &vtable, i); - return avahi_dbus_respond_path(c, m, i->path); - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -void dbus_protocol_server_state_changed(AvahiServerState state) { - DBusMessage *m; - int32_t t; - const char *e; - - if (!server || !server->bus) - return; - - m = dbus_message_new_signal(AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "StateChanged"); - - if (!m) { - avahi_log_error("Failed allocate message"); - return; - } - - t = (int32_t) state; - - if (state == AVAHI_SERVER_COLLISION) - e = AVAHI_DBUS_ERR_COLLISION; - else if (state == AVAHI_SERVER_FAILURE) - e = avahi_error_number_to_dbus(avahi_server_errno(avahi_server)); - else - e = AVAHI_DBUS_ERR_OK; - - dbus_message_append_args(m, DBUS_TYPE_INT32, &t, DBUS_TYPE_STRING, &e, DBUS_TYPE_INVALID); - dbus_connection_send(server->bus, m, NULL); - dbus_message_unref(m); -} - -static int dbus_connect(void) { - DBusError error; - - static const DBusObjectPathVTable server_vtable = { - NULL, - msg_server_impl, - NULL, - NULL, - NULL, - NULL - }; - - assert(server); - assert(!server->bus); - - dbus_error_init(&error); - -#ifdef HAVE_DBUS_BUS_GET_PRIVATE - if (!(server->bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error))) { - assert(dbus_error_is_set(&error)); - avahi_log_error("dbus_bus_get_private(): %s", error.message); - goto fail; - } -#else - { - const char *a; - - if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a) - a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS; - - if (!(server->bus = dbus_connection_open_private(a, &error))) { - assert(dbus_error_is_set(&error)); - avahi_log_error("dbus_bus_open_private(): %s", error.message); - goto fail; - } - - if (!dbus_bus_register(server->bus, &error)) { - assert(dbus_error_is_set(&error)); - avahi_log_error("dbus_bus_register(): %s", error.message); - goto fail; - } - } -#endif - - if (avahi_dbus_connection_glue(server->bus, server->poll_api) < 0) { - avahi_log_error("avahi_dbus_connection_glue() failed"); - goto fail; - } - - dbus_connection_set_exit_on_disconnect(server->bus, FALSE); - - if (dbus_bus_request_name( - server->bus, - AVAHI_DBUS_NAME, -#if (DBUS_VERSION_MAJOR == 0) && (DBUS_VERSION_MINOR < 60) - DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT, -#else - DBUS_NAME_FLAG_DO_NOT_QUEUE, -#endif - &error) != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - if (dbus_error_is_set(&error)) { - avahi_log_error("dbus_bus_request_name(): %s", error.message); - goto fail; - } - - avahi_log_error("Failed to acquire D-Bus name '"AVAHI_DBUS_NAME"'"); - goto fail; - } - - if (!(dbus_connection_add_filter(server->bus, msg_signal_filter_impl, (void*) server->poll_api, NULL))) { - avahi_log_error("dbus_connection_add_filter() failed"); - goto fail; - } - - dbus_bus_add_match(server->bus, "type='signal',""interface='" DBUS_INTERFACE_DBUS "'", &error); - - if (dbus_error_is_set(&error)) { - avahi_log_error("dbus_bus_add_match(): %s", error.message); - goto fail; - } - - if (!(dbus_connection_register_object_path(server->bus, AVAHI_DBUS_PATH_SERVER, &server_vtable, NULL))) { - avahi_log_error("dbus_connection_register_object_path() failed"); - goto fail; - } - - return 0; -fail: - - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - if (server->bus) { -#ifdef HAVE_DBUS_CONNECTION_CLOSE - dbus_connection_close(server->bus); -#else - dbus_connection_disconnect(server->bus); -#endif - dbus_connection_unref(server->bus); - server->bus = NULL; - } - - return -1; -} - -static void dbus_disconnect(void) { - assert(server); - - while (server->clients) - client_free(server->clients); - - assert(server->n_clients == 0); - - if (server->bus) { -#ifdef HAVE_DBUS_CONNECTION_CLOSE - dbus_connection_close(server->bus); -#else - dbus_connection_disconnect(server->bus); -#endif - dbus_connection_unref(server->bus); - server->bus = NULL; - } -} - -int dbus_protocol_setup(const AvahiPoll *poll_api, - int _disable_user_service_publishing, - int _n_clients_max, - int _n_objects_per_client_max, - int _n_entries_per_entry_group_max, - int force) { - - - server = avahi_new(Server, 1); - AVAHI_LLIST_HEAD_INIT(Clients, server->clients); - server->current_id = 0; - server->n_clients = 0; - server->bus = NULL; - server->poll_api = poll_api; - server->reconnect_timeout = NULL; - server->reconnect = force; - server->disable_user_service_publishing = _disable_user_service_publishing; - server->n_clients_max = _n_clients_max > 0 ? _n_clients_max : DEFAULT_CLIENTS_MAX; - server->n_objects_per_client_max = _n_objects_per_client_max > 0 ? _n_objects_per_client_max : DEFAULT_OBJECTS_PER_CLIENT_MAX; - server->n_entries_per_entry_group_max = _n_entries_per_entry_group_max > 0 ? _n_entries_per_entry_group_max : DEFAULT_ENTRIES_PER_ENTRY_GROUP_MAX; - - if (dbus_connect() < 0) { - struct timeval tv; - - if (!force) - goto fail; - - avahi_log_warn("WARNING: Failed to contact D-Bus daemon, retrying in %ims.", RECONNECT_MSEC); - - avahi_elapse_time(&tv, RECONNECT_MSEC, 0); - server->reconnect_timeout = server->poll_api->timeout_new(server->poll_api, &tv, reconnect_callback, NULL); - } - - return 0; - -fail: - if (server->bus) { -#ifdef HAVE_DBUS_CONNECTION_CLOSE - dbus_connection_close(server->bus); -#else - dbus_connection_disconnect(server->bus); -#endif - - dbus_connection_unref(server->bus); - } - - avahi_free(server); - server = NULL; - return -1; -} - -void dbus_protocol_shutdown(void) { - - if (server) { - dbus_disconnect(); - - if (server->reconnect_timeout) - server->poll_api->timeout_free(server->reconnect_timeout); - - avahi_free(server); - server = NULL; - } -} diff --git a/avahi-daemon/dbus-protocol.h b/avahi-daemon/dbus-protocol.h deleted file mode 100644 index 2184487..0000000 --- a/avahi-daemon/dbus-protocol.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef foodbusprotocolhfoo -#define foodbusprotocolhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -int dbus_protocol_setup(const AvahiPoll *poll_api, - int _disable_user_service_publishing, - int _n_clients_max, - int _n_objects_per_client_max, - int _n_entries_per_entry_group_max, - int force); -void dbus_protocol_shutdown(void); -void dbus_protocol_server_state_changed(AvahiServerState state); - -#endif diff --git a/avahi-daemon/dbus-record-browser.c b/avahi-daemon/dbus-record-browser.c deleted file mode 100644 index c0337cf..0000000 --- a/avahi-daemon/dbus-record-browser.c +++ /dev/null @@ -1,164 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" - -void avahi_dbus_record_browser_free(RecordBrowserInfo *i) { - assert(i); - - if (i->record_browser) - avahi_s_record_browser_free(i->record_browser); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - AVAHI_LLIST_REMOVE(RecordBrowserInfo, record_browsers, i->client->record_browsers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -DBusHandlerResult avahi_dbus_msg_record_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - RecordBrowserInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.RecordBrowser.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing RecordBrowser::Free message"); - goto fail; - } - - avahi_dbus_record_browser_free(i); - return avahi_dbus_respond_ok(c, m); - - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -void avahi_dbus_record_browser_callback( - AvahiSRecordBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - AvahiRecord *record, - AvahiLookupResultFlags flags, - void* userdata) { - - RecordBrowserInfo *i = userdata; - DBusMessage *m = NULL; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(b); - assert(i); - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, avahi_dbus_map_browse_signal_name(event)); - - if (!m) { - avahi_log_error("Failed allocate message"); - return; - } - - if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { - uint8_t rdata[0xFFFF]; - size_t size; - assert(record); - - if (!(dbus_message_append_args( - m, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &record->key->name, - DBUS_TYPE_UINT16, &record->key->clazz, - DBUS_TYPE_UINT16, &record->key->type, - DBUS_TYPE_INVALID))) - goto fail; - - if ((size = avahi_rdata_serialize(record, rdata, sizeof(rdata))) == (size_t) -1 || - avahi_dbus_append_rdata(m, rdata, size) < 0) { - avahi_log_debug(__FILE__": Failed to append rdata"); - dbus_message_unref(m); - return; - } - - dbus_message_append_args( - m, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - - } else if (event == AVAHI_BROWSER_FAILURE) - avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); - dbus_connection_send(server->bus, m, NULL); - dbus_message_unref(m); - - return; - -fail: - - if (m) - dbus_message_unref(m); -} diff --git a/avahi-daemon/dbus-service-browser.c b/avahi-daemon/dbus-service-browser.c deleted file mode 100644 index 962dca0..0000000 --- a/avahi-daemon/dbus-service-browser.c +++ /dev/null @@ -1,144 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" - -void avahi_dbus_service_browser_free(ServiceBrowserInfo *i) { - assert(i); - - if (i->service_browser) - avahi_s_service_browser_free(i->service_browser); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - - AVAHI_LLIST_REMOVE(ServiceBrowserInfo, service_browsers, i->client->service_browsers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -DBusHandlerResult avahi_dbus_msg_service_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - ServiceBrowserInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.ServiceBrowser.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing ServiceBrowser::Free message"); - goto fail; - } - - avahi_dbus_service_browser_free(i); - return avahi_dbus_respond_ok(c, m); - - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -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) { - ServiceBrowserInfo *i = userdata; - DBusMessage *m; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(b); - assert(i); - - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, avahi_dbus_map_browse_signal_name(event)); - - if (!m) { - avahi_log_error("Failed allocate message"); - return; - } - - if (event == AVAHI_BROWSER_NEW) { - /* Patch in AVAHI_LOOKUP_RESULT_OUR_OWN */ - - if (avahi_dbus_is_our_own_service(i->client, interface, protocol, name, type, domain) > 0) - flags |= AVAHI_LOOKUP_RESULT_OUR_OWN; - } - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { - assert(name); - assert(type); - assert(domain); - - dbus_message_append_args( - m, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - } else if (event == AVAHI_BROWSER_FAILURE) - avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); - dbus_connection_send(server->bus, m, NULL); - dbus_message_unref(m); -} diff --git a/avahi-daemon/dbus-service-type-browser.c b/avahi-daemon/dbus-service-type-browser.c deleted file mode 100644 index 20afdbe..0000000 --- a/avahi-daemon/dbus-service-type-browser.c +++ /dev/null @@ -1,134 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" - -void avahi_dbus_service_type_browser_free(ServiceTypeBrowserInfo *i) { - assert(i); - - if (i->service_type_browser) - avahi_s_service_type_browser_free(i->service_type_browser); - - if (i->path) { - dbus_connection_unregister_object_path(server->bus, i->path); - avahi_free(i->path); - } - - AVAHI_LLIST_REMOVE(ServiceTypeBrowserInfo, service_type_browsers, i->client->service_type_browsers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -DBusHandlerResult avahi_dbus_msg_service_type_browser_impl(DBusConnection *c, DBusMessage *m, void *userdata) { - DBusError error; - ServiceTypeBrowserInfo *i = userdata; - - assert(c); - assert(m); - assert(i); - - dbus_error_init(&error); - - avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", - dbus_message_get_interface(m), - dbus_message_get_path(m), - dbus_message_get_member(m)); - - /* Introspection */ - if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.ServiceTypeBrowser.xml"); - - /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) - return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Free")) { - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_warn("Error parsing ServiceTypeBrowser::Free message"); - goto fail; - } - - avahi_dbus_service_type_browser_free(i); - return avahi_dbus_respond_ok(c, m); - - } - - avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -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) { - ServiceTypeBrowserInfo *i = userdata; - DBusMessage *m; - int32_t i_interface, i_protocol; - uint32_t u_flags; - - assert(b); - assert(i); - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - u_flags = (uint32_t) flags; - - m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, avahi_dbus_map_browse_signal_name(event)); - - if (!m) { - avahi_log_error("Failed allocate message"); - return; - } - - if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { - assert(type); - assert(domain); - dbus_message_append_args( - m, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - } else if (event == AVAHI_BROWSER_FAILURE) - avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); - dbus_connection_send(server->bus, m, NULL); - dbus_message_unref(m); -} diff --git a/avahi-daemon/dbus-sync-address-resolver.c b/avahi-daemon/dbus-sync-address-resolver.c deleted file mode 100644 index 9845420..0000000 --- a/avahi-daemon/dbus-sync-address-resolver.c +++ /dev/null @@ -1,96 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" -#include "main.h" - -void avahi_dbus_sync_address_resolver_free(SyncAddressResolverInfo *i) { - assert(i); - - if (i->address_resolver) - avahi_s_address_resolver_free(i->address_resolver); - dbus_message_unref(i->message); - AVAHI_LLIST_REMOVE(SyncAddressResolverInfo, sync_address_resolvers, i->client->sync_address_resolvers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -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) { - SyncAddressResolverInfo *i = userdata; - - assert(r); - assert(address); - assert(i); - - if (event == AVAHI_RESOLVER_FOUND) { - char t[AVAHI_ADDRESS_STR_MAX], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - DBusMessage *reply; - - assert(host_name); - avahi_address_snprint(t, sizeof(t), address); - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) address->proto; - u_flags = (uint32_t) flags; - - reply = dbus_message_new_method_return(i->message); - - if (!reply) { - avahi_log_error("Failed allocate message"); - goto finish; - } - - dbus_message_append_args( - reply, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_STRING, &pt, - DBUS_TYPE_STRING, &host_name, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - - dbus_connection_send(server->bus, reply, NULL); - dbus_message_unref(reply); - } else { - assert(event == AVAHI_RESOLVER_FAILURE); - avahi_dbus_respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL); - } - -finish: - avahi_dbus_sync_address_resolver_free(i); -} diff --git a/avahi-daemon/dbus-sync-host-name-resolver.c b/avahi-daemon/dbus-sync-host-name-resolver.c deleted file mode 100644 index e511327..0000000 --- a/avahi-daemon/dbus-sync-host-name-resolver.c +++ /dev/null @@ -1,96 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" -#include "main.h" - -void avahi_dbus_sync_host_name_resolver_free(SyncHostNameResolverInfo *i) { - assert(i); - - if (i->host_name_resolver) - avahi_s_host_name_resolver_free(i->host_name_resolver); - dbus_message_unref(i->message); - AVAHI_LLIST_REMOVE(SyncHostNameResolverInfo, sync_host_name_resolvers, i->client->sync_host_name_resolvers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -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) { - SyncHostNameResolverInfo *i = userdata; - - assert(r); - assert(host_name); - assert(i); - - if (event == AVAHI_RESOLVER_FOUND) { - char t[AVAHI_ADDRESS_STR_MAX], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - DBusMessage *reply; - - assert(a); - avahi_address_snprint(t, sizeof(t), a); - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - i_aprotocol = (int32_t) a->proto; - u_flags = (uint32_t) flags; - - reply = dbus_message_new_method_return(i->message); - - if (!reply) { - avahi_log_error("Failed allocate message"); - goto finish; - } - - dbus_message_append_args( - reply, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &host_name, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_STRING, &pt, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - - dbus_connection_send(server->bus, reply, NULL); - dbus_message_unref(reply); - } else { - assert(event == AVAHI_RESOLVER_FAILURE); - avahi_dbus_respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL); - } - -finish: - avahi_dbus_sync_host_name_resolver_free(i); -} diff --git a/avahi-daemon/dbus-sync-service-resolver.c b/avahi-daemon/dbus-sync-service-resolver.c deleted file mode 100644 index ed7276a..0000000 --- a/avahi-daemon/dbus-sync-service-resolver.c +++ /dev/null @@ -1,135 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include - -#include "dbus-util.h" -#include "dbus-internal.h" -#include "main.h" - -void avahi_dbus_sync_service_resolver_free(SyncServiceResolverInfo *i) { - assert(i); - - if (i->service_resolver) - avahi_s_service_resolver_free(i->service_resolver); - dbus_message_unref(i->message); - AVAHI_LLIST_REMOVE(SyncServiceResolverInfo, sync_service_resolvers, i->client->sync_service_resolvers, i); - - assert(i->client->n_objects >= 1); - i->client->n_objects--; - - avahi_free(i); -} - -void avahi_dbus_sync_service_resolver_callback( - AvahiSServiceResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AvahiLookupResultFlags flags, - void* userdata) { - - SyncServiceResolverInfo *i = userdata; - - assert(r); - assert(i); - - if (event == AVAHI_RESOLVER_FOUND) { - char t[AVAHI_ADDRESS_STR_MAX], *pt = t; - int32_t i_interface, i_protocol, i_aprotocol; - uint32_t u_flags; - DBusMessage *reply; - - assert(host_name); - - if (!name) - name = ""; - - if (a) - avahi_address_snprint(t, sizeof(t), a); - else - t[0] = 0; - - /* Patch in AVAHI_LOOKUP_RESULT_OUR_OWN */ - - if (avahi_dbus_is_our_own_service(i->client, interface, protocol, name, type, domain) > 0) - flags |= AVAHI_LOOKUP_RESULT_OUR_OWN; - - i_interface = (int32_t) interface; - i_protocol = (int32_t) protocol; - if (a) - i_aprotocol = (int32_t) a->proto; - else - i_aprotocol = AVAHI_PROTO_UNSPEC; - u_flags = (uint32_t) flags; - - reply = dbus_message_new_method_return(i->message); - - if (!reply) { - avahi_log_error("Failed allocate message"); - goto finish; - } - - dbus_message_append_args( - reply, - DBUS_TYPE_INT32, &i_interface, - DBUS_TYPE_INT32, &i_protocol, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &type, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_STRING, &host_name, - DBUS_TYPE_INT32, &i_aprotocol, - DBUS_TYPE_STRING, &pt, - DBUS_TYPE_UINT16, &port, - DBUS_TYPE_INVALID); - - avahi_dbus_append_string_list(reply, txt); - - dbus_message_append_args( - reply, - DBUS_TYPE_UINT32, &u_flags, - DBUS_TYPE_INVALID); - - dbus_connection_send(server->bus, reply, NULL); - dbus_message_unref(reply); - } else { - assert(event == AVAHI_RESOLVER_FAILURE); - - avahi_dbus_respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL); - } - -finish: - avahi_dbus_sync_service_resolver_free(i); -} diff --git a/avahi-daemon/dbus-util.c b/avahi-daemon/dbus-util.c deleted file mode 100644 index 2983b29..0000000 --- a/avahi-daemon/dbus-util.c +++ /dev/null @@ -1,435 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifdef ENABLE_CHROOT -#include "chroot.h" -#endif - -#include "main.h" -#include "dbus-util.h" - -DBusHandlerResult avahi_dbus_respond_error(DBusConnection *c, DBusMessage *m, int error, const char *text) { - DBusMessage *reply; - - assert(-error > -AVAHI_OK); - assert(-error < -AVAHI_ERR_MAX); - - if (!text) - text = avahi_strerror(error); - - reply = dbus_message_new_error(m, avahi_error_number_to_dbus(error), text); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return DBUS_HANDLER_RESULT_NEED_MEMORY; - } - - dbus_connection_send(c, reply, NULL); - dbus_message_unref(reply); - - avahi_log_debug(__FILE__": Responding error '%s' (%i)", text, error); - - return DBUS_HANDLER_RESULT_HANDLED; -} - -DBusHandlerResult avahi_dbus_respond_string(DBusConnection *c, DBusMessage *m, const char *text) { - DBusMessage *reply; - - reply = dbus_message_new_method_return(m); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return DBUS_HANDLER_RESULT_NEED_MEMORY; - } - - dbus_message_append_args(reply, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); - dbus_connection_send(c, reply, NULL); - dbus_message_unref(reply); - - return DBUS_HANDLER_RESULT_HANDLED; -} - -DBusHandlerResult avahi_dbus_respond_int32(DBusConnection *c, DBusMessage *m, int32_t i) { - DBusMessage *reply; - - reply = dbus_message_new_method_return(m); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return DBUS_HANDLER_RESULT_NEED_MEMORY; - } - - dbus_message_append_args(reply, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID); - dbus_connection_send(c, reply, NULL); - dbus_message_unref(reply); - - return DBUS_HANDLER_RESULT_HANDLED; -} - -DBusHandlerResult avahi_dbus_respond_uint32(DBusConnection *c, DBusMessage *m, uint32_t u) { - DBusMessage *reply; - - reply = dbus_message_new_method_return(m); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return DBUS_HANDLER_RESULT_NEED_MEMORY; - } - - dbus_message_append_args(reply, DBUS_TYPE_UINT32, &u, DBUS_TYPE_INVALID); - dbus_connection_send(c, reply, NULL); - dbus_message_unref(reply); - - return DBUS_HANDLER_RESULT_HANDLED; -} - -DBusHandlerResult avahi_dbus_respond_boolean(DBusConnection *c, DBusMessage *m, int b) { - DBusMessage *reply; - - reply = dbus_message_new_method_return(m); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return DBUS_HANDLER_RESULT_NEED_MEMORY; - } - - dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID); - dbus_connection_send(c, reply, NULL); - dbus_message_unref(reply); - - return DBUS_HANDLER_RESULT_HANDLED; -} - -DBusHandlerResult avahi_dbus_respond_ok(DBusConnection *c, DBusMessage *m) { - DBusMessage *reply; - - reply = dbus_message_new_method_return(m); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return DBUS_HANDLER_RESULT_NEED_MEMORY; - } - - dbus_connection_send(c, reply, NULL); - dbus_message_unref(reply); - - return DBUS_HANDLER_RESULT_HANDLED; -} - -DBusHandlerResult avahi_dbus_respond_path(DBusConnection *c, DBusMessage *m, const char *path) { - DBusMessage *reply; - - reply = dbus_message_new_method_return(m); - - if (!reply) { - avahi_log_error("Failed allocate message"); - return DBUS_HANDLER_RESULT_NEED_MEMORY; - } - - dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); - dbus_connection_send(c, reply, NULL); - dbus_message_unref(reply); - - return DBUS_HANDLER_RESULT_HANDLED; -} - -void avahi_dbus_append_server_error(DBusMessage *reply) { - const char *t; - - t = avahi_error_number_to_dbus(avahi_server_errno(avahi_server)); - - dbus_message_append_args( - reply, - DBUS_TYPE_STRING, &t, - DBUS_TYPE_INVALID); -} - -const char *avahi_dbus_map_browse_signal_name(AvahiBrowserEvent e) { - switch (e) { - case AVAHI_BROWSER_NEW : return "ItemNew"; - case AVAHI_BROWSER_REMOVE : return "ItemRemove"; - case AVAHI_BROWSER_FAILURE : return "Failure"; - case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CacheExhausted"; - case AVAHI_BROWSER_ALL_FOR_NOW : return "AllForNow"; - } - - abort(); -} - -const char *avahi_dbus_map_resolve_signal_name(AvahiResolverEvent e) { - switch (e) { - case AVAHI_RESOLVER_FOUND : return "Found"; - case AVAHI_RESOLVER_FAILURE : return "Failure"; - } - - abort(); -} - -static char *file_get_contents(const char *fname) { - int fd = -1; - struct stat st; - ssize_t size; - char *buf = NULL; - - assert(fname); - -#ifdef ENABLE_CHROOT - fd = avahi_chroot_helper_get_fd(fname); -#else - fd = open(fname, O_RDONLY); -#endif - - if (fd < 0) { - avahi_log_error("Failed to open %s: %s", fname, strerror(errno)); - goto fail; - } - - if (fstat(fd, &st) < 0) { - avahi_log_error("stat(%s) failed: %s", fname, strerror(errno)); - goto fail; - } - - if (!(S_ISREG(st.st_mode))) { - avahi_log_error("Invalid file %s", fname); - goto fail; - } - - if (st.st_size > 1024*1024) { /** 1MB */ - avahi_log_error("File too large %s", fname); - goto fail; - } - - buf = avahi_new(char, st.st_size+1); - - if ((size = read(fd, buf, st.st_size)) < 0) { - avahi_log_error("read() failed: %s\n", strerror(errno)); - goto fail; - } - - buf[size] = 0; - - close(fd); - - return buf; - -fail: - if (fd >= 0) - close(fd); - - if (buf) - avahi_free(buf); - - return NULL; - -} - -DBusHandlerResult avahi_dbus_handle_introspect(DBusConnection *c, DBusMessage *m, const char *fname) { - char *contents, *path; - DBusError error; - - assert(c); - assert(m); - assert(fname); - - dbus_error_init(&error); - - if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { - avahi_log_error("Error parsing Introspect message: %s", error.message); - goto fail; - } - - path = avahi_strdup_printf("%s/%s", AVAHI_DBUS_INTROSPECTION_DIR, fname); - contents = file_get_contents(path); - avahi_free(path); - - if (!contents) { - avahi_log_error("Failed to load introspection data."); - goto fail; - } - - avahi_dbus_respond_string(c, m, contents); - avahi_free(contents); - - return DBUS_HANDLER_RESULT_HANDLED; - -fail: - if (dbus_error_is_set(&error)) - dbus_error_free(&error); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - -} - -void avahi_dbus_append_string_list(DBusMessage *reply, AvahiStringList *txt) { - AvahiStringList *p; - DBusMessageIter iter, sub; - - assert(reply); - - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub); - - for (p = txt; p; p = p->next) { - DBusMessageIter sub2; - const uint8_t *data = p->text; - - dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2); - dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size); - dbus_message_iter_close_container(&sub, &sub2); - - } - dbus_message_iter_close_container(&iter, &sub); -} - -int avahi_dbus_read_rdata(DBusMessage *m, int idx, void **rdata, uint32_t *size) { - DBusMessageIter iter, sub; - int n, j; - uint8_t *k; - - assert(m); - - dbus_message_iter_init(m, &iter); - - for (j = 0; j < idx; j++) - dbus_message_iter_next(&iter); - - if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || - dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE) - goto fail; - - dbus_message_iter_recurse(&iter, &sub); - dbus_message_iter_get_fixed_array(&sub, &k, &n); - - *rdata = k; - *size = n; - - return 0; - -fail: - avahi_log_warn("Error parsing data"); - - *rdata = NULL; - size = 0; - return -1; -} - -int avahi_dbus_read_strlst(DBusMessage *m, int idx, AvahiStringList **l) { - DBusMessageIter iter, sub; - int j; - AvahiStringList *strlst = NULL; - - assert(m); - assert(l); - - dbus_message_iter_init(m, &iter); - - for (j = 0; j < idx; j++) - dbus_message_iter_next(&iter); - - if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || - dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) - goto fail; - - dbus_message_iter_recurse(&iter, &sub); - - for (;;) { - int at, n; - const uint8_t *k; - DBusMessageIter sub2; - - if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID) - break; - - assert(at == DBUS_TYPE_ARRAY); - - if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) - goto fail; - - dbus_message_iter_recurse(&sub, &sub2); - - k = (const uint8_t*) ""; - n = 0; - dbus_message_iter_get_fixed_array(&sub2, &k, &n); - - if (!k) - k = (const uint8_t*) ""; - - strlst = avahi_string_list_add_arbitrary(strlst, k, n); - - dbus_message_iter_next(&sub); - } - - *l = strlst; - - return 0; - -fail: - avahi_log_warn("Error parsing TXT data"); - - avahi_string_list_free(strlst); - *l = NULL; - return -1; -} - -int avahi_dbus_is_our_own_service(Client *c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) { - AvahiSEntryGroup *g; - - if (avahi_server_get_group_of_service(avahi_server, interface, protocol, name, type, domain, &g) == AVAHI_OK) { - EntryGroupInfo *egi; - - for (egi = c->entry_groups; egi; egi = egi->entry_groups_next) - if (egi->entry_group == g) - return 1; - } - - return 0; -} - -int avahi_dbus_append_rdata(DBusMessage *message, const void *rdata, size_t size) { - DBusMessageIter iter, sub; - - assert(message); - - dbus_message_iter_init_append(message, &iter); - - if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) || - !(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) || - !(dbus_message_iter_close_container(&iter, &sub))) - return -1; - - return 0; -} diff --git a/avahi-daemon/dbus-util.h b/avahi-daemon/dbus-util.h deleted file mode 100644 index a513367..0000000 --- a/avahi-daemon/dbus-util.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef foodbusutilhfoo -#define foodbusutilhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include - -#include -#include - -#include "dbus-internal.h" - -DBusHandlerResult avahi_dbus_respond_error(DBusConnection *c, DBusMessage *m, int error, const char *text); -DBusHandlerResult avahi_dbus_respond_string(DBusConnection *c, DBusMessage *m, const char *text); -DBusHandlerResult avahi_dbus_respond_int32(DBusConnection *c, DBusMessage *m, int32_t i); -DBusHandlerResult avahi_dbus_respond_uint32(DBusConnection *c, DBusMessage *m, uint32_t u); -DBusHandlerResult avahi_dbus_respond_boolean(DBusConnection *c, DBusMessage *m, int b); -DBusHandlerResult avahi_dbus_respond_ok(DBusConnection *c, DBusMessage *m); -DBusHandlerResult avahi_dbus_respond_path(DBusConnection *c, DBusMessage *m, const char *path); - -void avahi_dbus_append_server_error(DBusMessage *reply); - -const char *avahi_dbus_map_browse_signal_name(AvahiBrowserEvent e); - -const char *avahi_dbus_map_resolve_signal_name(AvahiResolverEvent e); - -DBusHandlerResult avahi_dbus_handle_introspect(DBusConnection *c, DBusMessage *m, const char *fname); - -void avahi_dbus_append_string_list(DBusMessage *reply, AvahiStringList *txt); - -int avahi_dbus_read_rdata(DBusMessage *m, int idx, void **rdata, uint32_t *size); -int avahi_dbus_read_strlst(DBusMessage *m, int idx, AvahiStringList **l); - -int avahi_dbus_is_our_own_service(Client *c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain); - -int avahi_dbus_append_rdata(DBusMessage *message, const void *rdata, size_t size); - -#endif diff --git a/avahi-daemon/example.service b/avahi-daemon/example.service deleted file mode 100644 index 46db2ae..0000000 --- a/avahi-daemon/example.service +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - Printer on %h - - - _printer._tcp - 515 - - - - _ipp._tcp - _colour._sub._ipp._tcp - 631 - - - - _uberprinter._tcp - local - quux.local - 4711 - this=is - a=really - bad=example - - - diff --git a/avahi-daemon/hosts b/avahi-daemon/hosts deleted file mode 100644 index 4483340..0000000 --- a/avahi-daemon/hosts +++ /dev/null @@ -1,27 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# This file contains static ip address <-> host name mappings. These -# can be useful to publish services on behalf of a non-avahi enabled -# device. Please bear in mind that host names are expected to be -# fully qualified domain names, i.e. ending in .local! - -# See avahi.hosts(5) for more information on this configuration file! - -# Examples: -# 192.168.0.1 router.local -# 2001::81:1 test.local diff --git a/avahi-daemon/ini-file-parser-test.c b/avahi-daemon/ini-file-parser-test.c deleted file mode 100644 index 6ca6641..0000000 --- a/avahi-daemon/ini-file-parser-test.c +++ /dev/null @@ -1,62 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include - -#include "ini-file-parser.h" - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - - AvahiIniFile *f; - AvahiIniFileGroup *g; - - if (!(f = avahi_ini_file_load("avahi-daemon.conf"))) { - return 1; - } - - printf("%u groups\n", f->n_groups); - - for (g = f->groups; g; g = g->groups_next) { - AvahiIniFilePair *p; - printf("<%s> (%u pairs)\n", g->name, g->n_pairs); - - for (p = g->pairs; p; p = p->pairs_next) { - char **split, **i; - - printf("\t<%s> = ", p->key); - split = avahi_split_csv(p->value); - - for (i = split; *i; i++) - printf("<%s> ", *i); - - avahi_strfreev(split); - - printf("\n"); - } - } - - avahi_ini_file_free(f); - return 0; -} diff --git a/avahi-daemon/ini-file-parser.c b/avahi-daemon/ini-file-parser.c deleted file mode 100644 index 0a99ce3..0000000 --- a/avahi-daemon/ini-file-parser.c +++ /dev/null @@ -1,196 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include "ini-file-parser.h" - -AvahiIniFile* avahi_ini_file_load(const char *fname) { - AvahiIniFile *f; - FILE *fo; - AvahiIniFileGroup *group = NULL; - unsigned line; - - assert(fname); - - if (!(fo = fopen(fname, "r"))) { - avahi_log_error("Failed to open file '%s': %s", fname, strerror(errno)); - return NULL; - } - - f = avahi_new(AvahiIniFile, 1); - AVAHI_LLIST_HEAD_INIT(AvahiIniFileGroup, f->groups); - f->n_groups = 0; - - line = 0; - while (!feof(fo)) { - char ln[256], *s, *e; - AvahiIniFilePair *pair; - - if (!(fgets(ln, sizeof(ln), fo))) - break; - - line++; - - s = ln + strspn(ln, " \t"); - s[strcspn(s, "\r\n")] = 0; - - /* Skip comments and empty lines */ - if (*s == '#' || *s == '%' || *s == 0) - continue; - - if (*s == '[') { - /* new group */ - - if (!(e = strchr(s, ']'))) { - avahi_log_error("Unclosed group header in %s:%u: <%s>", fname, line, s); - goto fail; - } - - *e = 0; - - group = avahi_new(AvahiIniFileGroup, 1); - group->name = avahi_strdup(s+1); - group->n_pairs = 0; - AVAHI_LLIST_HEAD_INIT(AvahiIniFilePair, group->pairs); - - AVAHI_LLIST_PREPEND(AvahiIniFileGroup, groups, f->groups, group); - f->n_groups++; - } else { - - /* Normal assignment */ - if (!(e = strchr(s, '='))) { - avahi_log_error("Missing assignment in %s:%u: <%s>", fname, line, s); - goto fail; - } - - if (!group) { - avahi_log_error("Assignment outside group in %s:%u <%s>", fname, line, s); - goto fail; - } - - /* Split the key and the value */ - *(e++) = 0; - - pair = avahi_new(AvahiIniFilePair, 1); - pair->key = avahi_strdup(s); - pair->value = avahi_strdup(e); - - AVAHI_LLIST_PREPEND(AvahiIniFilePair, pairs, group->pairs, pair); - group->n_pairs++; - } - } - - fclose(fo); - - return f; - -fail: - - if (fo) - fclose(fo); - - if (f) - avahi_ini_file_free(f); - - return NULL; -} - -void avahi_ini_file_free(AvahiIniFile *f) { - AvahiIniFileGroup *g; - assert(f); - - while ((g = f->groups)) { - AvahiIniFilePair *p; - - while ((p = g->pairs)) { - avahi_free(p->key); - avahi_free(p->value); - - AVAHI_LLIST_REMOVE(AvahiIniFilePair, pairs, g->pairs, p); - avahi_free(p); - } - - avahi_free(g->name); - - AVAHI_LLIST_REMOVE(AvahiIniFileGroup, groups, f->groups, g); - avahi_free(g); - } - - avahi_free(f); -} - -char** avahi_split_csv(const char *t) { - unsigned n_comma = 0; - const char *p; - char **r, **i; - - for (p = t; *p; p++) - if (*p == ',') - n_comma++; - - i = r = avahi_new(char*, n_comma+2); - - for (;;) { - size_t n, l = strcspn(t, ","); - const char *c; - - /* Ignore leading blanks */ - for (c = t, n = l; isblank(*c); c++, n--); - - /* Ignore trailing blanks */ - for (; n > 0 && isblank(c[n-1]); n--); - - *(i++) = avahi_strndup(c, n); - - t += l; - - if (*t == 0) - break; - - assert(*t == ','); - t++; - } - - *i = NULL; - - return r; -} - -void avahi_strfreev(char **p) { - char **i; - - if (!p) - return; - - for (i = p; *i; i++) - avahi_free(*i); - - avahi_free(p); -} diff --git a/avahi-daemon/ini-file-parser.h b/avahi-daemon/ini-file-parser.h deleted file mode 100644 index dd3aace..0000000 --- a/avahi-daemon/ini-file-parser.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef fooinifileparserhfoo -#define fooinifileparserhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -typedef struct AvahiIniFile AvahiIniFile; -typedef struct AvahiIniFilePair AvahiIniFilePair; -typedef struct AvahiIniFileGroup AvahiIniFileGroup; - -struct AvahiIniFilePair { - AVAHI_LLIST_FIELDS(AvahiIniFilePair, pairs); - char *key, *value; -}; - -struct AvahiIniFileGroup { - AVAHI_LLIST_FIELDS(AvahiIniFileGroup, groups); - char *name; - - AVAHI_LLIST_HEAD(AvahiIniFilePair, pairs); - unsigned n_pairs; -}; - -struct AvahiIniFile { - AVAHI_LLIST_HEAD(AvahiIniFileGroup, groups); - unsigned n_groups; -}; - - -AvahiIniFile* avahi_ini_file_load(const char *fname); -void avahi_ini_file_free(AvahiIniFile *f); - -char** avahi_split_csv(const char *t); - -void avahi_strfreev(char **); - -#endif diff --git a/avahi-daemon/introspect.dtd b/avahi-daemon/introspect.dtd deleted file mode 100644 index 15d913a..0000000 --- a/avahi-daemon/introspect.dtd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/introspect.xsl b/avahi-daemon/introspect.xsl deleted file mode 100644 index 5d68560..0000000 --- a/avahi-daemon/introspect.xsl +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - DBUS Introspection data - - - - -
-

- interface - -

- -
    - - - - -
  • - - - - -
      - - -
    • - - - - - - - out - - - in - - - - - - - - -
    • -
      -
    - -
  • -
    - -
-
-
- - -
- - - -
  • - annotation - = - -
  • -
    - -
    diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c deleted file mode 100644 index 8c28fd6..0000000 --- a/avahi-daemon/main.c +++ /dev/null @@ -1,1701 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_INOTIFY -#include -#endif - -#ifdef HAVE_KQUEUE -#include -#include -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifdef ENABLE_CHROOT -#include "chroot.h" -#include "caps.h" -#endif - -#include "setproctitle.h" -#include "main.h" -#include "simple-protocol.h" -#include "static-services.h" -#include "static-hosts.h" -#include "ini-file-parser.h" -#include "sd-daemon.h" - -#ifdef HAVE_DBUS -#include "dbus-protocol.h" -#endif - -AvahiServer *avahi_server = NULL; -AvahiSimplePoll *simple_poll_api = NULL; -static char *argv0 = NULL; -int nss_support = 0; - -typedef enum { - DAEMON_RUN, - DAEMON_KILL, - DAEMON_VERSION, - DAEMON_HELP, - DAEMON_RELOAD, - DAEMON_CHECK -} DaemonCommand; - -typedef struct { - AvahiServerConfig server_config; - DaemonCommand command; - int daemonize; - int use_syslog; - char *config_file; -#ifdef HAVE_DBUS - int enable_dbus; - int fail_on_missing_dbus; - unsigned n_clients_max; - unsigned n_objects_per_client_max; - unsigned n_entries_per_entry_group_max; -#endif - int drop_root; - int set_rlimits; -#ifdef ENABLE_CHROOT - int use_chroot; -#endif - int modify_proc_title; - - int disable_user_service_publishing; - int publish_resolv_conf; - char ** publish_dns_servers; - int debug; - - int rlimit_as_set, rlimit_core_set, rlimit_data_set, rlimit_fsize_set, rlimit_nofile_set, rlimit_stack_set; - rlim_t rlimit_as, rlimit_core, rlimit_data, rlimit_fsize, rlimit_nofile, rlimit_stack; - -#ifdef RLIMIT_NPROC - int rlimit_nproc_set; - rlim_t rlimit_nproc; -#endif -} DaemonConfig; - -#define RESOLV_CONF "/etc/resolv.conf" -#define BROWSE_DOMAINS_MAX 16 - -static AvahiSEntryGroup *dns_servers_entry_group = NULL; -static AvahiSEntryGroup *resolv_conf_entry_group = NULL; - -static char **resolv_conf_name_servers = NULL; -static char **resolv_conf_search_domains = NULL; - -static DaemonConfig config; - -static int has_prefix(const char *s, const char *prefix) { - size_t l; - - l = strlen(prefix); - - return strlen(s) >= l && strncmp(s, prefix, l) == 0; -} - -static int load_resolv_conf(void) { - int ret = -1; - FILE *f; - int i = 0, j = 0; - - avahi_strfreev(resolv_conf_name_servers); - resolv_conf_name_servers = NULL; - - avahi_strfreev(resolv_conf_search_domains); - resolv_conf_search_domains = NULL; - -#ifdef ENABLE_CHROOT - f = avahi_chroot_helper_get_file(RESOLV_CONF); -#else - f = fopen(RESOLV_CONF, "r"); -#endif - - if (!f) { - avahi_log_warn("Failed to open "RESOLV_CONF": %s", strerror(errno)); - goto finish; - } - - resolv_conf_name_servers = avahi_new0(char*, AVAHI_WIDE_AREA_SERVERS_MAX+1); - resolv_conf_search_domains = avahi_new0(char*, BROWSE_DOMAINS_MAX+1); - - while (!feof(f)) { - char ln[128]; - char *p; - - if (!(fgets(ln, sizeof(ln), f))) - break; - - ln[strcspn(ln, "\r\n#")] = 0; - p = ln + strspn(ln, "\t "); - - if ((has_prefix(p, "nameserver ") || has_prefix(p, "nameserver\t")) && i < AVAHI_WIDE_AREA_SERVERS_MAX) { - p += 10; - p += strspn(p, "\t "); - p[strcspn(p, "\t ")] = 0; - resolv_conf_name_servers[i++] = avahi_strdup(p); - } - - if ((has_prefix(p, "search ") || has_prefix(p, "search\t") || - has_prefix(p, "domain ") || has_prefix(p, "domain\t"))) { - - p += 6; - - while (j < BROWSE_DOMAINS_MAX) { - size_t k; - - p += strspn(p, "\t "); - k = strcspn(p, "\t "); - - if (k > 0) { - resolv_conf_search_domains[j++] = avahi_strndup(p, k); - p += k; - } - - if (!*p) - break; - } - } - } - - ret = 0; - -finish: - - if (ret != 0) { - avahi_strfreev(resolv_conf_name_servers); - resolv_conf_name_servers = NULL; - - avahi_strfreev(resolv_conf_search_domains); - resolv_conf_search_domains = NULL; - } - - if (f) - fclose(f); - - return ret; -} - -static AvahiSEntryGroup* add_dns_servers(AvahiServer *s, AvahiSEntryGroup* g, char **l) { - char **p; - - assert(s); - assert(l); - - if (!g) - g = avahi_s_entry_group_new(s, NULL, NULL); - - assert(avahi_s_entry_group_is_empty(g)); - - for (p = l; *p; p++) { - AvahiAddress a; - - if (!avahi_address_parse(*p, AVAHI_PROTO_UNSPEC, &a)) - avahi_log_warn("Failed to parse address '%s', ignoring.", *p); - else - if (avahi_server_add_dns_server_address(s, g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, NULL, AVAHI_DNS_SERVER_RESOLVE, &a, 53) < 0) { - avahi_s_entry_group_free(g); - avahi_log_error("Failed to add DNS server address: %s", avahi_strerror(avahi_server_errno(s))); - return NULL; - } - } - - avahi_s_entry_group_commit(g); - - return g; -} - -static void remove_dns_server_entry_groups(void) { - - if (resolv_conf_entry_group) - avahi_s_entry_group_reset(resolv_conf_entry_group); - - if (dns_servers_entry_group) - avahi_s_entry_group_reset(dns_servers_entry_group); -} - -static void update_wide_area_servers(void) { - AvahiAddress a[AVAHI_WIDE_AREA_SERVERS_MAX]; - unsigned n = 0; - char **p; - - if (!resolv_conf_name_servers) { - avahi_server_set_wide_area_servers(avahi_server, NULL, 0); - return; - } - - for (p = resolv_conf_name_servers; *p && n < AVAHI_WIDE_AREA_SERVERS_MAX; p++) { - if (!avahi_address_parse(*p, AVAHI_PROTO_UNSPEC, &a[n])) - avahi_log_warn("Failed to parse address '%s', ignoring.", *p); - else - n++; - } - - avahi_server_set_wide_area_servers(avahi_server, a, n); -} - -static AvahiStringList *filter_duplicate_domains(AvahiStringList *l) { - AvahiStringList *e, *n, *p; - - if (!l) - return l; - - for (p = l, e = l->next; e; e = n) { - n = e->next; - - if (avahi_domain_equal((char*) e->text, (char*) l->text)) { - p->next = e->next; - avahi_free(e); - } else - p = e; - } - - l->next = filter_duplicate_domains(l->next); - return l; -} - -static void update_browse_domains(void) { - AvahiStringList *l; - int n; - char **p; - - if (!resolv_conf_search_domains) { - avahi_server_set_browse_domains(avahi_server, NULL); - return; - } - - l = avahi_string_list_copy(config.server_config.browse_domains); - - for (p = resolv_conf_search_domains, n = 0; *p && n < BROWSE_DOMAINS_MAX; p++, n++) { - if (!avahi_is_valid_domain_name(*p)) - avahi_log_warn("'%s' is no valid domain name, ignoring.", *p); - else - l = avahi_string_list_add(l, *p); - } - - l = filter_duplicate_domains(l); - - avahi_server_set_browse_domains(avahi_server, l); - avahi_string_list_free(l); -} - -static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) { - DaemonConfig *c = userdata; - - assert(s); - assert(c); - - /* This function is possibly called before the global variable - * avahi_server has been set, therefore we do it explicitly */ - - avahi_server = s; - -#ifdef HAVE_DBUS - if (c->enable_dbus && state != AVAHI_SERVER_INVALID && state != AVAHI_SERVER_FAILURE) - dbus_protocol_server_state_changed(state); -#endif - - switch (state) { - case AVAHI_SERVER_RUNNING: - avahi_log_info("Server startup complete. Host name is %s. Local service cookie is %u.", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s)); - sd_notifyf(0, "STATUS=Server startup complete. Host name is %s. Local service cookie is %u.", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s)); - avahi_set_proc_title(argv0, "%s: running [%s]", argv0, avahi_server_get_host_name_fqdn(s)); - - static_service_add_to_server(); - static_hosts_add_to_server(); - - remove_dns_server_entry_groups(); - - if (c->publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0]) - resolv_conf_entry_group = add_dns_servers(s, resolv_conf_entry_group, resolv_conf_name_servers); - - if (c->publish_dns_servers && c->publish_dns_servers[0]) - dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers); - - simple_protocol_restart_queries(); - break; - - case AVAHI_SERVER_COLLISION: { - char *n; - - static_service_remove_from_server(); - static_hosts_remove_from_server(); - remove_dns_server_entry_groups(); - - n = avahi_alternative_host_name(avahi_server_get_host_name(s)); - - avahi_log_warn("Host name conflict, retrying with %s", n); - sd_notifyf(0, "STATUS=Host name conflict, retrying with %s", n); - avahi_set_proc_title(argv0, "%s: collision [%s]", argv0, n); - - avahi_server_set_host_name(s, n); - avahi_free(n); - - break; - } - - case AVAHI_SERVER_FAILURE: - - avahi_log_error("Server error: %s", avahi_strerror(avahi_server_errno(s))); - sd_notifyf(0, "STATUS=Server error: %s", avahi_strerror(avahi_server_errno(s))); - - avahi_simple_poll_quit(simple_poll_api); - break; - - case AVAHI_SERVER_REGISTERING: - - sd_notifyf(0, "STATUS=Registering host name %s", avahi_server_get_host_name_fqdn(s)); - avahi_set_proc_title(argv0, "%s: registering [%s]", argv0, avahi_server_get_host_name_fqdn(s)); - - static_service_remove_from_server(); - static_hosts_remove_from_server(); - remove_dns_server_entry_groups(); - - break; - - case AVAHI_SERVER_INVALID: - break; - - } -} - -static void help(FILE *f) { - fprintf(f, - "%s [options]\n" - " -h --help Show this help\n" - " -D --daemonize Daemonize after startup (implies -s)\n" - " -s --syslog Write log messages to syslog(3) instead of STDERR\n" - " -k --kill Kill a running daemon\n" - " -r --reload Request a running daemon to reload static services\n" - " -c --check Return 0 if a daemon is already running\n" - " -V --version Show version\n" - " -f --file=FILE Load the specified configuration file instead of\n" - " "AVAHI_CONFIG_FILE"\n" - " --no-rlimits Don't enforce resource limits\n" - " --no-drop-root Don't drop privileges\n" -#ifdef ENABLE_CHROOT - " --no-chroot Don't chroot()\n" -#endif - " --no-proc-title Don't modify process title\n" - " --debug Increase verbosity\n", - argv0); -} - - -static int parse_command_line(DaemonConfig *c, int argc, char *argv[]) { - int o; - - enum { - OPTION_NO_RLIMITS = 256, - OPTION_NO_DROP_ROOT, -#ifdef ENABLE_CHROOT - OPTION_NO_CHROOT, -#endif - OPTION_NO_PROC_TITLE, - OPTION_DEBUG - }; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "daemonize", no_argument, NULL, 'D' }, - { "kill", no_argument, NULL, 'k' }, - { "version", no_argument, NULL, 'V' }, - { "file", required_argument, NULL, 'f' }, - { "reload", no_argument, NULL, 'r' }, - { "check", no_argument, NULL, 'c' }, - { "syslog", no_argument, NULL, 's' }, - { "no-rlimits", no_argument, NULL, OPTION_NO_RLIMITS }, - { "no-drop-root", no_argument, NULL, OPTION_NO_DROP_ROOT }, -#ifdef ENABLE_CHROOT - { "no-chroot", no_argument, NULL, OPTION_NO_CHROOT }, -#endif - { "no-proc-title", no_argument, NULL, OPTION_NO_PROC_TITLE }, - { "debug", no_argument, NULL, OPTION_DEBUG }, - { NULL, 0, NULL, 0 } - }; - - assert(c); - - while ((o = getopt_long(argc, argv, "hDkVf:rcs", long_options, NULL)) >= 0) { - - switch(o) { - case 's': - c->use_syslog = 1; - break; - case 'h': - c->command = DAEMON_HELP; - break; - case 'D': - c->daemonize = 1; - break; - case 'k': - c->command = DAEMON_KILL; - break; - case 'V': - c->command = DAEMON_VERSION; - break; - case 'f': - avahi_free(c->config_file); - c->config_file = avahi_strdup(optarg); - break; - case 'r': - c->command = DAEMON_RELOAD; - break; - case 'c': - c->command = DAEMON_CHECK; - break; - case OPTION_NO_RLIMITS: - c->set_rlimits = 0; - break; - case OPTION_NO_DROP_ROOT: - c->drop_root = 0; - break; -#ifdef ENABLE_CHROOT - case OPTION_NO_CHROOT: - c->use_chroot = 0; - break; -#endif - case OPTION_NO_PROC_TITLE: - c->modify_proc_title = 0; - break; - case OPTION_DEBUG: - c->debug = 1; - break; - default: - return -1; - } - } - - if (optind < argc) { - fprintf(stderr, "Too many arguments\n"); - return -1; - } - - return 0; -} - -static int is_yes(const char *s) { - assert(s); - - return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T'; -} - -static int parse_unsigned(const char *s, unsigned *u) { - char *e = NULL; - unsigned long ul; - unsigned k; - - errno = 0; - ul = strtoul(s, &e, 0); - - if (!e || *e || errno != 0) - return -1; - - k = (unsigned) ul; - - if ((unsigned long) k != ul) - return -1; - - *u = k; - return 0; -} - -static int parse_usec(const char *s, AvahiUsec *u) { - char *e = NULL; - unsigned long long ull; - AvahiUsec k; - - errno = 0; - ull = strtoull(s, &e, 0); - - if (!e || *e || errno != 0) - return -1; - - k = (AvahiUsec) ull; - - if ((unsigned long long) k != ull) - return -1; - - *u = k; - return 0; -} - -static char *get_machine_id(void) { - int fd; - char buf[32]; - - fd = open("/etc/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY); - if (fd == -1 && errno == ENOENT) - fd = open("/var/lib/dbus/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY); - if (fd == -1) - return NULL; - - /* File is on a filesystem so we never get EINTR or partial reads */ - if (read(fd, buf, sizeof buf) != sizeof buf) { - close(fd); - return NULL; - } - close(fd); - - /* Contents can be lower, upper and even mixed case so normalize */ - avahi_strdown(buf); - - return avahi_strndup(buf, sizeof buf); -} - -static int load_config_file(DaemonConfig *c) { - int r = -1; - AvahiIniFile *f; - AvahiIniFileGroup *g; - - assert(c); - - if (!(f = avahi_ini_file_load(c->config_file ? c->config_file : AVAHI_CONFIG_FILE))) - goto finish; - - for (g = f->groups; g; g = g->groups_next) { - - if (strcasecmp(g->name, "server") == 0) { - AvahiIniFilePair *p; - - for (p = g->pairs; p; p = p->pairs_next) { - - if (strcasecmp(p->key, "host-name") == 0) { - avahi_free(c->server_config.host_name); - c->server_config.host_name = avahi_strdup(p->value); - } else if (strcasecmp(p->key, "domain-name") == 0) { - avahi_free(c->server_config.domain_name); - c->server_config.domain_name = avahi_strdup(p->value); - } else if (strcasecmp(p->key, "browse-domains") == 0) { - char **e, **t; - - e = avahi_split_csv(p->value); - - for (t = e; *t; t++) { - char cleaned[AVAHI_DOMAIN_NAME_MAX]; - - if (!avahi_normalize_name(*t, cleaned, sizeof(cleaned))) { - avahi_log_error("Invalid domain name \"%s\" for key \"%s\" in group \"%s\"\n", *t, p->key, g->name); - avahi_strfreev(e); - goto finish; - } - - c->server_config.browse_domains = avahi_string_list_add(c->server_config.browse_domains, cleaned); - } - - avahi_strfreev(e); - - c->server_config.browse_domains = filter_duplicate_domains(c->server_config.browse_domains); - } else if (strcasecmp(p->key, "use-ipv4") == 0) - c->server_config.use_ipv4 = is_yes(p->value); - else if (strcasecmp(p->key, "use-ipv6") == 0) - c->server_config.use_ipv6 = is_yes(p->value); - else if (strcasecmp(p->key, "check-response-ttl") == 0) - c->server_config.check_response_ttl = is_yes(p->value); - else if (strcasecmp(p->key, "allow-point-to-point") == 0) - c->server_config.allow_point_to_point = is_yes(p->value); - else if (strcasecmp(p->key, "use-iff-running") == 0) - c->server_config.use_iff_running = is_yes(p->value); - else if (strcasecmp(p->key, "disallow-other-stacks") == 0) - c->server_config.disallow_other_stacks = is_yes(p->value); - else if (strcasecmp(p->key, "host-name-from-machine-id") == 0) { - if (*(p->value) == 'y' || *(p->value) == 'Y') { - char *machine_id = get_machine_id(); - if (machine_id != NULL) { - avahi_free(c->server_config.host_name); - c->server_config.host_name = machine_id; - } - } - } -#ifdef HAVE_DBUS - else if (strcasecmp(p->key, "enable-dbus") == 0) { - - if (*(p->value) == 'w' || *(p->value) == 'W') { - c->fail_on_missing_dbus = 0; - c->enable_dbus = 1; - } else if (*(p->value) == 'y' || *(p->value) == 'Y') { - c->fail_on_missing_dbus = 1; - c->enable_dbus = 1; - } else { - c->enable_dbus = 0; - } - } -#endif - else if (strcasecmp(p->key, "allow-interfaces") == 0) { - char **e, **t; - - avahi_string_list_free(c->server_config.allow_interfaces); - c->server_config.allow_interfaces = NULL; - e = avahi_split_csv(p->value); - - for (t = e; *t; t++) - c->server_config.allow_interfaces = avahi_string_list_add(c->server_config.allow_interfaces, *t); - - avahi_strfreev(e); - } else if (strcasecmp(p->key, "deny-interfaces") == 0) { - char **e, **t; - - avahi_string_list_free(c->server_config.deny_interfaces); - c->server_config.deny_interfaces = NULL; - e = avahi_split_csv(p->value); - - for (t = e; *t; t++) - c->server_config.deny_interfaces = avahi_string_list_add(c->server_config.deny_interfaces, *t); - - avahi_strfreev(e); - } else if (strcasecmp(p->key, "ratelimit-interval-usec") == 0) { - AvahiUsec k; - - if (parse_usec(p->value, &k) < 0) { - avahi_log_error("Invalid ratelimit-interval-usec setting %s", p->value); - goto finish; - } - - c->server_config.ratelimit_interval = k; - - } else if (strcasecmp(p->key, "ratelimit-burst") == 0) { - unsigned k; - - if (parse_unsigned(p->value, &k) < 0) { - avahi_log_error("Invalid ratelimit-burst setting %s", p->value); - goto finish; - } - - c->server_config.ratelimit_burst = k; - - } else if (strcasecmp(p->key, "cache-entries-max") == 0) { - unsigned k; - - if (parse_unsigned(p->value, &k) < 0) { - avahi_log_error("Invalid cache-entries-max setting %s", p->value); - goto finish; - } - - c->server_config.n_cache_entries_max = k; -#ifdef HAVE_DBUS - } else if (strcasecmp(p->key, "clients-max") == 0) { - unsigned k; - - if (parse_unsigned(p->value, &k) < 0) { - avahi_log_error("Invalid clients-max setting %s", p->value); - goto finish; - } - - c->n_clients_max = k; - } else if (strcasecmp(p->key, "objects-per-client-max") == 0) { - unsigned k; - - if (parse_unsigned(p->value, &k) < 0) { - avahi_log_error("Invalid objects-per-client-max setting %s", p->value); - goto finish; - } - - c->n_objects_per_client_max = k; - } else if (strcasecmp(p->key, "entries-per-entry-group-max") == 0) { - unsigned k; - - if (parse_unsigned(p->value, &k) < 0) { - avahi_log_error("Invalid entries-per-entry-group-max setting %s", p->value); - goto finish; - } - - c->n_entries_per_entry_group_max = k; -#endif - } else { - avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); - goto finish; - } - } - - } else if (strcasecmp(g->name, "publish") == 0) { - AvahiIniFilePair *p; - - for (p = g->pairs; p; p = p->pairs_next) { - - if (strcasecmp(p->key, "publish-addresses") == 0) - c->server_config.publish_addresses = is_yes(p->value); - else if (strcasecmp(p->key, "publish-hinfo") == 0) - c->server_config.publish_hinfo = is_yes(p->value); - else if (strcasecmp(p->key, "publish-workstation") == 0) - c->server_config.publish_workstation = is_yes(p->value); - else if (strcasecmp(p->key, "publish-domain") == 0) - c->server_config.publish_domain = is_yes(p->value); - else if (strcasecmp(p->key, "publish-resolv-conf-dns-servers") == 0) - c->publish_resolv_conf = is_yes(p->value); - else if (strcasecmp(p->key, "disable-publishing") == 0) - c->server_config.disable_publishing = is_yes(p->value); - else if (strcasecmp(p->key, "disable-user-service-publishing") == 0) - c->disable_user_service_publishing = is_yes(p->value); - else if (strcasecmp(p->key, "add-service-cookie") == 0) - c->server_config.add_service_cookie = is_yes(p->value); - else if (strcasecmp(p->key, "publish-dns-servers") == 0) { - avahi_strfreev(c->publish_dns_servers); - c->publish_dns_servers = avahi_split_csv(p->value); - } else if (strcasecmp(p->key, "publish-a-on-ipv6") == 0) - c->server_config.publish_a_on_ipv6 = is_yes(p->value); - else if (strcasecmp(p->key, "publish-aaaa-on-ipv4") == 0) - c->server_config.publish_aaaa_on_ipv4 = is_yes(p->value); - else { - avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); - goto finish; - } - } - - } else if (strcasecmp(g->name, "wide-area") == 0) { - AvahiIniFilePair *p; - - for (p = g->pairs; p; p = p->pairs_next) { - - if (strcasecmp(p->key, "enable-wide-area") == 0) - c->server_config.enable_wide_area = is_yes(p->value); - else { - avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); - goto finish; - } - } - - } else if (strcasecmp(g->name, "reflector") == 0) { - AvahiIniFilePair *p; - - for (p = g->pairs; p; p = p->pairs_next) { - - if (strcasecmp(p->key, "enable-reflector") == 0) - c->server_config.enable_reflector = is_yes(p->value); - else if (strcasecmp(p->key, "reflect-ipv") == 0) - c->server_config.reflect_ipv = is_yes(p->value); - else { - avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); - goto finish; - } - } - - } else if (strcasecmp(g->name, "rlimits") == 0) { - AvahiIniFilePair *p; - - for (p = g->pairs; p; p = p->pairs_next) { - - if (strcasecmp(p->key, "rlimit-as") == 0) { - c->rlimit_as_set = 1; - c->rlimit_as = atoi(p->value); - } else if (strcasecmp(p->key, "rlimit-core") == 0) { - c->rlimit_core_set = 1; - c->rlimit_core = atoi(p->value); - } else if (strcasecmp(p->key, "rlimit-data") == 0) { - c->rlimit_data_set = 1; - c->rlimit_data = atoi(p->value); - } else if (strcasecmp(p->key, "rlimit-fsize") == 0) { - c->rlimit_fsize_set = 1; - c->rlimit_fsize = atoi(p->value); - } else if (strcasecmp(p->key, "rlimit-nofile") == 0) { - c->rlimit_nofile_set = 1; - c->rlimit_nofile = atoi(p->value); - } else if (strcasecmp(p->key, "rlimit-stack") == 0) { - c->rlimit_stack_set = 1; - c->rlimit_stack = atoi(p->value); - } else if (strcasecmp(p->key, "rlimit-nproc") == 0) { -#ifdef RLIMIT_NPROC - c->rlimit_nproc_set = 1; - c->rlimit_nproc = atoi(p->value); -#else - avahi_log_error("Ignoring configuration key \"%s\" in group \"%s\"\n", p->key, g->name); -#endif - } else { - avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); - goto finish; - } - - } - - } else { - avahi_log_error("Invalid configuration file group \"%s\".\n", g->name); - goto finish; - } - } - - r = 0; - -finish: - - if (f) - avahi_ini_file_free(f); - - return r; -} - -static void log_function(AvahiLogLevel level, const char *txt) { - - static const int log_level_map[] = { - LOG_ERR, - LOG_WARNING, - LOG_NOTICE, - LOG_INFO, - LOG_DEBUG - }; - - assert(level < AVAHI_LOG_LEVEL_MAX); - assert(txt); - - if (!config.debug && level == AVAHI_LOG_DEBUG) - return; - - daemon_log(log_level_map[level], "%s", txt); -} - -static void dump(const char *text, AVAHI_GCC_UNUSED void* userdata) { - avahi_log_info("%s", text); -} - -#ifdef HAVE_INOTIFY - -static int inotify_fd = -1; - -static void add_inotify_watches(void) { - int c = 0; - /* We ignore the return values, because one or more of these files - * might not exist and we're OK with that. In addition we never - * want to remove these watches, hence we keep their ids? */ - -#ifdef ENABLE_CHROOT - c = config.use_chroot; -#endif - - inotify_add_watch(inotify_fd, c ? "/services" : AVAHI_SERVICE_DIR, IN_CLOSE_WRITE|IN_DELETE|IN_DELETE_SELF|IN_MOVED_FROM|IN_MOVED_TO|IN_MOVE_SELF -#ifdef IN_ONLYDIR - |IN_ONLYDIR -#endif - ); - inotify_add_watch(inotify_fd, c ? "/" : AVAHI_CONFIG_DIR, IN_CLOSE_WRITE|IN_DELETE|IN_DELETE_SELF|IN_MOVED_FROM|IN_MOVED_TO|IN_MOVE_SELF -#ifdef IN_ONLYDIR - |IN_ONLYDIR -#endif - ); -} - -#endif - -#ifdef HAVE_KQUEUE - -#define NUM_WATCHES 2 - -static int kq = -1; -static int kfds[NUM_WATCHES]; -static int num_kfds = 0; - -static void add_kqueue_watch(const char *dir); - -static void add_kqueue_watches(void) { - int c = 0; - -#ifdef ENABLE_CHROOT - c = config.use_chroot; -#endif - - add_kqueue_watch(c ? "/" : AVAHI_CONFIG_DIR); - add_kqueue_watch(c ? "/services" : AVAHI_SERVICE_DIR); -} - -static void add_kqueue_watch(const char *dir) { - int fd; - struct kevent ev; - - if (kq < 0) - return; - - if (num_kfds >= NUM_WATCHES) - return; - - fd = open(dir, O_RDONLY); - if (fd < 0) - return; - EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, - NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_RENAME, - 0, 0); - if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) { - close(fd); - return; - } - - kfds[num_kfds++] = fd; -} - -#endif - -static void reload_config(void) { - -#ifdef HAVE_INOTIFY - /* Refresh in case the config dirs have been removed */ - add_inotify_watches(); -#endif - -#ifdef HAVE_KQUEUE - add_kqueue_watches(); -#endif - -#ifdef ENABLE_CHROOT - static_service_load(config.use_chroot); - static_hosts_load(config.use_chroot); -#else - static_service_load(0); - static_hosts_load(0); -#endif - static_service_add_to_server(); - static_hosts_add_to_server(); - - if (resolv_conf_entry_group) - avahi_s_entry_group_reset(resolv_conf_entry_group); - - load_resolv_conf(); - - update_wide_area_servers(); - update_browse_domains(); - - if (config.publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0]) - resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf_name_servers); -} - -#ifdef HAVE_INOTIFY - -static void inotify_callback(AvahiWatch *watch, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) { - char* buffer; - int n = 0; - - assert(fd == inotify_fd); - assert(watch); - - ioctl(inotify_fd, FIONREAD, &n); - if (n <= 0) - n = 128; - - buffer = avahi_malloc(n); - if (read(inotify_fd, buffer, n) < 0 ) { - avahi_free(buffer); - avahi_log_error("Failed to read inotify event: %s", avahi_strerror(errno)); - return; - } - avahi_free(buffer); - - avahi_log_info("Files changed, reloading."); - reload_config(); -} - -#endif - -#ifdef HAVE_KQUEUE - -static void kqueue_callback(AvahiWatch *watch, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) { - struct kevent ev; - struct timespec nullts = { 0, 0 }; - int res; - - assert(fd == kq); - assert(watch); - - res = kevent(kq, NULL, 0, &ev, 1, &nullts); - - if (res > 0) { - /* Sleep for a half-second to avoid potential races - * during install/uninstall. */ - usleep(500000); - avahi_log_info("Files changed, reloading."); - reload_config(); - } else { - avahi_log_error("Failed to read kqueue event: %s", avahi_strerror(errno)); - } -} - -#endif - -static void signal_callback(AvahiWatch *watch, AVAHI_GCC_UNUSED int fd, AVAHI_GCC_UNUSED AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) { - int sig; - const AvahiPoll *poll_api; - - assert(watch); - assert(simple_poll_api); - - poll_api = avahi_simple_poll_get(simple_poll_api); - - if ((sig = daemon_signal_next()) <= 0) { - avahi_log_error("daemon_signal_next() failed"); - poll_api->watch_free(watch); - return; - } - - switch (sig) { - case SIGINT: - case SIGTERM: - avahi_log_info( - "Got %s, quitting.", - sig == SIGINT ? "SIGINT" : "SIGTERM"); - avahi_simple_poll_quit(simple_poll_api); - break; - - case SIGHUP: - avahi_log_info("Got SIGHUP, reloading."); - - reload_config(); - break; - - case SIGUSR1: - avahi_log_info("Got SIGUSR1, dumping record data."); - avahi_server_dump(avahi_server, dump, NULL); - break; - - default: - avahi_log_warn("Got spurious signal, ignoring."); - break; - } -} - -/* Imported from ../avahi-client/nss-check.c */ -int avahi_nss_support(void); - -static void ignore_signal(int sig) { - struct sigaction sa; - - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = SIG_IGN; - sa.sa_flags = SA_RESTART; - - sigaction(sig, &sa, NULL); -} - -static int run_server(DaemonConfig *c) { - int r = -1; - int error; - const AvahiPoll *poll_api = NULL; - AvahiWatch *sig_watch = NULL; - int retval_is_sent = 0; -#ifdef HAVE_INOTIFY - AvahiWatch *inotify_watch = NULL; -#endif -#ifdef HAVE_KQUEUE - int i; - AvahiWatch *kqueue_watch = NULL; -#endif - - assert(c); - - ignore_signal(SIGPIPE); - - if (!(nss_support = avahi_nss_support())) - avahi_log_warn("WARNING: No NSS support for mDNS detected, consider installing nss-mdns!"); - - if (!(simple_poll_api = avahi_simple_poll_new())) { - avahi_log_error("Failed to create main loop object."); - goto finish; - } - - poll_api = avahi_simple_poll_get(simple_poll_api); - - if (daemon_signal_init(SIGINT, SIGHUP, SIGTERM, SIGUSR1, 0) < 0) { - avahi_log_error("Could not register signal handlers (%s).", strerror(errno)); - goto finish; - } - - if (!(sig_watch = poll_api->watch_new(poll_api, daemon_signal_fd(), AVAHI_WATCH_IN, signal_callback, simple_poll_api))) { - avahi_log_error( "Failed to create signal watcher"); - goto finish; - } - - if (simple_protocol_setup(poll_api) < 0) - goto finish; - -#ifdef HAVE_DBUS - if (c->enable_dbus) { - if (dbus_protocol_setup(poll_api, - config.disable_user_service_publishing, - config.n_clients_max, - config.n_objects_per_client_max, - config.n_entries_per_entry_group_max, - !c->fail_on_missing_dbus -#ifdef ENABLE_CHROOT - && !config.use_chroot -#endif - ) < 0) { - - avahi_log_warn("WARNING: Failed to contact D-Bus daemon."); - - if (c->fail_on_missing_dbus) - goto finish; - } - } -#endif - -#ifdef ENABLE_CHROOT - - if (config.drop_root && config.use_chroot) { - if (chroot(AVAHI_CONFIG_DIR) < 0) { - avahi_log_error("Failed to chroot(): %s", strerror(errno)); - goto finish; - } - - avahi_log_info("Successfully called chroot()."); - chdir("/"); - - if (avahi_caps_drop_all() < 0) { - avahi_log_error("Failed to drop capabilities."); - goto finish; - } - avahi_log_info("Successfully dropped remaining capabilities."); - } - -#endif - -#ifdef HAVE_INOTIFY - if ((inotify_fd = inotify_init()) < 0) - avahi_log_warn( "Failed to initialize inotify: %s", strerror(errno)); - else { - add_inotify_watches(); - - if (!(inotify_watch = poll_api->watch_new(poll_api, inotify_fd, AVAHI_WATCH_IN, inotify_callback, NULL))) { - avahi_log_error( "Failed to create inotify watcher"); - goto finish; - } - } -#endif - -#ifdef HAVE_KQUEUE - if ((kq = kqueue()) < 0) - avahi_log_warn( "Failed to initialize kqueue: %s", strerror(errno)); - else { - add_kqueue_watches(); - - if (!(kqueue_watch = poll_api->watch_new(poll_api, kq, AVAHI_WATCH_IN, kqueue_callback, NULL))) { - avahi_log_error( "Failed to create kqueue watcher"); - goto finish; - } - } -#endif - - load_resolv_conf(); -#ifdef ENABLE_CHROOT - static_service_load(config.use_chroot); - static_hosts_load(config.use_chroot); -#else - static_service_load(0); - static_hosts_load(0); -#endif - - if (!(avahi_server = avahi_server_new(poll_api, &c->server_config, server_callback, c, &error))) { - avahi_log_error("Failed to create server: %s", avahi_strerror(error)); - goto finish; - } - - update_wide_area_servers(); - update_browse_domains(); - - if (c->daemonize) { - daemon_retval_send(0); - retval_is_sent = 1; - } - - for (;;) { - if ((r = avahi_simple_poll_iterate(simple_poll_api, -1)) < 0) { - - /* We handle signals through an FD, so let's continue */ - if (errno == EINTR) - continue; - - avahi_log_error("poll(): %s", strerror(errno)); - goto finish; - } else if (r > 0) - /* Quit */ - break; - } - - r = 0; - -finish: - - static_service_remove_from_server(); - static_service_free_all(); - - static_hosts_remove_from_server(); - static_hosts_free_all(); - - remove_dns_server_entry_groups(); - - simple_protocol_shutdown(); - -#ifdef HAVE_DBUS - if (c->enable_dbus) - dbus_protocol_shutdown(); -#endif - - if (avahi_server) { - avahi_server_free(avahi_server); - avahi_server = NULL; - } - - daemon_signal_done(); - - if (sig_watch) - poll_api->watch_free(sig_watch); - -#ifdef HAVE_INOTIFY - if (inotify_watch) - poll_api->watch_free(inotify_watch); - if (inotify_fd >= 0) - close(inotify_fd); -#endif - -#ifdef HAVE_KQUEUE - if (kqueue_watch) - poll_api->watch_free(kqueue_watch); - if (kq >= 0) - close(kq); - for (i = 0; i < num_kfds; i++) { - if (kfds[i] >= 0) - close(kfds[i]); - } -#endif - - if (simple_poll_api) { - avahi_simple_poll_free(simple_poll_api); - simple_poll_api = NULL; - } - - if (!retval_is_sent && c->daemonize) - daemon_retval_send(1); - - return r; -} - -#define set_env(key, value) putenv(avahi_strdup_printf("%s=%s", (key), (value))) - -static int drop_root(void) { - struct passwd *pw; - struct group * gr; - int r; - - if (!(pw = getpwnam(AVAHI_USER))) { - avahi_log_error( "Failed to find user '"AVAHI_USER"'."); - return -1; - } - - if (!(gr = getgrnam(AVAHI_GROUP))) { - avahi_log_error( "Failed to find group '"AVAHI_GROUP"'."); - return -1; - } - - avahi_log_info("Found user '"AVAHI_USER"' (UID %lu) and group '"AVAHI_GROUP"' (GID %lu).", (unsigned long) pw->pw_uid, (unsigned long) gr->gr_gid); - - if (initgroups(AVAHI_USER, gr->gr_gid) != 0) { - avahi_log_error("Failed to change group list: %s", strerror(errno)); - return -1; - } - -#if defined(HAVE_SETRESGID) - r = setresgid(gr->gr_gid, gr->gr_gid, gr->gr_gid); -#elif defined(HAVE_SETEGID) - if ((r = setgid(gr->gr_gid)) >= 0) - r = setegid(gr->gr_gid); -#elif defined(HAVE_SETREGID) - r = setregid(gr->gr_gid, gr->gr_gid); -#else -#error "No API to drop privileges" -#endif - - if (r < 0) { - avahi_log_error("Failed to change GID: %s", strerror(errno)); - return -1; - } - -#if defined(HAVE_SETRESUID) - r = setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid); -#elif defined(HAVE_SETEUID) - if ((r = setuid(pw->pw_uid)) >= 0) - r = seteuid(pw->pw_uid); -#elif defined(HAVE_SETREUID) - r = setreuid(pw->pw_uid, pw->pw_uid); -#else -#error "No API to drop privileges" -#endif - - if (r < 0) { - avahi_log_error("Failed to change UID: %s", strerror(errno)); - return -1; - } - - set_env("USER", pw->pw_name); - set_env("LOGNAME", pw->pw_name); - set_env("HOME", pw->pw_dir); - - avahi_log_info("Successfully dropped root privileges."); - - return 0; -} - -static const char* pid_file_proc(void) { - return AVAHI_DAEMON_RUNTIME_DIR"/pid"; -} - -static int make_runtime_dir(void) { - int r = -1; - mode_t u; - int reset_umask = 0; - struct passwd *pw; - struct group * gr; - struct stat st; - - if (!(pw = getpwnam(AVAHI_USER))) { - avahi_log_error( "Failed to find user '"AVAHI_USER"'."); - goto fail; - } - - if (!(gr = getgrnam(AVAHI_GROUP))) { - avahi_log_error( "Failed to find group '"AVAHI_GROUP"'."); - goto fail; - } - - u = umask(0000); - reset_umask = 1; - - if (mkdir(AVAHI_DAEMON_RUNTIME_DIR, 0755) < 0 && errno != EEXIST) { - avahi_log_error("mkdir(\""AVAHI_DAEMON_RUNTIME_DIR"\"): %s", strerror(errno)); - goto fail; - } - - chown(AVAHI_DAEMON_RUNTIME_DIR, pw->pw_uid, gr->gr_gid); - - if (stat(AVAHI_DAEMON_RUNTIME_DIR, &st) < 0) { - avahi_log_error("stat(): %s\n", strerror(errno)); - goto fail; - } - - if (!S_ISDIR(st.st_mode) || st.st_uid != pw->pw_uid || st.st_gid != gr->gr_gid) { - avahi_log_error("Failed to create runtime directory "AVAHI_DAEMON_RUNTIME_DIR"."); - goto fail; - } - - r = 0; - -fail: - if (reset_umask) - umask(u); - return r; -} - -static void set_one_rlimit(int resource, rlim_t limit, const char *name) { - struct rlimit rl; - rl.rlim_cur = rl.rlim_max = limit; - - if (setrlimit(resource, &rl) < 0) - avahi_log_warn("setrlimit(%s, {%u, %u}) failed: %s", name, (unsigned) limit, (unsigned) limit, strerror(errno)); -} - -static void enforce_rlimits(void) { -#ifdef RLIMIT_AS - if (config.rlimit_as_set) - set_one_rlimit(RLIMIT_AS, config.rlimit_as, "RLIMIT_AS"); -#endif - if (config.rlimit_core_set) - set_one_rlimit(RLIMIT_CORE, config.rlimit_core, "RLIMIT_CORE"); - if (config.rlimit_data_set) - set_one_rlimit(RLIMIT_DATA, config.rlimit_data, "RLIMIT_DATA"); - if (config.rlimit_fsize_set) - set_one_rlimit(RLIMIT_FSIZE, config.rlimit_fsize, "RLIMIT_FSIZE"); - if (config.rlimit_nofile_set) - set_one_rlimit(RLIMIT_NOFILE, config.rlimit_nofile, "RLIMIT_NOFILE"); - if (config.rlimit_stack_set) - set_one_rlimit(RLIMIT_STACK, config.rlimit_stack, "RLIMIT_STACK"); -#ifdef RLIMIT_NPROC - if (config.rlimit_nproc_set) - set_one_rlimit(RLIMIT_NPROC, config.rlimit_nproc, "RLIMIT_NPROC"); -#endif - - /* the sysctl() call from iface-pfroute.c needs locked memory on FreeBSD */ -#if defined(RLIMIT_MEMLOCK) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) - /* We don't need locked memory */ - set_one_rlimit(RLIMIT_MEMLOCK, 0, "RLIMIT_MEMLOCK"); -#endif -} - -#define RANDOM_DEVICE "/dev/urandom" - -static void init_rand_seed(void) { - int fd; - unsigned seed = 0; - - /* Try to initialize seed from /dev/urandom, to make it a little - * less predictable, and to make sure that multiple machines - * booted at the same time choose different random seeds. */ - if ((fd = open(RANDOM_DEVICE, O_RDONLY)) >= 0) { - read(fd, &seed, sizeof(seed)); - close(fd); - } - - /* If the initialization failed by some reason, we add the time to the seed*/ - seed ^= (unsigned) time(NULL); - - srand(seed); -} - -int main(int argc, char *argv[]) { - int r = 255; - int wrote_pid_file = 0; - - avahi_set_log_function(log_function); - - init_rand_seed(); - - avahi_server_config_init(&config.server_config); - config.command = DAEMON_RUN; - config.daemonize = 0; - config.config_file = NULL; -#ifdef HAVE_DBUS - config.enable_dbus = 1; - config.fail_on_missing_dbus = 1; - config.n_clients_max = 0; - config.n_objects_per_client_max = 0; - config.n_entries_per_entry_group_max = 0; -#endif - - config.drop_root = 1; - config.set_rlimits = 1; -#ifdef ENABLE_CHROOT - config.use_chroot = 1; -#endif - config.modify_proc_title = 1; - - config.disable_user_service_publishing = 0; - config.publish_dns_servers = NULL; - config.publish_resolv_conf = 0; - config.use_syslog = 0; - config.debug = 0; - config.rlimit_as_set = 0; - config.rlimit_core_set = 0; - config.rlimit_data_set = 0; - config.rlimit_fsize_set = 0; - config.rlimit_nofile_set = 0; - config.rlimit_stack_set = 0; -#ifdef RLIMIT_NPROC - config.rlimit_nproc_set = 0; -#endif - - if ((argv0 = strrchr(argv[0], '/'))) - argv0 = avahi_strdup(argv0 + 1); - else - argv0 = avahi_strdup(argv[0]); - - daemon_pid_file_ident = (const char *) argv0; - daemon_log_ident = (char*) argv0; - daemon_pid_file_proc = pid_file_proc; - - if (parse_command_line(&config, argc, argv) < 0) - goto finish; - - if (config.modify_proc_title) - avahi_init_proc_title(argc, argv); - -#ifdef ENABLE_CHROOT - config.use_chroot = config.use_chroot && config.drop_root; -#endif - - if (config.command == DAEMON_HELP) { - help(stdout); - r = 0; - } else if (config.command == DAEMON_VERSION) { - printf("%s "PACKAGE_VERSION"\n", argv0); - r = 0; - } else if (config.command == DAEMON_KILL) { - if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) { - avahi_log_warn("Failed to kill daemon: %s", strerror(errno)); - goto finish; - } - - r = 0; - - } else if (config.command == DAEMON_RELOAD) { - if (daemon_pid_file_kill(SIGHUP) < 0) { - avahi_log_warn("Failed to kill daemon: %s", strerror(errno)); - goto finish; - } - - r = 0; - - } else if (config.command == DAEMON_CHECK) - r = (daemon_pid_file_is_running() >= 0) ? 0 : 1; - else if (config.command == DAEMON_RUN) { - pid_t pid; - - if (getuid() != 0 && config.drop_root) { - avahi_log_error("This program is intended to be run as root."); - goto finish; - } - - if ((pid = daemon_pid_file_is_running()) >= 0) { - avahi_log_error("Daemon already running on PID %u", pid); - goto finish; - } - - if (load_config_file(&config) < 0) - goto finish; - - if (config.daemonize) { - daemon_retval_init(); - - if ((pid = daemon_fork()) < 0) - goto finish; - else if (pid != 0) { - int ret; - /** Parent **/ - - if ((ret = daemon_retval_wait(20)) < 0) { - avahi_log_error("Could not receive return value from daemon process."); - goto finish; - } - - r = ret; - goto finish; - } - - /* Child */ - } - - if (config.use_syslog || config.daemonize) - daemon_log_use = DAEMON_LOG_SYSLOG; - - if (sd_listen_fds(0) <= 0) - if (daemon_close_all(-1) < 0) - avahi_log_warn("Failed to close all remaining file descriptors: %s", strerror(errno)); - - daemon_reset_sigs(-1); - daemon_unblock_sigs(-1); - - if (make_runtime_dir() < 0) - goto finish; - - if (config.drop_root) { -#ifdef ENABLE_CHROOT - if (config.use_chroot) - if (avahi_caps_reduce() < 0) - goto finish; -#endif - - if (drop_root() < 0) - goto finish; - -#ifdef ENABLE_CHROOT - if (config.use_chroot) - if (avahi_caps_reduce2() < 0) - goto finish; -#endif - } - - if (daemon_pid_file_create() < 0) { - avahi_log_error("Failed to create PID file: %s", strerror(errno)); - - if (config.daemonize) - daemon_retval_send(1); - goto finish; - } else - wrote_pid_file = 1; - - if (config.set_rlimits) - enforce_rlimits(); - - chdir("/"); - -#ifdef ENABLE_CHROOT - if (config.drop_root && config.use_chroot) - if (avahi_chroot_helper_start(argv0) < 0) { - avahi_log_error("failed to start chroot() helper daemon."); - goto finish; - } -#endif - avahi_log_info("%s "PACKAGE_VERSION" starting up.", argv0); - sd_notifyf(0, "STATUS=%s "PACKAGE_VERSION" starting up.", argv0); - avahi_set_proc_title(argv0, "%s: starting up", argv0); - - if (run_server(&config) == 0) - r = 0; - - avahi_log_info("%s "PACKAGE_VERSION" exiting.", argv0); - sd_notifyf(0, "STATUS=%s "PACKAGE_VERSION" exiting.", argv0); - } - -finish: - - if (config.daemonize) - daemon_retval_done(); - - avahi_server_config_free(&config.server_config); - avahi_free(config.config_file); - avahi_strfreev(config.publish_dns_servers); - avahi_strfreev(resolv_conf_name_servers); - avahi_strfreev(resolv_conf_search_domains); - - if (wrote_pid_file) { -#ifdef ENABLE_CHROOT - avahi_chroot_helper_unlink(pid_file_proc()); -#else - daemon_pid_file_remove(); -#endif - } - -#ifdef ENABLE_CHROOT - avahi_chroot_helper_shutdown(); -#endif - - avahi_free(argv0); - - return r; -} diff --git a/avahi-daemon/main.h b/avahi-daemon/main.h deleted file mode 100644 index ef04c2d..0000000 --- a/avahi-daemon/main.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef foomainhfoo -#define foomainhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include -#include - -extern AvahiServer *avahi_server; -extern AvahiSimplePoll *simple_poll_api; - -extern int nss_support; - -#endif diff --git a/avahi-daemon/org.freedesktop.Avahi.AddressResolver.xml b/avahi-daemon/org.freedesktop.Avahi.AddressResolver.xml deleted file mode 100644 index bae9c2f..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.AddressResolver.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.DomainBrowser.xml b/avahi-daemon/org.freedesktop.Avahi.DomainBrowser.xml deleted file mode 100644 index 22c614e..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.DomainBrowser.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.EntryGroup.xml b/avahi-daemon/org.freedesktop.Avahi.EntryGroup.xml deleted file mode 100644 index 43fd63c..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.EntryGroup.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.HostNameResolver.xml b/avahi-daemon/org.freedesktop.Avahi.HostNameResolver.xml deleted file mode 100644 index 0b43752..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.HostNameResolver.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.RecordBrowser.xml b/avahi-daemon/org.freedesktop.Avahi.RecordBrowser.xml deleted file mode 100644 index 9ba86f4..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.RecordBrowser.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.Server.xml b/avahi-daemon/org.freedesktop.Avahi.Server.xml deleted file mode 100644 index c291274..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.Server.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.ServiceBrowser.xml b/avahi-daemon/org.freedesktop.Avahi.ServiceBrowser.xml deleted file mode 100644 index d80298d..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.ServiceBrowser.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.ServiceResolver.xml b/avahi-daemon/org.freedesktop.Avahi.ServiceResolver.xml deleted file mode 100644 index 623f209..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.ServiceResolver.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.ServiceTypeBrowser.xml b/avahi-daemon/org.freedesktop.Avahi.ServiceTypeBrowser.xml deleted file mode 100644 index 4efec82..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.ServiceTypeBrowser.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-daemon/org.freedesktop.Avahi.service b/avahi-daemon/org.freedesktop.Avahi.service deleted file mode 100644 index 30ed2d8..0000000 --- a/avahi-daemon/org.freedesktop.Avahi.service +++ /dev/null @@ -1,24 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -[D-BUS Service] -Name=org.freedesktop.Avahi -SystemdService=dbus-org.freedesktop.Avahi.service - -# This service should not be bus activated if systemd isn't running, -# so that activation won't conflict with the init script startup. -Exec=/bin/false diff --git a/avahi-daemon/sd-daemon.c b/avahi-daemon/sd-daemon.c deleted file mode 100644 index 6d1eebf..0000000 --- a/avahi-daemon/sd-daemon.c +++ /dev/null @@ -1,436 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/*** - Copyright 2010 Lennart Poettering - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -***/ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sd-daemon.h" - -int sd_listen_fds(int unset_environment) { - -#if defined(DISABLE_SYSTEMD) || !defined(__linux__) - return 0; -#else - int r, fd; - const char *e; - char *p = NULL; - unsigned long l; - - if (!(e = getenv("LISTEN_PID"))) { - r = 0; - goto finish; - } - - errno = 0; - l = strtoul(e, &p, 10); - - if (errno != 0) { - r = -errno; - goto finish; - } - - if (!p || *p || l <= 0) { - r = -EINVAL; - goto finish; - } - - /* Is this for us? */ - if (getpid() != (pid_t) l) { - r = 0; - goto finish; - } - - if (!(e = getenv("LISTEN_FDS"))) { - r = 0; - goto finish; - } - - errno = 0; - l = strtoul(e, &p, 10); - - if (errno != 0) { - r = -errno; - goto finish; - } - - if (!p || *p) { - r = -EINVAL; - goto finish; - } - - for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) { - int flags; - - if ((flags = fcntl(fd, F_GETFD)) < 0) { - r = -errno; - goto finish; - } - - if (flags & FD_CLOEXEC) - continue; - - if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) { - r = -errno; - goto finish; - } - } - - r = (int) l; - -finish: - if (unset_environment) { - unsetenv("LISTEN_PID"); - unsetenv("LISTEN_FDS"); - } - - return r; -#endif -} - -int sd_is_fifo(int fd, const char *path) { - struct stat st_fd; - - if (fd < 0) - return -EINVAL; - - memset(&st_fd, 0, sizeof(st_fd)); - if (fstat(fd, &st_fd) < 0) - return -errno; - - if (!S_ISFIFO(st_fd.st_mode)) - return 0; - - if (path) { - struct stat st_path; - - memset(&st_path, 0, sizeof(st_path)); - if (stat(path, &st_path) < 0) { - - if (errno == ENOENT || errno == ENOTDIR) - return 0; - - return -errno; - } - - return - st_path.st_dev == st_fd.st_dev && - st_path.st_ino == st_fd.st_ino; - } - - return 1; -} - -static int sd_is_socket_internal(int fd, int type, int listening) { - struct stat st_fd; - - if (fd < 0 || type < 0) - return -EINVAL; - - if (fstat(fd, &st_fd) < 0) - return -errno; - - if (!S_ISSOCK(st_fd.st_mode)) - return 0; - - if (type != 0) { - int other_type = 0; - socklen_t l = sizeof(other_type); - - if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0) - return -errno; - - if (l != sizeof(other_type)) - return -EINVAL; - - if (other_type != type) - return 0; - } - - if (listening >= 0) { - int accepting = 0; - socklen_t l = sizeof(accepting); - - if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0) - return -errno; - - if (l != sizeof(accepting)) - return -EINVAL; - - if (!accepting != !listening) - return 0; - } - - return 1; -} - -union sockaddr_union { - struct sockaddr sa; - struct sockaddr_in in4; - struct sockaddr_in6 in6; - struct sockaddr_un un; - struct sockaddr_storage storage; -}; - -int sd_is_socket(int fd, int family, int type, int listening) { - int r; - - if (family < 0) - return -EINVAL; - - if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) - return r; - - if (family > 0) { - union sockaddr_union sockaddr; - socklen_t l; - - memset(&sockaddr, 0, sizeof(sockaddr)); - l = sizeof(sockaddr); - - if (getsockname(fd, &sockaddr.sa, &l) < 0) - return -errno; - - if (l < sizeof(sa_family_t)) - return -EINVAL; - - return sockaddr.sa.sa_family == family; - } - - return 1; -} - -int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) { - union sockaddr_union sockaddr; - socklen_t l; - int r; - - if (family != 0 && family != AF_INET && family != AF_INET6) - return -EINVAL; - - if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) - return r; - - memset(&sockaddr, 0, sizeof(sockaddr)); - l = sizeof(sockaddr); - - if (getsockname(fd, &sockaddr.sa, &l) < 0) - return -errno; - - if (l < sizeof(sa_family_t)) - return -EINVAL; - - if (sockaddr.sa.sa_family != AF_INET && - sockaddr.sa.sa_family != AF_INET6) - return 0; - - if (family > 0) - if (sockaddr.sa.sa_family != family) - return 0; - - if (port > 0) { - if (sockaddr.sa.sa_family == AF_INET) { - if (l < sizeof(struct sockaddr_in)) - return -EINVAL; - - return htons(port) == sockaddr.in4.sin_port; - } else { - if (l < sizeof(struct sockaddr_in6)) - return -EINVAL; - - return htons(port) == sockaddr.in6.sin6_port; - } - } - - return 1; -} - -int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) { - union sockaddr_union sockaddr; - socklen_t l; - int r; - - if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) - return r; - - memset(&sockaddr, 0, sizeof(sockaddr)); - l = sizeof(sockaddr); - - if (getsockname(fd, &sockaddr.sa, &l) < 0) - return -errno; - - if (l < sizeof(sa_family_t)) - return -EINVAL; - - if (sockaddr.sa.sa_family != AF_UNIX) - return 0; - - if (path) { - if (length <= 0) - length = strlen(path); - - if (length <= 0) - /* Unnamed socket */ - return l == offsetof(struct sockaddr_un, sun_path); - - if (path[0]) - /* Normal path socket */ - return - (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) && - memcmp(path, sockaddr.un.sun_path, length+1) == 0; - else - /* Abstract namespace socket */ - return - (l == offsetof(struct sockaddr_un, sun_path) + length) && - memcmp(path, sockaddr.un.sun_path, length) == 0; - } - - return 1; -} - -int sd_notify(int unset_environment, const char *state) { -#if defined(DISABLE_SYSTEMD) || !defined(__linux__) || !defined(SOCK_CLOEXEC) - return 0; -#else - int fd = -1, r; - struct msghdr msghdr; - struct iovec iovec; - union sockaddr_union sockaddr; - const char *e; - - if (!state) { - r = -EINVAL; - goto finish; - } - - if (!(e = getenv("NOTIFY_SOCKET"))) - return 0; - - /* Must be an abstract socket, or an absolute path */ - if ((e[0] != '@' && e[0] != '/') || e[1] == 0) { - r = -EINVAL; - goto finish; - } - - if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) { - r = -errno; - goto finish; - } - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sa.sa_family = AF_UNIX; - strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path)); - - if (sockaddr.un.sun_path[0] == '@') - sockaddr.un.sun_path[0] = 0; - - memset(&iovec, 0, sizeof(iovec)); - iovec.iov_base = (char*) state; - iovec.iov_len = strlen(state); - - memset(&msghdr, 0, sizeof(msghdr)); - msghdr.msg_name = &sockaddr; - msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e); - - if (msghdr.msg_namelen > sizeof(struct sockaddr_un)) - msghdr.msg_namelen = sizeof(struct sockaddr_un); - - msghdr.msg_iov = &iovec; - msghdr.msg_iovlen = 1; - - if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) { - r = -errno; - goto finish; - } - - r = 1; - -finish: - if (unset_environment) - unsetenv("NOTIFY_SOCKET"); - - if (fd >= 0) - close(fd); - - return r; -#endif -} - -int sd_notifyf(int unset_environment, const char *format, ...) { -#if defined(DISABLE_SYSTEMD) || !defined(__linux__) - return 0; -#else - va_list ap; - char *p = NULL; - int r; - - va_start(ap, format); - r = vasprintf(&p, format, ap); - va_end(ap); - - if (r < 0 || !p) - return -ENOMEM; - - r = sd_notify(unset_environment, p); - free(p); - - return r; -#endif -} - -int sd_booted(void) { -#if defined(DISABLE_SYSTEMD) || !defined(__linux__) - return 0; -#else - - struct stat a, b; - - /* We simply test whether the systemd cgroup hierarchy is - * mounted */ - - if (lstat("/sys/fs/cgroup", &a) < 0) - return 0; - - if (lstat("/sys/fs/cgroup/systemd", &b) < 0) - return 0; - - return a.st_dev != b.st_dev; -#endif -} diff --git a/avahi-daemon/sd-daemon.h b/avahi-daemon/sd-daemon.h deleted file mode 100644 index 4b853a1..0000000 --- a/avahi-daemon/sd-daemon.h +++ /dev/null @@ -1,265 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -#ifndef foosddaemonhfoo -#define foosddaemonhfoo - -/*** - Copyright 2010 Lennart Poettering - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -***/ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - Reference implementation of a few systemd related interfaces for - writing daemons. These interfaces are trivial to implement. To - simplify porting we provide this reference implementation. - Applications are welcome to reimplement the algorithms described - here if they do not want to include these two source files. - - The following functionality is provided: - - - Support for logging with log levels on stderr - - File descriptor passing for socket-based activation - - Daemon startup and status notification - - Detection of systemd boots - - You may compile this with -DDISABLE_SYSTEMD to disable systemd - support. This makes all those calls NOPs that are directly related to - systemd (i.e. only sd_is_xxx() will stay useful). - - Since this is drop-in code we don't want any of our symbols to be - exported in any case. Hence we declare hidden visibility for all of - them. - - You may find an up-to-date version of these source files online: - - http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h - http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c - - This should compile on non-Linux systems, too, but with the - exception of the sd_is_xxx() calls all functions will become NOPs. - - See sd-daemon(7) for more information. -*/ - -#ifndef _sd_printf_attr_ -#if __GNUC__ >= 4 -#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b))) -#else -#define _sd_printf_attr_(a,b) -#endif -#endif - -#ifndef _sd_hidden_ -#if (__GNUC__ >= 4) && !defined(SD_EXPORT_SYMBOLS) -#define _sd_hidden_ __attribute__ ((visibility("hidden"))) -#else -#define _sd_hidden_ -#endif -#endif - -/* - Log levels for usage on stderr: - - fprintf(stderr, SD_NOTICE "Hello World!\n"); - - This is similar to printk() usage in the kernel. -*/ -#define SD_EMERG "<0>" /* system is unusable */ -#define SD_ALERT "<1>" /* action must be taken immediately */ -#define SD_CRIT "<2>" /* critical conditions */ -#define SD_ERR "<3>" /* error conditions */ -#define SD_WARNING "<4>" /* warning conditions */ -#define SD_NOTICE "<5>" /* normal but significant condition */ -#define SD_INFO "<6>" /* informational */ -#define SD_DEBUG "<7>" /* debug-level messages */ - -/* The first passed file descriptor is fd 3 */ -#define SD_LISTEN_FDS_START 3 - -/* - Returns how many file descriptors have been passed, or a negative - errno code on failure. Optionally, removes the $LISTEN_FDS and - $LISTEN_PID file descriptors from the environment (recommended, but - problematic in threaded environments). If r is the return value of - this function you'll find the file descriptors passed as fds - SD_LISTEN_FDS_START to SD_LISTEN_FDS_START+r-1. Returns a negative - errno style error code on failure. This function call ensures that - the FD_CLOEXEC flag is set for the passed file descriptors, to make - sure they are not passed on to child processes. If FD_CLOEXEC shall - not be set, the caller needs to unset it after this call for all file - descriptors that are used. - - See sd_listen_fds(3) for more information. -*/ -int sd_listen_fds(int unset_environment) _sd_hidden_; - -/* - Helper call for identifying a passed file descriptor. Returns 1 if - the file descriptor is a FIFO in the file system stored under the - specified path, 0 otherwise. If path is NULL a path name check will - not be done and the call only verifies if the file descriptor - refers to a FIFO. Returns a negative errno style error code on - failure. - - See sd_is_fifo(3) for more information. -*/ -int sd_is_fifo(int fd, const char *path) _sd_hidden_; - -/* - Helper call for identifying a passed file descriptor. Returns 1 if - the file descriptor is a socket of the specified family (AF_INET, - ...) and type (SOCK_DGRAM, SOCK_STREAM, ...), 0 otherwise. If - family is 0 a socket family check will not be done. If type is 0 a - socket type check will not be done and the call only verifies if - the file descriptor refers to a socket. If listening is > 0 it is - verified that the socket is in listening mode. (i.e. listen() has - been called) If listening is == 0 it is verified that the socket is - not in listening mode. If listening is < 0 no listening mode check - is done. Returns a negative errno style error code on failure. - - See sd_is_socket(3) for more information. -*/ -int sd_is_socket(int fd, int family, int type, int listening) _sd_hidden_; - -/* - Helper call for identifying a passed file descriptor. Returns 1 if - the file descriptor is an Internet socket, of the specified family - (either AF_INET or AF_INET6) and the specified type (SOCK_DGRAM, - SOCK_STREAM, ...), 0 otherwise. If version is 0 a protocol version - check is not done. If type is 0 a socket type check will not be - done. If port is 0 a socket port check will not be done. The - listening flag is used the same way as in sd_is_socket(). Returns a - negative errno style error code on failure. - - See sd_is_socket_inet(3) for more information. -*/ -int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) _sd_hidden_; - -/* - Helper call for identifying a passed file descriptor. Returns 1 if - the file descriptor is an AF_UNIX socket of the specified type - (SOCK_DGRAM, SOCK_STREAM, ...) and path, 0 otherwise. If type is 0 - a socket type check will not be done. If path is NULL a socket path - check will not be done. For normal AF_UNIX sockets set length to - 0. For abstract namespace sockets set length to the length of the - socket name (including the initial 0 byte), and pass the full - socket path in path (including the initial 0 byte). The listening - flag is used the same way as in sd_is_socket(). Returns a negative - errno style error code on failure. - - See sd_is_socket_unix(3) for more information. -*/ -int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) _sd_hidden_; - -/* - Informs systemd about changed daemon state. This takes a number of - newline separated environment-style variable assignments in a - string. The following variables are known: - - READY=1 Tells systemd that daemon startup is finished (only - relevant for services of Type=notify). The passed - argument is a boolean "1" or "0". Since there is - little value in signaling non-readiness the only - value daemons should send is "READY=1". - - STATUS=... Passes a single-line status string back to systemd - that describes the daemon state. This is free-from - and can be used for various purposes: general state - feedback, fsck-like programs could pass completion - percentages and failing programs could pass a human - readable error message. Example: "STATUS=Completed - 66% of file system check..." - - ERRNO=... If a daemon fails, the errno-style error code, - formatted as string. Example: "ERRNO=2" for ENOENT. - - BUSERROR=... If a daemon fails, the D-Bus error-style error - code. Example: "BUSERROR=org.freedesktop.DBus.Error.TimedOut" - - MAINPID=... The main pid of a daemon, in case systemd did not - fork off the process itself. Example: "MAINPID=4711" - - Daemons can choose to send additional variables. However, it is - recommended to prefix variable names not listed above with X_. - - Returns a negative errno-style error code on failure. Returns > 0 - if systemd could be notified, 0 if it couldn't possibly because - systemd is not running. - - Example: When a daemon finished starting up, it could issue this - call to notify systemd about it: - - sd_notify(0, "READY=1"); - - See sd_notifyf() for more complete examples. - - See sd_notify(3) for more information. -*/ -int sd_notify(int unset_environment, const char *state) _sd_hidden_; - -/* - Similar to sd_notify() but takes a format string. - - Example 1: A daemon could send the following after initialization: - - sd_notifyf(0, "READY=1\n" - "STATUS=Processing requests...\n" - "MAINPID=%lu", - (unsigned long) getpid()); - - Example 2: A daemon could send the following shortly before - exiting, on failure: - - sd_notifyf(0, "STATUS=Failed to start up: %s\n" - "ERRNO=%i", - strerror(errno), - errno); - - See sd_notifyf(3) for more information. -*/ -int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3) _sd_hidden_; - -/* - Returns > 0 if the system was booted with systemd. Returns < 0 on - error. Returns 0 if the system was not booted with systemd. Note - that all of the functions above handle non-systemd boots just - fine. You should NOT protect them with a call to this function. Also - note that this function checks whether the system, not the user - session is controlled by systemd. However the functions above work - for both user and system services. - - See sd_booted(3) for more information. -*/ -int sd_booted(void) _sd_hidden_; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/avahi-daemon/setproctitle.c b/avahi-daemon/setproctitle.c deleted file mode 100644 index e6f0941..0000000 --- a/avahi-daemon/setproctitle.c +++ /dev/null @@ -1,111 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#ifdef HAVE_SYS_PRCTL_H -#include -#endif - -#include - -#include "setproctitle.h" - -#if !defined(HAVE_SETPROCTITLE) && defined(__linux__) -static char** argv_buffer = NULL; -static size_t argv_size = 0; - -#if !HAVE_DECL_ENVIRON -extern char **environ; -#endif - -#endif - -void avahi_init_proc_title(int argc, char **argv) { - -#if !defined(HAVE_SETPROCTITLE) && defined(__linux__) - - unsigned i; - char **new_environ, *endptr; - - /* This code is really really ugly. We make some memory layout - * assumptions and reuse the environment array as memory to store - * our process title in */ - - for (i = 0; environ[i]; i++); - - endptr = i ? environ[i-1] + strlen(environ[i-1]) : argv[argc-1] + strlen(argv[argc-1]); - - argv_buffer = argv; - argv_size = endptr - argv_buffer[0]; - - /* Make a copy of environ */ - - new_environ = avahi_malloc(sizeof(char*) * (i + 1)); - for (i = 0; environ[i]; i++) - new_environ[i] = avahi_strdup(environ[i]); - new_environ[i] = NULL; - - environ = new_environ; - -#endif -} - -void avahi_set_proc_title(const char *name, const char *fmt,...) { -#ifdef HAVE_SETPROCTITLE - char t[256]; - - va_list ap; - va_start(ap, fmt); - vsnprintf(t, sizeof(t), fmt, ap); - va_end(ap); - - setproctitle("-%s", t); -#elif defined(__linux__) - size_t l; - va_list ap; - - if (!argv_buffer) - return; - - va_start(ap, fmt); - vsnprintf(argv_buffer[0], argv_size, fmt, ap); - va_end(ap); - - l = strlen(argv_buffer[0]); - - memset(argv_buffer[0] + l, 0, argv_size - l); - argv_buffer[1] = NULL; -#endif - -#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_NAME) - - if (name) - prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0); - -#endif -} diff --git a/avahi-daemon/setproctitle.h b/avahi-daemon/setproctitle.h deleted file mode 100644 index 3499e2e..0000000 --- a/avahi-daemon/setproctitle.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef foosetproctitlehfoo -#define foosetproctitlehfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -void avahi_init_proc_title(int argc, char **argv); -void avahi_set_proc_title(const char *name, const char *fmt, ...) AVAHI_GCC_PRINTF_ATTR23; - -#endif diff --git a/avahi-daemon/sftp-ssh.service b/avahi-daemon/sftp-ssh.service deleted file mode 100644 index dfae4f1..0000000 --- a/avahi-daemon/sftp-ssh.service +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - %h - - - _sftp-ssh._tcp - 22 - - - diff --git a/avahi-daemon/simple-protocol.c b/avahi-daemon/simple-protocol.c deleted file mode 100644 index 3e0ebb1..0000000 --- a/avahi-daemon/simple-protocol.c +++ /dev/null @@ -1,568 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "simple-protocol.h" -#include "main.h" -#include "sd-daemon.h" - -#ifdef ENABLE_CHROOT -#include "chroot.h" -#endif - -#ifndef AF_LOCAL -#define AF_LOCAL AF_UNIX -#endif -#ifndef PF_LOCAL -#define PF_LOCAL PF_UNIX -#endif - -#define BUFFER_SIZE (20*1024) - -#define CLIENTS_MAX 50 - -typedef struct Client Client; -typedef struct Server Server; - -typedef enum { - CLIENT_IDLE, - CLIENT_RESOLVE_HOSTNAME, - CLIENT_RESOLVE_ADDRESS, - CLIENT_BROWSE_DNS_SERVERS, - CLIENT_DEAD -} ClientState; - -struct Client { - Server *server; - - ClientState state; - - int fd; - AvahiWatch *watch; - - char inbuf[BUFFER_SIZE], outbuf[BUFFER_SIZE]; - size_t inbuf_length, outbuf_length; - - AvahiSHostNameResolver *host_name_resolver; - AvahiSAddressResolver *address_resolver; - AvahiSDNSServerBrowser *dns_server_browser; - - AvahiProtocol afquery; - - AVAHI_LLIST_FIELDS(Client, clients); -}; - -struct Server { - const AvahiPoll *poll_api; - int fd; - AvahiWatch *watch; - AVAHI_LLIST_HEAD(Client, clients); - - unsigned n_clients; - int remove_socket; -}; - -static Server *server = NULL; - -static void client_work(AvahiWatch *watch, int fd, AvahiWatchEvent events, void *userdata); - -static void client_free(Client *c) { - assert(c); - - assert(c->server->n_clients >= 1); - c->server->n_clients--; - - if (c->host_name_resolver) - avahi_s_host_name_resolver_free(c->host_name_resolver); - - if (c->address_resolver) - avahi_s_address_resolver_free(c->address_resolver); - - if (c->dns_server_browser) - avahi_s_dns_server_browser_free(c->dns_server_browser); - - c->server->poll_api->watch_free(c->watch); - close(c->fd); - - AVAHI_LLIST_REMOVE(Client, clients, c->server->clients, c); - avahi_free(c); -} - -static void client_new(Server *s, int fd) { - Client *c; - - assert(fd >= 0); - - c = avahi_new(Client, 1); - c->server = s; - c->fd = fd; - c->state = CLIENT_IDLE; - - c->inbuf_length = c->outbuf_length = 0; - - c->host_name_resolver = NULL; - c->address_resolver = NULL; - c->dns_server_browser = NULL; - - c->watch = s->poll_api->watch_new(s->poll_api, fd, AVAHI_WATCH_IN, client_work, c); - - AVAHI_LLIST_PREPEND(Client, clients, s->clients, c); - s->n_clients++; -} - -static void client_output(Client *c, const uint8_t*data, size_t size) { - size_t k, m; - - assert(c); - assert(data); - - if (!size) - return; - - k = sizeof(c->outbuf) - c->outbuf_length; - m = size > k ? k : size; - - memcpy(c->outbuf + c->outbuf_length, data, m); - c->outbuf_length += m; - - server->poll_api->watch_update(c->watch, AVAHI_WATCH_OUT); -} - -static void client_output_printf(Client *c, const char *format, ...) { - char *t; - va_list ap; - - va_start(ap, format); - t = avahi_strdup_vprintf(format, ap); - va_end(ap); - - client_output(c, (uint8_t*) t, strlen(t)); - avahi_free(t); -} - -static void host_name_resolver_callback( - AVAHI_GCC_UNUSED AvahiSHostNameResolver *r, - AvahiIfIndex iface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *hostname, - const AvahiAddress *a, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { - - Client *c = userdata; - - assert(c); - - if (event == AVAHI_RESOLVER_FAILURE) - client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server))); - else if (event == AVAHI_RESOLVER_FOUND) { - char t[AVAHI_ADDRESS_STR_MAX]; - avahi_address_snprint(t, sizeof(t), a); - client_output_printf(c, "+ %i %u %s %s\n", iface, protocol, hostname, t); - } - - c->state = CLIENT_DEAD; -} - -static void address_resolver_callback( - AVAHI_GCC_UNUSED AvahiSAddressResolver *r, - AvahiIfIndex iface, - AvahiProtocol protocol, - AvahiResolverEvent event, - AVAHI_GCC_UNUSED const AvahiAddress *a, - const char *hostname, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { - - Client *c = userdata; - - assert(c); - - if (event == AVAHI_RESOLVER_FAILURE) - client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server))); - else if (event == AVAHI_RESOLVER_FOUND) - client_output_printf(c, "+ %i %u %s\n", iface, protocol, hostname); - - c->state = CLIENT_DEAD; -} - -static void dns_server_browser_callback( - AVAHI_GCC_UNUSED AvahiSDNSServerBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - AVAHI_GCC_UNUSED const char *host_name, - const AvahiAddress *a, - uint16_t port, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { - - Client *c = userdata; - char t[AVAHI_ADDRESS_STR_MAX]; - - assert(c); - - if (!a) - return; - - switch (event) { - case AVAHI_BROWSER_FAILURE: - client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server))); - c->state = CLIENT_DEAD; - break; - - case AVAHI_BROWSER_ALL_FOR_NOW: - case AVAHI_BROWSER_CACHE_EXHAUSTED: - break; - - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE: - - avahi_address_snprint(t, sizeof(t), a); - client_output_printf(c, "%c %i %u %s %u\n", event == AVAHI_BROWSER_NEW ? '>' : '<', interface, protocol, t, port); - break; - } -} - -static void handle_line(Client *c, const char *s) { - char cmd[64], arg[64]; - int n_args; - - assert(c); - assert(s); - - if (c->state != CLIENT_IDLE) - return; - - if ((n_args = sscanf(s, "%63s %63s", cmd, arg)) < 1 ) { - client_output_printf(c, "%+i Failed to parse command, try \"HELP\".\n", AVAHI_ERR_INVALID_OPERATION); - c->state = CLIENT_DEAD; - return; - } - - if (strcmp(cmd, "HELP") == 0) { - client_output_printf(c, - "+ Available commands are:\n" - "+ RESOLVE-HOSTNAME \n" - "+ RESOLVE-HOSTNAME-IPV6 \n" - "+ RESOLVE-HOSTNAME-IPV4 \n" - "+ RESOLVE-ADDRESS
    \n" - "+ BROWSE-DNS-SERVERS\n" - "+ BROWSE-DNS-SERVERS-IPV4\n" - "+ BROWSE-DNS-SERVERS-IPV6\n"); - c->state = CLIENT_DEAD; } - else if (strcmp(cmd, "FUCK") == 0 && n_args == 1) { - client_output_printf(c, "+ FUCK: Go fuck yourself!\n"); - c->state = CLIENT_DEAD; - } else if (strcmp(cmd, "RESOLVE-HOSTNAME-IPV4") == 0 && n_args == 2) { - c->state = CLIENT_RESOLVE_HOSTNAME; - if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_INET, AVAHI_LOOKUP_USE_MULTICAST, host_name_resolver_callback, c))) - goto fail; - - avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg); - } else if (strcmp(cmd, "RESOLVE-HOSTNAME-IPV6") == 0 && n_args == 2) { - c->state = CLIENT_RESOLVE_HOSTNAME; - if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_INET6, AVAHI_LOOKUP_USE_MULTICAST, host_name_resolver_callback, c))) - goto fail; - - avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg); - } else if (strcmp(cmd, "RESOLVE-HOSTNAME") == 0 && n_args == 2) { - c->state = CLIENT_RESOLVE_HOSTNAME; - if (!(c->host_name_resolver = avahi_s_host_name_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, arg, c->afquery = AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_USE_MULTICAST, host_name_resolver_callback, c))) - goto fail; - - avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg); - } else if (strcmp(cmd, "RESOLVE-ADDRESS") == 0 && n_args == 2) { - AvahiAddress addr; - - if (!(avahi_address_parse(arg, AVAHI_PROTO_UNSPEC, &addr))) { - client_output_printf(c, "%+i Failed to parse address \"%s\".\n", AVAHI_ERR_INVALID_ADDRESS, arg); - c->state = CLIENT_DEAD; - } else { - c->state = CLIENT_RESOLVE_ADDRESS; - if (!(c->address_resolver = avahi_s_address_resolver_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, &addr, AVAHI_LOOKUP_USE_MULTICAST, address_resolver_callback, c))) - goto fail; - } - - avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg); - - } else if (strcmp(cmd, "BROWSE-DNS-SERVERS-IPV4") == 0 && n_args == 1) { - c->state = CLIENT_BROWSE_DNS_SERVERS; - if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_INET, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c))) - goto fail; - client_output_printf(c, "+ Browsing ...\n"); - - avahi_log_debug(__FILE__": Got %s request.", cmd); - - } else if (strcmp(cmd, "BROWSE-DNS-SERVERS-IPV6") == 0 && n_args == 1) { - c->state = CLIENT_BROWSE_DNS_SERVERS; - if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_INET6, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c))) - goto fail; - client_output_printf(c, "+ Browsing ...\n"); - - avahi_log_debug(__FILE__": Got %s request.", cmd); - - } else if (strcmp(cmd, "BROWSE-DNS-SERVERS") == 0 && n_args == 1) { - c->state = CLIENT_BROWSE_DNS_SERVERS; - if (!(c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery = AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c))) - goto fail; - client_output_printf(c, "+ Browsing ...\n"); - - avahi_log_debug(__FILE__": Got %s request.", cmd); - - } else { - client_output_printf(c, "%+i Invalid command \"%s\", try \"HELP\".\n", AVAHI_ERR_INVALID_OPERATION, cmd); - c->state = CLIENT_DEAD; - - avahi_log_debug(__FILE__": Got invalid request '%s'.", cmd); - } - - return; - -fail: - client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server))); - c->state = CLIENT_DEAD; -} - -static void handle_input(Client *c) { - assert(c); - - for (;;) { - char *e; - size_t k; - - if (!(e = memchr(c->inbuf, '\n', c->inbuf_length))) - break; - - k = e - (char*) c->inbuf; - *e = 0; - - handle_line(c, c->inbuf); - c->inbuf_length -= k + 1; - memmove(c->inbuf, e+1, c->inbuf_length); - } -} - -static void client_work(AvahiWatch *watch, AVAHI_GCC_UNUSED int fd, AvahiWatchEvent events, void *userdata) { - Client *c = userdata; - - assert(c); - - if ((events & AVAHI_WATCH_IN) && c->inbuf_length < sizeof(c->inbuf)) { - ssize_t r; - - if ((r = read(c->fd, c->inbuf + c->inbuf_length, sizeof(c->inbuf) - c->inbuf_length)) <= 0) { - if (r < 0) - avahi_log_warn("read(): %s", strerror(errno)); - client_free(c); - return; - } - - c->inbuf_length += r; - assert(c->inbuf_length <= sizeof(c->inbuf)); - - handle_input(c); - } - - if ((events & AVAHI_WATCH_OUT) && c->outbuf_length > 0) { - ssize_t r; - - if ((r = write(c->fd, c->outbuf, c->outbuf_length)) < 0) { - avahi_log_warn("write(): %s", strerror(errno)); - client_free(c); - return; - } - - assert((size_t) r <= c->outbuf_length); - c->outbuf_length -= r; - - if (c->outbuf_length) - memmove(c->outbuf, c->outbuf + r, c->outbuf_length - r); - - if (c->outbuf_length == 0 && c->state == CLIENT_DEAD) { - client_free(c); - return; - } - } - - c->server->poll_api->watch_update( - watch, - (c->outbuf_length > 0 ? AVAHI_WATCH_OUT : 0) | - (c->inbuf_length < sizeof(c->inbuf) ? AVAHI_WATCH_IN : 0)); -} - -static void server_work(AVAHI_GCC_UNUSED AvahiWatch *watch, int fd, AvahiWatchEvent events, void *userdata) { - Server *s = userdata; - - assert(s); - - if (events & AVAHI_WATCH_IN) { - int cfd; - - if ((cfd = accept(fd, NULL, NULL)) < 0) - avahi_log_error("accept(): %s", strerror(errno)); - else - client_new(s, cfd); - } -} - -int simple_protocol_setup(const AvahiPoll *poll_api) { - struct sockaddr_un sa; - mode_t u; - int n; - - assert(!server); - - server = avahi_new(Server, 1); - server->poll_api = poll_api; - server->remove_socket = 0; - server->fd = -1; - server->n_clients = 0; - AVAHI_LLIST_HEAD_INIT(Client, server->clients); - server->watch = NULL; - - u = umask(0000); - - if ((n = sd_listen_fds(1)) < 0) { - avahi_log_warn("Failed to acquire systemd file descriptors: %s", strerror(-n)); - goto fail; - } - - if (n > 1) { - avahi_log_warn("Too many systemd file descriptors passed."); - goto fail; - } - - if (n == 1) { - int r; - - if ((r = sd_is_socket(SD_LISTEN_FDS_START, AF_LOCAL, SOCK_STREAM, 1)) < 0) { - avahi_log_warn("Passed systemd file descriptor is of wrong type: %s", strerror(-r)); - goto fail; - } - - server->fd = SD_LISTEN_FDS_START; - - } else { - - if ((server->fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) { - avahi_log_warn("socket(AF_LOCAL, SOCK_STREAM, 0): %s", strerror(errno)); - goto fail; - } - - memset(&sa, 0, sizeof(sa)); - sa.sun_family = AF_LOCAL; - strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1); - - /* We simply remove existing UNIX sockets under this name. The - Avahi daemon makes sure that it runs only once on a host, - therefore sockets that already exist are stale and may be - removed without any ill effects */ - - unlink(AVAHI_SOCKET); - - if (bind(server->fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) { - avahi_log_warn("bind(): %s", strerror(errno)); - goto fail; - } - - server->remove_socket = 1; - - if (listen(server->fd, SOMAXCONN) < 0) { - avahi_log_warn("listen(): %s", strerror(errno)); - goto fail; - } - } - - umask(u); - - server->watch = poll_api->watch_new(poll_api, server->fd, AVAHI_WATCH_IN, server_work, server); - - return 0; - -fail: - - umask(u); - simple_protocol_shutdown(); - - return -1; -} - -void simple_protocol_shutdown(void) { - - if (server) { - - if (server->remove_socket) -#ifdef ENABLE_CHROOT - avahi_chroot_helper_unlink(AVAHI_SOCKET); -#else - unlink(AVAHI_SOCKET); -#endif - - while (server->clients) - client_free(server->clients); - - if (server->watch) - server->poll_api->watch_free(server->watch); - - if (server->fd >= 0) - close(server->fd); - - avahi_free(server); - - server = NULL; - } -} - -void simple_protocol_restart_queries(void) { - Client *c; - - /* Restart queries in case of local domain name changes */ - - assert(server); - - for (c = server->clients; c; c = c->clients_next) - if (c->state == CLIENT_BROWSE_DNS_SERVERS && c->dns_server_browser) { - avahi_s_dns_server_browser_free(c->dns_server_browser); - c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c); - } -} diff --git a/avahi-daemon/simple-protocol.h b/avahi-daemon/simple-protocol.h deleted file mode 100644 index bcbffc3..0000000 --- a/avahi-daemon/simple-protocol.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef foosimpleprotocolhfoo -#define foosimpleprotocolhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -int simple_protocol_setup(const AvahiPoll *poll_api); -void simple_protocol_shutdown(void); -void simple_protocol_restart_queries(void); - -#endif diff --git a/avahi-daemon/ssh.service b/avahi-daemon/ssh.service deleted file mode 100644 index c66e0c1..0000000 --- a/avahi-daemon/ssh.service +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - %h - - - _ssh._tcp - 22 - - - diff --git a/avahi-daemon/static-hosts.c b/avahi-daemon/static-hosts.c deleted file mode 100644 index 34f531f..0000000 --- a/avahi-daemon/static-hosts.c +++ /dev/null @@ -1,278 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "main.h" -#include "static-hosts.h" - -typedef struct StaticHost StaticHost; - -struct StaticHost { - AvahiSEntryGroup *group; - int iteration; - - char *host; - AvahiAddress address; - - AVAHI_LLIST_FIELDS(StaticHost, hosts); -}; - -static AVAHI_LLIST_HEAD(StaticHost, hosts) = NULL; -static int current_iteration = 0; - -static void add_static_host_to_server(StaticHost *h); -static void remove_static_host_from_server(StaticHost *h); - -static void entry_group_callback(AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGroup *eg, AvahiEntryGroupState state, void* userdata) { - StaticHost *h; - - assert(s); - assert(eg); - - h = userdata; - - switch (state) { - - case AVAHI_ENTRY_GROUP_COLLISION: - avahi_log_error("Host name conflict for \"%s\", not established.", h->host); - break; - - case AVAHI_ENTRY_GROUP_ESTABLISHED: - avahi_log_notice ("Static host name \"%s\" successfully established.", h->host); - break; - - case AVAHI_ENTRY_GROUP_FAILURE: - avahi_log_notice ("Failed to establish static host name \"%s\": %s.", h->host, avahi_strerror (avahi_server_errno (s))); - break; - - case AVAHI_ENTRY_GROUP_UNCOMMITED: - case AVAHI_ENTRY_GROUP_REGISTERING: - ; - } -} - -static StaticHost *static_host_new(void) { - StaticHost *s; - - s = avahi_new(StaticHost, 1); - - s->group = NULL; - s->host = NULL; - s->iteration = current_iteration; - - AVAHI_LLIST_PREPEND(StaticHost, hosts, hosts, s); - - return s; -} - -static void static_host_free(StaticHost *s) { - assert(s); - - AVAHI_LLIST_REMOVE(StaticHost, hosts, hosts, s); - - if (s->group) - avahi_s_entry_group_free (s->group); - - avahi_free(s->host); - - avahi_free(s); -} - -static StaticHost *static_host_find(const char *host, const AvahiAddress *a) { - StaticHost *h; - - assert(host); - assert(a); - - for (h = hosts; h; h = h->hosts_next) - if (!strcmp(h->host, host) && !avahi_address_cmp(a, &h->address)) - return h; - - return NULL; -} - -static void add_static_host_to_server(StaticHost *h) -{ - - if (!h->group) - if (!(h->group = avahi_s_entry_group_new (avahi_server, entry_group_callback, h))) { - avahi_log_error("avahi_s_entry_group_new() failed: %s", avahi_strerror(avahi_server_errno(avahi_server))); - return; - } - - if (avahi_s_entry_group_is_empty(h->group)) { - AvahiProtocol p; - int err; - const AvahiServerConfig *config; - config = avahi_server_get_config(avahi_server); - - p = (h->address.proto == AVAHI_PROTO_INET && config->publish_a_on_ipv6) || - (h->address.proto == AVAHI_PROTO_INET6 && config->publish_aaaa_on_ipv4) ? AVAHI_PROTO_UNSPEC : h->address.proto; - - if ((err = avahi_server_add_address(avahi_server, h->group, AVAHI_IF_UNSPEC, p, 0, h->host, &h->address)) < 0) { - avahi_log_error ("Static host name %s: avahi_server_add_address failure: %s", h->host, avahi_strerror(err)); - return; - } - - avahi_s_entry_group_commit (h->group); - } -} - -static void remove_static_host_from_server(StaticHost *h) -{ - if (h->group) - avahi_s_entry_group_reset (h->group); -} - -void static_hosts_add_to_server(void) { - StaticHost *h; - - for (h = hosts; h; h = h->hosts_next) - add_static_host_to_server(h); -} - -void static_hosts_remove_from_server(void) { - StaticHost *h; - - for (h = hosts; h; h = h->hosts_next) - remove_static_host_from_server(h); -} - -void static_hosts_load(int in_chroot) { - FILE *f; - unsigned int line = 0; - StaticHost *h, *next; - const char *filename = in_chroot ? "/hosts" : AVAHI_CONFIG_DIR "/hosts"; - - if (!(f = fopen(filename, "r"))) { - if (errno != ENOENT) - avahi_log_error ("Failed to open static hosts file: %s", strerror (errno)); - return; - } - - current_iteration++; - - while (!feof(f)) { - unsigned int len; - char ln[256], *s; - char *host, *ip; - AvahiAddress a; - - if (!fgets(ln, sizeof (ln), f)) - break; - - line++; - - /* Find the start of the line, ignore whitespace */ - s = ln + strspn(ln, " \t"); - /* Set the end of the string to NULL */ - s[strcspn(s, "#\r\n")] = 0; - - /* Ignore blank lines */ - if (*s == 0) - continue; - - /* Read the first string (ip) up to the next whitespace */ - len = strcspn(s, " \t"); - ip = avahi_strndup(s, len); - - /* Skip past it */ - s += len; - - /* Find the next token */ - s += strspn(s, " \t"); - len = strcspn(s, " \t"); - host = avahi_strndup(s, len); - - if (*host == 0) - { - avahi_log_error("%s:%d: Error, unexpected end of line!", filename, line); - avahi_free(host); - avahi_free(ip); - goto fail; - } - - /* Skip over the host */ - s += len; - - /* Skip past any more spaces */ - s += strspn(s, " \t"); - - /* Anything left? */ - if (*s != 0) { - avahi_log_error ("%s:%d: Junk on the end of the line!", filename, line); - avahi_free(host); - avahi_free(ip); - goto fail; - } - - if (!avahi_address_parse(ip, AVAHI_PROTO_UNSPEC, &a)) { - avahi_log_error("Static host name %s: failed to parse address %s", host, ip); - avahi_free(host); - avahi_free(ip); - goto fail; - } - - avahi_free(ip); - - if ((h = static_host_find(host, &a))) - avahi_free(host); - else { - h = static_host_new(); - h->host = host; - h->address = a; - - avahi_log_info("Loading new static hostname %s.", h->host); - } - - h->iteration = current_iteration; - } - - for (h = hosts; h; h = next) { - next = h->hosts_next; - - if (h->iteration != current_iteration) { - avahi_log_info("Static hostname %s vanished, removing.", h->host); - static_host_free(h); - } - } - -fail: - - fclose(f); -} - -void static_hosts_free_all (void) -{ - while(hosts) - static_host_free(hosts); -} diff --git a/avahi-daemon/static-hosts.h b/avahi-daemon/static-hosts.h deleted file mode 100644 index 5d63995..0000000 --- a/avahi-daemon/static-hosts.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef foostatichostshfoo -#define foostatichostshfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -void static_hosts_load(int in_chroot); -void static_hosts_free_all(void); -void static_hosts_add_to_server(void); -void static_hosts_remove_from_server(void); - -#endif diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c deleted file mode 100644 index 4c3491f..0000000 --- a/avahi-daemon/static-services.c +++ /dev/null @@ -1,744 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef USE_EXPAT_H -#include -#endif /* USE_EXPAT_H */ - -#ifdef USE_BSDXML_H -#include -#endif /* USE_BSDXML_H */ - -#include -#include -#include -#include -#include -#include -#include - -#include "main.h" -#include "static-services.h" - -typedef struct StaticService StaticService; -typedef struct StaticServiceGroup StaticServiceGroup; - -struct StaticService { - StaticServiceGroup *group; - - char *type; - char *domain_name; - char *host_name; - uint16_t port; - int protocol; - - AvahiStringList *subtypes; - - AvahiStringList *txt_records; - - AVAHI_LLIST_FIELDS(StaticService, services); -}; - -struct StaticServiceGroup { - char *filename; - time_t mtime; - - char *name, *chosen_name; - int replace_wildcards; - - AvahiSEntryGroup *entry_group; - AVAHI_LLIST_HEAD(StaticService, services); - AVAHI_LLIST_FIELDS(StaticServiceGroup, groups); -}; - -static AVAHI_LLIST_HEAD(StaticServiceGroup, groups) = NULL; - -static char *replacestr(const char *pattern, const char *a, const char *b) { - char *r = NULL, *e, *n; - - while ((e = strstr(pattern, a))) { - char *k; - - k = avahi_strndup(pattern, e - pattern); - if (r) - n = avahi_strdup_printf("%s%s%s", r, k, b); - else - n = avahi_strdup_printf("%s%s", k, b); - - avahi_free(k); - avahi_free(r); - r = n; - - pattern = e + strlen(a); - } - - if (!r) - return avahi_strdup(pattern); - - n = avahi_strdup_printf("%s%s", r, pattern); - avahi_free(r); - - return n; -} - -static void add_static_service_group_to_server(StaticServiceGroup *g); -static void remove_static_service_group_from_server(StaticServiceGroup *g); - -static StaticService *static_service_new(StaticServiceGroup *group) { - StaticService *s; - - assert(group); - s = avahi_new(StaticService, 1); - s->group = group; - - s->type = s->host_name = s->domain_name = NULL; - s->port = 0; - s->protocol = AVAHI_PROTO_UNSPEC; - - s->txt_records = NULL; - s->subtypes = NULL; - - AVAHI_LLIST_PREPEND(StaticService, services, group->services, s); - - return s; -} - -static StaticServiceGroup *static_service_group_new(char *filename) { - StaticServiceGroup *g; - assert(filename); - - g = avahi_new(StaticServiceGroup, 1); - g->filename = avahi_strdup(filename); - g->mtime = 0; - g->name = g->chosen_name = NULL; - g->replace_wildcards = 0; - g->entry_group = NULL; - - AVAHI_LLIST_HEAD_INIT(StaticService, g->services); - AVAHI_LLIST_PREPEND(StaticServiceGroup, groups, groups, g); - - return g; -} - -static void static_service_free(StaticService *s) { - assert(s); - - AVAHI_LLIST_REMOVE(StaticService, services, s->group->services, s); - - avahi_free(s->type); - avahi_free(s->host_name); - avahi_free(s->domain_name); - - avahi_string_list_free(s->txt_records); - avahi_string_list_free(s->subtypes); - - avahi_free(s); -} - -static void static_service_group_free(StaticServiceGroup *g) { - assert(g); - - if (g->entry_group) - avahi_s_entry_group_free(g->entry_group); - - while (g->services) - static_service_free(g->services); - - AVAHI_LLIST_REMOVE(StaticServiceGroup, groups, groups, g); - - avahi_free(g->filename); - avahi_free(g->name); - avahi_free(g->chosen_name); - avahi_free(g); -} - -static void entry_group_callback(AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGroup *eg, AvahiEntryGroupState state, void* userdata) { - StaticServiceGroup *g = userdata; - - assert(s); - assert(g); - - switch (state) { - - case AVAHI_ENTRY_GROUP_COLLISION: { - char *n; - - remove_static_service_group_from_server(g); - - n = avahi_alternative_service_name(g->chosen_name); - avahi_free(g->chosen_name); - g->chosen_name = n; - - avahi_log_notice("Service name conflict for \"%s\" (%s), retrying with \"%s\".", g->name, g->filename, g->chosen_name); - - add_static_service_group_to_server(g); - break; - } - - case AVAHI_ENTRY_GROUP_ESTABLISHED: - avahi_log_info("Service \"%s\" (%s) successfully established.", g->chosen_name, g->filename); - break; - - case AVAHI_ENTRY_GROUP_FAILURE: - avahi_log_warn("Failed to publish service \"%s\" (%s): %s", g->chosen_name, g->filename, avahi_strerror(avahi_server_errno(s))); - remove_static_service_group_from_server(g); - break; - - case AVAHI_ENTRY_GROUP_UNCOMMITED: - case AVAHI_ENTRY_GROUP_REGISTERING: - ; - } -} - -static void add_static_service_group_to_server(StaticServiceGroup *g) { - StaticService *s; - - assert(g); - - if (g->entry_group && !avahi_s_entry_group_is_empty(g->entry_group)) - /* This service group is already registered in the server */ - return; - - if (!g->chosen_name || (g->replace_wildcards && strstr(g->name, "%h"))) { - - avahi_free(g->chosen_name); - - if (g->replace_wildcards) { - char label[AVAHI_LABEL_MAX]; - const char *p; - - p = avahi_server_get_host_name(avahi_server); - avahi_unescape_label(&p, label, sizeof(label)); - - g->chosen_name = replacestr(g->name, "%h", label); - } else - g->chosen_name = avahi_strdup(g->name); - - } - - if (!g->entry_group) - g->entry_group = avahi_s_entry_group_new(avahi_server, entry_group_callback, g); - - assert(avahi_s_entry_group_is_empty(g->entry_group)); - - for (s = g->services; s; s = s->services_next) { - AvahiStringList *i; - - if (avahi_server_add_service_strlst( - avahi_server, - g->entry_group, - AVAHI_IF_UNSPEC, s->protocol, - 0, - g->chosen_name, s->type, s->domain_name, - s->host_name, s->port, - s->txt_records) < 0) { - avahi_log_error("Failed to add service '%s' of type '%s', ignoring service group (%s): %s", - g->chosen_name, s->type, g->filename, - avahi_strerror(avahi_server_errno(avahi_server))); - remove_static_service_group_from_server(g); - return; - } - - for (i = s->subtypes; i; i = i->next) { - - if (avahi_server_add_service_subtype( - avahi_server, - g->entry_group, - AVAHI_IF_UNSPEC, s->protocol, - 0, - g->chosen_name, s->type, s->domain_name, - (char*) i->text) < 0) { - - avahi_log_error("Failed to add subtype '%s' for service '%s' of type '%s', ignoring subtype (%s): %s", - i->text, g->chosen_name, s->type, g->filename, - avahi_strerror(avahi_server_errno(avahi_server))); - } - } - } - - avahi_s_entry_group_commit(g->entry_group); -} - -static void remove_static_service_group_from_server(StaticServiceGroup *g) { - assert(g); - - if (g->entry_group) - avahi_s_entry_group_reset(g->entry_group); -} - -typedef enum { - XML_TAG_INVALID, - XML_TAG_SERVICE_GROUP, - XML_TAG_NAME, - XML_TAG_SERVICE, - XML_TAG_TYPE, - XML_TAG_SUBTYPE, - XML_TAG_DOMAIN_NAME, - XML_TAG_HOST_NAME, - XML_TAG_PORT, - XML_TAG_TXT_RECORD -} xml_tag_name; - -struct xml_userdata { - StaticServiceGroup *group; - StaticService *service; - xml_tag_name current_tag; - int failed; - char *buf; -}; - -#ifndef XMLCALL -#define XMLCALL -#endif - -static void XMLCALL xml_start(void *data, const char *el, const char *attr[]) { - struct xml_userdata *u = data; - - assert(u); - - if (u->failed) - return; - - if (u->current_tag == XML_TAG_INVALID && strcmp(el, "service-group") == 0) { - - if (attr[0]) - goto invalid_attr; - - u->current_tag = XML_TAG_SERVICE_GROUP; - } else if (u->current_tag == XML_TAG_SERVICE_GROUP && strcmp(el, "name") == 0) { - u->current_tag = XML_TAG_NAME; - - if (attr[0]) { - if (strcmp(attr[0], "replace-wildcards") == 0) - u->group->replace_wildcards = strcmp(attr[1], "yes") == 0; - else - goto invalid_attr; - - if (attr[2]) - goto invalid_attr; - } - - } else if (u->current_tag == XML_TAG_SERVICE_GROUP && strcmp(el, "service") == 0) { - u->current_tag = XML_TAG_SERVICE; - - assert(!u->service); - u->service = static_service_new(u->group); - - if (attr[0]) { - if (strcmp(attr[0], "protocol") == 0) { - AvahiProtocol protocol; - - if (strcmp(attr[1], "ipv4") == 0) { - protocol = AVAHI_PROTO_INET; - } else if (strcmp(attr[1], "ipv6") == 0) { - protocol = AVAHI_PROTO_INET6; - } else if (strcmp(attr[1], "any") == 0) { - protocol = AVAHI_PROTO_UNSPEC; - } else { - avahi_log_error("%s: parse failure: invalid protocol specification \"%s\".", u->group->filename, attr[1]); - u->failed = 1; - return; - } - - u->service->protocol = protocol; - } else - goto invalid_attr; - - if (attr[2]) - goto invalid_attr; - } - - } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "type") == 0) { - if (attr[0]) - goto invalid_attr; - - u->current_tag = XML_TAG_TYPE; - } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "subtype") == 0) { - if (attr[0]) - goto invalid_attr; - - u->current_tag = XML_TAG_SUBTYPE; - } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "domain-name") == 0) { - if (attr[0]) - goto invalid_attr; - - u->current_tag = XML_TAG_DOMAIN_NAME; - } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "host-name") == 0) { - if (attr[0]) - goto invalid_attr; - - u->current_tag = XML_TAG_HOST_NAME; - } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "port") == 0) { - if (attr[0]) - goto invalid_attr; - - u->current_tag = XML_TAG_PORT; - } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "txt-record") == 0) { - if (attr[0]) - goto invalid_attr; - - u->current_tag = XML_TAG_TXT_RECORD; - } else { - avahi_log_error("%s: parse failure: didn't expect element <%s>.", u->group->filename, el); - u->failed = 1; - } - - return; - -invalid_attr: - avahi_log_error("%s: parse failure: invalid attribute for element <%s>.", u->group->filename, el); - u->failed = 1; - return; -} - -static void XMLCALL xml_end(void *data, AVAHI_GCC_UNUSED const char *el) { - struct xml_userdata *u = data; - assert(u); - - if (u->failed) - return; - - switch (u->current_tag) { - case XML_TAG_SERVICE_GROUP: - - if (!u->group->name || !u->group->services) { - avahi_log_error("%s: parse failure: service group incomplete.", u->group->filename); - u->failed = 1; - return; - } - - u->current_tag = XML_TAG_INVALID; - break; - - case XML_TAG_SERVICE: - - if (!u->service->type) { - avahi_log_error("%s: parse failure: service incomplete.", u->group->filename); - u->failed = 1; - return; - } - - u->service = NULL; - u->current_tag = XML_TAG_SERVICE_GROUP; - break; - - case XML_TAG_NAME: - u->current_tag = XML_TAG_SERVICE_GROUP; - break; - - case XML_TAG_PORT: { - int p; - assert(u->service); - - p = u->buf ? atoi(u->buf) : 0; - - if (p < 0 || p > 0xFFFF) { - avahi_log_error("%s: parse failure: invalid port specification \"%s\".", u->group->filename, u->buf); - u->failed = 1; - return; - } - - u->service->port = (uint16_t) p; - - u->current_tag = XML_TAG_SERVICE; - break; - } - - case XML_TAG_TXT_RECORD: { - assert(u->service); - - u->service->txt_records = avahi_string_list_add(u->service->txt_records, u->buf ? u->buf : ""); - u->current_tag = XML_TAG_SERVICE; - break; - } - - case XML_TAG_SUBTYPE: { - assert(u->service); - - u->service->subtypes = avahi_string_list_add(u->service->subtypes, u->buf ? u->buf : ""); - u->current_tag = XML_TAG_SERVICE; - break; - } - - case XML_TAG_TYPE: - case XML_TAG_DOMAIN_NAME: - case XML_TAG_HOST_NAME: - u->current_tag = XML_TAG_SERVICE; - break; - - case XML_TAG_INVALID: - ; - } - - avahi_free(u->buf); - u->buf = NULL; -} - -static char *append_cdata(char *t, const char *n, int length) { - char *r, *k; - - if (!length) - return t; - - - k = avahi_strndup(n, length); - - if (t) { - r = avahi_strdup_printf("%s%s", t, k); - avahi_free(k); - avahi_free(t); - } else - r = k; - - return r; -} - -static void XMLCALL xml_cdata(void *data, const XML_Char *s, int len) { - struct xml_userdata *u = data; - assert(u); - - if (u->failed) - return; - - switch (u->current_tag) { - case XML_TAG_NAME: - u->group->name = append_cdata(u->group->name, s, len); - break; - - case XML_TAG_TYPE: - assert(u->service); - u->service->type = append_cdata(u->service->type, s, len); - break; - - case XML_TAG_DOMAIN_NAME: - assert(u->service); - u->service->domain_name = append_cdata(u->service->domain_name, s, len); - break; - - case XML_TAG_HOST_NAME: - assert(u->service); - u->service->host_name = append_cdata(u->service->host_name, s, len); - break; - - case XML_TAG_PORT: - case XML_TAG_TXT_RECORD: - case XML_TAG_SUBTYPE: - assert(u->service); - u->buf = append_cdata(u->buf, s, len); - break; - - case XML_TAG_SERVICE_GROUP: - case XML_TAG_SERVICE: - case XML_TAG_INVALID: - ; - } -} - -static int static_service_group_load(StaticServiceGroup *g) { - XML_Parser parser = NULL; - int fd = -1; - struct xml_userdata u; - int r = -1; - struct stat st; - ssize_t n; - - assert(g); - - u.buf = NULL; - u.group = g; - u.service = NULL; - u.current_tag = XML_TAG_INVALID; - u.failed = 0; - - /* Cleanup old data in this service group, if available */ - remove_static_service_group_from_server(g); - while (g->services) - static_service_free(g->services); - - avahi_free(g->name); - avahi_free(g->chosen_name); - g->name = g->chosen_name = NULL; - g->replace_wildcards = 0; - - if (!(parser = XML_ParserCreate(NULL))) { - avahi_log_error("XML_ParserCreate() failed."); - goto finish; - } - - if ((fd = open(g->filename, O_RDONLY)) < 0) { - avahi_log_error("open(\"%s\", O_RDONLY): %s", g->filename, strerror(errno)); - goto finish; - } - - if (fstat(fd, &st) < 0) { - avahi_log_error("fstat(): %s", strerror(errno)); - goto finish; - } - - g->mtime = st.st_mtime; - - XML_SetUserData(parser, &u); - - XML_SetElementHandler(parser, xml_start, xml_end); - XML_SetCharacterDataHandler(parser, xml_cdata); - - do { - void *buffer; - -#define BUFSIZE (10*1024) - - if (!(buffer = XML_GetBuffer(parser, BUFSIZE))) { - avahi_log_error("XML_GetBuffer() failed."); - goto finish; - } - - if ((n = read(fd, buffer, BUFSIZE)) < 0) { - avahi_log_error("read(): %s\n", strerror(errno)); - goto finish; - } - - if (!XML_ParseBuffer(parser, n, n == 0)) { - avahi_log_error("XML_ParseBuffer() failed at line %d: %s.\n", (int) XML_GetCurrentLineNumber(parser), XML_ErrorString(XML_GetErrorCode(parser))); - goto finish; - } - - } while (n != 0); - - if (!u.failed) - r = 0; - -finish: - - if (fd >= 0) - close(fd); - - if (parser) - XML_ParserFree(parser); - - avahi_free(u.buf); - - return r; -} - -static void load_file(char *n) { - StaticServiceGroup *g; - assert(n); - - for (g = groups; g; g = g->groups_next) - if (strcmp(g->filename, n) == 0) - return; - - avahi_log_info("Loading service file %s.", n); - - g = static_service_group_new(n); - if (static_service_group_load(g) < 0) { - avahi_log_error("Failed to load service group file %s, ignoring.", g->filename); - static_service_group_free(g); - } -} - -void static_service_load(int in_chroot) { - StaticServiceGroup *g, *n; - glob_t globbuf; - int globret; - char **p; - - for (g = groups; g; g = n) { - struct stat st; - - n = g->groups_next; - - if (stat(g->filename, &st) < 0) { - - if (errno == ENOENT) - avahi_log_info("Service group file %s vanished, removing services.", g->filename); - else - avahi_log_warn("Failed to stat() file %s, ignoring: %s", g->filename, strerror(errno)); - - static_service_group_free(g); - } else if (st.st_mtime != g->mtime) { - avahi_log_info("Service group file %s changed, reloading.", g->filename); - - if (static_service_group_load(g) < 0) { - avahi_log_warn("Failed to load service group file %s, removing service.", g->filename); - static_service_group_free(g); - } - } - } - - memset(&globbuf, 0, sizeof(globbuf)); - - if ((globret = glob(in_chroot ? "/services/*.service" : AVAHI_SERVICE_DIR "/*.service", GLOB_ERR, NULL, &globbuf)) != 0) - - switch (globret) { -#ifdef GLOB_NOSPACE - case GLOB_NOSPACE: - avahi_log_error("Not enough memory to read service directory "AVAHI_SERVICE_DIR"."); - break; -#endif -#ifdef GLOB_NOMATCH - case GLOB_NOMATCH: - avahi_log_info("No service file found in "AVAHI_SERVICE_DIR"."); - break; -#endif - default: - avahi_log_error("Failed to read "AVAHI_SERVICE_DIR"."); - break; - } - - else { - for (p = globbuf.gl_pathv; *p; p++) - load_file(*p); - - globfree(&globbuf); - } -} - -void static_service_free_all(void) { - - while (groups) - static_service_group_free(groups); -} - -void static_service_add_to_server(void) { - StaticServiceGroup *g; - - for (g = groups; g; g = g->groups_next) - add_static_service_group_to_server(g); -} - -void static_service_remove_from_server(void) { - StaticServiceGroup *g; - - for (g = groups; g; g = g->groups_next) - remove_static_service_group_from_server(g); -} diff --git a/avahi-daemon/static-services.h b/avahi-daemon/static-services.h deleted file mode 100644 index 62edc36..0000000 --- a/avahi-daemon/static-services.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef foostaticserviceshfoo -#define foostaticserviceshfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -void static_service_load(int in_chroot); -void static_service_free_all(void); -void static_service_add_to_server(void); -void static_service_remove_from_server(void); - -#endif diff --git a/avahi-discover-standalone/.gitignore b/avahi-discover-standalone/.gitignore deleted file mode 100644 index 9864451..0000000 --- a/avahi-discover-standalone/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -avahi-discover-standalone -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs diff --git a/avahi-discover-standalone/Makefile.am b/avahi-discover-standalone/Makefile.am deleted file mode 100644 index 3995c0a..0000000 --- a/avahi-discover-standalone/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -interfaces = \ - avahi-discover.ui - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -if HAVE_GTK2OR3 -if HAVE_GLIB -bin_PROGRAMS = \ - avahi-discover-standalone - -avahi_discover_standalone_SOURCES = \ - main.c - -avahi_discover_standalone_CFLAGS = \ - $(AM_CFLAGS) \ - -DAVAHI_INTERFACES_DIR=\"$(interfacesdir)\" - -avahi_discover_standalone_LDADD = \ - $(AM_LDADD) \ - ../avahi-common/libavahi-common.la \ - ../avahi-glib/libavahi-glib.la \ - ../avahi-core/libavahi-core.la - -if HAVE_GTK3 -avahi_discover_standalone_CFLAGS += \ - $(GLIB30_CFLAGS) $(GTK30_CFLAGS) -avahi_discover_standalone_LDADD += \ - $(GLIB30_LIBS) $(GTK30_LIBS) -else -avahi_discover_standalone_CFLAGS += \ - $(GLIB20_CFLAGS) $(GTK20_CFLAGS) -avahi_discover_standalone_LDADD += \ - $(GLIB20_LIBS) $(GTK20_LIBS) -endif - -interfaces_DATA = $(interfaces) - -endif # HAVE_GLIB -else - -if HAVE_PYTHON_DBUS - -interfaces_DATA = - -endif -endif - -EXTRA_DIST = \ - $(interfaces) diff --git a/avahi-discover-standalone/avahi-discover.ui b/avahi-discover-standalone/avahi-discover.ui deleted file mode 100644 index b4b72f9..0000000 --- a/avahi-discover-standalone/avahi-discover.ui +++ /dev/null @@ -1,84 +0,0 @@ - - - - - True - Avahi Discovery - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 500 - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - True - - - - 12 - True - False - 12 - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - True - True - True - False - False - True - False - False - False - - - - - - 0 - True - True - - - - - True - True - <i>No service currently selected.</i> - False - True - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - diff --git a/avahi-discover-standalone/main.c b/avahi-discover-standalone/main.c deleted file mode 100644 index 2f000a4..0000000 --- a/avahi-discover-standalone/main.c +++ /dev/null @@ -1,368 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -struct ServiceType; - -struct Service { - struct ServiceType *service_type; - gchar *service_name; - gchar *domain_name; - - AvahiIfIndex interface; - AvahiProtocol protocol; - - GtkTreeRowReference *tree_ref; -}; - -struct ServiceType { - gchar *service_type; - AvahiSServiceBrowser *browser; - - GList *services; - GtkTreeRowReference *tree_ref; -}; - -static GtkWidget *main_window = NULL; -static GtkTreeView *tree_view = NULL; -static GtkTreeStore *tree_store = NULL; -static GtkLabel *info_label = NULL; -static AvahiServer *server = NULL; -static AvahiSServiceTypeBrowser *service_type_browser = NULL; -static GHashTable *service_type_hash_table = NULL; -static AvahiSServiceResolver *service_resolver = NULL; -static struct Service *current_service = NULL; - -static struct Service *get_service(const gchar *service_type, const gchar *service_name, const gchar*domain_name, AvahiIfIndex interface, AvahiProtocol protocol) { - struct ServiceType *st; - GList *l; - - if (!(st = g_hash_table_lookup(service_type_hash_table, service_type))) - return NULL; - - for (l = st->services; l; l = l->next) { - struct Service *s = l->data; - - if (s->interface == interface && - s->protocol == protocol && - avahi_domain_equal(s->service_name, service_name) && - avahi_domain_equal(s->domain_name, domain_name)) - return s; - } - - return NULL; -} - -static void free_service(struct Service *s) { - GtkTreeIter iter; - GtkTreePath *path; - - if (current_service == s) { - current_service = NULL; - - if (service_resolver) { - avahi_s_service_resolver_free(service_resolver); - service_resolver = NULL; - } - - gtk_label_set_text(info_label, "Service removed"); - } - - s->service_type->services = g_list_remove(s->service_type->services, s); - - if ((path = gtk_tree_row_reference_get_path(s->tree_ref))) { - gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_store), &iter, path); - gtk_tree_path_free(path); - } - - gtk_tree_store_remove(tree_store, &iter); - - gtk_tree_row_reference_free(s->tree_ref); - - g_free(s->service_name); - g_free(s->domain_name); - g_free(s); -} - -static void service_browser_callback( - AVAHI_GCC_UNUSED AvahiSServiceBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *service_name, - const char *service_type, - const char *domain_name, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void* userdata) { - - if (event == AVAHI_BROWSER_NEW) { - struct Service *s; - GtkTreeIter iter, piter; - GtkTreePath *path, *ppath; - gchar iface[256]; - char name[IF_NAMESIZE]; - - s = g_new(struct Service, 1); - s->service_name = g_strdup(service_name); - s->domain_name = g_strdup(domain_name); - s->interface = interface; - s->protocol = protocol; - s->service_type = g_hash_table_lookup(service_type_hash_table, service_type); - g_assert(s->service_type); - - s->service_type->services = g_list_prepend(s->service_type->services, s); - - ppath = gtk_tree_row_reference_get_path(s->service_type->tree_ref); - gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_store), &piter, ppath); - - snprintf(iface, sizeof(iface), "%s %s", if_indextoname(interface, name), avahi_proto_to_string(protocol)); - - gtk_tree_store_append(tree_store, &iter, &piter); - gtk_tree_store_set(tree_store, &iter, 0, s->service_name, 1, iface, 2, s, -1); - - path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree_store), &iter); - s->tree_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(tree_store), path); - gtk_tree_path_free(path); - - gtk_tree_view_expand_row(tree_view, ppath, FALSE); - gtk_tree_path_free(ppath); - - - } else if (event == AVAHI_BROWSER_REMOVE) { - struct Service* s; - - if ((s = get_service(service_type, service_name, domain_name, interface, protocol))) - free_service(s); - } -} - -static void service_type_browser_callback( - AVAHI_GCC_UNUSED AvahiSServiceTypeBrowser *b, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *service_type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void * userdata) { - - struct ServiceType *st; - GtkTreePath *path; - GtkTreeIter iter; - - if (event != AVAHI_BROWSER_NEW) - return; - - if (g_hash_table_lookup(service_type_hash_table, service_type)) - return; - - st = g_new(struct ServiceType, 1); - st->service_type = g_strdup(service_type); - st->services = NULL; - - gtk_tree_store_append(tree_store, &iter, NULL); - gtk_tree_store_set(tree_store, &iter, 0, st->service_type, 1, "", 2, NULL, -1); - - path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree_store), &iter); - st->tree_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(tree_store), path); - gtk_tree_path_free(path); - - g_hash_table_insert(service_type_hash_table, st->service_type, st); - - st->browser = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, st->service_type, domain, 0, service_browser_callback, NULL); -} - -static void update_label(struct Service *s, const gchar *hostname, const AvahiAddress *a, guint16 port, AvahiStringList *txt) { - gchar t[512], address[64], *txt_s; - char name[IF_NAMESIZE]; - - if (a && hostname) { - char na[AVAHI_ADDRESS_STR_MAX]; - avahi_address_snprint(na, sizeof(na), a); - snprintf(address, sizeof(address), "%s/%s:%u", hostname, na, port); - - if (txt) - txt_s = avahi_string_list_to_string(txt); - else - txt_s = g_strdup("empty"); - } else { - snprintf(address, sizeof(address), "n/a"); - txt_s = g_strdup("n/a"); - } - - snprintf(t, sizeof(t), - "Service Type: %s\n" - "Service Name: %s\n" - "Domain Name: %s\n" - "Interface: %s %s\n" - "Address: %s\n" - "TXT Data: %s", - s->service_type->service_type, - s->service_name, - s->domain_name, - if_indextoname(s->interface,name), avahi_proto_to_string(s->protocol), - address, - txt_s); - - gtk_label_set_markup(info_label, t); - - g_free(txt_s); -} - -static struct Service *get_service_on_cursor(void) { - GtkTreePath *path; - struct Service *s; - GtkTreeIter iter; - - gtk_tree_view_get_cursor(tree_view, &path, NULL); - - if (!path) - return NULL; - - gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_store), &iter, path); - gtk_tree_model_get(GTK_TREE_MODEL(tree_store), &iter, 2, &s, -1); - gtk_tree_path_free(path); - - return s; -} - -static void service_resolver_callback( - AvahiSServiceResolver *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiResolverEvent event, - AVAHI_GCC_UNUSED const char *name, - AVAHI_GCC_UNUSED const char *type, - AVAHI_GCC_UNUSED const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { - - struct Service *s; - g_assert(r); - - if (!(s = get_service_on_cursor()) || userdata != s) { - g_assert(r == service_resolver); - avahi_s_service_resolver_free(service_resolver); - service_resolver = NULL; - return; - } - - if (event == AVAHI_RESOLVER_FAILURE) { - char t[256]; - snprintf(t, sizeof(t), "Failed to resolve: %s.", avahi_strerror(avahi_server_errno(server))); - gtk_label_set_markup(info_label, t); - } else if (event == AVAHI_RESOLVER_FOUND) - update_label(s, host_name, a, port, txt); -} - -static void tree_view_on_cursor_changed(AVAHI_GCC_UNUSED GtkTreeView *tv, AVAHI_GCC_UNUSED gpointer userdata) { - struct Service *s; - - if (!(s = get_service_on_cursor())) - return; - - if (service_resolver) - avahi_s_service_resolver_free(service_resolver); - - update_label(s, NULL, NULL, 0, NULL); - - service_resolver = avahi_s_service_resolver_new(server, s->interface, s->protocol, s->service_name, s->service_type->service_type, s->domain_name, AVAHI_PROTO_UNSPEC, 0, service_resolver_callback, s); -} - -static gboolean main_window_on_delete_event(AVAHI_GCC_UNUSED GtkWidget *widget, AVAHI_GCC_UNUSED GdkEvent *event, AVAHI_GCC_UNUSED gpointer user_data) { - gtk_main_quit(); - return FALSE; -} - -int main(int argc, char *argv[]) { - GtkBuilder *ui; - AvahiServerConfig config; - GtkTreeViewColumn *c; - gint error; - AvahiGLibPoll *poll_api; - - gtk_init(&argc, &argv); - - avahi_set_allocator(avahi_glib_allocator()); - - poll_api = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT); - - ui = gtk_builder_new(); - gtk_builder_add_from_file(ui, AVAHI_INTERFACES_DIR"avahi-discover.ui", NULL); - main_window = GTK_WIDGET(gtk_builder_get_object(ui, "main_window")); - g_signal_connect(main_window, "delete-event", (GCallback) main_window_on_delete_event, NULL); - - tree_view = GTK_TREE_VIEW(gtk_builder_get_object(ui, "tree_view")); - g_signal_connect(GTK_WIDGET(tree_view), "cursor-changed", (GCallback) tree_view_on_cursor_changed, NULL); - - info_label = GTK_LABEL(gtk_builder_get_object(ui, "info_label")); - - tree_store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model(tree_view, GTK_TREE_MODEL(tree_store)); - gtk_tree_view_insert_column_with_attributes(tree_view, -1, "Name", gtk_cell_renderer_text_new(), "text", 0, NULL); - gtk_tree_view_insert_column_with_attributes(tree_view, -1, "Interface", gtk_cell_renderer_text_new(), "text", 1, NULL); - - gtk_tree_view_column_set_resizable(c = gtk_tree_view_get_column(tree_view, 0), TRUE); - gtk_tree_view_column_set_sizing(c, GTK_TREE_VIEW_COLUMN_GROW_ONLY); - gtk_tree_view_column_set_expand(c, TRUE); - - service_type_hash_table = g_hash_table_new((GHashFunc) avahi_domain_hash, (GEqualFunc) avahi_domain_equal); - - avahi_server_config_init(&config); - config.publish_hinfo = config.publish_addresses = config.publish_domain = config.publish_workstation = FALSE; - server = avahi_server_new(avahi_glib_poll_get(poll_api), &config, NULL, NULL, &error); - avahi_server_config_free(&config); - - g_assert(server); - - service_type_browser = avahi_s_service_type_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, argc >= 2 ? argv[1] : NULL, 0, service_type_browser_callback, NULL); - - gtk_main(); - - avahi_server_free(server); - avahi_glib_poll_free(poll_api); - - return 0; -} diff --git a/avahi-dnsconfd/.gitignore b/avahi-dnsconfd/.gitignore deleted file mode 100644 index 2c6d07f..0000000 --- a/avahi-dnsconfd/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -avahi-dnsconfd.service -avahi-dnsconfd diff --git a/avahi-dnsconfd/Makefile.am b/avahi-dnsconfd/Makefile.am deleted file mode 100644 index 4e74429..0000000 --- a/avahi-dnsconfd/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -EXTRA_DIST=avahi-dnsconfd.action avahi-dnsconfd.service.in - -if HAVE_XML -if HAVE_LIBDAEMON - -pkgsysconfdir=$(sysconfdir)/avahi - -AM_CFLAGS= \ - -I$(top_srcdir) \ - -DAVAHI_RUNTIME_DIR=\"$(avahi_runtime_dir)/\" \ - -DAVAHI_SOCKET=\"$(avahi_socket)\" \ - -DAVAHI_DNSCONF_SCRIPT=\"$(pkgsysconfdir)/avahi-dnsconfd.action\" - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -sbin_PROGRAMS = avahi-dnsconfd - -avahi_dnsconfd_SOURCES = main.c -avahi_dnsconfd_CFLAGS = $(AM_CFLAGS) $(LIBDAEMON_CFLAGS) -avahi_dnsconfd_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(LIBDAEMON_LIBS) - -pkgsysconf_SCRIPTS=avahi-dnsconfd.action - -%.service: %.service.in - $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - -if HAVE_SYSTEMD -systemdsystemunit_DATA = \ - avahi-dnsconfd.service -endif - -CLEANFILES = $(systemdsystemunit_DATA) - -endif -endif diff --git a/avahi-dnsconfd/avahi-dnsconfd.action b/avahi-dnsconfd/avahi-dnsconfd.action deleted file mode 100755 index f0ace51..0000000 --- a/avahi-dnsconfd/avahi-dnsconfd.action +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -set -e - -test "x$AVAHI_INTERFACE" != "x" - -# Command line arguments: -# $1 "+" if a new DNS server was found, "-" if one was removed -# $2 DNS Server address -# $3 interface index where this server was found on -# $4 protocol number where this server was found on - -# Available environment variables: -# -# $AVAHI_INTERFACE The interface name where this DNS server was found on -# $AVAHI_INTERFACE_DNS_SERVERS A whitespace seperated list of DNS servers on $AVAHI_INTERFACE -# $AVAHI_DNS_SERVERS The complete list of all DNS servers found on all interfaces - -if [ -x /sbin/netconfig ]; then - # SUSE method on 11.1+ - if [ -n "$AVAHI_INTERFACE_DNS_SERVERS" ]; then - /sbin/netconfig modify -s avahi -i "$AVAHI_INTERFACE" <<-EOF - INTERFACE='$AVAHI_INTERFACE' - DNSSERVERS='$AVAHI_INTERFACE_DNS_SERVERS' - EOF - else - /sbin/netconfig remove -s avahi -i "$AVAHI_INTERFACE" - fi -elif [ -x /sbin/modify_resolvconf ] ; then - # method for SUSE <= 11.0 - if [ -n "$AVAHI_DNS_SERVERS" ]; then - /sbin/modify_resolvconf modify -s avahi -t - -p avahi-dnsconfd -n "$AVAHI_DNS_SERVERS" <<-EOF - if you don't like avahi to update your Nameservers - disable the avahi-dnsconfd init script - EOF - else - /sbin/modify_resolvconf restore -s avahi - fi -elif [ -x /sbin/resolvconf ] ; then - - # We have Debian's resolvconf tool - - if [ "x$AVAHI_INTERFACE_DNS_SERVERS" = "x" ] ; then - /sbin/resolvconf -d "$AVAHI_INTERFACE.avahi" - else - for n in $AVAHI_INTERFACE_DNS_SERVERS ; do - echo "nameserver $n" - done | /sbin/resolvconf -a "$AVAHI_INTERFACE.avahi" - fi -else - - # No resolvconf tool available - - if [ "x$AVAHI_DNS_SERVERS" = "x" ] ; then - test -f /etc/resolv.conf.avahi && mv /etc/resolv.conf.avahi /etc/resolv.conf - else - test -f /etc/resolv.conf.avahi || mv /etc/resolv.conf /etc/resolv.conf.avahi - - for n in $AVAHI_DNS_SERVERS ; do - echo "nameserver $n" - done > /etc/resolv.conf - fi -fi diff --git a/avahi-dnsconfd/avahi-dnsconfd.service.in b/avahi-dnsconfd/avahi-dnsconfd.service.in deleted file mode 100644 index 95db79f..0000000 --- a/avahi-dnsconfd/avahi-dnsconfd.service.in +++ /dev/null @@ -1,29 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -[Unit] -Description=Avahi DNS Configuration Daemon -Requires=avahi-daemon.socket avahi-daemon.service -After=avahi-daemon.socket - -[Service] -Type=simple -ExecStart=@sbindir@/avahi-dnsconfd -s - -[Install] -WantedBy=multi-user.target -Also=avahi-daemon.socket diff --git a/avahi-dnsconfd/main.c b/avahi-dnsconfd/main.c deleted file mode 100644 index 719fbeb..0000000 --- a/avahi-dnsconfd/main.c +++ /dev/null @@ -1,668 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define BROWSE_DNS_SERVERS "BROWSE-DNS-SERVERS\n" - -#define ENV_INTERFACE_DNS_SERVERS "AVAHI_INTERFACE_DNS_SERVERS" -#define ENV_DNS_SERVERS "AVAHI_DNS_SERVERS" -#define ENV_INTERFACE "AVAHI_INTERFACE" - -static enum { - ACKWAIT, - BROWSING -} state = ACKWAIT; - -static enum { - DAEMON_RUN, - DAEMON_KILL, - DAEMON_REFRESH, - DAEMON_VERSION, - DAEMON_HELP, - DAEMON_CHECK -} command = DAEMON_RUN; - -static int quit = 0; -static int daemonize = 0; -static int use_syslog = 0; - -#if !HAVE_DECL_ENVIRON -extern char **environ; -#endif - -typedef struct DNSServerInfo DNSServerInfo; - -struct DNSServerInfo { - AvahiIfIndex interface; - AvahiProtocol protocol; - char *address; - AVAHI_LLIST_FIELDS(DNSServerInfo, servers); -}; - -static AVAHI_LLIST_HEAD(DNSServerInfo, servers); - -static void server_info_free(DNSServerInfo *i) { - assert(i); - - avahi_free(i->address); - - AVAHI_LLIST_REMOVE(DNSServerInfo, servers, servers, i); - avahi_free(i); -} - -static DNSServerInfo* get_server_info(AvahiIfIndex interface, AvahiProtocol protocol, const char *address) { - DNSServerInfo *i; - assert(address); - - for (i = servers; i; i = i->servers_next) - if (i->interface == interface && - i->protocol == protocol && - strcmp(i->address, address) == 0) - return i; - - return NULL; -} - -static DNSServerInfo* new_server_info(AvahiIfIndex interface, AvahiProtocol protocol, const char *address) { - DNSServerInfo *i; - - assert(address); - - i = avahi_new(DNSServerInfo, 1); - i->interface = interface; - i->protocol = protocol; - i->address = avahi_strdup(address); - - AVAHI_LLIST_PREPEND(DNSServerInfo, servers, servers, i); - - return i; -} - -static int set_cloexec(int fd) { - int n; - - assert(fd >= 0); - - if ((n = fcntl(fd, F_GETFD)) < 0) - return -1; - - if (n & FD_CLOEXEC) - return 0; - - return fcntl(fd, F_SETFD, n|FD_CLOEXEC); -} - -static int open_socket(void) { - int fd = -1; - struct sockaddr_un sa; - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - daemon_log(LOG_ERR, "socket(): %s", strerror(errno)); - goto fail; - } - - if (set_cloexec(fd) < 0) { - daemon_log(LOG_ERR, "fcntl(): %s", strerror(errno)); - goto fail; - } - - memset(&sa, 0, sizeof(sa)); - sa.sun_family = AF_UNIX; - strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1); - sa.sun_path[sizeof(sa.sun_path)-1] = 0; - - if (connect(fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) { - daemon_log(LOG_ERR, "connect(): %s", strerror(errno)); - daemon_log(LOG_INFO, "Failed to connect to the daemon. This probably means that you"); - daemon_log(LOG_INFO, "didn't start avahi-daemon before avahi-dnsconfd."); - goto fail; - } - - return fd; - -fail: - if (fd >= 0) - close(fd); - - return -1; -} - -static ssize_t loop_write(int fd, const void*data, size_t size) { - - ssize_t ret = 0; - assert(fd >= 0 && data && size); - - while (size > 0) { - ssize_t r; - - if ((r = write(fd, data, size)) < 0) - return r; - - if (r == 0) - break; - - ret += r; - data = (const uint8_t*) data + r; - size -= r; - } - - return ret; -} - -static char *concat_dns_servers(AvahiIfIndex interface) { - DNSServerInfo *i; - char *r = NULL; - - for (i = servers; i; i = i->servers_next) - if (i->interface == interface || interface <= 0) { - DNSServerInfo *j; - char *t; - - /* Filter out double entries */ - for (j = servers; j != i; j = j->servers_next) - if (j->interface == interface || interface <= 0) - if (strcmp(i->address, j->address) == 0) - break; - - if (j != i) - continue; - - if (!r) - t = avahi_strdup(i->address); - else - t = avahi_strdup_printf("%s %s", r, i->address); - - avahi_free(r); - r = t; - } - - return r; -} - -static void set_env(const char *name, const char *value) { - char **e; - size_t l; - - assert(name); - assert(value); - - l = strlen(name); - - for (e = environ; *e; e++) { - /* Search for the variable */ - if (strlen(*e) < l+1) - continue; - - if (strncmp(*e, name, l) != 0 || (*e)[l] != '=') - continue; - - /* We simply free the record, sicne we know that we created it previously */ - avahi_free(*e); - *e = avahi_strdup_printf("%s=%s", name, value); - return; - } - - assert(0); -} - -static void run_script(int new, AvahiIfIndex interface, AvahiProtocol protocol, const char *address) { - char *p; - int ret; - char ia[16], pa[16]; - char name[IF_NAMESIZE]; - - assert(interface > 0); - - if (!if_indextoname(interface, name)) - return; - - p = concat_dns_servers(interface); - set_env(ENV_INTERFACE_DNS_SERVERS, p ? p : ""); - avahi_free(p); - - p = concat_dns_servers(-1); - set_env(ENV_DNS_SERVERS, p ? p : ""); - avahi_free(p); - - set_env(ENV_INTERFACE, name); - - snprintf(ia, sizeof(ia), "%i", (int) interface); - snprintf(pa, sizeof(pa), "%i", (int) protocol); - - if (daemon_exec("/", &ret, AVAHI_DNSCONF_SCRIPT, AVAHI_DNSCONF_SCRIPT, new ? "+" : "-", address, ia, pa, avahi_proto_to_string(protocol), NULL) < 0) - daemon_log(LOG_WARNING, "Failed to run script"); - else if (ret != 0) - daemon_log(LOG_WARNING, "Script returned with non-zero exit code %i", ret); -} - -static int new_line(const char *l) { - assert(l); - - if (state == ACKWAIT) { - if (*l != '+') { - daemon_log(LOG_ERR, "Avahi command failed: %s", l); - return -1; - } - - daemon_log(LOG_INFO, "Successfully connected to Avahi daemon."); - state = BROWSING; - } else { - AvahiIfIndex interface; - AvahiProtocol protocol; - int i_interface, i_protocol, port; - char a[AVAHI_ADDRESS_STR_MAX]; - - assert(state == BROWSING); - - if (*l != '<' && *l != '>') { - daemon_log(LOG_ERR, "Avahi sent us an invalid browsing line: %s", l); - return -1; - } - - if (sscanf(l+1, "%i %i %39s %i", &i_interface, &i_protocol, a, &port) != 4) { - daemon_log(LOG_ERR, "Failed to parse browsing line: %s", l); - return -1; - } - - interface = (AvahiIfIndex) i_interface; - protocol = (AvahiProtocol) i_protocol; - - if (*l == '>') { - if (port != 53) - daemon_log(LOG_WARNING, "DNS server with port address != 53 found, ignoring"); - else { - daemon_log(LOG_INFO, "New DNS Server %s (interface: %i.%s)", a, interface, avahi_proto_to_string(protocol)); - new_server_info(interface, protocol, a); - run_script(1, interface, protocol, a); - } - } else { - DNSServerInfo *i; - - if (port == 53) - if ((i = get_server_info(interface, protocol, a))) { - daemon_log(LOG_INFO, "DNS Server %s removed (interface: %i.%s)", a, interface, avahi_proto_to_string(protocol)); - server_info_free(i); - run_script(0, interface, protocol, a); - } - } - - } - - return 0; -} - -static int do_connect(void) { - int fd = -1; - - if ((fd = open_socket()) < 0) - goto fail; - - if (loop_write(fd, BROWSE_DNS_SERVERS, sizeof(BROWSE_DNS_SERVERS)-1) < 0) { - daemon_log(LOG_ERR, "write(): %s", strerror(errno)); - goto fail; - } - - state = ACKWAIT; - return fd; - -fail: - if (fd >= 0) - close(fd); - - return -1; -} - -static void free_dns_server_info_list(void) { - while (servers) { - AvahiIfIndex interface = servers->interface; - AvahiProtocol protocol = servers->protocol; - char *address = avahi_strdup(servers->address); - server_info_free(servers); - - run_script(0, interface, protocol, address); - avahi_free(address); - } -} - -static void help(FILE *f, const char *argv0) { - fprintf(f, - "%s [options]\n" - " -h --help Show this help\n" - " -D --daemonize Daemonize after startup\n" - " -s --syslog Write log messages to syslog(3) instead of STDERR\n" - " -k --kill Kill a running daemon\n" - " -r --refresh Request a running daemon to refresh DNS server data\n" - " -c --check Return 0 if a daemon is already running\n" - " -V --version Show version\n", - argv0); -} - -static int parse_command_line(int argc, char *argv[]) { - int c; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "daemonize", no_argument, NULL, 'D' }, - { "syslog", no_argument, NULL, 's' }, - { "kill", no_argument, NULL, 'k' }, - { "version", no_argument, NULL, 'V' }, - { "refresh", no_argument, NULL, 'r' }, - { "check", no_argument, NULL, 'c' }, - { NULL, 0, NULL, 0 } - }; - - while ((c = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) { - - switch(c) { - case 'h': - command = DAEMON_HELP; - break; - case 'D': - daemonize = 1; - break; - case 's': - use_syslog = 1; - break; - case 'k': - command = DAEMON_KILL; - break; - case 'V': - command = DAEMON_VERSION; - break; - case 'r': - command = DAEMON_REFRESH; - break; - case 'c': - command = DAEMON_CHECK; - break; - default: - return -1; - } - } - - if (optind < argc) { - fprintf(stderr, "Too many arguments\n"); - return -1; - } - - return 0; -} - -static int run_daemon(void) { - int fd = -1, ret = -1; - char buf[1024]; - size_t buflen = 0; - - AVAHI_LLIST_HEAD_INIT(DNSServerInfo, servers); - - daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP, 0); - - /* Allocate some memory for our environment variables */ - putenv(avahi_strdup(ENV_INTERFACE"=")); - putenv(avahi_strdup(ENV_DNS_SERVERS"=")); - putenv(avahi_strdup(ENV_INTERFACE_DNS_SERVERS"=")); - - if ((fd = do_connect()) < 0) - goto finish; - - if (daemonize) - daemon_retval_send(0); - - ret = 0; - - while (!quit) { - fd_set rfds, wfds; - - FD_ZERO(&rfds); - FD_ZERO(&wfds); - - FD_SET(fd, &rfds); - FD_SET(daemon_signal_fd(), &rfds); - - for (;;) { - if (select(fd+1, &rfds, NULL, NULL, NULL) < 0) { - if (errno == EINTR) - continue; - - daemon_log(LOG_ERR, "select(): %s", strerror(errno)); - goto finish; - } - - break; - } - - if (FD_ISSET(daemon_signal_fd(), &rfds)) { - - int sig; - - if ((sig = daemon_signal_next()) <= 0) { - daemon_log(LOG_ERR, "daemon_signal_next() failed"); - goto finish; - } - - switch(sig) { - case SIGINT: - case SIGTERM: - daemon_log(LOG_INFO, "Got %s, quitting.", sig == SIGINT ? "SIGINT" : "SIGTERM"); - ret = 0; - goto finish; - - case SIGCHLD: - waitpid(-1, NULL, WNOHANG); - break; - - case SIGHUP: - daemon_log(LOG_INFO, "Refreshing DNS Server list"); - - close(fd); - free_dns_server_info_list(); - - if ((fd = do_connect()) < 0) - goto finish; - - break; - } - - } else if (FD_ISSET(fd, &rfds)) { - ssize_t r; - char *n; - - if ((r = read(fd, buf, sizeof(buf) - buflen - 1)) <= 0) { - daemon_log(LOG_ERR, "read(): %s", r < 0 ? strerror(errno) : "EOF"); - goto finish; - } - - buflen += r; - assert(buflen <= sizeof(buf)-1); - - while ((n = memchr(buf, '\n', buflen))) { - *(n++) = 0; - - if (new_line(buf) < 0) - goto finish; - - buflen -= (n - buf); - memmove(buf, n, buflen); - } - - if (buflen >= sizeof(buf)-1) { - /* The incoming line is horribly long */ - buf[sizeof(buf)-1] = 0; - - if (new_line(buf) < 0) - goto finish; - - buflen = 0; - } - } - } - -finish: - - free_dns_server_info_list(); - - if (fd >= 0) - close(fd); - - daemon_signal_done(); - - if (ret != 0 && daemonize) - daemon_retval_send(1); - - return ret; -} - -static const char* pid_file_proc(void) { - return AVAHI_RUNTIME_DIR"/avahi-dnsconfd.pid"; -} - -int main(int argc, char *argv[]) { - char *argv0; - int r = 1; - int wrote_pid_file = 0; - - if ((argv0 = strrchr(argv[0], '/'))) - argv0++; - else - argv0 = argv[0]; - - daemon_pid_file_ident = daemon_log_ident = argv0; - daemon_pid_file_proc = pid_file_proc; - - if (parse_command_line(argc, argv) < 0) - goto finish; - - if (command == DAEMON_RUN) { - pid_t pid; - - if (getuid() != 0) { - daemon_log(LOG_ERR, "This program is intended to be run as root."); - goto finish; - } - - if ((pid = daemon_pid_file_is_running()) >= 0) { - daemon_log(LOG_ERR, "Daemon already running on PID %u", pid); - goto finish; - } - - if (daemonize) { - daemon_retval_init(); - - if ((pid = daemon_fork()) < 0) - goto finish; - else if (pid != 0) { - int ret; - /** Parent **/ - - if ((ret = daemon_retval_wait(20)) < 0) { - daemon_log(LOG_ERR, "Could not receive return value from daemon process."); - goto finish; - } - - r = ret; - goto finish; - } - - /* Child */ - } - - if (use_syslog || daemonize) - daemon_log_use = DAEMON_LOG_SYSLOG; - - chdir("/"); - - if (daemon_pid_file_create() < 0) { - daemon_log(LOG_ERR, "Failed to create PID file: %s", strerror(errno)); - - if (daemonize) - daemon_retval_send(1); - goto finish; - } else - wrote_pid_file = 1; - - if (run_daemon() < 0) - goto finish; - - r = 0; - } else if (command == DAEMON_HELP) { - help(stdout, argv0); - - r = 0; - } else if (command == DAEMON_VERSION) { - printf("%s "PACKAGE_VERSION"\n", argv0); - - r = 0; - } else if (command == DAEMON_KILL) { - if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) { - daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno)); - goto finish; - } - - r = 0; - } else if (command == DAEMON_REFRESH) { - if (daemon_pid_file_kill(SIGHUP) < 0) { - daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno)); - goto finish; - } - - r = 0; - } else if (command == DAEMON_CHECK) - r = (daemon_pid_file_is_running() >= 0) ? 0 : 1; - - -finish: - - if (daemonize) - daemon_retval_done(); - - if (wrote_pid_file) - daemon_pid_file_remove(); - - return r; -} diff --git a/avahi-glib.pc.in b/avahi-glib.pc.in deleted file mode 100644 index f163e89..0000000 --- a/avahi-glib.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include - -Name: avahi-glib -Description: Avahi Multicast DNS Responder (GLib Support) -Version: @PACKAGE_VERSION@ -Requires: glib-2.0 -Libs: -L${libdir} -lavahi-glib -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-glib/.gitignore b/avahi-glib/.gitignore deleted file mode 100644 index 02ec7d3..0000000 --- a/avahi-glib/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs -glib-watch-test diff --git a/avahi-glib/Makefile.am b/avahi-glib/Makefile.am deleted file mode 100644 index b5d5fba..0000000 --- a/avahi-glib/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -if HAVE_GLIB - -avahiglibincludedir=$(includedir)/avahi-glib - -avahiglibinclude_HEADERS = \ - glib-watch.h \ - glib-malloc.h - -lib_LTLIBRARIES = \ - libavahi-glib.la - -if ENABLE_TESTS -noinst_PROGRAMS = \ - glib-watch-test -endif - -libavahi_glib_la_SOURCES = \ - glib-watch.c glib-watch.h \ - glib-malloc.h glib-malloc.c - -libavahi_glib_la_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS) -libavahi_glib_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(GLIB20_LIBS) -libavahi_glib_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_GLIB_VERSION_INFO) - -glib_watch_test_SOURCES = \ - glib-watch.c glib-watch.h \ - glib-watch-test.c -glib_watch_test_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS) -glib_watch_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(GLIB20_LIBS) - -endif diff --git a/avahi-glib/glib-malloc.c b/avahi-glib/glib-malloc.c deleted file mode 100644 index 20ac1d1..0000000 --- a/avahi-glib/glib-malloc.c +++ /dev/null @@ -1,55 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "glib-malloc.h" - -static void* malloc_glue(size_t l) { - return g_malloc(l); -} - -static void* realloc_glue(void *p, size_t l) { - return g_realloc(p, l); -} - -static void* calloc_glue(size_t nmemb, size_t size) { - return g_malloc0(nmemb * size); -} - -const AvahiAllocator *avahi_glib_allocator(void) { - - static AvahiAllocator allocator; - static int allocator_initialized = 0; - - if (!allocator_initialized) { - allocator.malloc = malloc_glue; - allocator.free = g_free; - allocator.realloc = realloc_glue; - allocator.calloc = calloc_glue; - allocator_initialized = 1; - } - - return &allocator; -} diff --git a/avahi-glib/glib-malloc.h b/avahi-glib/glib-malloc.h deleted file mode 100644 index 8b189d2..0000000 --- a/avahi-glib/glib-malloc.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef fooglibmallochfoo -#define fooglibmallochfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -/** \file glib-malloc.h GLib's memory allocator for Avahi */ - -#include - -#include -#include - -AVAHI_C_DECL_BEGIN - -/** Return a pointer to a memory allocator that uses GLib's g_malloc() - and friends. The returned structure is statically allocated, and needs - not to be copied or freed. Pass this directly to avahi_set_allocator(). */ -const AvahiAllocator * avahi_glib_allocator(void); - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-glib/glib-watch-test.c b/avahi-glib/glib-watch-test.c deleted file mode 100644 index 53c6683..0000000 --- a/avahi-glib/glib-watch-test.c +++ /dev/null @@ -1,89 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "glib-watch.h" - -static const AvahiPoll *api = NULL; -static GMainLoop *loop = NULL; - -static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) { - - if (event & AVAHI_WATCH_IN) { - ssize_t r; - char c; - - if ((r = read(fd, &c, 1)) <= 0) { - fprintf(stderr, "read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); - api->watch_free(w); - return; - } - - printf("Read: %c\n", c >= 32 && c < 127 ? c : '.'); - } -} - -static void wakeup(AvahiTimeout *t, AVAHI_GCC_UNUSED void *userdata) { - struct timeval tv; - static int i = 0; - - printf("Wakeup #%i\n", i++); - - if (i > 10) - g_main_loop_quit(loop); - - avahi_elapse_time(&tv, 1000, 0); - api->timeout_update(t, &tv); -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - AvahiGLibPoll *g; - struct timeval tv; - - g = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT); - assert(g); - - api = avahi_glib_poll_get(g); - - api->watch_new(api, 0, AVAHI_WATCH_IN, callback, NULL); - - avahi_elapse_time(&tv, 1000, 0); - api->timeout_new(api, &tv, wakeup, NULL); - - loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(loop); - g_main_loop_unref(loop); - - avahi_glib_poll_free(g); - - return 0; -} diff --git a/avahi-glib/glib-watch.c b/avahi-glib/glib-watch.c deleted file mode 100644 index 5b60bbc..0000000 --- a/avahi-glib/glib-watch.c +++ /dev/null @@ -1,402 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include "glib-watch.h" - -struct AvahiWatch { - AvahiGLibPoll *glib_poll; - int dead; - - GPollFD pollfd; - int pollfd_added; - - AvahiWatchCallback callback; - void *userdata; - - AVAHI_LLIST_FIELDS(AvahiWatch, watches); -}; - -struct AvahiTimeout { - AvahiGLibPoll *glib_poll; - gboolean dead; - - gboolean enabled; - struct timeval expiry; - - AvahiTimeoutCallback callback; - void *userdata; - - AVAHI_LLIST_FIELDS(AvahiTimeout, timeouts); -}; - -struct AvahiGLibPoll { - GSource source; - AvahiPoll api; - GMainContext *context; - - gboolean timeout_req_cleanup; - gboolean watch_req_cleanup; - - AVAHI_LLIST_HEAD(AvahiWatch, watches); - AVAHI_LLIST_HEAD(AvahiTimeout, timeouts); -}; - -static void destroy_watch(AvahiWatch *w) { - assert(w); - - if (w->pollfd_added) - g_source_remove_poll(&w->glib_poll->source, &w->pollfd); - - AVAHI_LLIST_REMOVE(AvahiWatch, watches, w->glib_poll->watches, w); - - avahi_free(w); -} - -static void cleanup_watches(AvahiGLibPoll *g, int all) { - AvahiWatch *w, *next; - assert(g); - - for (w = g->watches; w; w = next) { - next = w->watches_next; - - if (all || w->dead) - destroy_watch(w); - } - - g->watch_req_cleanup = 0; -} - -static gushort map_events_to_glib(AvahiWatchEvent events) { - return - (events & AVAHI_WATCH_IN ? G_IO_IN : 0) | - (events & AVAHI_WATCH_OUT ? G_IO_OUT : 0) | - (events & AVAHI_WATCH_ERR ? G_IO_ERR : 0) | - (events & AVAHI_WATCH_HUP ? G_IO_HUP : 0); -} - -static AvahiWatchEvent map_events_from_glib(gushort events) { - return - (events & G_IO_IN ? AVAHI_WATCH_IN : 0) | - (events & G_IO_OUT ? AVAHI_WATCH_OUT : 0) | - (events & G_IO_ERR ? AVAHI_WATCH_ERR : 0) | - (events & G_IO_HUP ? AVAHI_WATCH_HUP : 0); -} - -static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent events, AvahiWatchCallback callback, void *userdata) { - AvahiWatch *w; - AvahiGLibPoll *g; - - assert(api); - assert(fd >= 0); - assert(callback); - - g = api->userdata; - assert(g); - - if (!(w = avahi_new(AvahiWatch, 1))) - return NULL; - - w->glib_poll = g; - w->pollfd.fd = fd; - w->pollfd.events = map_events_to_glib(events); - w->pollfd.revents = 0; - w->callback = callback; - w->userdata = userdata; - w->dead = FALSE; - - g_source_add_poll(&g->source, &w->pollfd); - w->pollfd_added = TRUE; - - AVAHI_LLIST_PREPEND(AvahiWatch, watches, g->watches, w); - - return w; -} - -static void watch_update(AvahiWatch *w, AvahiWatchEvent events) { - assert(w); - assert(!w->dead); - - w->pollfd.events = map_events_to_glib(events); -} - -static AvahiWatchEvent watch_get_events(AvahiWatch *w) { - assert(w); - assert(!w->dead); - - return map_events_from_glib(w->pollfd.revents); -} - -static void watch_free(AvahiWatch *w) { - assert(w); - assert(!w->dead); - - if (w->pollfd_added) { - g_source_remove_poll(&w->glib_poll->source, &w->pollfd); - w->pollfd_added = FALSE; - } - - w->dead = TRUE; - w->glib_poll->timeout_req_cleanup = TRUE; -} - -static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) { - AvahiTimeout *t; - AvahiGLibPoll *g; - - assert(api); - assert(callback); - - g = api->userdata; - assert(g); - - if (!(t = avahi_new(AvahiTimeout, 1))) - return NULL; - - t->glib_poll = g; - t->dead = FALSE; - - if ((t->enabled = !!tv)) - t->expiry = *tv; - - t->callback = callback; - t->userdata = userdata; - - AVAHI_LLIST_PREPEND(AvahiTimeout, timeouts, g->timeouts, t); - - return t; -} - -static void timeout_update(AvahiTimeout *t, const struct timeval *tv) { - assert(t); - assert(!t->dead); - - if ((t->enabled = !!tv)) - t->expiry = *tv; -} - -static void timeout_free(AvahiTimeout *t) { - assert(t); - assert(!t->dead); - - t->dead = TRUE; - t->glib_poll->timeout_req_cleanup = TRUE; -} - -static void destroy_timeout(AvahiTimeout *t) { - assert(t); - - AVAHI_LLIST_REMOVE(AvahiTimeout, timeouts, t->glib_poll->timeouts, t); - avahi_free(t); -} - -static void cleanup_timeouts(AvahiGLibPoll *g, int all) { - AvahiTimeout *t, *next; - assert(g); - - for (t = g->timeouts; t; t = next) { - next = t->timeouts_next; - - if (all || t->dead) - destroy_timeout(t); - } - - g->timeout_req_cleanup = FALSE; -} - -static AvahiTimeout* find_next_timeout(AvahiGLibPoll *g) { - AvahiTimeout *t, *n = NULL; - assert(g); - - for (t = g->timeouts; t; t = t->timeouts_next) { - - if (t->dead || !t->enabled) - continue; - - if (!n || avahi_timeval_compare(&t->expiry, &n->expiry) < 0) - n = t; - } - - return n; -} - -static void start_timeout_callback(AvahiTimeout *t) { - assert(t); - assert(!t->dead); - assert(t->enabled); - - t->enabled = 0; - t->callback(t, t->userdata); -} - -static gboolean prepare_func(GSource *source, gint *timeout) { - AvahiGLibPoll *g = (AvahiGLibPoll*) source; - AvahiTimeout *next_timeout; - - g_assert(g); - g_assert(timeout); - - if (g->watch_req_cleanup) - cleanup_watches(g, 0); - - if (g->timeout_req_cleanup) - cleanup_timeouts(g, 0); - - if ((next_timeout = find_next_timeout(g))) { - GTimeVal now; - struct timeval tvnow; - AvahiUsec usec; - - g_source_get_current_time(source, &now); - tvnow.tv_sec = now.tv_sec; - tvnow.tv_usec = now.tv_usec; - - usec = avahi_timeval_diff(&next_timeout->expiry, &tvnow); - - if (usec <= 0) { - *timeout = 0; - return TRUE; - } - - *timeout = (gint) (usec / 1000); - } else - *timeout = -1; - - return FALSE; -} - -static gboolean check_func(GSource *source) { - AvahiGLibPoll *g = (AvahiGLibPoll*) source; - AvahiWatch *w; - AvahiTimeout *next_timeout; - - g_assert(g); - - if ((next_timeout = find_next_timeout(g))) { - GTimeVal now; - struct timeval tvnow; - g_source_get_current_time(source, &now); - tvnow.tv_sec = now.tv_sec; - tvnow.tv_usec = now.tv_usec; - - if (avahi_timeval_compare(&next_timeout->expiry, &tvnow) <= 0) - return TRUE; - } - - for (w = g->watches; w; w = w->watches_next) - if (w->pollfd.revents > 0) - return TRUE; - - return FALSE; -} - -static gboolean dispatch_func(GSource *source, AVAHI_GCC_UNUSED GSourceFunc callback, AVAHI_GCC_UNUSED gpointer userdata) { - AvahiGLibPoll* g = (AvahiGLibPoll*) source; - AvahiWatch *w; - AvahiTimeout *next_timeout; - - g_assert(g); - - if ((next_timeout = find_next_timeout(g))) { - GTimeVal now; - struct timeval tvnow; - g_source_get_current_time(source, &now); - tvnow.tv_sec = now.tv_sec; - tvnow.tv_usec = now.tv_usec; - - if (avahi_timeval_compare(&next_timeout->expiry, &tvnow) < 0) { - start_timeout_callback(next_timeout); - return TRUE; - } - } - - for (w = g->watches; w; w = w->watches_next) - if (w->pollfd.revents > 0) { - assert(w->callback); - w->callback(w, w->pollfd.fd, map_events_from_glib(w->pollfd.revents), w->userdata); - w->pollfd.revents = 0; - return TRUE; - } - - return TRUE; -} - -AvahiGLibPoll *avahi_glib_poll_new(GMainContext *context, gint priority) { - AvahiGLibPoll *g; - - static GSourceFuncs source_funcs = { - prepare_func, - check_func, - dispatch_func, - NULL, - NULL, - NULL - }; - - g = (AvahiGLibPoll*) g_source_new(&source_funcs, sizeof(AvahiGLibPoll)); - g_main_context_ref(g->context = context ? context : g_main_context_default()); - - g->api.userdata = g; - - g->api.watch_new = watch_new; - g->api.watch_free = watch_free; - g->api.watch_update = watch_update; - g->api.watch_get_events = watch_get_events; - - g->api.timeout_new = timeout_new; - g->api.timeout_free = timeout_free; - g->api.timeout_update = timeout_update; - - g->watch_req_cleanup = FALSE; - g->timeout_req_cleanup = FALSE; - - AVAHI_LLIST_HEAD_INIT(AvahiWatch, g->watches); - AVAHI_LLIST_HEAD_INIT(AvahiTimeout, g->timeouts); - - g_source_attach(&g->source, g->context); - g_source_set_priority(&g->source, priority); - g_source_set_can_recurse(&g->source, FALSE); - - return g; -} - -void avahi_glib_poll_free(AvahiGLibPoll *g) { - GSource *s = &g->source; - assert(g); - - cleanup_watches(g, 1); - cleanup_timeouts(g, 1); - - g_main_context_unref(g->context); - g_source_destroy(s); - g_source_unref(s); -} - -const AvahiPoll* avahi_glib_poll_get(AvahiGLibPoll *g) { - assert(g); - - return &g->api; -} diff --git a/avahi-glib/glib-watch.h b/avahi-glib/glib-watch.h deleted file mode 100644 index ffc3aac..0000000 --- a/avahi-glib/glib-watch.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef fooglibwatchhfoo -#define fooglibwatchhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -/** \file glib-watch.h GLib main loop adapter */ - -/** \example glib-integration.c Example of how to integrate - * avahi use with GLIB/GTK applications */ - -#include - -#include -#include - -AVAHI_C_DECL_BEGIN - -/** GLib main loop adapter. You can safely cast this into a GSource */ -typedef struct AvahiGLibPoll AvahiGLibPoll; - -/** Create a new GLib main loop adapter attached to the specified - context. If context is NULL, the default main loop context is - used. You can attach as many AvahiGLibPoll objects to the same context - as you want. priority takes one of GLib's G_PRIORITY constants. */ -AvahiGLibPoll *avahi_glib_poll_new(GMainContext *context, gint priority); - -/** Free GLib main loop adapter */ -void avahi_glib_poll_free(AvahiGLibPoll *g); - -/** Return the abstract poll API structure for this object. This will - * return the same pointer to a internally allocated structure on each - * call */ -const AvahiPoll *avahi_glib_poll_get(AvahiGLibPoll *g); - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-gobject.pc.in b/avahi-gobject.pc.in deleted file mode 100644 index bf38200..0000000 --- a/avahi-gobject.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include - -Name: avahi-gobject -Description: Avahi Multicast DNS Responder (GLib GObject Support) -Version: @PACKAGE_VERSION@ -Requires.private: glib-2.0 gobject-2.0 avahi-glib avahi-client -Libs: -L${libdir} -lavahi-gobject -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-gobject/.gitignore b/avahi-gobject/.gitignore deleted file mode 100644 index 402b45c..0000000 --- a/avahi-gobject/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -*.typelib -Avahi-0.6.gir -ga-*-enumtypes.c -ga-*-enumtypes.h -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs -signals-marshal.c -signals-marshal.h -signals-marshal.list diff --git a/avahi-gobject/AvahiCore-0.6.gir b/avahi-gobject/AvahiCore-0.6.gir deleted file mode 100644 index 5d7f68b..0000000 --- a/avahi-gobject/AvahiCore-0.6.gir +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avahi-gobject/Makefile.am b/avahi-gobject/Makefile.am deleted file mode 100644 index 02f2b94..0000000 --- a/avahi-gobject/Makefile.am +++ /dev/null @@ -1,142 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -EXTRA_DIST = \ - AvahiCore-0.6.gir - -if HAVE_GOBJECT -if HAVE_DBUS - -avahigobjectincludedir=$(includedir)/avahi-gobject - -avahigobjectinclude_HEADERS = \ - ga-client.h \ - ga-entry-group.h \ - ga-enums.h \ - ga-error.h \ - ga-record-browser.h \ - ga-service-browser.h \ - ga-service-resolver.h - -lib_LTLIBRARIES = \ - libavahi-gobject.la - -BUILT_SOURCES = \ - signals-marshal.list \ - signals-marshal.h \ - signals-marshal.c \ - ga-client-enumtypes.h \ - ga-client-enumtypes.c \ - ga-entry-group-enumtypes.h \ - ga-entry-group-enumtypes.c \ - ga-enums-enumtypes.h \ - ga-enums-enumtypes.c - -CORE_SOURCES = \ - ga-client.c ga-client.h \ - ga-entry-group.c ga-entry-group.h \ - ga-enums.h \ - ga-error.c ga-error.h \ - ga-record-browser.c ga-record-browser.h \ - ga-service-browser.c ga-service-browser.h \ - ga-service-resolver.c ga-service-resolver.h - -libavahi_gobject_la_SOURCES = \ - $(CORE_SOURCES) \ - $(BUILT_SOURCES) - -libavahi_gobject_la_CFLAGS = $(AM_CFLAGS) $(GOBJECT_CFLAGS) -libavahi_gobject_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GOBJECT_LIBS) -libavahi_gobject_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_GOBJECT_VERSION_INFO) -export-symbols-regex '^ga_' - -# correctly clean the generated source files -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - $(shell for x in $(BUILT_SOURCES); do rm -f $(distdir)/$$x ; done) - -signals-marshal.list: $(CORE_SOURCES) Makefile.am - $(AM_V_GEN)( cd $(srcdir) && \ - sed -n -e 's/.*_ga_signals_marshal_\([A-Z]*__[A-Z_]*\).*/\1/p' \ - $(CORE_SOURCES) ) \ - | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp && \ - if cmp -s $@.tmp $@; then \ - rm $@.tmp; \ - else \ - mv $@.tmp $@; \ - fi - -signals-marshal.h: signals-marshal.list - $(AM_V_GEN)glib-genmarshal --header --prefix=_ga_signals_marshal $< > $@ - -signals-marshal.c: signals-marshal.list - $(AM_V_GEN)(echo "#include \"signals-marshal.h\"" ; glib-genmarshal --body --prefix=_ga_signals_marshal $< ) > $@ - -# rules for making the glib enum objects -%-enumtypes.h: %.h Makefile.in - $(AM_V_GEN)glib-mkenums \ - --fhead "#ifndef __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n#define __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n\n#include \n\nG_BEGIN_DECLS\n" \ - --fprod "/* enumerations from \"@filename@\" */\n" \ - --vhead "GType @enum_name@_get_type (void);\n#define $(shell echo $* | tr [:lower:]- [:upper:]_ | sed 's/_.*//')_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ - --ftail "G_END_DECLS\n\n#endif /* __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__ */" \ - $< > $@ - -%-enumtypes.c: %.h Makefile.in - $(AM_V_GEN)glib-mkenums \ - --fhead "#include <$*.h>\n#include<$*-enumtypes.h>" \ - --fprod "\n/* enumerations from \"@filename@\" */" \ - --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \ - --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@VALUENAME@\" }," \ - --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \ - $< > $@ - --include $(INTROSPECTION_MAKEFILE) -INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) -INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) - -if HAVE_INTROSPECTION -introspection_sources = $(libavahi_gobject_la_SOURCES) - -Avahi-0.6.gir: $(lib_LTLIBRARIES) -Avahi_0_6_gir_INCLUDES = GObject-2.0 AvahiCore-0.6 -Avahi_0_6_gir_CFLAGS = $(libavahi_gobject_la_CFLAGS) -Avahi_0_6_gir_LIBS = $(lib_LTLIBRARIES) -Avahi_0_6_gir_FILES = $(addprefix $(srcdir)/, $(CORE_SOURCES)) $(BUILT_SOURCES) -Avahi_0_6_gir_SCANNERFLAGS = --strip-prefix=Ga -INTROSPECTION_GIRS += Avahi-0.6.gir -INTROSPECTION_INSTALL_GIRS = AvahiCore-0.6.gir $(INTROSPECTION_GIRS) - -girdir = $(datadir)/gir-1.0 -gir_DATA = $(INTROSPECTION_INSTALL_GIRS) - -typelibdir = $(libdir)/girepository-1.0 -typelib_DATA = $(INTROSPECTION_INSTALL_GIRS:.gir=.typelib) - -CLEANFILES += $(INTROSPECTION_GIRS) $(typelib_DATA) -endif - -endif -endif - -indent: - indent -brf -nbbo -nbc -ip0 -cs -nbfde -npsl -br -brs -bap -i4 -bs -cdw -ce -npcs -hnl -cli4 -nut -ci8 ga-*.[ch] diff --git a/avahi-gobject/ga-client.c b/avahi-gobject/ga-client.c deleted file mode 100644 index 1874bb1..0000000 --- a/avahi-gobject/ga-client.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * ga-client.c - Source for GaClient - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "ga-client.h" - -#include "ga-client-enumtypes.h" -#include "ga-error.h" - -/* FIXME what to do about glib-malloc ? */ -#include -#include -#include -#include - -G_DEFINE_TYPE(GaClient, ga_client, G_TYPE_OBJECT) - -/* signal enum */ -enum { - STATE_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/* properties */ -enum { - PROP_STATE = 1, - PROP_FLAGS -}; - -/* private structure */ -typedef struct _GaClientPrivate GaClientPrivate; - -struct _GaClientPrivate { - AvahiGLibPoll *poll; - GaClientFlags flags; - GaClientState state; - gboolean dispose_has_run; -}; - -#define GA_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GA_TYPE_CLIENT, GaClientPrivate)) - -static void ga_client_init(GaClient * self) { - GaClientPrivate *priv = GA_CLIENT_GET_PRIVATE(self); - /* allocate any data required by the object here */ - self->avahi_client = NULL; - priv->state = GA_CLIENT_STATE_NOT_STARTED; - priv->flags = GA_CLIENT_FLAG_NO_FLAGS; -} - -static void ga_client_dispose(GObject * object); -static void ga_client_finalize(GObject * object); - -static void ga_client_set_property(GObject * object, - guint property_id, - const GValue * value, GParamSpec * pspec) { - GaClient *client = GA_CLIENT(object); - GaClientPrivate *priv = GA_CLIENT_GET_PRIVATE(client); - - switch (property_id) { - case PROP_FLAGS: - g_assert(client->avahi_client == NULL); - priv->flags = g_value_get_enum(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void ga_client_get_property(GObject * object, - guint property_id, - GValue * value, GParamSpec * pspec) { - GaClient *client = GA_CLIENT(object); - GaClientPrivate *priv = GA_CLIENT_GET_PRIVATE(client); - - switch (property_id) { - case PROP_STATE: - g_value_set_enum(value, priv->state); - break; - case PROP_FLAGS: - g_value_set_enum(value, priv->flags); - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void ga_client_class_init(GaClientClass * ga_client_class) { - GObjectClass *object_class = G_OBJECT_CLASS(ga_client_class); - GParamSpec *param_spec; - - g_type_class_add_private(ga_client_class, sizeof (GaClientPrivate)); - - - object_class->dispose = ga_client_dispose; - object_class->finalize = ga_client_finalize; - - object_class->set_property = ga_client_set_property; - object_class->get_property = ga_client_get_property; - - param_spec = g_param_spec_enum("state", "Client state", - "The state of the Avahi client", - GA_TYPE_CLIENT_STATE, - GA_CLIENT_STATE_NOT_STARTED, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_STATE, param_spec); - - param_spec = g_param_spec_enum("flags", "Client flags", - "The flags the Avahi client is started with", - GA_TYPE_CLIENT_FLAGS, - GA_CLIENT_FLAG_NO_FLAGS, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_FLAGS, param_spec); - - signals[STATE_CHANGED] = - g_signal_new("state-changed", - G_OBJECT_CLASS_TYPE(ga_client_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, GA_TYPE_CLIENT_STATE); - -} - -void ga_client_dispose(GObject * object) { - GaClient *self = GA_CLIENT(object); - GaClientPrivate *priv = GA_CLIENT_GET_PRIVATE(self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - if (self->avahi_client) { - avahi_client_free(self->avahi_client); - self->avahi_client = NULL; - } - if (priv->poll) { - avahi_glib_poll_free(priv->poll); - priv->poll = NULL; - } - - /* release any references held by the object here */ - if (G_OBJECT_CLASS(ga_client_parent_class)->dispose) - G_OBJECT_CLASS(ga_client_parent_class)->dispose(object); -} - -void ga_client_finalize(GObject * object) { - - /* free any data held directly by the object here */ - G_OBJECT_CLASS(ga_client_parent_class)->finalize(object); -} - -GaClient *ga_client_new(GaClientFlags flags) { - return g_object_new(GA_TYPE_CLIENT, "flags", flags, NULL); -} - -static GQuark detail_for_state(AvahiClientState state) { - static struct { - AvahiClientState state; - const gchar *name; - GQuark quark; - } states[] = { - { AVAHI_CLIENT_S_REGISTERING, "registering", 0}, - { AVAHI_CLIENT_S_RUNNING, "running", 0}, - { AVAHI_CLIENT_S_COLLISION, "collistion", 0}, - { AVAHI_CLIENT_FAILURE, "failure", 0}, - { AVAHI_CLIENT_CONNECTING, "connecting", 0}, - { 0, NULL, 0} - }; - int i; - - for (i = 0; states[i].name != NULL; i++) { - if (state != states[i].state) - continue; - - if (!states[i].quark) - states[i].quark = g_quark_from_static_string(states[i].name); -/* printf("Detail: %s\n", states[i].name); */ - return states[i].quark; - } - g_assert_not_reached(); -} - -static void _avahi_client_cb(AvahiClient * c, AvahiClientState state, void *data) { - GaClient *self = GA_CLIENT(data); - GaClientPrivate *priv = GA_CLIENT_GET_PRIVATE(self); - -/* printf("CLIENT CB: %d\n", state); */ - - /* Avahi can call the callback before return from _client_new */ - if (self->avahi_client == NULL) - self->avahi_client = c; - - g_assert(c == self->avahi_client); - priv->state = state; - g_signal_emit(self, signals[STATE_CHANGED], - detail_for_state(state), state); -} - -gboolean ga_client_start(GaClient * client, GError ** error) { - GaClientPrivate *priv = GA_CLIENT_GET_PRIVATE(client); - AvahiClient *aclient; - int aerror; - - g_assert(client->avahi_client == NULL); - g_assert(priv->poll == NULL); - - avahi_set_allocator(avahi_glib_allocator()); - - priv->poll = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT); - - aclient = avahi_client_new(avahi_glib_poll_get(priv->poll), - priv->flags, - _avahi_client_cb, client, &aerror); - if (aclient == NULL) { - if (error != NULL) { - *error = g_error_new(GA_ERROR, aerror, - "Failed to create avahi client: %s", - avahi_strerror(aerror)); - } - return FALSE; - } - client->avahi_client = aclient; - return TRUE; -} diff --git a/avahi-gobject/ga-client.h b/avahi-gobject/ga-client.h deleted file mode 100644 index 817db3c..0000000 --- a/avahi-gobject/ga-client.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ga-client.h - Header for GaClient - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GA_CLIENT_H__ -#define __GA_CLIENT_H__ - -#include -#include - -G_BEGIN_DECLS - -typedef enum { - GA_CLIENT_STATE_NOT_STARTED = -1, - GA_CLIENT_STATE_S_REGISTERING = AVAHI_CLIENT_S_REGISTERING, - GA_CLIENT_STATE_S_RUNNING = AVAHI_CLIENT_S_RUNNING, - GA_CLIENT_STATE_S_COLLISION = AVAHI_CLIENT_S_COLLISION, - GA_CLIENT_STATE_FAILURE = AVAHI_CLIENT_FAILURE, - GA_CLIENT_STATE_CONNECTING = AVAHI_CLIENT_CONNECTING -} GaClientState; - -typedef enum { - GA_CLIENT_FLAG_NO_FLAGS = 0, - GA_CLIENT_FLAG_IGNORE_USER_CONFIG = AVAHI_CLIENT_IGNORE_USER_CONFIG, - GA_CLIENT_FLAG_NO_FAIL = AVAHI_CLIENT_NO_FAIL -} GaClientFlags; - -typedef struct _GaClient GaClient; -typedef struct _GaClientClass GaClientClass; - -struct _GaClientClass { - GObjectClass parent_class; -}; - -struct _GaClient { - GObject parent; - /* Raw avahi_client handle, only reuse if you have reffed this instance */ - AvahiClient *avahi_client; -}; - -GType ga_client_get_type(void); - -/* TYPE MACROS */ -#define GA_TYPE_CLIENT \ - (ga_client_get_type()) -#define GA_CLIENT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GA_TYPE_CLIENT, GaClient)) -#define GA_CLIENT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GA_TYPE_CLIENT, GaClientClass)) -#define IS_GA_CLIENT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GA_TYPE_CLIENT)) -#define IS_GA_CLIENT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GA_TYPE_CLIENT)) -#define GA_CLIENT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GA_TYPE_CLIENT, GaClientClass)) - -GaClient *ga_client_new(GaClientFlags flags); - -gboolean ga_client_start(GaClient * client, GError ** error); - -G_END_DECLS - -#endif /* #ifndef __GA_CLIENT_H__ */ diff --git a/avahi-gobject/ga-entry-group.c b/avahi-gobject/ga-entry-group.c deleted file mode 100644 index 101acbf..0000000 --- a/avahi-gobject/ga-entry-group.c +++ /dev/null @@ -1,626 +0,0 @@ -/* - * ga-entry-group.c - Source for GaEntryGroup - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "ga-error.h" -#include "ga-entry-group.h" -#include "ga-entry-group-enumtypes.h" - -G_DEFINE_TYPE(GaEntryGroup, ga_entry_group, G_TYPE_OBJECT) - -static void _free_service(gpointer data); - -/* signal enum */ -enum { - STATE_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/* properties */ -enum { - PROP_STATE = 1 -}; - -/* private structures */ -typedef struct _GaEntryGroupPrivate GaEntryGroupPrivate; - -struct _GaEntryGroupPrivate { - GaEntryGroupState state; - GaClient *client; - AvahiEntryGroup *group; - GHashTable *services; - gboolean dispose_has_run; -}; - -typedef struct _GaEntryGroupServicePrivate GaEntryGroupServicePrivate; - -struct _GaEntryGroupServicePrivate { - GaEntryGroupService public; - GaEntryGroup *group; - gboolean frozen; - GHashTable *entries; -}; - -typedef struct _GaEntryGroupServiceEntry GaEntryGroupServiceEntry; - -struct _GaEntryGroupServiceEntry { - guint8 *value; - gsize size; -}; - - -#define GA_ENTRY_GROUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GA_TYPE_ENTRY_GROUP, GaEntryGroupPrivate)) - -static void ga_entry_group_init(GaEntryGroup * obj) { - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(obj); - /* allocate any data required by the object here */ - priv->state = GA_ENTRY_GROUP_STATE_UNCOMMITED; - priv->client = NULL; - priv->group = NULL; - priv->services = g_hash_table_new_full(g_direct_hash, - g_direct_equal, - NULL, _free_service); -} - -static void ga_entry_group_dispose(GObject * object); -static void ga_entry_group_finalize(GObject * object); - -static void ga_entry_group_get_property(GObject * object, - guint property_id, - GValue * value, GParamSpec * pspec) { - GaEntryGroup *group = GA_ENTRY_GROUP(object); - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(group); - - switch (property_id) { - case PROP_STATE: - g_value_set_enum(value, priv->state); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void ga_entry_group_class_init(GaEntryGroupClass * ga_entry_group_class) { - GObjectClass *object_class = G_OBJECT_CLASS(ga_entry_group_class); - GParamSpec *param_spec; - - g_type_class_add_private(ga_entry_group_class, - sizeof (GaEntryGroupPrivate)); - - object_class->dispose = ga_entry_group_dispose; - object_class->finalize = ga_entry_group_finalize; - object_class->get_property = ga_entry_group_get_property; - - param_spec = g_param_spec_enum("state", "Entry Group state", - "The state of the avahi entry group", - GA_TYPE_ENTRY_GROUP_STATE, - GA_ENTRY_GROUP_STATE_UNCOMMITED, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_STATE, param_spec); - - signals[STATE_CHANGED] = - g_signal_new("state-changed", - G_OBJECT_CLASS_TYPE(ga_entry_group_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, GA_TYPE_ENTRY_GROUP_STATE); -} - -void ga_entry_group_dispose(GObject * object) { - GaEntryGroup *self = GA_ENTRY_GROUP(object); - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(self); - - if (priv->dispose_has_run) - return; - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - if (priv->group) { - avahi_entry_group_free(priv->group); - priv->group = NULL; - } - - if (priv->client) { - g_object_unref(priv->client); - priv->client = NULL; - } - - if (G_OBJECT_CLASS(ga_entry_group_parent_class)->dispose) - G_OBJECT_CLASS(ga_entry_group_parent_class)->dispose(object); -} - -void ga_entry_group_finalize(GObject * object) { - GaEntryGroup *self = GA_ENTRY_GROUP(object); - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(self); - - /* free any data held directly by the object here */ - g_hash_table_destroy(priv->services); - priv->services = NULL; - - G_OBJECT_CLASS(ga_entry_group_parent_class)->finalize(object); -} - -static void _free_service(gpointer data) { - GaEntryGroupService *s = (GaEntryGroupService *) data; - GaEntryGroupServicePrivate *p = (GaEntryGroupServicePrivate *) s; - g_free(s->name); - g_free(s->type); - g_free(s->domain); - g_free(s->host); - g_hash_table_destroy(p->entries); - g_free(s); -} - -static GQuark detail_for_state(AvahiEntryGroupState state) { - static struct { - AvahiEntryGroupState state; - const gchar *name; - GQuark quark; - } states[] = { - { AVAHI_ENTRY_GROUP_UNCOMMITED, "uncommited", 0}, - { AVAHI_ENTRY_GROUP_REGISTERING, "registering", 0}, - { AVAHI_ENTRY_GROUP_ESTABLISHED, "established", 0}, - { AVAHI_ENTRY_GROUP_COLLISION, "collistion", 0}, - { AVAHI_ENTRY_GROUP_FAILURE, "failure", 0}, - { 0, NULL, 0} - }; - int i; - - for (i = 0; states[i].name != NULL; i++) { - if (state != states[i].state) - continue; - - if (!states[i].quark) - states[i].quark = g_quark_from_static_string(states[i].name); - return states[i].quark; - } - g_assert_not_reached(); -} - -static void _avahi_entry_group_cb(AvahiEntryGroup * g, - AvahiEntryGroupState state, void *data) { - GaEntryGroup *self = GA_ENTRY_GROUP(data); - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(self); - - /* Avahi can call the callback before return from _client_new */ - if (priv->group == NULL) - priv->group = g; - - g_assert(g == priv->group); - priv->state = state; - g_signal_emit(self, signals[STATE_CHANGED], - detail_for_state(state), state); -} - -GaEntryGroup *ga_entry_group_new(void) { - return g_object_new(GA_TYPE_ENTRY_GROUP, NULL); -} - -static guint _entry_hash(gconstpointer v) { - const GaEntryGroupServiceEntry *entry = - (const GaEntryGroupServiceEntry *) v; - guint32 h = 0; - guint i; - - for (i = 0; i < entry->size; i++) { - h = (h << 5) - h + entry->value[i]; - } - - return h; -} - -static gboolean _entry_equal(gconstpointer a, gconstpointer b) { - const GaEntryGroupServiceEntry *aentry = - (const GaEntryGroupServiceEntry *) a; - const GaEntryGroupServiceEntry *bentry = - (const GaEntryGroupServiceEntry *) b; - - if (aentry->size != bentry->size) { - return FALSE; - } - - return memcmp(aentry->value, bentry->value, aentry->size) == 0; -} - -static GaEntryGroupServiceEntry *_new_entry(const guint8 * value, gsize size) { - GaEntryGroupServiceEntry *entry; - - if (value == NULL) { - return NULL; - } - - entry = g_slice_new(GaEntryGroupServiceEntry); - entry->value = g_malloc(size + 1); - memcpy(entry->value, value, size); - /* for string keys, make sure it's NUL-terminated too */ - entry->value[size] = 0; - entry->size = size; - - return entry; -} - -static void _set_entry(GHashTable * table, const guint8 * key, gsize ksize, - const guint8 * value, gsize vsize) { - - g_hash_table_insert(table, _new_entry(key, ksize), - _new_entry(value, vsize)); -} - -static void _free_entry(gpointer data) { - GaEntryGroupServiceEntry *entry = (GaEntryGroupServiceEntry *) data; - - if (entry == NULL) { - return; - } - - g_free(entry->value); - g_slice_free(GaEntryGroupServiceEntry, entry); -} - -static GHashTable *_string_list_to_hash(AvahiStringList * list) { - GHashTable *ret; - AvahiStringList *t; - - ret = g_hash_table_new_full(_entry_hash, - _entry_equal, _free_entry, _free_entry); - - for (t = list; t != NULL; t = avahi_string_list_get_next(t)) { - gchar *key; - gchar *value; - gsize size; - int r; - - /* list_get_pair only fails if if memory allocation fails. Normal glib - * behaviour is to assert/abort when that happens */ - r = avahi_string_list_get_pair(t, &key, &value, &size); - g_assert(r == 0); - - if (value == NULL) { - _set_entry(ret, t->text, t->size, NULL, 0); - } else { - _set_entry(ret, (const guint8 *) key, strlen(key), - (const guint8 *) value, size); - } - avahi_free(key); - avahi_free(value); - } - return ret; -} - -static void _hash_to_string_list_foreach(gpointer key, gpointer value, gpointer data) { - AvahiStringList **list = (AvahiStringList **) data; - GaEntryGroupServiceEntry *kentry = (GaEntryGroupServiceEntry *) key; - GaEntryGroupServiceEntry *ventry = (GaEntryGroupServiceEntry *) value; - - if (value != NULL) { - *list = avahi_string_list_add_pair_arbitrary(*list, - (gchar *) kentry->value, - ventry->value, - ventry->size); - } else { - *list = avahi_string_list_add_arbitrary(*list, - kentry->value, kentry->size); - } -} - -static AvahiStringList *_hash_to_string_list(GHashTable * table) { - AvahiStringList *list = NULL; - g_hash_table_foreach(table, _hash_to_string_list_foreach, - (gpointer) & list); - return list; -} - -GaEntryGroupService *ga_entry_group_add_service_strlist(GaEntryGroup * group, - const gchar * name, - const gchar * type, - guint16 port, - GError ** error, - AvahiStringList * - txt) { - return ga_entry_group_add_service_full_strlist(group, AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, 0, - name, type, NULL, NULL, - port, error, txt); -} - -GaEntryGroupService *ga_entry_group_add_service_full_strlist(GaEntryGroup * - group, - AvahiIfIndex - interface, - AvahiProtocol - protocol, - AvahiPublishFlags - flags, - const gchar * - name, - const gchar * - type, - const gchar * - domain, - const gchar * - host, - guint16 port, - GError ** error, - AvahiStringList * - txt) { - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(group); - GaEntryGroupServicePrivate *service = NULL; - int ret; - - ret = avahi_entry_group_add_service_strlst(priv->group, - interface, protocol, - flags, - name, type, - domain, host, port, txt); - if (ret) { - if (error != NULL) { - *error = g_error_new(GA_ERROR, ret, - "Adding service to group failed: %s", - avahi_strerror(ret)); - } - goto out; - } - - service = g_new0(GaEntryGroupServicePrivate, 1); - service->public.interface = interface; - service->public.protocol = protocol; - service->public.flags = flags; - service->public.name = g_strdup(name); - service->public.type = g_strdup(type); - service->public.domain = g_strdup(domain); - service->public.host = g_strdup(host); - service->public.port = port; - service->group = group; - service->frozen = FALSE; - service->entries = _string_list_to_hash(txt); - g_hash_table_insert(priv->services, group, service); - out: - return (GaEntryGroupService *) service; -} - -GaEntryGroupService *ga_entry_group_add_service(GaEntryGroup * group, - const gchar * name, - const gchar * type, - guint16 port, - GError ** error, ...) { - GaEntryGroupService *ret; - AvahiStringList *txt = NULL; - va_list va; - va_start(va, error); - txt = avahi_string_list_new_va(va); - - ret = ga_entry_group_add_service_full_strlist(group, - AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, - 0, - name, type, - NULL, NULL, - port, error, txt); - avahi_string_list_free(txt); - va_end(va); - return ret; -} - -GaEntryGroupService *ga_entry_group_add_service_full(GaEntryGroup * group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const gchar * name, - const gchar * type, - const gchar * domain, - const gchar * host, - guint16 port, - GError ** error, ...) { - GaEntryGroupService *ret; - AvahiStringList *txt = NULL; - va_list va; - - va_start(va, error); - txt = avahi_string_list_new_va(va); - - ret = ga_entry_group_add_service_full_strlist(group, - interface, protocol, - flags, - name, type, - domain, host, - port, error, txt); - avahi_string_list_free(txt); - va_end(va); - return ret; -} - -gboolean ga_entry_group_add_record(GaEntryGroup * group, - AvahiPublishFlags flags, - const gchar * name, - guint16 type, - guint32 ttl, - const void *rdata, gsize size, GError ** error) { - return ga_entry_group_add_record_full(group, - AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, - flags, name, AVAHI_DNS_CLASS_IN, - type, ttl, rdata, size, error); -} - -gboolean ga_entry_group_add_record_full(GaEntryGroup * group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const gchar * name, - guint16 clazz, - guint16 type, - guint32 ttl, - const void *rdata, - gsize size, GError ** error) { - int ret; - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(group); - g_assert(group != NULL && priv->group != NULL); - - ret = avahi_entry_group_add_record(priv->group, interface, protocol, - flags, name, clazz, type, ttl, rdata, - size); - if (ret) { - if (error != NULL) { - *error = g_error_new(GA_ERROR, ret, - "Setting raw record failed: %s", - avahi_strerror(ret)); - } - return FALSE; - } - return TRUE; -} - - -void ga_entry_group_service_freeze(GaEntryGroupService * service) { - GaEntryGroupServicePrivate *p = (GaEntryGroupServicePrivate *) service; - p->frozen = TRUE; -} - -gboolean ga_entry_group_service_thaw(GaEntryGroupService * service, GError ** error) { - GaEntryGroupServicePrivate *priv = (GaEntryGroupServicePrivate *) service; - int ret; - gboolean result = TRUE; - - AvahiStringList *txt = _hash_to_string_list(priv->entries); - ret = avahi_entry_group_update_service_txt_strlst - (GA_ENTRY_GROUP_GET_PRIVATE(priv->group)->group, - service->interface, service->protocol, service->flags, - service->name, service->type, service->domain, txt); - if (ret) { - if (error != NULL) { - *error = g_error_new(GA_ERROR, ret, - "Updating txt record failed: %s", - avahi_strerror(ret)); - } - result = FALSE; - } - - avahi_string_list_free(txt); - priv->frozen = FALSE; - return result; -} - -gboolean ga_entry_group_service_set(GaEntryGroupService * service, - const gchar * key, const gchar * value, - GError ** error) { - return ga_entry_group_service_set_arbitrary(service, key, - (const guint8 *) value, - strlen(value), error); - -} - -gboolean ga_entry_group_service_set_arbitrary(GaEntryGroupService * service, - const gchar * key, const guint8 * value, - gsize size, GError ** error) { - GaEntryGroupServicePrivate *priv = (GaEntryGroupServicePrivate *) service; - - _set_entry(priv->entries, (const guint8 *) key, strlen(key), value, size); - - if (!priv->frozen) - return ga_entry_group_service_thaw(service, error); - else - return TRUE; -} - -gboolean ga_entry_group_service_remove_key(GaEntryGroupService * service, - const gchar * key, GError ** error) { - GaEntryGroupServicePrivate *priv = (GaEntryGroupServicePrivate *) service; - GaEntryGroupServiceEntry entry; - - entry.value = (void*) key; - entry.size = strlen(key); - - g_hash_table_remove(priv->entries, &entry); - - if (!priv->frozen) - return ga_entry_group_service_thaw(service, error); - else - return TRUE; -} - - -gboolean ga_entry_group_attach(GaEntryGroup * group, - GaClient * client, GError ** error) { - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(group); - - g_return_val_if_fail(client->avahi_client, FALSE); - g_assert(priv->client == NULL || priv->client == client); - g_assert(priv->group == NULL); - - priv->client = client; - g_object_ref(client); - - priv->group = avahi_entry_group_new(client->avahi_client, - _avahi_entry_group_cb, group); - if (priv->group == NULL) { - if (error != NULL) { - int aerrno = avahi_client_errno(client->avahi_client); - *error = g_error_new(GA_ERROR, aerrno, - "Attaching group failed: %s", - avahi_strerror(aerrno)); - } - return FALSE; - } - return TRUE; -} - -gboolean ga_entry_group_commit(GaEntryGroup * group, GError ** error) { - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(group); - int ret; - ret = avahi_entry_group_commit(priv->group); - if (ret) { - if (error != NULL) { - *error = g_error_new(GA_ERROR, ret, - "Committing group failed: %s", - avahi_strerror(ret)); - } - return FALSE; - } - return TRUE; -} - -gboolean ga_entry_group_reset(GaEntryGroup * group, GError ** error) { - GaEntryGroupPrivate *priv = GA_ENTRY_GROUP_GET_PRIVATE(group); - int ret; - ret = avahi_entry_group_reset(priv->group); - if (ret) { - if (error != NULL) { - *error = g_error_new(GA_ERROR, ret, - "Resetting group failed: %s", - avahi_strerror(ret)); - } - return FALSE; - } - return TRUE; -} diff --git a/avahi-gobject/ga-entry-group.h b/avahi-gobject/ga-entry-group.h deleted file mode 100644 index efb6ede..0000000 --- a/avahi-gobject/ga-entry-group.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * ga-entry-group.h - Header for GaEntryGroup - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GA_ENTRY_GROUP_H__ -#define __GA_ENTRY_GROUP_H__ - -#include -#include -#include - -#include "ga-client.h" - -G_BEGIN_DECLS - -typedef enum { - GA_ENTRY_GROUP_STATE_UNCOMMITED = AVAHI_ENTRY_GROUP_UNCOMMITED, - GA_ENTRY_GROUP_STATE_REGISTERING = AVAHI_ENTRY_GROUP_REGISTERING, - GA_ENTRY_GROUP_STATE_ESTABLISHED = AVAHI_ENTRY_GROUP_ESTABLISHED, - GA_ENTRY_GROUP_STATE_COLLISTION = AVAHI_ENTRY_GROUP_COLLISION, - GA_ENTRY_GROUP_STATE_FAILURE = AVAHI_ENTRY_GROUP_FAILURE -} GaEntryGroupState; - -typedef struct _GaEntryGroupService GaEntryGroupService; -typedef struct _GaEntryGroup GaEntryGroup; -typedef struct _GaEntryGroupClass GaEntryGroupClass; - -struct _GaEntryGroupService { - AvahiIfIndex interface; - AvahiProtocol protocol; - AvahiPublishFlags flags; - gchar *name; - gchar *type; - gchar *domain; - gchar *host; - guint16 port; -}; - -struct _GaEntryGroupClass { - GObjectClass parent_class; -}; - -struct _GaEntryGroup { - GObject parent; -}; - -GType ga_entry_group_get_type(void); - -/* TYPE MACROS */ -#define GA_TYPE_ENTRY_GROUP \ - (ga_entry_group_get_type()) -#define GA_ENTRY_GROUP(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GA_TYPE_ENTRY_GROUP, GaEntryGroup)) -#define GA_ENTRY_GROUP_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GA_TYPE_ENTRY_GROUP, GaEntryGroupClass)) -#define IS_GA_ENTRY_GROUP(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GA_TYPE_ENTRY_GROUP)) -#define IS_GA_ENTRY_GROUP_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GA_TYPE_ENTRY_GROUP)) -#define GA_ENTRY_GROUP_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GA_TYPE_ENTRY_GROUP, GaEntryGroupClass)) - -GaEntryGroup *ga_entry_group_new(void); - -gboolean ga_entry_group_attach(GaEntryGroup * group, - GaClient * client, GError ** error); - -GaEntryGroupService *ga_entry_group_add_service_strlist(GaEntryGroup * group, - const gchar * name, - const gchar * type, - guint16 port, - GError ** error, - AvahiStringList * - txt); - -GaEntryGroupService *ga_entry_group_add_service_full_strlist(GaEntryGroup * - group, - AvahiIfIndex - interface, - AvahiProtocol - protocol, - AvahiPublishFlags - flags, - const gchar * - name, - const gchar * - type, - const gchar * - domain, - const gchar * - host, - guint16 port, - GError ** error, - AvahiStringList * - txt); -GaEntryGroupService *ga_entry_group_add_service(GaEntryGroup * group, - const gchar * name, - const gchar * type, - guint16 port, GError ** error, - ...); - -GaEntryGroupService *ga_entry_group_add_service_full(GaEntryGroup * group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const gchar * name, - const gchar * type, - const gchar * domain, - const gchar * host, - guint16 port, - GError ** error, ...); - -/* Add raw record */ -gboolean ga_entry_group_add_record(GaEntryGroup * group, - AvahiPublishFlags flags, - const gchar * name, - guint16 type, - guint32 ttl, - const void *rdata, gsize size, GError ** error); -gboolean ga_entry_group_add_record_full(GaEntryGroup * group, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiPublishFlags flags, - const gchar * name, - guint16 clazz, - guint16 type, - guint32 ttl, - const void *rdata, - gsize size, GError ** error); - - - -void ga_entry_group_service_freeze(GaEntryGroupService * service); - -/* Set a key in the service record. If the service isn't frozen it's committed - * immediately */ -gboolean ga_entry_group_service_set(GaEntryGroupService * service, - const gchar * key, const gchar * value, - GError ** error); - -gboolean ga_entry_group_service_set_arbitrary(GaEntryGroupService * service, - const gchar * key, const guint8 * value, - gsize size, GError ** error); - -/* Remove one key from the service record */ -gboolean ga_entry_group_service_remove_key(GaEntryGroupService * service, - const gchar * key, GError ** error); - -/* Update the txt record of the frozen service */ -gboolean ga_entry_group_service_thaw(GaEntryGroupService * service, GError ** error); - -/* Commit all newly added services */ -gboolean ga_entry_group_commit(GaEntryGroup * group, GError ** error); - -/* Invalidated all GaEntryGroupServices */ -gboolean ga_entry_group_reset(GaEntryGroup * group, GError ** error); - -G_END_DECLS -#endif /* #ifndef __GA_ENTRY_GROUP_H__ */ diff --git a/avahi-gobject/ga-enums.h b/avahi-gobject/ga-enums.h deleted file mode 100644 index 04a8ac3..0000000 --- a/avahi-gobject/ga-enums.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * ga-enums.h - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GA_ENUMS_H__ -#define __GA_ENUMS_H__ - -#include -#include -#include - -G_BEGIN_DECLS -/** Values for GaProtocol */ - typedef enum { - GA_PROTOCOL_INET = AVAHI_PROTO_INET, /**< IPv4 */ - GA_PROTOCOL_INET6 = AVAHI_PROTO_INET6, /**< IPv6 */ - GA_PROTOCOL_UNSPEC = AVAHI_PROTO_UNSPEC /**< Unspecified/all protocol(s) */ -} GaProtocol; - - -/** Some flags for lookup callback functions */ -typedef enum { - GA_LOOKUP_RESULT_CACHED = AVAHI_LOOKUP_RESULT_CACHED, /**< This response originates from the cache */ - GA_LOOKUP_RESULT_WIDE_AREA = AVAHI_LOOKUP_RESULT_WIDE_AREA, - /**< This response originates from wide area DNS */ - GA_LOOKUP_RESULT_MULTICAST = AVAHI_LOOKUP_RESULT_MULTICAST, - /**< This response originates from multicast DNS */ - GA_LOOKUP_RESULT_LOCAL = AVAHI_LOOKUP_RESULT_LOCAL, /**< This record/service resides on and was announced by the local host. Only available in service and record browsers and only on AVAHI_BROWSER_NEW. */ - GA_LOOKUP_RESULT_OUR_OWN = AVAHI_LOOKUP_RESULT_OUR_OWN, /**< This service belongs to the same local client as the browser object. Only available in avahi-client, and only for service browsers and only on AVAHI_BROWSER_NEW. */ - GA_LOOKUP_RESULT_STATIC = AVAHI_LOOKUP_RESULT_STATIC /**< The returned data has been defined statically by some configuration option */ -} GaLookupResultFlags; - -typedef enum { - GA_LOOKUP_NO_FLAGS = 0, - GA_LOOKUP_USE_WIDE_AREA = AVAHI_LOOKUP_USE_WIDE_AREA, /**< Force lookup via wide area DNS */ - GA_LOOKUP_USE_MULTICAST = AVAHI_LOOKUP_USE_MULTICAST, /**< Force lookup via multicast DNS */ - GA_LOOKUP_NO_TXT = AVAHI_LOOKUP_NO_TXT, /**< When doing service resolving, don't lookup TXT record */ - GA_LOOKUP_NO_ADDRESS = AVAHI_LOOKUP_NO_ADDRESS /**< When doing service resolving, don't lookup A/AAAA record */ -} GaLookupFlags; - -typedef enum { - GA_RESOLVER_FOUND = AVAHI_RESOLVER_FOUND, /**< RR found, resolving successful */ - GA_RESOLVER_FAILURE = AVAHI_RESOLVER_FAILURE /**< Resolving failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */ -} GaResolverEvent; - -typedef enum { - GA_BROWSER_NEW = AVAHI_BROWSER_NEW, /**< The object is new on the network */ - GA_BROWSER_REMOVE = AVAHI_BROWSER_REMOVE, /**< The object has been removed from the network */ - GA_BROWSER_CACHE_EXHAUSTED = AVAHI_BROWSER_CACHE_EXHAUSTED, /**< One-time event, to notify the user that all entries from the caches have been send */ - GA_BROWSER_ALL_FOR_NOW = AVAHI_BROWSER_ALL_FOR_NOW, /**< One-time event, to notify the user that more records will probably not show up in the near future, i.e. all cache entries have been read and all static servers been queried */ - GA_BROWSER_FAILURE = AVAHI_BROWSER_FAILURE /**< Browsing failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */ -} GaBrowserEvent; - -G_END_DECLS -#endif /* #ifndef __GA_CLIENT_H__ */ diff --git a/avahi-gobject/ga-error.c b/avahi-gobject/ga-error.c deleted file mode 100644 index f6ea9ae..0000000 --- a/avahi-gobject/ga-error.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ga-error.c - Source for error types used - * Copyright (C) 2006 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "ga-error.h" - -GQuark ga_error_quark(void) { - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string("ga_error"); - return quark; -} diff --git a/avahi-gobject/ga-error.h b/avahi-gobject/ga-error.h deleted file mode 100644 index 5c83ea7..0000000 --- a/avahi-gobject/ga-error.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ga-error.h - Header for Avahi error types - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GA_ERROR_H__ -#define __GA_ERROR_H__ - -#include - -G_BEGIN_DECLS -#include - -GQuark ga_error_quark(void); - -#define GA_ERROR ga_error_quark() - -G_END_DECLS -#endif /* #ifndef __GA_ERROR_H__ */ diff --git a/avahi-gobject/ga-record-browser.c b/avahi-gobject/ga-record-browser.c deleted file mode 100644 index f310506..0000000 --- a/avahi-gobject/ga-record-browser.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * ga-record-browser.c - Source for GaRecordBrowser - * Copyright (C) 2007 Collabora Ltd. - * @author Sjoerd Simons - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "ga-record-browser.h" -#include "signals-marshal.h" -#include "ga-error.h" -#include "ga-enums-enumtypes.h" - -G_DEFINE_TYPE(GaRecordBrowser, ga_record_browser, G_TYPE_OBJECT) - -/* signal enum */ -enum { - NEW, - REMOVED, - FAILURE, - ALL_FOR_NOW, - CACHE_EXHAUSTED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/* properties */ -enum { - PROP_PROTOCOL = 1, - PROP_IFINDEX, - PROP_NAME, - PROP_CLASS, - PROP_TYPE, - PROP_FLAGS -}; - -/* private structure */ -typedef struct _GaRecordBrowserPrivate GaRecordBrowserPrivate; - -struct _GaRecordBrowserPrivate { - gboolean dispose_has_run; - GaClient *client; - AvahiRecordBrowser *browser; - AvahiProtocol protocol; - AvahiIfIndex interface; - gchar *name; - guint16 class; - guint16 type; - AvahiLookupFlags flags; -}; - -#define GA_RECORD_BROWSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GA_TYPE_RECORD_BROWSER, GaRecordBrowserPrivate)) - -static void ga_record_browser_init(AVAHI_GCC_UNUSED GaRecordBrowser * obj) { - /* allocate any data required by the object here */ -} - -static void ga_record_browser_dispose(GObject * object); -static void ga_record_browser_finalize(GObject * object); - -static void ga_record_browser_set_property(GObject * object, - guint property_id, - const GValue * value, GParamSpec * pspec) { - GaRecordBrowser *browser = GA_RECORD_BROWSER(object); - GaRecordBrowserPrivate *priv = GA_RECORD_BROWSER_GET_PRIVATE(browser); - - g_assert(priv->browser == NULL); - - switch (property_id) { - case PROP_PROTOCOL: - priv->protocol = g_value_get_enum(value); - break; - case PROP_IFINDEX: - priv->interface = g_value_get_int(value); - break; - case PROP_NAME: - priv->name = g_value_dup_string(value); - break; - case PROP_CLASS: - priv->class = g_value_get_uint(value); - break; - case PROP_TYPE: - priv->type = g_value_get_uint(value); - break; - case PROP_FLAGS: - priv->flags = g_value_get_enum(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void ga_record_browser_get_property(GObject * object, - guint property_id, - GValue * value, GParamSpec * pspec) { - GaRecordBrowser *browser = GA_RECORD_BROWSER(object); - GaRecordBrowserPrivate *priv = GA_RECORD_BROWSER_GET_PRIVATE(browser); - - switch (property_id) { - case PROP_PROTOCOL: - g_value_set_int(value, priv->protocol); - break; - case PROP_IFINDEX: - g_value_set_int(value, priv->interface); - break; - case PROP_TYPE: - g_value_set_uint(value, priv->type); - break; - case PROP_CLASS: - g_value_set_uint(value, priv->class); - break; - case PROP_NAME: - g_value_set_string(value, priv->name); - break; - case PROP_FLAGS: - g_value_set_enum(value, priv->flags); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - - -static void ga_record_browser_class_init(GaRecordBrowserClass * ga_record_browser_class) { - GObjectClass *object_class = G_OBJECT_CLASS(ga_record_browser_class); - GParamSpec *param_spec; - - g_type_class_add_private(ga_record_browser_class, - sizeof (GaRecordBrowserPrivate)); - - object_class->dispose = ga_record_browser_dispose; - object_class->finalize = ga_record_browser_finalize; - - object_class->set_property = ga_record_browser_set_property; - object_class->get_property = ga_record_browser_get_property; - - signals[NEW] = - g_signal_new("new-record", - G_OBJECT_CLASS_TYPE(ga_record_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _ga_signals_marshal_VOID__INT_ENUM_STRING_UINT_UINT_POINTER_INT_INT, - G_TYPE_NONE, 8, - G_TYPE_INT, - GA_TYPE_PROTOCOL, - G_TYPE_STRING, - G_TYPE_UINT, - G_TYPE_UINT, - G_TYPE_POINTER, - G_TYPE_INT, GA_TYPE_LOOKUP_RESULT_FLAGS); - - signals[REMOVED] = - g_signal_new("removed-record", - G_OBJECT_CLASS_TYPE(ga_record_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _ga_signals_marshal_VOID__INT_ENUM_STRING_UINT_UINT_POINTER_INT_INT, - G_TYPE_NONE, 8, - G_TYPE_INT, - GA_TYPE_PROTOCOL, - G_TYPE_STRING, - G_TYPE_UINT, - G_TYPE_UINT, - G_TYPE_POINTER, - G_TYPE_INT, GA_TYPE_LOOKUP_RESULT_FLAGS); - - signals[ALL_FOR_NOW] = - g_signal_new("all-for-now", - G_OBJECT_CLASS_TYPE(ga_record_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - signals[CACHE_EXHAUSTED] = - g_signal_new("cache-exhausted", - G_OBJECT_CLASS_TYPE(ga_record_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - signals[FAILURE] = - g_signal_new("failure", - G_OBJECT_CLASS_TYPE(ga_record_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - param_spec = g_param_spec_enum("protocol", "Avahi protocol to browse", - "Avahi protocol to browse", - GA_TYPE_PROTOCOL, - GA_PROTOCOL_UNSPEC, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_PROTOCOL, param_spec); - - param_spec = g_param_spec_int("interface", "interface index", - "Interface use for browser", - AVAHI_IF_UNSPEC, - G_MAXINT, - AVAHI_IF_UNSPEC, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_IFINDEX, param_spec); - - param_spec = g_param_spec_string("name", "record name", - "Record name to browse for", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_NAME, param_spec); - - param_spec = g_param_spec_uint("type", "record type", - "Record type to browse for", - 0, G_MAXUINT16, 0, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_TYPE, param_spec); - - param_spec = g_param_spec_uint("class", "record class", - "Record class to browse for", - 0, G_MAXUINT16, 0, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_CLASS, param_spec); - - param_spec = g_param_spec_enum("flags", "Lookup flags for the browser", - "Browser lookup flags", - GA_TYPE_LOOKUP_FLAGS, - GA_LOOKUP_NO_FLAGS, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_FLAGS, param_spec); -} - -void ga_record_browser_dispose(GObject * object) { - GaRecordBrowser *self = GA_RECORD_BROWSER(object); - GaRecordBrowserPrivate *priv = GA_RECORD_BROWSER_GET_PRIVATE(self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - if (priv->client) - g_object_unref(priv->client); - priv->client = NULL; - - if (priv->browser) - avahi_record_browser_free(priv->browser); - priv->browser = NULL; - - if (G_OBJECT_CLASS(ga_record_browser_parent_class)->dispose) - G_OBJECT_CLASS(ga_record_browser_parent_class)->dispose(object); -} - -void ga_record_browser_finalize(GObject * object) { - GaRecordBrowser *self = GA_RECORD_BROWSER(object); - GaRecordBrowserPrivate *priv = GA_RECORD_BROWSER_GET_PRIVATE(self); - - /* free any data held directly by the object here */ - g_free(priv->name); - - G_OBJECT_CLASS(ga_record_browser_parent_class)->finalize(object); -} - - -GaRecordBrowser *ga_record_browser_new(const gchar * name, guint16 type) { - return ga_record_browser_new_full(AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, name, - AVAHI_DNS_CLASS_IN, type, 0); -} - -GaRecordBrowser *ga_record_browser_new_full(AvahiIfIndex interface, - AvahiProtocol protocol, - const gchar * name, - guint16 clazz, - guint16 type, - GaLookupFlags flags) { - return g_object_new(GA_TYPE_RECORD_BROWSER, - "interface", interface, - "protocol", protocol, - "name", name, - "class", clazz, "type", type, "flags", flags, NULL); - -} - -static void _avahi_record_browser_cb(AVAHI_GCC_UNUSED AvahiRecordBrowser * r, AvahiIfIndex interface, - AvahiProtocol protocol, AvahiBrowserEvent event, - const char *name, uint16_t clazz, uint16_t type, - const void *rdata, size_t rdata_size, - AvahiLookupResultFlags flags, void *userdata) { - GaRecordBrowser *self = GA_RECORD_BROWSER(userdata); - GaRecordBrowserPrivate *priv = GA_RECORD_BROWSER_GET_PRIVATE(userdata); - - switch (event) { - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE:{ - guint signalid = (event == AVAHI_BROWSER_NEW ? NEW : REMOVED); - g_signal_emit(self, signals[signalid], 0, - interface, protocol, name, clazz, type, - rdata, rdata_size, flags); - break; - } - case AVAHI_BROWSER_CACHE_EXHAUSTED: - g_signal_emit(self, signals[CACHE_EXHAUSTED], 0); - break; - case AVAHI_BROWSER_ALL_FOR_NOW: - g_signal_emit(self, signals[ALL_FOR_NOW], 0); - break; - case AVAHI_BROWSER_FAILURE:{ - GError *error; - int aerrno = avahi_client_errno(priv->client->avahi_client); - error = g_error_new(GA_ERROR, aerrno, - "Browsing failed: %s", - avahi_strerror(aerrno)); - g_signal_emit(self, signals[FAILURE], 0, error); - g_error_free(error); - break; - } - } -} - -gboolean ga_record_browser_attach(GaRecordBrowser * browser, - GaClient * client, GError ** error) { - GaRecordBrowserPrivate *priv = GA_RECORD_BROWSER_GET_PRIVATE(browser); - - priv->client = g_object_ref(client); - priv->browser = avahi_record_browser_new(client->avahi_client, - priv->interface, - priv->protocol, - priv->name, - priv->class, - priv->type, - priv->flags, - _avahi_record_browser_cb, - browser); - if (priv->browser == NULL) { - if (error != NULL) { - int aerrno = avahi_client_errno(client->avahi_client); - *error = g_error_new(GA_ERROR, aerrno, - "Attaching record browser failed: %s", - avahi_strerror(aerrno)); - } - return FALSE; - } - return TRUE; -} diff --git a/avahi-gobject/ga-record-browser.h b/avahi-gobject/ga-record-browser.h deleted file mode 100644 index c27c061..0000000 --- a/avahi-gobject/ga-record-browser.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * ga-record-browser.h - Header for GaRecordBrowser - * Copyright (C) 2007 Collabora Ltd. - * @author Sjoerd Simons - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GA_RECORD_BROWSER_H__ -#define __GA_RECORD_BROWSER_H__ - -#include -#include -#include -#include "ga-client.h" -#include "ga-enums.h" - -G_BEGIN_DECLS - -typedef struct _GaRecordBrowser GaRecordBrowser; -typedef struct _GaRecordBrowserClass GaRecordBrowserClass; - -struct _GaRecordBrowserClass { - GObjectClass parent_class; -}; - -struct _GaRecordBrowser { - GObject parent; -}; - -GType ga_record_browser_get_type(void); - -/* TYPE MACROS */ -#define GA_TYPE_RECORD_BROWSER \ - (ga_record_browser_get_type()) -#define GA_RECORD_BROWSER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GA_TYPE_RECORD_BROWSER, GaRecordBrowser)) -#define GA_RECORD_BROWSER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GA_TYPE_RECORD_BROWSER, GaRecordBrowserClass)) -#define IS_GA_RECORD_BROWSER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GA_TYPE_RECORD_BROWSER)) -#define IS_GA_RECORD_BROWSER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GA_TYPE_RECORD_BROWSER)) -#define GA_RECORD_BROWSER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GA_TYPE_RECORD_BROWSER, GaRecordBrowserClass)) - -GaRecordBrowser *ga_record_browser_new(const gchar * name, guint16 type); - -GaRecordBrowser *ga_record_browser_new_full(AvahiIfIndex interface, - AvahiProtocol protocol, - const gchar * name, - guint16 clazz, - guint16 type, - GaLookupFlags flags); - -gboolean -ga_record_browser_attach(GaRecordBrowser * browser, - GaClient * client, GError ** error); - - -G_END_DECLS -#endif /* #ifndef __GA_RECORD_BROWSER_H__ */ diff --git a/avahi-gobject/ga-service-browser.c b/avahi-gobject/ga-service-browser.c deleted file mode 100644 index 3c3b80e..0000000 --- a/avahi-gobject/ga-service-browser.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * ga-service-browser.c - Source for GaServiceBrowser - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include - -#include "ga-service-browser.h" -#include "signals-marshal.h" -#include "ga-error.h" -#include "ga-enums-enumtypes.h" - -G_DEFINE_TYPE(GaServiceBrowser, ga_service_browser, G_TYPE_OBJECT) - -/* signal enum */ -enum { - NEW, - REMOVED, - CACHE_EXHAUSTED, - ALL_FOR_NOW, - FAILURE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/* properties */ -enum { - PROP_PROTOCOL = 1, - PROP_IFINDEX, - PROP_TYPE, - PROP_DOMAIN, - PROP_FLAGS -}; - -/* private structure */ -typedef struct _GaServiceBrowserPrivate GaServiceBrowserPrivate; - -struct _GaServiceBrowserPrivate { - GaClient *client; - AvahiServiceBrowser *browser; - AvahiIfIndex interface; - AvahiProtocol protocol; - char *type; - char *domain; - AvahiLookupFlags flags; - gboolean dispose_has_run; -}; - -#define GA_SERVICE_BROWSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GA_TYPE_SERVICE_BROWSER, GaServiceBrowserPrivate)) - -static void ga_service_browser_init(GaServiceBrowser * obj) { - GaServiceBrowserPrivate *priv = GA_SERVICE_BROWSER_GET_PRIVATE(obj); - - /* allocate any data required by the object here */ - priv->client = NULL; - priv->browser = NULL; - priv->type = NULL; - priv->domain = NULL; - -} - -static void ga_service_browser_dispose(GObject * object); -static void ga_service_browser_finalize(GObject * object); - -static void ga_service_browser_set_property(GObject * object, - guint property_id, - const GValue * value, GParamSpec * pspec) { - GaServiceBrowser *browser = GA_SERVICE_BROWSER(object); - GaServiceBrowserPrivate *priv = GA_SERVICE_BROWSER_GET_PRIVATE(browser); - - g_assert(priv->browser == NULL); - switch (property_id) { - case PROP_PROTOCOL: - priv->protocol = g_value_get_enum(value); - break; - case PROP_IFINDEX: - priv->interface = g_value_get_int(value); - break; - case PROP_TYPE: - priv->type = g_strdup(g_value_get_string(value)); - break; - case PROP_DOMAIN: - priv->domain = g_strdup(g_value_get_string(value)); - break; - case PROP_FLAGS: - priv->flags = g_value_get_enum(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void ga_service_browser_get_property(GObject * object, - guint property_id, - GValue * value, GParamSpec * pspec) { - GaServiceBrowser *browser = GA_SERVICE_BROWSER(object); - GaServiceBrowserPrivate *priv = GA_SERVICE_BROWSER_GET_PRIVATE(browser); - - switch (property_id) { - case PROP_PROTOCOL: - g_value_set_int(value, priv->protocol); - break; - case PROP_IFINDEX: - g_value_set_int(value, priv->interface); - break; - case PROP_TYPE: - g_value_set_string(value, priv->type); - break; - case PROP_DOMAIN: - g_value_set_string(value, priv->domain); - break; - case PROP_FLAGS: - g_value_set_enum(value, priv->flags); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - - -static void ga_service_browser_class_init(GaServiceBrowserClass * - ga_service_browser_class) { - GObjectClass *object_class = G_OBJECT_CLASS(ga_service_browser_class); - GParamSpec *param_spec; - - g_type_class_add_private(ga_service_browser_class, - sizeof (GaServiceBrowserPrivate)); - - object_class->dispose = ga_service_browser_dispose; - object_class->finalize = ga_service_browser_finalize; - - object_class->set_property = ga_service_browser_set_property; - object_class->get_property = ga_service_browser_get_property; - - signals[NEW] = - g_signal_new("new-service", - G_OBJECT_CLASS_TYPE(ga_service_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _ga_signals_marshal_VOID__INT_ENUM_STRING_STRING_STRING_UINT, - G_TYPE_NONE, 6, - G_TYPE_INT, - GA_TYPE_PROTOCOL, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, GA_TYPE_LOOKUP_RESULT_FLAGS); - - signals[REMOVED] = - g_signal_new("removed-service", - G_OBJECT_CLASS_TYPE(ga_service_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _ga_signals_marshal_VOID__INT_ENUM_STRING_STRING_STRING_UINT, - G_TYPE_NONE, 6, - G_TYPE_INT, - GA_TYPE_PROTOCOL, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, GA_TYPE_LOOKUP_RESULT_FLAGS); - - signals[ALL_FOR_NOW] = - g_signal_new("all-for-now", - G_OBJECT_CLASS_TYPE(ga_service_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - signals[CACHE_EXHAUSTED] = - g_signal_new("cache-exhausted", - G_OBJECT_CLASS_TYPE(ga_service_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - signals[FAILURE] = - g_signal_new("failure", - G_OBJECT_CLASS_TYPE(ga_service_browser_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - param_spec = g_param_spec_enum("protocol", "Avahi protocol to browse", - "Avahi protocol to browse", - GA_TYPE_PROTOCOL, - GA_PROTOCOL_UNSPEC, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_PROTOCOL, param_spec); - - param_spec = g_param_spec_int("interface", "interface index", - "Interface use for browser", - AVAHI_IF_UNSPEC, - G_MAXINT, - AVAHI_IF_UNSPEC, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_IFINDEX, param_spec); - - param_spec = g_param_spec_string("type", "service type", - "Service type to browse for", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_TYPE, param_spec); - - param_spec = g_param_spec_string("domain", "service domain", - "Domain to browse in", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_DOMAIN, param_spec); - - param_spec = g_param_spec_enum("flags", "Lookup flags for the browser", - "Browser lookup flags", - GA_TYPE_LOOKUP_FLAGS, - GA_LOOKUP_NO_FLAGS, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_FLAGS, param_spec); -} - -void ga_service_browser_dispose(GObject * object) { - GaServiceBrowser *self = GA_SERVICE_BROWSER(object); - GaServiceBrowserPrivate *priv = GA_SERVICE_BROWSER_GET_PRIVATE(self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - if (priv->browser) - avahi_service_browser_free(priv->browser); - priv->browser = NULL; - if (priv->client) - g_object_unref(priv->client); - priv->client = NULL; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS(ga_service_browser_parent_class)->dispose) - G_OBJECT_CLASS(ga_service_browser_parent_class)->dispose(object); -} - -void ga_service_browser_finalize(GObject * object) { - GaServiceBrowser *self = GA_SERVICE_BROWSER(object); - GaServiceBrowserPrivate *priv = GA_SERVICE_BROWSER_GET_PRIVATE(self); - - /* free any data held directly by the object here */ - g_free(priv->type); - priv->type = NULL; - g_free(priv->domain); - priv->domain = NULL; - - G_OBJECT_CLASS(ga_service_browser_parent_class)->finalize(object); -} - -static void _avahi_service_browser_cb(AvahiServiceBrowser * b, AvahiIfIndex interface, - AvahiProtocol protocol, AvahiBrowserEvent event, - const char *name, const char *type, - const char *domain, AvahiLookupResultFlags flags, - void *userdata) { - GaServiceBrowser *self = GA_SERVICE_BROWSER(userdata); - GaServiceBrowserPrivate *priv = GA_SERVICE_BROWSER_GET_PRIVATE(self); - if (priv->browser == NULL) { - priv->browser = b; - } - g_assert(priv->browser == b); - - switch (event) { - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE:{ - guint signalid; - signalid = (event == AVAHI_BROWSER_NEW ? NEW : REMOVED); - g_signal_emit(self, signals[signalid], 0, - interface, protocol, name, type, domain, flags); - break; - } - case AVAHI_BROWSER_CACHE_EXHAUSTED: - g_signal_emit(self, signals[CACHE_EXHAUSTED], 0); - break; - case AVAHI_BROWSER_ALL_FOR_NOW: - g_signal_emit(self, signals[ALL_FOR_NOW], 0); - break; - case AVAHI_BROWSER_FAILURE:{ - GError *error; - int aerrno = avahi_client_errno(priv->client->avahi_client); - error = g_error_new(GA_ERROR, aerrno, - "Browsing failed: %s", - avahi_strerror(aerrno)); - g_signal_emit(self, signals[FAILURE], 0, error); - g_error_free(error); - break; - } - } -} - -GaServiceBrowser *ga_service_browser_new(const gchar * type) { - return ga_service_browser_new_full(AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, type, NULL, 0); -} - -GaServiceBrowser *ga_service_browser_new_full(AvahiIfIndex interface, - AvahiProtocol protocol, - const gchar * type, gchar * domain, - GaLookupFlags flags) { - return g_object_new(GA_TYPE_SERVICE_BROWSER, - "interface", interface, - "protocol", protocol, - "type", type, "domain", domain, "flags", flags, NULL); -} - -gboolean ga_service_browser_attach(GaServiceBrowser * browser, - GaClient * client, GError ** error) { - GaServiceBrowserPrivate *priv = GA_SERVICE_BROWSER_GET_PRIVATE(browser); - - g_object_ref(client); - priv->client = client; - - priv->browser = avahi_service_browser_new(client->avahi_client, - priv->interface, - priv->protocol, - priv->type, priv->domain, - priv->flags, - _avahi_service_browser_cb, - browser); - if (priv->browser == NULL) { - if (error != NULL) { - int aerrno = avahi_client_errno(client->avahi_client); - *error = g_error_new(GA_ERROR, aerrno, - "Attaching group failed: %s", - avahi_strerror(aerrno)); - } - return FALSE; - } - return TRUE; -} diff --git a/avahi-gobject/ga-service-browser.h b/avahi-gobject/ga-service-browser.h deleted file mode 100644 index eaead4b..0000000 --- a/avahi-gobject/ga-service-browser.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ga-service-browser.h - Header for GaServiceBrowser - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GA_SERVICE_BROWSER_H__ -#define __GA_SERVICE_BROWSER_H__ - -#include -#include -#include -#include "ga-client.h" -#include "ga-enums.h" - -G_BEGIN_DECLS - -typedef struct _GaServiceBrowser GaServiceBrowser; -typedef struct _GaServiceBrowserClass GaServiceBrowserClass; - -struct _GaServiceBrowserClass { - GObjectClass parent_class; -}; - -struct _GaServiceBrowser { - GObject parent; -}; - -GType ga_service_browser_get_type(void); - -/* TYPE MACROS */ -#define GA_TYPE_SERVICE_BROWSER \ - (ga_service_browser_get_type()) -#define GA_SERVICE_BROWSER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GA_TYPE_SERVICE_BROWSER, GaServiceBrowser)) -#define GA_SERVICE_BROWSER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GA_TYPE_SERVICE_BROWSER, GaServiceBrowserClass)) -#define IS_GA_SERVICE_BROWSER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GA_TYPE_SERVICE_BROWSER)) -#define IS_GA_SERVICE_BROWSER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GA_TYPE_SERVICE_BROWSER)) -#define GA_SERVICE_BROWSER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GA_TYPE_SERVICE_BROWSER, GaServiceBrowserClass)) - -GaServiceBrowser *ga_service_browser_new(const gchar * type); - -GaServiceBrowser *ga_service_browser_new_full(AvahiIfIndex interface, - AvahiProtocol protocol, - const gchar * type, gchar * domain, - GaLookupFlags flags); - -gboolean -ga_service_browser_attach(GaServiceBrowser * browser, - GaClient * client, GError ** error); - - -G_END_DECLS -#endif /* #ifndef __GA_SERVICE_BROWSER_H__ */ diff --git a/avahi-gobject/ga-service-resolver.c b/avahi-gobject/ga-service-resolver.c deleted file mode 100644 index d3cfaa0..0000000 --- a/avahi-gobject/ga-service-resolver.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * ga-service-resolver.c - Source for GaServiceResolver - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "ga-service-resolver.h" -#include "signals-marshal.h" - -#include "ga-error.h" - -#include "ga-enums.h" -#include "ga-enums-enumtypes.h" - -#include - -G_DEFINE_TYPE(GaServiceResolver, ga_service_resolver, G_TYPE_OBJECT) - -/* signal enum */ -enum { - FOUND, - FAILURE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/* properties */ -enum { - PROP_PROTOCOL = 1, - PROP_IFINDEX, - PROP_NAME, - PROP_TYPE, - PROP_DOMAIN, - PROP_FLAGS, - PROP_APROTOCOL -}; - -/* private structure */ -typedef struct _GaServiceResolverPrivate GaServiceResolverPrivate; - -struct _GaServiceResolverPrivate { - GaClient *client; - AvahiServiceResolver *resolver; - AvahiIfIndex interface; - AvahiProtocol protocol; - AvahiAddress address; - uint16_t port; - char *name; - char *type; - char *domain; - AvahiProtocol aprotocol; - AvahiLookupFlags flags; - gboolean dispose_has_run; -}; - -#define GA_SERVICE_RESOLVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GA_TYPE_SERVICE_RESOLVER, GaServiceResolverPrivate)) - -static void ga_service_resolver_init(GaServiceResolver * obj) { - GaServiceResolverPrivate *priv = GA_SERVICE_RESOLVER_GET_PRIVATE(obj); - - /* allocate any data required by the object here */ - priv->client = NULL; - priv->resolver = NULL; - priv->name = NULL; - priv->type = NULL; - priv->domain = NULL; - priv->port = 0; -} - -static void ga_service_resolver_dispose(GObject * object); -static void ga_service_resolver_finalize(GObject * object); - -static void ga_service_resolver_set_property(GObject * object, - guint property_id, - const GValue * value, GParamSpec * pspec) { - GaServiceResolver *resolver = GA_SERVICE_RESOLVER(object); - GaServiceResolverPrivate *priv = - GA_SERVICE_RESOLVER_GET_PRIVATE(resolver); - - g_assert(priv->resolver == NULL); - switch (property_id) { - case PROP_PROTOCOL: - priv->protocol = g_value_get_enum(value); - break; - case PROP_APROTOCOL: - priv->aprotocol = g_value_get_enum(value); - break; - case PROP_IFINDEX: - priv->interface = g_value_get_int(value); - break; - case PROP_NAME: - priv->name = g_strdup(g_value_get_string(value)); - break; - case PROP_TYPE: - priv->type = g_strdup(g_value_get_string(value)); - break; - case PROP_DOMAIN: - priv->domain = g_strdup(g_value_get_string(value)); - break; - case PROP_FLAGS: - priv->flags = g_value_get_enum(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void ga_service_resolver_get_property(GObject * object, - guint property_id, - GValue * value, GParamSpec * pspec) { - GaServiceResolver *resolver = GA_SERVICE_RESOLVER(object); - GaServiceResolverPrivate *priv = - GA_SERVICE_RESOLVER_GET_PRIVATE(resolver); - - switch (property_id) { - case PROP_APROTOCOL: - g_value_set_enum(value, priv->aprotocol); - break; - case PROP_PROTOCOL: - g_value_set_enum(value, priv->protocol); - break; - case PROP_IFINDEX: - g_value_set_int(value, priv->interface); - break; - case PROP_NAME: - g_value_set_string(value, priv->name); - break; - case PROP_TYPE: - g_value_set_string(value, priv->type); - break; - case PROP_DOMAIN: - g_value_set_string(value, priv->domain); - break; - case PROP_FLAGS: - g_value_set_enum(value, priv->flags); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - - -static void ga_service_resolver_class_init(GaServiceResolverClass * - ga_service_resolver_class) { - GObjectClass *object_class = G_OBJECT_CLASS(ga_service_resolver_class); - GParamSpec *param_spec; - - g_type_class_add_private(ga_service_resolver_class, - sizeof (GaServiceResolverPrivate)); - - object_class->set_property = ga_service_resolver_set_property; - object_class->get_property = ga_service_resolver_get_property; - - object_class->dispose = ga_service_resolver_dispose; - object_class->finalize = ga_service_resolver_finalize; - - signals[FOUND] = - g_signal_new("found", - G_OBJECT_CLASS_TYPE(ga_service_resolver_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _ga_signals_marshal_VOID__INT_ENUM_STRING_STRING_STRING_STRING_POINTER_INT_POINTER_INT, - G_TYPE_NONE, 10, - G_TYPE_INT, - GA_TYPE_PROTOCOL, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_POINTER, - G_TYPE_INT, - G_TYPE_POINTER, GA_TYPE_LOOKUP_RESULT_FLAGS); - - signals[FAILURE] = - g_signal_new("failure", - G_OBJECT_CLASS_TYPE(ga_service_resolver_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - param_spec = g_param_spec_enum("protocol", "Avahi protocol to resolve on", - "Avahi protocol to resolve on", - GA_TYPE_PROTOCOL, - GA_PROTOCOL_UNSPEC, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_PROTOCOL, param_spec); - - param_spec = g_param_spec_enum("aprotocol", "Address protocol", - "Avahi protocol of the address to be resolved", - GA_TYPE_PROTOCOL, - GA_PROTOCOL_UNSPEC, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_APROTOCOL, param_spec); - - param_spec = g_param_spec_int("interface", "interface index", - "Interface use for resolver", - AVAHI_IF_UNSPEC, - G_MAXINT, - AVAHI_IF_UNSPEC, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_IFINDEX, param_spec); - - param_spec = g_param_spec_string("name", "service name", - "name to resolve", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_NAME, param_spec); - - param_spec = g_param_spec_string("type", "service type", - "Service type to browse for", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_TYPE, param_spec); - - param_spec = g_param_spec_string("domain", "service domain", - "Domain to browse in", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_DOMAIN, param_spec); - - param_spec = g_param_spec_enum("flags", "Lookup flags for the resolver", - "Resolver lookup flags", - GA_TYPE_LOOKUP_FLAGS, - GA_LOOKUP_NO_FLAGS, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_class_install_property(object_class, PROP_FLAGS, param_spec); -} - -void ga_service_resolver_dispose(GObject * object) { - GaServiceResolver *self = GA_SERVICE_RESOLVER(object); - GaServiceResolverPrivate *priv = GA_SERVICE_RESOLVER_GET_PRIVATE(self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - if (priv->client) - g_object_unref(priv->client); - priv->client = NULL; - - if (priv->resolver) - avahi_service_resolver_free(priv->resolver); - priv->resolver = NULL; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS(ga_service_resolver_parent_class)->dispose) - G_OBJECT_CLASS(ga_service_resolver_parent_class)->dispose(object); -} - -void ga_service_resolver_finalize(GObject * object) { - GaServiceResolver *self = GA_SERVICE_RESOLVER(object); - GaServiceResolverPrivate *priv = GA_SERVICE_RESOLVER_GET_PRIVATE(self); - - /* free any data held directly by the object here */ - g_free(priv->name); - priv->name = NULL; - - g_free(priv->type); - priv->type = NULL; - - g_free(priv->domain); - priv->domain = NULL; - - G_OBJECT_CLASS(ga_service_resolver_parent_class)->finalize(object); -} - -static void _avahi_service_resolver_cb(AVAHI_GCC_UNUSED AvahiServiceResolver * resolver, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, const char *type, - const char *domain, const char *host_name, - const AvahiAddress * a, - uint16_t port, - AvahiStringList * txt, - AvahiLookupResultFlags flags, void *userdata) { - GaServiceResolver *self = GA_SERVICE_RESOLVER(userdata); - GaServiceResolverPrivate *priv = GA_SERVICE_RESOLVER_GET_PRIVATE(self); - - switch (event) { - case AVAHI_RESOLVER_FOUND:{ - /* FIXME: Double check if this address is always the same */ - priv->address = *a; - priv->port = port; - g_signal_emit(self, signals[FOUND], 0, - interface, protocol, - name, type, - domain, host_name, a, port, txt, flags); - break; - } - case AVAHI_RESOLVER_FAILURE:{ - GError *error; - int aerrno = avahi_client_errno(priv->client->avahi_client); - error = g_error_new(GA_ERROR, aerrno, - "Resolving failed: %s", - avahi_strerror(aerrno)); - g_signal_emit(self, signals[FAILURE], 0, error); - g_error_free(error); - break; - } - } -} - - -GaServiceResolver *ga_service_resolver_new(AvahiIfIndex interface, - AvahiProtocol protocol, - const gchar * name, - const gchar * type, - const gchar * domain, - AvahiProtocol address_protocol, - GaLookupFlags flags) { - return g_object_new(GA_TYPE_SERVICE_RESOLVER, "interface", interface, - "protocol", protocol, "name", name, "type", type, - "domain", domain, "aprotocol", address_protocol, - "flags", flags, NULL); -} - -gboolean ga_service_resolver_attach(GaServiceResolver * resolver, - GaClient * client, GError ** error) { - GaServiceResolverPrivate *priv = - GA_SERVICE_RESOLVER_GET_PRIVATE(resolver); - - g_assert(client != NULL); - g_object_ref(client); - - priv->client = client; - - priv->resolver = avahi_service_resolver_new(client->avahi_client, - priv->interface, - priv->protocol, - priv->name, - priv->type, priv->domain, - priv->aprotocol, - priv->flags, - _avahi_service_resolver_cb, - resolver); - if (priv->resolver == NULL) { - if (error != NULL) { - int aerrno = avahi_client_errno(client->avahi_client); - *error = g_error_new(GA_ERROR, aerrno, - "Attaching group failed: %s", - avahi_strerror(aerrno)); - } -/* printf("Failed to add resolver\n"); */ - return FALSE; - } - return TRUE; -} - -gboolean ga_service_resolver_get_address(GaServiceResolver * resolver, - AvahiAddress * address, uint16_t * port) { - GaServiceResolverPrivate *priv = - GA_SERVICE_RESOLVER_GET_PRIVATE(resolver); - if (priv->port == 0) { -/* printf("PORT == 0\n"); */ - return FALSE; - } - - *address = priv->address; - *port = priv->port; - return TRUE; -} diff --git a/avahi-gobject/ga-service-resolver.h b/avahi-gobject/ga-service-resolver.h deleted file mode 100644 index 50b4f58..0000000 --- a/avahi-gobject/ga-service-resolver.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * ga-service-resolver.h - Header for GaServiceResolver - * Copyright (C) 2006-2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GA_SERVICE_RESOLVER_H__ -#define __GA_SERVICE_RESOLVER_H__ - - -#include - -#include -#include "ga-client.h" -#include "ga-enums.h" - -G_BEGIN_DECLS - -typedef struct _GaServiceResolver GaServiceResolver; -typedef struct _GaServiceResolverClass GaServiceResolverClass; - -struct _GaServiceResolverClass { - GObjectClass parent_class; -}; - -struct _GaServiceResolver { - GObject parent; -}; - -GType ga_service_resolver_get_type(void); - -/* TYPE MACROS */ -#define GA_TYPE_SERVICE_RESOLVER \ - (ga_service_resolver_get_type()) -#define GA_SERVICE_RESOLVER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GA_TYPE_SERVICE_RESOLVER, GaServiceResolver)) -#define GA_SERVICE_RESOLVER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GA_TYPE_SERVICE_RESOLVER, GaServiceResolverClass)) -#define IS_GA_SERVICE_RESOLVER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GA_TYPE_SERVICE_RESOLVER)) -#define IS_GA_SERVICE_RESOLVER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GA_TYPE_SERVICE_RESOLVER)) -#define GA_SERVICE_RESOLVER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GA_TYPE_SERVICE_RESOLVER, GaServiceResolverClass)) - -GaServiceResolver *ga_service_resolver_new(AvahiIfIndex interface, - AvahiProtocol protocol, - const gchar * name, - const gchar * type, - const gchar * domain, - AvahiProtocol address_protocol, - GaLookupFlags flags); - -gboolean -ga_service_resolver_attach(GaServiceResolver * resolver, - GaClient * client, GError ** error); - -gboolean -ga_service_resolver_get_address(GaServiceResolver * resolver, - AvahiAddress * address, uint16_t * port); -G_END_DECLS -#endif /* #ifndef __GA_SERVICE_RESOLVER_H__ */ diff --git a/avahi-python/.gitignore b/avahi-python/.gitignore deleted file mode 100644 index 01b90e7..0000000 --- a/avahi-python/.gitignore +++ /dev/null @@ -1 +0,0 @@ -avahi-bookmarks diff --git a/avahi-python/Makefile.am b/avahi-python/Makefile.am deleted file mode 100644 index 7381a48..0000000 --- a/avahi-python/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -EXTRA_DIST = \ - avahi-bookmarks.in - -SUBDIRS=avahi avahi-discover - -if HAVE_PYTHON -if HAVE_PYTHON_DBUS - -pythonscripts = \ - avahi-bookmarks - -avahi-bookmarks: avahi-bookmarks.in - $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' $< > $@ && \ - chmod +x $@ - -bin_SCRIPTS = $(pythonscripts) -CLEANFILES = $(pythonscripts) - -endif -endif diff --git a/avahi-python/avahi-bookmarks.in b/avahi-python/avahi-bookmarks.in deleted file mode 100755 index dea7bef..0000000 --- a/avahi-python/avahi-bookmarks.in +++ /dev/null @@ -1,227 +0,0 @@ -#!@PYTHON@ -# -*-python-*- -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -import sys, getopt, os - -try: - import avahi, gobject, dbus -except ImportError: - print "Sorry, to use this tool you need to install Avahi and python-dbus." - sys.exit(1) - -try: - import dbus.glib -except ImportError: - pass - -urlproto = { "_http._tcp" : "http", "_https._tcp" : "https", "_ftp._tcp" : "ftp" } - -port = 8080 -address = "127.0.0.1" -use_host_names = None -use_CGI = None -domain = "local" -timeout = 3000 - -class AvahiBookmarks: - services = {} - - def __init__(self, use_host_names): - - self.bus = dbus.SystemBus() - self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) - - self.version_string = self.server.GetVersionString() - - self.browse_service_type("_http._tcp") - self.browse_service_type("_https._tcp") - self.browse_service_type("_ftp._tcp") - - if use_host_names is None: - try: - self.use_host_names = self.server.IsNSSSupportAvailable() - except: - self.use_host_names = False - else: - self.use_host_names = use_host_names - - def browse_service_type(self, stype): - - global domain, use_CGI - - browser = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER) - browser.connect_to_signal('ItemNew', self.new_service) - browser.connect_to_signal('ItemRemove', self.remove_service) - if use_CGI: - browser.connect_to_signal('AllForNow', self.all_for_now) - - def find_path(self, txt): - - l = avahi.txt_array_to_string_array(txt) - - for k in l: - if k[:5] == "path=": - if k[5:].startswith("/"): - return k[5:] - else: - return "/" + k[5:] - - return "/" - - def render_html(self): - - global domain - - t = '%s Zeroconf Bookmarks

    %s Zeroconf Bookmarks

    ' % (domain, domain) - - if len(self.services) == 0: - t += '

    Sorry, no Zeroconf web services have been registered on the %s domain.

    ' % domain - else: - t += '
      ' - - for k, v in self.services.iteritems(): - - if v[3] == 80: - port = '' - else: - port = ':%i' % v[3] - - path = self.find_path(v[4]) - t += '
    • %s
    • ' % (urlproto[k[3]], v[2], port, path, k[2]) - - t += '
    ' - - t += '

    Served by %s

    ' % self.version_string - - return str(t) - - - def new_service(self, interface, protocol, name, type, domain, flags): - - interface, protocol, name, type, domain, host, aprotocol, address, port, txt, flags = self.server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0)) - - if self.use_host_names: - h = host - else: - if aprotocol == avahi.PROTO_INET6: - h = "[" + address + "]" - else: - h = address - - self.services[(interface, protocol, name, type, domain)] = (host, aprotocol, h, port, txt) - - def remove_service(self, interface, protocol, name, type, domain): - - del self.services[(interface, protocol, name, type, domain)] - - - # Only reachable with use_CGI - def all_for_now(self): - - mainloop.quit() - -def usage(retval = 0): - - print "%s [options]\n" % sys.argv[0] - print " -h --help Show this help" - print " -c --cgi Run as a CGI instead of as a server (default to server" - print " unless environment variable GATEWAY_INTERFACE is set)" - print " -t --timeout MS Specify the max time for CGI browsing (default %u)" % timeout - print " -p --port PORT Specify the port to use (default %u)" % port - print " -a --address ADDRESS Specify the address to bind to (default %s)" % address - print " -H --host-names Show links with real hostnames" - print " -A --addresses Show links with numeric IP addresses" - print " -d --domain DOMAIN Specify the domain to browse" - sys.exit(retval) - -try: - opts, args = getopt.getopt(sys.argv[1:], "hct:p:a:HAd:", ["help", "cgi", "port=", "timeout=", "address=", "host-names", "addresses", "domain="]) -except getopt.GetoptError: - usage(2) - -for o, a in opts: - if o in ("-h", "--help"): - usage() - - if o in ("-c", "--cgi"): - use_CGI = True - - if o in ("-t", "--timeout"): - timeout = int(a) - - if o in ("-p", "--port"): - port = int(a) - - if o in ("-a", "--address"): - address = a - - if o in ("-H", "--host-names"): - use_host_names = True - - if o in ("-A", "--addresses"): - use_host_names = False - - if o in ("-d", "--domain"): - domain = a - -if use_CGI is None: - use_CGI = os.environ.has_key("GATEWAY_INTERFACE") - -if use_CGI: - cgi = AvahiBookmarks(use_host_names) - - mainloop = gobject.MainLoop() - gobject.timeout_add(timeout, mainloop.quit) - - try: - mainloop.run() - except KeyboardInterrupt: - pass - - print 'Content-type: text/html\n\n' + cgi.render_html() - -else: - try: - from twisted.internet import glib2reactor - glib2reactor.install() - from twisted.internet import reactor - from twisted.web import server, resource - except ImportError: - print "Sorry, to use this tool as a server you need to install twisted and twisted.web.\n" - sys.exit(1) - - class AvahiBookmarksServer(AvahiBookmarks, resource.Resource): - isLeaf = True - - def __init__(self, use_host_names): - resource.Resource.__init__(self) - AvahiBookmarks.__init__(self, use_host_names) - - def render_GET(self, request): - return self.render_html() - - site = server.Site(AvahiBookmarksServer(use_host_names)) - reactor.listenTCP(port, site, interface=address) - - print "Now point your web browser to http://%s:%u/!" % (address, port) - - try: - reactor.run() - except KeyboardInterrupt: - pass diff --git a/avahi-python/avahi-discover/.gitignore b/avahi-python/avahi-discover/.gitignore deleted file mode 100644 index f08aa89..0000000 --- a/avahi-python/avahi-discover/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -avahi-discover -avahi-discover.desktop -avahi-discover.desktop.in diff --git a/avahi-python/avahi-discover/Makefile.am b/avahi-python/avahi-discover/Makefile.am deleted file mode 100644 index d16bd11..0000000 --- a/avahi-python/avahi-discover/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -EXTRA_DIST = \ - __init__.py \ - avahi-discover.py \ - avahi-discover.desktop.in.in - -if HAVE_PYTHON -if HAVE_PYTHON_DBUS -if HAVE_PYGTK - -pythonscripts = - -desktopdir = $(datadir)/applications -desktop_DATA = - -avahi_discoverdir = $(pythondir)/avahi_discover -avahi_discover_PYTHON = - -if HAVE_GDBM -pythonscripts += \ - avahi-discover -desktop_DATA += avahi-discover.desktop -@INTLTOOL_DESKTOP_RULE@ -avahi_discover_PYTHON += __init__.py -endif - -if HAVE_DBM -pythonscripts += \ - avahi-discover -desktop_DATA += avahi-discover.desktop -@INTLTOOL_DESKTOP_RULE@ -avahi_discover_PYTHON += __init__.py -endif - -avahi-discover.desktop.in: avahi-discover.desktop.in.in - $(AM_V_GEN)sed -e 's,@bindir\@,$(bindir),g' $< > $@ - -avahi-discover: avahi-discover.py - $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ - -e 's,@GETTEXT_PACKAGE\@,"$(GETTEXT_PACKAGE)",g' \ - -e 's,@LOCALEDIR\@,"$(avahilocaledir)",g' \ - -e 's,@interfacesdir\@,$(interfacesdir),g' $< > $@ && \ - chmod +x $@ - -bin_SCRIPTS = $(pythonscripts) - -CLEANFILES = $(pythonscripts) $(desktop_DATA) *.pyc *.pyo avahi-discover.desktop.in - -endif -endif -endif diff --git a/avahi-python/avahi-discover/__init__.py b/avahi-python/avahi-discover/__init__.py deleted file mode 100755 index 6f3ec7f..0000000 --- a/avahi-python/avahi-discover/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -#!@PYTHON@ -# -*-python-*- -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. diff --git a/avahi-python/avahi-discover/avahi-discover.desktop.in.in b/avahi-python/avahi-discover/avahi-discover.desktop.in.in deleted file mode 100644 index dac9818..0000000 --- a/avahi-python/avahi-discover/avahi-discover.desktop.in.in +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Version=1.0 -_Name=Avahi Zeroconf Browser -_Comment=Browse for Zeroconf services available on your network -Exec=@bindir@/avahi-discover -Terminal=false -Type=Application -Icon=network-wired -Categories=GNOME;System; -StartupNotify=false -GenericName= diff --git a/avahi-python/avahi-discover/avahi-discover.py b/avahi-python/avahi-discover/avahi-discover.py deleted file mode 100755 index 362d3b6..0000000 --- a/avahi-python/avahi-discover/avahi-discover.py +++ /dev/null @@ -1,288 +0,0 @@ -#!@PYTHON@ -# -*-python-*- -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -import os, sys - -try: - import avahi, gettext, gtk, gobject, dbus, avahi.ServiceTypeDatabase - gettext.bindtextdomain(@GETTEXT_PACKAGE@, @LOCALEDIR@) - gettext.textdomain(@GETTEXT_PACKAGE@) - _ = gettext.gettext -except ImportError, e: - print "Sorry, to use this tool you need to install Avahi, pygtk and python-dbus.\n Error: %s" % e - sys.exit(1) -except Exception, e: - print "Failed to initialize: %s" % e - sys.exit(1) - - -## !!NOTE!! ## -# It's really important to do this, else you won't see any events -## -try: - from dbus import DBusException - import dbus.glib -except ImportError, e: - pass - -service_type_browsers = {} -service_browsers = {} - -def error_msg(msg): - d = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL, - type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK) - d.set_markup(msg) - d.show_all() - d.run() - d.destroy() - -ui_dir = "@interfacesdir@" - -service_type_db = avahi.ServiceTypeDatabase.ServiceTypeDatabase() - -class Main_window: - def __init__(self, path="avahi-discover.ui", root="main_window", domain=None, **kwargs): - path = os.path.join(ui_dir, path) - gtk.window_set_default_icon_name("network-wired") - self.ui = gtk.Builder() - self.ui.add_from_file(path) - self.ui.connect_signals(self) - self.tree_view = self.ui.get_object("tree_view") - self.info_label = self.ui.get_object("info_label") - self.new() - - def on_tree_view_cursor_changed(self, widget, *args): - (model, iter) = widget.get_selection().get_selected() - stype = None - if iter is not None: - (name,interface,protocol,stype,domain) = self.treemodel.get(iter,1,2,3,4,5) - if stype == None: - self.info_label.set_markup(_("No service currently selected.")) - return - #Asynchronous resolving - self.server.ResolveService( int(interface), int(protocol), name, stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), reply_handler=self.service_resolved, error_handler=self.print_error) - - def protoname(self,protocol): - if protocol == avahi.PROTO_INET: - return "IPv4" - if protocol == avahi.PROTO_INET6: - return "IPv6" - return "n/a" - - def siocgifname(self, interface): - if interface <= 0: - return "n/a" - else: - return self.server.GetNetworkInterfaceNameByIndex(interface) - - def get_interface_name(self, interface, protocol): - if interface == avahi.IF_UNSPEC and protocol == avahi.PROTO_UNSPEC: - return "Wide Area" - else: - return str(self.siocgifname(interface)) + " " + str(self.protoname(protocol)) - - def service_resolved(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags): - print "Service data for service '%s' of type '%s' in domain '%s' on %i.%i:" % (name, stype, domain, interface, protocol) - - print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(avahi.txt_array_to_string_array(txt))) - - self.update_label(interface, protocol, name, stype, domain, host, aprotocol, address, port, avahi.txt_array_to_string_array(txt)) - - def print_error(self, err): - error_label = "Error: %s" % (err) - self.info_label.set_markup(error_label) - print "Error:", str(err) - - def lookup_type(self, stype): - global service_type_db - - try: - return service_type_db[stype] - except KeyError: - return stype - - def new_service(self, interface, protocol, name, stype, domain, flags): - print "Found service '%s' of type '%s' in domain '%s' on %i.%i." % (name, stype, domain, interface, protocol) - if self.zc_ifaces.has_key((interface,protocol)) == False: - - ifn = self.get_interface_name(interface, protocol) - - self.zc_ifaces[(interface,protocol)] = self.insert_row(self.treemodel, None, ifn, None,interface,protocol,None,domain) - if self.zc_domains.has_key((interface,protocol,domain)) == False: - self.zc_domains[(interface,protocol,domain)] = self.insert_row(self.treemodel, self.zc_ifaces[(interface,protocol)], domain,None,interface,protocol,None,domain) - if self.zc_types.has_key((interface,protocol,stype,domain)) == False: - thisDomain = self.zc_domains[(interface,protocol,domain)] - self.zc_types[(interface,protocol,stype,domain)] = self.insert_row(self.treemodel, thisDomain, self.lookup_type(stype), name, interface,None,None,None) - treeiter = self.insert_row(self.treemodel,self.zc_types[(interface,protocol,stype,domain)], name, name, interface,protocol,stype,domain) - self.services_browsed[(interface, protocol, name, stype, domain)] = treeiter - # expand the tree of this path - self.tree_view.expand_to_path(self.treemodel.get_path(treeiter)) - - def remove_service(self, interface, protocol, name, stype, domain, flags): - print "Service '%s' of type '%s' in domain '%s' on %i.%i disappeared." % (name, stype, domain, interface, protocol) - self.info_label.set_markup("") - treeiter=self.services_browsed[(interface, protocol, name, stype, domain)] - parent = self.treemodel.iter_parent(treeiter) - self.treemodel.remove(treeiter) - del self.services_browsed[(interface, protocol, name, stype, domain)] - if self.treemodel.iter_has_child(parent) == False: - treeiter=self.zc_types[(interface,protocol,stype,domain)] - parent = self.treemodel.iter_parent(treeiter) - self.treemodel.remove(treeiter) - del self.zc_types[(interface,protocol,stype,domain)] - if self.treemodel.iter_has_child(parent) == False: - treeiter=self.zc_domains[(interface,protocol,domain)] - parent = self.treemodel.iter_parent(treeiter) - self.treemodel.remove(treeiter) - del self.zc_domains[(interface,protocol,domain)] - if self.treemodel.iter_has_child(parent) == False: - treeiter=self.zc_ifaces[(interface,protocol)] - parent = self.treemodel.iter_parent(treeiter) - self.treemodel.remove(treeiter) - del self.zc_ifaces[(interface,protocol)] - - def new_service_type(self, interface, protocol, stype, domain, flags): - global service_browsers - - # Are we already browsing this domain for this type? - if service_browsers.has_key((interface, protocol, stype, domain)): - return - - print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (stype, domain, interface, protocol) - - b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER) - b.connect_to_signal('ItemNew', self.new_service) - b.connect_to_signal('ItemRemove', self.remove_service) - - service_browsers[(interface, protocol, stype, domain)] = b - - def browse_domain(self, interface, protocol, domain): - global service_type_browsers - - # Are we already browsing this domain? - if service_type_browsers.has_key((interface, protocol, domain)): - return - - if self.stype is None: - print "Browsing domain '%s' on %i.%i ..." % (domain, interface, protocol) - - try: - b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceTypeBrowserNew(interface, protocol, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER) - except DBusException, e: - print e - error_msg("You should check that the avahi daemon is running.\n\nError : %s" % e) - sys.exit(0) - - b.connect_to_signal('ItemNew', self.new_service_type) - - service_type_browsers[(interface, protocol, domain)] = b - else: - new_service_type(interface, protocol, stype, domain) - - def new_domain(self,interface, protocol, domain, flags): - if self.zc_ifaces.has_key((interface,protocol)) == False: - ifn = self.get_interface_name(interface, protocol) - self.zc_ifaces[(interface,protocol)] = self.insert_row(self.treemodel, None, ifn,None,interface,protocol,None,domain) - if self.zc_domains.has_key((interface,protocol,domain)) == False: - self.zc_domains[(interface,protocol,domain)] = self.insert_row(self.treemodel, self.zc_ifaces[(interface,protocol)], domain,None,interface,protocol,None,domain) - if domain != "local": - self.browse_domain(interface, protocol, domain) - - def pair_to_dict(self, l): - res = dict() - for el in l: - if "=" not in el: - res[el]='' - else: - tmp = el.split('=',1) - if len(tmp[0]) > 0: - res[tmp[0]] = tmp[1] - return res - - - def update_label(self,interface, protocol, name, stype, domain, host, aprotocol, address, port, txt): - if len(txt) != 0: - txts = "" - txtd = self.pair_to_dict(txt) - for k,v in txtd.items(): - txts+="" + _("TXT") + " %s = %s\n" % (k,v) - else: - txts = "" + _("TXT Data:") + " " + _("empty") + "" - - infos = "" + _("Service Type:") + " %s\n" - infos += "" + _("Service Name:") + " %s\n" - infos += "" + _("Domain Name:") + " %s\n" - infos += "" + _("Interface:") + " %s %s\n" - infos += "" + _("Address:") + " %s/%s:%i\n%s" - infos = infos % (stype, name, domain, self.siocgifname(interface), self.protoname(protocol), host, address, port, txts.strip()) - self.info_label.set_markup(infos) - - def insert_row(self, model,parent, - content, name, interface,protocol,stype,domain): - myiter=model.insert_after(parent,None) - model.set(myiter,0,content,1,name,2,str(interface),3,str(protocol),4,stype,5,domain) - return myiter - - def new(self): - self.treemodel=gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) - self.tree_view.set_model(self.treemodel) - - #creating the columns headers - self.tree_view.set_headers_visible(False) - renderer=gtk.CellRendererText() - column=gtk.TreeViewColumn("",renderer, text=0) - column.set_resizable(True) - column.set_sizing("GTK_TREE_VIEW_COLUMN_GROW_ONLY"); - column.set_expand(True); - self.tree_view.append_column(column) - - self.domain = None - self.stype = None - self.zc_ifaces = {} - self.zc_domains = {} - self.zc_types = {} - self.services_browsed = {} - - try: - self.bus = dbus.SystemBus() - self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) - except Exception, e: - print "Failed to connect to Avahi Server (Is it running?): %s" % e - sys.exit(1) - - if self.domain is None: - # Explicitly browse .local - self.browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local") - - # Browse for other browsable domains - db = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE, dbus.UInt32(0))), avahi.DBUS_INTERFACE_DOMAIN_BROWSER) - db.connect_to_signal('ItemNew', self.new_domain) - else: - # Just browse the domain the user wants us to browse - self.browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain) - - def gtk_main_quit(self, *args): - gtk.main_quit() - -def main(): - main_window = Main_window() - gtk.main() - -if __name__ == "__main__": - main() diff --git a/avahi-python/avahi/.gitignore b/avahi-python/avahi/.gitignore deleted file mode 100644 index 118a34d..0000000 --- a/avahi-python/avahi/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ServiceTypeDatabase.py diff --git a/avahi-python/avahi/Makefile.am b/avahi-python/avahi/Makefile.am deleted file mode 100644 index 3eb67d0..0000000 --- a/avahi-python/avahi/Makefile.am +++ /dev/null @@ -1,61 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -EXTRA_DIST = __init__.py ServiceTypeDatabase.py.in - -pkglibdatadir=$(libdir)/avahi - -if HAVE_PYTHON - -avahidir = $(pythondir)/avahi - -if HAVE_GDBM -nodist_avahi_SCRIPTS = ServiceTypeDatabase.py - -ServiceTypeDatabase.py: ServiceTypeDatabase.py.in - $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ - -e 's,@DBM\@,gdbm,g' \ - -e 's,@FIRST_KEY\@,key = self.db.firstkey(),g' \ - -e 's,@CHECK_KEY\@,while key is not None:,g' \ - -e 's,@NEXT_KEY\@,key = self.db.nextkey(key),g' \ - -e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \ - chmod +x $@ -endif - -if HAVE_DBM -nodist_avahi_SCRIPTS = ServiceTypeDatabase.py - -ServiceTypeDatabase.py: ServiceTypeDatabase.py.in - $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ - -e 's,@DBM\@,dbm,g' \ - -e 's,@FIRST_KEY\@,keys = self.db.keys(),g' \ - -e 's,@CHECK_KEY\@,for key in keys:,g' \ - -e 's,@NEXT_KEY\@,,g' \ - -e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \ - chmod +x $@ -endif - -avahi_PYTHON = $(avahi_SCRIPTS) - -if HAVE_PYTHON_DBUS - -avahi_PYTHON += __init__.py - -endif -endif - -CLEANFILES=*.pyc *.pyo ServiceTypeDatabase.py diff --git a/avahi-python/avahi/ServiceTypeDatabase.py.in b/avahi-python/avahi/ServiceTypeDatabase.py.in deleted file mode 100644 index b2035fd..0000000 --- a/avahi-python/avahi/ServiceTypeDatabase.py.in +++ /dev/null @@ -1,161 +0,0 @@ -#!@PYTHON@ -# -*-python-*- -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -import @DBM@ -import locale -import re - -locale.setlocale(locale.LC_ALL, '') - -class ServiceTypeDatabase: - """ServiceTypeDatabase maps service types to descriptions""" - - def __init__(self, filename = "@pkglibdatadir@/service-types.db"): - - self.db = @DBM@.open(filename, "r") - - l = locale.getlocale(locale.LC_MESSAGES) - - self.suffixes = () - - if not l[0] is None: - - if not l[1] is None: - self.suffixes += (l[0] + "@" + l[1], ) - - self.suffixes += (l[0], ) - - i = l[0].find("_") - - if i >= 0: - - k = l[0][:i] - - if not l[1] is None: - self.suffixes += (k + "@" + l[1], ) - - self.suffixes += (k, ) - - - self.suffixes = tuple(map(lambda x: "["+x+"]", self.suffixes)) + ("", ) - - def __getitem__(self, key): - - for suffix in self.suffixes: - try: - return self.db[key + suffix] - except KeyError: - pass - - raise KeyError() - - def items(self): - - return list(self.iteritems()) - - def has_key(self, key): - - for suffix in self.suffixes: - - if self.db.has_key(key + suffix): - return True - - return False - - def __contains__(self, item): - - for suffix in self.suffixes: - - if item+suffix in self.db: - return True - - return False - - - def __iter__(self): - - @FIRST_KEY@ - @CHECK_KEY@ - - if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key): - yield key - - @NEXT_KEY@ - - def __len__(self): - - count = 0 - for _ in self: - - count+=1 - - self.__len__ = lambda : count - return len(self) - - def get(self, key, default=None): - - if key in self: - return self[key] - else: - return default - - def iteritems(self): - - return ((key, self[key]) for key in self) - - def iterkeys(self): - - return self.__iter__() - - def itervalues(self): - - return (self[key] for key in self) - - def keys(self): - - return list(self) - - def values(self): - - return list(self.itervalues()) - -if __name__ == "__main__": - - b = ServiceTypeDatabase() - print b.items() - - print b["_http._tcp"] - print b["_ftp._tcp"] - print b["_webdav._tcp"] - print b["_webdavs._tcp"] - - print b.get("gurki._tcp") - print len(b) - - for key, _ in zip(b, xrange(3)): - - print key - - for key, _ in zip(b.iteritems(), xrange(3)): - - print key - - for key, _ in zip(b.itervalues(), xrange(3)): - - print key diff --git a/avahi-python/avahi/__init__.py b/avahi-python/avahi/__init__.py deleted file mode 100644 index 7b45029..0000000 --- a/avahi-python/avahi/__init__.py +++ /dev/null @@ -1,112 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# Some definitions matching those in avahi-common/defs.h - -import dbus - -SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_FAILURE = range(0, 5) - -ENTRY_GROUP_UNCOMMITED, ENTRY_GROUP_REGISTERING, ENTRY_GROUP_ESTABLISHED, ENTRY_GROUP_COLLISION, ENTRY_GROUP_FAILURE = range(0, 5) - -DOMAIN_BROWSER_BROWSE, DOMAIN_BROWSER_BROWSE_DEFAULT, DOMAIN_BROWSER_REGISTER, DOMAIN_BROWSER_REGISTER_DEFAULT, DOMAIN_BROWSER_BROWSE_LEGACY = range(0, 5) - -PROTO_UNSPEC, PROTO_INET, PROTO_INET6 = -1, 0, 1 - -IF_UNSPEC = -1 - -PUBLISH_UNIQUE = 1 -PUBLISH_NO_PROBE = 2 -PUBLISH_NO_ANNOUNCE = 4 -PUBLISH_ALLOW_MULTIPLE = 8 -PUBLISH_NO_REVERSE = 16 -PUBLISH_NO_COOKIE = 32 -PUBLISH_UPDATE = 64 -PUBLISH_USE_WIDE_AREA = 128 -PUBLISH_USE_MULTICAST = 256 - -LOOKUP_USE_WIDE_AREA = 1 -LOOKUP_USE_MULTICAST = 2 -LOOKUP_NO_TXT = 4 -LOOKUP_NO_ADDRESS = 8 - -LOOKUP_RESULT_CACHED = 1 -LOOKUP_RESULT_WIDE_AREA = 2 -LOOKUP_RESULT_MULTICAST = 4 -LOOKUP_RESULT_LOCAL = 8 -LOOKUP_RESULT_OUR_OWN = 16 -LOOKUP_RESULT_STATIC = 32 - -SERVICE_COOKIE = "org.freedesktop.Avahi.cookie" -SERVICE_COOKIE_INVALID = 0 - -DBUS_NAME = "org.freedesktop.Avahi" -DBUS_INTERFACE_SERVER = DBUS_NAME + ".Server" -DBUS_PATH_SERVER = "/" -DBUS_INTERFACE_ENTRY_GROUP = DBUS_NAME + ".EntryGroup" -DBUS_INTERFACE_DOMAIN_BROWSER = DBUS_NAME + ".DomainBrowser" -DBUS_INTERFACE_SERVICE_TYPE_BROWSER = DBUS_NAME + ".ServiceTypeBrowser" -DBUS_INTERFACE_SERVICE_BROWSER = DBUS_NAME + ".ServiceBrowser" -DBUS_INTERFACE_ADDRESS_RESOLVER = DBUS_NAME + ".AddressResolver" -DBUS_INTERFACE_HOST_NAME_RESOLVER = DBUS_NAME + ".HostNameResolver" -DBUS_INTERFACE_SERVICE_RESOLVER = DBUS_NAME + ".ServiceResolver" -DBUS_INTERFACE_RECORD_BROWSER = DBUS_NAME + ".RecordBrowser" - -def byte_array_to_string(s): - r = "" - - for c in s: - - if c >= 32 and c < 127: - r += "%c" % c - else: - r += "." - - return r - -def txt_array_to_string_array(t): - l = [] - - for s in t: - l.append(byte_array_to_string(s)) - - return l - - -def string_to_byte_array(s): - r = [] - - for c in s: - r.append(dbus.Byte(ord(c))) - - return r - -def string_array_to_txt_array(t): - l = [] - - for s in t: - l.append(string_to_byte_array(s)) - - return l - -def dict_to_txt_array(txt_dict): - l = [] - - for k,v in txt_dict.items(): - l.append(string_to_byte_array("%s=%s" % (k,v))) - - return l diff --git a/avahi-qt/.gitignore b/avahi-qt/.gitignore deleted file mode 100644 index e155956..0000000 --- a/avahi-qt/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs -*.moc3 -*.moc4 diff --git a/avahi-qt/Makefile.am b/avahi-qt/Makefile.am deleted file mode 100644 index 64356a5..0000000 --- a/avahi-qt/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -lib_LTLIBRARIES = -BUILT_SOURCES = - -if HAVE_QT3 - -avahiqt3includedir=$(includedir)/avahi-qt3 - -avahiqt3include_HEADERS = \ - qt-watch.h - -lib_LTLIBRARIES += \ - libavahi-qt3.la - -BUILT_SOURCES += qt-watch.moc3 - -libavahi_qt3_la_SOURCES = \ - qt-watch.cpp - -qt-watch.moc3: qt-watch.cpp - $(AM_V_GEN)$(MOC_QT3) $^ > $@ - -libavahi_qt3_la_CPPFLAGS = $(AM_CFLAGS) $(QT3_CFLAGS) $(VISIBILITY_HIDDEN_CFLAGS) -libavahi_qt3_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT3_LIBS) -libavahi_qt3_la_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -version-info $(LIBAVAHI_QT3_VERSION_INFO) -endif - -if HAVE_QT4 - -avahiqt4includedir=$(includedir)/avahi-qt4 -avahiqt4include_HEADERS = \ - qt-watch.h - -lib_LTLIBRARIES += \ - libavahi-qt4.la - -BUILT_SOURCES += qt-watch.moc4 - -libavahi_qt4_la_SOURCES = \ - qt-watch.cpp - -qt-watch.moc4: qt-watch.cpp - $(AM_V_GEN)$(MOC_QT4) $^ > $@ - -libavahi_qt4_la_CPPFLAGS = $(AM_CFLAGS) $(QT4_CFLAGS) -DQT4 $(VISIBILITY_HIDDEN_CFLAGS) -libavahi_qt4_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT4_LIBS) -libavahi_qt4_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_QT4_VERSION_INFO) -endif - -CLEANFILES = $(BUILT_SOURCES) diff --git a/avahi-qt/qt-watch.cpp b/avahi-qt/qt-watch.cpp deleted file mode 100644 index dac9dcc..0000000 --- a/avahi-qt/qt-watch.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include -#ifdef QT4 -#include -#include -#include -#else -#include -#include -#include -#endif -#include -#include "qt-watch.h" - -class AvahiWatch : public QObject -{ - Q_OBJECT -public: - AvahiWatch(int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void* userdata); - ~AvahiWatch() {} - AvahiWatchEvent getEvents() const { return m_incallback ? m_lastEvent : (AvahiWatchEvent)0; } - void setWatchedEvents(AvahiWatchEvent event); - -private slots: - void gotIn(); - void gotOut(); - -private: - QSocketNotifier* m_in; - QSocketNotifier* m_out; - //FIXME: ERR and HUP? - AvahiWatchCallback m_callback; - AvahiWatchEvent m_lastEvent; - int m_fd; - void* m_userdata; - bool m_incallback; -}; - -class AvahiTimeout : public QObject -{ - Q_OBJECT - -public: - AvahiTimeout(const struct timeval* tv, AvahiTimeoutCallback callback, void* userdata); - ~AvahiTimeout() {} - void update(const struct timeval* tv); - -private slots: - void timeout(); - -private: - QTimer m_timer; - AvahiTimeoutCallback m_callback; - void* m_userdata; -}; - - - -AvahiWatch::AvahiWatch(int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void* userdata) : - m_in(0), m_out(0), m_callback(callback), m_fd(fd), m_userdata(userdata), m_incallback(false) -{ - setWatchedEvents(event); -} - -void AvahiWatch::gotIn() -{ - m_lastEvent = AVAHI_WATCH_IN; - m_incallback=true; - m_callback(this,m_fd,m_lastEvent,m_userdata); - m_incallback=false; -} - -void AvahiWatch::gotOut() -{ - m_lastEvent = AVAHI_WATCH_IN; - m_incallback=true; - m_callback(this,m_fd,m_lastEvent,m_userdata); - m_incallback=false; -} - -void AvahiWatch::setWatchedEvents(AvahiWatchEvent event) -{ - if (!(event & AVAHI_WATCH_IN)) { delete m_in; m_in=0; } - if (!(event & AVAHI_WATCH_OUT)) { delete m_out; m_out=0; } - if (event & AVAHI_WATCH_IN) { - m_in = new QSocketNotifier(m_fd,QSocketNotifier::Read, this); - connect(m_in,SIGNAL(activated(int)),SLOT(gotIn())); - } - if (event & AVAHI_WATCH_OUT) { - m_out = new QSocketNotifier(m_fd,QSocketNotifier::Write, this); - connect(m_out,SIGNAL(activated(int)),SLOT(gotOut())); - } -} - -AvahiTimeout::AvahiTimeout(const struct timeval* tv, AvahiTimeoutCallback callback, void *userdata) : - m_callback(callback), m_userdata(userdata) -{ - connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout())); -#ifdef QT4 - m_timer.setSingleShot(true); -#endif - update(tv); -} - -void AvahiTimeout::update(const struct timeval *tv) -{ - m_timer.stop(); - if (tv) { - AvahiUsec u = avahi_age(tv)/1000; -#ifdef QT4 - m_timer.start( (u>0) ? 0 : -u); -#else - m_timer.start( (u>0) ? 0 : -u,true); -#endif - } -} - -void AvahiTimeout::timeout() -{ - m_callback(this,m_userdata); -} - -static AvahiWatch* q_watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, - void *userdata) -{ - return new AvahiWatch(fd, event, callback, userdata); -} - -static void q_watch_update(AvahiWatch *w, AvahiWatchEvent events) -{ - w->setWatchedEvents(events); -} - -static AvahiWatchEvent q_watch_get_events(AvahiWatch *w) -{ - return w->getEvents(); -} - -static void q_watch_free(AvahiWatch *w) -{ - delete w; -} - -static AvahiTimeout* q_timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, - void *userdata) -{ - return new AvahiTimeout(tv, callback, userdata); -} - -static void q_timeout_update(AvahiTimeout *t, const struct timeval *tv) -{ - t->update(tv); -} - -static void q_timeout_free(AvahiTimeout *t) -{ - delete t; -} - -const AvahiPoll* avahi_qt_poll_get(void) -{ - static const AvahiPoll qt_poll = { - NULL, - q_watch_new, - q_watch_update, - q_watch_get_events, - q_watch_free, - q_timeout_new, - q_timeout_update, - q_timeout_free - }; - - return &qt_poll; -} - -#ifdef QT4 -#include "qt-watch.moc4" -#else -#include "qt-watch.moc3" -#endif diff --git a/avahi-qt/qt-watch.h b/avahi-qt/qt-watch.h deleted file mode 100644 index cd7130d..0000000 --- a/avahi-qt/qt-watch.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef QAVAHI_H -#define QAVAHI_H - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -/** \file qt-watch.h Qt main loop adapter */ - -#include - -AVAHI_C_DECL_BEGIN - -/** Setup abstract poll structure for integration with Qt main loop */ -const AvahiPoll* avahi_qt_poll_get(void) -#ifdef HAVE_VISIBILITY_HIDDEN -__attribute__ ((visibility("default"))) -#endif -; - -AVAHI_C_DECL_END - -#endif diff --git a/avahi-qt3.pc.in b/avahi-qt3.pc.in deleted file mode 100644 index c18f080..0000000 --- a/avahi-qt3.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include - -Name: avahi-qt3 -Description: Avahi Multicast DNS Responder (QT3 Support) -Version: @PACKAGE_VERSION@ -Requires.private: qt-mt >= 3.0.0 -Libs: -L${libdir} -lavahi-qt3 -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-qt4.pc.in b/avahi-qt4.pc.in deleted file mode 100644 index f62f717..0000000 --- a/avahi-qt4.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include - -Name: avahi-qt4 -Description: Avahi Multicast DNS Responder (QT4 Support) -Version: @PACKAGE_VERSION@ -Requires.private: QtCore >= 4.0.0 -Libs: -L${libdir} -lavahi-qt4 -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-sharp.pc.in b/avahi-sharp.pc.in deleted file mode 100644 index 3cc78b6..0000000 --- a/avahi-sharp.pc.in +++ /dev/null @@ -1,8 +0,0 @@ -prefix=@prefix@ -exec_prefix=@prefix@ -libdir=@libdir@ - -Name: avahi-sharp -Description: Mono bindings for the Avahi mDNS/DNS-SD stack -Version: @PACKAGE_VERSION@ -Libs: -r:${libdir}/mono/avahi-sharp/avahi-sharp.dll diff --git a/avahi-sharp/.gitignore b/avahi-sharp/.gitignore deleted file mode 100644 index 9ad47f0..0000000 --- a/avahi-sharp/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -avahi-sharp-docs.tree -avahi-sharp-docs.zip -avahi-sharp.dll -avahi-sharp.dll.config -avahi-sharp.dll.mdb - diff --git a/avahi-sharp/AddressResolver.cs b/avahi-sharp/AddressResolver.cs deleted file mode 100644 index c11e97d..0000000 --- a/avahi-sharp/AddressResolver.cs +++ /dev/null @@ -1,190 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Collections; -using System.Net; -using System.Runtime.InteropServices; -using Mono.Unix; - -namespace Avahi -{ - - internal delegate void AddressResolverCallback (IntPtr resolver, int iface, Protocol proto, - ResolverEvent revent, IntPtr address, - IntPtr hostname, LookupResultFlags flags, IntPtr userdata); - - public delegate void HostAddressHandler (object o, HostAddressArgs args); - - public class HostAddressArgs : EventArgs - { - private string host; - private IPAddress address; - - public string Host - { - get { return host; } - } - - public IPAddress Address - { - get { return address; } - } - - public HostAddressArgs (string host, IPAddress address) - { - this.host = host; - this.address = address; - } - } - - public class AddressResolver : ResolverBase, IDisposable - { - private IntPtr handle; - private Client client; - private int iface; - private Protocol proto; - private IPAddress address; - private LookupFlags flags; - private AddressResolverCallback cb; - - private IPAddress currentAddress; - private string currentHost; - - private ArrayList foundListeners = new ArrayList (); - private ArrayList timeoutListeners = new ArrayList (); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_address_resolver_new (IntPtr client, int iface, Protocol proto, - IntPtr address, LookupFlags flags, - AddressResolverCallback cb, - IntPtr userdata); - - [DllImport ("avahi-client")] - private static extern void avahi_address_resolver_free (IntPtr handle); - - public event HostAddressHandler Found - { - add { - foundListeners.Add (value); - Start (); - } - remove { - foundListeners.Remove (value); - Stop (false); - } - } - - public event EventHandler Timeout - { - add { - timeoutListeners.Add (value); - Start (); - } - remove { - timeoutListeners.Remove (value); - Stop (false); - } - } - - public IPAddress Address - { - get { return currentAddress; } - } - - public string HostName - { - get { return currentHost; } - } - - public AddressResolver (Client client, IPAddress address) : this (client, -1, Protocol.Unspecified, - address, LookupFlags.None) - { - } - - public AddressResolver (Client client, int iface, Protocol proto, IPAddress address, LookupFlags flags) - { - this.client = client; - this.iface = iface; - this.proto = proto; - this.address = address; - this.flags = flags; - cb = OnAddressResolverCallback; - } - - ~AddressResolver () - { - Dispose (); - } - - public void Dispose () - { - Stop (true); - } - - private void Start () - { - if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || - (foundListeners.Count == 0 && timeoutListeners.Count == 0)) - return; - - IntPtr addrPtr = Utility.AddressToPtr (address); - - lock (client) { - handle = avahi_address_resolver_new (client.Handle, iface, proto, addrPtr, flags, - cb, IntPtr.Zero); - - if (handle == IntPtr.Zero) - client.ThrowError (); - } - - Utility.Free (addrPtr); - } - - private void Stop (bool force) - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && - (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) { - - lock (client) { - avahi_address_resolver_free (handle); - handle = IntPtr.Zero; - } - } - } - - private void OnAddressResolverCallback (IntPtr resolver, int iface, Protocol proto, - ResolverEvent revent, IntPtr address, - IntPtr hostname, LookupResultFlags flags, IntPtr userdata) - { - switch (revent) { - case ResolverEvent.Found: - currentAddress = Utility.PtrToAddress (address); - currentHost = Utility.PtrToString (hostname); - - foreach (HostAddressHandler handler in foundListeners) - handler (this, new HostAddressArgs (currentHost, currentAddress)); - break; - case ResolverEvent.Failure: - EmitFailure (client.LastError); - break; - } - } - } -} diff --git a/avahi-sharp/AssemblyInfo.cs b/avahi-sharp/AssemblyInfo.cs deleted file mode 100644 index aff09d9..0000000 --- a/avahi-sharp/AssemblyInfo.cs +++ /dev/null @@ -1,48 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("avahi-sharp")] -[assembly: AssemblyDescription("Mono bindings for the Avahi mDNS/DNS-SD stack")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("(C) 2005 James Willcox ")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.0")] diff --git a/avahi-sharp/AvahiTest.cs b/avahi-sharp/AvahiTest.cs deleted file mode 100644 index 6ccfd57..0000000 --- a/avahi-sharp/AvahiTest.cs +++ /dev/null @@ -1,131 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Collections; -using System.Text; -using System.Net; -using Avahi; - -public class AvahiTest { - private static Client client; - private static ArrayList objects = new ArrayList (); - - public static void Main () { - client = new Client (); - - Console.WriteLine ("joined service name: " + Client.JoinServiceName ("FooBar", "_foo", "local")); - - EntryGroup eg = new EntryGroup (client); - eg.StateChanged += OnEntryGroupChanged; - eg.AddService ("foobar2", "_dingdong._tcp", client.DomainName, - 444, new string[] { "foo=stuff", "bar=stuff2", "baz=stuff3" }); - eg.Commit (); - BrowseServiceTypes ("local"); - Console.WriteLine ("Press enter to quit"); - Console.ReadLine (); - client.Dispose (); - } - - private static void OnEntryGroupChanged (object o, EntryGroupStateArgs args) - { - Console.WriteLine ("Entry group status: " + args.State); - if (args.State == EntryGroupState.Established) { - DomainBrowser browser = new DomainBrowser (client); - objects.Add (browser); - - browser.DomainAdded += OnDomainAdded; - } - } - - private static void OnDomainAdded (object o, DomainInfoArgs args) - { - Console.WriteLine ("Got domain added: " + args.Domain.Domain); - // BrowseServiceTypes (args.Domain.Domain); - } - - private static void BrowseServiceTypes (string domain) - { - ServiceTypeBrowser stb = new ServiceTypeBrowser (client, domain); - objects.Add (stb); - - stb.CacheExhausted += OnCacheExhausted; - stb.ServiceTypeAdded += OnServiceTypeAdded; - } - - private static void OnCacheExhausted (object o, EventArgs args) - { - Console.WriteLine ("Cache is exhausted"); - } - - private static void OnServiceTypeAdded (object o, ServiceTypeInfoArgs args) - { - Console.WriteLine ("Got service type: " + args.ServiceType.ServiceType); - ServiceBrowser sb = new ServiceBrowser (client, args.ServiceType.ServiceType, args.ServiceType.Domain); - objects.Add (sb); - - sb.ServiceAdded += OnServiceAdded; - } - - private static void OnServiceAdded (object o, ServiceInfoArgs args) - { - // Console.WriteLine ("Got service: " + info.Name); - ServiceResolver resolver = new ServiceResolver (client, args.Service); - objects.Add (resolver); - resolver.Found += OnServiceResolved; - } - - private static void OnServiceResolved (object o, ServiceInfoArgs args) - { - objects.Remove (o); - - Console.WriteLine ("Service '{0}' at {1}:{2}", args.Service.Name, args.Service.HostName, args.Service.Port); - foreach (byte[] bytes in args.Service.Text) { - Console.WriteLine ("Text: " + Encoding.UTF8.GetString (bytes)); - } - - AddressResolver ar = new AddressResolver (client, args.Service.Address); - objects.Add (ar); - - ar.Found += OnAddressResolved; - ar.Failed += OnAddressResolverFailed; - } - - private static void OnAddressResolverFailed (object o, ErrorCodeArgs args) - { - Console.WriteLine ("Failed to resolve '{0}': {1}", (o as AddressResolver).Address, args.ErrorCode); - } - - private static void OnAddressResolved (object o, HostAddressArgs args) - { - objects.Remove (o); - - Console.WriteLine ("Resolved {0} to {1}", args.Address, args.Host); - HostNameResolver hr = new HostNameResolver (client, args.Host); - objects.Add (hr); - - hr.Found += OnHostNameResolved; - } - - private static void OnHostNameResolved (object o, HostAddressArgs args) - { - objects.Remove (o); - Console.WriteLine ("Resolved {0} to {1}", args.Host, args.Address); - } -} diff --git a/avahi-sharp/BrowserBase.cs b/avahi-sharp/BrowserBase.cs deleted file mode 100644 index 3af0086..0000000 --- a/avahi-sharp/BrowserBase.cs +++ /dev/null @@ -1,50 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; - -namespace Avahi -{ - public abstract class BrowserBase - { - public event EventHandler CacheExhausted; - public event EventHandler AllForNow; - public event EventHandler Failed; - - internal void EmitBrowserEvent (BrowserEvent bevent) - { - switch (bevent) { - case BrowserEvent.CacheExhausted: - if (CacheExhausted != null) - CacheExhausted (this, new EventArgs ()); - break; - case BrowserEvent.AllForNow: - if (AllForNow != null) - AllForNow (this, new EventArgs ()); - break; - case BrowserEvent.Failure: - if (Failed != null) - Failed (this, new EventArgs ()); - break; - default: - break; - } - } - } -} diff --git a/avahi-sharp/Client.cs b/avahi-sharp/Client.cs deleted file mode 100644 index b3815b3..0000000 --- a/avahi-sharp/Client.cs +++ /dev/null @@ -1,383 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - - -using System; -using System.Threading; -using System.Collections; -using System.Runtime.InteropServices; -using Mono.Unix; -using Mono.Unix.Native; - -using Stdlib = Mono.Unix.Native.Stdlib; - -namespace Avahi -{ - internal enum ResolverEvent { - Found, - Failure - } - - internal enum BrowserEvent { - Added, - Removed, - CacheExhausted, - AllForNow, - Failure - } - - internal delegate int PollCallback (IntPtr ufds, uint nfds, int timeout); - internal delegate void ClientCallback (IntPtr client, ClientState state, IntPtr userData); - - public delegate void ClientStateHandler (object o, ClientStateArgs state); - - public class ClientStateArgs : EventArgs - { - private ClientState state; - private ErrorCode error; - - public ClientState State - { - get { return state; } - } - - public ErrorCode Error - { - get { return error; } - } - - public ClientStateArgs (ClientState state, ErrorCode error) - { - this.state = state; - this.error = error; - } - } - - public enum Protocol { - Unspecified = -1, - IPv4 = 0, - IPv6 = 1 - } - - internal enum ServerState { - Invalid, - Registering, - Running, - Collision - } - - public enum ClientState { - Registering = ServerState.Registering, - Running = ServerState.Running, - Collision = ServerState.Collision, - Failure = 100, - Connecting = 101 - } - - [Flags] - public enum LookupFlags { - None = 0, - UseWideArea = 1, - UseMulticast = 2, - NoTxt = 4, - NoAddress = 8 - } - - [Flags] - public enum LookupResultFlags { - None = 0, - Cached = 1, - WideArea = 2, - Multicast = 4, - Local = 8, - OurOwn = 16, - } - - [Flags] - public enum ClientFlags { - None = 0, - IgnoreUserConfig = 1, - NoFail = 2 - } - - public class Client : IDisposable - { - private IntPtr handle; - private ClientCallback cb; - private PollCallback pollcb; - private IntPtr spoll; - - private Thread thread; - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_client_new (IntPtr poll, ClientFlags flags, ClientCallback handler, - IntPtr userData, out int error); - - [DllImport ("avahi-client")] - private static extern void avahi_client_free (IntPtr handle); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_client_get_version_string (IntPtr handle); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_client_get_host_name (IntPtr handle); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_client_get_domain_name (IntPtr handle); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_client_get_host_name_fqdn (IntPtr handle); - - [DllImport ("avahi-client")] - private static extern ClientState avahi_client_get_state (IntPtr handle); - - [DllImport ("avahi-client")] - private static extern int avahi_client_errno (IntPtr handle); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_simple_poll_new (); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_simple_poll_get (IntPtr spoll); - - [DllImport ("avahi-common")] - private static extern void avahi_simple_poll_free (IntPtr spoll); - - [DllImport ("avahi-common")] - private static extern int avahi_simple_poll_loop (IntPtr spoll); - - [DllImport ("avahi-common")] - private static extern void avahi_simple_poll_set_func (IntPtr spoll, PollCallback cb); - - [DllImport ("avahi-common")] - private static extern void avahi_simple_poll_quit (IntPtr spoll); - - [DllImport ("avahi-client")] - private static extern uint avahi_client_get_local_service_cookie (IntPtr client); - - [DllImport ("avahi-common")] - private static extern int avahi_service_name_join (IntPtr buf, int len, byte[] name, byte[] type, - byte[] domain); - - [DllImport ("avahi-common")] - private static extern int avahi_service_name_split (byte[] service, IntPtr name, int name_len, - IntPtr type, int type_len, - IntPtr domain, int domain_len); - - - [DllImport ("libc")] - private static extern int poll(IntPtr ufds, uint nfds, int timeout); - - public event ClientStateHandler StateChanged; - - internal IntPtr Handle - { - get { return handle; } - } - - public string Version - { - get { - lock (this) { - return Utility.PtrToString (avahi_client_get_version_string (handle)); - } - } - } - - public string HostName - { - get { - lock (this) { - return Utility.PtrToString (avahi_client_get_host_name (handle)); - } - } - } - - public string DomainName - { - get { - lock (this) { - return Utility.PtrToString (avahi_client_get_domain_name (handle)); - } - } - } - - public string HostNameFqdn - { - get { - lock (this) { - return Utility.PtrToString (avahi_client_get_host_name_fqdn (handle)); - } - } - } - - public ClientState State - { - get { - lock (this) { - return (ClientState) avahi_client_get_state (handle); - } - } - } - - public uint LocalServiceCookie - { - get { - lock (this) { - return avahi_client_get_local_service_cookie (handle); - } - } - } - - internal ErrorCode LastError - { - get { - lock (this) { - return (ErrorCode) avahi_client_errno (handle); - } - } - } - - public Client (ClientFlags flags) - { - spoll = avahi_simple_poll_new (); - - pollcb = OnPollCallback; - avahi_simple_poll_set_func (spoll, pollcb); - IntPtr poll = avahi_simple_poll_get (spoll); - cb = OnClientCallback; - - int error; - handle = avahi_client_new (poll, flags, cb, IntPtr.Zero, out error); - if (error != 0) - throw new ClientException (error); - - thread = new Thread (PollLoop); - thread.IsBackground = true; - thread.Start (); - } - - public Client () : this (ClientFlags.None) { - } - - ~Client () - { - Dispose (); - } - - public void Dispose () - { - if (handle != IntPtr.Zero) { - lock (this) { - avahi_client_free (handle); - handle = IntPtr.Zero; - - avahi_simple_poll_quit (spoll); - Monitor.Wait (this); - - avahi_simple_poll_free (spoll); - } - } - } - - public static string JoinServiceName (string name, string type, string domain) - { - int len = 4 * (name.Length + type.Length + domain.Length) + 4; - IntPtr buf = Stdlib.malloc ((ulong) len); - - int ret = avahi_service_name_join (buf, len, - Utility.StringToBytes (name), - Utility.StringToBytes (type), - Utility.StringToBytes (domain)); - - if (ret < 0) { - Utility.Free (buf); - return null; // FIXME, should throw exception - } - - string service = Utility.PtrToString (buf); - Utility.Free (buf); - - return service; - } - - public static void SplitServiceName (string service, out string name, out string type, out string domain) - { - int len = 1024; - - IntPtr namePtr = Stdlib.malloc ((ulong) len); - IntPtr typePtr = Stdlib.malloc ((ulong) len); - IntPtr domainPtr = Stdlib.malloc ((ulong) len); - - int ret = avahi_service_name_split (Utility.StringToBytes (service), namePtr, len, typePtr, len, - domainPtr, len); - - if (ret < 0) { - Utility.Free (namePtr); - Utility.Free (typePtr); - Utility.Free (domainPtr); - - name = null; - type = null; - domain = null; - return; - } - - name = Utility.PtrToString (namePtr); - type = Utility.PtrToString (typePtr); - domain = Utility.PtrToString (domainPtr); - - Utility.Free (namePtr); - Utility.Free (typePtr); - Utility.Free (domainPtr); - } - - internal void ThrowError () - { - ErrorCode error = LastError; - - if (error != ErrorCode.Ok) - throw new ClientException (error); - } - - private void OnClientCallback (IntPtr client, ClientState state, IntPtr userData) - { - if (StateChanged != null) - StateChanged (this, new ClientStateArgs (state, LastError)); - } - - private int OnPollCallback (IntPtr ufds, uint nfds, int timeout) { - Monitor.Exit (this); - int result = poll (ufds, nfds, timeout); - Monitor.Enter (this); - return result; - } - - private void PollLoop () { - try { - lock (this) { - avahi_simple_poll_loop (spoll); - Monitor.Pulse (this); - } - } catch (Exception e) { - Console.Error.WriteLine ("Error in avahi-sharp event loop: " + e); - } - } - } -} diff --git a/avahi-sharp/ClientException.cs b/avahi-sharp/ClientException.cs deleted file mode 100644 index 0f511ac..0000000 --- a/avahi-sharp/ClientException.cs +++ /dev/null @@ -1,123 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - - -using System; -using System.Runtime.InteropServices; - -namespace Avahi -{ - public enum ErrorCode { - Ok = 0, - Failure = -1, - BadState = -2, - InvalidHostName = - 3, - InvalidDomainName = -4, - NoNetwork = -5, - InvalidTTL = -6, - IsPattern = -7, - Collision = -8, - InvalidRecord = -9, - InvalidServiceName = -10, - InvalidServiceType = -11, - InvalidPort = -12, - InvalidKey = -13, - InvalidAddress = -14, - Timeout = -15, - TooManyClients = -16, - TooManyObjects = -17, - TooManyEntries = -18, - OS = -19, - AccessDenied = -20, - InvalidOperation = -21, - DBusError = -22, - Disconnected = -23, - NoMemory = -24, - InvalidObject = -25, - NoDaemon = -26, - InvalidInterface = -27, - InvalidProtocol = -28, - InvalidFlags = -29, - NotFound = -30, - InvalidConfig = -31, - VersionMismatch = -32, - InvalidServiceSubtype = -33, - InvalidPacket = -34, - InvalidDnsError = -35, - DnsFormErr = -36, - DnsServFail = -37, - DnsNxDomain = -38, - DnsNoTimp = -39, - DnsRefused = -40, - DnsYxDomain = -41, - DnsYxRrSet = -42, - DnsNxRrSet = -43, - DnsNotAuth = -44, - DnsNotZone = -45, - InvalidRData = -46, - InvalidDnsClass = -47, - InvalidDnsType = -48, - NotSupported = -49, - NotPermitted = -50 - } - - public delegate void ErrorCodeHandler (object o, ErrorCodeArgs args); - - public class ErrorCodeArgs : EventArgs - { - private ErrorCode code; - - public ErrorCode ErrorCode - { - get { return code; } - } - - public ErrorCodeArgs (ErrorCode code) - { - this.code = code; - } - } - - public class ClientException : ApplicationException - { - private ErrorCode code; - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_strerror (ErrorCode code); - - public ErrorCode ErrorCode - { - get { return code; } - } - - internal ClientException (int code) : this ((ErrorCode) code) { - } - - internal ClientException (ErrorCode code) : base (GetErrorString (code)) - { - this.code = code; - } - - private static string GetErrorString (ErrorCode code) - { - IntPtr str = avahi_strerror (code); - return Utility.PtrToString (str); - } - } -} diff --git a/avahi-sharp/DomainBrowser.cs b/avahi-sharp/DomainBrowser.cs deleted file mode 100644 index a1165dc..0000000 --- a/avahi-sharp/DomainBrowser.cs +++ /dev/null @@ -1,198 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Collections; -using System.Runtime.InteropServices; -using System.Text; - -namespace Avahi -{ - internal delegate void DomainBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr domain, LookupResultFlags flags, IntPtr userdata); - - public enum DomainBrowserType { - Browse, - BrowseDefault, - Register, - RegisterDefault, - BrowseLegacy - } - - public struct DomainInfo - { - public int NetworkInterface; - public Protocol Protocol; - public string Domain; - public LookupResultFlags Flags; - } - - public class DomainInfoArgs : EventArgs - { - private DomainInfo domain; - - public DomainInfo Domain - { - get { return domain; } - } - - public DomainInfoArgs (DomainInfo domain) - { - this.domain = domain; - } - } - - public delegate void DomainInfoHandler (object o, DomainInfoArgs args); - - public class DomainBrowser : BrowserBase, IDisposable - { - private IntPtr handle; - private ArrayList infos = new ArrayList (); - private Client client; - private int iface; - private Protocol proto; - private string domain; - private DomainBrowserType btype; - private LookupFlags flags; - private DomainBrowserCallback cb; - - private ArrayList addListeners = new ArrayList (); - private ArrayList removeListeners = new ArrayList (); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_domain_browser_new (IntPtr client, int iface, int proto, - byte[] domain, int btype, LookupFlags flags, - DomainBrowserCallback cb, - IntPtr userdata); - - [DllImport ("avahi-client")] - private static extern void avahi_domain_browser_free (IntPtr handle); - - public event DomainInfoHandler DomainAdded - { - add { - addListeners.Add (value); - Start (); - } - remove { - addListeners.Remove (value); - Stop (false); - } - } - - public event DomainInfoHandler DomainRemoved - { - add { - removeListeners.Add (value); - Start (); - } - remove { - removeListeners.Remove (value); - Stop (false); - } - } - - public DomainInfo[] Domains - { - get { return (DomainInfo[]) infos.ToArray (typeof (DomainInfo)); } - } - - public DomainBrowser (Client client) : this (client, -1, Protocol.Unspecified, client.DomainName, - DomainBrowserType.Browse, LookupFlags.None) { - } - - public DomainBrowser (Client client, int iface, Protocol proto, string domain, - DomainBrowserType btype, LookupFlags flags) - { - this.client = client; - this.iface = iface; - this.proto = proto; - this.domain = domain; - this.btype = btype; - this.flags = flags; - cb = OnDomainBrowserCallback; - } - - ~DomainBrowser () - { - Dispose (); - } - - public void Dispose () - { - Stop (true); - } - - private void Start () - { - if (client.Handle == IntPtr.Zero && handle != IntPtr.Zero || - (addListeners.Count == 0 && removeListeners.Count == 0)) - return; - - lock (client) { - handle = avahi_domain_browser_new (client.Handle, iface, (int) proto, - Utility.StringToBytes (domain), (int) btype, flags, - cb, IntPtr.Zero); - - if (handle == IntPtr.Zero) - client.ThrowError (); - } - } - - private void Stop (bool force) - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && - (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { - lock (client) { - avahi_domain_browser_free (handle); - handle = IntPtr.Zero; - } - } - } - - private void OnDomainBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr domain, LookupResultFlags flags, IntPtr userdata) - { - - DomainInfo info; - info.NetworkInterface = iface; - info.Protocol = proto; - info.Domain = Utility.PtrToString (domain); - info.Flags = flags; - - switch (bevent) { - case BrowserEvent.Added: - infos.Add (info); - - foreach (DomainInfoHandler handler in addListeners) - handler (this, new DomainInfoArgs (info)); - break; - case BrowserEvent.Removed: - infos.Remove (info); - - foreach (DomainInfoHandler handler in removeListeners) - handler (this, new DomainInfoArgs (info)); - break; - default: - EmitBrowserEvent (bevent); - break; - } - } - } -} diff --git a/avahi-sharp/EntryGroup.cs b/avahi-sharp/EntryGroup.cs deleted file mode 100644 index 24abae4..0000000 --- a/avahi-sharp/EntryGroup.cs +++ /dev/null @@ -1,376 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Net; -using System.Runtime.InteropServices; -using System.Text; -using Mono.Unix; - -namespace Avahi -{ - - [Flags] - public enum PublishFlags { - None = 0, - Unique = 1, - NoProbe = 2, - NoAnnounce = 4, - AllowMultiple = 8, - NoReverse = 16, - NoCookie = 32, - Update = 64, - UseWideArea = 128, - UseMulticast = 256 - } - - public enum EntryGroupState { - Uncommited, - Registering, - Established, - Collision, - Failure - } - - public class EntryGroupStateArgs : EventArgs - { - private EntryGroupState state; - - public EntryGroupState State - { - get { return state; } - } - - public EntryGroupStateArgs (EntryGroupState state) - { - this.state = state; - } - } - - internal delegate void EntryGroupCallback (IntPtr group, EntryGroupState state, IntPtr userdata); - public delegate void EntryGroupStateHandler (object o, EntryGroupStateArgs args); - - public class EntryGroup : IDisposable - { - private Client client; - private IntPtr handle; - private EntryGroupCallback cb; - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_entry_group_new (IntPtr client, EntryGroupCallback cb, IntPtr userdata); - - [DllImport ("avahi-client")] - private static extern int avahi_entry_group_commit (IntPtr group); - - [DllImport ("avahi-client")] - private static extern int avahi_entry_group_reset (IntPtr group); - - [DllImport ("avahi-client")] - private static extern EntryGroupState avahi_entry_group_get_state (IntPtr group); - - [DllImport ("avahi-client")] - private static extern bool avahi_entry_group_is_empty (IntPtr group); - - [DllImport ("avahi-client")] - private static extern int avahi_entry_group_add_service_strlst (IntPtr group, int iface, Protocol proto, - PublishFlags flags, byte[] name, byte[] type, - byte[] domain, byte[] host, UInt16 port, - IntPtr strlst); - - [DllImport ("avahi-client")] - private static extern int avahi_entry_group_update_service_strlst (IntPtr group, int iface, Protocol proto, - PublishFlags flags, byte[] name, - byte[] type, byte[] domain, IntPtr strlst); - - [DllImport ("avahi-client")] - private static extern int avahi_entry_group_add_service_subtype (IntPtr group, int iface, Protocol proto, - PublishFlags flags, byte[] name, byte[] type, - byte[] domain, byte[] subtype); - - [DllImport ("avahi-client")] - private static extern int avahi_entry_group_add_address (IntPtr group, int iface, Protocol proto, - PublishFlags flags, byte[] name, IntPtr address); - - - [DllImport ("avahi-client")] - private static extern int avahi_entry_group_add_record (IntPtr group, int iface, Protocol proto, - PublishFlags flags, byte[] name, RecordClass clazz, - RecordType type, uint ttl, byte[] rdata, int size); - - [DllImport ("avahi-client")] - private static extern void avahi_entry_group_free (IntPtr group); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_string_list_new (IntPtr txt); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_string_list_add (IntPtr list, byte[] txt); - - [DllImport ("avahi-common")] - private static extern void avahi_string_list_free (IntPtr list); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_alternative_service_name (byte[] name); - - public event EntryGroupStateHandler StateChanged; - - public EntryGroupState State - { - get { - lock (client) { - return avahi_entry_group_get_state (handle); - } - } - } - - public bool IsEmpty - { - get { - lock (client) { - return avahi_entry_group_is_empty (handle); - } - } - } - - public EntryGroup (Client client) - { - this.client = client; - cb = OnEntryGroupCallback; - - lock (client) { - handle = avahi_entry_group_new (client.Handle, cb, IntPtr.Zero); - if (handle == IntPtr.Zero) - client.ThrowError (); - } - } - - ~EntryGroup () - { - Dispose (); - } - - public void Dispose () - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero) { - lock (client) { - avahi_entry_group_free (handle); - handle = IntPtr.Zero; - } - } - } - - public void Commit () - { - lock (client) { - if (avahi_entry_group_commit (handle) < 0) - client.ThrowError (); - } - } - - public void Reset () - { - lock (client) { - if (avahi_entry_group_reset (handle) < 0) - client.ThrowError (); - } - } - - public void AddService (string name, string type, string domain, - UInt16 port, params string[] txt) - { - AddService (PublishFlags.None, name, type, domain, port, txt); - } - - public void AddService (PublishFlags flags, string name, string type, string domain, - UInt16 port, params string[] txt) - { - AddService (-1, Protocol.Unspecified, flags, name, type, domain, null, port, txt); - } - - public void AddService (int iface, Protocol proto, PublishFlags flags, string name, string type, string domain, - string host, UInt16 port, params string[] txt) - { - IntPtr list = avahi_string_list_new (IntPtr.Zero); - - if (txt != null) { - foreach (string item in txt) { - list = avahi_string_list_add (list, Utility.StringToBytes (item)); - } - } - - AddService (iface, proto, flags, name, type, domain, host, port, list); - } - - public void AddService (int iface, Protocol proto, PublishFlags flags, string name, string type, string domain, - string host, UInt16 port, params byte[][] txt) - { - IntPtr list = avahi_string_list_new (IntPtr.Zero); - - if (txt != null) { - foreach (byte[] item in txt) { - list = avahi_string_list_add (list, item); - } - } - - AddService (iface, proto, flags, name, type, domain, host, port, list); - } - - private void AddService (int iface, Protocol proto, PublishFlags flags, string name, string type, - string domain, string host, UInt16 port, IntPtr list) - { - int ret; - - lock (client) { - ret = avahi_entry_group_add_service_strlst (handle, iface, proto, flags, - Utility.StringToBytes (name), - Utility.StringToBytes (type), - Utility.StringToBytes (domain), - Utility.StringToBytes (host), port, list); - } - - avahi_string_list_free (list); - - if (ret < 0) { - client.ThrowError (); - } - } - - public void UpdateService (string name, string type, string domain, params string[] txt) - { - UpdateService (-1, Protocol.Unspecified, PublishFlags.None, name, type, domain, txt); - } - - public void UpdateService (int iface, Protocol proto, PublishFlags flags, string name, string type, - string domain, params string[] txt) - { - IntPtr list = avahi_string_list_new (IntPtr.Zero); - - if (txt != null) { - foreach (string item in txt) { - list = avahi_string_list_add (list, Utility.StringToBytes (item)); - } - } - - UpdateService (iface, proto, flags, name, type, domain, list); - } - - public void UpdateService (int iface, Protocol proto, PublishFlags flags, string name, string type, - string domain, params byte[][] txt) - { - IntPtr list = avahi_string_list_new (IntPtr.Zero); - - if (txt != null) { - foreach (byte[] item in txt) { - list = avahi_string_list_add (list, item); - } - } - - UpdateService (iface, proto, flags, name, type, domain, list); - } - - private void UpdateService (int iface, Protocol proto, PublishFlags flags, string name, string type, - string domain, IntPtr list) - { - lock (client) { - int ret = avahi_entry_group_update_service_strlst (handle, iface, proto, flags, - Utility.StringToBytes (name), - Utility.StringToBytes (type), - Utility.StringToBytes (domain), - list); - - avahi_string_list_free (list); - - if (ret < 0) { - client.ThrowError (); - } - } - } - - public void AddServiceSubtype (string name, string type, string domain, string subtype) - { - AddServiceSubtype (-1, Protocol.Unspecified, PublishFlags.None, name, type, domain, subtype); - } - - public void AddServiceSubtype (int iface, Protocol proto, PublishFlags flags, string name, - string type, string domain, string subtype) - { - lock (client) { - int ret = avahi_entry_group_add_service_subtype (handle, iface, proto, flags, - Utility.StringToBytes (name), - Utility.StringToBytes (type), - Utility.StringToBytes (domain), - Utility.StringToBytes (subtype)); - - if (ret < 0) { - client.ThrowError (); - } - } - } - - public void AddAddress (string name, IPAddress address) - { - AddAddress (-1, Protocol.Unspecified, PublishFlags.None, name, address); - } - - public void AddAddress (int iface, Protocol proto, PublishFlags flags, string name, IPAddress address) - { - IntPtr addressPtr = Utility.AddressToPtr (address); - - lock (client) { - int ret = avahi_entry_group_add_address (handle, iface, proto, flags, - Utility.StringToBytes (name), addressPtr); - - Utility.Free (addressPtr); - - if (ret < 0) { - client.ThrowError (); - } - } - } - - public void AddRecord (string name, RecordClass clazz, RecordType type, uint ttl, byte[] rdata, int length) - { - AddRecord (-1, Protocol.Unspecified, PublishFlags.None, name, clazz, type, ttl, rdata, length); - } - - public void AddRecord (int iface, Protocol proto, PublishFlags flags, string name, - RecordClass clazz, RecordType type, uint ttl, byte[] rdata, int length) - { - lock (client) { - int ret = avahi_entry_group_add_record (handle, iface, proto, flags, - Utility.StringToBytes (name), - clazz, type, ttl, rdata, length); - - if (ret < 0) { - client.ThrowError (); - } - } - } - - public static string GetAlternativeServiceName (string name) { - return Utility.PtrToStringFree (avahi_alternative_service_name (Utility.StringToBytes (name))); - } - - private void OnEntryGroupCallback (IntPtr group, EntryGroupState state, IntPtr userdata) - { - if (StateChanged != null) - StateChanged (this, new EntryGroupStateArgs (state)); - } - } -} diff --git a/avahi-sharp/HostNameResolver.cs b/avahi-sharp/HostNameResolver.cs deleted file mode 100644 index b9fe7f4..0000000 --- a/avahi-sharp/HostNameResolver.cs +++ /dev/null @@ -1,167 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Collections; -using System.Net; -using System.Runtime.InteropServices; -using System.Text; -using Mono.Unix; - -namespace Avahi -{ - - internal delegate void HostNameResolverCallback (IntPtr resolver, int iface, Protocol proto, - ResolverEvent revent, IntPtr hostname, IntPtr address, - LookupResultFlags flags, IntPtr userdata); - - public class HostNameResolver : ResolverBase, IDisposable - { - private IntPtr handle; - private Client client; - private int iface; - private Protocol proto; - private string hostname; - private Protocol aproto; - private LookupFlags flags; - private HostNameResolverCallback cb; - - private IPAddress currentAddress; - private string currentHost; - - private ArrayList foundListeners = new ArrayList (); - private ArrayList timeoutListeners = new ArrayList (); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_host_name_resolver_new (IntPtr client, int iface, Protocol proto, - byte[] hostname, Protocol aproto, LookupFlags flags, - HostNameResolverCallback cb, IntPtr userdata); - - [DllImport ("avahi-client")] - private static extern void avahi_host_name_resolver_free (IntPtr handle); - - public event HostAddressHandler Found - { - add { - foundListeners.Add (value); - Start (); - } - remove { - foundListeners.Remove (value); - Stop (false); - } - } - - public event EventHandler Timeout - { - add { - timeoutListeners.Add (value); - Start (); - } - remove { - timeoutListeners.Remove (value); - Stop (false); - } - } - - public IPAddress Address - { - get { return currentAddress; } - } - - public string HostName - { - get { return currentHost; } - } - - public HostNameResolver (Client client, string hostname) : this (client, -1, Protocol.Unspecified, - hostname, Protocol.Unspecified, - LookupFlags.None) - { - } - - public HostNameResolver (Client client, int iface, Protocol proto, string hostname, - Protocol aproto, LookupFlags flags) - { - this.client = client; - this.iface = iface; - this.proto = proto; - this.hostname = hostname; - this.aproto = aproto; - this.flags = flags; - cb = OnHostNameResolverCallback; - } - - ~HostNameResolver () - { - Dispose (); - } - - public void Dispose () - { - Stop (true); - } - - private void Start () - { - if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || - (foundListeners.Count == 0 && timeoutListeners.Count == 0)) - return; - - lock (client) { - handle = avahi_host_name_resolver_new (client.Handle, iface, proto, - Utility.StringToBytes (hostname), aproto, flags, - cb, IntPtr.Zero); - - if (handle == IntPtr.Zero) - client.ThrowError (); - } - } - - private void Stop (bool force) - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && - (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) { - - lock (client) { - avahi_host_name_resolver_free (handle); - handle = IntPtr.Zero; - } - } - } - - private void OnHostNameResolverCallback (IntPtr resolver, int iface, Protocol proto, - ResolverEvent revent, IntPtr hostname, IntPtr address, - LookupResultFlags flags, IntPtr userdata) - { - switch (revent) { - case ResolverEvent.Found: - currentAddress = Utility.PtrToAddress (address); - currentHost = Utility.PtrToString (hostname); - - foreach (HostAddressHandler handler in foundListeners) - handler (this, new HostAddressArgs (currentHost, currentAddress)); - break; - case ResolverEvent.Failure: - EmitFailure (client.LastError); - break; - } - } - } -} diff --git a/avahi-sharp/Makefile.am b/avahi-sharp/Makefile.am deleted file mode 100644 index 1fdb1ca..0000000 --- a/avahi-sharp/Makefile.am +++ /dev/null @@ -1,82 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -ASSEMBLY = avahi-sharp.dll - -CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(ASSEMBLY).config - -AVAHISOURCES = \ - $(srcdir)/AddressResolver.cs \ - $(srcdir)/AssemblyInfo.cs \ - $(srcdir)/BrowserBase.cs \ - $(srcdir)/Client.cs \ - $(srcdir)/ClientException.cs \ - $(srcdir)/DomainBrowser.cs \ - $(srcdir)/EntryGroup.cs \ - $(srcdir)/HostNameResolver.cs \ - $(srcdir)/RecordBrowser.cs \ - $(srcdir)/ResolverBase.cs \ - $(srcdir)/ServiceBrowser.cs \ - $(srcdir)/ServiceResolver.cs \ - $(srcdir)/ServiceTypeBrowser.cs \ - $(srcdir)/Utility.cs - -EXTRA_DIST = \ - $(AVAHISOURCES) \ - $(srcdir)/AvahiTest.cs \ - $(srcdir)/avahi.snk \ - $(srcdir)/$(ASSEMBLY).config.in \ - $(srcdir)/avahi-sharp-docs.source \ - $(srcdir)/en/*.xml \ - $(srcdir)/en/*/*.xml \ - $(srcdir)/gencfg.sh - -$(ASSEMBLY): $(AVAHISOURCES) - $(AM_V_GEN)MONO_SHARED_DIR=. mcs -keyfile:$(srcdir)/avahi.snk -target:library -out:$@ -debug $(AVAHISOURCES) -r:Mono.Posix - - -$(ASSEMBLY).config: $(ASSEMBLY).config.in - $(AM_V_GEN)$(srcdir)/gencfg.sh $(top_builddir)/avahi-client/libavahi-client.la \ - $(top_builddir)/avahi-common/libavahi-common.la \ - $(top_builddir)/avahi-glib/libavahi-glib.la < $< > $@ - -if HAVE_MONO -if HAVE_DBUS -all: $(ASSEMBLY) $(ASSEMBLY).config - -if HAVE_MONODOC -update-docs: $(ASSEMBLY) - $(AM_V_GEN)$(MONODOCER) -assembly:$(ASSEMBLY) -path:en - -avahi-sharp-docs.zip: avahi-sharp-docs.tree - -avahi-sharp-docs.tree: $(srcdir)/en/*/* - $(AM_V_GEN)$(MDASSEMBLER) --out avahi-sharp-docs --ecma $(srcdir)/en - -monodocdir = $(MONODOC_DIR) -monodoc_DATA = avahi-sharp-docs.zip avahi-sharp-docs.tree avahi-sharp-docs.source - -endif - -install-data-hook: $(ASSEMBLY) - $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /i $(ASSEMBLY) /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) - -uninstall-hook: $(ASSEMBLY) - $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /u avahi-sharp /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) - -endif -endif diff --git a/avahi-sharp/RecordBrowser.cs b/avahi-sharp/RecordBrowser.cs deleted file mode 100644 index ba5a983..0000000 --- a/avahi-sharp/RecordBrowser.cs +++ /dev/null @@ -1,225 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Net; -using System.Collections; -using System.Runtime.InteropServices; -using System.Text; - -namespace Avahi -{ - - public delegate void RecordInfoHandler (object o, RecordInfoArgs args); - - internal delegate void RecordBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr name, ushort clazz, ushort type, IntPtr rdata, int size, - LookupResultFlags flags, IntPtr userdata); - - public enum RecordClass { - In = 1 - } - - public enum RecordType { - A = 1, - Ns = 2, - Cname = 5, - Soa = 6, - Ptr = 12, - Hinfo = 13, - Mx = 15, - Txt = 16, - Aaa = 28, - Srv = 33 - } - - public struct RecordInfo - { - public int NetworkInterface; - public Protocol Protocol; - public string Name; - public RecordClass Class; - public RecordType Type; - public byte[] Data; - public LookupResultFlags Flags; - } - - public class RecordInfoArgs : EventArgs - { - private RecordInfo record; - - public RecordInfo Record { - get { return record; } - } - - public RecordInfoArgs (RecordInfo record) - { - this.record = record; - } - } - - public class RecordBrowser : BrowserBase, IDisposable - { - private IntPtr handle; - private ArrayList infos = new ArrayList (); - private Client client; - private int iface; - private Protocol proto; - private string name; - private RecordClass clazz; - private RecordType type; - private LookupFlags flags; - private RecordBrowserCallback cb; - - private ArrayList addListeners = new ArrayList (); - private ArrayList removeListeners = new ArrayList (); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_record_browser_new (IntPtr client, int iface, Protocol proto, - byte[] name, ushort clazz, ushort type, - LookupFlags flags, RecordBrowserCallback cb, - IntPtr userdata); - - - [DllImport ("avahi-client")] - private static extern void avahi_record_browser_free (IntPtr handle); - - public event RecordInfoHandler RecordAdded - { - add { - addListeners.Add (value); - Start (); - } - remove { - addListeners.Remove (value); - Stop (false); - } - } - - public event RecordInfoHandler RecordRemoved - { - add { - removeListeners.Add (value); - Start (); - } - remove { - removeListeners.Remove (value); - Stop (false); - } - } - - public RecordInfo[] Records - { - get { return (RecordInfo[]) infos.ToArray (typeof (RecordInfo)); } - } - - public RecordBrowser (Client client, string name, RecordType type) : - this (client, -1, Protocol.Unspecified, name, RecordClass.In, type, LookupFlags.None) - { - } - - public RecordBrowser (Client client, int iface, Protocol proto, string name, RecordClass clazz, - RecordType type, LookupFlags flags) - { - this.client = client; - this.iface = iface; - this.proto = proto; - this.name = name; - this.clazz = clazz; - this.type = type; - this.flags = flags; - cb = OnRecordBrowserCallback; - } - - ~RecordBrowser () - { - Dispose (); - } - - public void Dispose () - { - Stop (true); - } - - private void Start () - { - if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || - (addListeners.Count == 0 && removeListeners.Count == 0)) - return; - - lock (client) { - handle = avahi_record_browser_new (client.Handle, iface, proto, Utility.StringToBytes (name), - (ushort) clazz, (ushort) type, flags, cb, IntPtr.Zero); - - if (handle == IntPtr.Zero) - client.ThrowError (); - } - } - - private void Stop (bool force) - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && - (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { - - lock (client) { - avahi_record_browser_free (handle); - handle = IntPtr.Zero; - } - } - } - - private void OnRecordBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr name, ushort clazz, ushort type, IntPtr rdata, int size, - LookupResultFlags flags, IntPtr userdata) - { - RecordInfo info; - info.NetworkInterface = iface; - info.Protocol = proto; - info.Name = Utility.PtrToString (name); - info.Class = (RecordClass) clazz; - info.Type = (RecordType) type; - info.Flags = flags; - info.Data = new byte[size]; - - if (rdata != IntPtr.Zero) { - Marshal.Copy (rdata, info.Data, 0, size); - } - - switch (bevent) { - case BrowserEvent.Added: - infos.Add (info); - - foreach (RecordInfoHandler handler in addListeners) - handler (this, new RecordInfoArgs (info)); - - break; - case BrowserEvent.Removed: - infos.Remove (info); - - foreach (RecordInfoHandler handler in removeListeners) - handler (this, new RecordInfoArgs (info)); - - break; - default: - EmitBrowserEvent (bevent); - break; - } - } - } -} diff --git a/avahi-sharp/ResolverBase.cs b/avahi-sharp/ResolverBase.cs deleted file mode 100644 index d546aba..0000000 --- a/avahi-sharp/ResolverBase.cs +++ /dev/null @@ -1,34 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; - -namespace Avahi -{ - public abstract class ResolverBase - { - public event ErrorCodeHandler Failed; - - internal void EmitFailure (ErrorCode code) - { - if (Failed != null) - Failed (this, new ErrorCodeArgs (code)); - } - } -} diff --git a/avahi-sharp/ServiceBrowser.cs b/avahi-sharp/ServiceBrowser.cs deleted file mode 100644 index 5c39ad4..0000000 --- a/avahi-sharp/ServiceBrowser.cs +++ /dev/null @@ -1,214 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Net; -using System.Collections; -using System.Runtime.InteropServices; -using System.Text; - -namespace Avahi -{ - internal delegate void ServiceBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr name, IntPtr type, IntPtr domain, LookupResultFlags flags, - IntPtr userdata); - - public struct ServiceInfo - { - public int NetworkInterface; - public Protocol Protocol; - public string Domain; - public string ServiceType; - public string Name; - - public string HostName; - public IPAddress Address; - public UInt16 Port; - public byte[][] Text; - public LookupResultFlags Flags; - - public static ServiceInfo Zero = new ServiceInfo (); - } - - public class ServiceInfoArgs : EventArgs - { - private ServiceInfo service; - - public ServiceInfo Service { - get { return service; } - } - - public ServiceInfoArgs (ServiceInfo service) - { - this.service = service; - } - } - - public delegate void ServiceInfoHandler (object o, ServiceInfoArgs args); - - public class ServiceBrowser : BrowserBase, IDisposable - { - private IntPtr handle; - private ArrayList infos = new ArrayList (); - private Client client; - private int iface; - private Protocol proto; - private string domain; - private string type; - private LookupFlags flags; - private ServiceBrowserCallback cb; - - private ArrayList addListeners = new ArrayList (); - private ArrayList removeListeners = new ArrayList (); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_service_browser_new (IntPtr client, int iface, int proto, byte[] type, - byte[] domain, LookupFlags flags, - ServiceBrowserCallback cb, - IntPtr userdata); - - [DllImport ("avahi-client")] - private static extern void avahi_service_browser_free (IntPtr handle); - - public event ServiceInfoHandler ServiceAdded - { - add { - addListeners.Add (value); - Start (); - } - remove { - addListeners.Remove (value); - Stop (false); - } - } - - public event ServiceInfoHandler ServiceRemoved - { - add { - removeListeners.Add (value); - Start (); - } - remove { - removeListeners.Remove (value); - Stop (false); - } - } - - public ServiceInfo[] Services - { - get { return (ServiceInfo[]) infos.ToArray (typeof (ServiceInfo)); } - } - - public ServiceBrowser (Client client, string type) : this (client, type, client.DomainName) - { - } - - public ServiceBrowser (Client client, string type, string domain) : this (client, -1, Protocol.Unspecified, - type, domain, LookupFlags.None) - { - } - - public ServiceBrowser (Client client, int iface, Protocol proto, string type, string domain, LookupFlags flags) - { - this.client = client; - this.iface = iface; - this.proto = proto; - this.domain = domain; - this.type = type; - this.flags = flags; - cb = OnServiceBrowserCallback; - } - - ~ServiceBrowser () - { - Dispose (); - } - - public void Dispose () - { - Stop (true); - } - - private void Start () - { - if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || - (addListeners.Count == 0 && removeListeners.Count == 0)) - return; - - lock (client) { - handle = avahi_service_browser_new (client.Handle, iface, (int) proto, - Utility.StringToBytes (type), Utility.StringToBytes (domain), - flags, cb, IntPtr.Zero); - - if (handle == IntPtr.Zero) - client.ThrowError (); - } - } - - private void Stop (bool force) - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && - (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { - - lock (client) { - avahi_service_browser_free (handle); - handle = IntPtr.Zero; - } - } - } - - private void OnServiceBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr name, IntPtr type, IntPtr domain, LookupResultFlags flags, - IntPtr userdata) - { - - ServiceInfo info; - info.NetworkInterface = iface; - info.Protocol = proto; - info.Domain = Utility.PtrToString (domain); - info.ServiceType = Utility.PtrToString (type); - info.Name = Utility.PtrToString (name); - info.HostName = null; - info.Address = null; - info.Port = 0; - info.Text = null; - info.Flags = flags; - - switch (bevent) { - case BrowserEvent.Added: - infos.Add (info); - - foreach (ServiceInfoHandler handler in addListeners) - handler (this, new ServiceInfoArgs (info)); - - break; - case BrowserEvent.Removed: - infos.Remove (info); - - foreach (ServiceInfoHandler handler in removeListeners) - handler (this, new ServiceInfoArgs (info)); - - break; - default: - EmitBrowserEvent (bevent); - break; - } - } - } -} diff --git a/avahi-sharp/ServiceResolver.cs b/avahi-sharp/ServiceResolver.cs deleted file mode 100644 index 7f8901a..0000000 --- a/avahi-sharp/ServiceResolver.cs +++ /dev/null @@ -1,225 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Collections; -using System.Net; -using System.Runtime.InteropServices; -using System.Text; -using Mono.Unix; - -namespace Avahi -{ - - internal delegate void ServiceResolverCallback (IntPtr resolver, int iface, Protocol proto, - ResolverEvent revent, IntPtr name, IntPtr type, - IntPtr domain, IntPtr host, IntPtr address, - UInt16 port, IntPtr txt, LookupResultFlags flags, - IntPtr userdata); - - public class ServiceResolver : ResolverBase, IDisposable - { - private IntPtr handle; - private ServiceInfo currentInfo; - private Client client; - private int iface; - private Protocol proto; - private string name; - private string type; - private string domain; - private Protocol aproto; - private LookupFlags flags; - private ServiceResolverCallback cb; - - private ArrayList foundListeners = new ArrayList (); - private ArrayList timeoutListeners = new ArrayList (); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_service_resolver_new (IntPtr client, int iface, Protocol proto, - byte[] name, byte[] type, byte[] domain, - Protocol aproto, LookupFlags flags, - ServiceResolverCallback cb, - IntPtr userdata); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_string_list_get_next (IntPtr list); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_string_list_get_text (IntPtr list); - - [DllImport ("avahi-common")] - private static extern int avahi_string_list_get_size (IntPtr list); - - [DllImport ("avahi-client")] - private static extern void avahi_service_resolver_free (IntPtr handle); - - public event ServiceInfoHandler Found - { - add { - foundListeners.Add (value); - Start (); - } - remove { - foundListeners.Remove (value); - Stop (false); - } - } - - public event EventHandler Timeout - { - add { - timeoutListeners.Add (value); - Start (); - } - remove { - timeoutListeners.Remove (value); - Stop (false); - } - } - - public ServiceInfo Service - { - get { return currentInfo; } - } - - public ServiceResolver (Client client, string name, string type, string domain) : this (client, -1, - Protocol.Unspecified, - name, type, domain, - Protocol.Unspecified, - LookupFlags.None) - { - } - - public ServiceResolver (Client client, ServiceInfo service) : this (client, service.NetworkInterface, - service.Protocol, service.Name, - service.ServiceType, service.Domain, - Protocol.Unspecified, - GetLookupFlags (service.Flags)) - { - } - - public ServiceResolver (Client client, int iface, Protocol proto, string name, - string type, string domain, Protocol aproto, LookupFlags flags) - { - this.client = client; - this.iface = iface; - this.proto = proto; - this.name = name; - this.type = type; - this.domain = domain; - this.aproto = aproto; - this.flags = flags; - cb = OnServiceResolverCallback; - } - - ~ServiceResolver () - { - Dispose (); - } - - public void Dispose () - { - Stop (true); - } - - private void Start () - { - if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || - (foundListeners.Count == 0 && timeoutListeners.Count == 0)) - return; - - lock (client) { - handle = avahi_service_resolver_new (client.Handle, iface, proto, - Utility.StringToBytes (name), Utility.StringToBytes (type), - Utility.StringToBytes (domain), aproto, flags, cb, IntPtr.Zero); - - if (handle == IntPtr.Zero) - client.ThrowError (); - } - } - - private void Stop (bool force) - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && - (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) { - - lock (client) { - avahi_service_resolver_free (handle); - handle = IntPtr.Zero; - } - } - } - - private void OnServiceResolverCallback (IntPtr resolver, int iface, Protocol proto, - ResolverEvent revent, IntPtr name, IntPtr type, - IntPtr domain, IntPtr host, IntPtr address, - UInt16 port, IntPtr txt, LookupResultFlags flags, - IntPtr userdata) - { - ServiceInfo info; - info.NetworkInterface = iface; - info.Protocol = proto; - info.Domain = Utility.PtrToString (domain); - info.ServiceType = Utility.PtrToString (type); - info.Name = Utility.PtrToString (name); - info.HostName = Utility.PtrToString (host); - info.Address = Utility.PtrToAddress (address); - info.Port = port; - - if (proto == Protocol.IPv6) - info.Address.ScopeId = iface; - - ArrayList txtlist = new ArrayList (); - for (IntPtr l = txt; l != IntPtr.Zero; l = avahi_string_list_get_next (l)) { - IntPtr buf = avahi_string_list_get_text (l); - int len = avahi_string_list_get_size (l); - - byte[] txtbuf = new byte[len]; - Marshal.Copy (buf, txtbuf, 0, len); - txtlist.Add (txtbuf); - } - - info.Text = (byte[][]) txtlist.ToArray (typeof (byte[])); - info.Flags = flags; - - switch (revent) { - case ResolverEvent.Found: - currentInfo = info; - - foreach (ServiceInfoHandler handler in foundListeners) - handler (this, new ServiceInfoArgs (info)); - break; - case ResolverEvent.Failure: - EmitFailure (client.LastError); - break; - } - } - - private static LookupFlags GetLookupFlags (LookupResultFlags rflags) { - LookupFlags ret = LookupFlags.None; - - if ((rflags & LookupResultFlags.Multicast) > 0) - ret |= LookupFlags.UseMulticast; - if ((rflags & LookupResultFlags.WideArea) > 0) - ret |= LookupFlags.UseWideArea; - - return ret; - } - } -} diff --git a/avahi-sharp/ServiceTypeBrowser.cs b/avahi-sharp/ServiceTypeBrowser.cs deleted file mode 100644 index e1356d0..0000000 --- a/avahi-sharp/ServiceTypeBrowser.cs +++ /dev/null @@ -1,197 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Collections; -using System.Runtime.InteropServices; -using System.Text; - -namespace Avahi -{ - internal delegate void ServiceTypeBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr type, IntPtr domain, LookupResultFlags flags, - IntPtr userdata); - - public struct ServiceTypeInfo - { - public int NetworkInterface; - public Protocol Protocol; - public string Domain; - public string ServiceType; - public LookupResultFlags Flags; - } - - public class ServiceTypeInfoArgs : EventArgs - { - private ServiceTypeInfo type; - - public ServiceTypeInfo ServiceType - { - get { return type; } - } - - public ServiceTypeInfoArgs (ServiceTypeInfo type) - { - this.type = type; - } - } - - public delegate void ServiceTypeInfoHandler (object o, ServiceTypeInfoArgs args); - - public class ServiceTypeBrowser : BrowserBase, IDisposable - { - private IntPtr handle; - private ArrayList infos = new ArrayList (); - private Client client; - private int iface; - private Protocol proto; - private string domain; - private LookupFlags flags; - private ServiceTypeBrowserCallback cb; - - private ArrayList addListeners = new ArrayList (); - private ArrayList removeListeners = new ArrayList (); - - [DllImport ("avahi-client")] - private static extern IntPtr avahi_service_type_browser_new (IntPtr client, int iface, int proto, - byte[] domain, LookupFlags flags, - ServiceTypeBrowserCallback cb, - IntPtr userdata); - - [DllImport ("avahi-client")] - private static extern void avahi_service_type_browser_free (IntPtr handle); - - public event ServiceTypeInfoHandler ServiceTypeAdded - { - add { - addListeners.Add (value); - Start (); - } - remove { - addListeners.Remove (value); - Stop (false); - } - } - - public event ServiceTypeInfoHandler ServiceTypeRemoved - { - add { - removeListeners.Add (value); - Start (); - } - remove { - removeListeners.Remove (value); - Stop (false); - } - } - - public ServiceTypeInfo[] ServiceTypes - { - get { return (ServiceTypeInfo[]) infos.ToArray (typeof (ServiceTypeInfo)); } - } - - public ServiceTypeBrowser (Client client) : this (client, client.DomainName) - { - } - - public ServiceTypeBrowser (Client client, string domain) : this (client, -1, Protocol.Unspecified, - domain, LookupFlags.None) - { - } - - public ServiceTypeBrowser (Client client, int iface, Protocol proto, string domain, LookupFlags flags) - { - this.client = client; - this.iface = iface; - this.proto = proto; - this.domain = domain; - this.flags = flags; - cb = OnServiceTypeBrowserCallback; - } - - ~ServiceTypeBrowser () - { - Dispose (); - } - - public void Dispose () - { - Stop (true); - } - - private void Start () - { - if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || - (addListeners.Count == 0 && removeListeners.Count == 0)) - return; - - lock (client) { - handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, - Utility.StringToBytes (domain), flags, - cb, IntPtr.Zero); - - if (handle == IntPtr.Zero) - client.ThrowError (); - } - } - - private void Stop (bool force) - { - if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && - (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { - - lock (client) { - avahi_service_type_browser_free (handle); - handle = IntPtr.Zero; - } - } - } - - private void OnServiceTypeBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, - IntPtr type, IntPtr domain, LookupResultFlags flags, - IntPtr userdata) - { - - ServiceTypeInfo info; - info.NetworkInterface = iface; - info.Protocol = proto; - info.Domain = Utility.PtrToString (domain); - info.ServiceType = Utility.PtrToString (type); - info.Flags = flags; - - switch (bevent) { - case BrowserEvent.Added: - infos.Add (info); - - foreach (ServiceTypeInfoHandler handler in addListeners) - handler (this, new ServiceTypeInfoArgs (info)); - break; - case BrowserEvent.Removed: - infos.Remove (info); - - foreach (ServiceTypeInfoHandler handler in removeListeners) - handler (this, new ServiceTypeInfoArgs (info)); - break; - default: - EmitBrowserEvent (bevent); - break; - } - } - } -} diff --git a/avahi-sharp/Utility.cs b/avahi-sharp/Utility.cs deleted file mode 100644 index a1d0a66..0000000 --- a/avahi-sharp/Utility.cs +++ /dev/null @@ -1,112 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -using System; -using System.Net; -using System.Text; -using System.Runtime.InteropServices; -using Mono.Unix; -using Mono.Unix.Native; - -using Stdlib = Mono.Unix.Native.Stdlib; - -namespace Avahi -{ - internal class Utility - { - [DllImport ("libc")] - private static extern int strlen (IntPtr ptr); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_address_snprint (IntPtr buf, int size, IntPtr address); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_address_parse (IntPtr str, Protocol proto, IntPtr ret); - - public static string PtrToString (IntPtr ptr) - { - if (ptr == IntPtr.Zero) - return null; - - int len = strlen (ptr); - byte[] bytes = new byte[len]; - Marshal.Copy (ptr, bytes, 0, len); - return Encoding.UTF8.GetString (bytes); - } - - public static string PtrToStringFree (IntPtr ptr) - { - if (ptr == IntPtr.Zero) - return null; - - string ret = PtrToString (ptr); - Free (ptr); - return ret; - } - - public static byte[] StringToBytes (string str) - { - if (str == null) - return null; - - return Encoding.UTF8.GetBytes (str + "\0"); // lame. - } - - private static IntPtr StringToPtr (string str) - { - if (str == null) - return IntPtr.Zero; - - byte[] bytes = Utility.StringToBytes (str); - IntPtr buf = Stdlib.malloc ((uint) bytes.Length + 1); - Marshal.Copy (bytes, 0, buf, bytes.Length); - Marshal.WriteByte (buf, bytes.Length, 0); - return buf; - } - - public static void Free (IntPtr ptr) - { - Stdlib.free (ptr); - } - - public static IntPtr AddressToPtr (IPAddress address) - { - IntPtr straddr = Utility.StringToPtr (address.ToString ()); - IntPtr addrPtr = Stdlib.malloc (32); - avahi_address_parse (straddr, Protocol.Unspecified, addrPtr); - Utility.Free (straddr); - - return addrPtr; - } - - public static IPAddress PtrToAddress (IntPtr ptr) - { - IPAddress address = null; - - if (ptr != IntPtr.Zero) { - IntPtr buf = Stdlib.malloc (256); - IntPtr addrPtr = avahi_address_snprint (buf, 256, ptr); - address = IPAddress.Parse (Utility.PtrToString (addrPtr)); - Utility.Free (addrPtr); - } - - return address; - } - } -} diff --git a/avahi-sharp/avahi-sharp-docs.source b/avahi-sharp/avahi-sharp-docs.source deleted file mode 100644 index f3b3c75..0000000 --- a/avahi-sharp/avahi-sharp-docs.source +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/avahi-sharp/avahi-sharp.dll.config.in b/avahi-sharp/avahi-sharp.dll.config.in deleted file mode 100644 index 5bae58f..0000000 --- a/avahi-sharp/avahi-sharp.dll.config.in +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/avahi-sharp/avahi.snk b/avahi-sharp/avahi.snk deleted file mode 100644 index 58c23bc59c070f2383770a03e7c80f8e202fe28d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONaL0001mSbmk7t=Uq!&;=4;8@7>A53M2XD-b!E z-Xf0`WJiB0dD81T)g=NpnBw9k%q&vQv@bmngx+49x_2yH)jA#kAP@_7-|oyoRuzh=WHc%;s85h`;Zw26@~S?;xxJ-X z@NAy427?zXFFUQ6sJcg8W4XhZCk*xalO#7M)NZo}f9`MrbGgJzWT^dl#-T0ZK^;ID z;r-Q`+;+uw2?4wf#6lxOSz6u7CVMUb)Q~AU7Z@YzC%By9A!Pg zm>`c$7B?Za1FsC)cOudh?};nung~GJ=Z4jI*90qHnM*ezE{H^koNtZ->kTO$ZhXER zs|C#KRBKiGCraMJtxfsF#v(+@Bl|~y;qZI?0{zRlC(1NwsXIJzp-5z5HX1dCGws&S z6;Xt(fbkIIx(|bDJ%ogG+p~@a3q?(DUU|!Ah_YL3QT-{Q6@==+BkpYbk6Le5-gTLAK&56U4=n1@r))S$4ZtP~?seDI7r_{N-`qa+Ie^0u!X@nCs#dqm1xRT4%m i?XsWBdx&guurKP?LrJP9FxYl{jJ-zFscr^=AbyB%9~8U* diff --git a/avahi-sharp/en/Avahi.xml b/avahi-sharp/en/Avahi.xml deleted file mode 100644 index 0739013..0000000 --- a/avahi-sharp/en/Avahi.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/AddressResolver.xml b/avahi-sharp/en/Avahi/AddressResolver.xml deleted file mode 100644 index 064e505..0000000 --- a/avahi-sharp/en/Avahi/AddressResolver.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - Avahi.ResolverBase - - - - System.IDisposable - - - - - - Constructor - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Event - - Avahi.HostAddressHandler - - - To be added. - To be added. - - - - - Event - - System.EventHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - System.Net.IPAddress - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/BrowserBase.xml b/avahi-sharp/en/Avahi/BrowserBase.xml deleted file mode 100644 index fa6d2ad..0000000 --- a/avahi-sharp/en/Avahi/BrowserBase.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Object - - - - - - Constructor - - - To be added. - To be added. - - - - - Event - - System.EventHandler - - - To be added. - To be added. - - - - - Event - - System.EventHandler - - - To be added. - To be added. - - - - - Event - - System.EventHandler - - - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/Client.xml b/avahi-sharp/en/Avahi/Client.xml deleted file mode 100644 index 0abecf7..0000000 --- a/avahi-sharp/en/Avahi/Client.xml +++ /dev/null @@ -1,178 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Object - - - - System.IDisposable - - - - - - Constructor - - - To be added. - To be added. - - - - - Event - - Avahi.ClientStateHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.ClientState - - - To be added. - To be added. - To be added. - - - - - Property - - System.UInt32 - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Method - - System.String - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ClientException.xml b/avahi-sharp/en/Avahi/ClientException.xml deleted file mode 100644 index 3b8319b..0000000 --- a/avahi-sharp/en/Avahi/ClientException.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.ApplicationException - - - - - - Property - - Avahi.ErrorCode - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ClientFlags.xml b/avahi-sharp/en/Avahi/ClientFlags.xml deleted file mode 100644 index d4ea291..0000000 --- a/avahi-sharp/en/Avahi/ClientFlags.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - System.Flags - - - - - - Field - - Avahi.ClientFlags - - - To be added. - - - - - Field - - Avahi.ClientFlags - - - To be added. - - - - - Field - - Avahi.ClientFlags - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ClientState.xml b/avahi-sharp/en/Avahi/ClientState.xml deleted file mode 100644 index c20a02b..0000000 --- a/avahi-sharp/en/Avahi/ClientState.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - - Field - - Avahi.ClientState - - - To be added. - - - - - Field - - Avahi.ClientState - - - To be added. - - - - - Field - - Avahi.ClientState - - - To be added. - - - - - Field - - Avahi.ClientState - - - To be added. - - - - - Field - - Avahi.ClientState - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ClientStateArgs.xml b/avahi-sharp/en/Avahi/ClientStateArgs.xml deleted file mode 100644 index e5da11d..0000000 --- a/avahi-sharp/en/Avahi/ClientStateArgs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.ClientState - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ClientStateHandler.xml b/avahi-sharp/en/Avahi/ClientStateHandler.xml deleted file mode 100644 index 0576975..0000000 --- a/avahi-sharp/en/Avahi/ClientStateHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/DomainBrowser.xml b/avahi-sharp/en/Avahi/DomainBrowser.xml deleted file mode 100644 index 20536e0..0000000 --- a/avahi-sharp/en/Avahi/DomainBrowser.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - Avahi.BrowserBase - - - - System.IDisposable - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Event - - Avahi.DomainInfoHandler - - - To be added. - To be added. - - - - - Event - - Avahi.DomainInfoHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - Avahi.DomainInfo[] - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/DomainBrowserType.xml b/avahi-sharp/en/Avahi/DomainBrowserType.xml deleted file mode 100644 index 9743524..0000000 --- a/avahi-sharp/en/Avahi/DomainBrowserType.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - - Field - - Avahi.DomainBrowserType - - - To be added. - - - - - Field - - Avahi.DomainBrowserType - - - To be added. - - - - - Field - - Avahi.DomainBrowserType - - - To be added. - - - - - Field - - Avahi.DomainBrowserType - - - To be added. - - - - - Field - - Avahi.DomainBrowserType - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/DomainInfo.xml b/avahi-sharp/en/Avahi/DomainInfo.xml deleted file mode 100644 index dddfd60..0000000 --- a/avahi-sharp/en/Avahi/DomainInfo.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.ValueType - - - - - - Field - - System.Int32 - - - To be added. - To be added. - - - - - Field - - Avahi.Protocol - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/DomainInfoArgs.xml b/avahi-sharp/en/Avahi/DomainInfoArgs.xml deleted file mode 100644 index 1967447..0000000 --- a/avahi-sharp/en/Avahi/DomainInfoArgs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.DomainInfo - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/DomainInfoHandler.xml b/avahi-sharp/en/Avahi/DomainInfoHandler.xml deleted file mode 100644 index 793e2b7..0000000 --- a/avahi-sharp/en/Avahi/DomainInfoHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/EntryGroup.xml b/avahi-sharp/en/Avahi/EntryGroup.xml deleted file mode 100644 index 93fec22..0000000 --- a/avahi-sharp/en/Avahi/EntryGroup.xml +++ /dev/null @@ -1,491 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Object - - - - System.IDisposable - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Event - - Avahi.EntryGroupStateHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Property - - Avahi.EntryGroupState - - - To be added. - To be added. - To be added. - - - - - Property - - System.Boolean - - - To be added. - To be added. - To be added. - - - - - Method - - System.String - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Method - - System.Void - - - - - - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/EntryGroupState.xml b/avahi-sharp/en/Avahi/EntryGroupState.xml deleted file mode 100644 index c01e1df..0000000 --- a/avahi-sharp/en/Avahi/EntryGroupState.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - - Field - - Avahi.EntryGroupState - - - To be added. - - - - - Field - - Avahi.EntryGroupState - - - To be added. - - - - - Field - - Avahi.EntryGroupState - - - To be added. - - - - - Field - - Avahi.EntryGroupState - - - To be added. - - - - - Field - - Avahi.EntryGroupState - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/EntryGroupStateArgs.xml b/avahi-sharp/en/Avahi/EntryGroupStateArgs.xml deleted file mode 100644 index c7d6f8c..0000000 --- a/avahi-sharp/en/Avahi/EntryGroupStateArgs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.EntryGroupState - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/EntryGroupStateHandler.xml b/avahi-sharp/en/Avahi/EntryGroupStateHandler.xml deleted file mode 100644 index 427c519..0000000 --- a/avahi-sharp/en/Avahi/EntryGroupStateHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ErrorCode.xml b/avahi-sharp/en/Avahi/ErrorCode.xml deleted file mode 100644 index 687f524..0000000 --- a/avahi-sharp/en/Avahi/ErrorCode.xml +++ /dev/null @@ -1,526 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - Field - - Avahi.ErrorCode - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ErrorCodeArgs.xml b/avahi-sharp/en/Avahi/ErrorCodeArgs.xml deleted file mode 100644 index c8a7ccc..0000000 --- a/avahi-sharp/en/Avahi/ErrorCodeArgs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.ErrorCode - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ErrorCodeHandler.xml b/avahi-sharp/en/Avahi/ErrorCodeHandler.xml deleted file mode 100644 index 04e22d3..0000000 --- a/avahi-sharp/en/Avahi/ErrorCodeHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/HostAddressArgs.xml b/avahi-sharp/en/Avahi/HostAddressArgs.xml deleted file mode 100644 index 2b126e3..0000000 --- a/avahi-sharp/en/Avahi/HostAddressArgs.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.Net.IPAddress - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/HostAddressHandler.xml b/avahi-sharp/en/Avahi/HostAddressHandler.xml deleted file mode 100644 index f0c195e..0000000 --- a/avahi-sharp/en/Avahi/HostAddressHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/HostNameResolver.xml b/avahi-sharp/en/Avahi/HostNameResolver.xml deleted file mode 100644 index 37124fd..0000000 --- a/avahi-sharp/en/Avahi/HostNameResolver.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - Avahi.ResolverBase - - - - System.IDisposable - - - - - - Constructor - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Event - - Avahi.HostAddressHandler - - - To be added. - To be added. - - - - - Event - - System.EventHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - System.Net.IPAddress - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/LookupFlags.xml b/avahi-sharp/en/Avahi/LookupFlags.xml deleted file mode 100644 index d7882e0..0000000 --- a/avahi-sharp/en/Avahi/LookupFlags.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - System.Flags - - - - - - Field - - Avahi.LookupFlags - - - To be added. - - - - - Field - - Avahi.LookupFlags - - - To be added. - - - - - Field - - Avahi.LookupFlags - - - To be added. - - - - - Field - - Avahi.LookupFlags - - - To be added. - - - - - Field - - Avahi.LookupFlags - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/LookupResultFlags.xml b/avahi-sharp/en/Avahi/LookupResultFlags.xml deleted file mode 100644 index 0066493..0000000 --- a/avahi-sharp/en/Avahi/LookupResultFlags.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - System.Flags - - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/Protocol.xml b/avahi-sharp/en/Avahi/Protocol.xml deleted file mode 100644 index 361f034..0000000 --- a/avahi-sharp/en/Avahi/Protocol.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - - Field - - Avahi.Protocol - - - To be added. - - - - - Field - - Avahi.Protocol - - - To be added. - - - - - Field - - Avahi.Protocol - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/PublishFlags.xml b/avahi-sharp/en/Avahi/PublishFlags.xml deleted file mode 100644 index c21774c..0000000 --- a/avahi-sharp/en/Avahi/PublishFlags.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - System.Flags - - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - Field - - Avahi.PublishFlags - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/RecordBrowser.xml b/avahi-sharp/en/Avahi/RecordBrowser.xml deleted file mode 100644 index fdf32ca..0000000 --- a/avahi-sharp/en/Avahi/RecordBrowser.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - Avahi.BrowserBase - - - - System.IDisposable - - - - - - Constructor - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Event - - Avahi.RecordInfoHandler - - - To be added. - To be added. - - - - - Event - - Avahi.RecordInfoHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - Avahi.RecordInfo[] - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/RecordClass.xml b/avahi-sharp/en/Avahi/RecordClass.xml deleted file mode 100644 index 69787ce..0000000 --- a/avahi-sharp/en/Avahi/RecordClass.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - - Field - - Avahi.RecordClass - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/RecordInfo.xml b/avahi-sharp/en/Avahi/RecordInfo.xml deleted file mode 100644 index 708678e..0000000 --- a/avahi-sharp/en/Avahi/RecordInfo.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.ValueType - - - - - - Field - - System.Int32 - - - To be added. - To be added. - - - - - Field - - Avahi.Protocol - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - Avahi.RecordClass - - - To be added. - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - To be added. - - - - - Field - - System.Byte[] - - - To be added. - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/RecordInfoArgs.xml b/avahi-sharp/en/Avahi/RecordInfoArgs.xml deleted file mode 100644 index 81e6e57..0000000 --- a/avahi-sharp/en/Avahi/RecordInfoArgs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.RecordInfo - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/RecordInfoHandler.xml b/avahi-sharp/en/Avahi/RecordInfoHandler.xml deleted file mode 100644 index f9cbc17..0000000 --- a/avahi-sharp/en/Avahi/RecordInfoHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/RecordType.xml b/avahi-sharp/en/Avahi/RecordType.xml deleted file mode 100644 index 7913cad..0000000 --- a/avahi-sharp/en/Avahi/RecordType.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Enum - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - Field - - Avahi.RecordType - - - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ResolverBase.xml b/avahi-sharp/en/Avahi/ResolverBase.xml deleted file mode 100644 index c7d8549..0000000 --- a/avahi-sharp/en/Avahi/ResolverBase.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Object - - - - - - Constructor - - - To be added. - To be added. - - - - - Event - - Avahi.ErrorCodeHandler - - - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceBrowser.xml b/avahi-sharp/en/Avahi/ServiceBrowser.xml deleted file mode 100644 index ff4eedb..0000000 --- a/avahi-sharp/en/Avahi/ServiceBrowser.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - Avahi.BrowserBase - - - - System.IDisposable - - - - - - Constructor - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Event - - Avahi.ServiceInfoHandler - - - To be added. - To be added. - - - - - Event - - Avahi.ServiceInfoHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - Avahi.ServiceInfo[] - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceInfo.xml b/avahi-sharp/en/Avahi/ServiceInfo.xml deleted file mode 100644 index d780085..0000000 --- a/avahi-sharp/en/Avahi/ServiceInfo.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.ValueType - - - - - - Field - - System.Int32 - - - To be added. - To be added. - - - - - Field - - Avahi.Protocol - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - System.Net.IPAddress - - - To be added. - To be added. - - - - - Field - - System.UInt16 - - - To be added. - To be added. - - - - - Field - - System.Byte[][] - - - To be added. - To be added. - - - - - Field - - Avahi.ServiceInfo - - - To be added. - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceInfoArgs.xml b/avahi-sharp/en/Avahi/ServiceInfoArgs.xml deleted file mode 100644 index d2ee14d..0000000 --- a/avahi-sharp/en/Avahi/ServiceInfoArgs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.ServiceInfo - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceInfoHandler.xml b/avahi-sharp/en/Avahi/ServiceInfoHandler.xml deleted file mode 100644 index 91cf630..0000000 --- a/avahi-sharp/en/Avahi/ServiceInfoHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceResolver.xml b/avahi-sharp/en/Avahi/ServiceResolver.xml deleted file mode 100644 index e8ac750..0000000 --- a/avahi-sharp/en/Avahi/ServiceResolver.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - Avahi.ResolverBase - - - - System.IDisposable - - - - - - Constructor - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Event - - Avahi.ServiceInfoHandler - - - To be added. - To be added. - - - - - Event - - System.EventHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - Avahi.ServiceInfo - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceTypeBrowser.xml b/avahi-sharp/en/Avahi/ServiceTypeBrowser.xml deleted file mode 100644 index 5ea64ac..0000000 --- a/avahi-sharp/en/Avahi/ServiceTypeBrowser.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - Avahi.BrowserBase - - - - System.IDisposable - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - Event - - Avahi.ServiceTypeInfoHandler - - - To be added. - To be added. - - - - - Event - - Avahi.ServiceTypeInfoHandler - - - To be added. - To be added. - - - - - Method - - System.Void - - - - To be added. - To be added. - - - - - Property - - Avahi.ServiceTypeInfo[] - - - To be added. - To be added. - To be added. - - - - - Constructor - - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceTypeInfo.xml b/avahi-sharp/en/Avahi/ServiceTypeInfo.xml deleted file mode 100644 index 5b09ae9..0000000 --- a/avahi-sharp/en/Avahi/ServiceTypeInfo.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.ValueType - - - - - - Field - - System.Int32 - - - To be added. - To be added. - - - - - Field - - Avahi.Protocol - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - System.String - - - To be added. - To be added. - - - - - Field - - Avahi.LookupResultFlags - - - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceTypeInfoArgs.xml b/avahi-sharp/en/Avahi/ServiceTypeInfoArgs.xml deleted file mode 100644 index fd584cd..0000000 --- a/avahi-sharp/en/Avahi/ServiceTypeInfoArgs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.EventArgs - - - - - - Constructor - - - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.ServiceTypeInfo - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-sharp/en/Avahi/ServiceTypeInfoHandler.xml b/avahi-sharp/en/Avahi/ServiceTypeInfoHandler.xml deleted file mode 100644 index 0fd751f..0000000 --- a/avahi-sharp/en/Avahi/ServiceTypeInfoHandler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - avahi-sharp - 1.0.0.0 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/avahi-sharp/en/index.xml b/avahi-sharp/en/index.xml deleted file mode 100644 index e180cd0..0000000 --- a/avahi-sharp/en/index.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - System.Reflection.AssemblyTrademark(Trademark="") - - - System.Reflection.AssemblyCopyright(Copyright="(C) 2005 James Willcox <snorp@snorp.net>") - - - System.Reflection.AssemblyProduct(Product="") - - - System.Reflection.AssemblyCompany(Company="") - - - System.Reflection.AssemblyConfiguration(Configuration="") - - - System.Reflection.AssemblyDescription(Description="Mono bindings for the Avahi mDNS/DNS-SD stack") - - - System.Reflection.AssemblyTitle(Title="avahi-sharp") - - - - - To be added. - To be added. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - avahi-sharp - diff --git a/avahi-sharp/gencfg.sh b/avahi-sharp/gencfg.sh deleted file mode 100755 index 3486187..0000000 --- a/avahi-sharp/gencfg.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -. $1 -client_dlname=$dlname -. $2 -common_dlname=$dlname -. $3 -glib_dlname=$dlname - -exec sed -e "s,@CLIENT_DLNAME\@,${client_dlname},g" \ - -e "s,@COMMON_DLNAME\@,${common_dlname},g" \ - -e "s,@GLIB_DLNAME\@,${glib_dlname},g" diff --git a/avahi-ui-gtk3.pc.in b/avahi-ui-gtk3.pc.in deleted file mode 100644 index 27c4322..0000000 --- a/avahi-ui-gtk3.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include - -Name: avahi-ui -Description: Avahi Multicast DNS Responder (Common GTK3 UI support) -Requires: gtk+-3.0 avahi-client avahi-glib -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lavahi-ui-gtk3 -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-ui-sharp.pc.in b/avahi-ui-sharp.pc.in deleted file mode 100644 index cdc35e0..0000000 --- a/avahi-ui-sharp.pc.in +++ /dev/null @@ -1,9 +0,0 @@ -prefix=@prefix@ -exec_prefix=@prefix@ -libdir=@libdir@ - -Name: avahi-ui-sharp -Description: Mono bindings for the Avahi mDNS/DNS-SD stack -Version: @PACKAGE_VERSION@ -Requires: gtk-sharp-2.0 -Libs: -r:${libdir}/mono/avahi-ui-sharp/avahi-ui-sharp.dll diff --git a/avahi-ui-sharp/.gitignore b/avahi-ui-sharp/.gitignore deleted file mode 100644 index 0a27ea5..0000000 --- a/avahi-ui-sharp/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -avahi-ui-sharp-docs.tree -avahi-ui-sharp-docs.zip -avahi-ui-sharp.dll -avahi-ui-sharp.dll.config -avahi-ui-sharp.dll.mdb -bssh.exe diff --git a/avahi-ui-sharp/Makefile.am b/avahi-ui-sharp/Makefile.am deleted file mode 100644 index 28ea64f..0000000 --- a/avahi-ui-sharp/Makefile.am +++ /dev/null @@ -1,70 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -ASSEMBLY = avahi-ui-sharp.dll - -CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(ASSEMBLY).config bssh.exe - -AVAHISOURCES = \ - $(srcdir)/ServiceDialog.cs - -EXTRA_DIST = \ - $(AVAHISOURCES) \ - $(srcdir)/avahi-ui-sharp-docs.source \ - $(srcdir)/en/*.xml \ - $(srcdir)/en/*/*.xml \ - $(srcdir)/gencfg.sh \ - $(srcdir)/$(ASSEMBLY).config.in \ - $(srcdir)/bssh.cs - -$(ASSEMBLY): $(AVAHISOURCES) - $(AM_V_GEN)mcs -keyfile:$(top_srcdir)/avahi-sharp/avahi.snk -target:library -out:$@ -debug $(AVAHISOURCES) -pkg:gtk-sharp-2.0 -r:$(top_builddir)/avahi-sharp/avahi-sharp.dll -r:Mono.Posix - -$(ASSEMBLY).config: $(ASSEMBLY).config.in - $(AM_V_GEN)$(srcdir)/gencfg.sh $(top_builddir)/avahi-common/libavahi-common.la < $< > $@ - -bssh.exe: $(srcdir)/bssh.cs $(ASSEMBLY) - $(AM_V_GEN)mcs -out:$@ $(srcdir)/bssh.cs -r:./avahi-ui-sharp.dll -r:../avahi-sharp/avahi-sharp.dll -pkg:gtk-sharp-2.0 -r:Mono.Posix - -if HAVE_MONO -if HAVE_DBUS -if HAVE_GTK -all: $(ASSEMBLY) $(ASSEMBLY).config bssh.exe - -if HAVE_MONODOC -update-docs: $(ASSEMBLY) - $(AM_V_GEN)$(MONODOCER) -assembly:$(ASSEMBLY) -path:en - -avahi-ui-sharp-docs.zip: avahi-ui-sharp-docs.tree - -avahi-ui-sharp-docs.tree: $(srcdir)/en/*/* - $(AM_V_GEN)$(MDASSEMBLER) --out avahi-ui-sharp-docs --ecma $(srcdir)/en - -monodocdir = $(MONODOC_DIR) -monodoc_DATA = avahi-ui-sharp-docs.zip avahi-ui-sharp-docs.tree avahi-ui-sharp-docs.source - -endif - -install-data-hook: $(ASSEMBLY) - $(GACUTIL) /i $(ASSEMBLY) /package avahi-ui-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) - -uninstall-hook: $(ASSEMBLY) - $(GACUTIL) /u avahi-ui-sharp /package avahi-ui-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) - -endif -endif -endif diff --git a/avahi-ui-sharp/ServiceDialog.cs b/avahi-ui-sharp/ServiceDialog.cs deleted file mode 100644 index 31f7479..0000000 --- a/avahi-ui-sharp/ServiceDialog.cs +++ /dev/null @@ -1,238 +0,0 @@ -using System; -using System.Net; -using System.Collections; -using System.Runtime.InteropServices; -using Gtk; -using Mono.Unix; -using Mono.Unix.Native; - -namespace Avahi.UI -{ - public class ServiceDialog : Dialog - { - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_new (string title, IntPtr parent, IntPtr dummy); - - [DllImport ("avahi-ui")] - private static extern void aui_service_dialog_set_browse_service_typesv (IntPtr dialog, IntPtr[] types); - - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_get_browse_service_types (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_get_domain (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern void aui_service_dialog_set_domain (IntPtr dialog, IntPtr domain); - - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_get_service_type (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern void aui_service_dialog_set_service_type (IntPtr dialog, IntPtr type); - - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_get_service_name (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern void aui_service_dialog_set_service_name (IntPtr dialog, IntPtr type); - - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_get_address (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern UInt16 aui_service_dialog_get_port (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_get_host_name (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern IntPtr aui_service_dialog_get_txt_data (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern bool aui_service_dialog_get_resolve_service (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern void aui_service_dialog_set_resolve_service (IntPtr dialog, bool val); - - [DllImport ("avahi-ui")] - private static extern bool aui_service_dialog_get_resolve_host_name (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern void aui_service_dialog_set_resolve_host_name (IntPtr dialog, bool val); - - [DllImport ("avahi-ui")] - private static extern Protocol aui_service_dialog_get_address_family (IntPtr dialog); - - [DllImport ("avahi-ui")] - private static extern void aui_service_dialog_set_address_family (IntPtr dialog, Protocol proto); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_address_snprint (IntPtr buf, int size, IntPtr address); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_string_list_get_next (IntPtr list); - - [DllImport ("avahi-common")] - private static extern IntPtr avahi_string_list_get_text (IntPtr list); - - [DllImport ("avahi-common")] - private static extern int avahi_string_list_get_size (IntPtr list); - - public string[] BrowseServiceTypes { - get { - IntPtr arr = aui_service_dialog_get_browse_service_types (Raw); - - ArrayList values = new ArrayList (); - - for (int i = 0;;i++) { - IntPtr ptr = Marshal.ReadIntPtr (arr, i * Marshal.SizeOf (typeof (IntPtr))); - - if (ptr == IntPtr.Zero) - break; - - values.Add (GLib.Marshaller.Utf8PtrToString (ptr)); - } - - return (string[]) values.ToArray (typeof (string)); - } set { - IntPtr[] types; - if (value == null) { - types = new IntPtr[] { IntPtr.Zero }; - } else { - types = new IntPtr[value.Length + 1]; - - for (int i = 0; i < value.Length; i++) { - types[i] = GLib.Marshaller.StringToPtrGStrdup (value[i]); - } - - types[value.Length] = IntPtr.Zero; - } - - aui_service_dialog_set_browse_service_typesv (Raw, types); - - for (int i = 0;;i++) { - if (types[i] != IntPtr.Zero) - break; - - GLib.Marshaller.Free (types[i]); - } - } - } - - public string ServiceType { - get { - return GLib.Marshaller.Utf8PtrToString (aui_service_dialog_get_service_type (Raw)); - } set { - IntPtr type = GLib.Marshaller.StringToPtrGStrdup (value); - aui_service_dialog_set_service_type (Raw, type); - GLib.Marshaller.Free (type); - } - } - - public string ServiceName { - get { - return GLib.Marshaller.Utf8PtrToString (aui_service_dialog_get_service_name (Raw)); - } set { - IntPtr name = GLib.Marshaller.StringToPtrGStrdup (value); - aui_service_dialog_set_service_name (Raw, name); - GLib.Marshaller.Free (name); - } - } - - public IPAddress Address { - get { - return PtrToAddress (aui_service_dialog_get_address (Raw)); - } - } - - public UInt16 Port { - get { - return aui_service_dialog_get_port (Raw); - } - } - - public string HostName { - get { - return GLib.Marshaller.Utf8PtrToString (aui_service_dialog_get_host_name (Raw)); - } - } - - public string Domain { - get { - return GLib.Marshaller.Utf8PtrToString (aui_service_dialog_get_domain (Raw)); - } set { - IntPtr domain = GLib.Marshaller.StringToPtrGStrdup (value); - aui_service_dialog_set_domain (Raw, domain); - GLib.Marshaller.Free (domain); - } - } - - public byte[][] TxtData { - get { - ArrayList txtlist = new ArrayList (); - IntPtr txt = aui_service_dialog_get_txt_data (Raw); - - for (IntPtr l = txt; l != IntPtr.Zero; l = avahi_string_list_get_next (l)) { - IntPtr buf = avahi_string_list_get_text (l); - int len = avahi_string_list_get_size (l); - - byte[] txtbuf = new byte[len]; - Marshal.Copy (buf, txtbuf, 0, len); - txtlist.Add (txtbuf); - } - - return (byte[][]) txtlist.ToArray (typeof (byte[])); - } - } - - public bool ResolveServiceEnabled { - get { - return aui_service_dialog_get_resolve_service (Raw); - } set { - aui_service_dialog_set_resolve_service (Raw, value); - } - } - - public bool ResolveHostNameEnabled { - get { - return aui_service_dialog_get_resolve_host_name (Raw); - } set { - aui_service_dialog_set_resolve_host_name (Raw, value); - } - } - - public Protocol AddressFamily { - get { - return aui_service_dialog_get_address_family (Raw); - } set { - aui_service_dialog_set_address_family (Raw, value); - } - } - - public ServiceDialog (string title, Window parent, params object[] buttonData) - { - Raw = aui_service_dialog_new (title, parent == null ? IntPtr.Zero : parent.Handle, - IntPtr.Zero); - - for (int i = 0; i < buttonData.Length - 1; i += 2) { - AddButton ((string) buttonData[i], (int) buttonData[i + 1]); - } - } - - private static IPAddress PtrToAddress (IntPtr ptr) - { - IPAddress address = null; - - if (ptr != IntPtr.Zero) { - IntPtr buf = Stdlib.malloc (256); - IntPtr addrPtr = avahi_address_snprint (buf, 256, ptr); - address = IPAddress.Parse (GLib.Marshaller.Utf8PtrToString (addrPtr)); - - Stdlib.free (addrPtr); - } - - return address; - } - } -} diff --git a/avahi-ui-sharp/avahi-ui-sharp-docs.source b/avahi-ui-sharp/avahi-ui-sharp-docs.source deleted file mode 100644 index 2e7b172..0000000 --- a/avahi-ui-sharp/avahi-ui-sharp-docs.source +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/avahi-ui-sharp/avahi-ui-sharp.dll.config.in b/avahi-ui-sharp/avahi-ui-sharp.dll.config.in deleted file mode 100644 index 819577f..0000000 --- a/avahi-ui-sharp/avahi-ui-sharp.dll.config.in +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/avahi-ui-sharp/bssh.cs b/avahi-ui-sharp/bssh.cs deleted file mode 100644 index fa3d4d4..0000000 --- a/avahi-ui-sharp/bssh.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Diagnostics; -using Gtk; -using Avahi.UI; - -public class EntryPoint { - public static void Main () { - Application.Init (); - - ServiceDialog dialog = new ServiceDialog ("Choose SSH Server", null, - Stock.Cancel, ResponseType.Cancel, - Stock.Connect, ResponseType.Accept); - dialog.BrowseServiceTypes = new string[] { "_ssh._tcp" }; - dialog.ResolveServiceEnabled = true; - - if (dialog.Run () == (int) ResponseType.Accept) { - Console.WriteLine ("Connecting to {0}:{1}", dialog.Address, dialog.Port); - - string user = Environment.UserName; - - foreach (byte[] txtBytes in dialog.TxtData) { - string txt = System.Text.Encoding.UTF8.GetString (txtBytes); - string[] splitTxt = txt.Split(new char[] { '=' }, 2); - - if (splitTxt.Length != 2) - continue; - - if (splitTxt[0] == "u") { - user = splitTxt[1]; - } - - string args = String.Format ("gnome-terminal -t {0} -x ssh -p {1} -l {2} {3}", - dialog.HostName, dialog.Port, user, dialog.Address.ToString ()); - Console.WriteLine ("Launching: " + args); - Process.Start (args); - } - } - } -} diff --git a/avahi-ui-sharp/en/Avahi.UI.xml b/avahi-ui-sharp/en/Avahi.UI.xml deleted file mode 100644 index 949581c..0000000 --- a/avahi-ui-sharp/en/Avahi.UI.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - To be added. - To be added. - - diff --git a/avahi-ui-sharp/en/Avahi.UI/ServiceDialog.xml b/avahi-ui-sharp/en/Avahi.UI/ServiceDialog.xml deleted file mode 100644 index 72fa8ed..0000000 --- a/avahi-ui-sharp/en/Avahi.UI/ServiceDialog.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - - avahi-ui-sharp - 0.0.0.0 - - - Gtk.Dialog - - - - - - Constructor - - - - - - - System.ParamArray - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - Property - - System.Net.IPAddress - - - To be added. - To be added. - To be added. - - - - - Property - - Avahi.Protocol - - - To be added. - To be added. - To be added. - - - - - Property - - System.String[] - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.UInt16 - - - To be added. - To be added. - To be added. - - - - - Property - - System.Boolean - - - To be added. - To be added. - To be added. - - - - - Property - - System.Boolean - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.String - - - To be added. - To be added. - To be added. - - - - - Property - - System.Byte[][] - - - To be added. - To be added. - To be added. - - - - - To be added. - To be added. - - diff --git a/avahi-ui-sharp/en/index.xml b/avahi-ui-sharp/en/index.xml deleted file mode 100644 index d1e808c..0000000 --- a/avahi-ui-sharp/en/index.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - To be added. - To be added. - - - - - - avahi-ui-sharp - diff --git a/avahi-ui-sharp/gencfg.sh b/avahi-ui-sharp/gencfg.sh deleted file mode 100755 index 44a6c81..0000000 --- a/avahi-ui-sharp/gencfg.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -. $1 -common_dlname=$dlname - -exec sed -e "s,@COMMON_DLNAME\@,${common_dlname},g" diff --git a/avahi-ui.pc.in b/avahi-ui.pc.in deleted file mode 100644 index 9edeea9..0000000 --- a/avahi-ui.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${prefix}/include - -Name: avahi-ui -Description: Avahi Multicast DNS Responder (Common GTK2 UI support) -Requires: gtk+-2.0 avahi-client avahi-glib -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lavahi-ui -Cflags: -D_REENTRANT -I${includedir} diff --git a/avahi-ui/.gitignore b/avahi-ui/.gitignore deleted file mode 100644 index b942010..0000000 --- a/avahi-ui/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -bssh -bvnc -bssh.desktop -bvnc.desktop -bssh.desktop.in -bvnc.desktop.in -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs diff --git a/avahi-ui/Makefile.am b/avahi-ui/Makefile.am deleted file mode 100644 index 5523325..0000000 --- a/avahi-ui/Makefile.am +++ /dev/null @@ -1,113 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) -DG_DISABLE_DEPRECATED=1 -DGDK_DISABLE_DEPRECATED=1 -DGTK_DISABLE_DEPRECATED=1 - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -pkglibdatadir=$(libdir)/avahi - -desktopdir = $(datadir)/applications -desktop_DATA = -desktop_DATA_in = $(desktop_DATA_in_in:.in.in=.in) -desktop_DATA_in_in = bssh.desktop.in.in bvnc.desktop.in.in - -EXTRA_DIST = $(desktop_DATA_in_in) - -if HAVE_GTK2OR3 -AM_CFLAGS += -DGNOMELOCALEDIR=\"$(datadir)/locale\" -if HAVE_DBUS -if HAVE_GLIB - -avahiincludedir=$(includedir)/avahi-ui - -avahiinclude_HEADERS = \ - avahi-ui.h - -lib_LTLIBRARIES = - -if HAVE_GTK -lib_LTLIBRARIES += \ - libavahi-ui.la -endif - -if HAVE_GTK3 -lib_LTLIBRARIES += \ - libavahi-ui-gtk3.la -endif - -libavahi_ui_la_SOURCES = \ - avahi-ui.h avahi-ui.c -libavahi_ui_la_CFLAGS = $(AM_CFLAGS) $(GTK20_CFLAGS) -libavahi_ui_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GTK20_LIBS) -libavahi_ui_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_UI_VERSION_INFO) - -libavahi_ui_gtk3_la_SOURCES = $(libavahi_ui_la_SOURCES) -libavahi_ui_gtk3_la_CFLAGS = $(AM_CFLAGS) $(GTK30_CFLAGS) -libavahi_ui_gtk3_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GTK30_LIBS) -libavahi_ui_gtk3_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_UI_VERSION_INFO) - -if HAVE_GDBM -libavahi_ui_la_SOURCES += ../avahi-utils/stdb.h ../avahi-utils/stdb.c -libavahi_ui_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdatadir)/service-types.db\" -libavahi_ui_la_LIBADD += -lgdbm - -libavahi_ui_gtk3_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdatadir)/service-types.db\" -libavahi_ui_gtk3_la_LIBADD += -lgdbm -endif - -if HAVE_DBM -libavahi_ui_la_SOURCES += ../avahi-utils/stdb.h ../avahi-utils/stdb.c -libavahi_ui_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdatadir)/service-types.db\" - -libavahi_ui_gtk3_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdatadir)/service-types.db\" -endif - -bin_PROGRAMS = bssh -desktop_DATA += bssh.desktop bvnc.desktop -@INTLTOOL_DESKTOP_RULE@ - -bssh_SOURCES = bssh.c - -if HAVE_GTK3 -bssh_CFLAGS = $(AM_CFLAGS) $(GTK30_CFLAGS) -bssh_LDADD = $(AM_LDADD) $(GTK30_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la libavahi-ui-gtk3.la -else -bssh_CFLAGS = $(AM_CFLAGS) $(GTK20_CFLAGS) -bssh_LDADD = $(AM_LDADD) $(GTK20_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la libavahi-ui.la -endif - -install-exec-local: - cd $(DESTDIR)/$(bindir) && \ - rm -f bvnc bshell && \ - $(LN_S) bssh bvnc && \ - $(LN_S) bssh bshell - -bssh.desktop.in: bssh.desktop.in.in - $(AM_V_GEN)sed -e 's,@bindir\@,$(bindir),g' $< > $@ - -bvnc.desktop.in: bvnc.desktop.in.in - $(AM_V_GEN)sed -e 's,@bindir\@,$(bindir),g' $< > $@ - -endif # HAVE_GLIB -endif -endif - -@INTLTOOL_DESKTOP_RULE@ - -CLEANFILES = $(desktop_DATA) $(desktop_DATA_in) diff --git a/avahi-ui/avahi-ui.c b/avahi-ui/avahi-ui.c deleted file mode 100644 index 92d765a..0000000 --- a/avahi-ui/avahi-ui.c +++ /dev/null @@ -1,1477 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "avahi-ui.h" - -#if defined(HAVE_GDBM) || defined(HAVE_DBM) -#include "../avahi-utils/stdb.h" -#endif - -/* todo: i18n, HIGify */ - -struct _AuiServiceDialogPrivate { - AvahiGLibPoll *glib_poll; - AvahiClient *client; - AvahiServiceBrowser **browsers; - AvahiServiceResolver *resolver; - AvahiDomainBrowser *domain_browser; - - gchar **browse_service_types; - gchar *service_type; - gchar *domain; - gchar *service_name; - AvahiProtocol address_family; - - AvahiAddress address; - gchar *host_name; - AvahiStringList *txt_data; - guint16 port; - - gboolean resolve_service, resolve_service_done; - gboolean resolve_host_name, resolve_host_name_done; - - GtkWidget *domain_label; - GtkWidget *domain_button; - GtkWidget *service_tree_view; - GtkWidget *service_progress_bar; - - GtkListStore *service_list_store, *domain_list_store; - GHashTable *service_type_names; - - guint service_pulse_timeout; - guint domain_pulse_timeout; - guint start_idle; - - AvahiIfIndex common_interface; - AvahiProtocol common_protocol; - - GtkWidget *domain_dialog; - GtkWidget *domain_entry; - GtkWidget *domain_tree_view; - GtkWidget *domain_progress_bar; - GtkWidget *domain_ok_button; - - gint forward_response_id; -}; - -enum { - PROP_0, - PROP_BROWSE_SERVICE_TYPES, - PROP_DOMAIN, - PROP_SERVICE_TYPE, - PROP_SERVICE_NAME, - PROP_ADDRESS, - PROP_PORT, - PROP_HOST_NAME, - PROP_TXT_DATA, - PROP_RESOLVE_SERVICE, - PROP_RESOLVE_HOST_NAME, - PROP_ADDRESS_FAMILY -}; - -enum { - SERVICE_COLUMN_IFACE, - SERVICE_COLUMN_PROTO, - SERVICE_COLUMN_TYPE, - SERVICE_COLUMN_NAME, - SERVICE_COLUMN_PRETTY_IFACE, - SERVICE_COLUMN_PRETTY_TYPE, - N_SERVICE_COLUMNS -}; - -enum { - DOMAIN_COLUMN_NAME, - DOMAIN_COLUMN_REF, - N_DOMAIN_COLUMNS -}; - -static void aui_service_dialog_finalize(GObject *object); -static void aui_service_dialog_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void aui_service_dialog_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - -static int get_default_response(GtkDialog *dlg) { - gint ret = GTK_RESPONSE_NONE; - - if (gtk_window_get_default_widget(GTK_WINDOW(dlg))) - /* Use the response of the default widget, if possible */ - ret = gtk_dialog_get_response_for_widget(dlg, gtk_window_get_default_widget(GTK_WINDOW(dlg))); - - if (ret == GTK_RESPONSE_NONE) { - /* Fall back to finding the first positive response */ - GList *children, *t; - gint bad = GTK_RESPONSE_NONE; - - t = children = gtk_container_get_children(GTK_CONTAINER(gtk_dialog_get_action_area(dlg))); - - while (t) { - GtkWidget *child = t->data; - - ret = gtk_dialog_get_response_for_widget(dlg, child); - - if (ret == GTK_RESPONSE_ACCEPT || - ret == GTK_RESPONSE_OK || - ret == GTK_RESPONSE_YES || - ret == GTK_RESPONSE_APPLY) - break; - - if (ret != GTK_RESPONSE_NONE && bad == GTK_RESPONSE_NONE) - bad = ret; - - t = t->next; - } - - g_list_free (children); - - /* Fall back to finding the first negative response */ - if (ret == GTK_RESPONSE_NONE) - ret = bad; - } - - return ret; -} - -G_DEFINE_TYPE(AuiServiceDialog, aui_service_dialog, GTK_TYPE_DIALOG) - -static void aui_service_dialog_class_init(AuiServiceDialogClass *klass) { - GObjectClass *object_class; - - avahi_init_i18n(); - - object_class = (GObjectClass*) klass; - - object_class->finalize = aui_service_dialog_finalize; - object_class->set_property = aui_service_dialog_set_property; - object_class->get_property = aui_service_dialog_get_property; - - g_object_class_install_property( - object_class, - PROP_BROWSE_SERVICE_TYPES, - g_param_spec_pointer("browse_service_types", _("Browse Service Types"), _("A NULL terminated list of service types to browse for"), - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property( - object_class, - PROP_DOMAIN, - g_param_spec_string("domain", _("Domain"), _("The domain to browse in, or NULL for the default domain"), - NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property( - object_class, - PROP_SERVICE_TYPE, - g_param_spec_string("service_type", _("Service Type"), _("The service type of the selected service"), - NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property( - object_class, - PROP_SERVICE_NAME, - g_param_spec_string("service_name", _("Service Name"), _("The service name of the selected service"), - NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property( - object_class, - PROP_ADDRESS, - g_param_spec_pointer("address", _("Address"), _("The address of the resolved service"), - G_PARAM_READABLE)); - g_object_class_install_property( - object_class, - PROP_PORT, - g_param_spec_uint("port", _("Port"), _("The IP port number of the resolved service"), - 0, 0xFFFF, 0, - G_PARAM_READABLE)); - g_object_class_install_property( - object_class, - PROP_HOST_NAME, - g_param_spec_string("host_name", _("Host Name"), _("The host name of the resolved service"), - NULL, - G_PARAM_READABLE)); - g_object_class_install_property( - object_class, - PROP_TXT_DATA, - g_param_spec_pointer("txt_data", _("TXT Data"), _("The TXT data of the resolved service"), - G_PARAM_READABLE)); - g_object_class_install_property( - object_class, - PROP_RESOLVE_SERVICE, - g_param_spec_boolean("resolve_service", _("Resolve Service"), _("Resolve the selected service automatically before returning"), - TRUE, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property( - object_class, - PROP_RESOLVE_HOST_NAME, - g_param_spec_boolean("resolve_host_name", _("Resolve Service Host Name"), _("Resolve the host name of the selected service automatically before returning"), - TRUE, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property( - object_class, - PROP_ADDRESS_FAMILY, - g_param_spec_int("address_family", _("Address family"), _("The address family for host name resolution"), - AVAHI_PROTO_UNSPEC, AVAHI_PROTO_INET6, AVAHI_PROTO_UNSPEC, - G_PARAM_READABLE | G_PARAM_WRITABLE)); -} - - -GtkWidget *aui_service_dialog_new_valist( - const gchar *title, - GtkWindow *parent, - const gchar *first_button_text, - va_list varargs) { - - const gchar *button_text; - gint dr; - - GtkWidget *w = (GtkWidget*)g_object_new( - AUI_TYPE_SERVICE_DIALOG, -#if !GTK_CHECK_VERSION (2,21,8) - "has-separator", FALSE, -#endif - "title", title, - NULL); - - if (parent) - gtk_window_set_transient_for(GTK_WINDOW(w), parent); - - button_text = first_button_text; - while (button_text) { - gint response_id; - - response_id = va_arg(varargs, gint); - gtk_dialog_add_button(GTK_DIALOG(w), button_text, response_id); - button_text = va_arg(varargs, const gchar *); - } - - gtk_dialog_set_response_sensitive(GTK_DIALOG(w), GTK_RESPONSE_ACCEPT, FALSE); - gtk_dialog_set_response_sensitive(GTK_DIALOG(w), GTK_RESPONSE_OK, FALSE); - gtk_dialog_set_response_sensitive(GTK_DIALOG(w), GTK_RESPONSE_YES, FALSE); - gtk_dialog_set_response_sensitive(GTK_DIALOG(w), GTK_RESPONSE_APPLY, FALSE); - - if ((dr = get_default_response(GTK_DIALOG(w))) != GTK_RESPONSE_NONE) - gtk_dialog_set_default_response(GTK_DIALOG(w), dr); - - return w; -} - -GtkWidget* aui_service_dialog_new( - const gchar *title, - GtkWindow *parent, - const gchar *first_button_text, - ...) { - - GtkWidget *w; - - va_list varargs; - va_start(varargs, first_button_text); - w = aui_service_dialog_new_valist(title, parent, first_button_text, varargs); - va_end(varargs); - - return w; -} - -static gboolean service_pulse_callback(gpointer data) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(data); - - gtk_progress_bar_pulse(GTK_PROGRESS_BAR(d->priv->service_progress_bar)); - return TRUE; -} - -static gboolean domain_pulse_callback(gpointer data) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(data); - - gtk_progress_bar_pulse(GTK_PROGRESS_BAR(d->priv->domain_progress_bar)); - return TRUE; -} - -static void client_callback(AvahiClient *c, AvahiClientState state, void *userdata) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(userdata); - - if (state == AVAHI_CLIENT_FAILURE) { - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Avahi client failure: %s"), - avahi_strerror(avahi_client_errno(c))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - } -} - -static void resolve_callback( - AvahiServiceResolver *r G_GNUC_UNUSED, - AvahiIfIndex interface G_GNUC_UNUSED, - AvahiProtocol protocol G_GNUC_UNUSED, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AvahiLookupResultFlags flags G_GNUC_UNUSED, - void *userdata) { - - AuiServiceDialog *d = AUI_SERVICE_DIALOG(userdata); - - switch (event) { - case AVAHI_RESOLVER_FOUND: - - d->priv->resolve_service_done = 1; - - g_free(d->priv->service_name); - d->priv->service_name = g_strdup(name); - - g_free(d->priv->service_type); - d->priv->service_type = g_strdup(type); - - g_free(d->priv->domain); - d->priv->domain = g_strdup(domain); - - g_free(d->priv->host_name); - d->priv->host_name = g_strdup(host_name); - - d->priv->port = port; - - avahi_string_list_free(d->priv->txt_data); - d->priv->txt_data = avahi_string_list_copy(txt); - - if (a) { - d->priv->resolve_host_name_done = 1; - d->priv->address = *a; - } - - gtk_dialog_response(GTK_DIALOG(d), d->priv->forward_response_id); - - break; - - case AVAHI_RESOLVER_FAILURE: { - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Avahi resolver failure: %s"), - avahi_strerror(avahi_client_errno(d->priv->client))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - break; - } - } -} - - -static void browse_callback( - AvahiServiceBrowser *b G_GNUC_UNUSED, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - const char *type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { - - AuiServiceDialog *d = AUI_SERVICE_DIALOG(userdata); - - switch (event) { - - case AVAHI_BROWSER_NEW: { - gchar *ifs; - const gchar *pretty_type = NULL; - char ifname[IFNAMSIZ]; - GtkTreeIter iter; - GtkTreeSelection *selection; - - if (!(if_indextoname(interface, ifname))) - g_snprintf(ifname, sizeof(ifname), "%i", interface); - - ifs = g_strdup_printf("%s %s", ifname, protocol == AVAHI_PROTO_INET ? "IPv4" : "IPv6"); - - if (d->priv->service_type_names) - pretty_type = g_hash_table_lookup (d->priv->service_type_names, type); - - if (!pretty_type) { -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - pretty_type = stdb_lookup(type); -#else - pretty_type = type; -#endif - } - - gtk_list_store_append(d->priv->service_list_store, &iter); - - gtk_list_store_set(d->priv->service_list_store, &iter, - SERVICE_COLUMN_IFACE, interface, - SERVICE_COLUMN_PROTO, protocol, - SERVICE_COLUMN_NAME, name, - SERVICE_COLUMN_TYPE, type, - SERVICE_COLUMN_PRETTY_IFACE, ifs, - SERVICE_COLUMN_PRETTY_TYPE, pretty_type, - -1); - - g_free(ifs); - - if (d->priv->common_protocol == AVAHI_PROTO_UNSPEC) - d->priv->common_protocol = protocol; - - if (d->priv->common_interface == AVAHI_IF_UNSPEC) - d->priv->common_interface = interface; - - if (d->priv->common_interface != interface || d->priv->common_protocol != protocol) { - gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(d->priv->service_tree_view), 0), TRUE); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(d->priv->service_tree_view), TRUE); - } - - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(d->priv->service_tree_view)); - if (!gtk_tree_selection_get_selected(selection, NULL, NULL)) { - - if (!d->priv->service_type || - !d->priv->service_name || - (avahi_domain_equal(d->priv->service_type, type) && strcasecmp(d->priv->service_name, name) == 0)) { - GtkTreePath *path; - - gtk_tree_selection_select_iter(selection, &iter); - - path = gtk_tree_model_get_path(GTK_TREE_MODEL(d->priv->service_list_store), &iter); - gtk_tree_view_set_cursor(GTK_TREE_VIEW(d->priv->service_tree_view), path, NULL, FALSE); - gtk_tree_path_free(path); - } - - } - - break; - } - - case AVAHI_BROWSER_REMOVE: { - GtkTreeIter iter; - gboolean valid; - - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(d->priv->service_list_store), &iter); - while (valid) { - gint _interface, _protocol; - gchar *_name, *_type; - gboolean found; - - gtk_tree_model_get(GTK_TREE_MODEL(d->priv->service_list_store), &iter, - SERVICE_COLUMN_IFACE, &_interface, - SERVICE_COLUMN_PROTO, &_protocol, - SERVICE_COLUMN_NAME, &_name, - SERVICE_COLUMN_TYPE, &_type, - -1); - - found = _interface == interface && _protocol == protocol && strcasecmp(_name, name) == 0 && avahi_domain_equal(_type, type); - g_free(_name); - - if (found) { - gtk_list_store_remove(d->priv->service_list_store, &iter); - break; - } - - valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(d->priv->service_list_store), &iter); - } - - break; - } - - case AVAHI_BROWSER_FAILURE: { - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Browsing for service type %s in domain %s failed: %s"), - type, domain ? domain : _("n/a"), - avahi_strerror(avahi_client_errno(d->priv->client))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - /* Fall through */ - } - - case AVAHI_BROWSER_ALL_FOR_NOW: - if (d->priv->service_pulse_timeout > 0) { - g_source_remove(d->priv->service_pulse_timeout); - d->priv->service_pulse_timeout = 0; - gtk_widget_hide(d->priv->service_progress_bar); - } - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - ; - } -} - -static void domain_make_default_selection(AuiServiceDialog *d, const gchar *name, GtkTreeIter *iter) { - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(d->priv->domain_tree_view)); - if (!gtk_tree_selection_get_selected(selection, NULL, NULL)) { - - if (avahi_domain_equal(gtk_entry_get_text(GTK_ENTRY(d->priv->domain_entry)), name)) { - GtkTreePath *path; - - gtk_tree_selection_select_iter(selection, iter); - - path = gtk_tree_model_get_path(GTK_TREE_MODEL(d->priv->domain_list_store), iter); - gtk_tree_view_set_cursor(GTK_TREE_VIEW(d->priv->domain_tree_view), path, NULL, FALSE); - gtk_tree_path_free(path); - } - - } -} - -static void domain_browse_callback( - AvahiDomainBrowser *b G_GNUC_UNUSED, - AvahiIfIndex interface G_GNUC_UNUSED, - AvahiProtocol protocol G_GNUC_UNUSED, - AvahiBrowserEvent event, - const char *name, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { - - AuiServiceDialog *d = AUI_SERVICE_DIALOG(userdata); - - switch (event) { - - case AVAHI_BROWSER_NEW: { - GtkTreeIter iter; - gboolean found = FALSE, valid; - gint ref; - - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(d->priv->domain_list_store), &iter); - while (valid) { - gchar *_name; - - gtk_tree_model_get(GTK_TREE_MODEL(d->priv->domain_list_store), &iter, - DOMAIN_COLUMN_NAME, &_name, - DOMAIN_COLUMN_REF, &ref, - -1); - - found = avahi_domain_equal(_name, name); - g_free(_name); - - if (found) - break; - - valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(d->priv->domain_list_store), &iter); - } - - if (found) - gtk_list_store_set(d->priv->domain_list_store, &iter, DOMAIN_COLUMN_REF, ref + 1, -1); - else { - gtk_list_store_append(d->priv->domain_list_store, &iter); - - gtk_list_store_set(d->priv->domain_list_store, &iter, - DOMAIN_COLUMN_NAME, name, - DOMAIN_COLUMN_REF, 1, - -1); - } - - domain_make_default_selection(d, name, &iter); - - break; - } - - case AVAHI_BROWSER_REMOVE: { - gboolean valid; - GtkTreeIter iter; - - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(d->priv->domain_list_store), &iter); - while (valid) { - gint ref; - gchar *_name; - gboolean found; - - gtk_tree_model_get(GTK_TREE_MODEL(d->priv->domain_list_store), &iter, - DOMAIN_COLUMN_NAME, &_name, - DOMAIN_COLUMN_REF, &ref, - -1); - - found = avahi_domain_equal(_name, name); - g_free(_name); - - if (found) { - if (ref <= 1) - gtk_list_store_remove(d->priv->service_list_store, &iter); - else - gtk_list_store_set(d->priv->domain_list_store, &iter, DOMAIN_COLUMN_REF, ref - 1, -1); - break; - } - - valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(d->priv->domain_list_store), &iter); - } - - break; - } - - - case AVAHI_BROWSER_FAILURE: { - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Avahi domain browser failure: %s"), - avahi_strerror(avahi_client_errno(d->priv->client))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - /* Fall through */ - } - - case AVAHI_BROWSER_ALL_FOR_NOW: - if (d->priv->domain_pulse_timeout > 0) { - g_source_remove(d->priv->domain_pulse_timeout); - d->priv->domain_pulse_timeout = 0; - gtk_widget_hide(d->priv->domain_progress_bar); - } - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - ; - } -} - -static const gchar *get_domain_name(AuiServiceDialog *d) { - const gchar *domain; - - g_return_val_if_fail(d, NULL); - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - - if (d->priv->domain) - return d->priv->domain; - - if (!(domain = avahi_client_get_domain_name(d->priv->client))) { - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Failed to read Avahi domain: %s"), - avahi_strerror(avahi_client_errno(d->priv->client))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - return NULL; - } - - return domain; -} - -static gboolean start_callback(gpointer data) { - int error; - AuiServiceDialog *d = AUI_SERVICE_DIALOG(data); - gchar **st; - AvahiServiceBrowser **sb; - unsigned i; - const char *domain; - - d->priv->start_idle = 0; - - if (!d->priv->browse_service_types || !*d->priv->browse_service_types) { - g_warning(_("Browse service type list is empty!")); - return FALSE; - } - - if (!d->priv->client) { - if (!(d->priv->client = avahi_client_new(avahi_glib_poll_get(d->priv->glib_poll), 0, client_callback, d, &error))) { - - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Failed to connect to Avahi server: %s"), - avahi_strerror(error)); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - return FALSE; - } - } - - if (!(domain = get_domain_name(d))) { - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - return FALSE; - } - - g_assert(domain); - - if (avahi_domain_equal(domain, "local.")) - gtk_label_set_markup(GTK_LABEL(d->priv->domain_label), _("Browsing for services on local network:")); - else { - gchar *t = g_strdup_printf(_("Browsing for services in domain %s:"), domain); - gtk_label_set_markup(GTK_LABEL(d->priv->domain_label), t); - g_free(t); - } - - if (d->priv->browsers) { - for (sb = d->priv->browsers; *sb; sb++) - avahi_service_browser_free(*sb); - - g_free(d->priv->browsers); - d->priv->browsers = NULL; - } - - gtk_list_store_clear(GTK_LIST_STORE(d->priv->service_list_store)); - d->priv->common_interface = AVAHI_IF_UNSPEC; - d->priv->common_protocol = AVAHI_PROTO_UNSPEC; - - gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(d->priv->service_tree_view), 0), FALSE); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(d->priv->service_tree_view), FALSE); - gtk_widget_show(d->priv->service_progress_bar); - - if (d->priv->service_pulse_timeout <= 0) - d->priv->service_pulse_timeout = g_timeout_add(100, service_pulse_callback, d); - - for (i = 0; d->priv->browse_service_types[i]; i++) - ; - g_assert(i > 0); - - d->priv->browsers = g_new0(AvahiServiceBrowser*, i+1); - for (st = d->priv->browse_service_types, sb = d->priv->browsers; *st; st++, sb++) { - - if (!(*sb = avahi_service_browser_new(d->priv->client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, *st, d->priv->domain, 0, browse_callback, d))) { - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Failed to create browser for %s: %s"), - *st, - avahi_strerror(avahi_client_errno(d->priv->client))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - return FALSE; - - } - } - - return FALSE; -} - -static void aui_service_dialog_finalize(GObject *object) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(object); - - if (d->priv->domain_pulse_timeout > 0) - g_source_remove(d->priv->domain_pulse_timeout); - - if (d->priv->service_pulse_timeout > 0) - g_source_remove(d->priv->service_pulse_timeout); - - if (d->priv->start_idle > 0) - g_source_remove(d->priv->start_idle); - - g_free(d->priv->host_name); - g_free(d->priv->domain); - g_free(d->priv->service_name); - - avahi_string_list_free(d->priv->txt_data); - - g_strfreev(d->priv->browse_service_types); - - if (d->priv->domain_browser) - avahi_domain_browser_free(d->priv->domain_browser); - - if (d->priv->resolver) - avahi_service_resolver_free(d->priv->resolver); - - if (d->priv->browsers) { - AvahiServiceBrowser **sb; - - for (sb = d->priv->browsers; *sb; sb++) - avahi_service_browser_free(*sb); - - g_free(d->priv->browsers); - } - - if (d->priv->client) - avahi_client_free(d->priv->client); - - if (d->priv->glib_poll) - avahi_glib_poll_free(d->priv->glib_poll); - - if (d->priv->service_list_store) - g_object_unref(d->priv->service_list_store); - if (d->priv->domain_list_store) - g_object_unref(d->priv->domain_list_store); - if (d->priv->service_type_names) - g_hash_table_unref (d->priv->service_type_names); - - g_free(d->priv); - d->priv = NULL; - - G_OBJECT_CLASS(aui_service_dialog_parent_class)->finalize(object); -} - -static void service_row_activated_callback(GtkTreeView *tree_view G_GNUC_UNUSED, GtkTreePath *path G_GNUC_UNUSED, GtkTreeViewColumn *column G_GNUC_UNUSED, gpointer user_data) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(user_data); - - gtk_dialog_response(GTK_DIALOG(d), get_default_response(GTK_DIALOG(d))); -} - -static void service_selection_changed_callback(GtkTreeSelection *selection, gpointer user_data) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(user_data); - gboolean b; - - b = gtk_tree_selection_get_selected(selection, NULL, NULL); - gtk_dialog_set_response_sensitive(GTK_DIALOG(d), GTK_RESPONSE_ACCEPT, b); - gtk_dialog_set_response_sensitive(GTK_DIALOG(d), GTK_RESPONSE_OK, b); - gtk_dialog_set_response_sensitive(GTK_DIALOG(d), GTK_RESPONSE_YES, b); - gtk_dialog_set_response_sensitive(GTK_DIALOG(d), GTK_RESPONSE_APPLY, b); -} - -static void response_callback(GtkDialog *dialog, gint response, gpointer user_data) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(user_data); - - if ((response == GTK_RESPONSE_ACCEPT || - response == GTK_RESPONSE_OK || - response == GTK_RESPONSE_YES || - response == GTK_RESPONSE_APPLY) && - ((d->priv->resolve_service && !d->priv->resolve_service_done) || - (d->priv->resolve_host_name && !d->priv->resolve_host_name_done))) { - - GtkTreeIter iter; - gint interface, protocol; - gchar *name, *type; - GdkCursor *cursor; - - g_signal_stop_emission(dialog, g_signal_lookup("response", gtk_dialog_get_type()), 0); - d->priv->forward_response_id = response; - - if (d->priv->resolver) - return; - - g_return_if_fail(gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(d->priv->service_tree_view)), NULL, &iter)); - - gtk_tree_model_get(GTK_TREE_MODEL(d->priv->service_list_store), &iter, - SERVICE_COLUMN_IFACE, &interface, - SERVICE_COLUMN_PROTO, &protocol, - SERVICE_COLUMN_NAME, &name, - SERVICE_COLUMN_TYPE, &type, -1); - - g_return_if_fail(d->priv->client); - - gtk_widget_set_sensitive(GTK_WIDGET(dialog), FALSE); - cursor = gdk_cursor_new(GDK_WATCH); - gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(dialog)), cursor); - g_object_unref(G_OBJECT(cursor)); - - if (!(d->priv->resolver = avahi_service_resolver_new( - d->priv->client, interface, protocol, name, type, d->priv->domain, - d->priv->address_family, !d->priv->resolve_host_name ? AVAHI_LOOKUP_NO_ADDRESS : 0, resolve_callback, d))) { - - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Failed to create resolver for %s of type %s in domain %s: %s"), - name, type, d->priv->domain, - avahi_strerror(avahi_client_errno(d->priv->client))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - return; - } - } -} - -static gboolean is_valid_domain_suffix(const gchar *n) { - gchar label[AVAHI_LABEL_MAX]; - - if (!avahi_is_valid_domain_name(n)) - return FALSE; - - if (!avahi_unescape_label(&n, label, sizeof(label))) - return FALSE; - - /* At least one label */ - - return !!label[0]; -} - -static void domain_row_activated_callback(GtkTreeView *tree_view G_GNUC_UNUSED, GtkTreePath *path G_GNUC_UNUSED, GtkTreeViewColumn *column G_GNUC_UNUSED, gpointer user_data) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(user_data); - - if (is_valid_domain_suffix(gtk_entry_get_text(GTK_ENTRY(d->priv->domain_entry)))) - gtk_dialog_response(GTK_DIALOG(d->priv->domain_dialog), GTK_RESPONSE_ACCEPT); -} - -static void domain_selection_changed_callback(GtkTreeSelection *selection G_GNUC_UNUSED, gpointer user_data) { - GtkTreeIter iter; - AuiServiceDialog *d = AUI_SERVICE_DIALOG(user_data); - gchar *name; - - g_return_if_fail(gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(d->priv->domain_tree_view)), NULL, &iter)); - - gtk_tree_model_get(GTK_TREE_MODEL(d->priv->domain_list_store), &iter, - DOMAIN_COLUMN_NAME, &name, -1); - - gtk_entry_set_text(GTK_ENTRY(d->priv->domain_entry), name); -} - -static void domain_entry_changed_callback(GtkEditable *editable G_GNUC_UNUSED, gpointer user_data) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(user_data); - - gtk_widget_set_sensitive(d->priv->domain_ok_button, is_valid_domain_suffix(gtk_entry_get_text(GTK_ENTRY(d->priv->domain_entry)))); -} - -static void domain_button_clicked(GtkButton *button G_GNUC_UNUSED, gpointer user_data) { - GtkWidget *vbox, *vbox2, *scrolled_window; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - AuiServiceDialog *d = AUI_SERVICE_DIALOG(user_data); - AuiServiceDialogPrivate *p = d->priv; - const gchar *domain; - GtkTreeIter iter; - - g_return_if_fail(!p->domain_dialog); - g_return_if_fail(!p->domain_browser); - - if (!(domain = get_domain_name(d))) { - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - return; - } - - if (!(p->domain_browser = avahi_domain_browser_new(p->client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, domain_browse_callback, d))) { - GtkWidget *m = gtk_message_dialog_new(GTK_WINDOW(d), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Failed to create domain browser: %s"), - avahi_strerror(avahi_client_errno(p->client))); - gtk_dialog_run(GTK_DIALOG(m)); - gtk_widget_destroy(m); - - gtk_dialog_response(GTK_DIALOG(d), GTK_RESPONSE_CANCEL); - return; - } - - p->domain_dialog = gtk_dialog_new(); - gtk_container_set_border_width(GTK_CONTAINER(p->domain_dialog), 5); - gtk_window_set_title(GTK_WINDOW(p->domain_dialog), _("Change domain")); -#if !GTK_CHECK_VERSION(2,21,8) - gtk_dialog_set_has_separator(GTK_DIALOG(p->domain_dialog), FALSE); -#endif - - vbox = gtk_vbox_new(FALSE, 8); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 8); - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(p->domain_dialog))), vbox, TRUE, TRUE, 0); - - p->domain_entry = gtk_entry_new(); - gtk_entry_set_max_length(GTK_ENTRY(p->domain_entry), AVAHI_DOMAIN_NAME_MAX); - gtk_entry_set_text(GTK_ENTRY(p->domain_entry), domain); - gtk_entry_set_activates_default(GTK_ENTRY(p->domain_entry), TRUE); - g_signal_connect(p->domain_entry, "changed", G_CALLBACK(domain_entry_changed_callback), d); - gtk_box_pack_start(GTK_BOX(vbox), p->domain_entry, FALSE, FALSE, 0); - - vbox2 = gtk_vbox_new(FALSE, 8); - gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0); - - scrolled_window = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN); - gtk_box_pack_start(GTK_BOX(vbox2), scrolled_window, TRUE, TRUE, 0); - - p->domain_list_store = gtk_list_store_new(N_DOMAIN_COLUMNS, G_TYPE_STRING, G_TYPE_INT); - - p->domain_tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(p->domain_list_store)); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(p->domain_tree_view), FALSE); - g_signal_connect(p->domain_tree_view, "row-activated", G_CALLBACK(domain_row_activated_callback), d); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(p->domain_tree_view)); - gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); - g_signal_connect(selection, "changed", G_CALLBACK(domain_selection_changed_callback), d); - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("Service Name"), renderer, "text", DOMAIN_COLUMN_NAME, NULL); - gtk_tree_view_column_set_expand(column, TRUE); - gtk_tree_view_append_column(GTK_TREE_VIEW(p->domain_tree_view), column); - - gtk_tree_view_set_search_column(GTK_TREE_VIEW(p->domain_tree_view), DOMAIN_COLUMN_NAME); - gtk_container_add(GTK_CONTAINER(scrolled_window), p->domain_tree_view); - - p->domain_progress_bar = gtk_progress_bar_new(); - gtk_progress_bar_set_text(GTK_PROGRESS_BAR(p->domain_progress_bar), _("Browsing...")); - gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(p->domain_progress_bar), 0.1); - gtk_box_pack_end(GTK_BOX(vbox2), p->domain_progress_bar, FALSE, FALSE, 0); - - gtk_dialog_add_button(GTK_DIALOG(p->domain_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - p->domain_ok_button = GTK_WIDGET(gtk_dialog_add_button(GTK_DIALOG(p->domain_dialog), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT)); - gtk_dialog_set_default_response(GTK_DIALOG(p->domain_dialog), GTK_RESPONSE_ACCEPT); - gtk_widget_set_sensitive(p->domain_ok_button, is_valid_domain_suffix(gtk_entry_get_text(GTK_ENTRY(p->domain_entry)))); - - gtk_widget_grab_default(p->domain_ok_button); - gtk_widget_grab_focus(p->domain_entry); - - gtk_window_set_default_size(GTK_WINDOW(p->domain_dialog), 300, 300); - - gtk_widget_show_all(vbox); - - gtk_list_store_append(p->domain_list_store, &iter); - gtk_list_store_set(p->domain_list_store, &iter, DOMAIN_COLUMN_NAME, "local", DOMAIN_COLUMN_REF, 1, -1); - domain_make_default_selection(d, "local", &iter); - - p->domain_pulse_timeout = g_timeout_add(100, domain_pulse_callback, d); - - if (gtk_dialog_run(GTK_DIALOG(p->domain_dialog)) == GTK_RESPONSE_ACCEPT) - aui_service_dialog_set_domain(d, gtk_entry_get_text(GTK_ENTRY(p->domain_entry))); - - gtk_widget_destroy(p->domain_dialog); - p->domain_dialog = NULL; - - if (p->domain_pulse_timeout > 0) { - g_source_remove(p->domain_pulse_timeout); - p->domain_pulse_timeout = 0; - } - - avahi_domain_browser_free(p->domain_browser); - p->domain_browser = NULL; -} - -static void aui_service_dialog_init(AuiServiceDialog *d) { - GtkWidget *vbox, *vbox2, *scrolled_window; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *selection; - AuiServiceDialogPrivate *p; - - p = d->priv = g_new(AuiServiceDialogPrivate, 1); - - p->host_name = NULL; - p->domain = NULL; - p->service_name = NULL; - p->service_type = NULL; - p->txt_data = NULL; - p->browse_service_types = NULL; - memset(&p->address, 0, sizeof(p->address)); - p->port = 0; - p->resolve_host_name = p->resolve_service = TRUE; - p->resolve_host_name_done = p->resolve_service_done = FALSE; - p->address_family = AVAHI_PROTO_UNSPEC; - - p->glib_poll = NULL; - p->client = NULL; - p->browsers = NULL; - p->resolver = NULL; - p->domain_browser = NULL; - - p->service_pulse_timeout = 0; - p->domain_pulse_timeout = 0; - p->start_idle = 0; - p->common_interface = AVAHI_IF_UNSPEC; - p->common_protocol = AVAHI_PROTO_UNSPEC; - - p->domain_dialog = NULL; - p->domain_entry = NULL; - p->domain_tree_view = NULL; - p->domain_progress_bar = NULL; - p->domain_ok_button = NULL; - - p->forward_response_id = GTK_RESPONSE_NONE; - - p->service_list_store = p->domain_list_store = NULL; - p->service_type_names = NULL; - - gtk_widget_push_composite_child(); - - gtk_container_set_border_width(GTK_CONTAINER(d), 5); - - vbox = gtk_vbox_new(FALSE, 8); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 8); - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(d))), vbox, TRUE, TRUE, 0); - - p->domain_label = gtk_label_new(_("Initializing...")); - gtk_label_set_ellipsize(GTK_LABEL(p->domain_label), TRUE); - gtk_misc_set_alignment(GTK_MISC(p->domain_label), 0, 0.5); - gtk_box_pack_start(GTK_BOX(vbox), p->domain_label, FALSE, FALSE, 0); - - - vbox2 = gtk_vbox_new(FALSE, 8); - gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0); - - scrolled_window = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN); - gtk_box_pack_start(GTK_BOX(vbox2), scrolled_window, TRUE, TRUE, 0); - - p->service_list_store = gtk_list_store_new(N_SERVICE_COLUMNS, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - - p->service_tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(p->service_list_store)); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(p->service_tree_view), FALSE); - g_signal_connect(p->service_tree_view, "row-activated", G_CALLBACK(service_row_activated_callback), d); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(p->service_tree_view)); - gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); - g_signal_connect(selection, "changed", G_CALLBACK(service_selection_changed_callback), d); - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", SERVICE_COLUMN_PRETTY_IFACE, NULL); - gtk_tree_view_column_set_visible(column, FALSE); - gtk_tree_view_append_column(GTK_TREE_VIEW(p->service_tree_view), column); - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, "text", SERVICE_COLUMN_NAME, NULL); - gtk_tree_view_column_set_expand(column, TRUE); - gtk_tree_view_append_column(GTK_TREE_VIEW(p->service_tree_view), column); - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("Type"), renderer, "text", SERVICE_COLUMN_PRETTY_TYPE, NULL); - gtk_tree_view_column_set_visible(column, FALSE); - gtk_tree_view_append_column(GTK_TREE_VIEW(p->service_tree_view), column); - - gtk_tree_view_set_search_column(GTK_TREE_VIEW(p->service_tree_view), SERVICE_COLUMN_NAME); - gtk_container_add(GTK_CONTAINER(scrolled_window), p->service_tree_view); - - p->service_progress_bar = gtk_progress_bar_new(); - gtk_progress_bar_set_text(GTK_PROGRESS_BAR(p->service_progress_bar), _("Browsing...")); - gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(p->service_progress_bar), 0.1); - gtk_box_pack_end(GTK_BOX(vbox2), p->service_progress_bar, FALSE, FALSE, 0); - - p->domain_button = gtk_button_new_with_mnemonic(_("_Domain...")); - gtk_button_set_image(GTK_BUTTON(p->domain_button), gtk_image_new_from_stock(GTK_STOCK_NETWORK, GTK_ICON_SIZE_BUTTON)); - g_signal_connect(p->domain_button, "clicked", G_CALLBACK(domain_button_clicked), d); - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(d))), p->domain_button, FALSE, TRUE, 0); - gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(gtk_dialog_get_action_area(GTK_DIALOG(d))), p->domain_button, TRUE); - gtk_widget_show(p->domain_button); - - gtk_dialog_set_default_response(GTK_DIALOG(d), GTK_RESPONSE_ACCEPT); - - gtk_widget_grab_focus(p->service_tree_view); - - gtk_window_set_default_size(GTK_WINDOW(d), 400, 300); - - gtk_widget_show_all(vbox); - - gtk_widget_pop_composite_child(); - - p->glib_poll = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT); - - p->service_pulse_timeout = g_timeout_add(100, service_pulse_callback, d); - p->start_idle = g_idle_add(start_callback, d); - - g_signal_connect(d, "response", G_CALLBACK(response_callback), d); -} - -static void restart_browsing(AuiServiceDialog *d) { - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - - if (d->priv->start_idle <= 0) - d->priv->start_idle = g_idle_add(start_callback, d); -} - -void aui_service_dialog_set_browse_service_types(AuiServiceDialog *d, const char *type, ...) { - va_list ap; - const char *t; - unsigned u; - - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - g_return_if_fail(type); - - g_strfreev(d->priv->browse_service_types); - - va_start(ap, type); - for (u = 1; va_arg(ap, const char *); u++) - ; - va_end(ap); - - d->priv->browse_service_types = g_new0(gchar*, u+1); - d->priv->browse_service_types[0] = g_strdup(type); - - va_start(ap, type); - for (u = 1; (t = va_arg(ap, const char*)); u++) - d->priv->browse_service_types[u] = g_strdup(t); - va_end(ap); - - if (d->priv->browse_service_types[0] && d->priv->browse_service_types[1]) { - /* Multiple service types, show type-column */ - gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(d->priv->service_tree_view), 2), TRUE); - } - - restart_browsing(d); -} - -void aui_service_dialog_set_browse_service_typesv(AuiServiceDialog *d, const char *const*types) { - - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - g_return_if_fail(types); - g_return_if_fail(*types); - - g_strfreev(d->priv->browse_service_types); - d->priv->browse_service_types = g_strdupv((char**) types); - - if (d->priv->browse_service_types[0] && d->priv->browse_service_types[1]) { - /* Multiple service types, show type-column */ - gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(d->priv->service_tree_view), 2), TRUE); - } - - restart_browsing(d); -} - -const gchar*const* aui_service_dialog_get_browse_service_types(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - - return (const char* const*) d->priv->browse_service_types; -} - -void aui_service_dialog_set_service_type_name(AuiServiceDialog *d, const gchar *type, const gchar *name) { - GtkTreeModel *m = NULL; - GtkTreeIter iter; - - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - g_return_if_fail(NULL != type); - g_return_if_fail(NULL != name); - - if (NULL == d->priv->service_type_names) - d->priv->service_type_names = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - - g_hash_table_insert(d->priv->service_type_names, g_strdup(type), g_strdup(name)); - - if (d->priv->service_list_store) - m = GTK_TREE_MODEL(d->priv->service_list_store); - - if (m && gtk_tree_model_get_iter_first(m, &iter)) { - do { - char *stored_type = NULL; - - gtk_tree_model_get(m, &iter, SERVICE_COLUMN_TYPE, &stored_type, -1); - - if (stored_type && g_str_equal(stored_type, type)) - gtk_list_store_set(d->priv->service_list_store, &iter, SERVICE_COLUMN_PRETTY_TYPE, name, -1); - } while (gtk_tree_model_iter_next(m, &iter)); - } -} - -void aui_service_dialog_set_domain(AuiServiceDialog *d, const char *domain) { - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - g_return_if_fail(!domain || is_valid_domain_suffix(domain)); - - g_free(d->priv->domain); - d->priv->domain = domain ? avahi_normalize_name_strdup(domain) : NULL; - - restart_browsing(d); -} - -const char* aui_service_dialog_get_domain(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - - return d->priv->domain; -} - -void aui_service_dialog_set_service_name(AuiServiceDialog *d, const char *name) { - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - - g_free(d->priv->service_name); - d->priv->service_name = g_strdup(name); -} - -const char* aui_service_dialog_get_service_name(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - - return d->priv->service_name; -} - -void aui_service_dialog_set_service_type(AuiServiceDialog *d, const char*stype) { - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - - g_free(d->priv->service_type); - d->priv->service_type = g_strdup(stype); -} - -const char* aui_service_dialog_get_service_type(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - - return d->priv->service_type; -} - -const AvahiAddress* aui_service_dialog_get_address(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - g_return_val_if_fail(d->priv->resolve_service_done && d->priv->resolve_host_name_done, NULL); - - return &d->priv->address; -} - -guint16 aui_service_dialog_get_port(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), 0); - g_return_val_if_fail(d->priv->resolve_service_done, 0); - - return d->priv->port; -} - -const char* aui_service_dialog_get_host_name(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - g_return_val_if_fail(d->priv->resolve_service_done, NULL); - - return d->priv->host_name; -} - -const AvahiStringList *aui_service_dialog_get_txt_data(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), NULL); - g_return_val_if_fail(d->priv->resolve_service_done, NULL); - - return d->priv->txt_data; -} - -void aui_service_dialog_set_resolve_service(AuiServiceDialog *d, gboolean resolve) { - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - - d->priv->resolve_service = resolve; -} - -gboolean aui_service_dialog_get_resolve_service(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), FALSE); - - return d->priv->resolve_service; -} - -void aui_service_dialog_set_resolve_host_name(AuiServiceDialog *d, gboolean resolve) { - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - - d->priv->resolve_host_name = resolve; -} - -gboolean aui_service_dialog_get_resolve_host_name(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), FALSE); - - return d->priv->resolve_host_name; -} - -void aui_service_dialog_set_address_family(AuiServiceDialog *d, AvahiProtocol proto) { - g_return_if_fail(AUI_IS_SERVICE_DIALOG(d)); - g_return_if_fail(proto == AVAHI_PROTO_UNSPEC || proto == AVAHI_PROTO_INET || proto == AVAHI_PROTO_INET6); - - d->priv->address_family = proto; -} - -AvahiProtocol aui_service_dialog_get_address_family(AuiServiceDialog *d) { - g_return_val_if_fail(AUI_IS_SERVICE_DIALOG(d), AVAHI_PROTO_UNSPEC); - - return d->priv->address_family; -} - -static void aui_service_dialog_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(object); - - switch (prop_id) { - case PROP_BROWSE_SERVICE_TYPES: - aui_service_dialog_set_browse_service_typesv(d, g_value_get_pointer(value)); - break; - - case PROP_DOMAIN: - aui_service_dialog_set_domain(d, g_value_get_string(value)); - break; - - case PROP_SERVICE_TYPE: - aui_service_dialog_set_service_type(d, g_value_get_string(value)); - break; - - case PROP_SERVICE_NAME: - aui_service_dialog_set_service_name(d, g_value_get_string(value)); - break; - - case PROP_RESOLVE_SERVICE: - aui_service_dialog_set_resolve_service(d, g_value_get_boolean(value)); - break; - - case PROP_RESOLVE_HOST_NAME: - aui_service_dialog_set_resolve_host_name(d, g_value_get_boolean(value)); - break; - - case PROP_ADDRESS_FAMILY: - aui_service_dialog_set_address_family(d, g_value_get_int(value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void aui_service_dialog_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - AuiServiceDialog *d = AUI_SERVICE_DIALOG(object); - - switch (prop_id) { - case PROP_BROWSE_SERVICE_TYPES: - g_value_set_pointer(value, (gpointer) aui_service_dialog_get_browse_service_types(d)); - break; - - case PROP_DOMAIN: - g_value_set_string(value, aui_service_dialog_get_domain(d)); - break; - - case PROP_SERVICE_TYPE: - g_value_set_string(value, aui_service_dialog_get_service_type(d)); - break; - - case PROP_SERVICE_NAME: - g_value_set_string(value, aui_service_dialog_get_service_name(d)); - break; - - case PROP_ADDRESS: - g_value_set_pointer(value, (gpointer) aui_service_dialog_get_address(d)); - break; - - case PROP_PORT: - g_value_set_uint(value, aui_service_dialog_get_port(d)); - break; - - case PROP_HOST_NAME: - g_value_set_string(value, aui_service_dialog_get_host_name(d)); - break; - - case PROP_TXT_DATA: - g_value_set_pointer(value, (gpointer) aui_service_dialog_get_txt_data(d)); - break; - - case PROP_RESOLVE_SERVICE: - g_value_set_boolean(value, aui_service_dialog_get_resolve_service(d)); - break; - - case PROP_RESOLVE_HOST_NAME: - g_value_set_boolean(value, aui_service_dialog_get_resolve_host_name(d)); - break; - - case PROP_ADDRESS_FAMILY: - g_value_set_int(value, aui_service_dialog_get_address_family(d)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} diff --git a/avahi-ui/avahi-ui.h b/avahi-ui/avahi-ui.h deleted file mode 100644 index aae61dc..0000000 --- a/avahi-ui/avahi-ui.h +++ /dev/null @@ -1,181 +0,0 @@ -#ifndef fooavahiuihfoo -#define fooavahiuihfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -#include - -/** \file avahi-ui.h A Gtk dialog for browsing for services */ - -G_BEGIN_DECLS - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -#define AUI_TYPE_SERVICE_DIALOG (aui_service_dialog_get_type()) -#define AUI_SERVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialog)) -#define AUI_SERVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialogClass)) -#define AUI_IS_SERVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AUI_TYPE_SERVICE_DIALOG)) -#define AUI_IS_SERVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), AUI_TYPE_SERVICE_DIALOG)) -#define AUI_SERVICE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialogClass)) - -typedef struct _AuiServiceDialogPrivate AuiServiceDialogPrivate; -typedef struct _AuiServiceDialogClass AuiServiceDialogClass; - -struct _AuiServiceDialogClass { - GtkDialogClass parent_class; - - /* Padding for future expansion */ - void (*_aui_reserved1)(void); - void (*_aui_reserved2)(void); - void (*_aui_reserved3)(void); - void (*_aui_reserved4)(void); -}; - -struct _AuiServiceDialog { - GtkDialog parent_instance; - AuiServiceDialogPrivate *priv; -}; - -/* ServiceDialog */ -GType aui_service_dialog_get_type(void) G_GNUC_CONST; - -#endif - -/** The GTK service dialog structure */ -typedef struct _AuiServiceDialog AuiServiceDialog; - -/** @{ \name Construction */ - -/** Create a new service browser dialog with the specific title, - * parent window and the speicified buttons. The buttons are specified - * in a similar way to GtkFileChooserDialog. Please note that at least - * one button has to respond GTK_RESPONSE_ACCEPT. */ -GtkWidget* aui_service_dialog_new( - const gchar *title, - GtkWindow *parent, - const gchar *first_button_text, ...) G_GNUC_NULL_TERMINATED; - -/** \cond fulldocs */ -GtkWidget *aui_service_dialog_new_valist( - const gchar *title, - GtkWindow *parent, - const gchar *first_button_text, - va_list varargs); -/** \endcond */ - -/** @} */ - -/** @{ \name Service types to browse for */ - -/** Select the service types to browse for. Takes a NULL terminated list of DNS-SD service types. i.e. _http._tcp */ -void aui_service_dialog_set_browse_service_types(AuiServiceDialog *d, const gchar *type, ...) G_GNUC_NULL_TERMINATED; -/** Same as aui_service_dialog_set_browse_service_types() but take a NULL terminated array */ -void aui_service_dialog_set_browse_service_typesv(AuiServiceDialog *d, const gchar *const*type); -/** Return the service types currently browsed for. i.e. what was previously set with aui_service_dialog_set_browse_service_types() */ -const gchar*const* aui_service_dialog_get_browse_service_types(AuiServiceDialog *d); -/** Overwrite the pretty name shown in the service type column. \since 0.6.22 */ -void aui_service_dialog_set_service_type_name(AuiServiceDialog *d, const gchar *type, const gchar *name); - -/** @} */ - -/** @{ \name Domain to browse in */ - -/** Set the domain to browse in */ -void aui_service_dialog_set_domain(AuiServiceDialog *d, const gchar *domain); -/** Query the domain that is browsed in */ -const gchar* aui_service_dialog_get_domain(AuiServiceDialog *d); - -/** @} */ - -/** @{ \name Selected service item */ - -/** Set the service type for the service to select */ -void aui_service_dialog_set_service_type(AuiServiceDialog *d, const gchar *name); - -/** Query the service type of the currently selected service */ -const gchar* aui_service_dialog_get_service_type(AuiServiceDialog *d); - -/** Set the service name for the service to select */ -void aui_service_dialog_set_service_name(AuiServiceDialog *d, const gchar *name); - -/** Query the service name of the currently select service */ -const gchar* aui_service_dialog_get_service_name(AuiServiceDialog *d); - -/** @} */ - -/** @{ \name Resolved service information */ - -/** Return the IP address of the selected service. (Only valid if host name resolving has not been disabled via aui_service_dialog_set_resolve_host_name()) */ -const AvahiAddress* aui_service_dialog_get_address(AuiServiceDialog *d); - -/** Return the IP port number of the selected service */ -guint16 aui_service_dialog_get_port(AuiServiceDialog *d); - -/** Return the host name of the selected service */ -const gchar* aui_service_dialog_get_host_name(AuiServiceDialog *d); - -/** Return the TXT metadata of the selected service */ -const AvahiStringList *aui_service_dialog_get_txt_data(AuiServiceDialog *d); - -/** @} */ - -/** @{ \name Resolving settings */ - -/** Disable/Enable automatic service resolving. Disabling this feature - * will require you to resolve the selected service on our own. I.e. the port - * number, the TXT data and the host name/IP address will not be - * available after a service has been selected. This functionality - * offers a certain optimization in the traffic imposed on the - * network. Most people will not want to touch this. */ -void aui_service_dialog_set_resolve_service(AuiServiceDialog *d, gboolean resolve); - -/** Query the last status of aui_service_dialog_set_resolve_service() */ -gboolean aui_service_dialog_get_resolve_service(AuiServiceDialog *d); - -/** Disable/Enable automatic host name resolving. Disabling this - * feature will cause aui_service_dialog_get_address() return NULL in - * all case because avahi-ui will not resolve the host name of the - * selected service to an address. This is a slight optimization - * regarding the traffic imposed by this query to the network. By - * default, avahi-ui will resolve the host names of selected services. */ -void aui_service_dialog_set_resolve_host_name(AuiServiceDialog *d, gboolean resolve); - -/** Query the last status of aui_service_dialog_set_resolve_host_name() */ -gboolean aui_service_dialog_get_resolve_host_name(AuiServiceDialog *d); - -/** @} */ - -/** @{ \name Address family */ - -/** Select the address family to look for services of. This can be -used to look only for IPv6 services or only for IPv4 services. By -default avahi-ui will browse for both IPv4 and IPv6 services.*/ -void aui_service_dialog_set_address_family(AuiServiceDialog *d, AvahiProtocol proto); - -/** Query the address family we're looking for. */ -AvahiProtocol aui_service_dialog_get_address_family(AuiServiceDialog *d); - -/** @} */ - -G_END_DECLS - -#endif diff --git a/avahi-ui/bssh.c b/avahi-ui/bssh.c deleted file mode 100644 index 491380f..0000000 --- a/avahi-ui/bssh.c +++ /dev/null @@ -1,256 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "avahi-ui.h" - -typedef enum { - COMMAND_HELP, - COMMAND_SSH, - COMMAND_VNC, - COMMAND_SHELL -} Command; - -typedef struct Config { - char *domain; - Command command; -} Config; - -static void help(FILE *f, const char *argv0) { - fprintf(f, - _("%s [options]\n\n" - " -h --help Show this help\n" - " -s --ssh Browse SSH servers\n" - " -v --vnc Browse VNC servers\n" - " -S --shell Browse both SSH and VNC\n" - " -d --domain=DOMAIN The domain to browse in\n"), - argv0); -} - -static int parse_command_line(Config *c, int argc, char *argv[]) { - int o; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "ssh", no_argument, NULL, 's' }, - { "vnc", no_argument, NULL, 'v' }, - { "shell", no_argument, NULL, 'S' }, - { "domain", required_argument, NULL, 'd' }, - { NULL, 0, NULL, 0 } - }; - - while ((o = getopt_long(argc, argv, "hVd:svS", long_options, NULL)) >= 0) { - - switch(o) { - case 'h': - c->command = COMMAND_HELP; - break; - case 's': - c->command = COMMAND_SSH; - break; - case 'v': - c->command = COMMAND_VNC; - break; - case 'S': - c->command = COMMAND_SHELL; - break; - case 'd': - avahi_free(c->domain); - c->domain = avahi_strdup(optarg); - break; - default: - return -1; - } - } - - if (optind < argc) { - fprintf(stderr, _("Too many arguments\n")); - return -1; - } - - return 0; -} - -int main(int argc, char*argv[]) { - GtkWidget *d; - Config config; - const char *argv0; - - avahi_init_i18n(); - setlocale(LC_ALL, ""); - - if ((argv0 = strrchr(argv[0], '/'))) - argv0++; - else - argv0 = argv[0]; - - if (g_str_has_suffix(argv[0], "bshell")) - config.command = COMMAND_SHELL; - else if (g_str_has_suffix(argv[0], "bvnc")) - config.command = COMMAND_VNC; - else - config.command = COMMAND_SSH; - - /* defaults to local */ - config.domain = NULL; - - if (parse_command_line(&config, argc, argv) < 0) { - help(stderr, argv0); - return 1; - } - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - gtk_init(&argc, &argv); - - switch (config.command) { - case COMMAND_HELP: - help(stdout, argv0); - return 0; - break; - - case COMMAND_SHELL: - d = aui_service_dialog_new(_("Choose Shell Server"), NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, NULL); - aui_service_dialog_set_browse_service_types(AUI_SERVICE_DIALOG(d), "_rfb._tcp", "_ssh._tcp", NULL); - aui_service_dialog_set_service_type_name(AUI_SERVICE_DIALOG(d), "_rfb._tcp", _("Desktop")); - aui_service_dialog_set_service_type_name(AUI_SERVICE_DIALOG(d), "_ssh._tcp", _("Terminal")); - break; - - case COMMAND_VNC: - d = aui_service_dialog_new(_("Choose VNC server"), NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, NULL); - aui_service_dialog_set_browse_service_types(AUI_SERVICE_DIALOG(d), "_rfb._tcp", NULL); - break; - - case COMMAND_SSH: - d = aui_service_dialog_new(_("Choose SSH server"), NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, NULL); - aui_service_dialog_set_browse_service_types(AUI_SERVICE_DIALOG(d), "_ssh._tcp", NULL); - break; - } - - aui_service_dialog_set_domain (AUI_SERVICE_DIALOG(d), config.domain); - aui_service_dialog_set_resolve_service(AUI_SERVICE_DIALOG(d), TRUE); - aui_service_dialog_set_resolve_host_name(AUI_SERVICE_DIALOG(d), !avahi_nss_support()); - - gtk_window_present(GTK_WINDOW(d)); - - if (gtk_dialog_run(GTK_DIALOG(d)) == GTK_RESPONSE_ACCEPT) { - char a[AVAHI_ADDRESS_STR_MAX], *u = NULL, *n = NULL; - char *h = NULL, *t = NULL; - const AvahiStringList *txt; - - t = g_strdup(aui_service_dialog_get_service_type(AUI_SERVICE_DIALOG(d))); - n = g_strdup(aui_service_dialog_get_service_name(AUI_SERVICE_DIALOG(d))); - - if (avahi_nss_support()) - h = g_strdup(aui_service_dialog_get_host_name(AUI_SERVICE_DIALOG(d))); - else - h = g_strdup(avahi_address_snprint(a, sizeof(a), aui_service_dialog_get_address(AUI_SERVICE_DIALOG(d)))); - - g_print(_("Connecting to '%s' ...\n"), n); - - if (avahi_domain_equal(t, "_rfb._tcp")) { - char p[AVAHI_DOMAIN_NAME_MAX+16]; - snprintf(p, sizeof(p), "%s:%u", h, aui_service_dialog_get_port(AUI_SERVICE_DIALOG(d))-5900); - - gtk_widget_destroy(d); - - g_print("vncviewer %s\n", p); - execlp("xvncviewer", "xvncviewer", p, NULL); - execlp("vncviewer", "vncviewer", p, NULL); - - } else { - char p[16]; - - snprintf(p, sizeof(p), "%u", aui_service_dialog_get_port(AUI_SERVICE_DIALOG(d))); - - for (txt = aui_service_dialog_get_txt_data(AUI_SERVICE_DIALOG(d)); txt; txt = txt->next) { - char *key, *value; - - if (avahi_string_list_get_pair((AvahiStringList*) txt, &key, &value, NULL) < 0) - break; - - if (strcmp(key, "u") == 0) - u = g_strdup(value); - - avahi_free(key); - avahi_free(value); - } - - gtk_widget_destroy(d); - - if (u) { - g_print("ssh -p %s -l %s %s\n", p, u, h); - - if (isatty(0) || !getenv("DISPLAY")) - execlp("ssh", "ssh", "-p", p, "-l", u, h, NULL); - else { - execlp("x-terminal-emulator", "x-terminal-emulator", "-T", n, "-e", "ssh", "-p", p, "-l", u, h, NULL); - execlp("gnome-terminal", "gnome-terminal", "-t", n, "-x", "ssh", "-p", p, "-l", u, h, NULL); - execlp("xterm", "xterm", "-T", n, "-e", "ssh", "-p", p, "-l", u, h, NULL); - } - } else { - g_print("ssh -p %s %s\n", p, h); - - if (isatty(0) || !getenv("DISPLAY")) - execlp("ssh", "ssh", "-p", p, h, NULL); - else { - execlp("x-terminal-emulator", "x-terminal-emulator", "-T", n, "-e", "ssh", "-p", p, h, NULL); - execlp("gnome-terminal", "gnome-terminal", "-t", n, "-x", "ssh", "-p", p, h, NULL); - execlp("xterm", "xterm", "-T", n, "-e", "ssh", "-p", p, h, NULL); - } - } - } - - g_warning(_("execlp() failed: %s\n"), strerror(errno)); - - g_free(h); - g_free(u); - g_free(t); - g_free(n); - - } else { - gtk_widget_destroy(d); - - g_print(_("Canceled.\n")); - } - - g_free(config.domain); - - return 1; -} diff --git a/avahi-ui/bssh.desktop.in.in b/avahi-ui/bssh.desktop.in.in deleted file mode 100644 index a4e54fe..0000000 --- a/avahi-ui/bssh.desktop.in.in +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Version=1.0 -_Name=Avahi SSH Server Browser -_Comment=Browse for Zeroconf-enabled SSH Servers -Exec=@bindir@/bssh -Terminal=false -Type=Application -Icon=network-wired -Categories=GNOME;Network; -StartupNotify=false -GenericName= diff --git a/avahi-ui/bvnc.desktop.in.in b/avahi-ui/bvnc.desktop.in.in deleted file mode 100644 index 92b8247..0000000 --- a/avahi-ui/bvnc.desktop.in.in +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Version=1.0 -_Name=Avahi VNC Server Browser -_Comment=Browse for Zeroconf-enabled VNC Servers -Exec=@bindir@/bvnc -Terminal=false -Type=Application -Icon=network-wired -Categories=GNOME;Network; -StartupNotify=false -GenericName= diff --git a/avahi-utils/.gitignore b/avahi-utils/.gitignore deleted file mode 100644 index fecb9e1..0000000 --- a/avahi-utils/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -*.o -*.lo -Makefile -Makefile.in -.deps -.libs -avahi-browse -avahi-publish -avahi-resolve -avahi-set-host-name diff --git a/avahi-utils/Makefile.am b/avahi-utils/Makefile.am deleted file mode 100644 index 66c4cc6..0000000 --- a/avahi-utils/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS=-I$(top_srcdir) - -# This cool debug trap works on i386/gcc only -AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' - -pkglibdatadir=$(libdir)/avahi - -if HAVE_DBUS - -bin_PROGRAMS = avahi-browse avahi-resolve avahi-publish avahi-set-host-name - -avahi_browse_SOURCES = avahi-browse.c sigint.c sigint.h -avahi_browse_CFLAGS = $(AM_CFLAGS) -avahi_browse_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la - -if HAVE_GDBM -avahi_browse_SOURCES += stdb.h stdb.c -avahi_browse_CFLAGS += -DDATABASE_FILE=\"$(pkglibdatadir)/service-types.db\" -avahi_browse_LDADD += -lgdbm -endif - -if HAVE_DBM -avahi_browse_SOURCES += stdb.h stdb.c -avahi_browse_CFLAGS += -DDATABASE_FILE=\"$(pkglibdatadir)/service-types.db\" -endif - -avahi_resolve_SOURCES = avahi-resolve.c sigint.c sigint.h -avahi_resolve_CFLAGS = $(AM_CFLAGS) -avahi_resolve_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la - -avahi_publish_SOURCES = avahi-publish.c sigint.c sigint.h -avahi_publish_CFLAGS = $(AM_CFLAGS) -avahi_publish_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la - -avahi_set_host_name_SOURCES = avahi-set-host-name.c sigint.c sigint.h -avahi_set_host_name_CFLAGS = $(AM_CFLAGS) -avahi_set_host_name_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la - -install-exec-local: - $(MKDIR_P) $(DESTDIR)/$(bindir) && \ - cd $(DESTDIR)/$(bindir) && \ - rm -f avahi-resolve-host-name avahi-resolve-address avahi-browse-domains avahi-publish-address avahi-publish-service && \ - $(LN_S) avahi-resolve avahi-resolve-host-name && \ - $(LN_S) avahi-resolve avahi-resolve-address && \ - $(LN_S) avahi-browse avahi-browse-domains && \ - $(LN_S) avahi-publish avahi-publish-address && \ - $(LN_S) avahi-publish avahi-publish-service - -endif diff --git a/avahi-utils/avahi-browse.c b/avahi-utils/avahi-browse.c deleted file mode 100644 index 4101895..0000000 --- a/avahi-utils/avahi-browse.c +++ /dev/null @@ -1,879 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sigint.h" - -#if defined(HAVE_GDBM) || defined(HAVE_DBM) -#include "stdb.h" -#endif - -typedef enum { - COMMAND_HELP, - COMMAND_VERSION, - COMMAND_BROWSE_SERVICES, - COMMAND_BROWSE_ALL_SERVICES, - COMMAND_BROWSE_DOMAINS -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - , COMMAND_DUMP_STDB -#endif -} Command; - -typedef struct Config { - int verbose; - int terminate_on_all_for_now; - int terminate_on_cache_exhausted; - char *domain; - char *stype; - int ignore_local; - Command command; - int resolve; - int no_fail; - int parsable; -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - int no_db_lookup; -#endif -} Config; - -typedef struct ServiceInfo ServiceInfo; - -struct ServiceInfo { - AvahiIfIndex interface; - AvahiProtocol protocol; - char *name, *type, *domain; - - AvahiServiceResolver *resolver; - Config *config; - - AVAHI_LLIST_FIELDS(ServiceInfo, info); -}; - -static AvahiSimplePoll *simple_poll = NULL; -static AvahiClient *client = NULL; -static int n_all_for_now = 0, n_cache_exhausted = 0, n_resolving = 0; -static AvahiStringList *browsed_types = NULL; -static ServiceInfo *services = NULL; -static int n_columns = 80; -static int browsing = 0; - -static void check_terminate(Config *c) { - - assert(n_all_for_now >= 0); - assert(n_cache_exhausted >= 0); - assert(n_resolving >= 0); - - if (n_all_for_now <= 0 && n_resolving <= 0) { - - if (c->verbose && !c->parsable) { - printf(_(": All for now\n")); - n_all_for_now++; /* Make sure that this event is not repeated */ - } - - if (c->terminate_on_all_for_now) - avahi_simple_poll_quit(simple_poll); - } - - if (n_cache_exhausted <= 0 && n_resolving <= 0) { - - if (c->verbose && !c->parsable) { - printf(_(": Cache exhausted\n")); - n_cache_exhausted++; /* Make sure that this event is not repeated */ - } - - if (c->terminate_on_cache_exhausted) - avahi_simple_poll_quit(simple_poll); - } -} - -static ServiceInfo *find_service(AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) { - ServiceInfo *i; - - for (i = services; i; i = i->info_next) - if (i->interface == interface && - i->protocol == protocol && - strcasecmp(i->name, name) == 0 && - avahi_domain_equal(i->type, type) && - avahi_domain_equal(i->domain, domain)) - - return i; - - return NULL; -} - -static char *make_printable(const char *from, char *to) { - const char *f; - char *t; - - for (f = from, t = to; *f; f++, t++) - *t = isprint(*f) ? *f : '_'; - - *t = 0; - - return to; -} - -static void print_service_line(Config *config, char c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, int nl) { - char ifname[IF_NAMESIZE]; - -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - if (!config->no_db_lookup) - type = stdb_lookup(type); -#endif - - if (config->parsable) { - char sn[AVAHI_DOMAIN_NAME_MAX], *e = sn; - size_t l = sizeof(sn); - - printf("%c;%s;%s;%s;%s;%s%s", - c, - interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : _("n/a"), - protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : _("n/a"), - avahi_escape_label(name, strlen(name), &e, &l), type, domain, nl ? "\n" : ""); - - } else { - char label[AVAHI_LABEL_MAX]; - make_printable(name, label); - - printf("%c %6s %4s %-*s %-20s %s\n", - c, - interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : _("n/a"), - protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : _("n/a"), - n_columns-35, label, type, domain); - } - - fflush(stdout); -} - -static void service_resolver_callback( - AvahiServiceResolver *r, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *a, - uint16_t port, - AvahiStringList *txt, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - ServiceInfo *i = userdata; - - assert(r); - assert(i); - - switch (event) { - case AVAHI_RESOLVER_FOUND: { - char address[AVAHI_ADDRESS_STR_MAX], *t; - - avahi_address_snprint(address, sizeof(address), a); - - t = avahi_string_list_to_string(txt); - - print_service_line(i->config, '=', interface, protocol, name, type, domain, 0); - - if (i->config->parsable) - printf(";%s;%s;%u;%s\n", - host_name, - address, - port, - t); - else - printf(" hostname = [%s]\n" - " address = [%s]\n" - " port = [%u]\n" - " txt = [%s]\n", - host_name, - address, - port, - t); - - avahi_free(t); - - break; - } - - case AVAHI_RESOLVER_FAILURE: - - fprintf(stderr, _("Failed to resolve service '%s' of type '%s' in domain '%s': %s\n"), name, type, domain, avahi_strerror(avahi_client_errno(client))); - break; - } - - - avahi_service_resolver_free(i->resolver); - i->resolver = NULL; - - assert(n_resolving > 0); - n_resolving--; - check_terminate(i->config); - fflush(stdout); -} - -static ServiceInfo *add_service(Config *c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) { - ServiceInfo *i; - - i = avahi_new(ServiceInfo, 1); - - if (c->resolve) { - if (!(i->resolver = avahi_service_resolver_new(client, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, service_resolver_callback, i))) { - avahi_free(i); - fprintf(stderr, _("Failed to resolve service '%s' of type '%s' in domain '%s': %s\n"), name, type, domain, avahi_strerror(avahi_client_errno(client))); - return NULL; - } - - n_resolving++; - } else - i->resolver = NULL; - - i->interface = interface; - i->protocol = protocol; - i->name = avahi_strdup(name); - i->type = avahi_strdup(type); - i->domain = avahi_strdup(domain); - i->config = c; - - AVAHI_LLIST_PREPEND(ServiceInfo, info, services, i); - - return i; -} - -static void remove_service(Config *c, ServiceInfo *i) { - assert(c); - assert(i); - - AVAHI_LLIST_REMOVE(ServiceInfo, info, services, i); - - if (i->resolver) - avahi_service_resolver_free(i->resolver); - - avahi_free(i->name); - avahi_free(i->type); - avahi_free(i->domain); - avahi_free(i); -} - -static void service_browser_callback( - AvahiServiceBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - const char *type, - const char *domain, - AvahiLookupResultFlags flags, - void *userdata) { - - Config *c = userdata; - - assert(b); - assert(c); - - switch (event) { - case AVAHI_BROWSER_NEW: { - if (c->ignore_local && (flags & AVAHI_LOOKUP_RESULT_LOCAL)) - break; - - if (find_service(interface, protocol, name, type, domain)) - return; - - add_service(c, interface, protocol, name, type, domain); - - print_service_line(c, '+', interface, protocol, name, type, domain, 1); - break; - - } - - case AVAHI_BROWSER_REMOVE: { - ServiceInfo *info; - - if (!(info = find_service(interface, protocol, name, type, domain))) - return; - - remove_service(c, info); - - print_service_line(c, '-', interface, protocol, name, type, domain, 1); - break; - } - - case AVAHI_BROWSER_FAILURE: - fprintf(stderr, _("service_browser failed: %s\n"), avahi_strerror(avahi_client_errno(client))); - avahi_simple_poll_quit(simple_poll); - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - n_cache_exhausted --; - check_terminate(c); - break; - - case AVAHI_BROWSER_ALL_FOR_NOW: - n_all_for_now --; - check_terminate(c); - break; - } -} - -static void browse_service_type(Config *c, const char *stype, const char *domain) { - AvahiServiceBrowser *b; - AvahiStringList *i; - - assert(c); - assert(client); - assert(stype); - - for (i = browsed_types; i; i = i->next) - if (avahi_domain_equal(stype, (char*) i->text)) - return; - - if (!(b = avahi_service_browser_new( - client, - AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, - stype, - domain, - 0, - service_browser_callback, - c))) { - - fprintf(stderr, _("avahi_service_browser_new() failed: %s\n"), avahi_strerror(avahi_client_errno(client))); - avahi_simple_poll_quit(simple_poll); - } - - browsed_types = avahi_string_list_add(browsed_types, stype); - - n_all_for_now++; - n_cache_exhausted++; -} - -static void service_type_browser_callback( - AvahiServiceTypeBrowser *b, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - Config *c = userdata; - - assert(b); - assert(c); - - switch (event) { - - case AVAHI_BROWSER_NEW: - browse_service_type(c, type, domain); - break; - - case AVAHI_BROWSER_REMOVE: - /* We're dirty and never remove the browser again */ - break; - - case AVAHI_BROWSER_FAILURE: - fprintf(stderr, _("service_type_browser failed: %s\n"), avahi_strerror(avahi_client_errno(client))); - avahi_simple_poll_quit(simple_poll); - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - n_cache_exhausted --; - check_terminate(c); - break; - - case AVAHI_BROWSER_ALL_FOR_NOW: - n_all_for_now --; - check_terminate(c); - break; - } -} - -static void browse_all(Config *c) { - AvahiServiceTypeBrowser *b; - - assert(c); - - if (!(b = avahi_service_type_browser_new( - client, - AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, - c->domain, - 0, - service_type_browser_callback, - c))) { - - fprintf(stderr, _("avahi_service_type_browser_new() failed: %s\n"), avahi_strerror(avahi_client_errno(client))); - avahi_simple_poll_quit(simple_poll); - } - - n_cache_exhausted++; - n_all_for_now++; -} - -static void domain_browser_callback( - AvahiDomainBrowser *b, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void *userdata) { - - Config *c = userdata; - - assert(b); - assert(c); - - switch (event) { - - case AVAHI_BROWSER_NEW: - case AVAHI_BROWSER_REMOVE: { - char ifname[IF_NAMESIZE]; - - if (c->parsable) - printf("%c;%s;%s;%s\n", - event == AVAHI_BROWSER_NEW ? '+' : '-', - interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : "", - protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : "", - domain); - else - printf("%c %4s %4s %s\n", - event == AVAHI_BROWSER_NEW ? '+' : '-', - interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : "n/a", - protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : "n/a", - domain); - break; - } - - case AVAHI_BROWSER_FAILURE: - fprintf(stderr, ("domain_browser failed: %s\n"), avahi_strerror(avahi_client_errno(client))); - avahi_simple_poll_quit(simple_poll); - break; - - case AVAHI_BROWSER_CACHE_EXHAUSTED: - n_cache_exhausted --; - check_terminate(c); - break; - - case AVAHI_BROWSER_ALL_FOR_NOW: - n_all_for_now --; - check_terminate(c); - break; - } -} - -static void browse_domains(Config *c) { - AvahiDomainBrowser *b; - - assert(c); - - if (!(b = avahi_domain_browser_new( - client, - AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, - c->domain, - AVAHI_DOMAIN_BROWSER_BROWSE, - 0, - domain_browser_callback, - c))) { - - fprintf(stderr, _("avahi_domain_browser_new() failed: %s\n"), avahi_strerror(avahi_client_errno(client))); - avahi_simple_poll_quit(simple_poll); - } - - n_cache_exhausted++; - n_all_for_now++; -} - -static int start(Config *config) { - - assert(!browsing); - - if (config->verbose && !config->parsable) { - const char *version, *hn; - - if (!(version = avahi_client_get_version_string(client))) { - fprintf(stderr, _("Failed to query version string: %s\n"), avahi_strerror(avahi_client_errno(client))); - return -1; - } - - if (!(hn = avahi_client_get_host_name_fqdn(client))) { - fprintf(stderr, _("Failed to query host name: %s\n"), avahi_strerror(avahi_client_errno(client))); - return -1; - } - - fprintf(stderr, _("Server version: %s; Host name: %s\n"), version, hn); - - if (config->command == COMMAND_BROWSE_DOMAINS) { - /* Translators: This is a column heading with abbreviations for - * Event (+/-), Network Interface, Protocol (IPv4/v6), Domain */ - fprintf(stderr, _("E Ifce Prot Domain\n")); - } else { - /* Translators: This is a column heading with abbreviations for - * Event (+/-), Network Interface, Protocol (IPv4/v6), Domain */ - fprintf(stderr, _("E Ifce Prot %-*s %-20s Domain\n"), n_columns-35, _("Name"), _("Type")); - } - } - - if (config->command == COMMAND_BROWSE_SERVICES) - browse_service_type(config, config->stype, config->domain); - else if (config->command == COMMAND_BROWSE_ALL_SERVICES) - browse_all(config); - else { - assert(config->command == COMMAND_BROWSE_DOMAINS); - browse_domains(config); - } - - browsing = 1; - return 0; -} - -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { - Config *config = userdata; - - /* This function might be called when avahi_client_new() has not - * returned yet.*/ - client = c; - - switch (state) { - case AVAHI_CLIENT_FAILURE: - - if (config->no_fail && avahi_client_errno(c) == AVAHI_ERR_DISCONNECTED) { - int error; - - /* We have been disconnected, so let reconnect */ - - fprintf(stderr, _("Disconnected, reconnecting ...\n")); - - avahi_client_free(client); - client = NULL; - - avahi_string_list_free(browsed_types); - browsed_types = NULL; - - while (services) - remove_service(config, services); - - browsing = 0; - - if (!(client = avahi_client_new(avahi_simple_poll_get(simple_poll), AVAHI_CLIENT_NO_FAIL, client_callback, config, &error))) { - fprintf(stderr, _("Failed to create client object: %s\n"), avahi_strerror(error)); - avahi_simple_poll_quit(simple_poll); - } - - } else { - fprintf(stderr, _("Client failure, exiting: %s\n"), avahi_strerror(avahi_client_errno(c))); - avahi_simple_poll_quit(simple_poll); - } - - break; - - case AVAHI_CLIENT_S_REGISTERING: - case AVAHI_CLIENT_S_RUNNING: - case AVAHI_CLIENT_S_COLLISION: - - if (!browsing) - if (start(config) < 0) - avahi_simple_poll_quit(simple_poll); - - break; - - case AVAHI_CLIENT_CONNECTING: - - if (config->verbose && !config->parsable) - fprintf(stderr, _("Waiting for daemon ...\n")); - - break; - } -} - -static void help(FILE *f, const char *argv0) { - if (strstr(argv0, "domain")) - fprintf(f, "%s [options] \n\n", argv0); - else - fprintf(f, - "%s [options] \n" - "%s [options] -a\n" - "%s [options] -D\n" -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - "%s [options] -b\n" -#endif - "\n", -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - argv0, -#endif - argv0, argv0, argv0); - - fprintf(f, "%s%s", - _(" -h --help Show this help\n" - " -V --version Show version\n" - " -D --browse-domains Browse for browsing domains instead of services\n" - " -a --all Show all services, regardless of the type\n" - " -d --domain=DOMAIN The domain to browse in\n" - " -v --verbose Enable verbose mode\n" - " -t --terminate Terminate after dumping a more or less complete list\n" - " -c --cache Terminate after dumping all entries from the cache\n" - " -l --ignore-local Ignore local services\n" - " -r --resolve Resolve services found\n" - " -f --no-fail Don't fail if the daemon is not available\n" - " -p --parsable Output in parsable format\n"), -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - _(" -k --no-db-lookup Don't lookup service types\n" - " -b --dump-db Dump service type database\n") -#else - "" -#endif - ); -} - -static int parse_command_line(Config *c, const char *argv0, int argc, char *argv[]) { - int o; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'V' }, - { "browse-domains", no_argument, NULL, 'D' }, - { "domain", required_argument, NULL, 'd' }, - { "all", no_argument, NULL, 'a' }, - { "verbose", no_argument, NULL, 'v' }, - { "terminate", no_argument, NULL, 't' }, - { "cache", no_argument, NULL, 'c' }, - { "ignore-local", no_argument, NULL, 'l' }, - { "resolve", no_argument, NULL, 'r' }, - { "no-fail", no_argument, NULL, 'f' }, - { "parsable", no_argument, NULL, 'p' }, -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - { "no-db-lookup", no_argument, NULL, 'k' }, - { "dump-db", no_argument, NULL, 'b' }, -#endif - { NULL, 0, NULL, 0 } - }; - - assert(c); - - c->command = strstr(argv0, "domain") ? COMMAND_BROWSE_DOMAINS : COMMAND_BROWSE_SERVICES; - c->verbose = - c->terminate_on_cache_exhausted = - c->terminate_on_all_for_now = - c->ignore_local = - c->resolve = - c->no_fail = - c->parsable = 0; - c->domain = c->stype = NULL; - -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - c->no_db_lookup = 0; -#endif - - while ((o = getopt_long(argc, argv, "hVd:avtclrDfp" -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - "kb" -#endif - , long_options, NULL)) >= 0) { - - switch(o) { - case 'h': - c->command = COMMAND_HELP; - break; - case 'V': - c->command = COMMAND_VERSION; - break; - case 'a': - c->command = COMMAND_BROWSE_ALL_SERVICES; - break; - case 'D': - c->command = COMMAND_BROWSE_DOMAINS; - break; - case 'd': - avahi_free(c->domain); - c->domain = avahi_strdup(optarg); - break; - case 'v': - c->verbose = 1; - break; - case 't': - c->terminate_on_all_for_now = 1; - break; - case 'c': - c->terminate_on_cache_exhausted = 1; - break; - case 'l': - c->ignore_local = 1; - break; - case 'r': - c->resolve = 1; - break; - case 'f': - c->no_fail = 1; - break; - case 'p': - c->parsable = 1; - break; -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - case 'k': - c->no_db_lookup = 1; - break; - case 'b': - c->command = COMMAND_DUMP_STDB; - break; -#endif - default: - return -1; - } - } - - if (c->command == COMMAND_BROWSE_SERVICES) { - if (optind >= argc) { - fprintf(stderr, _("Too few arguments\n")); - return -1; - } - - c->stype = avahi_strdup(argv[optind]); - optind++; - } - - if (optind < argc) { - fprintf(stderr, _("Too many arguments\n")); - return -1; - } - - return 0; -} - -int main(int argc, char *argv[]) { - int ret = 1, error; - Config config; - const char *argv0; - char *ec; - - avahi_init_i18n(); - setlocale(LC_ALL, ""); - - if ((argv0 = strrchr(argv[0], '/'))) - argv0++; - else - argv0 = argv[0]; - - if ((ec = getenv("COLUMNS"))) - n_columns = atoi(ec); - - if (n_columns < 40) - n_columns = 40; - - if (parse_command_line(&config, argv0, argc, argv) < 0) - goto fail; - - switch (config.command) { - case COMMAND_HELP: - help(stdout, argv0); - ret = 0; - break; - - case COMMAND_VERSION: - printf("%s "PACKAGE_VERSION"\n", argv0); - ret = 0; - break; - - case COMMAND_BROWSE_SERVICES: - case COMMAND_BROWSE_ALL_SERVICES: - case COMMAND_BROWSE_DOMAINS: - - if (!(simple_poll = avahi_simple_poll_new())) { - fprintf(stderr, _("Failed to create simple poll object.\n")); - goto fail; - } - - if (sigint_install(simple_poll) < 0) - goto fail; - - if (!(client = avahi_client_new(avahi_simple_poll_get(simple_poll), config.no_fail ? AVAHI_CLIENT_NO_FAIL : 0, client_callback, &config, &error))) { - fprintf(stderr, _("Failed to create client object: %s\n"), avahi_strerror(error)); - goto fail; - } - - avahi_simple_poll_loop(simple_poll); - ret = 0; - break; - -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - case COMMAND_DUMP_STDB: { - char *t; - stdb_setent(); - - while ((t = stdb_getent())) { - if (config.no_db_lookup) - printf("%s\n", t); - else - printf("%s\n", stdb_lookup(t)); - } - - ret = 0; - break; - } -#endif - } - - -fail: - - while (services) - remove_service(&config, services); - - if (client) - avahi_client_free(client); - - sigint_uninstall(); - - if (simple_poll) - avahi_simple_poll_free(simple_poll); - - avahi_free(config.domain); - avahi_free(config.stype); - - avahi_string_list_free(browsed_types); - -#if defined(HAVE_GDBM) || defined(HAVE_DBM) - stdb_shutdown(); -#endif - - return ret; -} diff --git a/avahi-utils/avahi-publish.c b/avahi-utils/avahi-publish.c deleted file mode 100644 index 485de3a..0000000 --- a/avahi-utils/avahi-publish.c +++ /dev/null @@ -1,429 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "sigint.h" - -typedef enum { - COMMAND_UNSPEC, - COMMAND_HELP, - COMMAND_VERSION, - COMMAND_PUBLISH_SERVICE, - COMMAND_PUBLISH_ADDRESS -} Command; - -typedef struct Config { - int verbose, no_fail, no_reverse; - Command command; - char *name, *stype, *domain, *host; - uint16_t port; - AvahiStringList *txt, *subtypes; - AvahiAddress address; -} Config; - -static AvahiSimplePoll *simple_poll = NULL; -static AvahiClient *client = NULL; -static AvahiEntryGroup *entry_group = NULL; - -static int register_stuff(Config *config); - -static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { - Config *config = userdata; - - assert(g); - assert(config); - - switch (state) { - - case AVAHI_ENTRY_GROUP_ESTABLISHED: - - fprintf(stderr, _("Established under name '%s'\n"), config->name); - break; - - case AVAHI_ENTRY_GROUP_FAILURE: - - fprintf(stderr, _("Failed to register: %s\n"), avahi_strerror(avahi_client_errno(client))); - break; - - case AVAHI_ENTRY_GROUP_COLLISION: { - char *n; - - if (config->command == COMMAND_PUBLISH_SERVICE) - n = avahi_alternative_service_name(config->name); - else { - assert(config->command == COMMAND_PUBLISH_ADDRESS); - n = avahi_alternative_host_name(config->name); - } - - fprintf(stderr, _("Name collision, picking new name '%s'.\n"), n); - avahi_free(config->name); - config->name = n; - - register_stuff(config); - - break; - } - - case AVAHI_ENTRY_GROUP_UNCOMMITED: - case AVAHI_ENTRY_GROUP_REGISTERING: - ; - } -} - -static int register_stuff(Config *config) { - assert(config); - - if (!entry_group) { - if (!(entry_group = avahi_entry_group_new(client, entry_group_callback, config))) { - fprintf(stderr, _("Failed to create entry group: %s\n"), avahi_strerror(avahi_client_errno(client))); - return -1; - } - } - - assert(avahi_entry_group_is_empty(entry_group)); - - if (config->command == COMMAND_PUBLISH_ADDRESS) { - - if (avahi_entry_group_add_address(entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, config->no_reverse ? AVAHI_PUBLISH_NO_REVERSE : 0, config->name, &config->address) < 0) { - fprintf(stderr, _("Failed to add address: %s\n"), avahi_strerror(avahi_client_errno(client))); - return -1; - } - - } else { - AvahiStringList *i; - - assert(config->command == COMMAND_PUBLISH_SERVICE); - - if (avahi_entry_group_add_service_strlst(entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, config->name, config->stype, config->domain, config->host, config->port, config->txt) < 0) { - fprintf(stderr, _("Failed to add service: %s\n"), avahi_strerror(avahi_client_errno(client))); - return -1; - } - - for (i = config->subtypes; i; i = i->next) - if (avahi_entry_group_add_service_subtype(entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, config->name, config->stype, config->domain, (char*) i->text) < 0) { - fprintf(stderr, _("Failed to add subtype '%s': %s\n"), i->text, avahi_strerror(avahi_client_errno(client))); - return -1; - } - } - - avahi_entry_group_commit(entry_group); - - return 0; -} - -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { - Config *config = userdata; - - client = c; - - switch (state) { - case AVAHI_CLIENT_FAILURE: - - if (config->no_fail && avahi_client_errno(c) == AVAHI_ERR_DISCONNECTED) { - int error; - - /* We have been disconnected, so let reconnect */ - - fprintf(stderr, _("Disconnected, reconnecting ...\n")); - - avahi_client_free(client); - client = NULL; - entry_group = NULL; - - if (!(client = avahi_client_new(avahi_simple_poll_get(simple_poll), AVAHI_CLIENT_NO_FAIL, client_callback, config, &error))) { - fprintf(stderr, _("Failed to create client object: %s\n"), avahi_strerror(error)); - avahi_simple_poll_quit(simple_poll); - } - - } else { - fprintf(stderr, _("Client failure, exiting: %s\n"), avahi_strerror(avahi_client_errno(c))); - avahi_simple_poll_quit(simple_poll); - } - - break; - - case AVAHI_CLIENT_S_RUNNING: - - if (register_stuff(config) < 0) - avahi_simple_poll_quit(simple_poll); - - break; - - case AVAHI_CLIENT_S_COLLISION: - - if (config->verbose) - fprintf(stderr, _("Host name conflict\n")); - - /* Fall through */ - - case AVAHI_CLIENT_S_REGISTERING: - - if (entry_group) { - avahi_entry_group_free(entry_group); - entry_group = NULL; - } - break; - - case AVAHI_CLIENT_CONNECTING: - - if (config->verbose) - fprintf(stderr, _("Waiting for daemon ...\n")); - - break; - - ; - } -} - -static void help(FILE *f, const char *argv0) { - fprintf(f, - _("%s [options] %s []\n" - "%s [options] %s
    \n\n" - " -h --help Show this help\n" - " -V --version Show version\n" - " -s --service Publish service\n" - " -a --address Publish address\n" - " -v --verbose Enable verbose mode\n" - " -d --domain=DOMAIN Domain to publish service in\n" - " -H --host=DOMAIN Host where service resides\n" - " --subtype=SUBTYPE An additional subtype to register this service with\n" - " -R --no-reverse Do not publish reverse entry with address\n" - " -f --no-fail Don't fail if the daemon is not available\n"), - argv0, strstr(argv0, "service") ? "[-s]" : "-s", - argv0, strstr(argv0, "address") ? "[-a]" : "-a"); -} - -static int parse_command_line(Config *c, const char *argv0, int argc, char *argv[]) { - int o; - - enum { - ARG_SUBTYPE = 256 - }; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'V' }, - { "service", no_argument, NULL, 's' }, - { "address", no_argument, NULL, 'a' }, - { "verbose", no_argument, NULL, 'v' }, - { "domain", required_argument, NULL, 'd' }, - { "host", required_argument, NULL, 'H' }, - { "subtype", required_argument, NULL, ARG_SUBTYPE}, - { "no-reverse", no_argument, NULL, 'R' }, - { "no-fail", no_argument, NULL, 'f' }, - { NULL, 0, NULL, 0 } - }; - - assert(c); - - c->command = strstr(argv0, "address") ? COMMAND_PUBLISH_ADDRESS : (strstr(argv0, "service") ? COMMAND_PUBLISH_SERVICE : COMMAND_UNSPEC); - c->verbose = c->no_fail = c->no_reverse = 0; - c->host = c->name = c->domain = c->stype = NULL; - c->port = 0; - c->txt = c->subtypes = NULL; - - while ((o = getopt_long(argc, argv, "hVsavRd:H:f", long_options, NULL)) >= 0) { - - switch(o) { - case 'h': - c->command = COMMAND_HELP; - break; - case 'V': - c->command = COMMAND_VERSION; - break; - case 's': - c->command = COMMAND_PUBLISH_SERVICE; - break; - case 'a': - c->command = COMMAND_PUBLISH_ADDRESS; - break; - case 'v': - c->verbose = 1; - break; - case 'R': - c->no_reverse = 1; - break; - case 'd': - avahi_free(c->domain); - c->domain = avahi_strdup(optarg); - break; - case 'H': - avahi_free(c->host); - c->host = avahi_strdup(optarg); - break; - case 'f': - c->no_fail = 1; - break; - case ARG_SUBTYPE: - c->subtypes = avahi_string_list_add(c->subtypes, optarg); - break; - default: - return -1; - } - } - - if (c->command == COMMAND_PUBLISH_ADDRESS) { - if (optind+2 != argc) { - fprintf(stderr, _("Bad number of arguments\n")); - return -1; - } - - avahi_free(c->name); - c->name = avahi_strdup(argv[optind]); - avahi_address_parse(argv[optind+1], AVAHI_PROTO_UNSPEC, &c->address); - - } else if (c->command == COMMAND_PUBLISH_SERVICE) { - - char *e; - long int p; - int i; - - if (optind+3 > argc) { - fprintf(stderr, _("Bad number of arguments\n")); - return -1; - } - - c->name = avahi_strdup(argv[optind]); - c->stype = avahi_strdup(argv[optind+1]); - - errno = 0; - p = strtol(argv[optind+2], &e, 0); - - if (errno != 0 || *e || p < 0 || p > 0xFFFF) { - fprintf(stderr, _("Failed to parse port number: %s\n"), argv[optind+2]); - return -1; - } - - c->port = p; - - for (i = optind+3; i < argc; i++) - c->txt = avahi_string_list_add(c->txt, argv[i]); - } - - return 0; -} - -int main(int argc, char *argv[]) { - int ret = 1, error; - Config config; - const char *argv0; - - avahi_init_i18n(); - setlocale(LC_ALL, ""); - - if ((argv0 = strrchr(argv[0], '/'))) - argv0++; - else - argv0 = argv[0]; - - if (parse_command_line(&config, argv0, argc, argv) < 0) - goto fail; - - switch (config.command) { - case COMMAND_UNSPEC: - ret = 1; - fprintf(stderr, _("No command specified.\n")); - break; - - case COMMAND_HELP: - help(stdout, argv0); - ret = 0; - break; - - case COMMAND_VERSION: - printf("%s "PACKAGE_VERSION"\n", argv0); - ret = 0; - break; - - case COMMAND_PUBLISH_SERVICE: - case COMMAND_PUBLISH_ADDRESS: - - if (!(simple_poll = avahi_simple_poll_new())) { - fprintf(stderr, _("Failed to create simple poll object.\n")); - goto fail; - } - - if (sigint_install(simple_poll) < 0) - goto fail; - - if (!(client = avahi_client_new(avahi_simple_poll_get(simple_poll), config.no_fail ? AVAHI_CLIENT_NO_FAIL : 0, client_callback, &config, &error))) { - fprintf(stderr, _("Failed to create client object: %s\n"), avahi_strerror(error)); - goto fail; - } - - if (avahi_client_get_state(client) != AVAHI_CLIENT_CONNECTING && config.verbose) { - const char *version, *hn; - - if (!(version = avahi_client_get_version_string(client))) { - fprintf(stderr, _("Failed to query version string: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - if (!(hn = avahi_client_get_host_name_fqdn(client))) { - fprintf(stderr, _("Failed to query host name: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - fprintf(stderr, _("Server version: %s; Host name: %s\n"), version, hn); - } - - avahi_simple_poll_loop(simple_poll); - ret = 0; - break; - } - -fail: - - if (client) - avahi_client_free(client); - - sigint_uninstall(); - - if (simple_poll) - avahi_simple_poll_free(simple_poll); - - avahi_free(config.host); - avahi_free(config.name); - avahi_free(config.stype); - avahi_free(config.domain); - avahi_string_list_free(config.subtypes); - avahi_string_list_free(config.txt); - - return ret; -} diff --git a/avahi-utils/avahi-resolve.c b/avahi-utils/avahi-resolve.c deleted file mode 100644 index bf1730b..0000000 --- a/avahi-utils/avahi-resolve.c +++ /dev/null @@ -1,339 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sigint.h" - -typedef enum { - COMMAND_UNSPEC, - COMMAND_HELP, - COMMAND_VERSION, - COMMAND_RESOLVE_HOST_NAME, - COMMAND_RESOLVE_ADDRESS -} Command; - -typedef struct Config { - int verbose; - Command command; - AvahiProtocol proto; -} Config; - -static AvahiSimplePoll *simple_poll = NULL; -static AvahiClient *client = NULL; - -static int n_resolving = 0; - -static void host_name_resolver_callback( - AvahiHostNameResolver *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const AvahiAddress *a, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void *userdata) { - - assert(r); - - switch (event) { - case AVAHI_RESOLVER_FOUND: { - char address[AVAHI_ADDRESS_STR_MAX]; - - avahi_address_snprint(address, sizeof(address), a); - - printf("%s\t%s\n", name, address); - - break; - } - - case AVAHI_RESOLVER_FAILURE: - - fprintf(stderr, _("Failed to resolve host name '%s': %s\n"), name, avahi_strerror(avahi_client_errno(client))); - break; - } - - - avahi_host_name_resolver_free(r); - - assert(n_resolving > 0); - n_resolving--; - - if (n_resolving <= 0) - avahi_simple_poll_quit(simple_poll); -} - -static void address_resolver_callback( - AvahiAddressResolver *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiResolverEvent event, - const AvahiAddress *a, - const char *name, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void *userdata) { - - char address[AVAHI_ADDRESS_STR_MAX]; - assert(r); - - avahi_address_snprint(address, sizeof(address), a); - - switch (event) { - case AVAHI_RESOLVER_FOUND: - - printf("%s\t%s\n", address, name); - break; - - case AVAHI_RESOLVER_FAILURE: - - fprintf(stderr, _("Failed to resolve address '%s': %s\n"), address, avahi_strerror(avahi_client_errno(client))); - break; - } - - - avahi_address_resolver_free(r); - - assert(n_resolving > 0); - n_resolving--; - - if (n_resolving <= 0) - avahi_simple_poll_quit(simple_poll); -} - -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { - switch (state) { - case AVAHI_CLIENT_FAILURE: - fprintf(stderr, _("Client failure, exiting: %s\n"), avahi_strerror(avahi_client_errno(c))); - avahi_simple_poll_quit(simple_poll); - break; - - case AVAHI_CLIENT_S_REGISTERING: - case AVAHI_CLIENT_S_RUNNING: - case AVAHI_CLIENT_S_COLLISION: - case AVAHI_CLIENT_CONNECTING: - ; - } -} - -static void help(FILE *f, const char *argv0) { - fprintf(f, - _("%s [options] %s \n" - "%s [options] %s
    \n\n" - " -h --help Show this help\n" - " -V --version Show version\n" - " -n --name Resolve host name\n" - " -a --address Resolve address\n" - " -v --verbose Enable verbose mode\n" - " -6 Lookup IPv6 address\n" - " -4 Lookup IPv4 address\n"), - argv0, strstr(argv0, "host-name") ? "[-n]" : "-n", - argv0, strstr(argv0, "address") ? "[-a]" : "-a"); -} - -static int parse_command_line(Config *c, const char *argv0, int argc, char *argv[]) { - int o; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'V' }, - { "name", no_argument, NULL, 'n' }, - { "address", no_argument, NULL, 'a' }, - { "verbose", no_argument, NULL, 'v' }, - { NULL, 0, NULL, 0 } - }; - - assert(c); - - c->command = strstr(argv0, "address") ? COMMAND_RESOLVE_ADDRESS : (strstr(argv0, "host-name") ? COMMAND_RESOLVE_HOST_NAME : COMMAND_UNSPEC); - c->proto = AVAHI_PROTO_UNSPEC; - c->verbose = 0; - - while ((o = getopt_long(argc, argv, "hVnav46", long_options, NULL)) >= 0) { - - switch(o) { - case 'h': - c->command = COMMAND_HELP; - break; - case 'V': - c->command = COMMAND_VERSION; - break; - case 'n': - c->command = COMMAND_RESOLVE_HOST_NAME; - break; - case 'a': - c->command = COMMAND_RESOLVE_ADDRESS; - break; - case 'v': - c->verbose = 1; - break; - case '4': - c->proto = AVAHI_PROTO_INET; - break; - case '6': - c->proto = AVAHI_PROTO_INET6; - break; - default: - return -1; - } - } - - if (c->command == COMMAND_RESOLVE_ADDRESS || c->command == COMMAND_RESOLVE_HOST_NAME) { - if (optind >= argc) { - fprintf(stderr, _("Too few arguments\n")); - return -1; - } - } - - return 0; -} - -int main(int argc, char *argv[]) { - int ret = 1, error; - Config config; - const char *argv0; - - avahi_init_i18n(); - setlocale(LC_ALL, ""); - - if ((argv0 = strrchr(argv[0], '/'))) - argv0++; - else - argv0 = argv[0]; - - if (parse_command_line(&config, argv0, argc, argv) < 0) - goto fail; - - switch (config.command) { - case COMMAND_UNSPEC: - ret = 1; - fprintf(stderr, _("No command specified.\n")); - break; - - case COMMAND_HELP: - help(stdout, argv0); - ret = 0; - break; - - case COMMAND_VERSION: - printf("%s "PACKAGE_VERSION"\n", argv0); - ret = 0; - break; - - case COMMAND_RESOLVE_HOST_NAME: - case COMMAND_RESOLVE_ADDRESS: { - int i; - - if (!(simple_poll = avahi_simple_poll_new())) { - fprintf(stderr, _("Failed to create simple poll object.\n")); - goto fail; - } - - if (sigint_install(simple_poll) < 0) - goto fail; - - if (!(client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error))) { - fprintf(stderr, _("Failed to create client object: %s\n"), avahi_strerror(error)); - goto fail; - } - - if (config.verbose) { - const char *version, *hn; - - if (!(version = avahi_client_get_version_string(client))) { - fprintf(stderr, _("Failed to query version string: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - if (!(hn = avahi_client_get_host_name_fqdn(client))) { - fprintf(stderr, _("Failed to query host name: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - fprintf(stderr, _("Server version: %s; Host name: %s\n"), version, hn); - } - - n_resolving = 0; - - for (i = optind; i < argc; i++) { - - if (config.command == COMMAND_RESOLVE_HOST_NAME) { - - if (!(avahi_host_name_resolver_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, argv[i], config.proto, 0, host_name_resolver_callback, NULL))) { - fprintf(stderr, _("Failed to create host name resolver: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - } else { - AvahiAddress a; - - assert(config.command == COMMAND_RESOLVE_ADDRESS); - - if (!avahi_address_parse(argv[i], AVAHI_PROTO_UNSPEC, &a)) { - fprintf(stderr, _("Failed to parse address '%s'\n"), argv[i]); - goto fail; - } - - if (!(avahi_address_resolver_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, &a, 0, address_resolver_callback, NULL))) { - fprintf(stderr, _("Failed to create address resolver: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - } - - n_resolving++; - } - - avahi_simple_poll_loop(simple_poll); - ret = 0; - break; - } - } - -fail: - - if (client) - avahi_client_free(client); - - sigint_uninstall(); - - if (simple_poll) - avahi_simple_poll_free(simple_poll); - - return ret; -} diff --git a/avahi-utils/avahi-set-host-name.c b/avahi-utils/avahi-set-host-name.c deleted file mode 100644 index 34fbbeb..0000000 --- a/avahi-utils/avahi-set-host-name.c +++ /dev/null @@ -1,211 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "sigint.h" - -typedef enum { - COMMAND_UNSPEC, - COMMAND_HELP, - COMMAND_VERSION -} Command; - -typedef struct Config { - int verbose; - Command command; -} Config; - -static AvahiSimplePoll *simple_poll = NULL; -static AvahiClient *client = NULL; - -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { - switch (state) { - case AVAHI_CLIENT_FAILURE: - fprintf(stderr, _("Client failure, exiting: %s\n"), avahi_strerror(avahi_client_errno(c))); - avahi_simple_poll_quit(simple_poll); - break; - - case AVAHI_CLIENT_S_REGISTERING: - case AVAHI_CLIENT_S_RUNNING: - case AVAHI_CLIENT_S_COLLISION: - case AVAHI_CLIENT_CONNECTING: - ; - } -} - -static void help(FILE *f, const char *argv0) { - fprintf(f, - _("%s [options] \n\n" - " -h --help Show this help\n" - " -V --version Show version\n" - " -v --verbose Enable verbose mode\n"), - argv0); -} - -static int parse_command_line(Config *c, int argc, char *argv[]) { - int o; - - static const struct option long_options[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'V' }, - { "verbose", no_argument, NULL, 'v' }, - { NULL, 0, NULL, 0 } - }; - - assert(c); - - c->command = COMMAND_UNSPEC; - c->verbose = 0; - - while ((o = getopt_long(argc, argv, "hVv", long_options, NULL)) >= 0) { - - switch(o) { - case 'h': - c->command = COMMAND_HELP; - break; - case 'V': - c->command = COMMAND_VERSION; - break; - case 'v': - c->verbose = 1; - break; - default: - return -1; - } - } - - if (c->command == COMMAND_UNSPEC) { - if (optind != argc-1) { - fprintf(stderr, _("Invalid number of arguments, expecting exactly one.\n")); - return -1; - } - } - - return 0; -} - -int main(int argc, char *argv[]) { - int ret = 1, error; - Config config; - const char *argv0; - - avahi_init_i18n(); - setlocale(LC_ALL, ""); - - if ((argv0 = strrchr(argv[0], '/'))) - argv0++; - else - argv0 = argv[0]; - - if (parse_command_line(&config, argc, argv) < 0) - goto fail; - - switch (config.command) { - case COMMAND_HELP: - help(stdout, argv0); - ret = 0; - break; - - case COMMAND_VERSION: - printf("%s "PACKAGE_VERSION"\n", argv0); - ret = 0; - break; - - case COMMAND_UNSPEC: - - if (!(simple_poll = avahi_simple_poll_new())) { - fprintf(stderr, _("Failed to create simple poll object.\n")); - goto fail; - } - - if (sigint_install(simple_poll) < 0) - goto fail; - - if (!(client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error))) { - fprintf(stderr, _("Failed to create client object: %s\n"), avahi_strerror(error)); - goto fail; - } - - if (config.verbose) { - const char *version, *hn; - - if (!(version = avahi_client_get_version_string(client))) { - fprintf(stderr, _("Failed to query version string: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - if (!(hn = avahi_client_get_host_name_fqdn(client))) { - fprintf(stderr, _("Failed to query host name: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - fprintf(stderr, _("Server version: %s; Host name: %s\n"), version, hn); - } - - if (avahi_client_set_host_name(client, argv[optind]) < 0) { - fprintf(stderr, _("Failed to create host name resolver: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - if (config.verbose) { - const char *hn; - - if (!(hn = avahi_client_get_host_name_fqdn(client))) { - fprintf(stderr, _("Failed to query host name: %s\n"), avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - fprintf(stderr, _("Host name successfully changed to %s\n"), hn); - } - - ret = 0; - break; - } - -fail: - - if (client) - avahi_client_free(client); - - sigint_uninstall(); - - if (simple_poll) - avahi_simple_poll_free(simple_poll); - - return ret; -} diff --git a/avahi-utils/sigint.c b/avahi-utils/sigint.c deleted file mode 100644 index b726654..0000000 --- a/avahi-utils/sigint.c +++ /dev/null @@ -1,144 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "sigint.h" - -static AvahiSimplePoll *simple_poll = NULL; -static struct sigaction old_sigint_sa, old_sigterm_sa; -static int pipe_fds[2] = { -1, -1 }; -static AvahiWatch *watch = NULL; - -static int set_nonblock(int fd) { - int n; - - assert(fd >= 0); - - if ((n = fcntl(fd, F_GETFL)) < 0) - return -1; - - if (n & O_NONBLOCK) - return 0; - - return fcntl(fd, F_SETFL, n|O_NONBLOCK); -} - -static void handler(int s) { - write(pipe_fds[1], &s, sizeof(s)); -} - -static void close_pipe_fds(void) { - if (pipe_fds[0] >= 0) - close(pipe_fds[0]); - if (pipe_fds[1] >= 0) - close(pipe_fds[1]); - - pipe_fds[0] = pipe_fds[1] = -1; -} - -static void watch_callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) { - int s; - ssize_t l; - - assert(w); - assert(fd == pipe_fds[0]); - assert(event == AVAHI_WATCH_IN); - - l = read(fd, &s, sizeof(s)); - assert(l == sizeof(s)); - - fprintf(stderr, "Got %s, quitting.\n", s == SIGINT ? "SIGINT" : "SIGTERM"); - avahi_simple_poll_quit(simple_poll); -} - -int sigint_install(AvahiSimplePoll *spoll) { - struct sigaction sa; - const AvahiPoll *p; - - assert(spoll); - assert(!simple_poll); - assert(pipe_fds[0] == -1 && pipe_fds[1] == -1); - - if (pipe(pipe_fds) < 0) { - fprintf(stderr, "pipe() failed: %s\n", strerror(errno)); - return -1; - } - - set_nonblock(pipe_fds[0]); - set_nonblock(pipe_fds[1]); - - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = handler; - sa.sa_flags = SA_RESTART; - - if (sigaction(SIGINT, &sa, &old_sigint_sa) < 0) { - fprintf(stderr, "sigaction() failed: %s\n", strerror(errno)); - close_pipe_fds(); - return -1; - } - - if (sigaction(SIGTERM, &sa, &old_sigterm_sa) < 0) { - sigaction(SIGINT, &old_sigint_sa, NULL); - fprintf(stderr, "sigaction() failed: %s\n", strerror(errno)); - close_pipe_fds(); - return -1; - } - - p = avahi_simple_poll_get(spoll); - watch = p->watch_new(p, pipe_fds[0], AVAHI_WATCH_IN, watch_callback, NULL); - assert(watch); - - simple_poll = spoll; - return 0; -} - -void sigint_uninstall(void) { - - if (!simple_poll) - return; - - sigaction(SIGTERM, &old_sigterm_sa, NULL); - sigaction(SIGINT, &old_sigint_sa, NULL); - - close_pipe_fds(); - - if (watch) { - const AvahiPoll *p; - - assert(simple_poll); - p = avahi_simple_poll_get(simple_poll); - - p->watch_free(watch); - watch = NULL; - } - - simple_poll = NULL; -} diff --git a/avahi-utils/sigint.h b/avahi-utils/sigint.h deleted file mode 100644 index ae66fd4..0000000 --- a/avahi-utils/sigint.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef foosigchfoo -#define foosigchfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -int sigint_install(AvahiSimplePoll *spoll); -void sigint_uninstall(void); - -#endif diff --git a/avahi-utils/stdb.c b/avahi-utils/stdb.c deleted file mode 100644 index 6602c97..0000000 --- a/avahi-utils/stdb.c +++ /dev/null @@ -1,212 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include -#ifdef HAVE_GDBM -#include -#endif -#ifdef HAVE_DBM -#include -#include -#endif -#include -#include -#include -#include - -#include - -#include "stdb.h" - -#ifdef HAVE_GDBM -static GDBM_FILE gdbm_file = NULL; -#endif -#ifdef HAVE_DBM -static DBM *dbm_file = NULL; -#endif -static char *buffer = NULL; -static char *enum_key = NULL; - -static int init(void) { - -#ifdef HAVE_GDBM - if (gdbm_file) - return 0; - - if (!(gdbm_file = gdbm_open((char*) DATABASE_FILE, 0, GDBM_READER, 0, NULL))) - return -1; -#endif -#ifdef HAVE_DBM - if (dbm_file) - return 0; - - if (!(dbm_file = dbm_open((char*) DATABASE_FILE, O_RDONLY, 0))) - return -1; -#endif - - return 0; -} - -const char* stdb_lookup(const char *name) { - datum key, data; - const char *loc; - - if (init() < 0) - goto fail; - - data.dptr = NULL; - data.dsize = 0; - - if ((loc = setlocale(LC_MESSAGES, NULL))) { - char k[256]; - - snprintf(k, sizeof(k), "%s[%s]", name, loc); - key.dptr = k; - key.dsize = strlen(k); -#ifdef HAVE_GDBM - data = gdbm_fetch(gdbm_file, key); -#endif -#ifdef HAVE_DBM - data = dbm_fetch(dbm_file, key); -#endif - - if (!data.dptr) { - char l[32], *e; - snprintf(l, sizeof(l), "%s", loc); - - if ((e = strchr(l, '@'))) { - *e = 0; - snprintf(k, sizeof(k), "%s[%s]", name, l); - key.dptr = k; - key.dsize = strlen(k); -#ifdef HAVE_GDBM - data = gdbm_fetch(gdbm_file, key); -#endif -#ifdef HAVE_DBM - data = dbm_fetch(dbm_file, key); -#endif - } - - if (!data.dptr) { - if ((e = strchr(l, '_'))) { - *e = 0; - snprintf(k, sizeof(k), "%s[%s]", name, l); - key.dptr = k; - key.dsize = strlen(k); -#ifdef HAVE_GDBM - data = gdbm_fetch(gdbm_file, key); -#endif -#ifdef HAVE_DBM - data = dbm_fetch(dbm_file, key); -#endif - } - } - } - } - - if (!data.dptr) { - key.dptr = (char*) name; - key.dsize = strlen(name); -#ifdef HAVE_GDBM - data = gdbm_fetch(gdbm_file, key); -#endif -#ifdef HAVE_DBM - data = dbm_fetch(dbm_file, key); -#endif - } - - if (!data.dptr) - goto fail; - - avahi_free(buffer); - buffer = avahi_strndup(data.dptr, data.dsize); - free(data.dptr); - - return buffer; - -fail: - - return name; -} - -void stdb_shutdown(void) { -#ifdef HAVE_GDBM - if (gdbm_file) - gdbm_close(gdbm_file); - - gdbm_file = NULL; -#endif -#ifdef HAVE_DBM - if (dbm_file) - dbm_close(dbm_file); - - dbm_file = NULL; -#endif - - avahi_free(buffer); - avahi_free(enum_key); - - buffer = enum_key = NULL; -} - -char *stdb_getent(void) { - datum key; - - if (init() < 0) - return NULL; - - for (;;) { - - if (!enum_key) { -#ifdef HAVE_GDBM - key = gdbm_firstkey(gdbm_file); -#endif -#ifdef HAVE_DBM - key = dbm_firstkey(dbm_file); -#endif - } else { - key.dptr = enum_key; - key.dsize = strlen(enum_key); - -#ifdef HAVE_GDBM - key = gdbm_nextkey(gdbm_file, key); -#endif -#ifdef HAVE_DBM - key = dbm_nextkey(dbm_file); -#endif - } - - avahi_free(enum_key); - enum_key = NULL; - - if (!key.dptr) - return NULL; - - enum_key = avahi_strndup(key.dptr, key.dsize); - free(key.dptr); - - if (!strchr(enum_key, '[')) - return enum_key; - } -} - -void stdb_setent(void) { - avahi_free(enum_key); - enum_key = NULL; -} diff --git a/avahi-utils/stdb.h b/avahi-utils/stdb.h deleted file mode 100644 index d1e1a91..0000000 --- a/avahi-utils/stdb.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef foostdbhfoo -#define foostdbhfoo - -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -const char* stdb_lookup(const char *name); -void stdb_shutdown(void); -char *stdb_getent(void); -void stdb_setent(void); - -#endif diff --git a/configure.ac b/configure.ac index 9debce2..82d816e 100644 --- a/configure.ac +++ b/configure.ac @@ -29,17 +29,6 @@ AC_SUBST(PACKAGE_URL, [http://avahi.org/]) AC_SUBST(LIBAVAHI_COMMON_VERSION_INFO, [8:3:5]) AC_SUBST(LIBAVAHI_CORE_VERSION_INFO, [7:2:0]) -AC_SUBST(LIBAVAHI_CLIENT_VERSION_INFO, [5:9:2]) -AC_SUBST(LIBAVAHI_GLIB_VERSION_INFO, [1:2:0]) -AC_SUBST(LIBAVAHI_GOBJECT_VERSION_INFO, [0:4:0]) -AC_SUBST(LIBAVAHI_QT3_VERSION_INFO, [1:2:0]) -AC_SUBST(LIBAVAHI_QT4_VERSION_INFO, [1:2:0]) -AC_SUBST(LIBAVAHI_UI_VERSION_INFO, [1:4:1]) - -# Do not touch these, since they we took this version-info from upstream HOWL/Bonjour -AC_SUBST(LIBAVAHI_COMPAT_LIBDNS_SD_VERSION_INFO, [1:0:0]) -AC_SUBST(LIBAVAHI_COMPAT_HOWL_VERSION_INFO, [0:0:0]) -AC_SUBST(HOWL_COMPAT_VERSION, [0.9.8]) AC_CANONICAL_HOST @@ -141,16 +130,6 @@ fi # libtool stuff AC_PROG_LIBTOOL -AC_CACHE_CHECK([whether the C++ compiler works], [avahi_cv_sys_cxx_works], [ - AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE([int main() { return 0; }], [avahi_cv_sys_cxx_works=yes], - [avahi_cv_sys_cxx_works=no]) - AC_LANG_POP([C++]) - ]) -[ if [ "x$avahi_cv_sys_cxx_works" = "xno" ]; then ] - AC_MSG_FAILURE([The C++ compiler does not work]) -[ fi ] - ACX_PTHREAD(,AC_MSG_ERROR([Missing POSIX Threads support])) # @@ -248,55 +227,6 @@ AC_TRY_COMPILE([#include ], [ ]) ]) -# -# Detecting the linux distribution for specific things like init scripts. -# -AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of lfs, debian, gentoo, archlinux, fedora, mandriva, darwin, netbsd, freebsd, slackware or none])) -if test "z$with_distro" = "z"; then - if test "$cross_compiling" = yes; then - AC_MSG_WARN([Target distribution cannot be reliably detected when cross-compiling. You should specify it with --with-distro (see $0 --help for recognized distros)]) - else - AC_CHECK_FILE(/etc/lfs-release,with_distro="lfs") - AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse") - AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo") - AC_CHECK_FILE(/etc/arch-release,with_distro="archlinux") - AC_CHECK_FILE(/etc/debian_version,with_distro="debian") - AC_CHECK_FILE(/etc/redhat-release,with_distro="fedora") - AC_CHECK_FILE(/etc/mandriva-release,with_distro="mandriva") - AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware") - fi - if test "z$with_distro" = "z"; then - with_distro=`uname -s` - fi -fi -with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' ` - -case $with_distro in - lfs|debian|gentoo|archlinux|suse|fedora|mandriva|darwin|freebsd|slackware|none) - ;; - netbsd) - AC_MSG_WARN([Your distribution (${with_distro}) is supported but no init script exist yet! (patches welcome)]) - ;; - linux) - AC_MSG_ERROR([Linux distribution autodetection failed, you must specify the distribution to target using --with-distro=DISTRO, set DISTRO to none if your distribution is not supported.]) - ;; - *) - AC_MSG_ERROR([Your distribution (${with_distro}) is not yet supported, init scripts and D-Bus configuration will not be installed! (patches welcome), you can specify --with-distro=none to skip this check]) - ;; -esac - -AM_CONDITIONAL(TARGET_LFS, test x"$with_distro" = xlfs) -AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse) -AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo) -AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian) -AM_CONDITIONAL(TARGET_ARCHLINUX, test x"$with_distro" = xarchlinux) -AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora) -AM_CONDITIONAL(TARGET_MANDRIVA, test x"$with_distro" = xmandriva) -AM_CONDITIONAL(TARGET_DARWIN, test x"$with_distro" = xdarwin) -AM_CONDITIONAL(TARGET_NETBSD, test x"$with_distro" = xnetbsd) -AM_CONDITIONAL(TARGET_FREEBSD, test x"$with_distro" = xfreebsd) -AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware) - test_gcc_flag() { AC_LANG_CONFTEST([int main() {}]) $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null @@ -378,41 +308,6 @@ AC_CHECK_DECLS(environ) # check if gcc's -fvisibility is supported CHECK_VISIBILITY_HIDDEN -enable_chroot=yes -AC_CHECK_HEADERS([sys/capability.h],,enable_chroot=no) -AC_CHECK_HEADERS([sys/prctl.h],,enable_chroot=no) -AC_CHECK_FUNCS([chroot],,enable_chroot=no) - -AM_CONDITIONAL(ENABLE_CHROOT, test "x$enable_chroot" = "xyes") - -if test "x$enable_chroot" = "xyes" ; then - AC_DEFINE([ENABLE_CHROOT], 1, [Enable chroot() usage]) -fi - -AC_CHECK_LIB(dl, dlopen, [ AC_CHECK_HEADERS(dlfcn.h, HAVE_DLOPEN=yes, HAVE_DLOPEN=no) ], HAVE_DLOPEN=no) -if test "x$HAVE_DLOPEN" = "xyes" ; then - AC_DEFINE([HAVE_DLOPEN],1,[Have dlopen()]) -fi -AM_CONDITIONAL(HAVE_DLOPEN, test "x$HAVE_DLOPEN" = "xyes") - -have_inotify=no -AC_CHECK_HEADERS([sys/inotify.h], [have_inotify=yes]) - -AM_CONDITIONAL(HAVE_INOTIFY, test "x$have_inotify" = "xyes") - -if test "x$have_inotify" = "xyes" ; then - AC_DEFINE([HAVE_INOTIFY], 1, [Enable Linux inotify() usage]) -fi - -have_kqueue=yes -AC_CHECK_FUNCS([kqueue],,have_kqueue=no) - -AM_CONDITIONAL(HAVE_KQUEUE, test "x$have_kqueue" = "xyes") - -if test "x$have_kqueue" = "xyes" ; then - AC_DEFINE([HAVE_KQUEUE], 1, [Enable BSD kqueue() usage]) -fi - IT_PROG_INTLTOOL([0.35.0]) GETTEXT_PACKAGE=avahi AC_SUBST([GETTEXT_PACKAGE]) @@ -432,544 +327,6 @@ fi PKG_PROG_PKG_CONFIG -# -# Check for GLIB 2.0 -# -AC_ARG_ENABLE(glib, - AS_HELP_STRING([--disable-glib],[Disable use of GLib]), - [case "${enableval}" in - yes) HAVE_GLIB=yes ;; - no) HAVE_GLIB=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-glib) ;; - esac], - [HAVE_GLIB=yes]) - -if test "x$HAVE_GLIB" = "xyes" ; then - PKG_CHECK_MODULES(GLIB20, [ glib-2.0 >= 2.4.0 ]) - AC_SUBST(GLIB20_CFLAGS) - AC_SUBST(GLIB20_LIBS) -fi -AM_CONDITIONAL(HAVE_GLIB, test "x$HAVE_GLIB" = "xyes") - -# -# Check for GLIB's gobject 2.0 -# -AC_ARG_ENABLE(gobject, - AS_HELP_STRING([--disable-gobject],[Disable use of GLib GObject]), - [case "${enableval}" in - yes) HAVE_GOBJECT=yes ;; - no) HAVE_GOBJECT=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-gobject) ;; - esac], - [HAVE_GOBJECT=yes]) - -if test "x$HAVE_GOBJECT" = "xyes" ; then - PKG_CHECK_MODULES(GOBJECT, [ glib-2.0 >= 2.4.0 gobject-2.0 ]) - AC_SUBST(GOBJECT_CFLAGS) - AC_SUBST(GOBJECT_LIBS) -fi -AM_CONDITIONAL(HAVE_GOBJECT, test "x$HAVE_GOBJECT" = "xyes") - -# -# Introspection support. -# -GOBJECT_INTROSPECTION_CHECK([0.9.5]) - -# -# Check for Qt 3 -# -AC_ARG_ENABLE(qt3, - AS_HELP_STRING([--disable-qt3],[Disable building of Qt3 mainloop integration]), - [case "${enableval}" in - yes) HAVE_QT3=yes ;; - no) HAVE_QT3=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-qt3) ;; - esac], - [HAVE_QT3=yes]) - -if test "x$HAVE_QT3" = "xyes" ; then - PKG_CHECK_MODULES( QT3, [ qt-mt >= 3.0.0 ]) - AC_SUBST(QT3_CFLAGS) - AC_SUBST(QT3_LIBS) - QT3_PREFIX="`$PKG_CONFIG --variable=prefix qt-mt`/bin" - AC_PATH_PROGS(MOC_QT3, [moc-qt3 moc], no, [$QT3_PREFIX]) - if test "$MOC_QT3" = no; then - AC_MSG_ERROR([Could not find QT3 moc]) - fi - AC_SUBST(MOC_QT3) -fi -AM_CONDITIONAL(HAVE_QT3, test "x$HAVE_QT3" = "xyes") - -# -# Check for Qt 4 -# -AC_ARG_ENABLE(qt4, - AS_HELP_STRING([--disable-qt4],[Disable building of Qt4Core mainloop integration]), - [case "${enableval}" in - yes) HAVE_QT4=yes ;; - no) HAVE_QT4=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-qt4) ;; - esac], - [HAVE_QT4=yes]) - -if test "x$HAVE_QT4" = "xyes" ; then - PKG_CHECK_MODULES( QT4, [ QtCore >= 4.0.0 ]) - AC_SUBST(QT4_CFLAGS) - AC_SUBST(QT4_LIBS) - QT4_PREFIX="`$PKG_CONFIG --variable=prefix QtCore`/bin" - AC_PATH_PROGS(MOC_QT4, [moc-qt4 moc], no, [$QT4_PREFIX]) - if test "$MOC_QT4" = no; then - AC_MSG_ERROR([Could not find QT4 moc]) - fi - AC_SUBST(MOC_QT4) -fi -AM_CONDITIONAL(HAVE_QT4, test "x$HAVE_QT4" = "xyes") - -# -# Check for GTK+ 2.0 -# -AC_ARG_ENABLE(gtk, - AS_HELP_STRING([--disable-gtk],[Disable use of GTK+ 2]), - [case "${enableval}" in - yes) HAVE_GTK=yes ;; - no) HAVE_GTK=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtk) ;; - esac], - [HAVE_GTK=yes]) - -if test "x$HAVE_GTK" = "xyes" ; then - # Check for GTK 2.0 - PKG_CHECK_MODULES(GTK20, [ gtk+-2.0 >= 2.14.0 ]) - AC_SUBST(GTK20_CFLAGS) - AC_SUBST(GTK20_LIBS) -fi -AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes") - -# -# Check for GTK+ 3.0 -# -AC_ARG_ENABLE(gtk3, - AS_HELP_STRING([--disable-gtk3],[Disable use of GTK+ 3]), - [case "${enableval}" in - yes) HAVE_GTK3=yes ;; - no) HAVE_GTK3=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtk3) ;; - esac], - [HAVE_GTK3=yes]) - -if test "x$HAVE_GTK3" = "xyes" ; then - # Check for GTK 3.0 - PKG_CHECK_MODULES(GTK30, [ gtk+-3.0 ]) - AC_SUBST(GTK30_CFLAGS) - AC_SUBST(GTK30_LIBS) -fi -AM_CONDITIONAL(HAVE_GTK3, test "x$HAVE_GTK3" = "xyes") - -AM_CONDITIONAL(HAVE_GTK2OR3, test "x$HAVE_GTK3" = "xyes" -o "x$HAVE_GTK" = "xyes" ) - -# -# D-Bus -# -AC_ARG_ENABLE(dbus, - AS_HELP_STRING([--disable-dbus],[Disable use of D-Bus]), - [case "${enableval}" in - yes) HAVE_DBUS=yes ;; - no) HAVE_DBUS=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-dbus) ;; - esac], - [HAVE_DBUS=yes]) - -AC_ARG_WITH(dbus-sys, AS_HELP_STRING([--with-dbus-sys=], [Path to D-Bus system.d directory])) -AC_ARG_WITH(dbus-system-socket, AS_HELP_STRING([--with-dbus-system-address=
    ], [Path to the D-Bus system socket, you probably want to put unix:path= at the start. Only needed for very old D-Bus releases])) - -DBUS_VERSION="Disabled" -DBUS_SYS_DIR="Disabled" -DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="Disabled" -if test "x$HAVE_DBUS" = "xyes" ; then - PKG_CHECK_MODULES(DBUS, [ dbus-1 >= 0.34 ]) - - AC_DEFINE(HAVE_DBUS, 1, [Whether we have D-Bus or not]) - - DBUS_VERSION=`$PKG_CONFIG dbus-1 --modversion` - DBUS_VERSION_MAJOR=`echo $DBUS_VERSION | awk -F. '{print $1}'` - DBUS_VERSION_MINOR=`echo $DBUS_VERSION | awk -F. '{print $2}'` - DBUS_VERSION_MICRO=`echo $DBUS_VERSION | awk -F. '{print $3}'` - if test "z$DBUS_VERSION_MAJOR" = "z"; then - DBUS_VERSION_MAJOR="0" - fi - if test "z$DBUS_VERSION_MINOR" = "z"; then - DBUS_VERSION_MINOR="0" - fi - if test "z$DBUS_VERSION_MICRO" = "z"; then - DBUS_VERSION_MICRO="0" - fi - - if test "z$DBUS_VERSION_MAJOR" = "z0" -a "z$DBUS_VERSION_MINOR" = "z0" -a "z$DBUS_VERSION_MICRO" = "z0"; then - echo "Error: Couldn't determine the version of your D-Bus package." - echo " This is probably an error in this script, please report it" - echo " along with the following information:" - echo " Base D-Buss version ='$DBUS_VERSION'" - echo " DBUS_VERSION_MAJOR='$DBUS_VERSION_MAJOR'" - echo " DBUS_VERSION_MINOR='$DBUS_VERSION_MINOR'" - echo " DBUS_VERSION_MICRO='$DBUS_VERSION_MICRO'" - exit 1 - else - echo "Your D-Bus version is $DBUS_VERSION_MAJOR,$DBUS_VERSION_MINOR,$DBUS_VERSION_MICRO." - DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_VERSION_MAJOR=$DBUS_VERSION_MAJOR" - DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_VERSION_MINOR=$DBUS_VERSION_MINOR" - DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_VERSION_MICRO=$DBUS_VERSION_MICRO" - fi - - DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_API_SUBJECT_TO_CHANGE" - AC_SUBST(DBUS_CFLAGS) - AC_SUBST(DBUS_LIBS) - - if ! test -z "$with_dbus_sys" ; then - DBUS_SYS_DIR="$with_dbus_sys" - else - DBUS_SYS_DIR="${sysconfdir}/dbus-1/system.d" - fi - AC_SUBST(DBUS_SYS_DIR) - - if ! test -z "$with_dbus_system_address" ; then - DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="$with_dbus_system_address" - else - # This is ugly, but D-Bus doesn't export this address for us - # so we have to guess, pretty much all setups i've seen have - # it in /var/lib/dbus or /var/run/dbus, and its defaulted to - # /var/run upstream so we will try guess first then default - # to /var/run/dbus. - - DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=/var/run/dbus/system_bus_socket" - TRY_SOCKETS="/var/lib/dbus/system_bus_socket /var/run/dbus/system_bus_socket ${localstatedir}/run/dbus/system_bus_socket ${prefix}/var/run/dbus/system_bus_socket" - for sock in $TRY_SOCKETS; do - if test -S $sock; then - DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$sock" - fi - done - fi - AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS) - - SAVED_LIBS="$LIBS" - LIBS="$LIBS $DBUS_LIBS" - AC_CHECK_FUNCS([dbus_connection_close dbus_bus_get_private]) - LIBS="$SAVED_LIBS" -fi -AM_CONDITIONAL(HAVE_DBUS, test "x$HAVE_DBUS" = "xyes") - -# -# Expat -# -AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[expat/bsdxml/none]],[XML library to use])) -use_expat=false -use_bsdxml=false - -# See what we have -AC_CHECK_LIB(expat, XML_ParserCreate, [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ], have_expat=false) -AC_CHECK_LIB(bsdxml, XML_ParserCreate, [ AC_CHECK_HEADERS(bsdxml.h, have_bsdxml=true, have_bsdxml=false) ], have_bsdxml=false) - -if test "x$with_xml" = "xnone"; then - : -elif test "x$with_xml" = "xexpat"; then - use_expat=true - if ! $have_expat ; then - AC_MSG_ERROR([*** libexpat requested, but not found ***]) - fi -elif test "x$with_xml" = "xbsdxml"; then - use_bsdxml=true - if ! $have_bsdxml ; then - AC_MSG_ERROR([*** libbsdxml requested, but not found ***]) - fi -elif test "x$with_xml" != "x"; then - AC_MSG_ERROR([*** unknown with-xml option ***]) -else - if $have_expat ; then - use_expat=true - elif $have_bsdxml ; then - use_bsdxml=true - else - AC_MSG_ERROR([*** neither libexpat not libbsdxml could be found ***]) - fi -fi - -if $use_expat; then - with_xml=expat - XML_CFLAGS=-DUSE_EXPAT_H - XML_LIBS=-lexpat -fi -if $use_bsdxml; then - with_xml=bsdxml - XML_CFLAGS=-DUSE_BSDXML_H - XML_LIBS=-lbsdxml -fi -AC_SUBST(XML_LIBS) -AC_SUBST(XML_CFLAGS) - -if $use_expat || $use_bsdxml; then - HAVE_XML=yes -fi - -AM_CONDITIONAL(HAVE_XML, test "x$HAVE_XML" = "xyes") - -# -# GDBM -# -# -# Check for dbm -# -AC_ARG_ENABLE(dbm, - AS_HELP_STRING([--enable-dbm],[Enable use of DBM]), - [case "${enableval}" in - yes) HAVE_DBM=yes ;; - no) HAVE_DBM=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-dbm) ;; - esac], - [HAVE_DBM=no]) - -AC_ARG_ENABLE(gdbm, - AS_HELP_STRING([--disable-gdbm],[Disable use of GDBM]), - [case "${enableval}" in - yes) HAVE_GDBM=yes ;; - no) HAVE_GDBM=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --disable-gdbm) ;; - esac], - [HAVE_GDBM=yes]) - -if test "x$HAVE_GDBM" = "xyes" ; then - if test "x$HAVE_DBM" = "xyes" ; then - AC_MSG_ERROR([*** --enable-gdbm and --enable-dbm both specified ***]) - fi - AC_CHECK_LIB(gdbm, gdbm_open, [ AC_CHECK_HEADERS(gdbm.h, have_gdbm=true, have_gdbm=false) ], have_gdbm=false) - - if ! $have_gdbm ; then - AC_MSG_ERROR([*** libgdbm not found ***]) - fi - AC_DEFINE([HAVE_GDBM],[],[Support for GDBM]) -else - if test "x$HAVE_DBM" = "xyes" ; then - AC_CHECK_HEADERS(ndbm.h, have_dbm=true, have_dbm=false) - - if ! $have_dbm ; then - AC_MSG_ERROR([*** dbm not found ***]) - fi - AC_DEFINE([HAVE_DBM],[],[Support for DBM]) - fi -fi -AM_CONDITIONAL(HAVE_GDBM, test "x$HAVE_GDBM" = "xyes") -AM_CONDITIONAL(HAVE_DBM, test "x$HAVE_DBM" = "xyes") - -# -# libdaemon -# -AC_ARG_ENABLE(libdaemon, - AS_HELP_STRING([--disable-libdaemon],[Disable use of libdaemon]), - [case "${enableval}" in - yes) HAVE_LIBDAEMON=yes ;; - no) HAVE_LIBDAEMON=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-libdaemon) ;; - esac], - [HAVE_LIBDAEMON=yes]) - -if test "x$HAVE_LIBDAEMON" = "xyes" ; then - PKG_CHECK_MODULES(LIBDAEMON, [ libdaemon >= 0.14 ]) - AC_SUBST(LIBDAEMON_CFLAGS) - AC_SUBST(LIBDAEMON_LIBS) -fi -AM_CONDITIONAL(HAVE_LIBDAEMON, test "x$HAVE_LIBDAEMON" = "xyes") - -# -# Python stuff -# -AC_ARG_ENABLE(python, - AS_HELP_STRING([--disable-python], [Disable scripts that depends on python]), - [case "${enableval}" in - yes) HAVE_PYTHON=yes ;; - no) HAVE_PYTHON=no ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-python]) ;; - esac],[HAVE_PYTHON=yes]) - -HAVE_PYTHON_DBUS=no -HAVE_PYGTK=no - -if test "x$HAVE_PYTHON" = "xyes" ; then - AM_PATH_PYTHON([2.4]) - - AC_ARG_ENABLE(pygtk, - AS_HELP_STRING([--disable-pygtk],[Disable use of GTK in Python]), - [case "${enableval}" in - yes) HAVE_PYGTK=yes ;; - no) HAVE_PYGTK=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-pygtk) ;; - esac], - [HAVE_PYGTK=yes]) - - if test "x$HAVE_PYGTK" = "xyes" ; then - AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(Could not find Python module gtk)]) - fi - - - if test "x$HAVE_DBUS" = "xyes" ; then - AC_ARG_ENABLE(python-dbus, - AS_HELP_STRING([--disable-python-dbus],[Disable use of D-Bus in Python]), - [case "${enableval}" in - yes) HAVE_PYTHON_DBUS=yes ;; - no) HAVE_PYTHON_DBUS=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-python-dbus) ;; - esac], - [HAVE_PYTHON_DBUS=yes]) - - if test "x$HAVE_PYTHON_DBUS" = "xyes"; then - AM_CHECK_PYMOD(dbus,,,[AC_MSG_ERROR(Could not find Python module dbus)]) - fi - - AM_CHECK_PYMOD(socket,,,[AC_MSG_ERROR(Could not find Python module socket)]) - if test "x$HAVE_GDBM" = "xyes"; then - AM_CHECK_PYMOD(gdbm,,,[AC_MSG_ERROR(Could not find Python module gdbm)]) - fi - if test "x$HAVE_DBM" = "xyes"; then - AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)]) - fi - fi -fi -AM_CONDITIONAL(HAVE_PYTHON, [test "x$HAVE_PYTHON" = "xyes" ]) -AM_CONDITIONAL(HAVE_PYGTK, test "x$HAVE_PYGTK" = "xyes") -AM_CONDITIONAL(HAVE_PYTHON_DBUS, test "x$HAVE_PYTHON_DBUS" = "xyes") - -# -# Check for mono stuff -# -HAVE_MONO=no -if test "x$HAVE_DBUS" = "xyes" ; then - AC_ARG_ENABLE(mono, - AS_HELP_STRING([--disable-mono],[Disable mono bindings]), - [case "${enableval}" in - yes) HAVE_MONO=yes ;; - no) HAVE_MONO=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-mono) ;; - esac], - [HAVE_MONO=yes]) - - if test "x$HAVE_MONO" = "xyes" ; then - AC_PATH_PROG(MCS, mcs) - if test "x$MCS" = "x" ; then - AC_MSG_ERROR([Can not find "mcs" - The Mono C-Sharp Compiler) in your PATH]) - fi - - AC_PATH_PROG(GACUTIL, gacutil) - if test "x$GACUTIL" = "x" ; then - AC_MSG_ERROR([Can not find "gacutil" in your PATH]) - fi - - AC_SUBST(MCS) - AC_SUBST(GACUTIL) - fi -fi -AM_CONDITIONAL(HAVE_MONO, test "x$HAVE_MONO" = "xyes") - -# -# Check for monodoc stuff -# -HAVE_MONODOC=no -AC_ARG_ENABLE(monodoc, - AS_HELP_STRING([--disable-monodoc],[Disable documentation for mono bindings]), - [case "${enableval}" in - yes) HAVE_MONODOC=yes ;; - no) HAVE_MONODOC=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-monodoc) ;; - esac], - [HAVE_MONODOC=yes]) - -if test "x$HAVE_MONO" = "xyes" && test "x$HAVE_MONODOC" = "xyes" ; then - PKG_CHECK_MODULES(MONODOC, [monodoc >= 1.1.8]) - MONODOC_DIR=`$PKG_CONFIG --variable=sourcesdir monodoc` - - AC_PATH_PROG(MONODOCER, monodocer) - AC_PATH_PROG(MDASSEMBLER, mdassembler) - - AC_SUBST(MONODOC_DIR) - AC_SUBST(MONODOCER) - AC_SUBST(MDASSEMBLER) -fi -AM_CONDITIONAL(HAVE_MONODOC, test "x$HAVE_MONODOC" = "xyes") - -# -# Build autoipd? -# -AC_ARG_ENABLE(autoipd, - AS_HELP_STRING([--disable-autoipd],[Disable building of avahi-autoipd]), - [case "${enableval}" in - yes) ENABLE_AUTOIPD=yes ;; - no) ENABLE_AUTOIPD=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --disable-autoipd) ;; - esac], - [ENABLE_AUTOIPD=yes]) - -AM_CONDITIONAL(ENABLE_AUTOIPD, test "x$ENABLE_AUTOIPD" = "xyes") - -# -# Defining users and groups -# -AC_ARG_WITH(avahi_user, AS_HELP_STRING([--with-avahi-user=],[User for running avahi-daemon (avahi)])) -if test -z "$with_avahi_user" ; then - AVAHI_USER=avahi -else - AVAHI_USER=$with_avahi_user -fi -AC_SUBST(AVAHI_USER) -AC_DEFINE_UNQUOTED(AVAHI_USER,"$AVAHI_USER", [User for running the Avahi daemon]) - -AC_ARG_WITH(avahi_group,AS_HELP_STRING([--with-avahi-group=],[Group for running avahi-daemon (avahi)])) -if test -z "$with_avahi_group" ; then - AVAHI_GROUP=avahi -else - AVAHI_GROUP=$with_avahi_group -fi -AC_SUBST(AVAHI_GROUP) -AC_DEFINE_UNQUOTED(AVAHI_GROUP,"$AVAHI_GROUP", [Group for Avahi]) - -AC_ARG_WITH(avahi_priv_access_group,AS_HELP_STRING([--with-avahi-priv-access-group=],[Priviliged access group for Avahi clients (netdev)])) -if test -z "$with_avahi_priv_access_group" ; then - AVAHI_PRIV_ACCESS_GROUP=netdev -else - AVAHI_PRIV_ACCESS_GROUP=$with_avahi_priv_access_group -fi -AC_SUBST(AVAHI_PRIV_ACCESS_GROUP) -AC_DEFINE_UNQUOTED(AVAHI_PRIV_ACCESS_GROUP,"$AVAHI_PRIV_ACCESS_GROUP", [Privileged access group for Avahi clients]) - -AC_ARG_WITH(autoipd_user, AS_HELP_STRING([--with-autoipd-user=],[User for running the avahi-autoipd daemon (avahi-autoipd)])) -if test -z "$with_autoipd_user" ; then - AVAHI_AUTOIPD_USER=avahi-autoipd -else - AVAHI_AUTOIPD_USER=$with_autoipd_user -fi -AC_SUBST(AVAHI_AUTOIPD_USER) -AC_DEFINE_UNQUOTED(AVAHI_AUTOIPD_USER,"$AVAHI_AUTOIPD_USER", [User for running the avahi-autoipd daemon]) - -AC_ARG_WITH(autoipd_group,AS_HELP_STRING([--with-autoipd-group=],[Group for running the avahi-autoipd daemon (avahi-autoipd)])) -if test -z "$with_autoipd_group" ; then - AVAHI_AUTOIPD_GROUP=avahi-autoipd -else - AVAHI_AUTOIPD_GROUP=$with_autoipd_group -fi -AC_SUBST(AVAHI_AUTOIPD_GROUP) -AC_DEFINE_UNQUOTED(AVAHI_AUTOIPD_GROUP,"$AVAHI_AUTOIPD_GROUP", [Group for running the avahi-autoipd daemon]) - -# -# Avahi runtime dir -# -avahi_runtime_dir="${localstatedir}/run" -avahi_socket="${avahi_runtime_dir}/avahi-daemon/socket" -AC_SUBST(avahi_runtime_dir) -AC_SUBST(avahi_socket) - -# -# Avahi interfaces dir -# -if test "x$HAVE_PYTHON_DBUS" = "xyes" -o "x$HAVE_GTK" = "xyes"; then - interfacesdir="${datadir}/${PACKAGE}/interfaces/" - AC_SUBST(interfacesdir) -fi - # # Doxygen # @@ -993,45 +350,6 @@ esac],[ENABLE_CORE_DOCS=no]) AM_CONDITIONAL([ENABLE_CORE_DOCS], [test "x$ENABLE_CORE_DOCS" = xyes]) -# -# Build and Install man pages -# -AC_ARG_ENABLE(manpages, - AS_HELP_STRING([--disable-manpages],[Disable building and installation of man pages]), -[case "${enableval}" in - yes) manpages=yes ;; - no) manpages=no ;; - *) AC_MSG_ERROR([bad value ${enableval} for --disable-manpages]) ;; -esac],[manpages=yes]) - -if test x$manpages = xyes ; then - # - # XMLTOMAN manpage generation - # - AC_ARG_ENABLE(xmltoman, - AS_HELP_STRING([--disable-xmltoman],[Disable rebuilding of man pages with xmltoman]), - [case "${enableval}" in - yes) xmltoman=yes ;; - no) xmltoman=no ;; - *) AC_MSG_ERROR([bad value ${enableval} for --disable-xmltoman]) ;; - esac],[xmltoman=yes]) - - if test x$xmltoman = xyes ; then - AC_CHECK_PROG(have_xmltoman, xmltoman, yes, no) - fi - - if test x$have_xmltoman = xno -o x$xmltoman = xno; then - if ! test -e man/avahi-daemon.8 ; then - AC_MSG_ERROR([*** xmltoman was not found or was disabled, it is required to build the manpages as they have not been pre-built, install xmltoman, pass --disable-manpages or dont pass --disable-xmltoman]) - exit 1 - fi - AC_MSG_WARN([*** Not rebuilding man pages as xmltoman is not found ***]) - xmltoman=no - fi -fi -AM_CONDITIONAL([USE_XMLTOMAN], [test "x$xmltoman" = xyes]) -AM_CONDITIONAL([BUILD_MANPAGES], [test "x$manpages" = xyes]) - # # Conditionally compile test and example programs # @@ -1046,86 +364,13 @@ AC_ARG_ENABLE(tests, AM_CONDITIONAL([ENABLE_TESTS], [test "x$ENABLE_TESTS" = "xyes"]) -# -# Optionally enable libdns_sd compatibility support -# -AC_ARG_ENABLE(compat-libdns_sd, - AS_HELP_STRING([--enable-compat-libdns_sd],[Enable compatibility layer for libdns_sd]), - [case "${enableval}" in - yes) ENABLE_COMPAT_LIBDNS_SD=yes ;; - no) ENABLE_COMPAT_LIBDNS_SD=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-compat-libdns_sd) ;; - esac], - [ENABLE_COMPAT_LIBDNS_SD=no]) - -AM_CONDITIONAL([ENABLE_COMPAT_LIBDNS_SD], [test "x$ENABLE_COMPAT_LIBDNS_SD" = "xyes"]) - -# -# Optionally enable HOWL compatibility support -# -AC_ARG_ENABLE(compat-howl, - AS_HELP_STRING([--enable-compat-howl],[Enable compatibility layer for HOWL]), - [case "${enableval}" in - yes) ENABLE_COMPAT_HOWL=yes ;; - no) ENABLE_COMPAT_HOWL=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-compat-howl) ;; - esac], - [ENABLE_COMPAT_HOWL=no]) - -AM_CONDITIONAL([ENABLE_COMPAT_HOWL], [test "x$ENABLE_COMPAT_HOWL" = "xyes"]) - -# -# systemd -# -AC_ARG_WITH([systemdsystemunitdir], - AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), - [], - [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]) -if test "x$with_systemdsystemunitdir" != xno; then - AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) -fi -AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) - # ========================================================================== AC_CONFIG_FILES([ Makefile avahi-common/Makefile avahi-core/Makefile -avahi-glib/Makefile -avahi-gobject/Makefile -avahi-qt/Makefile -avahi-daemon/Makefile -avahi-daemon/avahi-dbus.conf -avahi-discover-standalone/Makefile -avahi-client/Makefile -initscript/Makefile -initscript/debian/Makefile -initscript/gentoo/Makefile -initscript/archlinux/Makefile -initscript/suse/Makefile -initscript/fedora/Makefile -initscript/lfs/Makefile -initscript/mandriva/Makefile -initscript/darwin/Makefile -initscript/freebsd/Makefile -initscript/slackware/Makefile -avahi-dnsconfd/Makefile -avahi-utils/Makefile -avahi-python/Makefile -avahi-python/avahi/Makefile -avahi-python/avahi-discover/Makefile examples/Makefile common/Makefile -man/Makefile -tests/Makefile -service-type-database/Makefile -avahi-sharp/Makefile -avahi-ui-sharp/Makefile -avahi-compat-libdns_sd/Makefile -avahi-compat-howl/Makefile -avahi-compat-howl/samples/Makefile -avahi-autoipd/Makefile -avahi-ui/Makefile po/Makefile.in ]) AC_OUTPUT @@ -1137,101 +382,13 @@ echo " prefix: ${prefix} sysconfdir: ${sysconfdir} localstatedir: ${localstatedir} - avahi socket: ${avahi_socket} - dbus-1 system.d dir: ${DBUS_SYS_DIR} - dbus-1 version: ${DBUS_VERSION} - dbus-1 system socket: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} C Compiler: ${CC} CFLAGS: ${CFLAGS} - Enable GLIB: ${HAVE_GLIB} - Enable GLIB GObject: ${HAVE_GOBJECT} - Enable GObject Introspection: ${found_introspection} - Enable GTK 2.0: ${HAVE_GTK} - Enable GTK 3.0: ${HAVE_GTK3} - Enable D-Bus: ${HAVE_DBUS} - With XML: ${with_xml} - Enable GDBM: ${HAVE_GDBM} - Enable DBM: ${HAVE_DBM} - Enable libdaemon: ${HAVE_LIBDAEMON} - Enable Python: ${HAVE_PYTHON} - Enable pygtk: ${HAVE_PYGTK} - Enable python-dbus: ${HAVE_PYTHON_DBUS} - Enable QT3: ${HAVE_QT3} - Enable QT4: ${HAVE_QT4} - Enable Mono: ${HAVE_MONO} - Enable Monodoc: ${HAVE_MONODOC} - Distribution/OS: ${with_distro} - User for avahi-daemon: ${AVAHI_USER} - Group for avahi-daemon: ${AVAHI_GROUP} - Priviliged access group for Avahi clients: ${AVAHI_PRIV_ACCESS_GROUP} - User for avahi-autoipd: ${AVAHI_AUTOIPD_USER} - Group for avahi-autoipd: ${AVAHI_AUTOIPD_GROUP} - Enable chroot(): ${enable_chroot} - Enable Linux inotify: ${have_inotify} Enable stack-smashing protection: ${enable_ssp} - systemd unit directory: ${with_systemdsystemunitdir} " -BUILD_DAEMON="no (You need libdaemon and expat/bsdxml!)" - -if test "x$HAVE_XML" = "xyes" -a "x$HAVE_LIBDAEMON" = "xyes" ; then - BUILD_DAEMON=yes -fi - -BUILD_PYTHON="no (You need python, pygtk and python-dbus!)" - -if test "x$BUILD_DAEMON" = "xyes" -a "x$HAVE_DBUS" = "xyes" -a "x$HAVE_PYTHON" = "xyes" -a "x$HAVE_PYTHON_DBUS" = "xyes" -a "x$HAVE_PYGTK" = "xyes" ; then - BUILD_PYTHON=yes -fi - -BUILD_CLIENT="no (You need avahi-daemon and D-Bus!)" - -if test "x$BUILD_DAEMON" = "xyes" -a "x$HAVE_DBUS" = "xyes" ; then - BUILD_CLIENT=yes -fi - -if test "x$ENABLE_COMPAT_LIBDNS_SD" = "xyes" -a "x$BUILD_CLIENT" != "xyes" ; then - ENABLE_COMPAT_LIBDNS_SD="no (You need libavahi-client!)" -fi -if test "x$ENABLE_COMPAT_HOWL" = "xyes" -a "x$BUILD_CLIENT" != "xyes" ; then - ENABLE_COMPAT_HOWL="no (You need libavahi-client!)" -fi -if test "x$ENABLE_AUTOIPD" = "xyes" -a "x$HAVE_LIBDAEMON" != "xyes" ; then - ENABLE_AUTOIPD="no (You need libdaemon!)" -fi - -HAVE_GTK2OR3=no -if test "x$HAVE_GTK" = "xyes" -o "x$HAVE_GTK3" = "xyes" ; then - HAVE_GTK2OR3=yes -fi - -BUILD_UI="no" -if test "x$HAVE_GTK2OR3" = "xyes" -a "x$BUILD_CLIENT" = "xyes" ; then - BUILD_UI="yes" -fi - -BUILD_GOBJECT="no" -if test "x$BUILD_CLIENT" = "xyes" -a "x$HAVE_GOBJECT" = "xyes" ; then - BUILD_GOBJECT="yes" -fi - echo "\ Building libavahi-core yes - Building avahi-daemon: ${BUILD_DAEMON} - Building avahi-dnsconfd: ${BUILD_DAEMON} - Building libavahi-client: ${BUILD_CLIENT} - Building avahi-utils: ${BUILD_CLIENT} - Building avahi-python: ${BUILD_PYTHON} - Building libavahi-glib: ${HAVE_GLIB} - Building libavahi-gobject: ${BUILD_GOBJECT} - Building avahi-discover-standalone: ${HAVE_GTK2OR3} - Building libavahi-qt3: ${HAVE_QT3} - Building libavahi-qt4: ${HAVE_QT4} - Building avahi-sharp: ${HAVE_MONO} - Building avahi-compat-libdns_sd: ${ENABLE_COMPAT_LIBDNS_SD} - Building avahi-compat-howl: ${ENABLE_COMPAT_HOWL} Building tests: ${ENABLE_TESTS} Building avahi-core documentation: ${ENABLE_CORE_DOCS} - Building avahi-autoipd: ${ENABLE_AUTOIPD} - Building libavahi-ui: ${BUILD_UI} " diff --git a/examples/Makefile.am b/examples/Makefile.am index dbb7f00..2235000 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -30,34 +30,3 @@ core_publish_service_LDADD = $(AM_LDADD) ../avahi-core/libavahi-core.la ../avahi core_browse_services_SOURCES = core-browse-services.c core_browse_services_CFLAGS = $(AM_CFLAGS) core_browse_services_LDADD = $(AM_LDADD) ../avahi-core/libavahi-core.la ../avahi-common/libavahi-common.la - -if HAVE_DBUS -if ENABLE_TESTS - -noinst_PROGRAMS += \ - client-publish-service \ - client-browse-services -endif - -client_publish_service_SOURCES = client-publish-service.c -client_publish_service_CFLAGS = $(AM_CFLAGS) -client_publish_service_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la - -client_browse_services_SOURCES = client-browse-services.c -client_browse_services_CFLAGS = $(AM_CFLAGS) -client_browse_services_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la - -if HAVE_GLIB - -if ENABLE_TESTS -noinst_PROGRAMS += \ - glib-integration -endif - -glib_integration_SOURCES = glib-integration.c -glib_integration_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS) -glib_integration_LDADD = $(AM_LDADD) $(GLIB20_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la ../avahi-glib/libavahi-glib.la - -endif - -endif diff --git a/examples/client-browse-services.c b/examples/client-browse-services.c deleted file mode 100644 index f7ded2a..0000000 --- a/examples/client-browse-services.c +++ /dev/null @@ -1,197 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -static AvahiSimplePoll *simple_poll = NULL; - -static void resolve_callback( - AvahiServiceResolver *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, - AvahiResolverEvent event, - const char *name, - const char *type, - const char *domain, - const char *host_name, - const AvahiAddress *address, - uint16_t port, - AvahiStringList *txt, - AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void* userdata) { - - assert(r); - - /* Called whenever a service has been resolved successfully or timed out */ - - switch (event) { - case AVAHI_RESOLVER_FAILURE: - fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r)))); - break; - - case AVAHI_RESOLVER_FOUND: { - char a[AVAHI_ADDRESS_STR_MAX], *t; - - fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain); - - avahi_address_snprint(a, sizeof(a), address); - t = avahi_string_list_to_string(txt); - fprintf(stderr, - "\t%s:%u (%s)\n" - "\tTXT=%s\n" - "\tcookie is %u\n" - "\tis_local: %i\n" - "\tour_own: %i\n" - "\twide_area: %i\n" - "\tmulticast: %i\n" - "\tcached: %i\n", - host_name, port, a, - t, - avahi_string_list_get_service_cookie(txt), - !!(flags & AVAHI_LOOKUP_RESULT_LOCAL), - !!(flags & AVAHI_LOOKUP_RESULT_OUR_OWN), - !!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA), - !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST), - !!(flags & AVAHI_LOOKUP_RESULT_CACHED)); - - avahi_free(t); - } - } - - avahi_service_resolver_free(r); -} - -static void browse_callback( - AvahiServiceBrowser *b, - AvahiIfIndex interface, - AvahiProtocol protocol, - AvahiBrowserEvent event, - const char *name, - const char *type, - const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { - - AvahiClient *c = userdata; - assert(b); - - /* Called whenever a new services becomes available on the LAN or is removed from the LAN */ - - switch (event) { - case AVAHI_BROWSER_FAILURE: - - fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b)))); - avahi_simple_poll_quit(simple_poll); - return; - - case AVAHI_BROWSER_NEW: - fprintf(stderr, "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain); - - /* We ignore the returned resolver object. In the callback - function we free it. If the server is terminated before - the callback function is called the server will free - the resolver for us. */ - - if (!(avahi_service_resolver_new(c, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, c))) - fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_client_errno(c))); - - break; - - case AVAHI_BROWSER_REMOVE: - fprintf(stderr, "(Browser) REMOVE: service '%s' of type '%s' in domain '%s'\n", name, type, domain); - break; - - case AVAHI_BROWSER_ALL_FOR_NOW: - case AVAHI_BROWSER_CACHE_EXHAUSTED: - fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); - break; - } -} - -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { - assert(c); - - /* Called whenever the client or server state changes */ - - if (state == AVAHI_CLIENT_FAILURE) { - fprintf(stderr, "Server connection failure: %s\n", avahi_strerror(avahi_client_errno(c))); - avahi_simple_poll_quit(simple_poll); - } -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { - AvahiClient *client = NULL; - AvahiServiceBrowser *sb = NULL; - int error; - int ret = 1; - - /* Allocate main loop object */ - if (!(simple_poll = avahi_simple_poll_new())) { - fprintf(stderr, "Failed to create simple poll object.\n"); - goto fail; - } - - /* Allocate a new client */ - client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error); - - /* Check wether creating the client object succeeded */ - if (!client) { - fprintf(stderr, "Failed to create client: %s\n", avahi_strerror(error)); - goto fail; - } - - /* Create the service browser */ - if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, browse_callback, client))) { - fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client))); - goto fail; - } - - /* Run the main loop */ - avahi_simple_poll_loop(simple_poll); - - ret = 0; - -fail: - - /* Cleanup things */ - if (sb) - avahi_service_browser_free(sb); - - if (client) - avahi_client_free(client); - - if (simple_poll) - avahi_simple_poll_free(simple_poll); - - return ret; -} diff --git a/examples/client-publish-service.c b/examples/client-publish-service.c deleted file mode 100644 index facc965..0000000 --- a/examples/client-publish-service.c +++ /dev/null @@ -1,280 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -static AvahiEntryGroup *group = NULL; -static AvahiSimplePoll *simple_poll = NULL; -static char *name = NULL; - -static void create_services(AvahiClient *c); - -static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) { - assert(g == group || group == NULL); - group = g; - - /* Called whenever the entry group state changes */ - - switch (state) { - case AVAHI_ENTRY_GROUP_ESTABLISHED : - /* The entry group has been established successfully */ - fprintf(stderr, "Service '%s' successfully established.\n", name); - break; - - case AVAHI_ENTRY_GROUP_COLLISION : { - char *n; - - /* A service name collision with a remote service - * happened. Let's pick a new name */ - n = avahi_alternative_service_name(name); - avahi_free(name); - name = n; - - fprintf(stderr, "Service name collision, renaming service to '%s'\n", name); - - /* And recreate the services */ - create_services(avahi_entry_group_get_client(g)); - break; - } - - case AVAHI_ENTRY_GROUP_FAILURE : - - fprintf(stderr, "Entry group failure: %s\n", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g)))); - - /* Some kind of failure happened while we were registering our services */ - avahi_simple_poll_quit(simple_poll); - break; - - case AVAHI_ENTRY_GROUP_UNCOMMITED: - case AVAHI_ENTRY_GROUP_REGISTERING: - ; - } -} - -static void create_services(AvahiClient *c) { - char *n, r[128]; - int ret; - assert(c); - - /* If this is the first time we're called, let's create a new - * entry group if necessary */ - - if (!group) - if (!(group = avahi_entry_group_new(c, entry_group_callback, NULL))) { - fprintf(stderr, "avahi_entry_group_new() failed: %s\n", avahi_strerror(avahi_client_errno(c))); - goto fail; - } - - /* If the group is empty (either because it was just created, or - * because it was reset previously, add our entries. */ - - if (avahi_entry_group_is_empty(group)) { - fprintf(stderr, "Adding service '%s'\n", name); - - /* Create some random TXT data */ - snprintf(r, sizeof(r), "random=%i", rand()); - - /* We will now add two services and one subtype to the entry - * group. The two services have the same name, but differ in - * the service type (IPP vs. BSD LPR). Only services with the - * same name should be put in the same entry group. */ - - /* Add the service for IPP */ - if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_ipp._tcp", NULL, NULL, 651, "test=blah", r, NULL)) < 0) { - - if (ret == AVAHI_ERR_COLLISION) - goto collision; - - fprintf(stderr, "Failed to add _ipp._tcp service: %s\n", avahi_strerror(ret)); - goto fail; - } - - /* Add the same service for BSD LPR */ - if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, NULL, 515, NULL)) < 0) { - - if (ret == AVAHI_ERR_COLLISION) - goto collision; - - fprintf(stderr, "Failed to add _printer._tcp service: %s\n", avahi_strerror(ret)); - goto fail; - } - - /* Add an additional (hypothetic) subtype */ - if ((ret = avahi_entry_group_add_service_subtype(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, "_magic._sub._printer._tcp") < 0)) { - fprintf(stderr, "Failed to add subtype _magic._sub._printer._tcp: %s\n", avahi_strerror(ret)); - goto fail; - } - - /* Tell the server to register the service */ - if ((ret = avahi_entry_group_commit(group)) < 0) { - fprintf(stderr, "Failed to commit entry group: %s\n", avahi_strerror(ret)); - goto fail; - } - } - - return; - -collision: - - /* A service name collision with a local service happened. Let's - * pick a new name */ - n = avahi_alternative_service_name(name); - avahi_free(name); - name = n; - - fprintf(stderr, "Service name collision, renaming service to '%s'\n", name); - - avahi_entry_group_reset(group); - - create_services(c); - return; - -fail: - avahi_simple_poll_quit(simple_poll); -} - -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { - assert(c); - - /* Called whenever the client or server state changes */ - - switch (state) { - case AVAHI_CLIENT_S_RUNNING: - - /* The server has startup successfully and registered its host - * name on the network, so it's time to create our services */ - create_services(c); - break; - - case AVAHI_CLIENT_FAILURE: - - fprintf(stderr, "Client failure: %s\n", avahi_strerror(avahi_client_errno(c))); - avahi_simple_poll_quit(simple_poll); - - break; - - case AVAHI_CLIENT_S_COLLISION: - - /* Let's drop our registered services. When the server is back - * in AVAHI_SERVER_RUNNING state we will register them - * again with the new host name. */ - - case AVAHI_CLIENT_S_REGISTERING: - - /* The server records are now being established. This - * might be caused by a host name change. We need to wait - * for our own records to register until the host name is - * properly esatblished. */ - - if (group) - avahi_entry_group_reset(group); - - break; - - case AVAHI_CLIENT_CONNECTING: - ; - } -} - -static void modify_callback(AVAHI_GCC_UNUSED AvahiTimeout *e, void *userdata) { - AvahiClient *client = userdata; - - fprintf(stderr, "Doing some weird modification\n"); - - avahi_free(name); - name = avahi_strdup("Modified MegaPrinter"); - - /* If the server is currently running, we need to remove our - * service and create it anew */ - if (avahi_client_get_state(client) == AVAHI_CLIENT_S_RUNNING) { - - /* Remove the old services */ - if (group) - avahi_entry_group_reset(group); - - /* And create them again with the new name */ - create_services(client); - } -} - -int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { - AvahiClient *client = NULL; - int error; - int ret = 1; - struct timeval tv; - - /* Allocate main loop object */ - if (!(simple_poll = avahi_simple_poll_new())) { - fprintf(stderr, "Failed to create simple poll object.\n"); - goto fail; - } - - name = avahi_strdup("MegaPrinter"); - - /* Allocate a new client */ - client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error); - - /* Check wether creating the client object succeeded */ - if (!client) { - fprintf(stderr, "Failed to create client: %s\n", avahi_strerror(error)); - goto fail; - } - - /* After 10s do some weird modification to the service */ - avahi_simple_poll_get(simple_poll)->timeout_new( - avahi_simple_poll_get(simple_poll), - avahi_elapse_time(&tv, 1000*10, 0), - modify_callback, - client); - - /* Run the main loop */ - avahi_simple_poll_loop(simple_poll); - - ret = 0; - -fail: - - /* Cleanup things */ - - if (client) - avahi_client_free(client); - - if (simple_poll) - avahi_simple_poll_free(simple_poll); - - avahi_free(name); - - return ret; -} diff --git a/examples/glib-integration.c b/examples/glib-integration.c deleted file mode 100644 index d2a2457..0000000 --- a/examples/glib-integration.c +++ /dev/null @@ -1,146 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include -#include - -/* Callback for Avahi API Timeout Event */ -static void -avahi_timeout_event (AVAHI_GCC_UNUSED AvahiTimeout *timeout, AVAHI_GCC_UNUSED void *userdata) -{ - g_message ("Avahi API Timeout reached!"); -} - -/* Callback for GLIB API Timeout Event */ -static gboolean -avahi_timeout_event_glib (void *userdata) -{ - GMainLoop *loop = userdata; - - g_message ("GLIB API Timeout reached, quitting main loop!"); - - /* Quit the application */ - g_main_loop_quit (loop); - - return FALSE; /* Don't re-schedule timeout event */ -} - -/* Callback for state changes on the Client */ -static void -avahi_client_callback (AVAHI_GCC_UNUSED AvahiClient *client, AvahiClientState state, void *userdata) -{ - GMainLoop *loop = userdata; - - g_message ("Avahi Client State Change: %d", state); - - if (state == AVAHI_CLIENT_FAILURE) - { - /* We we're disconnected from the Daemon */ - g_message ("Disconnected from the Avahi Daemon: %s", avahi_strerror(avahi_client_errno(client))); - - /* Quit the application */ - g_main_loop_quit (loop); - } -} - -int -main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) -{ - GMainLoop *loop = NULL; - const AvahiPoll *poll_api; - AvahiGLibPoll *glib_poll; - AvahiClient *client; - struct timeval tv; - const char *version; - int error; - - /* Optional: Tell avahi to use g_malloc and g_free */ - avahi_set_allocator (avahi_glib_allocator ()); - - /* Create the GLIB main loop */ - loop = g_main_loop_new (NULL, FALSE); - - /* Create the GLIB Adaptor */ - glib_poll = avahi_glib_poll_new (NULL, G_PRIORITY_DEFAULT); - poll_api = avahi_glib_poll_get (glib_poll); - - /* Example, schedule a timeout event with the Avahi API */ - avahi_elapse_time (&tv, /* timeval structure */ - 1000, /* 1 second */ - 0); /* "jitter" - Random additional delay from 0 to this value */ - - poll_api->timeout_new (poll_api, /* The AvahiPoll object */ - &tv, /* struct timeval indicating when to go activate */ - avahi_timeout_event, /* Pointer to function to call */ - NULL); /* User data to pass to function */ - - /* Schedule a timeout event with the glib api */ - g_timeout_add (5000, /* 5 seconds */ - avahi_timeout_event_glib, /* Pointer to function callback */ - loop); /* User data to pass to function */ - - /* Create a new AvahiClient instance */ - client = avahi_client_new (poll_api, /* AvahiPoll object from above */ - 0, - avahi_client_callback, /* Callback function for Client state changes */ - loop, /* User data */ - &error); /* Error return */ - - /* Check the error return code */ - if (client == NULL) - { - /* Print out the error string */ - g_warning ("Error initializing Avahi: %s", avahi_strerror (error)); - - goto fail; - } - - /* Make a call to get the version string from the daemon */ - version = avahi_client_get_version_string (client); - - /* Check if the call suceeded */ - if (version == NULL) - { - g_warning ("Error getting version string: %s", avahi_strerror (avahi_client_errno (client))); - - goto fail; - } - - g_message ("Avahi Server Version: %s", version); - - /* Start the GLIB Main Loop */ - g_main_loop_run (loop); - -fail: - /* Clean up */ - g_main_loop_unref (loop); - avahi_client_free (client); - avahi_glib_poll_free (glib_poll); - - return 0; -} diff --git a/initscript/.gitignore b/initscript/.gitignore deleted file mode 100644 index 282522d..0000000 --- a/initscript/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/initscript/Makefile.am b/initscript/Makefile.am deleted file mode 100644 index e5e1928..0000000 --- a/initscript/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -SUBDIRS = - -if TARGET_LFS -SUBDIRS += lfs -endif - -if TARGET_DEBIAN -SUBDIRS += debian -endif - -if TARGET_ARCHLINUX -SUBDIRS += archlinux -endif - -if TARGET_GENTOO -SUBDIRS += gentoo -endif - -if TARGET_SUSE -SUBDIRS += suse -endif - -if TARGET_FEDORA -SUBDIRS += fedora -endif - -if TARGET_MANDRIVA -SUBDIRS += mandriva -endif - -if TARGET_DARWIN -SUBDIRS += darwin -endif - -if TARGET_FREEBSD -SUBDIRS += freebsd -endif - -if TARGET_SLACKWARE -SUBDIRS += slackware -endif diff --git a/initscript/archlinux/Makefile.am b/initscript/archlinux/Makefile.am deleted file mode 100644 index 2070975..0000000 --- a/initscript/archlinux/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/rc.d - -EXTRA_DIST = \ - avahi-daemon.in \ - avahi-dnsconfd.in - -initd_SCRIPTS = \ - avahi-daemon \ - avahi-dnsconfd - -CLEANFILES = \ - avahi-daemon \ - avahi-dnsconfd - -avahi-daemon: avahi-daemon.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ - -avahi-dnsconfd: avahi-dnsconfd.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ diff --git a/initscript/archlinux/avahi-daemon.in b/initscript/archlinux/avahi-daemon.in deleted file mode 100644 index 6ae252d..0000000 --- a/initscript/archlinux/avahi-daemon.in +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# -# Authors: -# - - -# general config -. /etc/rc.conf -. /etc/rc.d/functions - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DESC="Avahi mDNS/DNS-SD Daemon" -NAME="avahi-daemon" -DAEMON="@sbindir@/$NAME" - -case "$1" in - start) - stat_busy "Starting $DESC" - $DAEMON -D > /dev/null 2>&1 - if [ $? -gt 0 ]; then - stat_fail - else - add_daemon $NAME - stat_done - fi - ;; - stop) - stat_busy "Stopping $DESC" - $DAEMON -k > /dev/null 2>&1 - if [ $? -gt 0 ]; then - stat_fail - else - rm_daemon $NAME - stat_done - fi - ;; - restart) - $0 stop - $0 start - ;; - reload) - stat_busy "Reloading services for $DESC" - $DAEMON -r > /dev/null 2>&1 - if [ $? -gt 0 ]; then - stat_fail - else - stat_done - fi - ;; - *) - echo "usage: $0 {start|stop|restart|reload}" - ;; -esac -exit 0 diff --git a/initscript/archlinux/avahi-dnsconfd.in b/initscript/archlinux/avahi-dnsconfd.in deleted file mode 100755 index c57260e..0000000 --- a/initscript/archlinux/avahi-dnsconfd.in +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# -# Authors: -# - - -# general config -. /etc/rc.conf -. /etc/rc.d/functions - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DESC="Avahi mDNS/DNS-SD DNS Server Configuration Daemon" -NAME="avahi-dnsconfd" -DAEMON="@sbindir@/$NAME" - -case "$1" in - start) - stat_busy "Starting $DESC" - $DAEMON -D > /dev/null 2>&1 - if [ $? -gt 0 ]; then - stat_fail - else - add_daemon $NAME - stat_done - fi - ;; - stop) - stat_busy "Stopping $DESC" - $DAEMON -k > /dev/null 2>&1 - if [ $? -gt 0 ]; then - stat_fail - else - rm_daemon $NAME - stat_done - fi - ;; - restart) - $0 stop - $0 start - ;; - reload) - stat_busy "Reloading services for $DESC" - $DAEMON -r > /dev/null 2>&1 - if [ $? -gt 0 ]; then - stat_fail - else - stat_done - fi - ;; - *) - echo "usage: $0 {start|stop|restart|reload}" - ;; -esac -exit 0 diff --git a/initscript/darwin/Makefile.am b/initscript/darwin/Makefile.am deleted file mode 100644 index d01e5a4..0000000 --- a/initscript/darwin/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = /Library/LaunchDaemons/ - -EXTRA_DIST = \ - org.freedesktop.avahi-daemon.plist.in \ - org.freedesktop.avahi-dnsconfd.plist.in - -initd_SCRIPTS = \ - org.freedesktop.avahi-daemon.plist \ - org.freedesktop.avahi-dnsconfd.plist - -CLEANFILES = \ - org.freedesktop.avahi-daemon.plist \ - org.freedesktop.avahi-dnsconfd.plist - -org.freedesktop.avahi-daemon.plist: org.freedesktop.avahi-daemon.plist.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - -org.freedesktop.avahi-dnsconfd.plist: org.freedesktop.avahi-dnsconfd.plist.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ diff --git a/initscript/darwin/org.freedesktop.avahi-daemon.plist.in b/initscript/darwin/org.freedesktop.avahi-daemon.plist.in deleted file mode 100644 index 135e40c..0000000 --- a/initscript/darwin/org.freedesktop.avahi-daemon.plist.in +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Label - org.freedesktop.avahi-daemon - OnDemand - - ProgramArguments - - @sbindir@/avahi-daemon - - ServiceIPC - - - diff --git a/initscript/darwin/org.freedesktop.avahi-dnsconfd.plist.in b/initscript/darwin/org.freedesktop.avahi-dnsconfd.plist.in deleted file mode 100644 index 822a2c0..0000000 --- a/initscript/darwin/org.freedesktop.avahi-dnsconfd.plist.in +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Label - org.freedesktop.avahi-dnsconfd - OnDemand - - ProgramArguments - - @sbindir@/avahi-dnsconfd - - ServiceIPC - - - diff --git a/initscript/debian/Makefile.am b/initscript/debian/Makefile.am deleted file mode 100644 index 314983d..0000000 --- a/initscript/debian/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/init.d - -EXTRA_DIST = \ - avahi-daemon.in \ - avahi-dnsconfd.in - -initd_SCRIPTS = \ - avahi-daemon \ - avahi-dnsconfd - -CLEANFILES = \ - avahi-daemon \ - avahi-dnsconfd - -avahi-daemon: avahi-daemon.in - sed \ - -e 's,@sbindir\@,$(sbindir),g' \ - -e 's,@sysconfdir\@,$(sysconfdir),g' \ - $< > $@ - chmod +x $@ - -avahi-dnsconfd: avahi-dnsconfd.in - sed \ - -e 's,@sbindir\@,$(sbindir),g' \ - -e 's,@sysconfdir\@,$(sysconfdir),g' \ - $< > $@ - chmod +x $@ diff --git a/initscript/debian/avahi-daemon.in b/initscript/debian/avahi-daemon.in deleted file mode 100755 index 97fa157..0000000 --- a/initscript/debian/avahi-daemon.in +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/sh - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# -# avahi avahi daemon -# Daemon for ZeroConf -# -# Authors: -# - -if [ -f /lib/lsb/init-functions ] -then - . /lib/lsb/init-functions -else - # int log_begin_message (char *message) - log_begin_msg () { - if [ -z "$1" ]; then - return 1 - fi - echo " * $@" - } - - # int log_end_message (int exitstatus) - log_end_msg () { - - # If no arguments were passed, return - [ -z "$1" ] && return 1 - - # Only do the fancy stuff if we have an appropriate terminal - # and if /usr is already mounted - TPUT=/usr/bin/tput - EXPR=/usr/bin/expr - if [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1; then - COLS=`$TPUT cols` - if [ -n "$COLS" ]; then - COL=`$EXPR $COLS - 7` - else - COL=73 - fi - UP=`$TPUT cuu1` - END=`$TPUT hpa $COL` - START=`$TPUT hpa 0` - RED=`$TPUT setaf 1` - NORMAL=`$TPUT op` - if [ $1 -eq 0 ]; then - echo "$UP$END[ ok ]" - else - echo -e "$UP$START $RED*$NORMAL$END[${RED}fail${NORMAL}]" - fi - else - if [ $1 -eq 0 ]; then - echo " ...done." - else - echo " ...fail!" - fi - fi - return $1 - } - - log_warning_msg () { - if log_use_fancy_output; then - YELLOW=`$TPUT setaf 3` - NORMAL=`$TPUT op` - echo "$YELLOW*$NORMAL $@" - else - echo "$@" - fi - } - -fi - -#set -e - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DESC="Avahi mDNS/DNS-SD Daemon" -NAME="avahi-daemon" -DAEMON="@sbindir@/$NAME" -SCRIPTNAME=/etc/init.d/$NAME - -# Gracefully exit if the package has been removed. -test -x $DAEMON || exit 0 - -# don't start if /etc/default/avahi-daemon says so. -AVAHI_DAEMON_START=1 -test -f /etc/default/avahi-daemon && . /etc/default/avahi-daemon - -if [ "$AVAHI_DAEMON_START" != "1" -a "$1" != "stop" ]; then - log_warning_msg "Not starting $DESC $NAME, disabled via /etc/default/$NAME" - exit 0 -fi - -# -# Function that starts the daemon/service. -# -d_start() { - modprobe capability >/dev/null 2>&1 || true - - $DAEMON -c && return 0 - - if [ -s /etc/localtime ]; then - if [ ! -d /etc/avahi/etc ]; then - mkdir -p @sysconfdir@/avahi/etc >/dev/null 2>&1 - fi - cp -fp /etc/localtime @sysconfdir@/avahi/etc >/dev/null 2>&1 - fi; - - $DAEMON -D -} - -# -# Function that stops the daemon/service. -# -d_stop() { - $DAEMON -c && $DAEMON -k -} - -# -# Function that reload the config file for the daemon/service. -# -d_reload() { - $DAEMON -c && $DAEMON -r -} - -# -# Function that check the status of the daemon/service. -# -d_status() { - $DAEMON -c && echo "$DESC is running" || echo "$DESC is not running" -} - -case "$1" in - start) - log_begin_msg "Starting $DESC: $NAME" - d_start - log_end_msg $? - ;; - stop) - log_begin_msg "Stopping $DESC: $NAME" - d_stop - log_end_msg $? - ;; - reload) - log_begin_msg "Reloading services for $DESC: $NAME" - d_reload - log_end_msg $? - ;; - restart|force-reload) - log_begin_msg "Restarting $DESC: $NAME" - $DAEMON -c && d_stop - d_start - log_end_msg $? - ;; - status) - d_status - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/initscript/debian/avahi-dnsconfd.in b/initscript/debian/avahi-dnsconfd.in deleted file mode 100755 index 67c2873..0000000 --- a/initscript/debian/avahi-dnsconfd.in +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/sh - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# -# avahi-dnsconfd avahi dns configuration daemon -# Daemon for ZeroConf -# -# Authors: -# - -if [ -f /lib/lsb/init-functions ] -then - . /lib/lsb/init-functions -else - # int log_begin_message (char *message) - log_begin_msg () { - if [ -z "$1" ]; then - return 1 - fi - echo " * $@" - } - - # int log_end_message (int exitstatus) - log_end_msg () { - - # If no arguments were passed, return - [ -z "$1" ] && return 1 - - # Only do the fancy stuff if we have an appropriate terminal - # and if /usr is already mounted - TPUT=/usr/bin/tput - EXPR=/usr/bin/expr - if [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1; then - COLS=`$TPUT cols` - if [ -n "$COLS" ]; then - COL=`$EXPR $COLS - 7` - else - COL=73 - fi - UP=`$TPUT cuu1` - END=`$TPUT hpa $COL` - START=`$TPUT hpa 0` - RED=`$TPUT setaf 1` - NORMAL=`$TPUT op` - if [ $1 -eq 0 ]; then - echo "$UP$END[ ok ]" - else - echo -e "$UP$START $RED*$NORMAL$END[${RED}fail${NORMAL}]" - fi - else - if [ $1 -eq 0 ]; then - echo " ...done." - else - echo " ...fail!" - fi - fi - return $1 - } - - log_warning_msg () { - if log_use_fancy_output; then - YELLOW=`$TPUT setaf 3` - NORMAL=`$TPUT op` - echo "$YELLOW*$NORMAL $@" - else - echo "$@" - fi - } - -fi - -#set -e - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DESC="Avahi Unicast DNS Configuration Daemon" -NAME="avahi-dnsconfd" -DAEMON="@sbindir@/$NAME" -SCRIPTNAME=/etc/init.d/$NAME - -# Gracefully exit if the package has been removed. -test -x $DAEMON || exit 0 - -# don't start if /etc/default/avahi-dnsconfd says so. -AVAHI_DNSCONFD_START=1 -test -f /etc/default/avahi-dnsconfd && . /etc/default/avahi-dnsconfd - -if [ "$AVAHI_DNSCONFD_START" != "1" -a "$1" != "stop" ]; then - log_warning_msg "Not starting $DESC $NAME, disabled via /etc/default/$NAME" - exit 0 -fi - -# -# Function that starts the daemon/service. -# -d_start() { - $DAEMON -c - [ $? = 0 ] && exit 0 - - if [ -s /etc/localtime ]; then - if [ ! -d /etc/avahi/etc ]; then - mkdir -p @sysconfdir@/avahi/etc >/dev/null 2>&1 - fi - cp -fp /etc/localtime @sysconfdir@/avahi/etc >/dev/null 2>&1 - fi; - - $DAEMON -D -} - -# -# Function that stops the daemon/service. -# -d_stop() { - $DAEMON -c - [ $? != 0 ] && exit 0 - - $DAEMON -k -} - -# -# Function that reload the config file for the daemon/service. -# -d_refresh() { - $DAEMON -c - [ $? != 0 ] && exit 0 - - $DAEMON -r -} - -# -# Function that check the status of the daemon/service. -# -d_status() { - $DAEMON -c - [ $? = 0 ] && echo "$DESC is running" || echo "$DESC is not running" -} - -case "$1" in - start) - log_begin_msg "Starting $DESC: $NAME" - d_start - log_end_msg $? - ;; - stop) - log_begin_msg "Stopping $DESC: $NAME" - d_stop - log_end_msg $? - ;; - refresh) - log_begin_msg "Refreshing $DESC: $NAME" - d_refresh - log_end_msg $? - ;; - reload|restart|force-reload) - log_begin_msg "Restarting $DESC: $NAME" - $DAEMON -c && d_stop - d_start - log_end_msg $? - ;; - status) - d_status - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/initscript/fedora/.gitignore b/initscript/fedora/.gitignore deleted file mode 100644 index fd8f359..0000000 --- a/initscript/fedora/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile -Makefile.in -avahi-daemon -avahi-dnsconfd diff --git a/initscript/fedora/Makefile.am b/initscript/fedora/Makefile.am deleted file mode 100644 index 93a4138..0000000 --- a/initscript/fedora/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/rc.d/init.d - -EXTRA_DIST = avahi-daemon.in avahi-dnsconfd.in - -initd_SCRIPTS = avahi-daemon avahi-dnsconfd - -CLEANFILES = avahi-daemon avahi-dnsconfd - -avahi-daemon: avahi-daemon.in - $(AM_V_GEN)sed \ - -e 's,@sbindir\@,$(sbindir),g' \ - -e 's,@localstatedir\@,$(localstatedir),g' \ - $< > $@ && \ - chmod +x $@ - -avahi-dnsconfd: avahi-dnsconfd.in - $(AM_V_GEN)sed \ - -e 's,@sbindir\@,$(sbindir),g' \ - -e 's,@localstatedir\@,$(localstatedir),g' \ - $< > $@ && \ - chmod +x $@ diff --git a/initscript/fedora/avahi-daemon.in b/initscript/fedora/avahi-daemon.in deleted file mode 100644 index 5a8f430..0000000 --- a/initscript/fedora/avahi-daemon.in +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/sh -# -# avahi-daemon: Starts the Avahi mDNS/DNS-SD Stack -# -# chkconfig: 345 24 02 -# description: This is a daemon which runs on client machines to \ -# perform Zeroconf service discovery on a \ -# network. avahi-daemon must be running on systems that \ -# use Avahi for service discovery. Avahi-daemon should \ -# not be running otherwise. -# processname: avahi-daemon -# pidfile: @localstatedir@/run/avahi-daemon/pid - -### BEGIN INIT INFO -# Required-Start: messagebus -# Required-Stop: messagebus -# Should-Start: $syslog $network $local_fs -# Should-Stop: $syslog $local_fs -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Starts the Avahi Daemon -# Description: This is a daemon which runs on client machines to -# perform Zeroconf service discovery on a -# network. avahi-daemon must be running on systems -# that use Avahi for service discovery. -# Avahi-daemon should not be running otherwise. -### END INIT INFO - -AVAHI_BIN=@sbindir@/avahi-daemon -AVAHI_OPTS="-D" - -if [ "$1" = 'status' ]; then - test -x $AVAHI_BIN || exit 4 -else - test -x $AVAHI_BIN || exit 5 -fi - -# Source function library. -. /etc/init.d/functions -. /etc/sysconfig/network - -LOCKFILE=@localstatedir@/lock/subsys/avahi-daemon -PIDFILE=@localstatedir@/run/avahi-daemon/pid -RETVAL=0 - -base=${0##*/} - -start() { - # Check that networking is configured. - [ ${NETWORKING} = "no" ] && exit 1 - - echo -n $"Starting Avahi daemon... " - if [ -s /etc/localtime ]; then - cp -fp /etc/localtime /etc/avahi/etc >/dev/null 2>&1 - fi; - daemon --pidfile=${PIDFILE} $AVAHI_BIN $AVAHI_OPTS - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch ${LOCKFILE} - return $RETVAL -} - -stop() { - echo -n $"Shutting down Avahi daemon: " - killproc -p ${PIDFILE} $AVAHI_BIN - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f ${LOCKFILE} ${PIDFILE} - echo - return $RETVAL -} - -reload() { - echo -n $"Reloading Avahi daemon... " - killproc -p ${PIDFILE} $AVAHI_BIN -HUP - RETVAL=$? - echo - return $RETVAL -} - -restart() { - stop - start -} - -RETVAL=0 - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status -p ${PIDFILE} $AVAHI_BIN - RETVAL=$? - ;; - restart) - restart - ;; - reload) - reload - ;; - condrestart) - if [ -f $LOCKFILE ]; then - restart - fi - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart}" - exit 2 - ;; -esac - -exit $RETVAL diff --git a/initscript/fedora/avahi-dnsconfd.in b/initscript/fedora/avahi-dnsconfd.in deleted file mode 100644 index bd4182e..0000000 --- a/initscript/fedora/avahi-dnsconfd.in +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh -# -# avahi-dnsconfd: Starts the Avahi DNS Configuration Daemon -# -# chkconfig: - 96 02 -# description: avahi-dnsconfd connects to a running avahi-daemon and \ -# runs the script /etc/avahi/dnsconf.action for each \ -# unicast DNS server that is announced on the local \ -# LAN. This is useful for configuring unicast DNS servers \ -# in a DHCP-like fashion with mDNS. -# processname: avahi-dnsconfd -# pidfile: @localstatedir@/run/avahi-dnsconfd.pid - -### BEGIN INIT INFO -# Required-Start: avahi-daemon -# Required-Stop: avahi-daemon -# Should-Start: $syslog $network $local_fs -# Should-Stop: $syslog $local_fs -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Starts the Avahi DNS Configuration Daemon -# Description: avahi-dnsconfd connects to a running avahi-daemon -# and runs the script /etc/avahi/dnsconf.action for -# each unicast DNS server that is announced on the -# local LAN. This is useful for configuring unicast -# DNS servers in a DHCP-like fashion with mDNS. -### END INIT INFO - -AVAHI_BIN=@sbindir@/avahi-dnsconfd -AVAHI_OPTS="-D" - -if [ "$1" = 'status' ]; then - test -x $AVAHI_BIN || exit 4 -else - test -x $AVAHI_BIN || exit 5 -fi - -# Source function library. -. /etc/init.d/functions -. /etc/sysconfig/network - -LOCKFILE=@localstatedir@/lock/subsys/avahi-dnsconfd -PIDFILE=@localstatedir@/run/avahi-dnsconfd.pid -RETVAL=0 - -base=${0##*/} - -start() { - # Check that networking is configured. - [ ${NETWORKING} = "no" ] && exit 1 - - echo -n $"Starting Avahi DNS daemon... " - daemon --pidfile=${PIDFILE} $AVAHI_BIN $AVAHI_OPTS - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch ${LOCKFILE} - return $RETVAL -} - -stop() { - echo -n $"Shutting down Avahi DNS daemon: " - killproc -p ${PIDFILE} $AVAHI_BIN - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f ${LOCKFILE} ${PIDFILE} - echo - return $RETVAL -} - -reload() { - echo -n $"Reloading Avahi DNS daemon... " - killproc -p ${PIDFILE} $AVAHI_BIN -HUP - RETVAL=$? - echo - return $RETVAL -} - -restart() { - stop - start -} - -RETVAL=0 - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status -p ${PIDFILE} $AVAHI_BIN - RETVAL=$? - ;; - restart) - restart - ;; - reload) - reload - ;; - condrestart) - if [ -f $LOCKFILE ]; then - restart - fi - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart}" - exit 2 - ;; -esac - -exit $RETVAL diff --git a/initscript/freebsd/Makefile.am b/initscript/freebsd/Makefile.am deleted file mode 100644 index c32830e..0000000 --- a/initscript/freebsd/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/rc.d - -EXTRA_DIST = \ - avahi-daemon.sh.in \ - avahi-dnsconfd.sh.in - -initd_SCRIPTS = \ - avahi-daemon.sh \ - avahi-dnsconfd.sh - -CLEANFILES = \ - avahi-daemon.sh \ - avahi-dnsconfd.sh - -avahi-daemon.sh: avahi-daemon.sh.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ - -avahi-dnsconfd.sh: avahi-dnsconfd.sh.in - sed \ - -e 's,@sbindir\@,$(sbindir),g' \ - -e 's,@sysconfdir\@,$(sysconfdir),g' \ - $< > $@ - chmod +x $@ diff --git a/initscript/freebsd/avahi-daemon.sh.in b/initscript/freebsd/avahi-daemon.sh.in deleted file mode 100644 index f3da39f..0000000 --- a/initscript/freebsd/avahi-daemon.sh.in +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# $FreeBSD: /repoman/r/pcvs/ports/net/avahi/files/avahi-daemon.sh,v 1.2 2005/11/19 05:55:56 marcus Exp $ -# -# PROVIDE: avahi_daemon -# REQUIRE: DAEMON dbus -# KEYWORD: FreeBSD -# -# Avahi's mDNSResponder, a Zeroconf (Bonjour) service advertisement daemon. -# - -avahi_daemon_enable=${avahi_daemon_enable-"NO"} -avahi_daemon_flags=${avahi_daemon_flags-"-D"} - -. /etc/rc.subr - -name=avahi_daemon -rcvar=`set_rcvar` - -start_cmd=avahi_daemon_start -stop_cmd=avahi_daemon_stop - -avahi_daemon_bin=@sbindir@/avahi-daemon - -avahi_daemon_start() { - checkyesno avahi_daemon_enable && echo "Starting avahi-daemon." && \ - ${avahi_daemon_bin} ${avahi_daemon_flags} -} - -avahi_daemon_stop() { - checkyesno avahi_daemon_enable && echo "Stopping avahi-daemon." && \ - ${avahi_daemon_bin} -k -} - -load_rc_config ${name} -run_rc_command "$1" diff --git a/initscript/freebsd/avahi-dnsconfd.sh.in b/initscript/freebsd/avahi-dnsconfd.sh.in deleted file mode 100644 index c034dca..0000000 --- a/initscript/freebsd/avahi-dnsconfd.sh.in +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# $FreeBSD: /repoman/r/pcvs/ports/net/avahi/files/avahi-dnsconfd.sh,v 1.4 2005/11/19 06:36:09 ahze Exp $ -# -# PROVIDE: avahi_dnsconfd -# REQUIRE: DAEMON dbus avahi_daemon -# KEYWORD: FreeBSD -# -# avahi-dnsconfd connects to a running avahi-daemon and runs the script -# @sysconfdir@/avahi/avahi-dnsconfd.action for each unicast DNS server that -# is announced on the local LAN. This is useful for configuring unicast -# DNS servers in a DHCP-like fashion with mDNS. -# - -avahi_dnsconfd_enable=${avahi_dnsconfd_enable-"NO"} -avahi_dnsconfd_flags=${avahi_dnsconfd_flags-"-D"} - -. /etc/rc.subr - -name=avahi_dnsconfd -rcvar=`set_rcvar` - -start_cmd=avahi_dnsconfd_start -stop_cmd=avahi_dnsconfd_stop - -avahi_dnsconfd_bin=@sbindir@/avahi-dnsconfd - -avahi_dnsconfd_start() { - checkyesno avahi_dnsconfd_enable && echo "Starting avahi-dnsconfd." && \ - ${avahi_dnsconfd_bin} ${avahi_dnsconfd_flags} -} - -avahi_dnsconfd_stop() { - checkyesno avahi_dnsconfd_enable && echo "Stopping avahi-dnsconfd." && \ - ${avahi_dnsconfd_bin} -k -} - -load_rc_config ${name} -run_rc_command "$1" diff --git a/initscript/gentoo/Makefile.am b/initscript/gentoo/Makefile.am deleted file mode 100644 index 0d20ca6..0000000 --- a/initscript/gentoo/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -if !HAVE_DBUS -NO_DBUS_DEPENDENCY=/need dbus/d -endif - -initddir = $(sysconfdir)/init.d - -EXTRA_DIST = \ - avahi-daemon.in \ - avahi-dnsconfd.in - -initd_SCRIPTS = \ - avahi-daemon \ - avahi-dnsconfd - -CLEANFILES = \ - avahi-daemon \ - avahi-dnsconfd - -avahi-daemon: avahi-daemon.in - - sed -e 's,@sbindir\@,$(sbindir),g; $(NO_DBUS_DEPENDENCY)' $< > $@ - chmod +x $@ - -avahi-dnsconfd: avahi-dnsconfd.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ diff --git a/initscript/gentoo/avahi-daemon.in b/initscript/gentoo/avahi-daemon.in deleted file mode 100644 index 02eefe6..0000000 --- a/initscript/gentoo/avahi-daemon.in +++ /dev/null @@ -1,29 +0,0 @@ -#!/sbin/runscript -# Copyright 1999-2007 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -opts="reload" - -depend() { - before netmount nfsmount - use net - need dbus -} - -start() { - ebegin "Starting avahi-daemon" - @sbindir@/avahi-daemon -D - eend $? -} - -stop() { - ebegin "Stopping avahi-daemon" - @sbindir@/avahi-daemon -k - eend $? -} - -reload() { - ebegin "Reloading avahi-daemon" - @sbindir@/avahi-daemon -r - eend $? -} diff --git a/initscript/gentoo/avahi-dnsconfd.in b/initscript/gentoo/avahi-dnsconfd.in deleted file mode 100644 index 376067e..0000000 --- a/initscript/gentoo/avahi-dnsconfd.in +++ /dev/null @@ -1,28 +0,0 @@ -#!/sbin/runscript -# Copyright 1999-2007 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -opts="reload" - -depend() { - need avahi-daemon - use net -} - -start() { - ebegin "Starting avahi-dnsconfd" - @sbindir@/avahi-dnsconfd -D - eend $? -} - -stop() { - ebegin "Stopping avahi-dnsconfd" - @sbindir@/avahi-dnsconfd -k - eend $? -} - -reload() { - ebegin "Reloading avahi-dnsconfd" - @sbindir@/avahi-dnsconfd -r - eend $? -} diff --git a/initscript/lfs/Makefile.am b/initscript/lfs/Makefile.am deleted file mode 100644 index ed8dcb8..0000000 --- a/initscript/lfs/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/rc.d/init.d - -EXTRA_DIST = avahi.in - -initd_SCRIPTS = avahi - -CLEANFILES = avahi - -avahi: avahi.in - $(AM_V_GEN)sed \ - -e 's,@sbindir\@,$(sbindir),g' \ - -e 's,@localstatedir\@,$(localstatedir),g' \ - $< > $@ && \ - chmod +x $@ diff --git a/initscript/lfs/avahi.in b/initscript/lfs/avahi.in deleted file mode 100644 index ba3672a..0000000 --- a/initscript/lfs/avahi.in +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $rc_base/init.d/avahi -# -# Description : Avahi daemon loader -# -# Authors : William Immendorf - will.immendorf@gmail.com -# -# Version : 00.00 -# -# Notes : Based off of the LFS 6.4 sysklogd script. -# -######################################################################## - -. /etc/sysconfig/rc -. ${rc_functions} - -case "${1}" in - start) - boot_mesg "Starting the Avahi daemon..." - loadproc avahi-daemon -D - ;; - - stop) - boot_mesg "Stopping the Avahi daemon..." - avahi-daemon -k - evaluate_retval - ;; - - reload) - boot_mesg "Reloading the Avahi daemon..." - reloadproc avahi-daemon -r - ;; - restart) - ${0} stop - sleep 1 - ${0} start - ;; - - status) - statusproc avahi-daemon - ;; - *) - echo "Usage: ${0} {start|stop|reload|restart|status}" - exit 1 - ;; -esac - -# End $rc_base/init.d/avahi diff --git a/initscript/mandriva/Makefile.am b/initscript/mandriva/Makefile.am deleted file mode 100644 index 480426b..0000000 --- a/initscript/mandriva/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/rc.d/init.d - -EXTRA_DIST = avahi-daemon.in avahi-dnsconfd.in - -initd_SCRIPTS = avahi-daemon avahi-dnsconfd - -CLEANFILES = avahi-daemon avahi-dnsconfd - -avahi-daemon: avahi-daemon.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ - -avahi-dnsconfd: avahi-dnsconfd.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ diff --git a/initscript/mandriva/avahi-daemon.in b/initscript/mandriva/avahi-daemon.in deleted file mode 100644 index d81b9a2..0000000 --- a/initscript/mandriva/avahi-daemon.in +++ /dev/null @@ -1,94 +0,0 @@ -#! /bin/sh -# -### BEGIN INIT INFO -# Provides: avahi -# Required-Start: $network messagebus -# Required-Stop: $network messagebus -# Default-Start: 3 5 -# Description: Avahi, a ZeroConf daemon whichs implements an mDNS stack -### END INIT INFO - -AVAHI_BIN=@sbindir@/avahi-daemon -test -x $AVAHI_BIN || exit 5 - -# Source function library. -. /etc/init.d/functions - -. /etc/sysconfig/network - -# Check that networking is configured. -[ "${NETWORKING}" = "no" ] && exit 0 - -start() { - echo -n $"Starting Avahi daemon: " - $AVAHI_BIN -D - RETVAL=$? - if [ $RETVAL = 0 ]; then - touch /var/lock/subsys/avahi-daemon - success $"$base startup" - else - failure $"$base startup" - fi - echo - return $RETVAL -} - -stop() { - echo -n "Shutting down Avahi daemon: " - $AVAHI_BIN -k - RETVAL=$? - if [ $RETVAL = 0 ]; then - rm -f /var/lock/subsys/avahi-daemon - success $"$base stop" - else - failure $"$base stop" - fi - echo - return $RETVAL -} - -reload() { - echo -n "Reloading Avahi daemon: " - $AVAHI_BIN -r - RETVAL=$? - [ $RETVAL = 0 ] && success $"$base startup" || failure $"$base startup" - echo - return $RETVAL -} - - -restart() { - stop - start -} - -RETVAL=0 - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - $AVAHI_BIN -c - [ $? = 0 ] && echo "Avahi daemon is running" || echo "Avahi daemon is not running" - ;; - restart) - restart - ;; - reload) - reload - ;; - condrestart) - $AVAHI_BIN -c - [ $? = 0 ] && restart || : - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart}" - exit 1 -esac - -exit $? diff --git a/initscript/mandriva/avahi-dnsconfd.in b/initscript/mandriva/avahi-dnsconfd.in deleted file mode 100644 index a221356..0000000 --- a/initscript/mandriva/avahi-dnsconfd.in +++ /dev/null @@ -1,94 +0,0 @@ -#! /bin/sh -# -### BEGIN INIT INFO -# Provides: avahi-dnsconfd -# Required-Start: avahi -# Required-Stop: avahi -# Default-Start: 3 5 -# Description: A DNS configuration daemon using mDNS in a DHCP-like fashion -### END INIT INFO - -AVAHI_BIN=@sbindir@/avahi-dnsconfd -test -x $AVAHI_BIN || exit 5 - -# Source function library. -. /etc/init.d/functions - -. /etc/sysconfig/network - -# Check that networking is configured. -[ ${NETWORKING} = "no" ] && exit 0 - -start() { - echo -n $"Starting Avahi DNS daemon: " - $AVAHI_BIN -D - RETVAL=$? - if [ $RETVAL = 0 ]; then - touch /var/lock/subsys/avahi-dnsconfd - success $"$base startup" - else - failure $"$base startup" - fi - echo - return $RETVAL -} - -stop() { - echo -n "Shutting down Avahi DNS daemon: " - $AVAHI_BIN -k - RETVAL=$? - if [ $RETVAL = 0 ]; then - rm -f /var/lock/subsys/avahi-dnsconfd - success $"$base stop" - else - failure $"$base stop" - fi - echo - return $RETVAL -} - -reload() { - echo -n "Reloading Avahi DNS daemon: " - $AVAHI_BIN -r - RETVAL=$? - [ $RETVAL = 0 ] && success $"$base startup" || failure $"$base startup" - echo - return $RETVAL -} - - -restart() { - stop - start -} - -RETVAL=0 - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - $AVAHI_BIN -c - [ $? = 0 ] && echo "Avahi DNS daemon is running" || echo "Avahi DNS daemon is not running" - ;; - restart) - restart - ;; - reload) - reload - ;; - condrestart) - $AVAHI_BIN -c - [ $? = 0 ] && restart || : - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart}" - exit 1 -esac - -exit $? diff --git a/initscript/slackware/Makefile.am b/initscript/slackware/Makefile.am deleted file mode 100644 index d415387..0000000 --- a/initscript/slackware/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/rc.d - -EXTRA_DIST = avahi-daemon.in avahi-dnsconfd.in - -initd_SCRIPTS = rc.avahidaemon rc.avahidnsconfd - -CLEANFILES = rc.avahidaemon rc.avahidnsconfd - -rc.avahidaemon: avahi-daemon.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ - -rc.avahidnsconfd: avahi-dnsconfd.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ diff --git a/initscript/slackware/avahi-daemon.in b/initscript/slackware/avahi-daemon.in deleted file mode 100644 index 76bf2f2..0000000 --- a/initscript/slackware/avahi-daemon.in +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# Start/stop/restart the avahi daemon: - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DESC="Avahi mDNS/DNS-SD Daemon" -NAME="avahi-daemon" -DAEMON="@sbindir@/$NAME" - -avahid_start() -{ - echo "Starting $DESC: $DAEMON -D" - $DAEMON -D -} - -avahid_status() -{ - $DAEMON -c - [ $? = 0 ] -} - -avahid_stop() -{ - echo -en "Stopping $DESC: " - $DAEMON -c - [ $? != 0 ] - echo "stopped"; - $DAEMON -k 2>/dev/null -} - -avahid_restart() -{ - avahid_stop - avahid_start -} - -case "$1" in -'start') - if ( ! avahid_status ); then - avahid_start - else - echo "$DESC is already running (will not start it twice)." - fi - ;; -'stop') - avahid_stop - ;; -'restart') - avahid_restart - ;; -'status') - if ( avahid_status ); then - echo "$DESC is currently running" - else - echo "$DESC is not running." - fi - ;; -*) - echo "usage $0 start|stop|status|restart" -esac - diff --git a/initscript/slackware/avahi-dnsconfd.in b/initscript/slackware/avahi-dnsconfd.in deleted file mode 100644 index ea1554d..0000000 --- a/initscript/slackware/avahi-dnsconfd.in +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# Start/stop/restart the avahi dnsconfd daemon: - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DESC="Avahi mDNS/DNS-SD DNS Server Configuration Daemon" -NAME="avahi-dnsconfd" -DAEMON="@sbindir@/$NAME" - -avahidns_start() -{ - echo "Starting $DESC: $DAEMON -D" - $DAEMON -D -} - -avahidns_status() -{ - $DAEMON -c - [ $? = 0 ] -} - -avahidns_stop() -{ - echo -en "Stopping $DESC: " - $DAEMON -c - [ $? != 0 ] - echo "stopped"; - $DAEMON -k 2>/dev/null -} - -avahidns_restart() -{ - avahidns_stop - avahidns_start -} - -case "$1" in -'start') - if ( ! avahidns_status ); then - avahidns_start - else - echo "$DESC is already running (will not start it twice)." - fi - ;; -'stop') - avahidns_stop - ;; -'restart') - avahidns_restart - ;; -'status') - if ( avahidns_status ); then - echo "$DESC is currently running" - else - echo "$DESC is not running." - fi - ;; -*) - echo "usage $0 start|stop|status|restart" -esac - diff --git a/initscript/suse/Makefile.am b/initscript/suse/Makefile.am deleted file mode 100644 index 5624bdc..0000000 --- a/initscript/suse/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -initddir = $(sysconfdir)/init.d - -EXTRA_DIST = avahi-daemon.in avahi-dnsconfd.in - -initd_SCRIPTS = avahi-daemon avahi-dnsconfd - -CLEANFILES = avahi-daemon avahi-dnsconfd - -avahi-daemon: avahi-daemon.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ - -avahi-dnsconfd: avahi-dnsconfd.in - sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod +x $@ diff --git a/initscript/suse/avahi-daemon.in b/initscript/suse/avahi-daemon.in deleted file mode 100644 index 0dc5f9f..0000000 --- a/initscript/suse/avahi-daemon.in +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: avahi -# Required-Start: $network $remote_fs dbus -# Required-Stop: $network $remote_fs dbus -# Default-Start: 3 5 -# Default-Stop: -# Short-Description: ZeroConf daemon -# Description: Avahi, a ZeroConf daemon for mDNS and service registration -### END INIT INFO - -AVAHI_BIN=@sbindir@/avahi-daemon -test -x $AVAHI_BIN || exit 5 - -. /etc/rc.status -rc_reset - -case "$1" in - start) - echo -n "Starting Avahi daemon " - $AVAHI_BIN -D - rc_status -v - ;; - stop) - echo -n "Shutting down Avahi daemon " - $AVAHI_BIN -k 2>/dev/null || /bin/true - rc_status -v - ;; - try-restart|condrestart) - if test "$1" = "condrestart"; then - echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" - fi - $0 status - if test $? = 0; then - $0 restart - else - rc_reset - fi - rc_status - ;; - restart) - $0 stop - $0 start - rc_status - ;; - force-reload|reload) - echo -n "Reloading Avahi daemon " - $AVAHI_BIN -r - rc_status -v - ;; - status) - echo -n "Checking for Avahi daemon: " - $AVAHI_BIN -c || _rc_status=3 - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" - exit 1 - ;; -esac diff --git a/initscript/suse/avahi-dnsconfd.in b/initscript/suse/avahi-dnsconfd.in deleted file mode 100644 index b88660b..0000000 --- a/initscript/suse/avahi-dnsconfd.in +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: avahi-dnsconfd -# Required-Start: $remote_fs avahi -# Required-Stop: $remote_fs avahi -# Default-Start: 3 5 -# Default-Stop: -# Short-Description: ZeroConf daemon -# Description: Avahi, a ZeroConf daemon for mDNS and service registration -### END INIT INFO - -AVAHI_BIN=@sbindir@/avahi-dnsconfd -test -x $AVAHI_BIN || exit 5 - -. /etc/rc.status -rc_reset - -case "$1" in - start) - echo -n "Starting Avahi DNS Configuration daemon " - $AVAHI_BIN -D - rc_status -v - ;; - stop) - echo -n "Shutting down Avahi DNS Configuration daemon " - $AVAHI_BIN -k 2>/dev/null || /bin/true - rc_status -v - ;; - restart) - $0 stop - $0 start - rc_status - ;; - try-restart|condrestart) - if test "$1" = "condrestart"; then - echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" - fi - $0 status - if test $? = 0; then - $0 restart - else - rc_reset - fi - rc_status - ;; - force-reload|reload) - echo -n "Reloading Avahi DNS Configuration daemon " - $AVAHI_BIN -r - rc_status -v - ;; - status) - echo -n "Checking for Avahi DNS Configuration daemon: " - $AVAHI_BIN -c || _rc_status=3 - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" - exit 1 - ;; -esac diff --git a/man/.gitignore b/man/.gitignore deleted file mode 100644 index b86c09c..0000000 --- a/man/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.1 -*.8 -*.5 -*.1.xml -*.8.xml -*.5.xml -Makefile -Makefile.in diff --git a/man/Makefile.am b/man/Makefile.am deleted file mode 100644 index d38267c..0000000 --- a/man/Makefile.am +++ /dev/null @@ -1,154 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -pkgsysconfdir=$(sysconfdir)/avahi -servicedir=$(pkgsysconfdir)/services - -if BUILD_MANPAGES - -man_MANS = \ - avahi-daemon.8 \ - avahi-dnsconfd.8 \ - avahi-daemon.conf.5 \ - avahi-dnsconfd.action.8 \ - avahi.service.5 \ - avahi.hosts.5 - -noinst_DATA = \ - avahi-browse.1.xml \ - avahi-publish.1.xml \ - avahi-resolve.1.xml \ - avahi-set-host-name.1.xml \ - avahi-daemon.8.xml \ - avahi-discover.1.xml \ - avahi-bookmarks.1.xml \ - avahi-dnsconfd.8.xml \ - avahi-daemon.conf.5.xml \ - avahi-dnsconfd.action.8.xml \ - avahi.service.5.xml \ - avahi.hosts.5.xml \ - avahi-autoipd.8.xml \ - avahi-autoipd.action.8.xml \ - bssh.1.xml - -CLEANFILES = \ - $(noinst_DATA) - -if HAVE_DBUS - -man_MANS += \ - avahi-browse.1 \ - avahi-resolve.1 \ - avahi-publish.1 \ - avahi-set-host-name.1 - -if HAVE_GTK -man_MANS += \ - bssh.1 -endif - -if HAVE_PYTHON -man_MANS += \ - avahi-bookmarks.1 -if HAVE_GTK -man_MANS += \ - avahi-discover.1 -endif -endif -endif - -if ENABLE_AUTOIPD -if HAVE_LIBDAEMON - -man_MANS += \ - avahi-autoipd.8 \ - avahi-autoipd.action.8 - -endif -endif - -%.xml: %.xml.in Makefile - $(AM_V_GEN) sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \ - -e 's,@servicedir\@,$(servicedir),g' \ - -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \ - -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@ - -if USE_XMLTOMAN - -CLEANFILES += $(man_MANS) - -%.1: %.1.xml Makefile - $(AM_V_GEN)xmltoman $< > $@ - -%.5: %.5.xml Makefile - $(AM_V_GEN)xmltoman $< > $@ - -%.8: %.8.xml Makefile - $(AM_V_GEN)xmltoman $< > $@ - -xmllint: $(noinst_DATA) - for f in $(noinst_DATA) ; do \ - xmllint --noout --valid "$$f" || exit 1 ; \ - done - -endif - -endif - -EXTRA_DIST = \ - $(man_MANS) \ - avahi-browse.1.xml.in \ - avahi-publish.1.xml.in \ - avahi-resolve.1.xml.in \ - avahi-set-host-name.1.xml.in \ - avahi-daemon.8.xml.in \ - avahi-discover.1.xml.in \ - avahi-bookmarks.1.xml.in \ - avahi-dnsconfd.8.xml.in \ - avahi-daemon.conf.5.xml.in \ - avahi-dnsconfd.action.8.xml.in \ - avahi.service.5.xml.in \ - avahi.hosts.5.xml.in \ - avahi-autoipd.action.8.xml.in \ - avahi-autoipd.8.xml.in \ - bssh.1.xml.in \ - xmltoman.css \ - xmltoman.xsl \ - xmltoman.dtd - - -if HAVE_DBUS - -BSSH_LN = -if HAVE_GTK -if HAVE_GLIB -BSSH_LN += $(LN_S) bssh.1 bvnc.1 && -endif -endif -install-exec-local: - mkdir -p $(DESTDIR)/$(mandir)/man1 && \ - cd $(DESTDIR)/$(mandir)/man1 && \ - rm -f avahi-resolve-host-name.1 avahi-resolve-address.1 avahi-browse-domains.1 avahi-publish-address.1 avahi-publish-service.1 bvnc.1 && \ - $(BSSH_LN) \ - $(LN_S) avahi-resolve.1 avahi-resolve-host-name.1 && \ - $(LN_S) avahi-resolve.1 avahi-resolve-address.1 && \ - $(LN_S) avahi-browse.1 avahi-browse-domains.1 && \ - $(LN_S) avahi-publish.1 avahi-publish-address.1 && \ - $(LN_S) avahi-publish.1 avahi-publish-service.1 - - -endif diff --git a/man/avahi-autoipd.8.xml.in b/man/avahi-autoipd.8.xml.in deleted file mode 100644 index 7137c30..0000000 --- a/man/avahi-autoipd.8.xml.in +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - avahi-autoipd [options] interface - avahi-autoipd --kill interface - avahi-autoipd --refresh interface - avahi-autoipd --check interface - - - -

    avahi-autoipd implements IPv4LL, "Dynamic Configuration of - IPv4 Link-Local Addresses" (IETF RFC3927), a protocol for - automatic IP address configuration from the link-local - 169.254.0.0/16 range without the need for a central server. It - is primarily intended to be used in ad-hoc networks which lack a - DHCP server.

    - -

    IPv4LL is part of the Zeroconf stack.

    - -

    avahi-autoipd can be used as stand-alone address allocator - or as plugin for a DHCP client such as ISC's dhclient, where it - can be used as fallback solution if no DHCP server is found.

    - -

    To allow communication between hosts that have only an IPv4LL - address assigned and hosts that only have a routable IP address - assigned you may add the following routes to both network - configurations:

    - -

    route add -net 169.254.0.0 netmask 255.255.0.0 dev eth0 metric 99

    -

    route add default dev eth0 metric 99

    - -

    See http://developer.apple.com/qa/qa2004/qa1357.html for more information.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -

    @pkgsysconfdir@/avahi-autoipd.action: the script to run when an IP address as been acquired or is lost.

    - -
    - -
    -

    SIGINT, SIGTERM: avahi-autoipd will shutdown. (Same as --kill)

    -

    SIGHUP: avahi-autoipd will re-announce the acquired IP address. (Same as --refresh)

    -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    - -

    http://avahi.org/wiki/AvahiAutoipd documents how avahi-autoipd is best packaged and integrated into distributions.

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-autoipd.action.8.xml.in b/man/avahi-autoipd.action.8.xml.in deleted file mode 100644 index 5e4986f..0000000 --- a/man/avahi-autoipd.action.8.xml.in +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - @pkgsysconfdir@/avahi-autoipd.action - - - -

    avahi-autoipd.action is the action script that - is called whenever an IP address has been acquired by - avahi-autoipd or when it detected an IP address conflict. The - script should add or remove the specified address from the - specified network interface.

    -
    - -
    - - - - - - - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , , , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-bookmarks.1.xml.in b/man/avahi-bookmarks.1.xml.in deleted file mode 100644 index d863e2b..0000000 --- a/man/avahi-bookmarks.1.xml.in +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - avahi-bookmarks - - - -

    A web service for listing HTTP services that are announced - via mDNS/DNS-SD using the Avahi daemon. avahi-bookmarks opens a - TCP socket on port 8080 and waits for incoming HTTP connections - returning a dynamic web site containing links to all services of - type _http._tcp on the LAN. Point your browser to - http://localhost:8080/ to make use of avahi-bookmarks.

    - -
    - - - - - - - - - - - - - - - - - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-browse.1.xml.in b/man/avahi-browse.1.xml.in deleted file mode 100644 index b13d4fc..0000000 --- a/man/avahi-browse.1.xml.in +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - avahi-browse [options] service-type - avahi-browse [options] --all - avahi-browse [options] --browse-domains - avahi-browse [options] --dump-db - avahi-browse-domains [options] - - - -

    Browse for mDNS/DNS-SD network services and browsing domains using the Avahi daemon.

    - -
    - - - -

    Specify a DNS-SD service type (e.g. _http._tcp) to browse for - on the command line, or -a to browse for all - available service types. Items that appear on the network are prefixed with "+", items that disappear are prefixed with "-". If --resolve is passed items that are resolved are prefixed with "=".

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-daemon.8.xml.in b/man/avahi-daemon.8.xml.in deleted file mode 100644 index 0c2990d..0000000 --- a/man/avahi-daemon.8.xml.in +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - avahi-daemon [options] - avahi-daemon --kill - avahi-daemon --reload - avahi-daemon --check - - - -

    The Avahi mDNS/DNS-SD daemon implements Apple's Zeroconf - architecture (also known as "Rendezvous" or "Bonjour"). The daemon - registers local IP addresses and static services using - mDNS/DNS-SD and provides two IPC APIs for local programs to make - use of the mDNS record cache the avahi-daemon maintains. First - there is the so called "simple protocol" which is used - exclusively by avahi-dnsconfd (a daemon which configures unicast - DNS servers using server info published via mDNS) and nss-mdns - (a libc NSS plugin, providing name resolution via mDNS). Finally - there is the D-Bus interface which provides a rich object - oriented interface to D-Bus enabled applications.

    - -

    Upon startup avahi-daemon interprets its configuration file - @pkgsysconfdir@/avahi-daemon.conf and reads XML - fragments from @servicedir@/*.service which may - define static DNS-SD services. If you enable - publish-resolv-conf-dns-servers in - avahi-daemon.conf the file - /etc/resolv.conf will be read, too.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -

    @pkgsysconfdir@/avahi-daemon.conf: the default configuration file for avahi-daemon, for more information.

    - -

    @pkgsysconfdir@/hosts: additional static hostname mappings to publish in mDNS, see for more information.

    - -

    @servicedir@/*.service: static service definitions, see for more information.

    - -
    - -
    -

    SIGINT, SIGTERM: avahi-daemon will shutdown. (Same as --kill).

    -

    SIGHUP: avahi-daemon will reload unicast DNS - server data from /etc/resolv.conf and static - service definitions from @servicedir@/. (Same as --reload)

    -

    SIGUSR1: avahi-daemon will dump local and remote cached resource record data to syslog.

    -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , , , , -

    - -

    http://avahi.org/wiki/AvahiAndUnicastDotLocal documents the problems when using Avahi in a unicast DNS zone .local.

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-daemon.conf.5.xml.in b/man/avahi-daemon.conf.5.xml.in deleted file mode 100644 index 2d15017..0000000 --- a/man/avahi-daemon.conf.5.xml.in +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - @pkgsysconfdir@/avahi-daemon.conf - - - -

    avahi-daemon.conf is the configuration file for avahi-daemon.

    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - - -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - - - -
    - -
    -

    This section is used to define system resource limits for the - daemon. See for more - information. If any of the options is not specified in the configuration - file, avahi-daemon does not change it from the system - defaults.

    - - - - - - - - - - - - - - - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-discover.1.xml.in b/man/avahi-discover.1.xml.in deleted file mode 100644 index e311f1f..0000000 --- a/man/avahi-discover.1.xml.in +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - avahi-discover - - - -

    Show a real-time graphical browse list for mDNS/DNS-SD - network services running on the local LAN using the Avahi - daemon.

    - -
    - - - -

    avahi-discover takes no command line arguments at the moment.

    - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-dnsconfd.8.xml.in b/man/avahi-dnsconfd.8.xml.in deleted file mode 100644 index 7b09cd4..0000000 --- a/man/avahi-dnsconfd.8.xml.in +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - avahi-dnsconfd [options] - avahi-dnsconfd --kill - avahi-dnsconfd --refresh - avahi-dnsconfd --check - - - -

    avahi-dnsconfd connects to a running avahi-daemon and runs - the script @pkgsysconfdir@/dnsconfd.action for each unicast DNS - server that is announced on the local LAN. This is useful for - configuring unicast DNS servers in a DHCP-like fashion with - mDNS.

    -
    - - - - - - - - - - - - - - - - - - - -
    - -

    @pkgsysconfdir@/avahi-dnsconfd.action: the script to run when a DNS server is found or removed.

    - -
    - -
    -

    SIGINT, SIGTERM: avahi-dnsconfd will shutdown. This is issued by passing --kill to avahi-daemon.

    -

    SIGHUP: avahi-dnsconfd will refresh the DNS server data.

    -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-dnsconfd.action.8.xml.in b/man/avahi-dnsconfd.action.8.xml.in deleted file mode 100644 index f4ae37e..0000000 --- a/man/avahi-dnsconfd.action.8.xml.in +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - @pkgsysconfdir@/avahi-dnsconfd.action - - - -

    avahi-dnsconfd.action is the action script that - is called whenever a new unicast DNS server is found or - removed by avahi-dnsconfd. The default script as shipped - with avahi patches /etc/resolv.conf to reflect the - changed unicast DNS server configuration.

    -
    - -
    - - - - - - - - - -
    - -
    - - - - - - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-publish.1.xml.in b/man/avahi-publish.1.xml.in deleted file mode 100644 index bb8dbda..0000000 --- a/man/avahi-publish.1.xml.in +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - avahi-publish -s [options] name service-type port [TXT data ...] - avahi-publish-service [options] name service-type port [TXT data ...] - avahi-publish -a [options] host name address - avahi-publish-address [options] host name address - - - -

    Register an mDNS/DNS-SD service or host name/address mapping using the Avahi daemon.

    -
    - - - -

    When calling in service registration mode, specify a DNS-SD - service name (e.g. "Lennart's Files"), a service type - (e.g. _http._tcp) and an IP port number for the service, - optionally followed by any number of TXT record strings on the - command line. When calling in address/host name registration - mode specify a fully qualified host name and an address (IPv4 or - IPv6).

    - - - - - - - - - - - - - - - - - - - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-resolve.1.xml.in b/man/avahi-resolve.1.xml.in deleted file mode 100644 index e444cb9..0000000 --- a/man/avahi-resolve.1.xml.in +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - avahi-resolve --name host-name ... - avahi-resolve-host-name host-name ... - avahi-resolve --address address ... - avahi-resolve-address address ... - - - -

    Resolve one or more mDNS/DNS host name(s) to IP address(es) (and vice versa) using the Avahi daemon.

    -
    - - - -

    When passing -n, specify one or more fully qualified mDNS/DNS host name(s) - (e.g. "foo.local") to resolve into IP addresses on the - command line. When passing -a, specify one or more IP address - to resolve into host names.

    - -

    avahi-resolve-host-name is equivalent to avahi-resolve --name.

    - -

    avahi-resolve-address is equivalent to avahi-resolve --address.

    - - - - - - - - - - - - - - - - - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , - -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi-set-host-name.1.xml.in b/man/avahi-set-host-name.1.xml.in deleted file mode 100644 index 407bbe7..0000000 --- a/man/avahi-set-host-name.1.xml.in +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - avahi-set-host-name host-name - - - -

    Set the mDNS host name of a currently running Avahi - daemon. The effect of this operation is not persistent across - daemon restarts. This operation is usually privileged.

    -
    - - - - - - - - - - - - - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/avahi.hosts.5.xml.in b/man/avahi.hosts.5.xml.in deleted file mode 100644 index eff2848..0000000 --- a/man/avahi.hosts.5.xml.in +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - @pkgsysconfdir@/hosts - - - -

    @pkgsysconfdir@/hosts is a file which may be used - to define static host name to IP address mappings for multicast - DNS. This is especially useful when publishing DNS-SD services - on behalf of other hosts. See for more information.

    - -

    The file format is similar to the one of - /etc/hosts: on each line an IP address and the - corresponding host name. The host names should be in FQDN form, - i.e. with appended .local suffix.

    -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    -
    - -
    -

    This man page was written using by Oliver - Kurth.

    -
    - -
    diff --git a/man/avahi.service.5.xml.in b/man/avahi.service.5.xml.in deleted file mode 100644 index 6598617..0000000 --- a/man/avahi.service.5.xml.in +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - @servicedir@/*.service - - -

    @servicedir@/*.service are XML - fragments containing static DNS-SD service data. Every service - file can contain multiple service definitions which share the - same name. This is useful for publishing service data for - services which implement multiple protocols. (i.e. a printer - implementing _ipp._tcp and _printer._tcp)

    - -
    - - - - - - - - - - - - - - - - - - - - -
    - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , -

    -
    - -
    -

    This man page was written using by Oliver - Kurth.

    -
    - -
    diff --git a/man/bssh.1.xml.in b/man/bssh.1.xml.in deleted file mode 100644 index 6df640d..0000000 --- a/man/bssh.1.xml.in +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - bssh - bvnc - bshell - - - -

    bssh/bvnc/bshell browses for SSH/VNC servers on the local - network, shows them in a GUI for the user to select one and - finally calls ssh/vncviewer after a selection was made.

    - -

    If the binary is called as bssh only ssh servers will be shown. If the binary is called as bvnc only VNC servers will be shown. If the binary is called as bshell both VNC and SSH servers are shown.

    - -
    - - - - - - - - - - - - - - - -
    -

    The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is - available from

    -
    - -
    -

    - , , -

    -
    - -
    -

    This man page was written using by Oliver Kurth.

    -
    - -
    diff --git a/man/xmltoman.css b/man/xmltoman.css deleted file mode 100644 index 6b3235b..0000000 --- a/man/xmltoman.css +++ /dev/null @@ -1,28 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with avahi; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -***/ - -body { color: black; background-color: white; } -a:link, a:visited { color: #900000; } -h1 { text-transform:uppercase; font-size: 18pt; } -p { margin-left:1cm; margin-right:1cm; } -.cmd { font-family:monospace; } -.file { font-family:monospace; } -.arg { text-transform:uppercase; font-family:monospace; font-style: italic; } -.opt { font-family:monospace; font-weight: bold; } -.manref { font-family:monospace; } -.option .optdesc { margin-left:2cm; } diff --git a/man/xmltoman.dtd b/man/xmltoman.dtd deleted file mode 100644 index 968dd5f..0000000 --- a/man/xmltoman.dtd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/man/xmltoman.xsl b/man/xmltoman.xsl deleted file mode 100644 index 1a344c2..0000000 --- a/man/xmltoman.xsl +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - <xsl:value-of select="@name"/>(<xsl:value-of select="@section"/>) - - - -

    Name

    -

    - - -

    - - - -
    - - -

    - -

    -
    - - -

    - -

    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -

    Synopsis

    - -
    - - -

    Synopsis

    - -
    - - -

    Description

    - -
    - - -

    Options

    - -
    - - -

    - -
    - - -
    -
    - - - - - () - - - () - - - - - - - - -
    diff --git a/service-type-database/.gitignore b/service-type-database/.gitignore deleted file mode 100644 index 581f192..0000000 --- a/service-type-database/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile -Makefile.in -service-types.db -build-db diff --git a/service-type-database/Makefile.am b/service-type-database/Makefile.am deleted file mode 100644 index b43e2cb..0000000 --- a/service-type-database/Makefile.am +++ /dev/null @@ -1,64 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -EXTRA_DIST=build-db.in service-types - -pkglibdatadir=$(libdir)/avahi - -pkgdata_DATA=service-types -pkglibdata_DATA= - -if HAVE_PYTHON -if HAVE_GDBM - -noinst_SCRIPTS=build-db -pkglibdata_DATA+=service-types.db - -build-db: build-db.in - $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ - -e 's,@DBM\@,gdbm,g' $< > $@ && \ - chmod +x $@ - -service-types.db: service-types build-db - $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \ - mv $@.coming $@ - -CLEANFILES = service-types.db build-db - -endif -if HAVE_DBM - -noinst_SCRIPTS=build-db -pkglibdata_DATA+=service-types.db.pag service-types.db.dir - -build-db: build-db.in - $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ - -e 's,@DBM\@,dbm,g' $< > $@ && \ - chmod +x $@ - -service-types.db.pag: service-types.db - $(AM_V_GEN)mv service-types.db.coming.pag service-types.db.pag -service-types.db.dir: service-types.db - $(AM_V_GEN)mv service-types.db.coming.dir service-types.db.dir -service-types.db: service-types build-db - $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \ - if test -f "$@.coming"; then mv $@.coming $@; fi - -CLEANFILES = service-types.db* build-db - -endif -endif diff --git a/service-type-database/build-db.in b/service-type-database/build-db.in deleted file mode 100755 index 4cda425..0000000 --- a/service-type-database/build-db.in +++ /dev/null @@ -1,44 +0,0 @@ -#!@PYTHON@ -# -*-python-*- -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -import @DBM@, sys - -if len(sys.argv) > 1: - infn = sys.argv[1] -else: - infn = "service-types" - -if len(sys.argv) > 2: - outfn = sys.argv[2] -else: - outfn = infn + ".db" - -db = @DBM@.open(outfn, "n") - -for ln in file(infn, "r"): - ln = ln.strip(" \r\n\t") - - if ln == "" or ln.startswith("#"): - continue - - t, n = ln.split(":", 1) - - db[t.strip()] = n.strip() - -db.close() diff --git a/service-type-database/service-types b/service-type-database/service-types deleted file mode 100644 index 6e7e2cd..0000000 --- a/service-type-database/service-types +++ /dev/null @@ -1,233 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -# Feel free to add more service types or translatons to this database. -# Please refrain from copying bulk service type data from any publicly -# available database unless its license is known and compatible with -# our project! The database available on -# -# http://www.dns-sd.org/ServiceTypes.html -# -# is not a source that complies with the criterion! - -### This list is NOT intended to be used as developer -### documentation. If you're looking for the correct service type to -### use for your application please refer to the URL mentioned above. - - -# Devices - -_workstation._tcp:Workstation -_workstation._tcp[de]:Arbeitsplatzrechner -_workstation._tcp[it]:Macchine - - -# Web - -_http._tcp:Web Site -_http._tcp[de]:Web-Angebot -_http._tcp[it]:Sito Web - -_https._tcp:Secure Web Site -_https._tcp[de]:Sicheres Web-Angebot -_https._tcp[it]:Sito Web sicuro - -_rss._tcp:Web Syndication RSS - - -# Network - -_domain._udp:DNS Server -_domain._udp[de]: DNS-Dienst - -_ntp._udp:NTP Time Server - -_smb._tcp:Microsoft Windows Network -_smb._tcp[it]:Rete Microsoft Windows - -_airport._tcp:Apple AirPort - - -# File and data access - -_ftp._tcp:FTP File Transfer -_ftp._tcp[de]:FTP-Dateifreigabe - -_tftp._udp:TFTP Trivial File Transfer - -_webdav._tcp:WebDAV File Share -_webdav._tcp[it]:WebDAV Condivisione File - -_webdavs._tcp:Secure WebDAV File Share -_webdavs._tcp[it]:WebDAV Condivisione File Sicuro - -_afpovertcp._tcp:Apple File Sharing - -_nfs._tcp:Network File System - -_sftp-ssh._tcp:SFTP File Transfer - -_apt._tcp:APT Package Repository -_apt._tcp[it]:APT - Repository dei Pacchetti - -_odisk._tcp:DVD or CD Sharing - -_adisk._tcp:Apple TimeMachine - - -# Remote machine access - -_ssh._tcp:SSH Remote Terminal -_ssh._tcp[de]:SSH-Fernzugriff -_ssh._tcp[it]:SSH Terminale remoto - -_rfb._tcp:VNC Remote Access -_rfb._tcp[it]:Controllo remoto VNC - -_telnet._tcp:Telnet Remote Terminal -_telnet._tcp[it]:Telnet Terminale Remoto - -_timbuktu._tcp:Timbuktu Remote Desktop Control - -_net-assistant._udp:Apple Net Assistant - -_udisks-ssh._tcp:Remote Disk Management - -# Mail - -_imap._tcp:IMAP Mail Access -_imap._tcp[it]:Posta - IMAP - -_pop3._tcp:POP3 Mail Access -_pop3._tcp:Posta - POP3 - - -# Printing - -_printer._tcp:UNIX Printer -_printer._tcp[it]:Stampante UNIX - -_pdl-datastream._tcp:PDL Printer -_pdl-datastream._tcp[it]:Stampante PDL - -_ipp._tcp:Internet Printer - - -# Multimedia - -_daap._tcp:iTunes Audio Access -_daap._tcp[de]:iTunes Audio-Zugriff -_daap._tcp[it]:Accesso Audio iTunes - -_dacp._tcp:iTunes Remote Control - -_realplayfavs._tcp:RealPlayer Shared Favorites -_realplayfavs._tcp[it]:RealPlayer - Preferiti Condivisi - -_raop._tcp:AirTunes Remote Audio - -_rtsp._tcp:RTSP Realtime Streaming Server -_rtp._udp:RTP Realtime Streaming Server - -_dpap._tcp:Digital Photo Sharing -_dpap._tcp[it]:Condivisione Foto - -_pulse-server._tcp:PulseAudio Sound Server -_pulse-sink._tcp:PulseAudio Sound Sink -_pulse-source._tcp:PulseAudio Sound Source - -_mpd._tcp:Music Player Daemon - -_remote-jukebox._tcp:Remote Jukebox - -# DAAP share provided by iTunes on behalf of an iPod Touch -_touch-able._tcp:iPod Touch Music Library - -_vlc-http._tcp:VLC Streaming - - -# Communication, presence, working together - -_presence._tcp:iChat Presence - -_sip._udp:SIP Telephony -_sip._udp[de]:SIP-Telefonie -_sip._udp[it]:Telefonia-SIP - -_h323._tcp:H.323 Telephony -_h323._tcp[de]:H.323-Telefonie -_h323._tcp[it]:Telefonia-H.323 - -_presence_olpc._tcp:OLPC Presence - -_iax._udp:Asterisk Exchange - -_skype._tcp:Skype VoIP - -_see._tcp:SubEthaEdit Collaborative Text Editor - -_lobby._tcp:Gobby Collaborative Editor Session - -_mumble._tcp:Mumble Server - - -# Databases - -_postgresql._tcp:PostgreSQL Server - - -# Development - -_svn._tcp:Subversion Revision Control -_svn._tcp[it]:Subversion - Versionatore - -_distcc._tcp:Distributed Compiler -_distcc._tcp[de]:Verteilter Compiler -_distcc._tcp[it]:Compilatore Distribuito - -_bzr._tcp:Bazaar - - -# Vendor specific - -_MacOSXDupSuppress._tcp:MacOS X Duplicate Machine Suppression - -_ksysguard._tcp:KDE System Guard - -_omni-bookmark._tcp:OmniWeb Bookmark Sharing - -_acrobatSRV._tcp:Adobe Acrobat - -_adobe-vc._tcp:Adobe Version Cue - -_home-sharing._tcp:Apple Home Sharing - - -# Other - -_pgpkey-hkp._tcp:GnuPG/PGP HKP Key Server - -_ldap._tcp:LDAP Directory Server - -_tp._tcp:Thousand Parsec Server -_tps._tcp:Thousand Parsec Server (Secure) -_tp-http._tcp:Thousand Parsec Server (HTTP Tunnel) -_tp-https._tcp:Thousand Parsec Server (Secure HTTP Tunnel) - -_shifter._tcp:Window Shifter - -_libvirt._tcp:Virtual Machine Manager diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 6c1b075..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.o -*.lo -*.la -Makefile -Makefile.in -.deps -.libs -c-plus-plus-test diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index e28b0b7..0000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -AM_CFLAGS= \ - -I$(top_srcdir) - -if HAVE_GLIB -if HAVE_DBUS -if HAVE_NETLINK - -if ENABLE_TESTS -noinst_PROGRAMS = c-plus-plus-test -endif - -c_plus_plus_test_SOURCES = c-plus-plus-test.cc - -c_plus_plus_test_CXXFLAGS = \ - $(AM_CFLAGS) \ - $(GLIB20_CFLAGS) \ - $(DBUS_CFLAGS) - -c_plus_plus_test_LDADD = \ - $(AM_LDADD) \ - ../avahi-common/libavahi-common.la \ - ../avahi-core/libavahi-core.la \ - ../avahi-client/libavahi-client.la \ - ../avahi-glib/libavahi-glib.la \ - $(GLIB20_LIBS) \ - $(DBUS_LIBS) - -endif -endif -endif - -EXTRA_DIST=c-plus-plus-test-gen.py - -gen: - python ./c-plus-plus-test-gen.py avahi-common avahi-core avahi-client avahi-glib > c-plus-plus-test.cc - diff --git a/tests/c-plus-plus-test-gen.py b/tests/c-plus-plus-test-gen.py deleted file mode 100755 index a2836f0..0000000 --- a/tests/c-plus-plus-test-gen.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python - -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -import os, sys - -def print_includes(dir): - - files = os.listdir("../%s" % dir) - files = filter(lambda fn: fn.endswith(".h") and not fn.startswith("."), files) - files.sort() - - for f in files: - print "#include <%s/%s>" % (dir, f) - - -print """/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -""" - -for f in sys.argv[1:]: - print_includes(f) - -print """ -int main(int argc, char*argv[]) { - return 0; -} -""" diff --git a/tests/c-plus-plus-test.cc b/tests/c-plus-plus-test.cc deleted file mode 100644 index ad7a529..0000000 --- a/tests/c-plus-plus-test.cc +++ /dev/null @@ -1,82 +0,0 @@ -/*** - This file is part of avahi. - - avahi is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - avahi is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General - Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with avahi; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char*argv[]) { - return 0; -} - diff --git a/tests/fuzz-mdns.py b/tests/fuzz-mdns.py deleted file mode 100755 index aeea295..0000000 --- a/tests/fuzz-mdns.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/python - -from scapy import * - - -sendp(Ether(type=0x800, dst="ff:ff:ff:ff:ff:ff")/IP(dst="224.0.0.251")/fuzz(UDP(dport = 5353, sport = 5353)/DNS(qd = fuzz(DNSQR()))),loop=1, iface="realtek0") - - -- 2.39.5