Exemplo n.º 1
0
static void
send_idle_notification(ft_entry_t *entry)
{
    of_bsn_flow_idle_t *msg;
    of_version_t ver;

    if (indigo_cxn_get_async_version(&ver) < 0) {
        /* No controllers connected */
        return;
    }

    if ((msg = of_bsn_flow_idle_new(ver)) == NULL) {
        LOG_ERROR("Failed to allocate flow_idle message");
        return;
    }

    of_bsn_flow_idle_cookie_set(msg, entry->cookie);
    of_bsn_flow_idle_priority_set(msg, entry->priority);
    of_bsn_flow_idle_table_id_set(msg, entry->table_id);

    if (of_bsn_flow_idle_match_set(msg, &entry->match)) {
        LOG_ERROR("Failed to set match in idle notification");
        of_object_delete(msg);
        return;
    }

    indigo_cxn_send_async_message(msg);
}
Exemplo n.º 2
0
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);
}