Beispiel #1
0
static void
port_desc_set(of_port_desc_t *of_port_desc, of_port_no_t of_port_num)
{
    struct ind_ovs_port *port = ind_ovs_ports[of_port_num];
    assert(port != NULL);

    of_port_desc_port_no_set(of_port_desc, of_port_num);
    of_port_desc_hw_addr_set(of_port_desc, port->mac_addr);
    of_port_desc_name_set(of_port_desc, port->ifname);
    of_port_desc_config_set(of_port_desc, port->config);

    uint32_t state = 0;
    if (!(port->ifflags & IFF_UP)) {
        state |= OF_PORT_STATE_FLAG_LINK_DOWN;
    }
    of_port_desc_state_set(of_port_desc, state);

    uint32_t curr, advertised, supported, peer;
    ind_ovs_get_interface_features(port->ifname, &curr, &advertised,
        &supported, &peer, of_port_desc->version);

    of_port_desc_curr_set(of_port_desc, curr);
    of_port_desc_advertised_set(of_port_desc, advertised);
    of_port_desc_supported_set(of_port_desc, supported);
    of_port_desc_peer_set(of_port_desc, peer);
}
Beispiel #2
0
/* Generated from of10/port_status.data */
static int
test_of10_port_status(void) {
    uint8_t binary[] = {
        0x01, 0x0c, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 
        0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
        0xff, 0xfd, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 
        0x66, 0x6f, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
        0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 
        0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 
        
    };

    of_object_t *obj;

    obj = of_port_status_new(OF_VERSION_1_0);
    {
        of_object_t *desc = of_port_desc_new(OF_VERSION_1_0);
        of_port_desc_advertised_set(desc, 32);
        of_port_desc_config_set(desc, 16);
        of_port_desc_curr_set(desc, 1);
        {
    	of_mac_addr_t hw_addr = { { 1, 2, 3, 4, 5, 6 } };
    	of_port_desc_hw_addr_set(desc, hw_addr);
        }
        {
    	of_port_name_t name = "foo";
    	of_port_desc_name_set(desc, name);
        }
        of_port_desc_peer_set(desc, 2048);
        of_port_desc_port_no_set(desc, 65533);
        of_port_desc_state_set(desc, 512);
        of_port_desc_supported_set(desc, 512);
        of_port_status_desc_set(obj, desc);
        of_object_delete(desc);
    }
    of_port_status_reason_set(obj, 1);
    of_port_status_xid_set(obj, 4);

    if (sizeof(binary) != WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj))
        || memcmp(binary, WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), sizeof(binary))) {
	show_failure(binary, sizeof(binary),
		     WBUF_BUF(OF_OBJECT_TO_WBUF(obj)),
		     WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj)));
	of_object_delete(obj);
	return TEST_FAIL;
    }

    of_object_delete(obj);
    return TEST_PASS;
}
Beispiel #3
0
static void
port_desc_set_local(of_port_desc_t *of_port_desc)
{
    of_port_desc_port_no_set(of_port_desc, OF_PORT_DEST_LOCAL);
    {
        of_mac_addr_t of_mac_addr;
        /** \todo Get proper MAC address */
        memset(&of_mac_addr, 0, sizeof(of_mac_addr));
        of_port_desc_hw_addr_set(of_port_desc, of_mac_addr);
    }
    of_port_name_t name = "local";
    of_port_desc_name_set(of_port_desc, name);
    of_port_desc_config_set(of_port_desc, 0);
    of_port_desc_state_set(of_port_desc, 0);

    of_port_desc_curr_set(of_port_desc, OF_PORT_FEATURE_FLAG_10GB_FD |
        OF_PORT_FEATURE_FLAG_COPPER_BY_VERSION(of_port_desc->version));
    of_port_desc_advertised_set(of_port_desc, 0);
    of_port_desc_supported_set(of_port_desc, 0);
    of_port_desc_peer_set(of_port_desc, 0);
}
Beispiel #4
0
/* Set the port features in LOCI structure
 * Parameters:
 *    port          (input)   Port number
 *    of_port_desc  (output)  Port description LOCI object
 */
static indigo_error_t ind_ofdpa_port_features_set(of_port_no_t port,
                                                  of_port_desc_t *of_port_desc)
{
  OFDPA_ERROR_t ofdpa_rv = OFDPA_E_NONE;
  ofdpaPortFeature_t  features;

  ofdpa_rv = ofdpaPortFeatureGet(port, &features);
  if (ofdpa_rv != OFDPA_E_NONE)
  {
    LOG_ERROR("Error getting port features");
    return (indigoConvertOfdpaRv(ofdpa_rv));
  }

  /* Port Current Features */
  of_port_desc_curr_set(of_port_desc, features.curr);
  /* Port Advertised Features */
  of_port_desc_advertised_set(of_port_desc, features.advertised);
  /* Port Supported Features */
  of_port_desc_supported_set(of_port_desc, features.supported);
  /* Peer Features */
  of_port_desc_peer_set(of_port_desc, features.peer);

  return INDIGO_ERROR_NONE;
}
Beispiel #5
0
/* Generated from of10/packet_in.data */
static int
test_of10_packet_in(void) {
    uint8_t binary[] = {
        0x01, 0x0a, 0x00, 0x15, 0x12, 0x34, 0x56, 0x78, 
        0xab, 0xcd, 0xef, 0x01, 0x00, 0x09, 0xff, 0xfe, 
        0x01, 0x00, 0x61, 0x62, 0x63, 
    };

    of_object_t *obj;

    obj = of_packet_in_new(OF_VERSION_1_0);
    of_packet_in_buffer_id_set(obj, 2882400001);
    {
        of_octets_t data = { .bytes=3, .data=(uint8_t *)"\x61\x62\x63" };
        of_packet_in_data_set(obj, &data);
    }
    of_packet_in_in_port_set(obj, 65534);
    of_packet_in_reason_set(obj, 1);
    of_packet_in_total_len_set(obj, 9);
    of_packet_in_xid_set(obj, 305419896);

    if (sizeof(binary) != WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj))
        || memcmp(binary, WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), sizeof(binary))) {
	show_failure(binary, sizeof(binary),
		     WBUF_BUF(OF_OBJECT_TO_WBUF(obj)),
		     WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj)));
	of_object_delete(obj);
	return TEST_FAIL;
    }

    of_object_delete(obj);
    return TEST_PASS;
}

/* Generated from of10/packet_out.data */
static int
test_of10_packet_out(void) {
    uint8_t binary[] = {
        0x01, 0x0d, 0x00, 0x23, 0x12, 0x34, 0x56, 0x78, 
        0xab, 0xcd, 0xef, 0x01, 0xff, 0xfe, 0x00, 0x10, 
        0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 
        0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 
        0x61, 0x62, 0x63, 
    };

    of_object_t *obj;

    obj = of_packet_out_new(OF_VERSION_1_0);
    of_packet_out_buffer_id_set(obj, 2882400001);
    of_packet_out_in_port_set(obj, 65534);
    of_packet_out_xid_set(obj, 305419896);
    {
        of_object_t *list = of_list_action_new(OF_VERSION_1_0);
        {
            of_object_t *obj = of_action_output_new(OF_VERSION_1_0);
            of_action_output_max_len_set(obj, 0);
            of_action_output_port_set(obj, 1);
            of_list_append(list, obj);
            of_object_delete(obj);
        }
        {
            of_object_t *obj = of_action_output_new(OF_VERSION_1_0);
            of_action_output_max_len_set(obj, 0);
            of_action_output_port_set(obj, 2);
            of_list_append(list, obj);
            of_object_delete(obj);
        }
        of_packet_out_actions_set(obj, list);
        of_object_delete(list);
    }
    {
        of_octets_t data = { .bytes=3, .data=(uint8_t *)"\x61\x62\x63" };
        of_packet_out_data_set(obj, &data);
    }

    if (sizeof(binary) != WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj))
        || memcmp(binary, WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), sizeof(binary))) {
	show_failure(binary, sizeof(binary),
		     WBUF_BUF(OF_OBJECT_TO_WBUF(obj)),
		     WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj)));
	of_object_delete(obj);
	return TEST_FAIL;
    }

    of_object_delete(obj);
    return TEST_PASS;
}

/* Generated from of10/port_desc.data */
static int
test_of10_port_desc(void) {
    uint8_t binary[] = {
        0xff, 0xfd, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 
        0x66, 0x6f, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
        0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 
        0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 
        
    };

    of_object_t *obj;

    obj = of_port_desc_new(OF_VERSION_1_0);
    of_port_desc_advertised_set(obj, 32);
    of_port_desc_config_set(obj, 16);
    of_port_desc_curr_set(obj, 1);
    {
        of_mac_addr_t hw_addr = { { 1, 2, 3, 4, 5, 6 } };
        of_port_desc_hw_addr_set(obj, hw_addr);
    }
    {
        of_port_name_t name = "foo";
        of_port_desc_name_set(obj, name);
    }
    of_port_desc_peer_set(obj, 2048);
    of_port_desc_port_no_set(obj, 65533);
    of_port_desc_state_set(obj, 512);
    of_port_desc_supported_set(obj, 512);

    if (sizeof(binary) != WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj))
        || memcmp(binary, WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), sizeof(binary))) {
	show_failure(binary, sizeof(binary),
		     WBUF_BUF(OF_OBJECT_TO_WBUF(obj)),
		     WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj)));
	of_object_delete(obj);
	return TEST_FAIL;
    }

    of_object_delete(obj);
    return TEST_PASS;
}