def get_as_info(self, isd_as=None): q_ia = isd_as if not q_ia: q_ia = "local" with self._as_infos_lock: _, as_infos = self._try_cache(self._as_infos, [q_ia]) as_info = as_infos.get(q_ia) if as_info: return as_info req_id = self._req_id.inc() as_req = SCIONDASInfoRequest.from_values(req_id, isd_as) with closing(self._create_socket()) as socket: if not socket.send(as_req.pack_full()): raise SCIONDRequestError response = self._get_response(socket, req_id, SMT.AS_REPLY) self._as_infos[q_ia] = list(response.iter_entries()) return self._as_infos[q_ia]
def _test_as_request_reply(self): as_req = SCIONDASInfoRequest.from_values() api_socket = self.api_socket() api_socket.send(as_req.pack_full()) data = api_socket.recv()[0] if data: response = parse_sciond_msg(data) if response.MSG_TYPE != SMT.AS_REPLY: logging.error("Unexpected SCIOND msg type received: %s" % response.NAME) return False for entry in response.iter_entries(): if entry.isd_as() == self.addr.isd_as: logging.debug("Received correct AS reply.") return True logging.error("Wrong AS Reply received.") return False