# Path: capirca/lib/iptables.py
# class Term(aclgenerator.Term):
# class Iptables(aclgenerator.ACLGenerator):
# class Error(Exception):
# class BadPortsError(Error):
# class UnsupportedFilterError(Error):
# class NoIptablesPolicyError(Error):
# class TcpEstablishedError(Error):
# class EstablishedError(Error):
# class UnsupportedDefaultActionError(Error):
# class UnsupportedTargetOptionError(Error):
# class LimitButNoLogError(Error):
#   _PLATFORM = 'iptables'
#   _POSTJUMP_FORMAT = None
#   _PREJUMP_FORMAT = Template('-A $filter -j $term')
#   _TERM_FORMAT = Template('-N $term')
#   _COMMENT_FORMAT = Template('-A $term -m comment --comment "$comment"')
#   _FILTER_TOP_FORMAT = Template('-A $term')
#   _LOG_FORMAT = Template('-j LOG --log-prefix $term')
#   _PROTO_TABLE = {
#       'icmpv6': '-p ipv6-icmp',
#       'icmp': '-p icmp',
#       'tcp': '-p tcp',
#       'udp': '-p udp',
#       'all': '-p all',
#       'esp': '-p esp',
#       'ah': '-p ah',
#       'gre': '-p gre',
#       }
#   _TCP_FLAGS_TABLE = {
#       'syn': 'SYN',
#       'ack': 'ACK',
#       'fin': 'FIN',
#       'rst': 'RST',
#       'urg': 'URG',
#       'psh': 'PSH',
#       'all': 'ALL',
#       'none': 'NONE',
#       }
#   _KNOWN_OPTIONS_MATCHERS = {
#       # '! -f' also matches non-fragmented packets.
#       'first-fragment': '-m u32 --u32 4&0x3FFF=0x2000',
#       'initial': '--syn',
#       'tcp-initial': '--syn',
#       'sample': '',
#       }
#   _PLATFORM = 'iptables'
#   _DEFAULT_PROTOCOL = 'all'
#   SUFFIX = ''
#   _RENDER_PREFIX = None
#   _RENDER_SUFFIX = None
#   _DEFAULTACTION_FORMAT = '-P %s %s'
#   _DEFAULTACTION_FORMAT_CUSTOM_CHAIN = '-N %s'
#   _DEFAULT_ACTION = 'DROP'
#   _TERM = Term
#   _TERM_MAX_LENGTH = 24
#   _GOOD_FILTERS = ['INPUT', 'OUTPUT', 'FORWARD']
#   _GOOD_OPTIONS = ['nostate', 'abbreviateterms', 'truncateterms', 'noverbose']
#   def __init__(self, term, filter_name, trackstate, filter_action, af='inet',
#                verbose=True):
#   def __str__(self):
#   def _CalculateAddresses(self, term_saddr, exclude_saddr,
#                           term_daddr, exclude_daddr):
#   def _FormatPart(self, protocol, saddr, sport, daddr, dport, options,
#                   tcp_flags, icmp_type, code, track_flags, sint, dint, log_hits,
#                   action):
#   def _GenerateAddressStatement(self, saddr, daddr):
#   def _GeneratePortStatement(self, ports, source=False, dest=False):
#   def _SetDefaultAction(self):
#   def __init__(self, pol, exp_info):
#   def _BuildTokens(self):
#   def _WarnIfCustomTarget(self, target):
#   def _TranslatePolicy(self, pol, exp_info):
#   def SetTarget(self, target, action=None):
#   def __str__(self):


from string import Template
from capirca.lib import iptables
# Copyright 2011 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# unless required by applicable law or agreed to in writing, software
# 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.
#


"""Speedway iptables generator.  This is a subclass of Iptables lib."""



class Error(Exception):
  pass


class Term(iptables.Term):
  """Generate Iptables policy terms."""
  _PLATFORM = 'speedway'
  _PREJUMP_FORMAT = None
  _POSTJUMP_FORMAT = Template('-A $filter -j $term')



# Path: capirca/lib/iptables.py
# class Term(aclgenerator.Term):
# class Iptables(aclgenerator.ACLGenerator):
# class Error(Exception):
# class BadPortsError(Error):
# class UnsupportedFilterError(Error):
# class NoIptablesPolicyError(Error):
# class TcpEstablishedError(Error):
# class EstablishedError(Error):
# class UnsupportedDefaultActionError(Error):
# class UnsupportedTargetOptionError(Error):
# class LimitButNoLogError(Error):
#   _PLATFORM = 'iptables'
#   _POSTJUMP_FORMAT = None
#   _PREJUMP_FORMAT = Template('-A $filter -j $term')
#   _TERM_FORMAT = Template('-N $term')
#   _COMMENT_FORMAT = Template('-A $term -m comment --comment "$comment"')
#   _FILTER_TOP_FORMAT = Template('-A $term')
#   _LOG_FORMAT = Template('-j LOG --log-prefix $term')
#   _PROTO_TABLE = {
#       'icmpv6': '-p ipv6-icmp',
#       'icmp': '-p icmp',
#       'tcp': '-p tcp',
#       'udp': '-p udp',
#       'all': '-p all',
#       'esp': '-p esp',
#       'ah': '-p ah',
#       'gre': '-p gre',
#       }
#   _TCP_FLAGS_TABLE = {
#       'syn': 'SYN',
#       'ack': 'ACK',
#       'fin': 'FIN',
#       'rst': 'RST',
#       'urg': 'URG',
#       'psh': 'PSH',
#       'all': 'ALL',
#       'none': 'NONE',
#       }
#   _KNOWN_OPTIONS_MATCHERS = {
#       # '! -f' also matches non-fragmented packets.
#       'first-fragment': '-m u32 --u32 4&0x3FFF=0x2000',
#       'initial': '--syn',
#       'tcp-initial': '--syn',
#       'sample': '',
#       }
#   _PLATFORM = 'iptables'
#   _DEFAULT_PROTOCOL = 'all'
#   SUFFIX = ''
#   _RENDER_PREFIX = None
#   _RENDER_SUFFIX = None
#   _DEFAULTACTION_FORMAT = '-P %s %s'
#   _DEFAULTACTION_FORMAT_CUSTOM_CHAIN = '-N %s'
#   _DEFAULT_ACTION = 'DROP'
#   _TERM = Term
#   _TERM_MAX_LENGTH = 24
#   _GOOD_FILTERS = ['INPUT', 'OUTPUT', 'FORWARD']
#   _GOOD_OPTIONS = ['nostate', 'abbreviateterms', 'truncateterms', 'noverbose']
#   def __init__(self, term, filter_name, trackstate, filter_action, af='inet',
#                verbose=True):
#   def __str__(self):
#   def _CalculateAddresses(self, term_saddr, exclude_saddr,
#                           term_daddr, exclude_daddr):
#   def _FormatPart(self, protocol, saddr, sport, daddr, dport, options,
#                   tcp_flags, icmp_type, code, track_flags, sint, dint, log_hits,
#                   action):
#   def _GenerateAddressStatement(self, saddr, daddr):
#   def _GeneratePortStatement(self, ports, source=False, dest=False):
#   def _SetDefaultAction(self):
#   def __init__(self, pol, exp_info):
#   def _BuildTokens(self):
#   def _WarnIfCustomTarget(self, target):
#   def _TranslatePolicy(self, pol, exp_info):
#   def SetTarget(self, target, action=None):
#   def __str__(self):


# Path: capirca/lib/speedway.py
from string import Template
from capirca.lib import iptables

# Copyright 2011 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# unless required by applicable law or agreed to in writing, software
# 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.
#


"""Speedway iptables generator.  This is a subclass of Iptables lib."""



class Error(Exception):
  pass


class Term(iptables.Term):
  """Generate Iptables policy terms."""
  _PLATFORM = 'speedway'
  _PREJUMP_FORMAT = None
  _POSTJUMP_FORMAT = Template('-A $filter -j $term')



class Speedway(iptables.Iptables):