summaryrefslogtreecommitdiffstats
path: root/Demo/dns/dnsopcode.py
blob: f2e7cd5b0a64ff03e8b7c4394fcf7c3413118005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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`