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 parse_ifconfig(self, data): if data[0][len(data[0]) - 1] == ":": tmp = Interface(data[0][:len(data[0]) - 1]) tmp.name = data[0][:len(data[0]) - 1] self.full_data.append(tmp) elif len(data) > 0: if data[0] == "inet": ip_device = None mask = None if len(data) == 6: ip_device = data[1] mask = data[3] elif len(data) == 4: ip_device = data[1] mask = data[3] if ip_device is not None and mask is not None: new_ip = Ip(ip_device, mask) self.full_data[len(self.full_data) - 1].network = new_ip