/* * Copyright (c) 2015 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * interface_funcs.h: VNET interfaces/sub-interfaces exported functions * * Copyright (c) 2008 Eliot Dresselhaus * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef included_vnet_interface_funcs_h #define included_vnet_interface_funcs_h always_inline vnet_hw_interface_t * vnet_get_hw_interface (vnet_main_t * vnm, u32 hw_if_index) { return pool_elt_at_index (vnm->interface_main.hw_interfaces, hw_if_index); } always_inline vnet_hw_interface_t * vnet_get_hw_interface_or_null (vnet_main_t * vnm, u32 hw_if_index) { if (!pool_is_free_index (vnm->interface_main.hw_interfaces, hw_if_index)) return pool_elt_at_index (vnm->interface_main.hw_interfaces, hw_if_index); return (NULL); } always_inline vnet_sw_interface_t * vnet_get_sw_interface (vnet_main_t * vnm, u32 sw_if_index) { return pool_elt_at_index (vnm->interface_main.sw_interfaces, sw_if_index); } always_inline vnet_sw_interface_t * vnet_get_sw_interface_or_null (vnet_main_t * vnm, u32 sw_if_index) { if (!pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index)) return pool_elt_at_index (vnm->interface_main.sw_interfaces, sw_if_index); return (NULL); } always_inline vnet_sw_interface_t * vnet_get_hw_sw_interface (vnet_main_t * vnm, u32 hw_if_index) { vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, hw->sw_if_index); ASSERT (sw->type == VNET_SW_INTERFACE_TYPE_HARDWARE); return sw; } always_inline vnet_sw_interface_t * vnet_get_sup_sw_interface (vnet_main_t * vnm, u32 sw_if_index) { vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, sw_if_index); if (sw->type == VNET_SW_INTERFACE_TYPE_SUB || sw->type == VNET_SW_INTERFACE_TYPE_PIPE || sw->type == VNET_SW_INTERFACE_TYPE_P2P) sw = vnet_get_sw_interface (vnm, sw->sup_sw_if_index); return sw; } always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface (vnet_main_t * vnm, u32 sw_if_index) { vnet_sw_interface_t *sw = vnet_get_sup_sw_interface (vnm, sw_if_index); ASSERT ((sw->type == VNET_SW_INTERFACE_TYPE_HARDWARE) || (sw->type == VNET_SW_INTERFACE_TYPE_PIPE)); return vnet_get_hw_interface (vnm, sw->hw_if_index); } always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface_api_visible_or_null (vnet_main_t * vnm, u32 sw_if_index) { vnet_sw_interface_t *si; if (PREDICT_FALSE (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))) return NULL; si = vnet_get_sup_sw_interface (vnm, sw_if_index); if (PREDICT_FALSE (si->flags & VNET_SW_INTERFACE_FLAG_HIDDEN)) return NULL; ASSERT ((si->type == VNET_SW_INTERFACE_TYPE_HARDWARE) || (si->type == VNET_SW_INTERFACE_TYPE_PIPE)); return vnet_get_hw_interface (vnm, si->hw_if_index); } always_inline vnet_hw_interface_class_t * vnet_get_hw_interface_class (vnet_main_t * vnm, u32 hw_class_index) { return vec_elt_at_index (vnm->interface_main.hw_interface_classes, hw_class_index); } always_inline vnet_device_class_t * vnet_get_device_class (vnet_main_t * vnm, u32 dev_class_index) { return vec_elt_at_index (vnm->interface_main.device_classes, dev_class_index); } static inline u8 * vnet_get_sw_interface_tag (vnet_main_t * vnm, u32 sw_if_index) { uword *p; p = hash_get (vnm->interface_tag_by_sw_if_index, sw_if_index); if (p) return ((u8 *) p[0]); return 0; } static inline void vnet_set_sw_interface_tag (vnet_main_t * vnm, u8 * tag, u32 sw_if_index) { uword *p; p = hash_get (vnm->interface_tag_by_sw_if_index, sw_if_index); if (p) { u8 *oldtag = (u8 *) p[0]; hash_unset (vnm->interface_tag_by_sw_if_index, sw_if_index); vec_free (oldtag); } hash_set (vnm->interface_tag_by_sw_if_index, sw_if_index, tag); } static inline void vnet_clear_sw_interface_tag (vnet_main_t * vnm, u32 sw_if_index) { uword *p; p = hash_get (vnm->interface_tag_by_sw_if_index, sw_if_index); if (p) { u8 *oldtag = (u8 *) p[0]; hash_unset (vnm->interface_tag_by_sw_if_index, sw_if_index); vec_free (oldtag); } } /** * Walk return code */ typedef enum walk_rc_t_ { WALK_STOP, WALK_CONTINUE, } walk_rc_t; /*
VPPAPICLIENT_19.01 {
global:
vac_read;
vac_write;
vac_connect;
vac_disconnect;
vac_set_error_handler;
vac_msg_table_max_index;
vac_get_msg_index;
vac_rx_suspend;
vac_rx_resume;
vac_free;
vac_msg_table_size;
api_main;
stat_client_get;
stat_client_free;
stat_segment_connect_r;
stat_segment_connect;
stat_segment_disconnect_r;
stat_segment_disconnect;
stat_segment_ls_r;
stat_segment_ls;
stat_segment_dump_r;
stat_segment_dump;
stat_segment_data_free;
stat_segment_heartbeat_r;
stat_segment_heartbeat;
stat_segment_string_vector;
stat_segment_vec_len;
stat_segment_vec_free;
local: *;
};