├── .gitignore ├── AUTHORS ├── CODE-OF-CONDUCT.md ├── COPYING ├── ChangeLog ├── Makefile.am ├── Mono.Zeroconf.sln ├── NEWS ├── README ├── README.Darwin ├── README.Windows ├── autogen.sh ├── configure.ac ├── docs ├── Makefile.am ├── en │ ├── Mono.Zeroconf.Providers │ │ ├── IZeroconfProvider.xml │ │ └── ZeroconfProviderAttribute.xml │ ├── Mono.Zeroconf │ │ ├── AddressProtocol.xml │ │ ├── IRegisterService.xml │ │ ├── IResolvableService.xml │ │ ├── IService.xml │ │ ├── IServiceBrowser.xml │ │ ├── ITxtRecord.xml │ │ ├── RegisterService.xml │ │ ├── RegisterServiceEventArgs.xml │ │ ├── RegisterServiceEventHandler.xml │ │ ├── ServiceBrowseEventArgs.xml │ │ ├── ServiceBrowseEventHandler.xml │ │ ├── ServiceBrowser.xml │ │ ├── ServiceErrorCode.xml │ │ ├── ServiceResolvedEventArgs.xml │ │ ├── ServiceResolvedEventHandler.xml │ │ ├── TxtRecord.xml │ │ └── TxtRecordItem.xml │ ├── index.xml │ ├── ns-Mono.Zeroconf.Providers.xml │ └── ns-Mono.Zeroconf.xml └── mono-zeroconf-docs.source ├── mono-zeroconf.spec ├── shamrock.m4 └── src ├── AssemblyInfo.cs ├── MZClient ├── MZClient.csproj ├── Makefile.am ├── ZeroconfClient.cs └── mzclient.in ├── Makefile.am ├── Makefile.include ├── Mono.Zeroconf.Providers.Avahi ├── Makefile.am ├── Mono.Zeroconf.Providers.Avahi │ ├── AvahiUtils.cs │ ├── RegisterService.cs │ ├── ResolvableService.cs │ ├── Service.cs │ ├── ServiceBrowser.cs │ ├── TxtRecord.cs │ └── ZeroconfProvider.cs └── README ├── Mono.Zeroconf.Providers.AvahiDBus ├── Makefile.am ├── Mono.Zeroconf.Providers.AvahiDBus.csproj ├── Mono.Zeroconf.Providers.AvahiDBus │ ├── AvahiServerState.cs │ ├── AvahiUtils.cs │ ├── BrowseService.cs │ ├── DBusManager.cs │ ├── EntryGroupState.cs │ ├── ErrorCode.cs │ ├── IAvahiEntryGroup.cs │ ├── IAvahiServer.cs │ ├── IAvahiServiceBrowser.cs │ ├── IAvahiServiceResolver.cs │ ├── LookupFlags.cs │ ├── LookupResultFlags.cs │ ├── Protocol.cs │ ├── PublishFlags.cs │ ├── RegisterService.cs │ ├── Service.cs │ ├── ServiceBrowser.cs │ ├── TxtRecord.cs │ └── ZeroconfProvider.cs └── NDesk.DBus │ ├── Address.cs │ ├── Authentication.cs │ ├── Bus.cs │ ├── BusObject.cs │ ├── Connection.cs │ ├── DBus.cs │ ├── DProxy.cs │ ├── ExportObject.cs │ ├── Introspection.cs │ ├── IntrospectionSchema.cs │ ├── Mapper.cs │ ├── MatchRule.cs │ ├── Message.cs │ ├── MessageFilter.cs │ ├── MessageReader.cs │ ├── MessageWriter.cs │ ├── PendingCall.cs │ ├── Protocol.cs │ ├── Server.cs │ ├── Signature.cs │ ├── SocketTransport.cs │ ├── Transport.cs │ ├── TypeDefiner.cs │ ├── TypeImplementer.cs │ ├── UnixMonoTransport.cs │ ├── UnixNativeTransport.cs │ ├── UnixTransport.cs │ └── Wrapper.cs ├── Mono.Zeroconf.Providers.Bonjour ├── Makefile.am ├── Mono.Zeroconf.Providers.Bonjour.csproj ├── Mono.Zeroconf.Providers.Bonjour.dll.config.in └── Mono.Zeroconf.Providers.Bonjour │ ├── BrowseService.cs │ ├── Native.cs │ ├── RegisterService.cs │ ├── Service.cs │ ├── ServiceBrowser.cs │ ├── ServiceClass.cs │ ├── ServiceError.cs │ ├── ServiceErrorException.cs │ ├── ServiceFlags.cs │ ├── ServiceRef.cs │ ├── ServiceType.cs │ ├── TxtRecord.cs │ ├── TxtRecordEnumerator.cs │ └── ZeroconfProvider.cs ├── Mono.Zeroconf ├── Makefile.am ├── Mono.Zeroconf.Providers │ ├── IZeroconfProvider.cs │ ├── ProviderFactory.cs │ └── ZeroconfProviderAttribute.cs ├── Mono.Zeroconf.csproj └── Mono.Zeroconf │ ├── AddressProtocol.cs │ ├── IRegisterService.cs │ ├── IResolvableService.cs │ ├── IService.cs │ ├── IServiceBrowser.cs │ ├── ITxtRecord.cs │ ├── RegisterService.cs │ ├── RegisterServiceEventArgs.cs │ ├── RegisterServiceEventHandler.cs │ ├── ServiceBrowseEventArgs.cs │ ├── ServiceBrowseEventHandler.cs │ ├── ServiceBrowser.cs │ ├── ServiceErrorCode.cs │ ├── ServiceResolvedEventArgs.cs │ ├── ServiceResolvedEventHandler.cs │ ├── TxtRecord.cs │ └── TxtRecordItem.cs ├── mono-zeroconf.pc.in ├── mono-zeroconf.snk └── policy.config.in /.gitignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | *.mdb 3 | *.exe 4 | 5 | INSTALL 6 | Makefile 7 | Makefile.in 8 | aclocal.m4 9 | autom4te.cache/ 10 | config.* 11 | configure 12 | install-sh 13 | missing 14 | *.tree 15 | *.zip 16 | mzclient 17 | *.config 18 | mono-zeroconf.pc 19 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Aaron Bockover 2 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project has adopted the code of conduct defined by the Contributor Covenant 4 | to clarify expected behavior in our community. 5 | 6 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). 7 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2008 Novell, Inc. 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. 8 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = \ 2 | src \ 3 | docs 4 | 5 | MAINTAINERCLEANFILES = \ 6 | Makefile.in \ 7 | aclocal.m4 \ 8 | configure \ 9 | config.* \ 10 | INSTALL \ 11 | install-sh \ 12 | missing 13 | 14 | EXTRA_DIST = \ 15 | mono-zeroconf.spec \ 16 | Mono.Zeroconf.sln \ 17 | README.Windows 18 | 19 | collect: 20 | rm -rf bin; \ 21 | mkdir bin; \ 22 | find src \( -iname *.exe -o -iname *.dll \) -exec cp {} bin \; 23 | 24 | PKV=$(PACKAGE)-$(VERSION) 25 | PKB=$(PKV)-binary 26 | 27 | dist-windows: all 28 | @rm -rf $(PKB) && \ 29 | mkdir -p $(PKB)/bin && \ 30 | cp src/MZClient/MZClient.exe src/Mono.Zeroconf/Mono.Zeroconf.dll src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour.dll $(PKB)/bin && \ 31 | cp AUTHORS NEWS README README.Windows $(PKB) && \ 32 | cp COPYING $(PKB)/LICENSE && \ 33 | zip -r9 $(PKB).zip $(PKB) && \ 34 | rm -rf $(PKB) 35 | 36 | release: 37 | (cd $(top_srcdir)/docs; make update-html) && \ 38 | test -e $(PKV).tar.bz2 -a -e $(PKV).tar.gz -a -e $(PKV).zip -a -e $(PKB).zip || { echo "You must run distcheck and dist-windows before release"; exit 1; }; \ 39 | test -z $$MONO_USER && { echo "Please set MONO_USER for the commit"; exit 1; }; \ 40 | cp ChangeLog $(PKV).changes && \ 41 | sha1sum $(PKV).* $(PKB).* > $(PKV).sha1sum && \ 42 | touch LATEST-IS-$(VERSION) && \ 43 | ssh bansheeweb@banshee-project.org rm /home/bansheeweb/download.banshee-project.org/mono-zeroconf/LATEST-IS*; \ 44 | ssh bansheeweb@banshee-project.org rm -rf /home/bansheeweb/download.banshee-project.org/mono-zeroconf/docs; \ 45 | scp $(PKV).* $(PKB).* mono-zeroconf.spec LATEST* README README.Windows bansheeweb@banshee-project.org:/home/bansheeweb/download.banshee-project.org/mono-zeroconf/ && rm LATEST* $(PKV).* $(PKB).* && \ 46 | scp -r $(top_builddir)/docs/html bansheeweb@banshee-project.org:/home/bansheeweb/download.banshee-project.org/mono-zeroconf/docs && \ 47 | echo "Sleeping 10 seconds, about to tag release (as user $$MONO_USER)..."; \ 48 | sleep 10; \ 49 | echo "Starting svn tag..."; \ 50 | svn cp svn+ssh://$$MONO_USER@mono-cvs.ximian.com/source/trunk/Mono.Zeroconf svn+ssh://$$MONO_USER@mono-cvs.ximian.com/source/tags/Mono.Zeroconf-$(VERSION) -m 'Created tag for Mono.Zeroconf $(VERSION)'; 51 | 52 | -------------------------------------------------------------------------------- /Mono.Zeroconf.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual C# Express 2005 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MZClient", "src\MZClient\MZClient.csproj", "{839D9048-31CF-4010-B427-6A8362556485}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Zeroconf", "src\Mono.Zeroconf\Mono.Zeroconf.csproj", "{5CF88E3A-13DD-4114-BAD9-DA826946516F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Zeroconf.Providers.Bonjour", "src\Mono.Zeroconf.Providers.Bonjour\Mono.Zeroconf.Providers.Bonjour.csproj", "{623325E2-5821-4701-A40C-3759097008DD}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Zeroconf.Providers.AvahiDBus", "src\Mono.Zeroconf.Providers.AvahiDBus\Mono.Zeroconf.Providers.AvahiDBus.csproj", "{EF6ED6D1-D201-42ED-B680-5A77641BEB77}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {5CF88E3A-13DD-4114-BAD9-DA826946516F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 | {5CF88E3A-13DD-4114-BAD9-DA826946516F}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 | {623325E2-5821-4701-A40C-3759097008DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {623325E2-5821-4701-A40C-3759097008DD}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {839D9048-31CF-4010-B427-6A8362556485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {839D9048-31CF-4010-B427-6A8362556485}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {EF6ED6D1-D201-42ED-B680-5A77641BEB77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {EF6ED6D1-D201-42ED-B680-5A77641BEB77}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | EndGlobalSection 26 | GlobalSection(MonoDevelopProperties) = preSolution 27 | name = Mono.Zeroconf 28 | version = 0.1 29 | StartupItem = src\MZClient\MZClient.csproj 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 2009-05-05: 0.9.0 Release 2 | 3 | * Major bug fix in Avahi provider where service registration would not 4 | work most of the time due to the interface being set to 0 instead of 5 | unspecified (-1) by default 6 | 7 | * Added the an ushort UPort property to IRegisterService for users who 8 | need to pass a port value greater than Int16.MaxValue without having 9 | to do an unchecked cast of the ushort port to short 10 | 11 | 2008-09-11: 0.8.0 Release 12 | 13 | * New Avahi provider using DBus instead of libavahi 14 | 15 | * Improved IPv6 support (AddressProtocol/A6 query support) 16 | 17 | * Garbage Collection bug fixed in the Bonjour backend, regarding delegates 18 | passed to native code being GCed prematurely; thanks to Josh Coole 19 | 20 | * New MZClient features: support for setting interface, domain, and 21 | address type restrictions on browse/resolve operations; new general 22 | verbosity options 23 | 24 | 2008-03-20: 0.7.6 Release 25 | 26 | * Added a NetworkInterface property to the IService object 27 | 28 | * Support IPv6 host address resolutions and set the IPv6 zone 29 | automatically to the network interface index 30 | 31 | 2008-01-25: 0.7.5 Release 32 | 33 | * Fixed major packaging/install bug - 0.7.4 lacked GAC version policy 34 | assembly support, so applications could break when Mono.Zeroconf 35 | were upgraded 36 | 37 | * Visual Studio solution/projects now work with Visual Studio 2005 38 | 39 | 2008-01-23: 0.7.4 Release 40 | 41 | * Fixed a big IP address resolution bug in the Bonjour provider 42 | that manifested only under .NET on Windows XP SP2 43 | 44 | * Minor bug fix in MZClient 45 | 46 | * Make it easy to build and use on Windows 47 | - Added Visual Studio 2008 solution 48 | - Publish the source code as a Zip archive (along with tar gz and bzip2) 49 | - Publish a -binary.zip file for Windows containing pre-built assemblies 50 | 51 | 2007-12-19: 0.7.3 Release 52 | 53 | * First release that works on Linux, Mac, and Windows 54 | 55 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Mono.Zeroconf is a cross platform Zero Configuration Networking library for 2 | Mono and .NET. It provides a unified API for performing the most common 3 | zeroconf operations on a variety of platforms and subsystems: all the 4 | operating systems supported by Mono and both the Avahi and 5 | Bonjour/mDNSResponder transports. 6 | 7 | By using Mono.ZeroConf developers can use a single API that will work 8 | regardless of the underlying implementation that a particular operating 9 | system uses. 10 | 11 | Developers can publish services that will be exposed to other computers on 12 | the network and also query the local machines on the network for services 13 | that could have been exposed. 14 | 15 | More information about Mono.Zeroconf can be found on its project page 16 | on the Mono Wiki: 17 | 18 | http://mono-project.com/Mono.Zeroconf 19 | 20 | General information about Zero Configuration Networking: 21 | 22 | http://www.zeroconf.org/ 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.Darwin: -------------------------------------------------------------------------------- 1 | If building using Mono.framework from git: 2 | 3 | $ PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig ACLOCAL_FLAGS="-I /Library/Frameworks/Mono.framework/Versions/Current/share/aclocal" ./autogen.sh 4 | -------------------------------------------------------------------------------- /README.Windows: -------------------------------------------------------------------------------- 1 | Downloading 2 | ----------- 3 | 4 | Mono.Zeroconf is available as zip file containing pre-compiled assemblies 5 | useful to Windows developers, which also includes the command line tool, 6 | MZClient. Additionally, the source code containing a Visual Studio solution 7 | is available in a separate zip file. 8 | 9 | a) mono-zeroconf--binary.zip: pre-compiled assemblies 10 | b) mono-zeroconf-.zip: full source code 11 | 12 | 13 | Running 14 | ------- 15 | 16 | To run Mono.Zeroconf properly on Windows, Apple's Bonjour must be installed 17 | first. For licensing reasons, we cannot bundle Bonjour with Mono.Zeroconf. 18 | 19 | Bonjour for Windows can be downloaded here: 20 | 21 | http://www.apple.com/support/downloads/bonjourforwindows.html 22 | 23 | After installing Bonjour, applications using Mono.Zeroconf should work 24 | properly on Windows. 25 | 26 | The MZClient.exe program can be used to test Mono.Zeroconf and Bonjour 27 | in general. 28 | 29 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROJECT=Mono.Zeroconf 4 | 5 | function error () { 6 | echo "Error: $1" 1>&2 7 | exit 1 8 | } 9 | 10 | function check_autotool_version () { 11 | which $1 &>/dev/null || { 12 | error "$1 is not installed, and is required to configure $PACKAGE" 13 | } 14 | 15 | version=$($1 --version | head -n 1 | cut -f4 -d' ') 16 | major=$(echo $version | cut -f1 -d.) 17 | minor=$(echo $version | cut -f2 -d.) 18 | major_check=$(echo $2 | cut -f1 -d.) 19 | minor_check=$(echo $2 | cut -f2 -d.) 20 | 21 | if [ $major -lt $major_check ]; then 22 | do_bail=yes 23 | elif [[ $minor -lt $minor_check && $major = $major_check ]]; then 24 | do_bail=yes 25 | fi 26 | 27 | if [ x"$do_bail" = x"yes" ]; then 28 | error "$1 version $2 or better is required to configure $PROJECT" 29 | fi 30 | } 31 | 32 | function run () { 33 | echo "Running $@ ..." 34 | $@ 2>.autogen.log || { 35 | cat .autogen.log 1>&2 36 | rm .autogen.log 37 | error "Could not run $1, which is required to configure $PROJECT" 38 | } 39 | rm .autogen.log 40 | } 41 | 42 | srcdir=$(dirname $0) 43 | test -z "$srcdir" && srcdir=. 44 | 45 | (test -f $srcdir/configure.ac) || { 46 | error "Directory \"$srcdir\" does not look like the top-level $PROJECT directory" 47 | } 48 | 49 | check_autotool_version aclocal 1.9 50 | check_autotool_version automake 1.9 51 | check_autotool_version autoconf 2.13 52 | 53 | run aclocal -I . $ACLOCAL_FLAGS 54 | run autoconf 55 | run automake -a --gnu 56 | 57 | if [ $# = 0 ]; then 58 | echo "WARNING: I am going to run configure without any arguments." 59 | fi 60 | 61 | run ./configure --enable-maintainer-mode $@ 62 | 63 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([Mono.Zeroconf], [0.9.0]) 2 | AC_CANONICAL_SYSTEM 3 | AC_PREREQ(2.13) 4 | AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar dist-zip]) 5 | AM_MAINTAINER_MODE 6 | 7 | API_VERSION="4.0.0.90" 8 | POLICY_VERSIONS="1.0 2.0 3.0 4.0" 9 | AC_SUBST(API_VERSION) 10 | AC_SUBST(POLICY_VERSIONS) 11 | 12 | DISTCHECK_CONFIGURE_FLAGS="--disable-docs" 13 | AC_SUBST(DISTCHECK_CONFIGURE_FLAGS) 14 | 15 | AC_PROG_INSTALL 16 | 17 | SHAMROCK_CHECK_MONO_MODULE(1.1.10) 18 | SHAMROCK_FIND_MONO_2_0_COMPILER 19 | SHAMROCK_FIND_MONO_RUNTIME 20 | SHAMROCK_CHECK_MONODOC 21 | SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES([ 22 | System 23 | System.Web 24 | ]) 25 | 26 | AC_PATH_PROG(GACUTIL, gacutil, no) 27 | if test "x$GACUTIL" = "xno"; then 28 | AC_MSG_ERROR([You need to install gacutil]) 29 | fi 30 | 31 | AC_PATH_PROG(AL, al2, no) 32 | if test "x$AL" = "xno" ; then 33 | AC_MSG_ERROR([You need to install al]) 34 | fi 35 | 36 | GACUTIL_FLAGS='-package $(PACKAGE) -root $(DESTDIR)$(prefix)/lib' 37 | GACUTIL_POLICY_FLAGS='-root $(DESTDIR)$(prefix)/lib' 38 | AC_SUBST(GACUTIL_FLAGS) 39 | AC_SUBST(GACUTIL_POLICY_FLAGS) 40 | 41 | 42 | AC_ARG_ENABLE(avahi, AC_HELP_STRING([--disable-avahi], 43 | [Do not build with Avahi support]), , enable_avahi=yes) 44 | 45 | if test "x$enable_avahi" = "xyes"; then 46 | AVAHI_LIBS="-r:Mono.Posix" 47 | AC_SUBST(AVAHI_LIBS) 48 | AM_CONDITIONAL(BUILD_AVAHI, true) 49 | else 50 | AC_MSG_NOTICE([not building Avahi support]) 51 | AM_CONDITIONAL(BUILD_AVAHI, false) 52 | fi 53 | 54 | AC_ARG_ENABLE(mdnsresponder, AC_HELP_STRING([--disable-mdnsresponder], 55 | [Do not build with mDNSResponder support]), , enable_mdnsresponder=yes) 56 | AM_CONDITIONAL(BUILD_MDNSRESPONDER, test "x$enable_mdnsresponder" = "xyes") 57 | 58 | case ${host} in 59 | *-*-darwin*) 60 | mdns_target_library="libc" 61 | ;; 62 | *) 63 | mdns_target_library="libnss_mdns-0.2.so" 64 | ;; 65 | esac 66 | 67 | AC_SUBST(mdns_target_library) 68 | 69 | SHAMROCK_EXPAND_LIBDIR 70 | 71 | AC_OUTPUT([ 72 | Makefile 73 | src/Makefile 74 | src/policy.config 75 | src/mono-zeroconf.pc 76 | src/Mono.Zeroconf/Makefile 77 | src/Mono.Zeroconf.Providers.Bonjour/Makefile 78 | src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour.dll.config 79 | src/Mono.Zeroconf.Providers.Avahi/Makefile 80 | src/Mono.Zeroconf.Providers.AvahiDBus/Makefile 81 | src/MZClient/Makefile 82 | src/MZClient/mzclient 83 | docs/Makefile 84 | ]) 85 | 86 | echo " 87 | Installation Prefix: ${prefix} 88 | C# Compiler: ${MCS} 89 | Host Platform: ${host} 90 | 91 | Avahi Support: ${enable_avahi} 92 | mDNSResponder Support: ${enable_mdnsresponder}" 93 | 94 | if test "x${enable_mdnsresponder}" = "xyes"; then 95 | echo " Target Library: ${mdns_target_library}" 96 | fi 97 | 98 | echo " 99 | Developer Documentation: ${enable_docs} 100 | " 101 | 102 | -------------------------------------------------------------------------------- /docs/Makefile.am: -------------------------------------------------------------------------------- 1 | DOC_UPDATER = @MONODOCER@ -delete 2 | DOC_ASSEMBLER = @MDASSEMBLER@ --out mono-zeroconf-docs --ecma 3 | 4 | ASSEMBLIES = \ 5 | $(top_builddir)/src/Mono.Zeroconf/Mono.Zeroconf.dll 6 | 7 | ASSEMBLIES_BUILD = $(foreach asm,$(ASSEMBLIES),$(addprefix -assembly:,$(asm))) 8 | 9 | if BUILD_DOCS 10 | 11 | monodocdir = $(DOCDIR) 12 | monodoc_DATA = \ 13 | mono-zeroconf-docs.zip \ 14 | mono-zeroconf-docs.tree \ 15 | mono-zeroconf-docs.source 16 | 17 | mono-zeroconf-docs.zip mono-zeroconf-docs.tree: $(srcdir)/en/*/*.xml $(srcdir)/en/*.xml 18 | $(DOC_ASSEMBLER) $(srcdir)/en 19 | 20 | update-docs: $(ASSEMBLIES) 21 | $(DOC_UPDATER) $(ASSEMBLIES_BUILD) -path:en/ 22 | 23 | update-html: 24 | rm -rf html 25 | monodocs2html -source:$(srcdir)/en -dest:$(srcdir)/html 26 | 27 | update-svn: 28 | @for remove in $$(find en -iregex .*\.remove$$); do \ 29 | real_remove=$${remove%.remove}; \ 30 | mv $$remove $$real_remove; \ 31 | svn delete $$real_remove; \ 32 | done; \ 33 | for add in $$(svn status | grep ^? | awk '{print $$2}'); do \ 34 | svn add $$add; \ 35 | done; 36 | 37 | endif 38 | 39 | merge: 40 | monodoc --merge-changes $$HOME/.config/monodoc/changeset.xml . 41 | 42 | EXTRA_DIST = \ 43 | $(srcdir)/en/*/*.xml \ 44 | $(srcdir)/en/*.xml \ 45 | mono-zeroconf-docs.source 46 | 47 | DISTCLEANFILES = \ 48 | mono-zeroconf-docs.zip \ 49 | mono-zeroconf-docs.tree 50 | 51 | MAINTAINERCLEANFILES = \ 52 | Makefile.in 53 | 54 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf.Providers/IZeroconfProvider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | 11 | The "entry point" interface for Zeroconf provider assemblies. 12 | 13 | Example stub code for a Zeroconf provider. The provider would implement the types MyServiceBrowser, MyRegisterService, and MyTxtRecord, which must implement the respecitve interfaces in . 14 | 15 | 16 | using System; 17 | using Mono.Zeroconf.Providers; 18 | 19 | [assembly:ZeroconfProvider (typeof (MyZeroconfProvider))] 20 | 21 | public class MyZeroconfProvider : IZeroconfProvider 22 | { 23 | public void Initialize () 24 | { 25 | } 26 | 27 | public Type ServiceBrowser { 28 | get { return typeof (MyServiceBrowser); } 29 | } 30 | 31 | public Type RegisterService { 32 | get { return typeof (MyRegisterService); } 33 | } 34 | 35 | public Type TxtRecord { 36 | get { return typeof (MyTxtRecord); } 37 | } 38 | } 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Method 50 | System.Void 51 | 52 | Method to perform any kind of subsystem initialization and sanity check.This method is responsible for ensuring the underlying Zeroconf subsystem is running. If the subsystem cannot be contacted, this method should throw an exception. In the Bonjour implementation, this method opens and closes a test connection to the mDNSResponder daemon to ensure it is running. 53 | 3.0.0.804.0.0.90 54 | 55 | Property 56 | System.Type 57 | Type of provider's A type which implements To be added. 58 | 3.0.0.804.0.0.90 59 | 60 | Property 61 | System.Type 62 | Type of provider's A type which implements To be added. 63 | 3.0.0.804.0.0.90 64 | 65 | Property 66 | System.Type 67 | Type of provider's A type which implements To be added. 68 | 3.0.0.804.0.0.90 69 | 70 | 71 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf.Providers/ZeroconfProviderAttribute.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.Attribute 11 | 12 | 13 | 14 | Assembly level attribute required for Zeroconf provider assemblies 15 | 16 | Assemblies implementing a Zeroconf provider (by way of ) must apply this attribute to the assembly. 17 | 18 | 19 | using System; 20 | using Mono.Zeroconf.Providers; 21 | 22 | [assembly:ZeroconfProvider (typeof (MyZeroconfProvider))] 23 | 24 | ... 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Constructor 34 | 35 | Type of the provider bound to the assemblyThis type must implement .To be added. 36 | 3.0.0.804.0.0.90 37 | 38 | Property 39 | System.Type 40 | Type of the provider bound to the assemblyValue passed to the constructor.This property is only used by the internal Mono.Zeroconf factory that loads Zeroconf providers. 41 | 3.0.0.804.0.0.90 42 | 43 | 44 | 45 | System.AttributeUsage(System.AttributeTargets.Assembly) 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/AddressProtocol.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 3.0.0.80 6 | 4.0.0.90 7 | 8 | 9 | System.Enum 10 | 11 | 12 | To be added. 13 | To be added. 14 | 15 | 16 | 17 | 18 | 19 | 20 | Field 21 | 22 | 23 | 3.0.0.804.0.0.90 24 | Mono.Zeroconf.AddressProtocol 25 | To be added. 26 | 27 | 28 | Field 29 | 30 | 31 | 3.0.0.804.0.0.90 32 | Mono.Zeroconf.AddressProtocol 33 | To be added. 34 | 35 | 36 | Field 37 | 38 | 39 | 3.0.0.804.0.0.90 40 | Mono.Zeroconf.AddressProtocol 41 | To be added. 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/IRegisterService.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | 11 | Mono.Zeroconf.IService 12 | 13 | 14 | System.IDisposable 15 | 16 | 17 | 18 | To be added. 19 | To be added. 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Property 30 | System.String 31 | To be added.To be added.To be added. 32 | 3.0.0.804.0.0.90 33 | 34 | Property 35 | System.Int16 36 | To be added.To be added.To be added. 37 | 3.0.0.804.0.0.90 38 | 39 | Method 40 | System.Void 41 | 42 | To be added.To be added. 43 | 3.0.0.804.0.0.90 44 | 45 | Property 46 | System.String 47 | To be added.To be added.To be added. 48 | 3.0.0.804.0.0.90 49 | 50 | Property 51 | System.String 52 | To be added.To be added.To be added. 53 | 3.0.0.804.0.0.90EventMono.Zeroconf.RegisterServiceEventHandlerTo be added.To be added.3.0.0.804.0.0.90Property3.0.0.804.0.0.90System.UInt16To be added.To be added.To be added. 54 | 55 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/IResolvableService.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | 11 | Mono.Zeroconf.IService 12 | 13 | 14 | 15 | To be added. 16 | To be added. 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Property3.0.0.804.0.0.90Mono.Zeroconf.AddressProtocolTo be added.To be added.To be added. 25 | 26 | Property 27 | System.String 28 | To be added.To be added.To be added. 29 | 3.0.0.804.0.0.90 30 | 31 | Property 32 | System.Net.IPHostEntry 33 | To be added.To be added.To be added. 34 | 3.0.0.804.0.0.90 35 | 36 | Property 37 | System.String 38 | To be added.To be added.To be added. 39 | 3.0.0.804.0.0.90Property3.0.0.804.0.0.90System.UInt32To be added.To be added.To be added. 40 | 41 | Property 42 | System.Int16 43 | To be added.To be added.To be added. 44 | 3.0.0.804.0.0.90 45 | 46 | Method 47 | System.Void 48 | 49 | To be added.To be added. 50 | 3.0.0.804.0.0.90 51 | 52 | Event 53 | Mono.Zeroconf.ServiceResolvedEventHandler 54 | To be added.To be added. 55 | 3.0.0.804.0.0.90 56 | 57 | 58 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/IService.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | 11 | To be added. 12 | To be added. 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Property 21 | System.String 22 | To be added.To be added.To be added. 23 | 3.0.0.804.0.0.90 24 | 25 | Property 26 | System.String 27 | To be added.To be added.To be added. 28 | 3.0.0.804.0.0.90 29 | 30 | Property 31 | System.String 32 | To be added.To be added.To be added. 33 | 3.0.0.804.0.0.90 34 | 35 | Property 36 | Mono.Zeroconf.ITxtRecord 37 | To be added.To be added.To be added. 38 | 3.0.0.804.0.0.90 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/IServiceBrowser.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | 11 | System.Collections.Generic.IEnumerable<Mono.Zeroconf.IResolvableService> 12 | 13 | 14 | System.IDisposable 15 | 16 | 17 | 18 | To be added. 19 | To be added. 20 | 21 | 22 | 23 | 24 | Method3.0.0.804.0.0.90System.VoidTo be added.To be added.To be added.To be added.To be added.To be added. 25 | 26 | Event 27 | Mono.Zeroconf.ServiceBrowseEventHandler 28 | To be added.To be added. 29 | 3.0.0.804.0.0.90 30 | 31 | Event 32 | Mono.Zeroconf.ServiceBrowseEventHandler 33 | To be added.To be added. 34 | 3.0.0.804.0.0.90 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/RegisterServiceEventArgs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.EventArgs 11 | 12 | 13 | 14 | To be added. 15 | To be added. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Constructor 25 | 26 | To be added.To be added. 27 | 3.0.0.804.0.0.90 28 | 29 | Constructor 30 | 31 | To be added.To be added.To be added.To be added.To be added. 32 | 3.0.0.804.0.0.90 33 | 34 | Property 35 | System.Boolean 36 | To be added.To be added.To be added. 37 | 3.0.0.804.0.0.90 38 | 39 | Property 40 | Mono.Zeroconf.IRegisterService 41 | To be added.To be added.To be added. 42 | 3.0.0.804.0.0.90 43 | 44 | Property 45 | Mono.Zeroconf.ServiceErrorCode 46 | To be added.To be added.To be added. 47 | 3.0.0.804.0.0.90 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/RegisterServiceEventHandler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.Delegate 11 | 12 | 13 | 14 | 15 | 16 | 17 | System.Void 18 | 19 | 20 | To be added. 21 | To be added. 22 | To be added. 23 | To be added. 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/ServiceBrowseEventArgs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.EventArgs 11 | 12 | 13 | 14 | To be added. 15 | To be added. 16 | 17 | 18 | 19 | 20 | 21 | Constructor 22 | 23 | To be added.To be added.To be added. 24 | 3.0.0.804.0.0.90 25 | 26 | Property 27 | Mono.Zeroconf.IResolvableService 28 | To be added.To be added.To be added. 29 | 3.0.0.804.0.0.90 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/ServiceBrowseEventHandler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.Delegate 11 | 12 | 13 | 14 | 15 | 16 | 17 | System.Void 18 | 19 | 20 | To be added. 21 | To be added. 22 | To be added. 23 | To be added. 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/ServiceResolvedEventArgs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.EventArgs 11 | 12 | 13 | 14 | To be added. 15 | To be added. 16 | 17 | 18 | 19 | 20 | 21 | Constructor 22 | 23 | To be added.To be added.To be added. 24 | 3.0.0.804.0.0.90 25 | 26 | Property 27 | Mono.Zeroconf.IResolvableService 28 | To be added.To be added.To be added. 29 | 3.0.0.804.0.0.90 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/ServiceResolvedEventHandler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.Delegate 11 | 12 | 13 | 14 | 15 | 16 | 17 | System.Void 18 | 19 | 20 | To be added. 21 | To be added. 22 | To be added. 23 | To be added. 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/en/Mono.Zeroconf/TxtRecordItem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mono.Zeroconf 5 | 1.0.0.0 6 | 3.0.0.80 7 | 4.0.0.90 8 | 9 | 10 | System.Object 11 | 12 | 13 | 14 | To be added. 15 | To be added. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Constructor 25 | 26 | To be added.To be added.To be added.To be added. 27 | 3.0.0.804.0.0.90 28 | 29 | Constructor 30 | 31 | To be added.To be added.To be added.To be added. 32 | 3.0.0.804.0.0.90 33 | 34 | Property 35 | System.String 36 | To be added.To be added.To be added. 37 | 3.0.0.804.0.0.90 38 | 39 | Property 40 | System.Byte[] 41 | To be added.To be added.To be added. 42 | 3.0.0.804.0.0.90 43 | 44 | Property 45 | System.String 46 | To be added.To be added.To be added. 47 | 3.0.0.804.0.0.90 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/en/index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true) 7 | 8 | 9 | System.Reflection.AssemblyCompany("Novell, Inc.") 10 | 11 | 12 | System.Reflection.AssemblyCopyright("Copyright (C) 2006-2009 Novell, Inc.") 13 | 14 | 15 | System.Reflection.AssemblyDescription("Cross Platform Zeroconf for .NET") 16 | 17 | 18 | System.Reflection.AssemblyTitle("Mono.Zeroconf") 19 | 20 | 21 | 22 | 23 | Cross Platform Zeroconf for .NET. 24 | Copyright (C) 2006-2007 Novell, Inc. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Mono.Zeroconf 51 | 52 | -------------------------------------------------------------------------------- /docs/en/ns-Mono.Zeroconf.Providers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | API for implementing new Zeroconf/mDNS providers, such as Bonjour and Avahi. 4 | 5 | Zeroconf providers for Mono.Zeroconf are written as plugins. Provider assemblies are loaded at runtime by Mono.Zeroconf. 6 | Each provider must implement a plugin "entry point" by implementing , providing classes that implement interfaces from , and applying the assembly level attribute, to the provider assembly. 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/en/ns-Mono.Zeroconf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User level API for browsing and publishing mDNS records. 4 | None. 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/mono-zeroconf-docs.source: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shamrock.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([SHAMROCK_EXPAND_LIBDIR], 2 | [ 3 | expanded_libdir=`( 4 | case $prefix in 5 | NONE) prefix=$ac_default_prefix ;; 6 | *) ;; 7 | esac 8 | case $exec_prefix in 9 | NONE) exec_prefix=$prefix ;; 10 | *) ;; 11 | esac 12 | eval echo $libdir 13 | )` 14 | AC_SUBST(expanded_libdir) 15 | ]) 16 | 17 | AC_DEFUN([SHAMROCK_FIND_PROGRAM], 18 | [ 19 | AC_PATH_PROG($1, $2, $3) 20 | AC_SUBST($1) 21 | ]) 22 | 23 | AC_DEFUN([SHAMROCK_FIND_PROGRAM_OR_BAIL], 24 | [ 25 | SHAMROCK_FIND_PROGRAM($1, $2, no) 26 | if test "x$1" = "xno"; then 27 | AC_MSG_ERROR([You need to install '$2']) 28 | fi 29 | ]) 30 | 31 | AC_DEFUN([SHAMROCK_FIND_MONO_1_0_COMPILER], 32 | [ 33 | SHAMROCK_FIND_PROGRAM_OR_BAIL(MCS, mcs) 34 | ]) 35 | 36 | AC_DEFUN([SHAMROCK_FIND_MONO_2_0_COMPILER], 37 | [ 38 | SHAMROCK_FIND_PROGRAM_OR_BAIL(MCS, gmcs) 39 | ]) 40 | 41 | AC_DEFUN([SHAMROCK_FIND_MONO_RUNTIME], 42 | [ 43 | SHAMROCK_FIND_PROGRAM_OR_BAIL(MONO, mono) 44 | ]) 45 | 46 | AC_DEFUN([SHAMROCK_CHECK_MONO_MODULE], 47 | [ 48 | PKG_CHECK_MODULES(MONO_MODULE, mono >= $1) 49 | ]) 50 | 51 | AC_DEFUN([_SHAMROCK_CHECK_MONO_GAC_ASSEMBLIES], 52 | [ 53 | for asm in $(echo "$*" | cut -d, -f2- | sed 's/\,/ /g') 54 | do 55 | AC_MSG_CHECKING([for Mono $1 GAC for $asm.dll]) 56 | if test \ 57 | -e "$($PKG_CONFIG --variable=libdir mono)/mono/$1/$asm.dll" -o \ 58 | -e "$($PKG_CONFIG --variable=prefix mono)/lib/mono/$1/$asm.dll"; \ 59 | then \ 60 | AC_MSG_RESULT([found]) 61 | else 62 | AC_MSG_RESULT([not found]) 63 | AC_MSG_ERROR([missing reqired Mono $1 assembly: $asm.dll]) 64 | fi 65 | done 66 | ]) 67 | 68 | AC_DEFUN([SHAMROCK_CHECK_MONO_1_0_GAC_ASSEMBLIES], 69 | [ 70 | _SHAMROCK_CHECK_MONO_GAC_ASSEMBLIES(1.0, $*) 71 | ]) 72 | 73 | AC_DEFUN([SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES], 74 | [ 75 | _SHAMROCK_CHECK_MONO_GAC_ASSEMBLIES(2.0, $*) 76 | ]) 77 | 78 | AC_DEFUN([SHAMROCK_CHECK_MONODOC], 79 | [ 80 | AC_ARG_ENABLE(docs, AC_HELP_STRING([--disable-docs], 81 | [Do not build documentation]), , enable_docs=yes) 82 | 83 | if test "x$enable_docs" = "xyes"; then 84 | AC_PATH_PROG(MONODOCER, monodocer, no) 85 | if test "x$MONODOCER" = "xno"; then 86 | AC_MSG_ERROR([You need to install monodoc, or pass --disable-docs to configure to skip documentation installation]) 87 | fi 88 | 89 | AC_PATH_PROG(MDASSEMBLER, mdassembler, no) 90 | if test "x$MDASSEMBLER" = "xno"; then 91 | AC_MSG_ERROR([You need to install mdassembler, or pass --disable-docs to configure to skip documentation installation]) 92 | fi 93 | 94 | DOCDIR=`$PKG_CONFIG monodoc --variable=sourcesdir` 95 | AC_SUBST(DOCDIR) 96 | AM_CONDITIONAL(BUILD_DOCS, true) 97 | else 98 | AC_MSG_NOTICE([not building API documentation]) 99 | AM_CONDITIONAL(BUILD_DOCS, false) 100 | fi 101 | ]) 102 | 103 | -------------------------------------------------------------------------------- /src/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | [assembly:AssemblyVersion("4.0.0.90")] 5 | [assembly:AssemblyTitle("Mono.Zeroconf")] 6 | [assembly:AssemblyDescription("Cross Platform Zeroconf for .NET")] 7 | [assembly:AssemblyCopyright("Copyright (C) 2006-2009 Novell, Inc.")] 8 | [assembly:AssemblyCompany("Novell, Inc.")] 9 | 10 | -------------------------------------------------------------------------------- /src/MZClient/MZClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {839D9048-31CF-4010-B427-6A8362556485} 9 | Exe 10 | Properties 11 | MZClient 12 | MZClient 13 | v2.0 14 | 512 15 | MZClient 16 | 17 | 18 | true 19 | full 20 | false 21 | ..\..\bin 22 | 23 | 24 | prompt 25 | 4 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {839D9048-31CF-4010-B427-6A8362556485} 37 | Mono.Zeroconf 38 | 39 | 40 | 41 | 48 | -------------------------------------------------------------------------------- /src/MZClient/Makefile.am: -------------------------------------------------------------------------------- 1 | ASSEMBLY_NAME = MZClient 2 | ASSEMBLY = $(ASSEMBLY_NAME).exe 3 | 4 | assemblydir = $(libdir)/mono-zeroconf 5 | assembly_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb 6 | 7 | wrapperdir = $(bindir) 8 | wrapper_SCRIPTS = mzclient 9 | 10 | SOURCES = \ 11 | $(top_srcdir)/src/AssemblyInfo.cs \ 12 | $(srcdir)/ZeroconfClient.cs 13 | 14 | all: $(ASSEMBLY) 15 | 16 | $(ASSEMBLY): $(top_builddir)/src/Mono.Zeroconf/Mono.Zeroconf.dll $(SOURCES) 17 | $(MCS) -debug -out:$@ -r:$< $(SOURCES) 18 | 19 | EXTRA_DIST = $(SOURCES) MZClient.csproj 20 | CLEANFILES = $(ASSEMBLY){,.mdb} 21 | MAINTAINERCLEANFILES = \ 22 | Makefile.in 23 | 24 | -------------------------------------------------------------------------------- /src/MZClient/mzclient.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mono --debug @expanded_libdir@/mono-zeroconf/MZClient.exe "$@" 3 | 4 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = \ 2 | Mono.Zeroconf \ 3 | Mono.Zeroconf.Providers.Bonjour \ 4 | Mono.Zeroconf.Providers.AvahiDBus \ 5 | Mono.Zeroconf.Providers.Avahi \ 6 | MZClient 7 | 8 | pkgconfigdir = $(libdir)/pkgconfig 9 | pkgconfig_DATA = mono-zeroconf.pc 10 | 11 | uninstall-hook: 12 | if test $$(find $(pkglibdir) | wc -l) -eq 1; then \ 13 | rmdir $(pkglibdir); \ 14 | fi 15 | 16 | EXTRA_DIST = \ 17 | AssemblyInfo.cs \ 18 | mono-zeroconf.pc.in \ 19 | mono-zeroconf.snk \ 20 | policy.config.in 21 | 22 | CLEANFILES = \ 23 | *.dll 24 | 25 | DISTCLEANFILES = \ 26 | mono-zeroconf.pc 27 | 28 | MAINTAINERCLEANFILES = \ 29 | Makefile.in 30 | 31 | -------------------------------------------------------------------------------- /src/Makefile.include: -------------------------------------------------------------------------------- 1 | POLICY_ASSEMBLIES = $(addsuffix .$(ASSEMBLY_NAME).dll, $(addprefix policy., $(POLICY_VERSIONS))) 2 | POLICY_CONFIGS = $(addsuffix .config, $(addprefix policy., $(POLICY_VERSIONS))) 3 | 4 | $(POLICY_ASSEMBLIES): $(top_builddir)/src/policy.config $(top_srcdir)/src/mono-zeroconf.snk 5 | for i in $(POLICY_VERSIONS); do \ 6 | echo "Creating policy.$$i.$(ASSEMBLY_NAME)"; \ 7 | sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/g" -e "s/@POLICY@/$$i/g" $(top_builddir)/src/policy.config > policy.$$i.config; \ 8 | $(AL) -link:policy.$$i.config -out:policy.$$i.$(ASSEMBLY_NAME).dll -keyfile:$(top_srcdir)/src/mono-zeroconf.snk; \ 9 | done 10 | 11 | gac-install: $(POLICY_ASSEMBLIES) 12 | $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; 13 | for p in $(POLICY_ASSEMBLIES); do \ 14 | echo $(GACUTIL) /i $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ 15 | $(GACUTIL) /i $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ 16 | done 17 | 18 | gac-uninstall: 19 | $(GACUTIL) /us $(ASSEMBLY) $(GACUTIL_FLAGS) || exit 1; 20 | @for p in $(POLICY_ASSEMBLIES); do \ 21 | echo $(GACUTIL) /us $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ 22 | $(GACUTIL) /us $$p /f $(GACUTIL_POLICY_FLAGS) || exit 1; \ 23 | done 24 | 25 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Avahi/Makefile.am: -------------------------------------------------------------------------------- 1 | ASSEMBLY_NAME = Mono.Zeroconf.Providers.Avahi 2 | ASSEMBLY = $(ASSEMBLY_NAME).dll 3 | 4 | MONO_ZEROCONF_PROVIDERS_AVAHI_SRC = \ 5 | AvahiUtils.cs \ 6 | RegisterService.cs \ 7 | ResolvableService.cs \ 8 | ServiceBrowser.cs \ 9 | Service.cs \ 10 | TxtRecord.cs \ 11 | ZeroconfProvider.cs 12 | 13 | SOURCES_PRE = \ 14 | $(foreach source,$(MONO_ZEROCONF_PROVIDERS_AVAHI_SRC),Mono.Zeroconf.Providers.Avahi/$(source)) 15 | 16 | SOURCES = \ 17 | $(top_srcdir)/src/AssemblyInfo.cs \ 18 | $(foreach source,$(SOURCES_PRE),$(srcdir)/$(source)) 19 | 20 | #if BUILD_AVAHI 21 | 22 | #assemblydir = $(libdir)/mono-zeroconf 23 | #assembly_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb 24 | 25 | #all: $(ASSEMBLY) 26 | 27 | #$(ASSEMBLY): $(top_builddir)/src/Mono.Zeroconf/Mono.Zeroconf.dll $(SOURCES) 28 | # $(MCS) -debug -target:library -out:$@ -r:$< $(AVAHI_LIBS) $(SOURCES) 29 | 30 | #endif 31 | 32 | EXTRA_DIST = $(SOURCES) README 33 | CLEANFILES = *.dll *.exe *.mdb 34 | DISTCLEANFILES = *.pidb 35 | MAINTAINERCLEANFILES = \ 36 | Makefile.in 37 | 38 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Avahi/Mono.Zeroconf.Providers.Avahi/AvahiUtils.cs: -------------------------------------------------------------------------------- 1 | // 2 | // AvahiUtils.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using AV=Avahi; 31 | 32 | namespace Mono.Zeroconf.Providers.Avahi 33 | { 34 | internal static class AvahiUtils 35 | { 36 | public static ServiceErrorCode ErrorCodeToServiceError(AV.ErrorCode error) 37 | { 38 | switch(error) { 39 | case AV.ErrorCode.Ok: return ServiceErrorCode.None; 40 | case AV.ErrorCode.Collision: return ServiceErrorCode.NameConflict; 41 | default: return ServiceErrorCode.Unknown; 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Avahi/Mono.Zeroconf.Providers.Avahi/ResolvableService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ResolvableService.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Net; 31 | using AV=Avahi; 32 | using Mono.Zeroconf; 33 | 34 | namespace Mono.Zeroconf.Providers.Avahi 35 | { 36 | public class ResolvableService : Service, IResolvableService 37 | { 38 | private AV.Client client; 39 | 40 | public event ServiceResolvedEventHandler Resolved; 41 | 42 | public ResolvableService(AV.Client client, AV.ServiceInfo service) : base(service) 43 | { 44 | this.client = client; 45 | } 46 | 47 | public void Resolve() 48 | { 49 | AV.ServiceResolver resolver = new AV.ServiceResolver(client, service); 50 | resolver.Found += OnServiceResolved; 51 | } 52 | 53 | private void OnServiceResolved(object o, AV.ServiceInfoArgs args) 54 | { 55 | service = args.Service; 56 | ((AV.ServiceResolver)o).Dispose(); 57 | 58 | ServiceResolvedEventHandler handler = Resolved; 59 | if(handler != null) { 60 | handler(this, new ServiceResolvedEventArgs(this)); 61 | } 62 | } 63 | 64 | public string FullName { 65 | get { 66 | return String.Format("{0}.{1}.{2}", service.Name.Replace(" ", "\\032"), 67 | service.ServiceType, service.Domain); 68 | } 69 | } 70 | 71 | public IPHostEntry HostEntry { 72 | get { 73 | IPHostEntry host_entry = new IPHostEntry(); 74 | host_entry.AddressList = new IPAddress[1]; 75 | host_entry.AddressList[0] = service.Address; 76 | if(service.Protocol == AV.Protocol.IPv6) { 77 | host_entry.AddressList[0].ScopeId = service.NetworkInterface; 78 | } 79 | host_entry.HostName = service.HostName; 80 | return host_entry; 81 | } 82 | } 83 | 84 | public string HostTarget { 85 | get { return service.HostName; } 86 | } 87 | 88 | public int NetworkInterface { 89 | get { return service.NetworkInterface; } 90 | } 91 | 92 | public short Port { 93 | get { return (short)service.Port; } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Avahi/Mono.Zeroconf.Providers.Avahi/Service.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Service.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using AV=Avahi; 31 | using Mono.Zeroconf; 32 | 33 | namespace Mono.Zeroconf.Providers.Avahi 34 | { 35 | public class Service : Mono.Zeroconf.IService 36 | { 37 | protected AV.ServiceInfo service; 38 | 39 | public Service(AV.ServiceInfo service) 40 | { 41 | this.service = service; 42 | } 43 | 44 | public string Name { 45 | get { return service.Name; } 46 | } 47 | 48 | public string RegType { 49 | get { return service.ServiceType; } 50 | } 51 | 52 | public string ReplyDomain { 53 | get { return service.Domain; } 54 | } 55 | 56 | public ITxtRecord TxtRecord { 57 | get { return new TxtRecord(service.Text); } 58 | set { } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Avahi/Mono.Zeroconf.Providers.Avahi/ServiceBrowser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceBrowser.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using AV=Avahi; 31 | using Mono.Zeroconf; 32 | 33 | namespace Mono.Zeroconf.Providers.Avahi 34 | { 35 | public class ServiceBrowser : IServiceBrowser 36 | { 37 | private AV.Client client; 38 | private AV.ServiceBrowser browser; 39 | 40 | public event ServiceBrowseEventHandler ServiceAdded; 41 | public event ServiceBrowseEventHandler ServiceRemoved; 42 | 43 | public ServiceBrowser() 44 | { 45 | } 46 | 47 | public void Dispose() 48 | { 49 | if(client != null) { 50 | client.Dispose(); 51 | client = null; 52 | } 53 | 54 | if(browser != null) { 55 | browser.Dispose(); 56 | browser = null; 57 | } 58 | } 59 | 60 | public void Browse(string regtype, string domain) 61 | { 62 | Dispose(); 63 | 64 | client = new AV.Client(); 65 | 66 | browser = new AV.ServiceBrowser(client, regtype, domain); 67 | browser.ServiceAdded += OnServiceAdded; 68 | browser.ServiceRemoved += OnServiceRemoved; 69 | } 70 | 71 | private void OnServiceAdded(object o, AV.ServiceInfoArgs args) 72 | { 73 | ServiceBrowseEventHandler handler = ServiceAdded; 74 | if(handler != null) { 75 | handler(this, new ServiceBrowseEventArgs(new ResolvableService(client, args.Service))); 76 | } 77 | } 78 | 79 | private void OnServiceRemoved(object o, AV.ServiceInfoArgs args) 80 | { 81 | ServiceBrowseEventHandler handler = ServiceRemoved; 82 | if(handler != null) { 83 | handler(this, new ServiceBrowseEventArgs(new ResolvableService(client, args.Service))); 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Avahi/Mono.Zeroconf.Providers.Avahi/ZeroconfProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ZeroconfProvider.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections; 31 | 32 | using AV=Avahi; 33 | 34 | [assembly:Mono.Zeroconf.Providers.ZeroconfProvider(typeof(Mono.Zeroconf.Providers.Avahi.ZeroconfProvider))] 35 | 36 | namespace Mono.Zeroconf.Providers.Avahi 37 | { 38 | public class ZeroconfProvider : IZeroconfProvider 39 | { 40 | public void Initialize() 41 | { 42 | AV.Client client = new AV.Client(); 43 | client.Dispose(); 44 | } 45 | 46 | public Type ServiceBrowser { 47 | get { return typeof(Mono.Zeroconf.Providers.Avahi.ServiceBrowser); } 48 | } 49 | 50 | public Type RegisterService { 51 | get { return typeof(Mono.Zeroconf.Providers.Avahi.RegisterService); } 52 | } 53 | 54 | public Type TxtRecord { 55 | get { return typeof(Mono.Zeroconf.Providers.Avahi.TxtRecord); } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Avahi/README: -------------------------------------------------------------------------------- 1 | This provider is deprecated, probably does not build. 2 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Makefile.am: -------------------------------------------------------------------------------- 1 | ASSEMBLY_NAME = Mono.Zeroconf.Providers.AvahiDBus 2 | ASSEMBLY = $(ASSEMBLY_NAME).dll 3 | 4 | MONO_ZEROCONF_PROVIDERS_AVAHI_SRC = \ 5 | Mono.Zeroconf.Providers.AvahiDBus/AvahiServerState.cs \ 6 | Mono.Zeroconf.Providers.AvahiDBus/AvahiUtils.cs \ 7 | Mono.Zeroconf.Providers.AvahiDBus/BrowseService.cs \ 8 | Mono.Zeroconf.Providers.AvahiDBus/DBusManager.cs \ 9 | Mono.Zeroconf.Providers.AvahiDBus/EntryGroupState.cs \ 10 | Mono.Zeroconf.Providers.AvahiDBus/ErrorCode.cs \ 11 | Mono.Zeroconf.Providers.AvahiDBus/IAvahiEntryGroup.cs \ 12 | Mono.Zeroconf.Providers.AvahiDBus/IAvahiServer.cs \ 13 | Mono.Zeroconf.Providers.AvahiDBus/IAvahiServiceBrowser.cs \ 14 | Mono.Zeroconf.Providers.AvahiDBus/IAvahiServiceResolver.cs \ 15 | Mono.Zeroconf.Providers.AvahiDBus/LookupFlags.cs \ 16 | Mono.Zeroconf.Providers.AvahiDBus/LookupResultFlags.cs \ 17 | Mono.Zeroconf.Providers.AvahiDBus/Protocol.cs \ 18 | Mono.Zeroconf.Providers.AvahiDBus/PublishFlags.cs \ 19 | Mono.Zeroconf.Providers.AvahiDBus/RegisterService.cs \ 20 | Mono.Zeroconf.Providers.AvahiDBus/Service.cs \ 21 | Mono.Zeroconf.Providers.AvahiDBus/ServiceBrowser.cs \ 22 | Mono.Zeroconf.Providers.AvahiDBus/TxtRecord.cs \ 23 | Mono.Zeroconf.Providers.AvahiDBus/ZeroconfProvider.cs \ 24 | NDesk.DBus/Address.cs \ 25 | NDesk.DBus/Authentication.cs \ 26 | NDesk.DBus/Bus.cs \ 27 | NDesk.DBus/BusObject.cs \ 28 | NDesk.DBus/Connection.cs \ 29 | NDesk.DBus/DBus.cs \ 30 | NDesk.DBus/DProxy.cs \ 31 | NDesk.DBus/ExportObject.cs \ 32 | NDesk.DBus/Introspection.cs \ 33 | NDesk.DBus/IntrospectionSchema.cs \ 34 | NDesk.DBus/Mapper.cs \ 35 | NDesk.DBus/MatchRule.cs \ 36 | NDesk.DBus/Message.cs \ 37 | NDesk.DBus/MessageFilter.cs \ 38 | NDesk.DBus/MessageReader.cs \ 39 | NDesk.DBus/MessageWriter.cs \ 40 | NDesk.DBus/PendingCall.cs \ 41 | NDesk.DBus/Protocol.cs \ 42 | NDesk.DBus/Server.cs \ 43 | NDesk.DBus/Signature.cs \ 44 | NDesk.DBus/SocketTransport.cs \ 45 | NDesk.DBus/Transport.cs \ 46 | NDesk.DBus/TypeDefiner.cs \ 47 | NDesk.DBus/TypeImplementer.cs \ 48 | NDesk.DBus/UnixMonoTransport.cs \ 49 | NDesk.DBus/UnixNativeTransport.cs \ 50 | NDesk.DBus/UnixTransport.cs \ 51 | NDesk.DBus/Wrapper.cs 52 | 53 | SOURCES = \ 54 | $(top_srcdir)/src/AssemblyInfo.cs \ 55 | $(foreach source,$(MONO_ZEROCONF_PROVIDERS_AVAHI_SRC),$(srcdir)/$(source)) 56 | 57 | if BUILD_AVAHI 58 | 59 | assemblydir = $(libdir)/mono-zeroconf 60 | assembly_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb 61 | 62 | all: $(ASSEMBLY) 63 | 64 | $(ASSEMBLY): $(top_builddir)/src/Mono.Zeroconf/Mono.Zeroconf.dll $(SOURCES) 65 | $(MCS) -unsafe -debug -target:library -out:$@ -r:$< $(AVAHI_LIBS) $(SOURCES) 66 | 67 | endif 68 | 69 | EXTRA_DIST = $(SOURCES) 70 | CLEANFILES = *.dll *.exe *.mdb 71 | DISTCLEANFILES = *.pidb 72 | MAINTAINERCLEANFILES = \ 73 | Makefile.in 74 | 75 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/AvahiServerState.cs: -------------------------------------------------------------------------------- 1 | // 2 | // AvahiServerState.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2009 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.AvahiDBus 32 | { 33 | public enum AvahiServerState 34 | { 35 | Invalid, 36 | Registering, 37 | Running, 38 | Collision, 39 | Failure 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/AvahiUtils.cs: -------------------------------------------------------------------------------- 1 | // 2 | // AvahiUtils.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using Mono.Zeroconf; 31 | 32 | namespace Mono.Zeroconf.Providers.AvahiDBus 33 | { 34 | public static class AvahiUtils 35 | { 36 | public static Protocol FromMzcProtocol (AddressProtocol addressProtocol) 37 | { 38 | switch (addressProtocol) { 39 | case AddressProtocol.IPv4: 40 | return Protocol.IPv4; 41 | case AddressProtocol.IPv6: 42 | return Protocol.IPv6; 43 | case AddressProtocol.Any: 44 | default: 45 | return Protocol.Unspecified; 46 | } 47 | } 48 | 49 | public static AddressProtocol ToMzcProtocol (Protocol addressProtocol) 50 | { 51 | switch (addressProtocol) { 52 | case Protocol.IPv4: 53 | return AddressProtocol.IPv4; 54 | case Protocol.IPv6: 55 | return AddressProtocol.IPv6; 56 | case Protocol.Unspecified: 57 | default: 58 | return AddressProtocol.Any; 59 | } 60 | } 61 | 62 | public static int FromMzcInterface (uint @interface) 63 | { 64 | // Avahi appears to use a value of -1 for "unspecified" ("any"), and 65 | // zero-based interface indexes... we hope 66 | 67 | switch (@interface) { 68 | case 0: return -1; 69 | default: return (int)@interface - 1; 70 | } 71 | } 72 | 73 | public static uint ToMzcInterface (int @interface) 74 | { 75 | switch (@interface) { 76 | case -1: return 0; 77 | default: return (uint)@interface + 1; 78 | } 79 | } 80 | 81 | public static ServiceErrorCode ErrorCodeToServiceError (ErrorCode error) 82 | { 83 | switch (error) { 84 | case ErrorCode.Ok: return ServiceErrorCode.None; 85 | case ErrorCode.Collision: return ServiceErrorCode.NameConflict; 86 | default: return ServiceErrorCode.Unknown; 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/DBusManager.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DBusManager.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007-2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.IO; 31 | using System.Reflection; 32 | using System.Threading; 33 | 34 | using NDesk.DBus; 35 | 36 | namespace Mono.Zeroconf.Providers.AvahiDBus 37 | { 38 | internal static class DBusManager 39 | { 40 | private const uint MINIMUM_AVAHI_API_VERSION = 515; 41 | 42 | private static object thread_wait = new object (); 43 | private static bool initialized; 44 | private static Bus bus; 45 | public static Bus Bus { 46 | get { return bus; } 47 | } 48 | 49 | private static IAvahiServer server; 50 | public static IAvahiServer Server { 51 | get { return server; } 52 | } 53 | 54 | private static void ConnectToSystemBus () 55 | { 56 | string address = Environment.GetEnvironmentVariable ("DBUS_SYSTEM_BUS_ADDRESS"); 57 | if (String.IsNullOrEmpty (address)) { 58 | address = "unix:path=/var/run/dbus/system_bus_socket"; 59 | } 60 | 61 | bus = Bus.Open (address); 62 | } 63 | 64 | private static void IterateThread (object o) 65 | { 66 | lock (thread_wait) { 67 | ConnectToSystemBus (); 68 | Monitor.Pulse (thread_wait); 69 | } 70 | 71 | while (true) { 72 | bus.Iterate (); 73 | } 74 | } 75 | 76 | public static void Initialize () 77 | { 78 | if (initialized) { 79 | return; 80 | } 81 | 82 | initialized = true; 83 | 84 | lock (thread_wait) { 85 | ThreadPool.QueueUserWorkItem (IterateThread); 86 | Monitor.Wait (thread_wait); 87 | } 88 | 89 | if (!bus.NameHasOwner("org.freedesktop.Avahi")) { 90 | throw new ApplicationException ("Could not find org.freedesktop.Avahi"); 91 | } 92 | 93 | server = GetObject ("/"); 94 | uint api_version = server.GetAPIVersion (); 95 | 96 | if (api_version < MINIMUM_AVAHI_API_VERSION) { 97 | throw new ApplicationException (String.Format ("Avahi API version " + 98 | "{0} is required, but {1} is what the server returned.", 99 | MINIMUM_AVAHI_API_VERSION, api_version)); 100 | } 101 | } 102 | 103 | public static T GetObject (string objectPath) 104 | { 105 | return GetObject (new ObjectPath (objectPath)); 106 | } 107 | 108 | public static T GetObject (ObjectPath objectPath) 109 | { 110 | return bus.GetObject ("org.freedesktop.Avahi", objectPath); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/EntryGroupState.cs: -------------------------------------------------------------------------------- 1 | // 2 | // EntryGroupState.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.AvahiDBus 32 | { 33 | public enum EntryGroupState 34 | { 35 | Uncommited, 36 | Registering, 37 | Established, 38 | Collision, 39 | Failure 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/ErrorCode.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ErrorCode.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.AvahiDBus 32 | { 33 | public enum ErrorCode 34 | { 35 | Ok = 0, 36 | Failure = -1, 37 | BadState = -2, 38 | InvalidHostName = - 3, 39 | InvalidDomainName = -4, 40 | NoNetwork = -5, 41 | InvalidTTL = -6, 42 | IsPattern = -7, 43 | Collision = -8, 44 | InvalidRecord = -9, 45 | InvalidServiceName = -10, 46 | InvalidServiceType = -11, 47 | InvalidPort = -12, 48 | InvalidKey = -13, 49 | InvalidAddress = -14, 50 | Timeout = -15, 51 | TooManyClients = -16, 52 | TooManyObjects = -17, 53 | TooManyEntries = -18, 54 | OS = -19, 55 | AccessDenied = -20, 56 | InvalidOperation = -21, 57 | DBusError = -22, 58 | Disconnected = -23, 59 | NoMemory = -24, 60 | InvalidObject = -25, 61 | NoDaemon = -26, 62 | InvalidInterface = -27, 63 | InvalidProtocol = -28, 64 | InvalidFlags = -29, 65 | NotFound = -30, 66 | InvalidConfig = -31, 67 | VersionMismatch = -32, 68 | InvalidServiceSubtype = -33, 69 | InvalidPacket = -34, 70 | InvalidDnsError = -35, 71 | DnsFormErr = -36, 72 | DnsServFail = -37, 73 | DnsNxDomain = -38, 74 | DnsNoTimp = -39, 75 | DnsRefused = -40, 76 | DnsYxDomain = -41, 77 | DnsYxRrSet = -42, 78 | DnsNxRrSet = -43, 79 | DnsNotAuth = -44, 80 | DnsNotZone = -45, 81 | InvalidRData = -46, 82 | InvalidDnsClass = -47, 83 | InvalidDnsType = -48, 84 | NotSupported = -49, 85 | NotPermitted = -50 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/IAvahiEntryGroup.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IAvahiEntryGroup.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using NDesk.DBus; 31 | 32 | namespace Mono.Zeroconf.Providers.AvahiDBus 33 | { 34 | public delegate void EntryGroupStateChangedHandler (EntryGroupState state, string error); 35 | 36 | [Interface ("org.freedesktop.Avahi.EntryGroup")] 37 | public interface IAvahiEntryGroup 38 | { 39 | event EntryGroupStateChangedHandler StateChanged; 40 | 41 | void Free (); 42 | void Commit (); 43 | void Reset (); 44 | EntryGroupState GetState (); 45 | bool IsEmpty (); 46 | 47 | void AddService (int @interface, Protocol protocol, PublishFlags flags, string name, 48 | string type, string domain, string host, ushort port, byte [][] txt); 49 | 50 | void AddServiceSubtype (int @interface, Protocol protocol, PublishFlags flags, 51 | string name, string type, string domain, string subtype); 52 | 53 | void UpdateServiceTxt (int @interface, Protocol protocol, PublishFlags flags, 54 | string name, string type, string domain, byte [][] txt); 55 | 56 | void AddAddress (int @interface, Protocol protocol, PublishFlags flags, string name, string address); 57 | 58 | void AddRecord (int @interface, Protocol protocol, PublishFlags flags, string name, 59 | ushort clazz, ushort type, uint ttl, byte [] rdata); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/IAvahiServer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IAvahiServer.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007-2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using NDesk.DBus; 31 | 32 | namespace Mono.Zeroconf.Providers.AvahiDBus 33 | { 34 | [Interface ("org.freedesktop.Avahi.Server")] 35 | public interface IAvahiServer 36 | { 37 | uint GetAPIVersion (); 38 | 39 | AvahiServerState GetState (); 40 | 41 | ObjectPath ServiceBrowserNew (int @interface, Protocol protocol, 42 | string type, string domain, LookupFlags flags); 43 | 44 | ObjectPath ServiceResolverNew (int @interface, Protocol protocol, string name, 45 | string type, string dmain, Protocol aprotocol, LookupFlags flags); 46 | 47 | ObjectPath EntryGroupNew (); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/IAvahiServiceBrowser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IAvahiServiceBrowser.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007-2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using NDesk.DBus; 31 | 32 | namespace Mono.Zeroconf.Providers.AvahiDBus 33 | { 34 | public delegate void ServiceBrowserItemHandler (int @interface, Protocol protocol, string name, 35 | string type, string domain, LookupResultFlags flags); 36 | 37 | public delegate void ServiceBrowserHandler (); 38 | 39 | [Interface ("org.freedesktop.Avahi.ServiceBrowser")] 40 | public interface IAvahiServiceBrowser 41 | { 42 | event ServiceBrowserItemHandler ItemNew; 43 | event ServiceBrowserItemHandler ItemRemove; 44 | 45 | event ServiceBrowserHandler AllForNow; 46 | event ServiceBrowserHandler CacheExhausted; 47 | 48 | void Free (); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/IAvahiServiceResolver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IAvahiServiceResolver.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using NDesk.DBus; 31 | 32 | namespace Mono.Zeroconf.Providers.AvahiDBus 33 | { 34 | public delegate void ServiceResolverFoundHandler (int @interface, Protocol protocol, string name, 35 | string type, string domain, string host, Protocol aprotocol, string address, 36 | ushort port, byte [][] txt, LookupResultFlags flags); 37 | 38 | public delegate void ServiceResolverErrorHandler (string error); 39 | 40 | [Interface ("org.freedesktop.Avahi.ServiceResolver")] 41 | public interface IAvahiServiceResolver 42 | { 43 | event ServiceResolverFoundHandler Found; 44 | event ServiceResolverErrorHandler Failure; 45 | 46 | void Free (); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/LookupFlags.cs: -------------------------------------------------------------------------------- 1 | // 2 | // LookupFlags.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.AvahiDBus 32 | { 33 | [Flags] 34 | public enum LookupFlags : uint 35 | { 36 | None = 0, 37 | UseWideArea = 1, 38 | UseMulticast = 2, 39 | NoTxt = 4, 40 | NoAddress = 8 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/LookupResultFlags.cs: -------------------------------------------------------------------------------- 1 | // 2 | // LookupResultFlags.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.AvahiDBus 32 | { 33 | [Flags] 34 | public enum LookupResultFlags : uint 35 | { 36 | None = 0, 37 | Cached = 1, 38 | WideArea = 2, 39 | Multicast = 4, 40 | Local = 8, 41 | OurOwn = 16, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/Protocol.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Protocol.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.AvahiDBus 32 | { 33 | public enum Protocol : int 34 | { 35 | Unspecified = -1, 36 | IPv4 = 0, 37 | IPv6 = 1 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/PublishFlags.cs: -------------------------------------------------------------------------------- 1 | // 2 | // PublishFlags.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.AvahiDBus 32 | { 33 | [Flags] 34 | public enum PublishFlags : uint 35 | { 36 | None = 0, 37 | Unique = 1, 38 | NoProbe = 2, 39 | NoAnnounce = 4, 40 | AllowMultiple = 8, 41 | NoReverse = 16, 42 | NoCookie = 32, 43 | Update = 64, 44 | UseWideArea = 128, 45 | UseMulticast = 256 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/Service.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Service.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using Mono.Zeroconf; 31 | 32 | namespace Mono.Zeroconf.Providers.AvahiDBus 33 | { 34 | public class Service : Mono.Zeroconf.IService 35 | { 36 | private string name; 37 | private string regtype; 38 | private string reply_domain; 39 | private int @interface; 40 | private Protocol aprotocol; 41 | private ITxtRecord txt_record; 42 | 43 | public Service () 44 | { 45 | this.@interface = -1; // Unspecified 46 | } 47 | 48 | public Service (string name, string regtype, string replyDomain, int @interface, Protocol aprotocol) 49 | { 50 | this.name = name; 51 | this.regtype = regtype; 52 | this.reply_domain = replyDomain; 53 | this.@interface = @interface; 54 | this.aprotocol = aprotocol; 55 | } 56 | 57 | protected int AvahiInterface { 58 | get { return @interface; } 59 | set { @interface = value; } 60 | } 61 | 62 | protected Protocol AvahiProtocol { 63 | get { return aprotocol; } 64 | set { aprotocol = value; } 65 | } 66 | 67 | public string Name { 68 | get { return name; } 69 | set { name = value; } 70 | } 71 | 72 | public string RegType { 73 | get { return regtype; } 74 | set { regtype = value; } 75 | } 76 | 77 | public string ReplyDomain { 78 | get { return reply_domain; } 79 | set { reply_domain = value; } 80 | } 81 | 82 | public uint NetworkInterface { 83 | get { return AvahiUtils.ToMzcInterface (@interface); } 84 | } 85 | 86 | public AddressProtocol AddressProtocol { 87 | get { return AvahiUtils.ToMzcProtocol (aprotocol); } 88 | } 89 | 90 | public ITxtRecord TxtRecord { 91 | get { return txt_record; } 92 | set { txt_record = value; } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/ZeroconfProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ZeroconfProvider.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007-2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections; 31 | 32 | [assembly:Mono.Zeroconf.Providers.ZeroconfProvider (typeof (Mono.Zeroconf.Providers.AvahiDBus.ZeroconfProvider))] 33 | 34 | namespace Mono.Zeroconf.Providers.AvahiDBus 35 | { 36 | public class ZeroconfProvider : IZeroconfProvider 37 | { 38 | public void Initialize () 39 | { 40 | DBusManager.Initialize (); 41 | } 42 | 43 | public Type ServiceBrowser { 44 | get { return typeof (Mono.Zeroconf.Providers.AvahiDBus.ServiceBrowser); } 45 | } 46 | 47 | public Type RegisterService { 48 | get { return typeof (Mono.Zeroconf.Providers.AvahiDBus.RegisterService); } 49 | } 50 | 51 | public Type TxtRecord { 52 | get { return typeof (Mono.Zeroconf.Providers.AvahiDBus.TxtRecord); } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/Address.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Text; 7 | using System.Collections.Generic; 8 | 9 | namespace NDesk.DBus 10 | { 11 | public class BadAddressException : Exception 12 | { 13 | public BadAddressException (string reason) : base (reason) {} 14 | } 15 | 16 | class AddressEntry 17 | { 18 | public string Method; 19 | public IDictionary Properties = new Dictionary (); 20 | 21 | public override string ToString () 22 | { 23 | StringBuilder sb = new StringBuilder (); 24 | sb.Append (Method); 25 | sb.Append (':'); 26 | 27 | bool first = true; 28 | foreach (KeyValuePair prop in Properties) { 29 | if (first) 30 | first = false; 31 | else 32 | sb.Append (','); 33 | 34 | sb.Append (prop.Key); 35 | sb.Append ('='); 36 | sb.Append (Escape (prop.Value)); 37 | } 38 | 39 | return sb.ToString (); 40 | } 41 | 42 | static string Escape (string str) 43 | { 44 | if (str == null) 45 | return String.Empty; 46 | 47 | StringBuilder sb = new StringBuilder (); 48 | int len = str.Length; 49 | 50 | for (int i = 0 ; i != len ; i++) { 51 | char c = str[i]; 52 | 53 | //everything other than the optionally escaped chars _must_ be escaped 54 | if (Char.IsLetterOrDigit (c) || c == '-' || c == '_' || c == '/' || c == '\\' || c == '.') 55 | sb.Append (c); 56 | else 57 | sb.Append (Uri.HexEscape (c)); 58 | } 59 | 60 | return sb.ToString (); 61 | } 62 | 63 | static string Unescape (string str) 64 | { 65 | if (str == null) 66 | return String.Empty; 67 | 68 | StringBuilder sb = new StringBuilder (); 69 | int len = str.Length; 70 | int i = 0; 71 | while (i != len) { 72 | if (Uri.IsHexEncoding (str, i)) 73 | sb.Append (Uri.HexUnescape (str, ref i)); 74 | else 75 | sb.Append (str[i++]); 76 | } 77 | 78 | return sb.ToString (); 79 | } 80 | 81 | 82 | public static AddressEntry Parse (string s) 83 | { 84 | AddressEntry entry = new AddressEntry (); 85 | 86 | string[] parts = s.Split (':'); 87 | 88 | if (parts.Length < 2) 89 | throw new BadAddressException ("No colon found"); 90 | if (parts.Length > 2) 91 | throw new BadAddressException ("Too many colons found"); 92 | 93 | entry.Method = parts[0]; 94 | 95 | foreach (string propStr in parts[1].Split (',')) { 96 | parts = propStr.Split ('='); 97 | 98 | if (parts.Length < 2) 99 | throw new BadAddressException ("No equals sign found"); 100 | if (parts.Length > 2) 101 | throw new BadAddressException ("Too many equals signs found"); 102 | 103 | entry.Properties[parts[0]] = Unescape (parts[1]); 104 | } 105 | 106 | return entry; 107 | } 108 | } 109 | 110 | static class Address 111 | { 112 | //(unix:(path|abstract)=.*,guid=.*|tcp:host=.*(,port=.*)?);? ... 113 | public static AddressEntry[] Parse (string addresses) 114 | { 115 | if (addresses == null) 116 | throw new ArgumentNullException (addresses); 117 | 118 | List entries = new List (); 119 | 120 | foreach (string entryStr in addresses.Split (';')) 121 | entries.Add (AddressEntry.Parse (entryStr)); 122 | 123 | return entries.ToArray (); 124 | } 125 | 126 | const string SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket"; 127 | public static string System 128 | { 129 | get { 130 | string addr = Environment.GetEnvironmentVariable ("DBUS_SYSTEM_BUS_ADDRESS"); 131 | 132 | if (String.IsNullOrEmpty (addr)) 133 | addr = SYSTEM_BUS_ADDRESS; 134 | 135 | return addr; 136 | } 137 | } 138 | 139 | public static string Session 140 | { 141 | get { 142 | return Environment.GetEnvironmentVariable ("DBUS_SESSION_BUS_ADDRESS"); 143 | } 144 | } 145 | 146 | public static string Starter 147 | { 148 | get { 149 | return Environment.GetEnvironmentVariable ("DBUS_STARTER_ADDRESS"); 150 | } 151 | } 152 | 153 | public static string StarterBusType 154 | { 155 | get { 156 | return Environment.GetEnvironmentVariable ("DBUS_STARTER_BUS_TYPE"); 157 | } 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/Authentication.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Text; 9 | using System.Globalization; 10 | 11 | namespace NDesk.DBus.Authentication 12 | { 13 | enum ClientState 14 | { 15 | WaitingForData, 16 | WaitingForOK, 17 | WaitingForReject, 18 | } 19 | 20 | enum ServerState 21 | { 22 | WaitingForAuth, 23 | WaitingForData, 24 | WaitingForBegin, 25 | } 26 | 27 | class SaslClient 28 | { 29 | protected Connection conn; 30 | 31 | protected SaslClient () 32 | { 33 | } 34 | 35 | public SaslClient (Connection conn) 36 | { 37 | this.conn = conn; 38 | } 39 | 40 | public void Run () 41 | { 42 | StreamReader sr = new StreamReader (conn.Transport.Stream, Encoding.ASCII); 43 | StreamWriter sw = new StreamWriter (conn.Transport.Stream, Encoding.ASCII); 44 | 45 | sw.NewLine = "\r\n"; 46 | 47 | string str = conn.Transport.AuthString (); 48 | byte[] bs = Encoding.ASCII.GetBytes (str); 49 | 50 | string authStr = ToHex (bs); 51 | 52 | sw.WriteLine ("AUTH EXTERNAL {0}", authStr); 53 | sw.Flush (); 54 | 55 | string ok_rep = sr.ReadLine (); 56 | 57 | string[] parts; 58 | parts = ok_rep.Split (' '); 59 | 60 | if (parts.Length < 1 || parts[0] != "OK") 61 | throw new Exception ("Authentication error: AUTH EXTERNAL was not OK: \"" + ok_rep + "\""); 62 | 63 | /* 64 | string guid = parts[1]; 65 | byte[] guidData = FromHex (guid); 66 | uint unixTime = BitConverter.ToUInt32 (guidData, 0); 67 | Console.Error.WriteLine ("guid: " + guid + ", " + "unixTime: " + unixTime + " (" + UnixToDateTime (unixTime) + ")"); 68 | */ 69 | 70 | sw.WriteLine ("BEGIN"); 71 | sw.Flush (); 72 | } 73 | 74 | //From Mono.Unix.Native.NativeConvert 75 | //should these methods use long or (u)int? 76 | public static DateTime UnixToDateTime (long time) 77 | { 78 | DateTime LocalUnixEpoch = new DateTime (1970, 1, 1); 79 | TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow); 80 | return LocalUnixEpoch.AddSeconds ((double) time + LocalUtcOffset.TotalSeconds); 81 | } 82 | 83 | public static long DateTimeToUnix (DateTime time) 84 | { 85 | DateTime LocalUnixEpoch = new DateTime (1970, 1, 1); 86 | TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow); 87 | TimeSpan unixTime = time.Subtract (LocalUnixEpoch) - LocalUtcOffset; 88 | 89 | return (long) unixTime.TotalSeconds; 90 | } 91 | 92 | //From Mono.Security.Cryptography 93 | //Modified to output lowercase hex 94 | static public string ToHex (byte[] input) 95 | { 96 | if (input == null) 97 | return null; 98 | 99 | StringBuilder sb = new StringBuilder (input.Length * 2); 100 | foreach (byte b in input) { 101 | sb.Append (b.ToString ("x2", CultureInfo.InvariantCulture)); 102 | } 103 | return sb.ToString (); 104 | } 105 | 106 | //From Mono.Security.Cryptography 107 | static private byte FromHexChar (char c) 108 | { 109 | if ((c >= 'a') && (c <= 'f')) 110 | return (byte) (c - 'a' + 10); 111 | if ((c >= 'A') && (c <= 'F')) 112 | return (byte) (c - 'A' + 10); 113 | if ((c >= '0') && (c <= '9')) 114 | return (byte) (c - '0'); 115 | throw new ArgumentException ("Invalid hex char"); 116 | } 117 | 118 | //From Mono.Security.Cryptography 119 | static public byte[] FromHex (string hex) 120 | { 121 | if (hex == null) 122 | return null; 123 | if ((hex.Length & 0x1) == 0x1) 124 | throw new ArgumentException ("Length must be a multiple of 2"); 125 | 126 | byte[] result = new byte [hex.Length >> 1]; 127 | int n = 0; 128 | int i = 0; 129 | while (n < result.Length) { 130 | result [n] = (byte) (FromHexChar (hex [i++]) << 4); 131 | result [n++] += FromHexChar (hex [i++]); 132 | } 133 | return result; 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/DBus.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using NDesk.DBus; 8 | 9 | namespace org.freedesktop.DBus 10 | { 11 | [Flags] 12 | public enum NameFlag : uint 13 | { 14 | None = 0, 15 | AllowReplacement = 0x1, 16 | ReplaceExisting = 0x2, 17 | DoNotQueue = 0x4, 18 | } 19 | 20 | public enum RequestNameReply : uint 21 | { 22 | PrimaryOwner = 1, 23 | InQueue, 24 | Exists, 25 | AlreadyOwner, 26 | } 27 | 28 | public enum ReleaseNameReply : uint 29 | { 30 | Released = 1, 31 | NonExistent, 32 | NotOwner, 33 | } 34 | 35 | public enum StartReply : uint 36 | { 37 | //The service was successfully started. 38 | Success = 1, 39 | //A connection already owns the given name. 40 | AlreadyRunning, 41 | } 42 | 43 | public delegate void NameOwnerChangedHandler (string name, string old_owner, string new_owner); 44 | public delegate void NameAcquiredHandler (string name); 45 | public delegate void NameLostHandler (string name); 46 | 47 | [Interface ("org.freedesktop.DBus.Peer")] 48 | public interface Peer 49 | { 50 | void Ping (); 51 | [return: Argument ("machine_uuid")] 52 | string GetMachineId (); 53 | } 54 | 55 | [Interface ("org.freedesktop.DBus.Introspectable")] 56 | public interface Introspectable 57 | { 58 | [return: Argument ("data")] 59 | string Introspect (); 60 | } 61 | 62 | [Interface ("org.freedesktop.DBus.Properties")] 63 | public interface Properties 64 | { 65 | [return: Argument ("value")] 66 | object Get (string @interface, string propname); 67 | void Set (string @interface, string propname, object value); 68 | [return: Argument ("props")] 69 | IDictionary GetAll(string @interface); 70 | } 71 | 72 | [Interface ("org.freedesktop.DBus")] 73 | public interface IBus : Introspectable 74 | { 75 | RequestNameReply RequestName (string name, NameFlag flags); 76 | ReleaseNameReply ReleaseName (string name); 77 | string Hello (); 78 | string[] ListNames (); 79 | string[] ListActivatableNames (); 80 | bool NameHasOwner (string name); 81 | event NameOwnerChangedHandler NameOwnerChanged; 82 | event NameLostHandler NameLost; 83 | event NameAcquiredHandler NameAcquired; 84 | StartReply StartServiceByName (string name, uint flags); 85 | string GetNameOwner (string name); 86 | uint GetConnectionUnixUser (string connection_name); 87 | void AddMatch (string rule); 88 | void RemoveMatch (string rule); 89 | 90 | //undocumented in spec 91 | string[] ListQueuedOwners (string name); 92 | uint GetConnectionUnixProcessID (string connection_name); 93 | byte[] GetConnectionSELinuxSecurityContext (string connection_name); 94 | void ReloadConfig (); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/DProxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Reflection; 7 | using System.Runtime.Remoting.Proxies; 8 | using System.Runtime.Remoting.Messaging; 9 | 10 | namespace NDesk.DBus 11 | { 12 | //marked internal because this is really an implementation detail and needs to be replaced 13 | internal class DProxy : RealProxy 14 | { 15 | protected BusObject busObject; 16 | 17 | public DProxy (BusObject busObject, Type type) : base(type) 18 | { 19 | this.busObject = busObject; 20 | } 21 | 22 | static MethodInfo mi_GetHashCode = typeof (object).GetMethod ("GetHashCode"); 23 | static MethodInfo mi_Equals = typeof (object).GetMethod ("Equals", BindingFlags.Instance); 24 | static MethodInfo mi_ToString = typeof (object).GetMethod ("ToString"); 25 | static MethodInfo mi_GetLifetimeService = typeof (MarshalByRefObject).GetMethod ("GetLifetimeService"); 26 | 27 | object GetDefaultReturn (MethodBase mi, object[] inArgs) 28 | { 29 | if (mi == mi_GetHashCode) 30 | return busObject.Path.Value.GetHashCode (); 31 | if (mi == mi_Equals) 32 | return busObject.Path.Value == ((BusObject)((MarshalByRefObject)inArgs[0]).GetLifetimeService ()).Path.Value; 33 | if (mi == mi_ToString) 34 | return busObject.Path.Value; 35 | if (mi == mi_GetLifetimeService) 36 | return busObject; 37 | 38 | return null; 39 | } 40 | 41 | public override IMessage Invoke (IMessage message) 42 | { 43 | IMethodCallMessage callMessage = (IMethodCallMessage) message; 44 | 45 | object defaultRetVal = GetDefaultReturn (callMessage.MethodBase, callMessage.InArgs); 46 | if (defaultRetVal != null) { 47 | MethodReturnMessageWrapper defaultReturnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message); 48 | defaultReturnMessage.ReturnValue = defaultRetVal; 49 | 50 | return defaultReturnMessage; 51 | } 52 | 53 | object[] outArgs; 54 | object retVal; 55 | Exception exception; 56 | busObject.Invoke (callMessage.MethodBase, callMessage.MethodName, callMessage.InArgs, out outArgs, out retVal, out exception); 57 | 58 | MethodReturnMessageWrapper returnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message); 59 | returnMessage.Exception = exception; 60 | returnMessage.ReturnValue = retVal; 61 | 62 | return returnMessage; 63 | } 64 | 65 | /* 66 | public override ObjRef CreateObjRef (Type ServerType) 67 | { 68 | throw new System.NotImplementedException (); 69 | } 70 | */ 71 | 72 | ~DProxy () 73 | { 74 | //FIXME: remove handlers/match rules here 75 | if (Protocol.Verbose) 76 | Console.Error.WriteLine ("Warning: Finalization of " + busObject.Path + " not yet supported"); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/ExportObject.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Reflection; 7 | using System.Reflection.Emit; 8 | 9 | using org.freedesktop.DBus; 10 | 11 | namespace NDesk.DBus 12 | { 13 | //TODO: perhaps ExportObject should not derive from BusObject 14 | internal class ExportObject : BusObject //, Peer 15 | { 16 | public readonly object obj; 17 | 18 | public ExportObject (Connection conn, ObjectPath object_path, object obj) : base (conn, null, object_path) 19 | { 20 | this.obj = obj; 21 | } 22 | 23 | //maybe add checks to make sure this is not called more than once 24 | //it's a bit silly as a property 25 | public bool Registered 26 | { 27 | set { 28 | Type type = obj.GetType (); 29 | 30 | foreach (MemberInfo mi in Mapper.GetPublicMembers (type)) { 31 | EventInfo ei = mi as EventInfo; 32 | 33 | if (ei == null) 34 | continue; 35 | 36 | Delegate dlg = GetHookupDelegate (ei); 37 | 38 | if (value) 39 | ei.AddEventHandler (obj, dlg); 40 | else 41 | ei.RemoveEventHandler (obj, dlg); 42 | } 43 | } 44 | } 45 | 46 | public void HandleMethodCall (MethodCall method_call) 47 | { 48 | Type type = obj.GetType (); 49 | //object retObj = type.InvokeMember (msg.Member, BindingFlags.InvokeMethod, null, obj, MessageHelper.GetDynamicValues (msg)); 50 | 51 | //TODO: there is no member name mapping for properties etc. yet 52 | MethodInfo mi = Mapper.GetMethod (type, method_call); 53 | 54 | if (mi == null) { 55 | conn.MaybeSendUnknownMethodError (method_call); 56 | return; 57 | } 58 | 59 | object retObj = null; 60 | object[] parmValues = MessageHelper.GetDynamicValues (method_call.message, mi.GetParameters ()); 61 | 62 | try { 63 | retObj = mi.Invoke (obj, parmValues); 64 | } catch (TargetInvocationException e) { 65 | if (!method_call.message.ReplyExpected) 66 | return; 67 | 68 | Exception ie = e.InnerException; 69 | //TODO: complete exception sending support 70 | 71 | Error error = new Error (Mapper.GetInterfaceName (ie.GetType ()), method_call.message.Header.Serial); 72 | error.message.Signature = new Signature (DType.String); 73 | 74 | MessageWriter writer = new MessageWriter (Connection.NativeEndianness); 75 | writer.connection = conn; 76 | writer.Write (ie.Message); 77 | error.message.Body = writer.ToArray (); 78 | 79 | //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p 80 | if (method_call.Sender != null) 81 | error.message.Header.Fields[FieldCode.Destination] = method_call.Sender; 82 | 83 | conn.Send (error.message); 84 | return; 85 | } 86 | 87 | if (method_call.message.ReplyExpected) { 88 | Message reply = MessageHelper.ConstructDynamicReply (method_call, mi, retObj, parmValues); 89 | conn.Send (reply); 90 | } 91 | } 92 | 93 | /* 94 | public void Ping () 95 | { 96 | } 97 | 98 | public string GetMachineId () 99 | { 100 | //TODO: implement this 101 | return String.Empty; 102 | } 103 | */ 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/IntrospectionSchema.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Xml.Serialization; 7 | using System.Collections.Generic; 8 | 9 | namespace NDesk.DBus.Introspection 10 | { 11 | [XmlRootAttribute(IsNullable=true)] 12 | public class Member { 13 | [XmlAttributeAttribute("name")] 14 | public string Name; 15 | } 16 | 17 | [XmlRootAttribute("node", IsNullable=true)] 18 | public class Node { 19 | 20 | [XmlAttributeAttribute("name")] 21 | public string Name; 22 | 23 | [XmlElementAttribute("interface", Type=typeof(@Interface))] 24 | public Interface[] Interfaces; 25 | [XmlElementAttribute("node", Type=typeof(Node))] 26 | public Node[] Nodes; 27 | } 28 | 29 | [XmlRootAttribute("interface", IsNullable=true)] 30 | public class @Interface { 31 | 32 | [XmlAttributeAttribute("name")] 33 | public string Name; 34 | 35 | /* 36 | [XmlElementAttribute("method", Type=typeof(Method))] 37 | [XmlElementAttribute("signal", Type=typeof(Signal))] 38 | [XmlElementAttribute("property", Type=typeof(Property))] 39 | //[XmlElementAttribute("annotation", Type=typeof(Annotation))] 40 | //public Member[] Members; 41 | */ 42 | 43 | [XmlElementAttribute("method", Type=typeof(Method))] 44 | public Method[] Methods; 45 | 46 | [XmlElementAttribute("signal", Type=typeof(Signal))] 47 | public Signal[] Signals; 48 | 49 | [XmlElementAttribute("property", Type=typeof(Property))] 50 | public Property[] Properties; 51 | } 52 | 53 | [XmlRootAttribute(IsNullable=true)] 54 | public class Method : Member { 55 | 56 | /* 57 | [XmlElementAttribute("arg", Type=typeof(Argument))] 58 | [XmlElementAttribute("annotation", Type=typeof(Annotation))] 59 | public object[] Items; 60 | */ 61 | 62 | //[System.ComponentModel.DefaultValue(new Argument[0])] 63 | [XmlElementAttribute("arg", Type=typeof(Argument))] 64 | //public List Arguments; 65 | public Argument[] Arguments; 66 | } 67 | 68 | [XmlRootAttribute(IsNullable=true)] 69 | public class Argument { 70 | 71 | [XmlAttributeAttribute("name")] 72 | public string Name = String.Empty; 73 | 74 | [XmlAttributeAttribute("type")] 75 | public string Type; 76 | 77 | [System.ComponentModel.DefaultValue(ArgDirection.@in)] 78 | [XmlAttributeAttribute("direction")] 79 | public ArgDirection Direction = ArgDirection.@in; 80 | } 81 | 82 | public enum ArgDirection { 83 | @in, 84 | @out, 85 | } 86 | 87 | [XmlRootAttribute(IsNullable=true)] 88 | public class Annotation { 89 | 90 | [XmlAttributeAttribute("name")] 91 | public string Name = String.Empty; 92 | 93 | [XmlAttributeAttribute("value")] 94 | public string Value = String.Empty; 95 | } 96 | 97 | [XmlRootAttribute("signal", IsNullable=true)] 98 | public class Signal : Method { 99 | } 100 | 101 | [XmlRootAttribute(IsNullable=true)] 102 | public class Property : Member { 103 | [XmlAttributeAttribute("type")] 104 | public string Type = String.Empty; 105 | 106 | [XmlAttributeAttribute("access")] 107 | public propertyAccess Access; 108 | 109 | [XmlElementAttribute("annotation")] 110 | public Annotation[] Annotations; 111 | } 112 | 113 | public enum propertyAccess { 114 | read, 115 | write, 116 | readwrite, 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/Message.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | 9 | namespace NDesk.DBus 10 | { 11 | class Message 12 | { 13 | public Message () 14 | { 15 | Header.Endianness = Connection.NativeEndianness; 16 | Header.MessageType = MessageType.MethodCall; 17 | Header.Flags = HeaderFlag.NoReplyExpected; //TODO: is this the right place to do this? 18 | Header.MajorVersion = Protocol.Version; 19 | Header.Fields = new Dictionary (); 20 | } 21 | 22 | public Header Header; 23 | 24 | public Connection Connection; 25 | 26 | public Signature Signature 27 | { 28 | get { 29 | object o; 30 | if (Header.Fields.TryGetValue (FieldCode.Signature, out o)) 31 | return (Signature)o; 32 | else 33 | return Signature.Empty; 34 | } set { 35 | if (value == Signature.Empty) 36 | Header.Fields.Remove (FieldCode.Signature); 37 | else 38 | Header.Fields[FieldCode.Signature] = value; 39 | } 40 | } 41 | 42 | public bool ReplyExpected 43 | { 44 | get { 45 | return (Header.Flags & HeaderFlag.NoReplyExpected) == HeaderFlag.None; 46 | } set { 47 | if (value) 48 | Header.Flags &= ~HeaderFlag.NoReplyExpected; //flag off 49 | else 50 | Header.Flags |= HeaderFlag.NoReplyExpected; //flag on 51 | } 52 | } 53 | 54 | //public HeaderField[] HeaderFields; 55 | //public Dictionary; 56 | 57 | public byte[] Body; 58 | 59 | //TODO: make use of Locked 60 | /* 61 | protected bool locked = false; 62 | public bool Locked 63 | { 64 | get { 65 | return locked; 66 | } 67 | } 68 | */ 69 | 70 | public void SetHeaderData (byte[] data) 71 | { 72 | EndianFlag endianness = (EndianFlag)data[0]; 73 | MessageReader reader = new MessageReader (endianness, data); 74 | 75 | Header = (Header)reader.ReadStruct (typeof (Header)); 76 | } 77 | 78 | public byte[] GetHeaderData () 79 | { 80 | if (Body != null) 81 | Header.Length = (uint)Body.Length; 82 | 83 | MessageWriter writer = new MessageWriter (Header.Endianness); 84 | writer.WriteValueType (Header, typeof (Header)); 85 | writer.CloseWrite (); 86 | 87 | return writer.ToArray (); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/MessageFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | 7 | namespace NDesk.DBus 8 | { 9 | class MessageFilter 10 | { 11 | //this should probably be made to use HeaderField or similar 12 | //this class is not generalized yet 13 | 14 | public static string MessageTypeToString (MessageType mtype) 15 | { 16 | switch (mtype) 17 | { 18 | case MessageType.MethodCall: 19 | return "method_call"; 20 | case MessageType.MethodReturn: 21 | return "method_return"; 22 | case MessageType.Error: 23 | return "error"; 24 | case MessageType.Signal: 25 | return "signal"; 26 | case MessageType.Invalid: 27 | return "invalid"; 28 | default: 29 | throw new Exception ("Bad MessageType: " + mtype); 30 | } 31 | } 32 | 33 | public static MessageType StringToMessageType (string text) 34 | { 35 | switch (text) 36 | { 37 | case "method_call": 38 | return MessageType.MethodCall; 39 | case "method_return": 40 | return MessageType.MethodReturn; 41 | case "error": 42 | return MessageType.Error; 43 | case "signal": 44 | return MessageType.Signal; 45 | case "invalid": 46 | return MessageType.Invalid; 47 | default: 48 | throw new Exception ("Bad MessageType: " + text); 49 | } 50 | } 51 | 52 | //TODO: remove this -- left here for the benefit of the monitor tool for now 53 | public static string CreateMatchRule (MessageType mtype) 54 | { 55 | return "type='" + MessageTypeToString (mtype) + "'"; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/PendingCall.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2007 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.Threading; 7 | 8 | namespace NDesk.DBus 9 | { 10 | class PendingCall 11 | { 12 | Connection conn; 13 | Message reply = null; 14 | object lockObj = new object (); 15 | 16 | public PendingCall (Connection conn) 17 | { 18 | this.conn = conn; 19 | } 20 | 21 | int waiters = 0; 22 | 23 | public Message Reply 24 | { 25 | get { 26 | if (Thread.CurrentThread == conn.mainThread) { 27 | /* 28 | while (reply == null) 29 | conn.Iterate (); 30 | */ 31 | 32 | while (reply == null) 33 | conn.HandleMessage (conn.ReadMessage ()); 34 | 35 | conn.DispatchSignals (); 36 | } else { 37 | lock (lockObj) { 38 | Interlocked.Increment (ref waiters); 39 | 40 | while (reply == null) 41 | Monitor.Wait (lockObj); 42 | 43 | Interlocked.Decrement (ref waiters); 44 | } 45 | } 46 | 47 | return reply; 48 | } set { 49 | lock (lockObj) { 50 | reply = value; 51 | 52 | if (waiters > 0) 53 | Monitor.PulseAll (lockObj); 54 | 55 | if (Completed != null) 56 | Completed (reply); 57 | } 58 | } 59 | } 60 | 61 | public event Action Completed; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/Server.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.IO; 7 | using System.Net; 8 | using System.Net.Sockets; 9 | 10 | namespace NDesk.DBus 11 | { 12 | //TODO: complete this class 13 | class Server 14 | { 15 | public void Listen (string address) 16 | { 17 | this.address = address; 18 | } 19 | 20 | public void Disconnect () 21 | { 22 | } 23 | 24 | public bool IsConnected 25 | { 26 | get { 27 | return true; 28 | } 29 | } 30 | 31 | protected string address; 32 | public string Address 33 | { 34 | get { 35 | return address; 36 | } 37 | } 38 | 39 | //TODO: new connection event/virtual method 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/SocketTransport.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.IO; 7 | using System.Net; 8 | using System.Net.Sockets; 9 | 10 | namespace NDesk.DBus.Transports 11 | { 12 | class SocketTransport : Transport 13 | { 14 | protected Socket socket; 15 | 16 | public override void Open (AddressEntry entry) 17 | { 18 | string host, portStr; 19 | int port; 20 | 21 | if (!entry.Properties.TryGetValue ("host", out host)) 22 | throw new Exception ("No host specified"); 23 | 24 | if (!entry.Properties.TryGetValue ("port", out portStr)) 25 | throw new Exception ("No port specified"); 26 | 27 | if (!Int32.TryParse (portStr, out port)) 28 | throw new Exception ("Invalid port: \"" + port + "\""); 29 | 30 | Open (host, port); 31 | } 32 | 33 | public void Open (string host, int port) 34 | { 35 | //TODO: use Socket directly 36 | TcpClient client = new TcpClient (host, port); 37 | Stream = client.GetStream (); 38 | } 39 | 40 | public void Open (Socket socket) 41 | { 42 | this.socket = socket; 43 | 44 | socket.Blocking = true; 45 | SocketHandle = (long)socket.Handle; 46 | //Stream = new UnixStream ((int)socket.Handle); 47 | Stream = new NetworkStream (socket); 48 | } 49 | 50 | public override void WriteCred () 51 | { 52 | Stream.WriteByte (0); 53 | } 54 | 55 | public override string AuthString () 56 | { 57 | return String.Empty; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/Transport.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.IO; 7 | 8 | namespace NDesk.DBus.Transports 9 | { 10 | abstract class Transport 11 | { 12 | public static Transport Create (AddressEntry entry) 13 | { 14 | switch (entry.Method) { 15 | case "tcp": 16 | { 17 | Transport transport = new SocketTransport (); 18 | transport.Open (entry); 19 | return transport; 20 | } 21 | #if !PORTABLE 22 | case "unix": 23 | { 24 | //Transport transport = new UnixMonoTransport (); 25 | Transport transport = new UnixNativeTransport (); 26 | transport.Open (entry); 27 | return transport; 28 | } 29 | #endif 30 | default: 31 | throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported"); 32 | } 33 | } 34 | 35 | protected Connection connection; 36 | 37 | public Connection Connection 38 | { 39 | get { 40 | return connection; 41 | } set { 42 | connection = value; 43 | } 44 | } 45 | 46 | //TODO: design this properly 47 | 48 | //this is just a temporary solution 49 | public Stream Stream; 50 | public long SocketHandle; 51 | public abstract void Open (AddressEntry entry); 52 | public abstract string AuthString (); 53 | public abstract void WriteCred (); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/UnixMonoTransport.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.IO; 7 | using System.Net; 8 | using System.Net.Sockets; 9 | 10 | using Mono.Unix; 11 | using Mono.Unix.Native; 12 | 13 | namespace NDesk.DBus.Transports 14 | { 15 | class UnixMonoTransport : UnixTransport 16 | { 17 | protected Socket socket; 18 | 19 | public override void Open (string path, bool @abstract) 20 | { 21 | if (@abstract) 22 | socket = OpenAbstractUnix (path); 23 | else 24 | socket = OpenUnix (path); 25 | 26 | socket.Blocking = true; 27 | SocketHandle = (long)socket.Handle; 28 | //Stream = new UnixStream ((int)socket.Handle); 29 | Stream = new NetworkStream (socket); 30 | } 31 | 32 | //send peer credentials null byte. note that this might not be portable 33 | //there are also selinux, BSD etc. considerations 34 | public override void WriteCred () 35 | { 36 | Stream.WriteByte (0); 37 | } 38 | 39 | protected Socket OpenAbstractUnix (string path) 40 | { 41 | AbstractUnixEndPoint ep = new AbstractUnixEndPoint (path); 42 | 43 | Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0); 44 | client.Connect (ep); 45 | 46 | return client; 47 | } 48 | 49 | public Socket OpenUnix (string path) 50 | { 51 | UnixEndPoint remoteEndPoint = new UnixEndPoint (path); 52 | 53 | Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0); 54 | client.Connect (remoteEndPoint); 55 | 56 | return client; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.AvahiDBus/NDesk.DBus/UnixTransport.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Alp Toker 2 | // This software is made available under the MIT License 3 | // See COPYING for details 4 | 5 | using System; 6 | using System.IO; 7 | using Mono.Unix; 8 | 9 | namespace NDesk.DBus.Transports 10 | { 11 | abstract class UnixTransport : Transport 12 | { 13 | public override void Open (AddressEntry entry) 14 | { 15 | string path; 16 | bool abstr; 17 | 18 | if (entry.Properties.TryGetValue ("path", out path)) 19 | abstr = false; 20 | else if (entry.Properties.TryGetValue ("abstract", out path)) 21 | abstr = true; 22 | else 23 | throw new Exception ("No path specified for UNIX transport"); 24 | 25 | Open (path, abstr); 26 | } 27 | 28 | public override string AuthString () 29 | { 30 | long uid = UnixUserInfo.GetRealUserId (); 31 | 32 | return uid.ToString (); 33 | } 34 | 35 | public abstract void Open (string path, bool @abstract); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Makefile.am: -------------------------------------------------------------------------------- 1 | ASSEMBLY_NAME = Mono.Zeroconf.Providers.Bonjour 2 | ASSEMBLY = $(ASSEMBLY_NAME).dll 3 | 4 | MONO_ZEROCONF_PROVIDERS_BONJOUR_SRC = \ 5 | BrowseService.cs \ 6 | Native.cs \ 7 | RegisterService.cs \ 8 | ServiceBrowser.cs \ 9 | ServiceClass.cs \ 10 | Service.cs \ 11 | ServiceError.cs \ 12 | ServiceErrorException.cs \ 13 | ServiceFlags.cs \ 14 | ServiceRef.cs \ 15 | ServiceType.cs \ 16 | TxtRecord.cs \ 17 | TxtRecordEnumerator.cs \ 18 | ZeroconfProvider.cs 19 | 20 | SOURCES_PRE = \ 21 | $(foreach source,$(MONO_ZEROCONF_PROVIDERS_BONJOUR_SRC),Mono.Zeroconf.Providers.Bonjour/$(source)) 22 | SOURCES = \ 23 | $(top_srcdir)/src/AssemblyInfo.cs \ 24 | $(foreach source,$(SOURCES_PRE),$(srcdir)/$(source)) 25 | 26 | if BUILD_MDNSRESPONDER 27 | 28 | assemblydir = $(libdir)/mono-zeroconf 29 | assembly_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb $(ASSEMBLY).config 30 | 31 | all: $(ASSEMBLY) 32 | 33 | $(ASSEMBLY): $(top_builddir)/src/Mono.Zeroconf/Mono.Zeroconf.dll $(SOURCES) 34 | $(MCS) -debug -target:library -out:$@ -r:$< $(AVAHI_LIBS) $(SOURCES) 35 | 36 | endif 37 | 38 | EXTRA_DIST = $(SOURCES) $(ASSEMBLY).config \ 39 | Mono.Zeroconf.Providers.Bonjour.csproj 40 | CLEANFILES = *.dll *.mdb 41 | DISTCLEANFILES = *.pidb 42 | MAINTAINERCLEANFILES = \ 43 | Makefile.in 44 | 45 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {623325E2-5821-4701-A40C-3759097008DD} 9 | Library 10 | Properties 11 | Mono.Zeroconf.Providers.Bonjour 12 | Mono.Zeroconf.Providers.Bonjour 13 | v2.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | ..\..\bin 21 | 22 | 23 | prompt 24 | 4 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | {623325E2-5821-4701-A40C-3759097008DD} 49 | Mono.Zeroconf 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour.dll.config.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/ServiceClass.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceClass.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | namespace Mono.Zeroconf.Providers.Bonjour 30 | { 31 | public enum ServiceClass : ushort { 32 | IN = 1 /* Internet */ 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/ServiceError.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceError.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | namespace Mono.Zeroconf.Providers.Bonjour 30 | { 31 | public enum ServiceError { 32 | NoError = 0, 33 | Unknown = -65537, /* 0xFFFE FFFF */ 34 | NoSuchName = -65538, 35 | NoMemory = -65539, 36 | BadParam = -65540, 37 | BadReference = -65541, 38 | BadState = -65542, 39 | BadFlags = -65543, 40 | Unsupported = -65544, 41 | NotInitialized = -65545, 42 | AlreadyRegistered = -65547, 43 | NameConflict = -65548, 44 | Invalid = -65549, 45 | Firewall = -65550, 46 | Incompatible = -65551, /* client library incompatible with daemon */ 47 | BadInterfaceIndex = -65552, 48 | Refused = -65553, 49 | NoSuchRecord = -65554, 50 | NoAuth = -65555, 51 | NoSuchKey = -65556, 52 | NATTraversal = -65557, 53 | DoubleNAT = -65558, 54 | BadTime = -65559 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/ServiceErrorException.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceException.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers.Bonjour 32 | { 33 | internal class ServiceErrorException : Exception 34 | { 35 | internal ServiceErrorException(ServiceError error) : base(error.ToString()) 36 | { 37 | } 38 | 39 | internal ServiceErrorException(string error) : base(error) 40 | { 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/ServiceRef.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceRef.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Threading; 31 | using System.Collections; 32 | using System.Runtime.InteropServices; 33 | 34 | namespace Mono.Zeroconf.Providers.Bonjour 35 | { 36 | public struct ServiceRef 37 | { 38 | public static readonly ServiceRef Zero; 39 | 40 | private IntPtr raw; 41 | 42 | public ServiceRef(IntPtr raw) 43 | { 44 | this.raw = raw; 45 | } 46 | 47 | public void Deallocate() 48 | { 49 | Native.DNSServiceRefDeallocate(Raw); 50 | } 51 | 52 | public ServiceError ProcessSingle() 53 | { 54 | return Native.DNSServiceProcessResult(Raw); 55 | } 56 | 57 | public void Process() 58 | { 59 | while(ProcessSingle() == ServiceError.NoError); 60 | } 61 | 62 | public int SocketFD { 63 | get { 64 | return Native.DNSServiceRefSockFD(Raw); 65 | } 66 | } 67 | 68 | public IntPtr Raw { 69 | get { 70 | return raw; 71 | } 72 | } 73 | 74 | public override bool Equals(object o) 75 | { 76 | if(!(o is ServiceRef)) { 77 | return false; 78 | } 79 | 80 | return ((ServiceRef)o).Raw == Raw; 81 | } 82 | 83 | public override int GetHashCode() 84 | { 85 | return Raw.GetHashCode(); 86 | } 87 | 88 | public static bool operator ==(ServiceRef a, ServiceRef b) 89 | { 90 | return a.Raw == b.Raw; 91 | } 92 | 93 | public static bool operator !=(ServiceRef a, ServiceRef b) 94 | { 95 | return a.Raw != b.Raw; 96 | } 97 | 98 | public static explicit operator IntPtr(ServiceRef value) 99 | { 100 | return value.Raw; 101 | } 102 | 103 | public static explicit operator ServiceRef(IntPtr value) 104 | { 105 | return new ServiceRef(value); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/ServiceType.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceType.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | namespace Mono.Zeroconf.Providers.Bonjour 30 | { 31 | public enum ServiceType : ushort { 32 | A = 1, /* Host address. */ 33 | NS = 2, /* Authoritative server. */ 34 | MD = 3, /* Mail destination. */ 35 | MF = 4, /* Mail forwarder. */ 36 | CNAME = 5, /* Canonical name. */ 37 | SOA = 6, /* Start of authority zone. */ 38 | MB = 7, /* Mailbox domain name. */ 39 | MG = 8, /* Mail group member. */ 40 | MR = 9, /* Mail rename name. */ 41 | NULL = 10, /* Null resource record. */ 42 | WKS = 11, /* Well known service. */ 43 | PTR = 12, /* Domain name pointer. */ 44 | HINFO = 13, /* Host information. */ 45 | MINFO = 14, /* Mailbox information. */ 46 | MX = 15, /* Mail routing information. */ 47 | TXT = 16, /* One or more text strings. */ 48 | RP = 17, /* Responsible person. */ 49 | AFSDB = 18, /* AFS cell database. */ 50 | X25 = 19, /* X_25 calling address. */ 51 | ISDN = 20, /* ISDN calling address. */ 52 | RT = 21, /* Router. */ 53 | NSAP = 22, /* NSAP address. */ 54 | NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated). */ 55 | SIG = 24, /* Security signature. */ 56 | KEY = 25, /* Security key. */ 57 | PX = 26, /* X.400 mail mapping. */ 58 | GPOS = 27, /* Geographical position (withdrawn). */ 59 | AAAA = 28, /* IPv6 Address. */ 60 | LOC = 29, /* Location Information. */ 61 | NXT = 30, /* Next domain (security). */ 62 | EID = 31, /* Endpoint identifier. */ 63 | NIMLOC = 32, /* Nimrod Locator. */ 64 | SRV = 33, /* Server Selection. */ 65 | ATMA = 34, /* ATM Address */ 66 | NAPTR = 35, /* Naming Authority PoinTeR */ 67 | KX = 36, /* Key Exchange */ 68 | CERT = 37, /* Certification record */ 69 | A6 = 38, /* IPv6 Address (deprecated) */ 70 | DNAME = 39, /* Non-terminal DNAME (for IPv6) */ 71 | SINK = 40, /* Kitchen sink (experimentatl) */ 72 | OPT = 41, /* EDNS0 option (meta-RR) */ 73 | TKEY = 249, /* Transaction key */ 74 | TSIG = 250, /* Transaction signature. */ 75 | IXFR = 251, /* Incremental zone transfer. */ 76 | AXFR = 252, /* Transfer zone of authority. */ 77 | MAILB = 253, /* Transfer mailbox records. */ 78 | MAILA = 254, /* Transfer mail agent records. */ 79 | ANY = 255 /* Wildcard match. */ 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/TxtRecordEnumerator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // TxtRecordEnumerator.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections; 31 | 32 | namespace Mono.Zeroconf.Providers.Bonjour 33 | { 34 | internal class TxtRecordEnumerator : IEnumerator 35 | { 36 | private TxtRecord record; 37 | private TxtRecordItem current_item; 38 | private int index; 39 | 40 | public TxtRecordEnumerator(TxtRecord record) 41 | { 42 | this.record = record; 43 | } 44 | 45 | public void Reset() 46 | { 47 | index = 0; 48 | current_item = null; 49 | } 50 | 51 | public bool MoveNext() 52 | { 53 | if(index < 0 || index >= record.Count) { 54 | return false; 55 | } 56 | 57 | current_item = record.GetItemAt(index++); 58 | return current_item != null; 59 | } 60 | 61 | public object Current { 62 | get { return current_item; } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/ZeroconfProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ZeroconfProvider.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | [assembly:Mono.Zeroconf.Providers.ZeroconfProvider(typeof(Mono.Zeroconf.Providers.Bonjour.ZeroconfProvider))] 32 | 33 | namespace Mono.Zeroconf.Providers.Bonjour 34 | { 35 | public static class Zeroconf 36 | { 37 | public static void Initialize() 38 | { 39 | ServiceRef sd_ref; 40 | ServiceError error = Native.DNSServiceCreateConnection(out sd_ref); 41 | 42 | if(error != ServiceError.NoError) { 43 | throw new ServiceErrorException(error); 44 | } 45 | 46 | sd_ref.Deallocate(); 47 | 48 | return; 49 | } 50 | } 51 | 52 | public class ZeroconfProvider : IZeroconfProvider 53 | { 54 | public void Initialize() 55 | { 56 | Zeroconf.Initialize(); 57 | } 58 | 59 | public Type ServiceBrowser { 60 | get { return typeof(ServiceBrowser); } 61 | } 62 | 63 | public Type RegisterService { 64 | get { return typeof(RegisterService); } 65 | } 66 | 67 | public Type TxtRecord { 68 | get { return typeof(TxtRecord); } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Makefile.am: -------------------------------------------------------------------------------- 1 | ASSEMBLY_NAME = Mono.Zeroconf 2 | ASSEMBLY = $(ASSEMBLY_NAME).dll 3 | 4 | MONO_ZEROCONF_SRC = \ 5 | Mono.Zeroconf/AddressProtocol.cs \ 6 | Mono.Zeroconf/IRegisterService.cs \ 7 | Mono.Zeroconf/IResolvableService.cs \ 8 | Mono.Zeroconf/IServiceBrowser.cs \ 9 | Mono.Zeroconf/IService.cs \ 10 | Mono.Zeroconf/ITxtRecord.cs \ 11 | Mono.Zeroconf/RegisterService.cs \ 12 | Mono.Zeroconf/RegisterServiceEventArgs.cs \ 13 | Mono.Zeroconf/RegisterServiceEventHandler.cs \ 14 | Mono.Zeroconf/ServiceBrowseEventArgs.cs \ 15 | Mono.Zeroconf/ServiceBrowseEventHandler.cs \ 16 | Mono.Zeroconf/ServiceBrowser.cs \ 17 | Mono.Zeroconf/ServiceResolvedEventArgs.cs \ 18 | Mono.Zeroconf/ServiceResolvedEventHandler.cs \ 19 | Mono.Zeroconf/ServiceErrorCode.cs \ 20 | Mono.Zeroconf/TxtRecord.cs \ 21 | Mono.Zeroconf/TxtRecordItem.cs 22 | 23 | MONO_ZEROCONF_PROVIDERS_SRC = \ 24 | Mono.Zeroconf.Providers/IZeroconfProvider.cs \ 25 | Mono.Zeroconf.Providers/ZeroconfProviderAttribute.cs \ 26 | Mono.Zeroconf.Providers/ProviderFactory.cs 27 | 28 | SOURCES_PRE = \ 29 | $(MONO_ZEROCONF_SRC) \ 30 | $(MONO_ZEROCONF_PROVIDERS_SRC) 31 | 32 | SOURCES = \ 33 | $(top_srcdir)/src/AssemblyInfo.cs \ 34 | $(foreach source,$(SOURCES_PRE),$(srcdir)/$(source)) 35 | 36 | all: $(ASSEMBLY) 37 | 38 | $(ASSEMBLY): $(SOURCES) $(POLICY_ASSEMBLIES) 39 | $(MCS) -debug -keyfile:$(top_srcdir)/src/mono-zeroconf.snk -target:library -out:$@ $(SOURCES) 40 | 41 | install-data-local: gac-install 42 | 43 | uninstall-local: gac-uninstall 44 | 45 | include $(top_srcdir)/src/Makefile.include 46 | 47 | EXTRA_DIST = $(SOURCES) Mono.Zeroconf.csproj 48 | CLEANFILES = *.dll *.mdb $(POLICY_ASSEMBLIES) $(POLICY_CONFIGS) 49 | DISTCLEANFILES = *.pidb 50 | MAINTAINERCLEANFILES = Makefile.in 51 | 52 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf.Providers/IZeroconfProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IZeroconfProvider.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers 32 | { 33 | public interface IZeroconfProvider 34 | { 35 | void Initialize(); 36 | Type ServiceBrowser { get; } 37 | Type RegisterService { get; } 38 | Type TxtRecord { get; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf.Providers/ZeroconfProviderAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ZeroconfProviderAttribute.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf.Providers 32 | { 33 | [AttributeUsage(AttributeTargets.Assembly)] 34 | public class ZeroconfProviderAttribute : Attribute 35 | { 36 | private Type provider_type; 37 | 38 | public ZeroconfProviderAttribute(Type providerType) 39 | { 40 | this.provider_type = providerType; 41 | } 42 | 43 | public Type ProviderType { 44 | get { return provider_type; } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {5CF88E3A-13DD-4114-BAD9-DA826946516F} 9 | Library 10 | Properties 11 | Mono.Zeroconf 12 | Mono.Zeroconf 13 | v2.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | ..\..\bin 21 | 22 | 23 | prompt 24 | 4 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/AddressProtocol.cs: -------------------------------------------------------------------------------- 1 | // 2 | // AddressProtocol.cs 3 | // 4 | // Author: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2008 Novell, Inc. 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf 32 | { 33 | public enum AddressProtocol 34 | { 35 | Any, 36 | IPv4, 37 | IPv6 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/IRegisterService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IRegisterService.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf 32 | { 33 | public interface IRegisterService : IService, IDisposable 34 | { 35 | event RegisterServiceEventHandler Response; 36 | 37 | void Register(); 38 | 39 | new string Name { get; set; } 40 | new string RegType { get; set; } 41 | new string ReplyDomain { get; set; } 42 | 43 | short Port { get; set; } 44 | ushort UPort { get; set; } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/IResolvableService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IResolvableService.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Net; 31 | 32 | namespace Mono.Zeroconf 33 | { 34 | public interface IResolvableService : IService 35 | { 36 | event ServiceResolvedEventHandler Resolved; 37 | 38 | void Resolve(); 39 | 40 | string FullName { get; } 41 | IPHostEntry HostEntry { get; } 42 | string HostTarget { get; } 43 | uint NetworkInterface { get; } 44 | AddressProtocol AddressProtocol { get; } 45 | short Port { get; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/IService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IService.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | namespace Mono.Zeroconf 30 | { 31 | public interface IService 32 | { 33 | string Name { get; } 34 | string RegType { get; } 35 | string ReplyDomain { get; } 36 | ITxtRecord TxtRecord { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/IServiceBrowser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IServiceBrowser.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections.Generic; 31 | 32 | namespace Mono.Zeroconf 33 | { 34 | public interface IServiceBrowser : IEnumerable, IDisposable 35 | { 36 | event ServiceBrowseEventHandler ServiceAdded; 37 | event ServiceBrowseEventHandler ServiceRemoved; 38 | 39 | void Browse (uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/ITxtRecord.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ITxtRecord.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections; 31 | 32 | namespace Mono.Zeroconf 33 | { 34 | public interface ITxtRecord : IEnumerable, IDisposable 35 | { 36 | void Add(string key, string value); 37 | void Add(string key, byte [] value); 38 | void Add(TxtRecordItem item); 39 | 40 | void Remove(string key); 41 | 42 | TxtRecordItem GetItemAt(int index); 43 | 44 | TxtRecordItem this[string key] { get; } 45 | int Count { get; } 46 | 47 | ITxtRecord BaseRecord { get; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/RegisterService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RegisterService.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using Mono.Zeroconf.Providers; 31 | 32 | namespace Mono.Zeroconf 33 | { 34 | public class RegisterService : IRegisterService 35 | { 36 | private IRegisterService register_service; 37 | 38 | public RegisterService() 39 | { 40 | register_service = (IRegisterService)Activator.CreateInstance( 41 | ProviderFactory.SelectedProvider.RegisterService); 42 | } 43 | 44 | public void Register() 45 | { 46 | register_service.Register(); 47 | } 48 | 49 | public void Dispose() 50 | { 51 | register_service.Dispose(); 52 | } 53 | 54 | public event RegisterServiceEventHandler Response { 55 | add { register_service.Response += value; } 56 | remove { register_service.Response -= value; } 57 | } 58 | 59 | public string Name { 60 | get { return register_service.Name; } 61 | set { register_service.Name = value; } 62 | } 63 | 64 | public string RegType { 65 | get { return register_service.RegType; } 66 | set { register_service.RegType = value; } 67 | } 68 | 69 | public string ReplyDomain { 70 | get { return register_service.ReplyDomain; } 71 | set { register_service.ReplyDomain = value; } 72 | } 73 | 74 | public ITxtRecord TxtRecord { 75 | get { return register_service.TxtRecord; } 76 | set { register_service.TxtRecord = value; } 77 | } 78 | 79 | public short Port { 80 | get { return register_service.Port; } 81 | set { register_service.Port = value; } 82 | } 83 | 84 | public ushort UPort { 85 | get { return register_service.UPort; } 86 | set { register_service.UPort = value; } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/RegisterServiceEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RegisterServiceEventArgs.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf 32 | { 33 | public class RegisterServiceEventArgs : EventArgs 34 | { 35 | private IRegisterService service; 36 | private bool is_registered; 37 | private ServiceErrorCode error; 38 | 39 | public RegisterServiceEventArgs() 40 | { 41 | } 42 | 43 | public RegisterServiceEventArgs(IRegisterService service, bool isRegistered, ServiceErrorCode error) 44 | { 45 | this.service = service; 46 | this.is_registered = isRegistered; 47 | this.error = error; 48 | } 49 | 50 | public IRegisterService Service { 51 | get { return service; } 52 | set { service = value; } 53 | } 54 | 55 | public bool IsRegistered { 56 | get { return is_registered; } 57 | set { is_registered = value; } 58 | } 59 | 60 | public ServiceErrorCode ServiceError { 61 | get { return error; } 62 | set { error = value; } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/RegisterServiceEventHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RegisterServiceEventHandler.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf 32 | { 33 | public delegate void RegisterServiceEventHandler(object o, RegisterServiceEventArgs args); 34 | } 35 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/ServiceBrowseEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IServiceBrowser.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf 32 | { 33 | public class ServiceBrowseEventArgs : EventArgs 34 | { 35 | private IResolvableService service; 36 | 37 | public ServiceBrowseEventArgs(IResolvableService service) 38 | { 39 | this.service = service; 40 | } 41 | 42 | public IResolvableService Service { 43 | get { return service; } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/ServiceBrowseEventHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IServiceBrowser.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | namespace Mono.Zeroconf 30 | { 31 | public delegate void ServiceBrowseEventHandler(object o, ServiceBrowseEventArgs args); 32 | } 33 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/ServiceBrowser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceBrowser.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections.Generic; 31 | using Mono.Zeroconf.Providers; 32 | 33 | namespace Mono.Zeroconf 34 | { 35 | public class ServiceBrowser : IServiceBrowser 36 | { 37 | private IServiceBrowser browser; 38 | 39 | public ServiceBrowser () 40 | { 41 | browser = (IServiceBrowser)Activator.CreateInstance (ProviderFactory.SelectedProvider.ServiceBrowser); 42 | } 43 | 44 | public void Dispose () 45 | { 46 | browser.Dispose (); 47 | } 48 | 49 | public void Browse (uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain) 50 | { 51 | browser.Browse (interfaceIndex, addressProtocol, regtype, domain ?? "local"); 52 | } 53 | 54 | public void Browse (uint interfaceIndex, string regtype, string domain) 55 | { 56 | Browse (interfaceIndex, AddressProtocol.Any, regtype, domain); 57 | } 58 | 59 | public void Browse (AddressProtocol addressProtocol, string regtype, string domain) 60 | { 61 | Browse (0, addressProtocol, regtype, domain); 62 | } 63 | 64 | public void Browse (string regtype, string domain) 65 | { 66 | Browse (0, AddressProtocol.Any, regtype, domain); 67 | } 68 | 69 | public IEnumerator GetEnumerator () 70 | { 71 | return browser.GetEnumerator (); 72 | } 73 | 74 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () 75 | { 76 | return browser.GetEnumerator (); 77 | } 78 | 79 | public event ServiceBrowseEventHandler ServiceAdded { 80 | add { browser.ServiceAdded += value; } 81 | remove { browser.ServiceRemoved -= value; } 82 | } 83 | 84 | public event ServiceBrowseEventHandler ServiceRemoved { 85 | add { browser.ServiceRemoved += value; } 86 | remove { browser.ServiceRemoved -= value; } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/ServiceErrorCode.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceErrorCode.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | namespace Mono.Zeroconf 30 | { 31 | // These are just copied from Bonjour 32 | 33 | public enum ServiceErrorCode { 34 | None = 0, 35 | Unknown = -65537, /* 0xFFFE FFFF */ 36 | NoSuchName = -65538, 37 | NoMemory = -65539, 38 | BadParam = -65540, 39 | BadReference = -65541, 40 | BadState = -65542, 41 | BadFlags = -65543, 42 | Unsupported = -65544, 43 | NotInitialized = -65545, 44 | AlreadyRegistered = -65547, 45 | NameConflict = -65548, 46 | Invalid = -65549, 47 | Firewall = -65550, 48 | Incompatible = -65551, /* client library incompatible with daemon */ 49 | BadInterfaceIndex = -65552, 50 | Refused = -65553, 51 | NoSuchRecord = -65554, 52 | NoAuth = -65555, 53 | NoSuchKey = -65556, 54 | NATTraversal = -65557, 55 | DoubleNAT = -65558, 56 | BadTime = -65559 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/ServiceResolvedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceResolvedEventArgs.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | 31 | namespace Mono.Zeroconf 32 | { 33 | public class ServiceResolvedEventArgs : EventArgs 34 | { 35 | private IResolvableService service; 36 | 37 | public ServiceResolvedEventArgs(IResolvableService service) 38 | { 39 | this.service = service; 40 | } 41 | 42 | public IResolvableService Service { 43 | get { return service; } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/ServiceResolvedEventHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceResolvedEventHandler.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | namespace Mono.Zeroconf 30 | { 31 | public delegate void ServiceResolvedEventHandler(object o, ServiceResolvedEventArgs args); 32 | } 33 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/TxtRecord.cs: -------------------------------------------------------------------------------- 1 | // 2 | // TxtRecord.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections; 31 | using Mono.Zeroconf.Providers; 32 | 33 | namespace Mono.Zeroconf 34 | { 35 | public class TxtRecord : ITxtRecord 36 | { 37 | private ITxtRecord record; 38 | 39 | public TxtRecord() 40 | { 41 | record = (ITxtRecord)Activator.CreateInstance(ProviderFactory.SelectedProvider.TxtRecord); 42 | } 43 | 44 | public void Add(string key, string value) 45 | { 46 | record.Add(key, value); 47 | } 48 | 49 | public void Add(string key, byte [] value) 50 | { 51 | record.Add(key, value); 52 | } 53 | 54 | public void Add(TxtRecordItem item) 55 | { 56 | record.Add(item); 57 | } 58 | 59 | public void Remove(string key) 60 | { 61 | record.Remove(key); 62 | } 63 | 64 | public TxtRecordItem GetItemAt(int index) 65 | { 66 | return record.GetItemAt(index); 67 | } 68 | 69 | public IEnumerator GetEnumerator() 70 | { 71 | return record.GetEnumerator(); 72 | } 73 | 74 | public void Dispose() 75 | { 76 | record.Dispose(); 77 | } 78 | 79 | public TxtRecordItem this[string index] { 80 | get { return record[index]; } 81 | } 82 | 83 | public int Count { 84 | get { return record.Count; } 85 | } 86 | 87 | public ITxtRecord BaseRecord { 88 | get { return record; } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/Mono.Zeroconf/Mono.Zeroconf/TxtRecordItem.cs: -------------------------------------------------------------------------------- 1 | // 2 | // TxtRecordItem.cs 3 | // 4 | // Authors: 5 | // Aaron Bockover 6 | // 7 | // Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Text; 31 | 32 | namespace Mono.Zeroconf 33 | { 34 | public class TxtRecordItem 35 | { 36 | private string key; 37 | private byte [] value_raw; 38 | private string value_string; 39 | 40 | private static readonly Encoding encoding = new UTF8Encoding(); 41 | 42 | public TxtRecordItem(string key, byte [] valueRaw) 43 | { 44 | this.key = key; 45 | ValueRaw = valueRaw; 46 | } 47 | 48 | public TxtRecordItem(string key, string valueString) 49 | { 50 | this.key = key; 51 | ValueString = valueString; 52 | } 53 | 54 | public override string ToString() 55 | { 56 | return String.Format("{0} = {1}", Key, ValueString); 57 | } 58 | 59 | public string Key { 60 | get { return key; } 61 | } 62 | 63 | public byte [] ValueRaw { 64 | get { return value_raw; } 65 | set { value_raw = value; } 66 | } 67 | 68 | public string ValueString { 69 | get { 70 | if(value_string != null) { 71 | return value_string; 72 | } 73 | 74 | value_string = encoding.GetString(value_raw); 75 | return value_string; 76 | } 77 | 78 | set { 79 | value_string = value; 80 | value_raw = encoding.GetBytes(value); 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/mono-zeroconf.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=${prefix} 3 | libdir=@libdir@ 4 | 5 | Name: Mono.Zeroconf 6 | Description: Mono library for universal cross platform Zeroconf support via a unified API with built in support for mdnsd and optional support for Avahi. 7 | Version: @VERSION@ 8 | Requires: 9 | Libs: -r:${libdir}/mono/mono-zeroconf/Mono.Zeroconf.dll 10 | 11 | -------------------------------------------------------------------------------- /src/mono-zeroconf.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono/Mono.Zeroconf/0ac393e168483dc7f5b3005dee2ede95f6b346fc/src/mono-zeroconf.snk -------------------------------------------------------------------------------- /src/policy.config.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | --------------------------------------------------------------------------------