Commit 9290b913 authored by Pedro Oliveira's avatar Pedro Oliveira

Fix some minor issues

parent b5bd0d28
...@@ -378,7 +378,3 @@ class Kernel: ...@@ -378,7 +378,3 @@ class Kernel:
pass pass
...@@ -50,34 +50,6 @@ def remove_interface(interface_name, pim=False, igmp=False): ...@@ -50,34 +50,6 @@ def remove_interface(interface_name, pim=False, igmp=False):
print(igmp_interfaces) print(igmp_interfaces)
"""
def add_neighbor(contact_interface, ip, random_number, hello_hold_time):
global neighbors
with neighbors_lock:
if ip not in neighbors:
print("ADD NEIGHBOR")
n = Neighbor(contact_interface, ip, random_number, hello_hold_time)
neighbors[ip] = n
protocols[0].force_send(contact_interface)
# todo check neighbor in interface
contact_interface.neighbors[ip] = n
def get_neighbor(ip) -> Neighbor:
global neighbors
with neighbors_lock:
if ip not in neighbors:
return None
return neighbors[ip]
def remove_neighbor(ip):
global neighbors
with neighbors_lock:
if ip in neighbors:
del neighbors[ip]
print("removido neighbor")
"""
def add_protocol(protocol_number, protocol_obj): def add_protocol(protocol_number, protocol_obj):
global protocols global protocols
protocols[protocol_number] = protocol_obj protocols[protocol_number] = protocol_obj
......
...@@ -72,7 +72,6 @@ class Neighbor: ...@@ -72,7 +72,6 @@ class Neighbor:
#Main.remove_neighbor(self.ip) #Main.remove_neighbor(self.ip)
interface_name = self.contact_interface.interface_name interface_name = self.contact_interface.interface_name
neighbor_ip = self.ip neighbor_ip = self.ip
Main.kernel.neighbor_removed(interface_name, neighbor_ip)
del self.contact_interface.neighbors[self.ip] del self.contact_interface.neighbors[self.ip]
......
...@@ -57,25 +57,25 @@ class MyDaemon(Daemon): ...@@ -57,25 +57,25 @@ class MyDaemon(Daemon):
print(sys.stderr, 'sending data back to the client') print(sys.stderr, 'sending data back to the client')
print(pickle.loads(data)) print(pickle.loads(data))
args = pickle.loads(data) args = pickle.loads(data)
if args.list_interfaces: if 'list_interfaces' in args and args.list_interfaces:
connection.sendall(pickle.dumps(Main.list_enabled_interfaces())) connection.sendall(pickle.dumps(Main.list_enabled_interfaces()))
elif args.list_neighbors: elif 'list_neighbors' in args and args.list_neighbors:
connection.sendall(pickle.dumps(Main.list_neighbors())) connection.sendall(pickle.dumps(Main.list_neighbors()))
elif args.list_state: elif 'list_state' in args and args.list_state:
connection.sendall(pickle.dumps(Main.list_state())) connection.sendall(pickle.dumps(Main.list_state()))
elif args.add_interface: elif 'add_interface' in args and args.add_interface:
Main.add_interface(args.add_interface[0], pim=True) Main.add_interface(args.add_interface[0], pim=True)
connection.shutdown(socket.SHUT_RDWR) connection.shutdown(socket.SHUT_RDWR)
elif args.add_interface_igmp: elif 'add_interface_igmp' in args and args.add_interface_igmp:
Main.add_interface(args.add_interface_igmp[0], igmp=True) Main.add_interface(args.add_interface_igmp[0], igmp=True)
connection.shutdown(socket.SHUT_RDWR) connection.shutdown(socket.SHUT_RDWR)
elif args.remove_interface: elif 'remove_interface' in args and args.remove_interface:
Main.remove_interface(args.remove_interface[0], pim=True) Main.remove_interface(args.remove_interface[0], pim=True)
connection.shutdown(socket.SHUT_RDWR) connection.shutdown(socket.SHUT_RDWR)
elif args.remove_interface_igmp: elif 'remove_interface_igmp' in args and args.remove_interface_igmp:
Main.remove_interface(args.remove_interface_igmp[0], igmp=True) Main.remove_interface(args.remove_interface_igmp[0], igmp=True)
connection.shutdown(socket.SHUT_RDWR) connection.shutdown(socket.SHUT_RDWR)
elif args.stop: elif 'stop' in args and args.stop:
Main.stop() Main.stop()
connection.shutdown(socket.SHUT_RDWR) connection.shutdown(socket.SHUT_RDWR)
except Exception: except Exception:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment