+ def _build_mac_mask(dst_mac='', src_mac='', ether_type=''):
+ """Build MAC ACL mask data in hexstring format.
+
+ :param dst_mac: Source MAC address <0-ffffffffffff>.
+ :param src_mac: Destination MAC address <0-ffffffffffff>.
+ :param ether_type: Ethernet type <0-ffff>.
+ :type dst_mac: str
+ :type src_mac: str
+ :type ether_type: str
+ :returns MAC ACL mask in hexstring format.
+ :rtype: str
+ """
+
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac.replace(':', ''), src_mac.replace(':', ''),
+ ether_type)).decode('hex').rstrip('\0')
+
+ @staticmethod
+ def _build_ip_mask(proto='', src_ip='', dst_ip='', src_port='',
+ dst_port=''):
+ """Build IP ACL mask data in hexstring format.
+
+ :param proto: Protocol number <0-ff>.
+ :param src_ip: Source ip address <0-ffffffff>.
+ :param dst_ip: Destination ip address <0-ffffffff>.
+ :param src_port: Source port number <0-ffff>.
+ :param str dst_port: Destination port number <0-ffff>.
+ :type proto: str
+ :type src_ip: str
+ :type dst_ip: str
+ :type src_port: str
+ :type dst_port:src
+ :returns: IP mask in hexstring format.
+ :rtype: str
+ """
+
+ return ('{!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s:0>4}'.format(
+ proto, src_ip, dst_ip, src_port, dst_port)).decode('hex').\
+ rstrip('\0')
+
+ @staticmethod
+ def _build_ip6_mask(next_hdr='', src_ip='', dst_ip='', src_port='',
+ dst_port=''):
+ """Build IPv6 ACL mask data in hexstring format.
+
+ :param next_hdr: Next header number <0-ff>.
+ :param src_ip: Source ip address <0-ffffffff>.
+ :param dst_ip: Destination ip address <0-ffffffff>.
+ :param src_port: Source port number <0-ffff>.
+ :param dst_port: Destination port number <0-ffff>.
+ :type next_hdr: str
+ :type src_ip: str
+ :type dst_ip: str
+ :type src_port: str
+ :type dst_port: str
+ :returns: IPv6 ACL mask in hexstring format.
+ :rtype: str
+ """
+
+ return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format(
+ next_hdr, src_ip, dst_ip, src_port, dst_port)).decode('hex').\
+ rstrip('\0')
+
+ @staticmethod
+ def _build_mac_match(dst_mac='', src_mac='', ether_type=''):
+ """Build MAC ACL match data in hexstring format.
+
+ :param dst_mac: Source MAC address <x:x:x:x:x:x>.
+ :param src_mac: Destination MAC address <x:x:x:x:x:x>.
+ :param ether_type: Ethernet type <0-ffff>.
+ :type dst_mac: str
+ :type src_mac: str
+ :type ether_type: str
+ :returns: MAC ACL match data in hexstring format.
+ :rtype: str
+ """
+
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac.replace(':', ''), src_mac.replace(':', ''),
+ ether_type)).decode('hex').rstrip('\0')
+
+ @staticmethod
+ def _build_ip_match(proto=0, src_ip='', dst_ip='', src_port=0, dst_port=0):
+ """Build IP ACL match data in byte-string format.
+
+ :param proto: Protocol number with valid option "x".
+ :param src_ip: Source ip address in packed format.
+ :param dst_ip: Destination ip address in packed format.
+ :param src_port: Source port number "x".
+ :param dst_port: Destination port number "x".
+ :type proto: int
+ :type src_ip: str
+ :type dst_ip: str
+ :type src_port: int
+ :type dst_port: int
+ :returns: IP ACL match data in byte-string format.
+ :rtype: str
+ """
+
+ return ('{!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s:0>4}'.format(
+ hex(proto)[2:], src_ip, dst_ip, hex(src_port)[2:],
+ hex(dst_port)[2:])).decode('hex').rstrip('\0')
+
+ @staticmethod
+ def _build_ip6_match(next_hdr=0, src_ip='', dst_ip='', src_port=0,
+ dst_port=0):
+ """Build IPv6 ACL match data in byte-string format.
+
+ :param next_hdr: Next header number with valid option "x".
+ :param src_ip: Source ip6 address in packed format.
+ :param dst_ip: Destination ip6 address in packed format.
+ :param src_port: Source port number "x".
+ :param dst_port: Destination port number "x".
+ :type next_hdr: int
+ :type src_ip: str
+ :type dst_ip: str
+ :type src_port: int
+ :type dst_port: int
+ :returns: IPv6 ACL match data in byte-string format.
+ :rtype: str
+ """
+
+ return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format(
+ hex(next_hdr)[2:], src_ip, dst_ip, hex(src_port)[2:],
+ hex(dst_port)[2:])).decode('hex').rstrip('\0')
+
+ @staticmethod
+ def _classify_add_del_table(
+ node, is_add, mask, match_n_vectors=Constants.BITWISE_NON_ZERO,
+ table_index=Constants.BITWISE_NON_ZERO, nbuckets=2,
+ memory_size=2097152, skip_n_vectors=Constants.BITWISE_NON_ZERO,
+ next_table_index=Constants.BITWISE_NON_ZERO,
+ miss_next_index=Constants.BITWISE_NON_ZERO,
+ current_data_flag=0, current_data_offset=0):
+ """Add or delete a classify table.