1 # Copyright (C) 2006, 2007, 2009, 2010 Nominum, Inc.
3 # Permission to use, copy, modify, and distribute this software and its
4 # documentation for any purpose with or without fee is hereby granted,
5 # provided that the above copyright notice and this permission notice
6 # appear in all copies.
8 # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 class DHCID(dns
.rdata
.Rdata
):
21 @ivar data: the data (the content of the RR is opaque as far as the
28 def __init__(self
, rdclass
, rdtype
, data
):
29 super(DHCID
, self
).__init
__(rdclass
, rdtype
)
32 def to_text(self
, origin
=None, relativize
=True, **kw
):
33 return dns
.rdata
._base
64ify
(self
.data
)
35 def from_text(cls
, rdclass
, rdtype
, tok
, origin
= None, relativize
= True):
38 t
= tok
.get().unescape()
41 if not t
.is_identifier():
42 raise dns
.exception
.SyntaxError
43 chunks
.append(t
.value
)
45 data
= b64
.decode('base64_codec')
46 return cls(rdclass
, rdtype
, data
)
48 from_text
= classmethod(from_text
)
50 def to_wire(self
, file, compress
= None, origin
= None):
53 def from_wire(cls
, rdclass
, rdtype
, wire
, current
, rdlen
, origin
= None):
54 data
= wire
[current
: current
+ rdlen
]
55 return cls(rdclass
, rdtype
, data
)
57 from_wire
= classmethod(from_wire
)
59 def _cmp(self
, other
):
60 return cmp(self
.data
, other
.data
)