Exemple #1
0
 def handle_msg_meta(self, msg, meta):
     """
     Main routine to handle incoming SCION messages.
     """
     if isinstance(meta, SockOnlyMetadata):  # From SCIOND API
         try:
             sciond_msg = SCIONDMsg.from_raw(msg)
         except SCIONParseError as err:
             logging.error(str(err))
             return
         self.api_handle_request(sciond_msg, meta)
         return
     super().handle_msg_meta(msg, meta)
Exemple #2
0
 def _get_response(self, socket, expected_id, expected_type):  # pragma: no cover
     try:
         data = socket.recv()[0]
     except timeout:
         raise SCIONDResponseError("Socket timed out.")
     except SCIONIOError:
         raise SCIONDResponseError("Socket IO error.")
     if not data:
         raise SCIONDResponseError("Received empty response from SCIOND.")
     try:
         response = SCIONDMsg.from_raw(data)
     except SCIONParseError as e:
         raise SCIONDResponseError(str(e))
     if response.type() != expected_type:
         raise SCIONDResponseError(
             "Unexpected SCIOND msg type received: %s" % response.NAME)
     if response.id != expected_id:
         raise SCIONDResponseError("Wrong response ID: %d (expected %d)" %
                                   (response.id, expected_id))
     return response.union