Пример #1
0
Файл: VNS.py Проект: smbz/vns
    def handle_recv_ti_msg(self, conn, ti_msg):
        if ti_msg is not None:
            logging.debug('recv VNS TI msg: %s' % ti_msg)
            if ti_msg.get_type() == VNSAuthReply.get_type():
                self.handle_auth_reply(conn, ti_msg, self.terminate_ti_connection)
                return
            elif not conn.vns_authorized:
                logging.warning('received non-auth-reply from unauthenticated TI user %s: terminating the user' % conn)
                self.terminate_ti_connection(conn, 'ERROR: simulator expected authentication reply')
                return
            # user is authenticated => any other messages are ok
            elif ti_msg.get_type() == TIOpen.get_type():
                self.handle_ti_open_msg(conn, ti_msg)
                return

            # all of the remaining messages require the associated topology
            topo = self.ti_conn_to_topo(conn)
            if not topo:
                return
            try:
                if ti_msg.get_type() == TIPacket.get_type():
                    self.handle_ti_packet_msg(conn, topo, ti_msg)
                elif ti_msg.get_type() == TIPingFromRequest.get_type():
                    self.handle_ti_pingfrom_msg(conn, topo, ti_msg)
                elif ti_msg.get_type() == TITap.get_type():
                    self.handle_ti_tap_msg(conn, topo, ti_msg)
                elif ti_msg.get_type() == TIModifyLink.get_type():
                    self.handle_ti_modifylink_msg(conn, topo, ti_msg)
                else:
                    logging.debug('unexpected VNS TI message received: %s' % ti_msg)
            except TIBadNodeOrPort, e:
                conn.send(e)
Пример #2
0
Файл: VNS.py Проект: dound/vns
 def handle_recv_msg(self, conn, vns_msg):
     if vns_msg is not None:
         logging.debug('recv VNS msg: %s' % vns_msg)
         if vns_msg.get_type() == VNSAuthReply.get_type():
             self.handle_auth_reply(conn, vns_msg, self.terminate_connection)
             return
         elif not conn.vns_authorized:
             logging.warning('received non-auth-reply from unauthenticated user %s: terminating the user' % conn)
             self.terminate_connection(conn, 'simulator expected authentication reply')
         # user is authenticated => any other messages are ok
         elif vns_msg.get_type() == VNSOpen.get_type():
             self.handle_open_msg(conn, vns_msg)
         elif vns_msg.get_type() == VNSClose.get_type():
             self.handle_close_msg(conn)
         elif vns_msg.get_type() == VNSPacket.get_type():
             self.handle_packet_msg(conn, vns_msg)
         elif vns_msg.get_type() == VNSOpenTemplate.get_type():
             self.handle_open_template_msg(conn, vns_msg)
         else:
             logging.debug('unexpected VNS message received: %s' % vns_msg)
Пример #3
0
  def _handle_recv_msg(self, conn, vns_msg):
    # demux sr-client messages and take approriate actions
    if vns_msg is None:
      log.debug("invalid message")
      self._handle_close_msg(conn)
      return

    log.debug('recv VNS msg: %s' % vns_msg)
    if vns_msg.get_type() == VNSAuthReply.get_type():
      self._handle_auth_reply(conn)
      return
    elif vns_msg.get_type() == VNSOpen.get_type():
      self._handle_open_msg(conn, vns_msg)
    elif vns_msg.get_type() == VNSClose.get_type():
      self._handle_close_msg(conn)
    elif vns_msg.get_type() == VNSPacket.get_type():
      self._handle_packet_msg(conn, vns_msg)
    elif vns_msg.get_type() == VNSOpenTemplate.get_type():
      # TODO: see if this is needed...
      self._handle_open_template_msg(conn, vns_msg)
    else:
      log.debug('unexpected VNS message received: %s' % vns_msg)
Пример #4
0
    def _handle_recv_msg(self, conn, vns_msg):
        # demux sr-client messages and take approriate actions
        if vns_msg is None:
            log.debug("invalid message")
            self._handle_close_msg(conn)
            return

        log.debug('recv VNS msg: %s' % vns_msg)
        if vns_msg.get_type() == VNSAuthReply.get_type():
            self._handle_auth_reply(conn)
            return
        elif vns_msg.get_type() == VNSOpen.get_type():
            self._handle_open_msg(conn, vns_msg)
        elif vns_msg.get_type() == VNSClose.get_type():
            self._handle_close_msg(conn)
        elif vns_msg.get_type() == VNSPacket.get_type():
            self._handle_packet_msg(conn, vns_msg)
        elif vns_msg.get_type() == VNSOpenTemplate.get_type():
            # TODO: see if this is needed...
            self._handle_open_template_msg(conn, vns_msg)
        else:
            log.debug('unexpected VNS message received: %s' % vns_msg)