コード例 #1
0
ファイル: panelmodel.cpp プロジェクト: pombreda/main
PanelModel::PanelModel()
{
	set_wait_state(get_global_info()->waitForState);
	set_wait_timeout(get_global_info()->waitTimeout);
}
コード例 #2
0
ファイル: probe_timer_table.c プロジェクト: n-tada/trema
void
probe_request( probe_timer_entry *entry, int event, uint64_t *dpid, uint16_t port_no ) {
  if ( event == PROBE_TIMER_EVENT_UP ) {
    get_current_time( &port_down_time );
  }

  int old_state = entry->state;
  switch ( entry->state ) {
    case PROBE_TIMER_STATE_INACTIVE:
      switch( event ) {
        case PROBE_TIMER_EVENT_UP:
          set_send_delay_state( entry );
          break;
        default:
          break;
      }
      break;
    case PROBE_TIMER_STATE_SEND_DELAY:
      switch( event ) {
        case PROBE_TIMER_EVENT_DOWN:
          set_inactive_state( entry );
          break;
        case PROBE_TIMER_EVENT_TIMEOUT:
          set_wait_state( entry );
          send_lldp( entry );
          break;
        default:
          break;
      }
      break;
    case PROBE_TIMER_STATE_WAIT:
      switch( event ) {
        case PROBE_TIMER_EVENT_DOWN:
          set_inactive_state( entry );
          break;
        case PROBE_TIMER_EVENT_RECV_LLDP:
          set_confirmed_state( entry );
          entry->link_up = true;
          entry->to_datapath_id = *dpid;
          entry->to_port_no = port_no;

          topology_update_link_status link_status;
          link_status.from_dpid = entry->datapath_id;
          link_status.from_portno = entry->port_no;
          link_status.to_dpid = *dpid;
          link_status.to_portno = port_no;
          link_status.status = TD_PORT_UP;
          set_link_status( &link_status, NULL, NULL );
          break;
        case PROBE_TIMER_EVENT_TIMEOUT:
          if ( --entry->retry_count > 0 ) {
            set_wait_state( entry );
            send_lldp( entry );
          } else {
            set_confirmed_state( entry );
            entry->link_up = false;
            entry->to_datapath_id = 0;
            entry->to_port_no = 0;
            get_current_time( &( entry->link_down_time ) );

            topology_update_link_status link_status;
            link_status.from_dpid = entry->datapath_id;
            link_status.from_portno = entry->port_no;
            link_status.to_dpid = 0;
            link_status.to_portno = 0;
            link_status.status = TD_PORT_DOWN;
            set_link_status( &link_status, NULL, NULL );
          }
          break;
        default:
          break;
      }
      break;
    case PROBE_TIMER_STATE_CONFIRMED:
      switch( event ) {
        case PROBE_TIMER_EVENT_DOWN:
          set_inactive_state( entry );
          break;
        case PROBE_TIMER_EVENT_TIMEOUT:
          if ( --entry->retry_count > 0
            && !other_port_status_changed( entry ) ) {
            set_confirmed_state( entry );
          } else {
            set_send_delay_state( entry );
          }
          break;
        default:
          break;
      }
      break;
    default:
      UNREACHABLE();
      break;
  }

  if ( entry->state != old_state ) {
    debug( "Update probe state: %d <= %d by event %d. dpid %" PRIx64 " %u.",
           entry->state, old_state, event,
           entry->datapath_id, entry->port_no );
  }

  if ( entry->state != PROBE_TIMER_STATE_INACTIVE ) {
    insert_probe_timer_entry( entry );
  }
}