Esempio n. 1
0
OFDPE
append_action( action_list *list, action *action ) {
  assert( list != NULL );
  assert( action != NULL );

  switch ( action->type ) {
    case OFPAT_OUTPUT:
    case OFPAT_COPY_TTL_OUT:
    case OFPAT_COPY_TTL_IN:
    case OFPAT_SET_MPLS_TTL:
    case OFPAT_DEC_MPLS_TTL:
    case OFPAT_PUSH_VLAN:
    case OFPAT_POP_VLAN:
    case OFPAT_PUSH_MPLS:
    case OFPAT_POP_MPLS:
    case OFPAT_SET_QUEUE:
    case OFPAT_GROUP:
    case OFPAT_SET_NW_TTL:
    case OFPAT_DEC_NW_TTL:
    case OFPAT_SET_FIELD:
    case OFPAT_PUSH_PBB:
    case OFPAT_POP_PBB:
      break;

    default:
      return ERROR_OFDPE_BAD_ACTION_BAD_TYPE;
  }

  list = insert_before_dlist( list, ( void * ) action );
  if ( list == NULL ) {
    return ERROR_APPEND_TO_LIST;
  }

  return OFDPE_SUCCESS;
}
Esempio n. 2
0
void
insert_probe_timer_entry( probe_timer_entry *new_entry ) {
  probe_timer_entry *last_entry = probe_timer_last->data;
  if ( probe_timer_table->next == NULL
       || timespec_le( &(last_entry->expires ), &( new_entry->expires ) ) ) {
    probe_timer_last = insert_after_dlist( probe_timer_last, new_entry );

    goto set_interval_timer;
  }

  dlist_element *dlist;
  probe_timer_entry *entry;
  for ( dlist = probe_timer_table->next; dlist != NULL; dlist = dlist->next ) {
    entry = dlist->data;
    if ( timespec_le( &(entry->expires ), &( new_entry->expires ) ) ) {
      continue;
    }
    insert_before_dlist( dlist, new_entry );
    goto set_interval_timer;
  }
  UNREACHABLE();

set_interval_timer:

  if ( probe_timer_table->next->data != new_entry ) {
    return;
  }

#if 0
  set_interval_timer();
#endif
}
Esempio n. 3
0
OFDPE
append_action_bucket( bucket_list *list, bucket *bucket ) {
  assert( list != NULL );
  assert( bucket != NULL );

  list = insert_before_dlist( list, ( void * ) bucket );
  if ( list == NULL ) {
    return ERROR_NO_MEMORY;
  }

  return OFDPE_SUCCESS;
}
static void
setup_reverse_path( int status, const path *p, void *user_data ) {
  assert(user_data);

  packet_out_params *params = user_data;
  if ( status != SETUP_SUCCEEDED ) {
    error( "Failed to set up path ( status = %d ).", status );
    output_packet( params->packet, params->out_datapath_id, params->out_port_no, params->out_vid );
    free_buffer( params->packet );
    xfree( params );
    return;
  }

  struct ofp_match rmatch;
  set_ipv4_reverse_match( &rmatch, &(p->match) );
  rmatch.dl_vlan = params->out_vid;

  openflow_actions *vlan_actions;
  vlan_actions = create_openflow_actions_to_update_vid( params->out_vid, params->in_vid );

  path *rpath = create_path( rmatch, p->priority, p->idle_timeout, p->hard_timeout );
  assert( rpath != NULL );
  list_element *hops = p->hops;
  dlist_element *rhops = create_dlist();
  while ( hops != NULL ) {
    hop *h = hops->data;
    assert( h != NULL );
    hop *rh = create_hop( h->datapath_id, h->out_port, h->in_port, vlan_actions );
    if ( vlan_actions ) {
      delete_actions( vlan_actions );
      vlan_actions = NULL;
    }
    assert( rh != NULL );
    rhops = insert_before_dlist( rhops, rh );
    hops = hops->next;
  }
  while ( rhops != NULL && rhops->data != NULL ) {
    append_hop_to_path( rpath, ( hop * ) rhops->data );
    rhops = rhops->next;
  }
  bool ret = setup_path( rpath, handle_setup, params, NULL, NULL );
  if ( ret != true ) {
    error( "Failed to set up reverse path." );
    output_packet( params->packet, params->out_datapath_id, params->out_port_no, params->out_vid );
    free_buffer( params->packet );
    xfree( params );
  }

  delete_path( rpath );
  delete_dlist( rhops );
}
Esempio n. 5
0
static void
insert_timer_callback( struct timer_info *timer, timer_callback_info *new_cb ) {
    assert( timer->timer_callbacks != NULL );
    dlist_element *element, *last = timer->timer_callbacks;
    for ( element = timer->timer_callbacks->next; element != NULL; element = element->next ) {
        timer_callback_info *cb = element->data;
        if ( TIMESPEC_LESS_THEN( &new_cb->expires_at, &cb->expires_at ) ) {
            insert_before_dlist( element, new_cb );
            return;
        }
        last = element;
    }
    insert_after_dlist( last, new_cb );
}
Esempio n. 6
0
// NULL <- "alpha" <-> "bravo" <-> "charlie" <-> new_element
static void
test_insert_before_dlist() {
    char element_data1[] = "alpha";
    char element_data2[] = "bravo";
    char element_data3[] = "charlie";

    dlist_element *new_element = create_dlist();

    assert_true( insert_before_dlist( new_element, element_data1 ) );
    assert_true( insert_before_dlist( new_element, element_data2 ) );
    assert_true( insert_before_dlist( new_element, element_data3 ) );

    assert_string_equal( new_element->prev->data, "charlie" );
    assert_string_equal( new_element->prev->prev->data, "bravo" );
    assert_string_equal( new_element->prev->prev->prev->data, "alpha" );
    assert_true( new_element->prev->prev->prev->prev == NULL );

    assert_true( new_element->prev->next == new_element );
    assert_true( new_element->prev->prev->next->next == new_element );
    assert_true( new_element->prev->prev->prev->next->next->next == new_element );

    delete_dlist( new_element );
}
Esempio n. 7
0
action_list *
duplicate_action_list( action_list *list ) {
  if ( list == NULL ) {
    return NULL;
  }

  dlist_element *dst = create_action_list();
  for ( dlist_element *element = get_first_element( list ); element != NULL; element = element->next ) {
    action *src_action = element->data;
    if ( src_action != NULL ) {
      action *dst_action = duplicate_action( src_action );
      insert_before_dlist( dst, dst_action );
    }
  }

  return dst;
}
Esempio n. 8
0
static void
test_insert_before_dlist_aborts_with_NULL_dlist() {
    expect_string( mock_die, output, "element must not be NULL" );
    expect_assert_failure( insert_before_dlist( NULL, NULL ) );
}