summaryrefslogtreecommitdiff
path: root/dns/inet.py
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2007-06-13 16:00:14 +0000
committerBob Halley <halley@dnspython.org>2007-06-13 16:00:14 +0000
commitf26fb84cd3b158ffb48021a5be889fed2937d9a7 (patch)
treea655df4dc2c19bc1ba985ebad6e6c667899d0d73 /dns/inet.py
parent0b3fa60e0575b1e39c8543d31d6fa2a4798fe89d (diff)
downloaddnspython-f26fb84cd3b158ffb48021a5be889fed2937d9a7.tar.gz
add basic multicast support
Diffstat (limited to 'dns/inet.py')
-rw-r--r--dns/inet.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/dns/inet.py b/dns/inet.py
index 1470925..67bd614 100644
--- a/dns/inet.py
+++ b/dns/inet.py
@@ -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
+