All pastes #950948 Raw Edit

Vermischtes

public text v1 · immutable
·published 2008-03-20 22:52 UTC
rendered paste body
===================================================================
--- src/Mono.Zeroconf.Providers.Avahi/Mono.Zeroconf.Providers.Avahi/ResolvableService.cs	(Revision 98696)
+++ src/Mono.Zeroconf.Providers.Avahi/Mono.Zeroconf.Providers.Avahi/ResolvableService.cs	(Arbeitskopie)
@@ -73,6 +73,7 @@
                 IPHostEntry host_entry = new IPHostEntry();
                 host_entry.AddressList = new IPAddress[1];
                 host_entry.AddressList[0] = service.Address;
+                host_entry.AddressList[0].ScopeId = service.NetworkInterface;
                 host_entry.HostName = service.HostName;
                 return host_entry;
             }

Index: src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs
===================================================================
--- src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs	(Revision 98696)
+++ src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs	(Arbeitskopie)
@@ -125,18 +125,25 @@
         {
             switch(rrtype) {
                 case ServiceType.A:
-                    if(rdlen != 4) {
+                    if(rdlen != 4 && rdlen != 16) {
                         break;
                     }
-                    
-                    // ~4.5 times faster than Marshal.Copy into byte[4]
-                    uint address_raw = (uint)(Marshal.ReadByte (rdata, 3) << 24);
-                    address_raw |= (uint)(Marshal.ReadByte (rdata, 2) << 16);
-                    address_raw |= (uint)(Marshal.ReadByte (rdata, 1) << 8);
-                    address_raw |= (uint)Marshal.ReadByte (rdata, 0);
+                    IPAddress address;
 
-                    IPAddress address = new IPAddress(address_raw);
+                    if (rdlen == 4) {
+                        uint address_raw = (uint)(Marshal.ReadByte (rdata, 3) << 24);
+                        address_raw |= (uint)(Marshal.ReadByte (rdata, 2) << 16);
+                        address_raw |= (uint)(Marshal.ReadByte (rdata, 1) << 8);
+                        address_raw |= (uint)Marshal.ReadByte (rdata, 0);
+                        address = new IPAddress(address_raw);
+                        address.ScopeId = interfaceIndex;
+                    } else {
+                        byte[] address_raw = new byte[rdlen];
+                        Marshal.Copy (rdata, address_raw, 0, rdlen);
 
+                        address = new IPAddress(address_raw, interfaceIndex);
+                    }
+
                     if(hostentry == null) {
                         hostentry = new IPHostEntry();
                         hostentry.HostName = hosttarget;