Introduce more logging levels
This commit is contained in:
parent
481675372d
commit
253353daf5
1 changed files with 11 additions and 5 deletions
|
@ -241,7 +241,6 @@ class L2Controller(object):
|
||||||
dst_addr = pkg[IPv6].src
|
dst_addr = pkg[IPv6].src
|
||||||
src_addr = pkg[ICMPv6ND_NS].tgt
|
src_addr = pkg[ICMPv6ND_NS].tgt
|
||||||
|
|
||||||
|
|
||||||
e = Ether(src=src_mac, dst=dst_mac)
|
e = Ether(src=src_mac, dst=dst_mac)
|
||||||
i = IPv6(src=src_addr, dst=dst_addr)
|
i = IPv6(src=src_addr, dst=dst_addr)
|
||||||
|
|
||||||
|
@ -249,12 +248,13 @@ class L2Controller(object):
|
||||||
i2 = ICMPv6ND_NA(S=1, tgt=src_addr)
|
i2 = ICMPv6ND_NA(S=1, tgt=src_addr)
|
||||||
i3 = ICMPv6NDOptSrcLLAddr(lladdr=src_mac)
|
i3 = ICMPv6NDOptSrcLLAddr(lladdr=src_mac)
|
||||||
|
|
||||||
self.debug_print_pkg(answer, "OUTGOING")
|
|
||||||
answer = e / i / i2 / i3
|
answer = e / i / i2 / i3
|
||||||
|
self.send_pkg(answer)
|
||||||
|
|
||||||
|
def send_pkg(self, pkg):
|
||||||
|
self.debug_print_pkg(pkg, "OUTGOING")
|
||||||
sendp(answer, iface=self.intf, verbose=False)
|
sendp(answer, iface=self.intf, verbose=False)
|
||||||
|
|
||||||
|
|
||||||
def recv_msg_cpu(self, pkg):
|
def recv_msg_cpu(self, pkg):
|
||||||
packet = Ether(str(pkg))
|
packet = Ether(str(pkg))
|
||||||
|
|
||||||
|
@ -275,10 +275,10 @@ class L2Controller(object):
|
||||||
if cpu_header.task == self.task['DEBUG']:
|
if cpu_header.task == self.task['DEBUG']:
|
||||||
log.debug("Debug purpose only")
|
log.debug("Debug purpose only")
|
||||||
elif cpu_header.task == self.task['ICMP6_NS']:
|
elif cpu_header.task == self.task['ICMP6_NS']:
|
||||||
log.debug("Doing neighbor solicitation")
|
log.info("Doing neighbor solicitation")
|
||||||
self.handle_icmp6_ns(orig_packet)
|
self.handle_icmp6_ns(orig_packet)
|
||||||
elif cpu_header.task == self.task['ICMP6_GENERAL']:
|
elif cpu_header.task == self.task['ICMP6_GENERAL']:
|
||||||
log.debug("Replying to ICMP packet")
|
log.info("Replying to ICMP packet")
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -292,6 +292,7 @@ class L2Controller(object):
|
||||||
parser = argparse.ArgumentParser(description='controller++')
|
parser = argparse.ArgumentParser(description='controller++')
|
||||||
parser.add_argument('--mode', help='Select mode / settings to use', choices=self.modes)
|
parser.add_argument('--mode', help='Select mode / settings to use', choices=self.modes)
|
||||||
parser.add_argument('--debug', help='Enable debug logging', action='store_true')
|
parser.add_argument('--debug', help='Enable debug logging', action='store_true')
|
||||||
|
parser.add_argument('--verbose', help='Enable verbose logging', action='store_true')
|
||||||
parser.add_argument('--multicast-to-controller', help='Send debug multicast to controller', action='store_true')
|
parser.add_argument('--multicast-to-controller', help='Send debug multicast to controller', action='store_true')
|
||||||
|
|
||||||
self.args = parser.parse_args()
|
self.args = parser.parse_args()
|
||||||
|
@ -316,5 +317,10 @@ if __name__ == "__main__":
|
||||||
controller.commandline()
|
controller.commandline()
|
||||||
if controller.args.debug:
|
if controller.args.debug:
|
||||||
log.setLevel(logging.DEBUG)
|
log.setLevel(logging.DEBUG)
|
||||||
|
elif controller.args.verbose:
|
||||||
|
log.setLevel(logging.INFO)
|
||||||
|
else:
|
||||||
|
log.setLevel(logging.WARNING)
|
||||||
|
|
||||||
controller.config()
|
controller.config()
|
||||||
controller.run_cpu_port_loop()
|
controller.run_cpu_port_loop()
|
||||||
|
|
Loading…
Reference in a new issue