Ejemplo n.º 1
0
// FIXME: Copy & Paste from hello_switch.c
static void
handle_hello( uint32_t xid, uint8_t version, void *user_data ) {
    UNUSED( version );
    UNUSED( user_data );

    switch_send_openflow_message( create_hello( xid ) );
}
Ejemplo n.º 2
0
static VALUE
switch_send_message( VALUE self, VALUE message ) {
  buffer *buf;
  Data_Get_Struct( message, buffer, buf );
  switch_send_openflow_message( buf );
  return self;
}
Ejemplo n.º 3
0
static void
_handle_barrier_request( uint32_t transaction_id, void *user_data ) {
  UNUSED( user_data );
  buffer *barrier_reply = create_barrier_reply( transaction_id ); 
  switch_send_openflow_message( barrier_reply );
  free_buffer( barrier_reply );
}
Ejemplo n.º 4
0
static void
_handle_echo_request( const uint32_t transaction_id, const buffer *body, void *user_data ) {
  UNUSED( user_data );
  buffer *echo_reply = create_echo_reply( transaction_id, body );
  switch_send_openflow_message( echo_reply );
  free_buffer( echo_reply );
}
Ejemplo n.º 5
0
static void
handle_echo_request( uint32_t xid, const buffer *body, void *user_data ) {
    UNUSED( body );
    UNUSED( user_data );

    info( "received: OFPT_ECHO_REQUEST" );

    switch_send_openflow_message( create_echo_reply( xid, NULL ) );
}
Ejemplo n.º 6
0
static void
_handle_hello( const uint32_t transaction_id, const uint8_t version, const buffer *version_data, void *user_data ) {
  UNUSED( user_data );
  debug( "Hello received ( transaction_id = %#x, version = %#x ).", transaction_id, version );

  struct ofp_hello_elem_versionbitmap *versionbitmap = ( struct ofp_hello_elem_versionbitmap * ) version_data->data;
  const uint32_t ofp_versions[ 1 ] = { OFP_VERSION };
  
  uint32_t bitmap = versionbitmap->bitmaps[ 0 ];
  if ( ( bitmap & ( ( uint32_t ) 1 << ofp_versions[ 0 ] ) ) != ( ( uint32_t ) ofp_versions[ 0 ] ) ) {
    buffer *hello_buf = create_hello_elem_versionbitmap( transaction_id, ofp_versions,
      sizeof( ofp_versions ) / sizeof( ofp_versions[ 0 ] ) );
    switch_send_openflow_message( hello_buf );
    free_buffer( hello_buf );
  } else {
    send_error_message( transaction_id, OFPET_HELLO_FAILED, OFPHFC_INCOMPATIBLE );
  }
}
Ejemplo n.º 7
0
static void
_handle_get_config_request( const uint32_t transaction_id, void * user_data ) {
  UNUSED( user_data );
  
  switch_config config;
  memset( &config, 0, sizeof( switch_config ) );

  OFDPE ret = get_switch_config( &config );
  if ( ret != OFDPE_SUCCESS ) {
    uint16_t type = OFPET_BAD_REQUEST;
    uint16_t code = OFPBRC_EPERM;
    get_ofp_error( ret, &type, &code );
    send_error_message( transaction_id, type, code );
  }

  buffer *get_config_reply = create_get_config_reply( transaction_id, config.flags, config.miss_send_len );
  switch_send_openflow_message( get_config_reply );
  free_buffer( get_config_reply );
}
Ejemplo n.º 8
0
// FIXME: Copy & Paste from hello_switch.c
static void
handle_features_request( uint32_t xid, void *user_data ) {
    UNUSED( user_data );

    uint32_t supported = ( ( 1 << OFPAT_OUTPUT ) |
                           ( 1 << OFPAT_SET_VLAN_VID ) |
                           ( 1 << OFPAT_SET_VLAN_PCP ) |
                           ( 1 << OFPAT_STRIP_VLAN ) |
                           ( 1 << OFPAT_SET_DL_SRC ) |
                           ( 1 << OFPAT_SET_DL_DST ) |
                           ( 1 << OFPAT_SET_NW_SRC ) |
                           ( 1 << OFPAT_SET_NW_DST ) |
                           ( 1 << OFPAT_SET_NW_TOS ) |
                           ( 1 << OFPAT_SET_TP_SRC ) |
                           ( 1 << OFPAT_SET_TP_DST ) );

    buffer *msg = create_features_reply( xid, get_datapath_id(), 0, 1, 0, supported, NULL );

    switch_send_openflow_message( msg );
}
Ejemplo n.º 9
0
static void
_handle_features_request( const uint32_t transaction_id, void *user_data ) {
  assert( user_data );
  struct protocol *protocol = user_data;

  switch_features features;
  memset( &features, 0, sizeof( switch_features ) );
  get_switch_features( &features );
  /*
   * The n_buffers field specifies the maximum number of packets the switch can
   * buffer when sending packets to the controller using packet-in messages.
   */
  buffer *features_reply = create_features_reply( transaction_id, features.datapath_id, features.n_buffers,
                                                  features.n_tables, features.auxiliary_id, features.capabilities );
  if ( switch_send_openflow_message( features_reply ) ) {
    protocol->ctrl.controller_connected = true;
    /*
     * save datapath's capabilities
     */
    protocol->ctrl.capabilities = features.capabilities;
  }
  free_buffer( features_reply );
}