def generate_lsu(self): for i in self.router.ospf_interfaces: #TODO p = scapy_ospf.Ether( src=ROUTER_CP_INTERFACE.get("mac"), dst=i.mac) / IP( src=i.ip_address, dst=i.neighbor_ip) / scapy_ospf.OSPF_Hdr( src=ROUTER_ID, area=AREA_ID) / scapy_ospf.OSPF_LSUpd() log("LSU generated") for k in self.router.ospf_interfaces: if k is not i: if k.mask == "24": temp_mask = "255.255.255.0" else: temp_mask = mask p[scapy_ospf.OSPF_LSUpd].lsalist.append( scapy_ospf.OSPF_Network_LSA( id=k.subnet, adrouter=self.router.router_id, mask=temp_mask)) log("LSA Appended") for router in self.database: for lsa in router["lsa"]: if lsa["mask"] == "24": temp_mask = "255.255.255.0" else: temp_mask = lsa["mask"] p[scapy_ospf.OSPF_LSUpd].lsalist.append( scapy_ospf.OSPF_Network_LSA(id=lsa["link_id"], adrouter=lsa["router_id"], mask=temp_mask)) log("LSA Appended") p.show() sendp(p, iface=i.name) log("LSU sent")
def generate_hello(self): #TODO for i in self.router.ospf_interfaces: log("Interface = {}".format(i)) log("Generating Hello with ip dest = {}".format(i.neighbor_ip)) p = scapy_ospf.Ether(src = ROUTER_CP_INTERFACE.get("mac"), dst = i.mac)/IP(src = i.ip_address, dst = i.neighbor_ip)/scapy_ospf.OSPF_Hdr(src=ROUTER_ID,area=AREA_ID)/scapy_ospf.OSPF_Hello(hellointerval=HELLOINT, deadinterval=NEIGHBOR_TIMEOUT) log("Hello generated") p.show() sendp(p, iface=i.name) log("Hello sent")