예제 #1
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;
}
예제 #2
0
파일: vport.c 프로젝트: Sovietaced/ivs
static indigo_error_t
port_status_notify(of_port_no_t of_port_num, unsigned reason)
{
    indigo_error_t   result = INDIGO_ERROR_NONE;
    of_port_desc_t   *of_port_desc   = 0;
    of_port_status_t *of_port_status = 0;
    of_version_t ctrlr_of_version;

    if (indigo_cxn_get_async_version(&ctrlr_of_version) != INDIGO_ERROR_NONE) {
        LOG_TRACE("No active controller connection");
        return INDIGO_ERROR_NONE;
    }

    if ((of_port_desc = of_port_desc_new(ctrlr_of_version)) == 0) {
        LOG_ERROR("of_port_desc_new() failed");
        result = INDIGO_ERROR_UNKNOWN;
        goto done;
    }

    port_desc_set(of_port_desc, of_port_num);

    if ((of_port_status = of_port_status_new(ctrlr_of_version)) == 0) {
        LOG_ERROR("of_port_status_new() failed");
        result = INDIGO_ERROR_UNKNOWN;
        goto done;
    }

    of_port_status_reason_set(of_port_status, reason);
    of_port_status_desc_set(of_port_status, of_port_desc);
    of_port_desc_delete(of_port_desc);

    indigo_core_port_status_update(of_port_status);

    of_port_desc   = 0;     /* No longer owned */
    of_port_status = 0;     /* No longer owned */

 done:
    if (of_port_desc)    of_port_desc_delete(of_port_desc);
    if (of_port_status)  of_port_status_delete(of_port_status);

    return (result);
}
예제 #3
0
void
ind_ofdpa_port_event_receive(void)
{
  of_port_desc_t   *of_port_desc   = 0;
  of_port_status_t *of_port_status = 0;
  ofdpaPortEvent_t portEventData;
  int reason = 0;

  LOG_TRACE("Reading Port Events");

  memset(&portEventData, 0, sizeof(portEventData));
  while (ofdpaPortEventNextGet(&portEventData) == OFDPA_E_NONE)
  {
    LOG_TRACE("client_event: retrieved port event: port no = %d, eventMask = 0x%x, state = %d\n",
              portEventData.portNum, portEventData.eventMask, portEventData.state);

    of_port_desc = of_port_desc_new(ofagent_of_version);
    if (of_port_desc == 0)
    {
      LOG_ERROR("of_port_desc_new() failed");
      break;
    }

    if ((ind_ofdpa_port_desc_set(portEventData.portNum, of_port_desc)) < 0)
    {
      LOG_ERROR("ind_ofdpa_port_desc_set() failed");
      break;
    }

    of_port_status = of_port_status_new(ofagent_of_version);
    if (of_port_status == 0)
    {
      LOG_ERROR("of_port_status_new() failed");
      break;
    }

    if (portEventData.eventMask & OFDPA_EVENT_PORT_CREATE)
    {
      reason = OF_PORT_CHANGE_REASON_ADD;
    }
    else if (portEventData.eventMask & OFDPA_EVENT_PORT_DELETE)
    {
      reason = OF_PORT_CHANGE_REASON_DELETE;
    }
    else if (portEventData.eventMask & OFDPA_EVENT_PORT_STATE)
    {
      reason = OF_PORT_CHANGE_REASON_MODIFY;
    }

    of_port_status_reason_set(of_port_status, reason);
    if (of_port_status_desc_set(of_port_status, of_port_desc) < 0) {
        LOG_ERROR("Unexpected failure setting port desc");
        break;
    }
    of_port_desc_delete(of_port_desc);

    indigo_core_port_status_update(of_port_status);

    of_port_desc   = 0;     /* No longer owned */
    of_port_status = 0;     /* No longer owned */
  }

  if (of_port_desc)
  {
    of_port_desc_delete(of_port_desc);
  }

  return;
}