addrlen = int(math.ceil(src/8.0))
if family == 1:
- af = dns.inet.AF_INET
pad = 4 - addrlen
+ addr = dns.ipv4.inet_ntoa(wire[cur:cur+addrlen] + b'\x00' * pad)
elif family == 2:
- af = dns.inet.AF_INET6
pad = 16 - addrlen
+ addr = dns.ipv6.inet_ntoa(wire[cur:cur+addrlen] + b'\x00' * pad)
else:
raise ValueError('unsupported family')
- addr = dns.inet.inet_ntop(af, wire[cur:cur+addrlen] + b'\x00' * pad)
return cls(addr, src, scope)
def _cmp(self, other):
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import dns.exception
-import dns.inet
+import dns.ipv6
import dns.rdata
import dns.tokenizer
def __init__(self, rdclass, rdtype, address):
super().__init__(rdclass, rdtype)
# check that it's OK
- dns.inet.inet_pton(dns.inet.AF_INET6, address)
+ dns.ipv6.inet_aton(address)
object.__setattr__(self, 'address', address)
def to_text(self, origin=None, relativize=True, **kw):
return cls(rdclass, rdtype, address)
def to_wire(self, file, compress=None, origin=None):
- file.write(dns.inet.inet_pton(dns.inet.AF_INET6, self.address))
+ file.write(dns.ipv6.inet_aton(self.address))
@classmethod
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
- address = dns.inet.inet_ntop(dns.inet.AF_INET6,
- wire[current: current + rdlen])
+ address = dns.ipv6.inet_ntoa(wire[current: current + rdlen])
return cls(rdclass, rdtype, address)
import struct
import dns.exception
-import dns.inet
+import dns.ipv4
+import dns.ipv6
import dns.rdata
import dns.tokenizer
def to_wire(self, file):
if self.family == 1:
- address = dns.inet.inet_pton(dns.inet.AF_INET, self.address)
+ address = dns.ipv4.inet_aton(self.address)
elif self.family == 2:
- address = dns.inet.inet_pton(dns.inet.AF_INET6, self.address)
+ address = dns.ipv6.inet_aton(self.address)
else:
address = binascii.unhexlify(self.address)
#
if header[0] == 1:
if l < 4:
address += b'\x00' * (4 - l)
- address = dns.inet.inet_ntop(dns.inet.AF_INET, address)
+ address = dns.ipv4.inet_ntoa(address)
elif header[0] == 2:
if l < 16:
address += b'\x00' * (16 - l)
- address = dns.inet.inet_ntop(dns.inet.AF_INET6, address)
+ address = dns.ipv6.inet_ntoa(address)
else:
#
# This isn't really right according to the RFC, but it
import base64
import dns.exception
-import dns.inet
+import dns.ipv4
+import dns.ipv6
import dns.name
gateway = None
elif gateway_type == 1:
# check that it's OK
- dns.inet.inet_pton(dns.inet.AF_INET, gateway)
+ dns.ipv4.inet_aton(gateway)
elif gateway_type == 2:
# check that it's OK
- dns.inet.inet_pton(dns.inet.AF_INET6, gateway)
+ dns.ipv6.inet_aton(gateway)
elif gateway_type == 3:
pass
else:
if self.gateway_type == 0:
pass
elif self.gateway_type == 1:
- file.write(dns.inet.inet_pton(dns.inet.AF_INET, self.gateway))
+ file.write(dns.ipv4.inet_aton(self.gateway))
elif self.gateway_type == 2:
- file.write(dns.inet.inet_pton(dns.inet.AF_INET6, self.gateway))
+ file.write(dns.ipv6.inet_aton(self.gateway))
elif self.gateway_type == 3:
self.gateway.to_wire(file, None, origin)
else:
if gateway_type == 0:
gateway = None
elif gateway_type == 1:
- gateway = dns.inet.inet_ntop(dns.inet.AF_INET,
- wire[current: current + 4])
+ gateway = dns.ipv4.inet_ntoa(wire[current: current + 4])
current += 4
rdlen -= 4
elif gateway_type == 2:
- gateway = dns.inet.inet_ntop(dns.inet.AF_INET6,
- wire[current: current + 16])
+ gateway = dns.ipv6.inet_ntoa(wire[current: current + 16])
current += 16
rdlen -= 16
elif gateway_type == 3: