# Path: capirca/lib/juniper.py
# class Error(Exception):
# class JuniperTermPortProtocolError(Error):
# class TcpEstablishedWithNonTcpError(Error):
# class JuniperDuplicateTermError(Error):
# class UnsupportedFilterError(Error):
# class PrecedenceError(Error):
# class JuniperIndentationError(Error):
# class JuniperNextIpError(Error):
# class JuniperMultipleTerminatingActionError(Error):
# class JuniperFragmentInV6Error(Error):
# class Config:
# class Term(aclgenerator.Term):
# class Juniper(aclgenerator.ACLGenerator):
#   def __init__(self, indent=0, tabstop=4):
#   def __str__(self):
#   def Append(self, line, verbatim=False):
#   def __init__(self, term, term_type, enable_dsmo, noverbose):
#   def __str__(self):
#   def NextIpCheck(next_ip, term_name):
#   def CheckTerminatingAction(self):
#   def _MinimizePrefixes(self, include, exclude):
#   def _Comment(self, addr, exclude=False, line_length=132):
#   def _Group(self, group, lc=True):
#     def _FormattedGroup(el, lc=True):
#   def _BuildTokens(self):
#   def _TranslatePolicy(self, pol, exp_info):
#   def __str__(self):
#   _PLATFORM = 'juniper'
#   _DEFAULT_INDENT = 12
#   ACTIONS = {'accept': 'accept',
#              'deny': 'discard',
#              'reject': 'reject',
#              'next': 'next term',
#              'reject-with-tcp-rst': 'reject tcp-reset',
#              'encapsulate': 'encapsulate'}
#   _TERM_TYPE = {'inet': {'addr': 'address',
#                          'saddr': 'source-address',
#                          'daddr': 'destination-address',
#                          'protocol': 'protocol',
#                          'protocol-except': 'protocol-except',
#                          'tcp-est': 'tcp-established'},
#                 'inet6': {'addr': 'address',
#                           'saddr': 'source-address',
#                           'daddr': 'destination-address',
#                           'protocol': 'next-header',
#                           'protocol-except': 'next-header-except',
#                           'tcp-est': 'tcp-established'},
#                 'bridge': {'addr': 'ip-address',
#                            'saddr': 'ip-source-address',
#                            'daddr': 'ip-destination-address',
#                            'protocol': 'ip-protocol',
#                            'protocol-except': 'ip-protocol-except',
#                            'tcp-est': 'tcp-flags "(ack|rst)"'}
#               }
#   _PLATFORM = 'juniper'
#   _DEFAULT_PROTOCOL = 'ip'
#   _SUPPORTED_AF = frozenset(('inet', 'inet6', 'bridge', 'mixed'))
#   _TERM = Term
#   SUFFIX = '.jcl'


from capirca.lib import juniper
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""Juniper SRX generator for loopback ACLs.

This is a subclass of Juniper generator. Juniper SRX loopback filter
uses the same syntax as regular Juniper stateless ACLs, with minor
differences. This subclass effects those differences.
"""



class Term(juniper.Term):
  """Single SRXlo term representation."""

  _PLATFORM = 'srxlo'

  def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self.term.protocol = ['icmp6' if x == 'icmpv6' else x
                          for x in self.term.protocol]

  def NormalizeIcmpTypes(self, icmp_types, protocols, af):
    protocols = ['icmpv6' if x == 'icmp6' else x for x in protocols]
    return super().NormalizeIcmpTypes(icmp_types, protocols, af)



# Path: capirca/lib/juniper.py
# class Error(Exception):
# class JuniperTermPortProtocolError(Error):
# class TcpEstablishedWithNonTcpError(Error):
# class JuniperDuplicateTermError(Error):
# class UnsupportedFilterError(Error):
# class PrecedenceError(Error):
# class JuniperIndentationError(Error):
# class JuniperNextIpError(Error):
# class JuniperMultipleTerminatingActionError(Error):
# class JuniperFragmentInV6Error(Error):
# class Config:
# class Term(aclgenerator.Term):
# class Juniper(aclgenerator.ACLGenerator):
#   def __init__(self, indent=0, tabstop=4):
#   def __str__(self):
#   def Append(self, line, verbatim=False):
#   def __init__(self, term, term_type, enable_dsmo, noverbose):
#   def __str__(self):
#   def NextIpCheck(next_ip, term_name):
#   def CheckTerminatingAction(self):
#   def _MinimizePrefixes(self, include, exclude):
#   def _Comment(self, addr, exclude=False, line_length=132):
#   def _Group(self, group, lc=True):
#     def _FormattedGroup(el, lc=True):
#   def _BuildTokens(self):
#   def _TranslatePolicy(self, pol, exp_info):
#   def __str__(self):
#   _PLATFORM = 'juniper'
#   _DEFAULT_INDENT = 12
#   ACTIONS = {'accept': 'accept',
#              'deny': 'discard',
#              'reject': 'reject',
#              'next': 'next term',
#              'reject-with-tcp-rst': 'reject tcp-reset',
#              'encapsulate': 'encapsulate'}
#   _TERM_TYPE = {'inet': {'addr': 'address',
#                          'saddr': 'source-address',
#                          'daddr': 'destination-address',
#                          'protocol': 'protocol',
#                          'protocol-except': 'protocol-except',
#                          'tcp-est': 'tcp-established'},
#                 'inet6': {'addr': 'address',
#                           'saddr': 'source-address',
#                           'daddr': 'destination-address',
#                           'protocol': 'next-header',
#                           'protocol-except': 'next-header-except',
#                           'tcp-est': 'tcp-established'},
#                 'bridge': {'addr': 'ip-address',
#                            'saddr': 'ip-source-address',
#                            'daddr': 'ip-destination-address',
#                            'protocol': 'ip-protocol',
#                            'protocol-except': 'ip-protocol-except',
#                            'tcp-est': 'tcp-flags "(ack|rst)"'}
#               }
#   _PLATFORM = 'juniper'
#   _DEFAULT_PROTOCOL = 'ip'
#   _SUPPORTED_AF = frozenset(('inet', 'inet6', 'bridge', 'mixed'))
#   _TERM = Term
#   SUFFIX = '.jcl'


# Path: capirca/lib/srxlo.py
from capirca.lib import juniper

# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""Juniper SRX generator for loopback ACLs.

This is a subclass of Juniper generator. Juniper SRX loopback filter
uses the same syntax as regular Juniper stateless ACLs, with minor
differences. This subclass effects those differences.
"""



class Term(juniper.Term):
  """Single SRXlo term representation."""

  _PLATFORM = 'srxlo'

  def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self.term.protocol = ['icmp6' if x == 'icmpv6' else x
                          for x in self.term.protocol]

  def NormalizeIcmpTypes(self, icmp_types, protocols, af):
    protocols = ['icmpv6' if x == 'icmp6' else x for x in protocols]
    return super().NormalizeIcmpTypes(icmp_types, protocols, af)



class SRXlo(juniper.Juniper):