def create_schc_protocol(self, rule_manager=None, lower_layer=None, upper_layer=None): if rule_manager is None: if self.rule_manager is None: XXX else: rule_manager = self.rule_manager if lower_layer is None: if self.lower_layer is None: XXX else: lower_layer = self.lower_layer if upper_layer is None: if self.upper_layer is None: XXX else: upper_layer = self.upper_layer schc_protocol = protocol.SCHCProtocol() self.rule_manager = rule_manager self.upper_layer = upper_layer self.lower_layer = lower_layer self.schc_protocol = schc_protocol return self.schc_protocol
def __init__(self, sim, extra_config={}): self.sim = sim self.config = sim.simul_config.get("node-config", {}).copy() self.config.update(extra_config) self.layer2 = SimulLayer2(sim) self.layer3 = SimulLayer3(sim) self.protocol = protocol.SCHCProtocol(self.config, self, self.layer2, self.layer3) self.id = self.layer2.mac_id self.sim._add_node(self)
def __init__(self, sim, extra_config={}, role="undefined"): self.sim = sim self.config = sim.simul_config.get("node-config", {}).copy() # XXX: remove? self.config.update(extra_config) unique_peer = self.config.get("unique-peer", True) # XXX:remove default self.layer2 = SimulLayer2(sim) self.layer3 = SimulLayer3(sim) self.protocol = protocol.SCHCProtocol( self.config, self, self.layer2, self.layer3, role, unique_peer) self.id = self.layer2.mac_id self.sim._add_node(self)
help="specify debug level.") config = ap.parse_args() update_config() # set the logger object. logger = set_logger(logging, config) if not config.debug_level: requests.packages.urllib3.disable_warnings() # create the schc protocol object. rule_manager = RuleManager() rule_manager.Add(device=b"\x00\x11\x22\x33", file=find_file(config.rule_file), compression=True) # loop = asyncio.get_event_loop() if config.debug_level > 1: loop.set_debug(True) system = System(loop, logger=logger, config=config) layer2 = gwLayer2(system, config=config) layer3 = gwLayer3(system, config=config) protocol = protocol.SCHCProtocol(config, system, layer2, layer3, role="core") protocol.set_rulemanager(rule_manager) # ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ctx.load_cert_chain(find_file(config.my_cert)) app = web.Application(loop=loop, debug=True) app.router.add_route("POST", "/ul", app_uplink) app.router.add_route("POST", "/dl", app_downlink) web.run_app(app, host=config.bind_addr, port=config.bind_port, ssl_context=ctx)
help="specify debug level.") config = ap.parse_args() update_config() # set the logger object. logger = set_logger(logging, config) if not config.debug_level: requests.packages.urllib3.disable_warnings() # create the schc protocol object. rule_manager = RuleManager() rule_manager.Add(device=b"\x00\x11\x22\x33", file=find_file(config.rule_file), compression=True) # loop = asyncio.get_event_loop() if config.debug_level > 1: loop.set_debug(True) system = System(loop, logger=logger, config=config) layer2 = gwLayer2(system, config=config) layer3 = gwLayer3(system, config=config) protocol = protocol.SCHCProtocol(config, system, layer2, layer3) protocol.set_rulemanager(rule_manager) # ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ctx.load_cert_chain(find_file(config.my_cert)) app = web.Application(loop=loop, debug=True) app.router.add_route("POST", "/ul", app_uplink) app.router.add_route("POST", "/dl", app_downlink) web.run_app(app, host=config.bind_addr, port=config.bind_port, ssl_context=ctx)
set_debug_output(True) # create the schc protocol object. rule_manager = RuleManager() for x in config.rule_config: rule_manager.Add(device=x.get("devL2Addr"), file=x["rule_file"]) if config.debug_level > 1: rule_manager.Print() # schc_conf = get_schc_conf(config) system = AiohttpSystem(logger=logger, config=schc_conf) layer2 = AiohttpLowerLayer(system, config=schc_conf) layer3 = AiohttpUpperLayer(system, config=schc_conf) protocol = protocol.SCHCProtocol(schc_conf, system, layer2, layer3, role="core-server", unique_peer=False) protocol.set_rulemanager(rule_manager) # ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ctx.load_cert_chain(config.my_cert) app = web.Application(logger=logger) if not config.enable_sim_device: app.router.add_route("POST", "/ul", app_uplink) app.router.add_route("POST", "/dl", app_downlink) else: # this is debug use only. app.router.add_route("POST", "/ul", app_downlink) app.router.add_route("POST", "/dl", app_uplink) #