Пример #1
0
static void
handle_application_request( const messenger_context_handle *handle, management_application_request *request ) {
  assert( handle != NULL );
  assert( request != NULL );
  assert( ntohs( request->header.type ) == MANAGEMENT_APPLICATION_REQUEST );
  assert( ntohl( request->header.length ) >= offsetof( management_application_request, data ) );

  debug( "Handling an application specific management request from %s ( application_id = %#x ).",
         handle->service_name, request->application_id );

  if ( application_callback != NULL ) {
    size_t length = ( size_t ) ntohl( request->header.length ) - offsetof( management_application_request, data );
    void *data = NULL;
    if ( length > 0 ) {
      data = request->data;
    }
    application_callback( handle, ntohl( request->application_id ), data, length, application_user_data );
  }
  else {
    management_application_reply *reply = create_management_application_reply( MANAGEMENT_REQUEST_FAILED,
                                                                               ntohl( request->application_id ), NULL, 0 );
    send_management_application_reply( handle, reply );
    xfree( reply );
  }
}
Пример #2
0
static void
management_recv( const messenger_context_handle *handle, uint32_t command, void *data, size_t data_len, void *user_data ) {
  UNUSED( user_data );

  switch ( command ) {
    case DUMP_XID_TABLE:
    {
      dump_xid_table();
    }
    break;

    case DUMP_COOKIE_TABLE:
    {
      if ( !switch_info.cookie_translation ) {
        break;
      }
      dump_cookie_table();
    }
    break;

    case TOGGLE_COOKIE_AGING:
    {
      if ( !switch_info.cookie_translation ) {
        break;
      }
      if ( age_cookie_table_enabled ) {
        delete_timer_event( age_cookie_table, NULL );
        age_cookie_table_enabled = false;
      }
      else {
        add_periodic_event_callback( COOKIE_TABLE_AGING_INTERVAL, age_cookie_table, NULL );
        age_cookie_table_enabled = true;
      }
    }
    break;

    case EVENT_FORWARD_ENTRY_ADD:
    case EVENT_FORWARD_ENTRY_DELETE:
    case EVENT_FORWARD_ENTRY_DUMP:
    case EVENT_FORWARD_ENTRY_SET:
    {
      event_forward_operation_request *req = data;
      req->n_services = ntohl( req->n_services );
      management_event_forward_entry_operation( handle, command, req, data_len );
      return;
    }
    break;

    default:
    {
      error( "Undefined management command ( %#x )", command );
      management_application_reply *reply = create_management_application_reply( MANAGEMENT_REQUEST_FAILED, command, NULL, 0 );
      send_management_application_reply( handle, reply );
      xfree( reply );
      return;
    }
  }

  management_application_reply *reply = create_management_application_reply( MANAGEMENT_REQUEST_SUCCEEDED, command, NULL, 0 );
  send_management_application_reply( handle, reply );
  xfree( reply );
}
Пример #3
0
static void
management_event_forward_entry_operation( const messenger_context_handle *handle, uint32_t command, event_forward_operation_request *req, size_t data_len ) {

  debug( "management efi command:%#x, type:%#x, n_services:%d", command, req->type, req->n_services );

  list_element **subject = NULL;
  switch ( req->type ) {
    case EVENT_FORWARD_TYPE_VENDOR:
      info( "Managing vendor event." );
      subject = &switch_info.vendor_service_name_list;
      break;

    case EVENT_FORWARD_TYPE_PACKET_IN:
      info( "Managing packet_in event." );
      subject = &switch_info.packetin_service_name_list;
      break;

    case EVENT_FORWARD_TYPE_PORT_STATUS:
      info( "Managing port_status event." );
      subject = &switch_info.portstatus_service_name_list;
      break;

    case EVENT_FORWARD_TYPE_STATE_NOTIFY:
      info( "Managing state_notify event." );
      subject = &switch_info.state_service_name_list;
      break;

    default:
      error( "Invalid EVENT_FWD_TYPE ( %#x )", req->type );
      event_forward_operation_reply res;
      memset( &res, 0, sizeof( event_forward_operation_reply ) );
      res.type = req->type;
      res.result = EFI_OPERATION_FAILED;
      management_application_reply *reply = create_management_application_reply( MANAGEMENT_REQUEST_FAILED, command, &res, sizeof( event_forward_operation_reply ) );
      send_management_application_reply( handle, reply );
      xfree( reply );
      return;
  }
  assert( subject != NULL );

  switch ( command ) {
    case EVENT_FORWARD_ENTRY_ADD:
      management_event_forward_entry_add( subject, req, data_len );
      break;

    case EVENT_FORWARD_ENTRY_DELETE:
      management_event_forward_entry_delete( subject, req, data_len );
      break;

    case EVENT_FORWARD_ENTRY_DUMP:
      info( "Dumping current event filter." );
      // do nothing
      break;

    case EVENT_FORWARD_ENTRY_SET:
      management_event_forward_entries_set( subject, req, data_len );
      break;
  }

  buffer *buf = create_event_forward_operation_reply( req->type, EFI_OPERATION_SUCCEEDED, *subject );
  management_application_reply *reply = create_management_application_reply( MANAGEMENT_REQUEST_SUCCEEDED, command, buf->data, buf->length );
  free_buffer( buf );
  send_management_application_reply( handle, reply );
  xfree( reply );
}