Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.destination_tag.append(x.value)
elif x.var_type is VarType.FLEXIBLE_MATCH_RANGE:
self.flexible_match_range.append(x.value)
else:
raise TermObjectTypeError(
'%s isn\'t a type I know how to deal with (contains \'%s\')' % (
type(x), x.value))
else:
# stupid no switch statement in python
if obj.var_type is VarType.COMMENT:
self.comment.append(str(obj))
elif obj.var_type is VarType.OWNER:
self.owner = obj.value
elif obj.var_type is VarType.EXPIRATION:
self.expiration = obj.value
elif obj.var_type is VarType.LOSS_PRIORITY:
self.loss_priority = obj.value
elif obj.var_type is VarType.ROUTING_INSTANCE:
self.routing_instance = obj.value
elif obj.var_type is VarType.PRECEDENCE:
self.precedence = obj.value
elif obj.var_type is VarType.FORWARDING_CLASS:
self.forwarding_class.append(obj.value)
elif obj.var_type is VarType.FORWARDING_CLASS_EXCEPT:
self.forwarding_class_except.append(obj.value)
elif obj.var_type is VarType.PAN_APPLICATION:
self.pan_application.append(obj.value)
elif obj.var_type is VarType.NEXT_IP:
self.next_ip = DEFINITIONS.GetNetAddr(obj.value)
elif obj.var_type is VarType.VERBATIM:
self.verbatim.append(obj.value)
elif obj.var_type is VarType.ACTION:
elif x.var_type is VarType.PORT:
self.port.append(x.value)
elif x.var_type is VarType.SPORT:
self.source_port.append(x.value)
elif x.var_type is VarType.DPORT:
self.destination_port.append(x.value)
# do we have a list of protocols?
elif x.var_type is VarType.PROTOCOL:
self.protocol.append(x.value)
# do we have a list of protocol-exceptions?
elif x.var_type is VarType.PROTOCOL_EXCEPT:
self.protocol_except.append(x.value)
# do we have a list of options?
elif x.var_type is VarType.OPTION:
self.option.append(x.value)
elif x.var_type is VarType.SPFX:
self.source_prefix.append(x.value)
elif x.var_type is VarType.ESPFX:
self.source_prefix_except.append(x.value)
elif x.var_type is VarType.DPFX:
self.destination_prefix.append(x.value)
elif x.var_type is VarType.EDPFX:
self.destination_prefix_except.append(x.value)
elif x.var_type is VarType.ETHER_TYPE:
self.ether_type.append(x.value)
elif x.var_type is VarType.TRAFFIC_TYPE:
self.traffic_type.append(x.value)
elif x.var_type is VarType.PRECEDENCE:
self.precedence.append(x.value)
elif x.var_type is VarType.FORWARDING_CLASS:
self.forwarding_class.append(x.value)
elif x.var_type is VarType.FORWARDING_CLASS_EXCEPT:
def p_losspriority_spec(p):
""" losspriority_spec : LOSS_PRIORITY ':' ':' STRING """
p[0] = VarType(VarType.LOSS_PRIORITY, p[4])
def p_fragment_offset_spec(p):
""" fragment_offset_spec : FRAGMENT_OFFSET ':' ':' INTEGER
| FRAGMENT_OFFSET ':' ':' INTEGER '-' INTEGER """
if len(p) == 5:
p[0] = VarType(VarType.FRAGMENT_OFFSET, str(p[4]))
else:
p[0] = VarType(VarType.FRAGMENT_OFFSET, str(p[4]) + '-' + str(p[6]))
self.log_limit = obj.value
elif obj.var_type is VarType.LOG_NAME:
self.log_name = obj.value
# police man, tryin'a take you jail
elif obj.var_type is VarType.POLICER:
self.policer = obj.value
elif obj.var_type is VarType.PRIORITY:
self.priority = obj.value
# qos?
elif obj.var_type is VarType.QOS:
self.qos = obj.value
elif obj.var_type is VarType.PACKET_LEN:
self.packet_length = obj.value
elif obj.var_type is VarType.FRAGMENT_OFFSET:
self.fragment_offset = obj.value
elif obj.var_type is VarType.HOP_LIMIT:
self.hop_limit = obj.value
elif obj.var_type is VarType.SINTERFACE:
self.source_interface = obj.value
elif obj.var_type is VarType.DINTERFACE:
self.destination_interface = obj.value
elif obj.var_type is VarType.TIMEOUT:
self.timeout = obj.value
elif obj.var_type is VarType.DSCP_SET:
self.dscp_set = obj.value
elif obj.var_type is VarType.VPN:
self.vpn = (obj.value[0], obj.value[1])
elif obj.var_type is VarType.TTL:
self.ttl = int(obj.value)
else:
raise TermObjectTypeError(
'%s isn\'t a type I know how to deal with' % (type(obj)))
def p_losspriority_spec(p):
""" losspriority_spec : LOSS_PRIORITY ':' ':' STRING """
p[0] = VarType(VarType.LOSS_PRIORITY, p[4])
self.traffic_class_count = obj
elif obj.var_type is VarType.ICMP_TYPE:
self.icmp_type.extend(obj.value)
elif obj.var_type is VarType.ICMP_CODE:
self.icmp_code.extend(obj.value)
elif obj.var_type is VarType.LOGGING:
if str(obj) not in _LOGGING:
raise InvalidTermLoggingError('%s is not a valid logging option' %
obj)
self.logging.append(obj)
elif obj.var_type is VarType.LOG_LIMIT:
self.log_limit = obj.value
elif obj.var_type is VarType.LOG_NAME:
self.log_name = obj.value
# police man, tryin'a take you jail
elif obj.var_type is VarType.POLICER:
self.policer = obj.value
elif obj.var_type is VarType.PRIORITY:
self.priority = obj.value
# qos?
elif obj.var_type is VarType.QOS:
self.qos = obj.value
elif obj.var_type is VarType.PACKET_LEN:
self.packet_length = obj.value
elif obj.var_type is VarType.FRAGMENT_OFFSET:
self.fragment_offset = obj.value
elif obj.var_type is VarType.HOP_LIMIT:
self.hop_limit = obj.value
elif obj.var_type is VarType.SINTERFACE:
self.source_interface = obj.value
elif obj.var_type is VarType.DINTERFACE:
self.destination_interface = obj.value
self.precedence = obj.value
elif obj.var_type is VarType.FORWARDING_CLASS:
self.forwarding_class.append(obj.value)
elif obj.var_type is VarType.FORWARDING_CLASS_EXCEPT:
self.forwarding_class_except.append(obj.value)
elif obj.var_type is VarType.PAN_APPLICATION:
self.pan_application.append(obj.value)
elif obj.var_type is VarType.NEXT_IP:
self.next_ip = DEFINITIONS.GetNetAddr(obj.value)
elif obj.var_type is VarType.VERBATIM:
self.verbatim.append(obj.value)
elif obj.var_type is VarType.ACTION:
if str(obj) not in ACTIONS:
raise InvalidTermActionError('%s is not a valid action' % obj)
self.action.append(obj.value)
elif obj.var_type is VarType.COUNTER:
self.counter = obj
elif obj.var_type is VarType.TRAFFIC_CLASS_COUNT:
self.traffic_class_count = obj
elif obj.var_type is VarType.ICMP_TYPE:
self.icmp_type.extend(obj.value)
elif obj.var_type is VarType.ICMP_CODE:
self.icmp_code.extend(obj.value)
elif obj.var_type is VarType.LOGGING:
if str(obj) not in _LOGGING:
raise InvalidTermLoggingError('%s is not a valid logging option' %
obj)
self.logging.append(obj)
elif obj.var_type is VarType.LOG_LIMIT:
self.log_limit = obj.value
elif obj.var_type is VarType.LOG_NAME:
self.log_name = obj.value
def p_platform_spec(p):
""" platform_spec : PLATFORM ':' ':' one_or_more_strings
| PLATFORMEXCLUDE ':' ':' one_or_more_strings """
p[0] = []
for platform in p[4]:
if p[1].find('platform-exclude') >= 0:
p[0].append(VarType(VarType.PLATFORMEXCLUDE, platform))
elif p[1].find('platform') >= 0:
p[0].append(VarType(VarType.PLATFORM, platform))
def p_protocol_spec(p):
""" protocol_spec : PROTOCOL ':' ':' strings_or_ints """
p[0] = []
for proto in p[4]:
p[0].append(VarType(VarType.PROTOCOL, proto))