summaryrefslogtreecommitdiff
path: root/project2/proj2_s4498062/dns/rcodes.py
diff options
context:
space:
mode:
authorCamil Staps2016-04-14 20:07:12 +0200
committerCamil Staps2016-04-14 20:07:12 +0200
commit872e11deb29e87eddcfaca76d555acc16e329653 (patch)
tree00aa2aec0b5a4e6874d6de7c0f9a6bf860bf1e11 /project2/proj2_s4498062/dns/rcodes.py
parentFix LaTeX warning (diff)
Added project2 framework
Diffstat (limited to 'project2/proj2_s4498062/dns/rcodes.py')
-rw-r--r--project2/proj2_s4498062/dns/rcodes.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/project2/proj2_s4498062/dns/rcodes.py b/project2/proj2_s4498062/dns/rcodes.py
new file mode 100644
index 0000000..d1b8c15
--- /dev/null
+++ b/project2/proj2_s4498062/dns/rcodes.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python2
+
+""" DNS RCODE values
+
+This module contains an Enum of RCODE values. See section 4.1.4 of RFC 1035 for
+more info.
+"""
+
+class RCode(object):
+ """ Enum of RCODE values
+
+ Usage:
+ >>> NoError
+ 0
+ >>> NXDomain
+ 3
+ """
+
+ NoError = 0
+ FormErr = 1
+ ServFail = 2
+ NXDomain = 3
+ NotImp = 4
+ Refused = 5
+ YXDomain = 6
+ YXRRSet = 7
+ NXRRSet = 8
+ NotAuth = 9
+ NotZone = 10
+ BADVERS = 16
+ BADSIG = 16
+ BADKEY = 17
+ BADTIME = 18
+ BADMODE = 19
+ BADNAME = 20
+ BADALG = 21
+ BADTRUNC = 22
+
+ by_string = {
+ "NoError": NoError,
+ "FormErr": FormErr,
+ "ServFail": ServFail,
+ "NXDomain": NXDomain,
+ "NotImp": NotImp,
+ "Refused": Refused,
+ "YXDomain": YXDomain,
+ "YXRRSet": YXRRSet,
+ "NXRRSet": NXRRSet,
+ "NotAuth": NotAuth,
+ "NotZone": NotZone,
+ "BADVERS": BADVERS,
+ "BADSIG": BADSIG,
+ "BADKEY": BADKEY,
+ "BADTIME": BADTIME,
+ "BADMODE": BADMODE,
+ "BADNAME": BADNAME,
+ "BADALG": BADALG,
+ "BADTRUNC": BADTRUNC
+ }
+
+ by_value = dict([(y, x) for x, y in by_string.items()])
+
+ @staticmethod
+ def to_string(rcode):
+ return RCode.by_value[rcode]
+
+ @staticmethod
+ def from_string(string):
+ return RCode.by_string[string]