Beispiel #1
0
static void
handle_packet_in( uint64_t datapath_id, uint32_t transaction_id,
                  uint32_t buffer_id, uint16_t total_len,
                  uint16_t in_port, uint8_t reason, const buffer *data,
                  void *user_data ) {
  services *services = user_data;
  list_element **list_head = &services->arp_or_unicast;

  packet_info *packet_info = data->user_data;
  if ( !packet_type_arp( data ) && ( packet_info->eth_macda[ 0 ] & 0x1 ) == 0x1 ) {
    list_head = &services->broadcast;
  }
  if ( *list_head == NULL ) {
    return;
  }
  buffer *buf = create_packet_in( transaction_id, buffer_id, total_len, in_port,
                                  reason, data );

  openflow_service_header_t *message;
  message = append_front_buffer( buf, sizeof( openflow_service_header_t ) );
  message->datapath_id = htonll( datapath_id );
  message->service_name_length = htons( 0 );
  char *service_name = ( *list_head )->data;
  if ( send_message( service_name, MESSENGER_OPENFLOW_MESSAGE, buf->data, buf->length ) ) {
    debug( "Sending a message to %s.", service_name );
  }
  free_buffer( buf );
  if ( ( *list_head )->next != NULL ) {
    //round robin
    delete_element( list_head, service_name );
    append_to_tail( list_head, service_name );
  }
}
Beispiel #2
0
static void
handle_packet_in( uint64_t datapath_id, uint32_t transaction_id,
                  uint32_t buffer_id, uint16_t total_len,
                  uint16_t in_port, uint8_t reason, const buffer *data,
                  void *user_data ) {
  UNUSED( user_data );

  char match_str[ 1024 ];
  struct ofp_match ofp_match;   // host order

  buffer *copy = NULL;
  packet_info *packet_info = data->user_data;
  debug( "Receive packet. ethertype=0x%04x, ipproto=0x%x", packet_info->eth_type, packet_info->ipv4_protocol );
  if ( packet_type_ipv4_etherip( data ) ) {
    copy = parse_etherip( data );
  }
  set_match_from_packet( &ofp_match, in_port, 0, copy != NULL ? copy : data );
  if ( copy != NULL ) {
    free_buffer( copy );
    copy = NULL;
  }
  match_to_string( &ofp_match, match_str, sizeof( match_str ) );

  list_element *services = lookup_match_entry( ofp_match );
  if ( services == NULL ) {
    debug( "match entry not found" );
    return;
  }

  buffer *buf = create_packet_in( transaction_id, buffer_id, total_len, in_port,
                                  reason, data );

  openflow_service_header_t *message;
  message = append_front_buffer( buf, sizeof( openflow_service_header_t ) );
  message->datapath_id = htonll( datapath_id );
  message->service_name_length = htons( 0 );
  list_element *element;
  for ( element = services; element != NULL; element = element->next ) {
    const char *service_name = element->data;
    if ( !send_message( service_name, MESSENGER_OPENFLOW_MESSAGE,
                        buf->data, buf->length ) ) {
      error( "Failed to send a message to %s ( match = %s ).", service_name, match_str );
      free_buffer( buf );
      return;
    }

    debug( "Sending a message to %s ( match = %s ).", service_name, match_str );
  }

  free_buffer( buf );
}
Beispiel #3
0
static void
handle_packet_in( uint64_t datapath_id, uint32_t transaction_id,
                  uint32_t buffer_id, uint16_t total_len,
                  uint16_t in_port, uint8_t reason, const buffer *data,
                  void *user_data ) {
  UNUSED( user_data );

  char match_str[ 1024 ];
  struct ofp_match ofp_match;   // host order

  set_match_from_packet( &ofp_match, in_port, 0, data );
  match_to_string( &ofp_match, match_str, sizeof( match_str ) );

  match_entry *match_entry = lookup_match_entry( &ofp_match );
  if ( match_entry == NULL ) {
    debug( "No match entry found." );
    return;
  }

  buffer *buf = create_packet_in( transaction_id, buffer_id, total_len, in_port,
                                  reason, data );

  openflow_service_header_t *message;
  message = append_front_buffer( buf, sizeof( openflow_service_header_t ) );
  message->datapath_id = htonll( datapath_id );
  message->service_name_length = htons( 0 );
  if ( !send_message( match_entry->service_name, MESSENGER_OPENFLOW_MESSAGE,
                      buf->data, buf->length ) ) {
    error( "Failed to send a message to %s ( entry_name = %s, match = %s ).",
           match_entry->service_name, match_entry->entry_name, match_str );
    free_buffer( buf );
    return;
  }

  debug( "Sending a message to %s ( entry_name = %s, match = %s ).",
         match_entry->service_name, match_entry->entry_name, match_str );

  free_buffer( buf );
}