def open(self, protocol_factory: Callable[[], Protocol], local_call: AX25Call, remote_call: AX25Call, origin_node: AX25Call, origin_user: AX25Call): # This a new connection, create the transport and protocol nl_connect = NetRomStateEvent.nl_connect(-1, remote_call, local_call, origin_node, origin_user) self.sm.handle_internal_event(nl_connect) self.l3_half_open[nl_connect.circuit_id] = protocol_factory
def nl_data_request(self, my_circuit_id: int, remote_call: AX25Call, local_call: AX25Call, data: bytes) -> None: dest = NetRomAddress(remote_call.callsign, remote_call.ssid) routed, mtu = self.l3_protocol.route_packet(dest) if routed: event = NetRomStateEvent.nl_data(my_circuit_id, remote_call, data, mtu) self.sm.handle_internal_event_sync(event) else: self.debug(f"No route to {dest}, dropping")
def open(self, protocol_factory: Callable[[], Protocol], local_call: AX25Call, remote_call: AX25Call, origin_node: AX25Call, origin_user: AX25Call) -> Protocol: # This a new connection, create the transport and protocol nl_connect = NetRomStateEvent.nl_connect(-1, remote_call, local_call, origin_node, origin_user) self.sm.handle_internal_event_sync(nl_connect) protocol = protocol_factory() self.l3_half_open[nl_connect.circuit_id] = protocol self.l3_protocol.listen( NetRomAddress(local_call.callsign, local_call.ssid, "")) self.l3_destinations.add(local_call) return protocol
def nl_disconnect_request(self, my_circuit_id: int, remote_call: AX25Call, local_call: AX25Call): nl_disconnect = NetRomStateEvent.nl_disconnect(my_circuit_id, remote_call, local_call) self.sm.handle_internal_event(nl_disconnect) async def poll(): while True: if self.sm.get_state(nl_disconnect.circuit_id ) == NetRomStateType.Disconnected: return nl_disconnect.circuit_id else: await asyncio.sleep(0.001) return asyncio.create_task(poll())
def nl_connect_request(self, remote_call: AX25Call, local_call: AX25Call, origin_node: AX25Call, origin_user: AX25Call): if remote_call == local_call: raise RuntimeError( f"Cannot connect to node's own callsign {local_call}") # circuit_id of -1 means pick an unused circuit to use nl_connect = NetRomStateEvent.nl_connect(-1, remote_call, local_call, origin_node, origin_user) self.sm.handle_internal_event(nl_connect) async def poll(): while True: if self.sm.get_state( nl_connect.circuit_id) == NetRomStateType.Connected: return nl_connect.circuit_id else: await asyncio.sleep(0.001) return asyncio.create_task(poll())
def nl_data_request(self, my_circuit_id: int, remote_call: AX25Call, local_call: AX25Call, data: bytes): event = NetRomStateEvent.nl_data(my_circuit_id, remote_call, data) event.future = self.loop.create_future() self.sm.handle_internal_event(event) return event.future
def nl_disconnect_request(self, my_circuit_id: int, remote_call: AX25Call, local_call: AX25Call) -> None: nl_disconnect = NetRomStateEvent.nl_disconnect(my_circuit_id, remote_call, local_call) self.sm.handle_internal_event_sync(nl_disconnect)
def nl_connect_request(self, remote_call: AX25Call, local_call: AX25Call, origin_node: AX25Call, origin_user: AX25Call) -> None: nl_connect = NetRomStateEvent.nl_connect(-1, remote_call, local_call, origin_node, origin_user) self.sm.handle_internal_event_sync(nl_connect)