summaryrefslogtreecommitdiffstats
path: root/Demo/dns/dnsopcode.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-10-08 19:30:50 (GMT)
committerGuido van Rossum <guido@python.org>1994-10-08 19:30:50 (GMT)
commit705d517e3f4df74b8c04edf54ac73b087c982f32 (patch)
tree7b0543f1165fc1bdfc4717277f67d8e699dcbeb4 /Demo/dns/dnsopcode.py
parent3dc44aba71305cd9be8cba7703a96b6528f34169 (diff)
downloadcpython-705d517e3f4df74b8c04edf54ac73b087c982f32.zip
cpython-705d517e3f4df74b8c04edf54ac73b087c982f32.tar.gz
cpython-705d517e3f4df74b8c04edf54ac73b087c982f32.tar.bz2
initial checkin
Diffstat (limited to 'Demo/dns/dnsopcode.py')
-rwxr-xr-xDemo/dns/dnsopcode.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Demo/dns/dnsopcode.py b/Demo/dns/dnsopcode.py
new file mode 100755
index 0000000..f2e7cd5
--- /dev/null
+++ b/Demo/dns/dnsopcode.py
@@ -0,0 +1,16 @@
+# Opcode values in message header (section 4.1.1)
+
+QUERY = 0
+IQUERY = 1
+STATUS = 2
+
+# Construct reverse mapping dictionary
+
+_names = dir()
+opcodemap = {}
+for _name in _names:
+ if _name[0] != '_': opcodemap[eval(_name)] = _name
+
+def opcodestr(opcode):
+ if opcodemap.has_key(opcode): return opcodemap[opcode]
+ else: return `opcode`