Ejemplo n.º 1
0
 public static extern DNSServiceErrorType DNSServiceQueryRecord(out IntPtr sdRef,
                                                                DNSServiceFlags flags,
                                                                UInt32 interfaceIndex,
                                                                [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] String fullname,
                                                                DNSServiceType rrType,
                                                                DNSServiceClass rrClass,
                                                                DNSServiceQueryReply callBack,
                                                                IntPtr context);
Ejemplo n.º 2
0
        /// <summary>
        /// Called with the result of the call to DNSServiceQueryRecord() in the IPLookup() method.
        ///
        /// If this object instance is configured with an <see cref="DNSService.InvokeableObject">InvokeableObject</see>,
        /// this method is called in a thread safe manner. Typically, this means it's called on the application main loop.
        /// </summary>
        /// <param name="sdRef">
        ///		The DNSServiceRef initialized by DNSServiceQueryRecord().
        /// </param>
        /// <param name="flags">
        ///		Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd.
        ///		The Add flag is NOT set for PTR records with a ttl of 0, i.e. "Remove" events.
        /// </param>
        /// <param name="interfaceIndex">
        ///		The interface on which the query was resolved.
        /// </param>
        /// <param name="errorCode">
        ///		Will be NoError on success, otherwise will indicate the failure that occurred.
        ///		Other parameters are undefined if errorCode is nonzero.
        /// </param>
        /// <param name="fullname">
        ///		The resource record's full domain name.
        /// </param>
        /// <param name="rrType">
        ///		The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
        /// </param>
        /// <param name="rrClass">
        ///		The class of the resource record (usually kDNSServiceClass_IN).
        /// </param>
        /// <param name="rdLength">
        ///		The length, in bytes, of the resource record rdata.
        /// </param>
        /// <param name="rData">
        ///		The raw rdata of the resource record.
        /// </param>
        /// <param name="ttl">
        ///		The resource record's time to live, in seconds.
        /// </param>
        /// <param name="context">
        ///		The context pointer that was passed to the callout.
        /// </param>
        private void IPLookupReply(IntPtr sdRef,
                                   DNSServiceFlags flags,
                                   UInt32 interfaceIndex,
                                   DNSServiceErrorType errorCode,
                                   String fullname,
                                   DNSServiceType rrType,
                                   DNSServiceClass rrClass,
                                   UInt16 rdLength,
                                   byte[] rData,
                                   UInt32 ttl,
                                   IntPtr context)
        {
            if (errorCode == DNSServiceErrorType.NoError)
            {
                if ((flags & DNSServiceFlags.Add) > 0)
                {
                    System.Net.IPAddress  addr = new System.Net.IPAddress(rData);
                    System.Net.IPEndPoint ep   = new System.Net.IPEndPoint(addr, mPort);
                    mAddresses.Add(ep);
                }

                if ((flags & DNSServiceFlags.MoreComing) == 0)
                {
                    Stop();
                    if (DidResolveService != null)
                    {
                        DidResolveService(this);
                    }
                }
            }
            else
            {
                Stop();
                if (DidNotResolveService != null)
                {
                    DNSServiceException exception = new DNSServiceException("DNSServiceQueryRecord", errorCode);
                    DidNotResolveService(this, exception);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called with the result of the call to DNSServiceQueryRecord() in the StartMonitoring() method.
        ///
        /// If this object instance is configured with an <see cref="DNSService.InvokeableObject">InvokeableObject</see>,
        /// this method is called in a thread safe manner. Typically, this means it's called on the application main loop.
        /// </summary>
        /// <param name="sdRef">
        ///		The DNSServiceRef initialized by DNSServiceQueryRecord().
        /// </param>
        /// <param name="flags">
        ///		Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd.
        ///		The Add flag is NOT set for PTR records with a ttl of 0, i.e. "Remove" events.
        /// </param>
        /// <param name="interfaceIndex">
        ///		The interface on which the query was resolved.
        /// </param>
        /// <param name="errorCode">
        ///		Will be NoError on success, otherwise will indicate the failure that occurred.
        ///		Other parameters are undefined if errorCode is nonzero.
        /// </param>
        /// <param name="fullname">
        ///		The resource record's full domain name.
        /// </param>
        /// <param name="rrType">
        ///		The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
        /// </param>
        /// <param name="rrClass">
        ///		The class of the resource record (usually kDNSServiceClass_IN).
        /// </param>
        /// <param name="rdLength">
        ///		The length, in bytes, of the resource record rdata.
        /// </param>
        /// <param name="rData">
        ///		The raw rdata of the resource record.
        /// </param>
        /// <param name="ttl">
        ///		The resource record's time to live, in seconds.
        /// </param>
        /// <param name="context">
        ///		The context pointer that was passed to the callout.
        /// </param>
        private void QueryReply(IntPtr sdRef,
                                DNSServiceFlags flags,
                                UInt32 interfaceIndex,
                                DNSServiceErrorType errorCode,
                                String fullname,
                                DNSServiceType rrType,
                                DNSServiceClass rrClass,
                                UInt16 rdLength,
                                byte[] rData,
                                UInt32 ttl,
                                IntPtr context)
        {
            if (errorCode == DNSServiceErrorType.NoError)
            {
                mTXTRecordData = rData;

                if (DidUpdateTXT != null)
                {
                    DidUpdateTXT(this);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called with the result of the call to DNSServiceQueryRecord() in the StartMonitoring() method.
        /// 
        /// If this object instance is configured with an <see cref="DNSService.InvokeableObject">InvokeableObject</see>,
        /// this method is called in a thread safe manner. Typically, this means it's called on the application main loop.
        /// </summary>
        /// <param name="sdRef">
        ///		The DNSServiceRef initialized by DNSServiceQueryRecord().
        /// </param>
        /// <param name="flags">
        ///		Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd.
        ///		The Add flag is NOT set for PTR records with a ttl of 0, i.e. "Remove" events.
        /// </param>
        /// <param name="interfaceIndex">
        ///		The interface on which the query was resolved.
        /// </param>
        /// <param name="errorCode">
        ///		Will be NoError on success, otherwise will indicate the failure that occurred.
        ///		Other parameters are undefined if errorCode is nonzero.
        /// </param>
        /// <param name="fullname">
        ///		The resource record's full domain name.
        /// </param>
        /// <param name="rrType">
        ///		The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
        /// </param>
        /// <param name="rrClass">
        ///		The class of the resource record (usually kDNSServiceClass_IN).
        /// </param>
        /// <param name="rdLength">
        ///		The length, in bytes, of the resource record rdata.
        /// </param>
        /// <param name="rData">
        ///		The raw rdata of the resource record.
        /// </param>
        /// <param name="ttl">
        ///		The resource record's time to live, in seconds.
        /// </param>
        /// <param name="context">
        ///		The context pointer that was passed to the callout.
        /// </param>
        private void QueryReply(IntPtr sdRef,
		               DNSServiceFlags flags,
		                        UInt32 interfaceIndex,
		           DNSServiceErrorType errorCode,
		                        String fullname,
		                DNSServiceType rrType,
		               DNSServiceClass rrClass,
		                        UInt16 rdLength,
		                        byte[] rData,
		                        UInt32 ttl,
		                        IntPtr context)
        {
            if (errorCode == DNSServiceErrorType.NoError)
            {
                mTXTRecordData = rData;

                if (DidUpdateTXT != null)
                {
                    DidUpdateTXT(this);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called with the result of the call to DNSServiceQueryRecord() in the IPLookup() method.
        /// 
        /// If this object instance is configured with an <see cref="DNSService.InvokeableObject">InvokeableObject</see>,
        /// this method is called in a thread safe manner. Typically, this means it's called on the application main loop.
        /// </summary>
        /// <param name="sdRef">
        ///		The DNSServiceRef initialized by DNSServiceQueryRecord().
        /// </param>
        /// <param name="flags">
        ///		Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd.
        ///		The Add flag is NOT set for PTR records with a ttl of 0, i.e. "Remove" events.
        /// </param>
        /// <param name="interfaceIndex">
        ///		The interface on which the query was resolved.
        /// </param>
        /// <param name="errorCode">
        ///		Will be NoError on success, otherwise will indicate the failure that occurred.
        ///		Other parameters are undefined if errorCode is nonzero.
        /// </param>
        /// <param name="fullname">
        ///		The resource record's full domain name.
        /// </param>
        /// <param name="rrType">
        ///		The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
        /// </param>
        /// <param name="rrClass">
        ///		The class of the resource record (usually kDNSServiceClass_IN).
        /// </param>
        /// <param name="rdLength">
        ///		The length, in bytes, of the resource record rdata.
        /// </param>
        /// <param name="rData">
        ///		The raw rdata of the resource record.
        /// </param>
        /// <param name="ttl">
        ///		The resource record's time to live, in seconds.
        /// </param>
        /// <param name="context">
        ///		The context pointer that was passed to the callout.
        /// </param>
        private void IPLookupReply(IntPtr sdRef,
		                  DNSServiceFlags flags,
		                           UInt32 interfaceIndex,
		              DNSServiceErrorType errorCode,
		                           String fullname,
		                   DNSServiceType rrType,
		                  DNSServiceClass rrClass,
		                           UInt16 rdLength,
		                           byte[] rData,
		                           UInt32 ttl,
		                           IntPtr context)
        {
            if (errorCode == DNSServiceErrorType.NoError)
            {
                if((flags & DNSServiceFlags.Add) > 0)
                {
                    System.Net.IPAddress addr = new System.Net.IPAddress(rData);
                    System.Net.IPEndPoint ep = new System.Net.IPEndPoint(addr, mPort);
                    mAddresses.Add(ep);
                }

                if ((flags & DNSServiceFlags.MoreComing) == 0)
                {
                    Stop();
                    if (DidResolveService != null)
                    {
                        DidResolveService(this);
                    }
                }
            }
            else
            {
                Stop();
                if (DidNotResolveService != null)
                {
                    DNSServiceException exception = new DNSServiceException("DNSServiceQueryRecord", errorCode);
                    DidNotResolveService(this, exception);
                }
            }
        }