示例#1
0
/**
 * @brief Set the attribute of STP instance.
 *
 * @param[in] stp_id stp instance id
 * @param[in] attr attribute value
 * @return SAI_STATUS_SUCCESS if operation is successful otherwise a different
 *  error code is returned.
 */
sai_status_t sai_set_stp_port_state(
        _In_ sai_object_id_t stp_id,
        _In_ sai_object_id_t port_id,   
        _In_ sai_port_stp_port_state_t stp_port_state) {

    SAI_LOG_ENTER(SAI_API_STP);

    sai_status_t status = SAI_STATUS_SUCCESS;
    switch_stp_state_t switch_stp_state = SWITCH_PORT_STP_STATE_NONE;
    switch (stp_port_state) {
        case SAI_PORT_STP_STATE_LEARNING:
            switch_stp_state = SWITCH_PORT_STP_STATE_LEARNING;
            break;
        case SAI_PORT_STP_STATE_FORWARDING:
            switch_stp_state = SWITCH_PORT_STP_STATE_FORWARDING;
            break;
        case SAI_PORT_STP_STATE_BLOCKING:
            switch_stp_state = SWITCH_PORT_STP_STATE_BLOCKING;
            break;
    }
    status = switch_api_stp_port_state_set(device, stp_id,
                                           port_id,
                                           switch_stp_state);

    SAI_LOG_EXIT(SAI_API_STP);

    return (sai_status_t) status;
}
示例#2
0
switch_status_t
switch_api_stp_group_delete(switch_device_t device, switch_handle_t stg_handle)
{
    switch_stp_info_t                 *stp_info = NULL;
    tommy_node                        *node = NULL;
    switch_stp_port_entry_t           *port_entry = NULL;
    switch_stp_vlan_entry_t           *vlan_entry = NULL;

    if (!SWITCH_STP_HANDLE_VALID(stg_handle)) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    stp_info = switch_api_stp_get_internal(stg_handle);
    if (!stp_info) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    node = tommy_list_head(&(stp_info->port_list));
    while (node) {
        port_entry = node->data;
        node = node->next;
        switch_api_stp_port_state_set(device, stg_handle,
                          port_entry->intf_handle,
                          SWITCH_PORT_STP_STATE_NONE);
    }
    node = tommy_list_head(&(stp_info->vlan_list));
    while (node) {
        vlan_entry = node->data;
        node = node->next;
        switch_api_stp_group_vlans_remove(device, 
                                          stg_handle, 1,
                                          &vlan_entry->bd_handle);
    }
    switch_stg_handle_delete(stg_handle);
    return SWITCH_STATUS_SUCCESS;
}