]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add basic multicast support
authorBob Halley <halley@dnspython.org>
Wed, 13 Jun 2007 16:00:14 +0000 (16:00 +0000)
committerBob Halley <halley@dnspython.org>
Wed, 13 Jun 2007 16:00:14 +0000 (16:00 +0000)
ChangeLog
dns/inet.py
dns/query.py

index 62e54fa0ce89bd6c7659cf678de6ff68393794c4..00aeb5d7950cf57e4020309704fee50c47b29da1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-06-13  Bob Halley  <halley@dnspython.org>
+
+       * dns/inet.py: Added is_multicast().
+
+       * dns/query.py (udp):  If the queried address is a multicast address, then
+         don't check that the address of the response is the same as the address
+         queried.
+
 2007-05-24  Bob Halley  <halley@dnspython.org>
 
        * dns/rdtypes/IN/NAPTR.py: NAPTR comparisons didn't compare the
index 1470925208111b80d2a747ab2bd036bcc7755adf..67bd614308b8d18058d722df50adc0e39ab30b5b 100644 (file)
@@ -88,3 +88,21 @@ def af_for_address(text):
             return AF_INET6
         except:
             raise ValueError
+
+def is_multicast(text):
+    """Is the textual-form network address a multicast address?
+
+    @param text: the textual address
+    @raises ValueError: the address family cannot be determined from the input.
+    @rtype: bool
+    """
+    try:
+        first = ord(dns.ipv4.inet_aton(text)[0])
+        return (first >= 224 and first <= 239)
+    except:
+        try:
+            first = ord(dns.ipv6.inet_aton(text)[0])
+            return (first == 255)
+        except:
+            raise ValueError
+    
index f2ff9a1d196edcd0c402d320d4dbb7b57157d07f..785e4230b0a644896bfe2014a79c1705be1dc599 100644 (file)
@@ -117,7 +117,9 @@ def udp(q, where, timeout=None, port=53, af=None, source=None, source_port=0,
         while 1:
             _wait_for_readable(s, expiration)
             (wire, from_address) = s.recvfrom(65535)
-            if from_address == destination:
+            if from_address == destination or \
+               (dns.inet.is_multicast(where) and \
+                from_address[1:] == destination[1:]):
                 break
             if not ignore_unexpected:
                 raise UnexpectedSource, \