+class IpDscp(IntEnum):
+ """DSCP code points."""
+ IP_API_DSCP_CS0 = 0
+ IP_API_DSCP_CS1 = 8
+ IP_API_DSCP_AF11 = 10
+ IP_API_DSCP_AF12 = 12
+ IP_API_DSCP_AF13 = 14
+ IP_API_DSCP_CS2 = 16
+ IP_API_DSCP_AF21 = 18
+ IP_API_DSCP_AF22 = 20
+ IP_API_DSCP_AF23 = 22
+ IP_API_DSCP_CS3 = 24
+ IP_API_DSCP_AF31 = 26
+ IP_API_DSCP_AF32 = 28
+ IP_API_DSCP_AF33 = 30
+ IP_API_DSCP_CS4 = 32
+ IP_API_DSCP_AF41 = 34
+ IP_API_DSCP_AF42 = 36
+ IP_API_DSCP_AF43 = 38
+ IP_API_DSCP_CS5 = 40
+ IP_API_DSCP_EF = 46
+ IP_API_DSCP_CS6 = 48
+ IP_API_DSCP_CS7 = 50
+
+
+class NetworkIncrement(ObjIncrement):
+ """
+ An iterator object which accepts an IPv4Network or IPv6Network and
+ returns a new network incremented by the increment each time it's
+ iterated or when inc_fmt is called. The increment may be positive,
+ negative or 0 (in which case the network is always the same).
+ """
+ def __init__(self, initial_value, increment):
+ """
+ :param initial_value: The initial network.
+ :param increment: The current network will be incremented by this
+ amount in each iteration/var_str call.
+ :type initial_value:
+ Union[ipaddress.IPv4Network, ipaddress.IPv6Network].
+ :type increment: int
+ """
+ super().__init__(initial_value, increment)
+ self._prefix_len = self._value.prefixlen
+ host_len = self._value.max_prefixlen - self._prefix_len
+ self._net_increment = self._increment * (1 << host_len)
+
+ def _incr(self):
+ """
+ Increment the network, e.g.:
+ '30.0.0.0/24' incremented by 1 (the next network) is '30.0.1.0/24'.
+ '30.0.0.0/24' incremented by 2 is '30.0.2.0/24'.
+ """
+ self._value = ip_network(
+ f"{self._value.network_address + self._net_increment}"
+ f"/{self._prefix_len}"
+ )
+
+ def _str_fmt(self):
+ """
+ The string representation of the network is
+ '<ip_address_start> - <ip_address_stop>' for the purposes of the
+ 'ipsec policy add spd' cli.
+ """
+ return f"{self._value.network_address} - " \
+ f"{self._value.broadcast_address}"
+
+