openc2lib.types.data.ipv6_net

IPv6 Address

    This module implements an IPv6 Address as described in Sec. 3.4.2.9.

The usage of the ipaddress module is compliant to what required in the language specification for IPv6 addresses, especially the following points: a) The IPv6 address should be available both in string and binary form b) The network representation is an array according to RFC 4291 Sec. 2.3 (host/prefix, host/mask, host/hostmask, etc.)

 1""" IPv6 Address
 2
 3	This module implements an IPv6 Address as described in Sec. 3.4.2.9.
 4
 5The usage of the ipaddress module is compliant to what required in the
 6language specification for IPv6 addresses, especially the following points:
 7a) The IPv6 address should be available both in string and binary form
 8b) The network representation is an array according to RFC 4291 Sec. 2.3
 9   (host/prefix, host/mask, host/hostmask, etc.)
10"""
11
12import ipaddress
13
14class IPv6Addr:
15	"""OpenC2 IPv6 Address"
16
17		This class implements an IPv6 Address as described in Sec. 3.4.2.9.
18
19		The usage of the ipaddress module is compliant to what required in the
20		language specification for IPv6 addresses, especially the following points:
21		a) The IPv6 address should be available both in string and binary form
22		b) The network representation is an array according to RFC 4291 Sec. 2.3
23		   (host/prefix, host/mask, host/hostmask, etc.)
24
25"""
26	__ipv6_addr = ipaddress.IPv6Address("::")
27	""" Internal representation of the IPv6 address"""
28	
29	def __init__(self, ipaddr=None):
30		""" Initialize IPv6 Address 
31
32			An IPv6 address is built from a string that uses the common dotted notation.
33			If no IPv6 address is provided, the null address is used ("::").
34
35			:param ipaddr: Quad-dotted representation of the IPv6 address.
36		"""
37		if ipaddr == None:
38			self.__ipv6_addr = ipaddress.IPv6Address("::")
39		else:
40			self.__ipv6_addr = ipaddress.IPv6Address(ipaddr)
41
42	def __str__(self):
43		return self.__ipv6_addr.exploded
44
45	def __repr__(self):
46		return self.__ipv6_addr.exploded
class IPv6Addr:
15class IPv6Addr:
16	"""OpenC2 IPv6 Address"
17
18		This class implements an IPv6 Address as described in Sec. 3.4.2.9.
19
20		The usage of the ipaddress module is compliant to what required in the
21		language specification for IPv6 addresses, especially the following points:
22		a) The IPv6 address should be available both in string and binary form
23		b) The network representation is an array according to RFC 4291 Sec. 2.3
24		   (host/prefix, host/mask, host/hostmask, etc.)
25
26"""
27	__ipv6_addr = ipaddress.IPv6Address("::")
28	""" Internal representation of the IPv6 address"""
29	
30	def __init__(self, ipaddr=None):
31		""" Initialize IPv6 Address 
32
33			An IPv6 address is built from a string that uses the common dotted notation.
34			If no IPv6 address is provided, the null address is used ("::").
35
36			:param ipaddr: Quad-dotted representation of the IPv6 address.
37		"""
38		if ipaddr == None:
39			self.__ipv6_addr = ipaddress.IPv6Address("::")
40		else:
41			self.__ipv6_addr = ipaddress.IPv6Address(ipaddr)
42
43	def __str__(self):
44		return self.__ipv6_addr.exploded
45
46	def __repr__(self):
47		return self.__ipv6_addr.exploded

OpenC2 IPv6 Address"

This class implements an IPv6 Address as described in Sec. 3.4.2.9.

The usage of the ipaddress module is compliant to what required in the language specification for IPv6 addresses, especially the following points: a) The IPv6 address should be available both in string and binary form b) The network representation is an array according to RFC 4291 Sec. 2.3 (host/prefix, host/mask, host/hostmask, etc.)

IPv6Addr(ipaddr=None)
30	def __init__(self, ipaddr=None):
31		""" Initialize IPv6 Address 
32
33			An IPv6 address is built from a string that uses the common dotted notation.
34			If no IPv6 address is provided, the null address is used ("::").
35
36			:param ipaddr: Quad-dotted representation of the IPv6 address.
37		"""
38		if ipaddr == None:
39			self.__ipv6_addr = ipaddress.IPv6Address("::")
40		else:
41			self.__ipv6_addr = ipaddress.IPv6Address(ipaddr)

Initialize IPv6 Address

An IPv6 address is built from a string that uses the common dotted notation. If no IPv6 address is provided, the null address is used ("::").

Parameters
  • ipaddr: Quad-dotted representation of the IPv6 address.