X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-sharp%2FUtility.cs;h=f8b4ffd8982857d55b65f603f839efb666cfa6fd;hb=2afb248985218ecb5c3b105ff04a986a506b59f9;hp=c621bed30878cecb21a61bafc19abf7c51c95863;hpb=ba12decc4413dedf22c06545d1ec5938efa8954a;p=catta diff --git a/avahi-sharp/Utility.cs b/avahi-sharp/Utility.cs index c621bed..f8b4ffd 100644 --- a/avahi-sharp/Utility.cs +++ b/avahi-sharp/Utility.cs @@ -1,3 +1,24 @@ +/* $Id$ */ + +/*** + This file is part of avahi. + + avahi is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + avahi is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with avahi; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + using System; using System.Net; using System.Text; @@ -15,6 +36,9 @@ namespace Avahi [DllImport ("avahi-common")] private static extern IntPtr avahi_address_snprint (IntPtr buf, int size, IntPtr address); + [DllImport ("avahi-common")] + private static extern IntPtr avahi_address_parse (IntPtr str, Protocol proto, IntPtr ret); + public static string PtrToString (IntPtr ptr) { if (ptr == IntPtr.Zero) @@ -53,6 +77,16 @@ namespace Avahi Stdlib.free (ptr); } + public static IntPtr AddressToPtr (IPAddress address) + { + IntPtr straddr = Utility.StringToPtr (address.ToString ()); + IntPtr addrPtr = Stdlib.malloc (32); + avahi_address_parse (straddr, Protocol.Unspecified, addrPtr); + Utility.Free (straddr); + + return addrPtr; + } + public static IPAddress PtrToAddress (IntPtr ptr) { IPAddress address = null;