]>
git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.recursor-dnssec/extendederrors.py
10 class ExtendedErrorOption(dns
.edns
.Option
):
11 """Implementation of rfc8914
14 def __init__(self
, code
, extra
):
15 super(ExtendedErrorOption
, self
).__init
__(15)
20 def to_wire(self
, file=None):
21 """Create EDNS packet."""
23 data
= struct
.pack('!H', self
.code
)
24 data
= data
+ self
.extra
30 def from_wire(cls
, otype
, wire
, current
, olen
):
34 An instance of ExtendedErrorOption based on the EDNS packet
38 raise Exception('Invalid EDNS Extended Error option')
40 (code
,) = struct
.unpack('!H', wire
[current
:current
+2])
42 extra
= wire
[current
+ 2:current
+ olen
]
46 return cls(code
, extra
)
48 from_wire
= classmethod(from_wire
)
52 def from_wire_parser(cls
, otype
, parser
):
53 data
= parser
.get_remaining()
56 raise Exception('Invalid EDNS Extended Error option')
58 (code
,) = struct
.unpack('!H', data
[0:2])
64 return cls(code
, extra
)
67 return '%s(%d, %s)' % (
68 self
.__class
__.__name
__,
74 return self
.__repr
__()
76 def __eq__(self
, other
):
77 if not isinstance(other
, ExtendedErrorOption
):
79 if self
.code
!= other
.code
:
81 if self
.extra
!= other
.extra
:
85 def __ne__(self
, other
):
86 return not self
.__eq
__(other
)
89 dns
.edns
._type
_to
_class
[0x000F] = ExtendedErrorOption