def p_interface_line_2(p): '''interface_line : SET INTERFACE object_name opt_tag ZONE object_name''' if re.match(r'.*/.*\..*', p[3]): nameif = p[3].split('.') interface = p_info['firewall'].get_interface_by_nameif(nameif[0]) if not interface: interface = Interface(nameif[0], None, None, []) p_info['firewall'].interfaces.append(interface) sub_if = interface.get_subif_by_nameif(p[3]) if sub_if: sub_if.name = p[6] else: sub_if = Interface(p[3], None, p[6], []) interface.sub_interfaces.append(sub_if) if p[4]: sub_if.attributes['tag'] = p[4] else: interface = p_info['firewall'].get_interface_by_nameif(p[3]) if interface: interface.name = p[6] else: interface = Interface(p[3], None, p[6], []) p_info['firewall'].interfaces.append(interface) if p[4]: interface.attributes['tag'] = p[4]
def p_interface_line_1(p): '''interface_line : SET INTERFACE object_name IP IP_ADDR SLASH NUMBER | SET INTERFACE object_name IP IP_ADDR SLASH NUMBER SECONDARY''' # detect sub-interface if re.match(r'.*/.*\..*', p[3]): nameif = p[3].split('.') interface = p_info['firewall'].get_interface_by_nameif(nameif[0]) if not interface: interface = Interface(nameif[0], None, None, []) p_info['firewall'].interfaces.append(interface) sub_if = interface.get_subif_by_nameif(p[3]) if sub_if: sub_if.network = Ip(p[5], Ip.CidrToMask(int(p[7]))) else: interface.sub_interfaces.append(Interface(p[3], Ip(p[5], Ip.CidrToMask(int(p[7]))), None, [])) else: interface = p_info['firewall'].get_interface_by_nameif(p[3]) if interface: interface.network = Ip(p[5], Ip.CidrToMask(int(p[7]))) else: p_info['firewall'].interfaces.append(Interface(p[3], Ip(p[5], Ip.CidrToMask(int(p[7]))), None, []))
def p_interface_line_1(p): '''interface_line : SET INTERFACE object_name IP IP_ADDR SLASH NUMBER | SET INTERFACE object_name IP IP_ADDR SLASH NUMBER SECONDARY''' # detect sub-interface if re.match(r'.*/.*\..*', p[3]): nameif = p[3].split('.') interface = p_info['firewall'].get_interface_by_nameif(nameif[0]) if not interface: interface = Interface(nameif[0], None, None, []) p_info['firewall'].interfaces.append(interface) sub_if = interface.get_subif_by_nameif(p[3]) if sub_if: sub_if.network = Ip(p[5], Ip.CidrToMask(int(p[7]))) else: interface.sub_interfaces.append( Interface(p[3], Ip(p[5], Ip.CidrToMask(int(p[7]))), None, [])) else: interface = p_info['firewall'].get_interface_by_nameif(p[3]) if interface: interface.network = Ip(p[5], Ip.CidrToMask(int(p[7]))) else: p_info['firewall'].interfaces.append( Interface(p[3], Ip(p[5], Ip.CidrToMask(int(p[7]))), None, []))