# NB NB NB NB NB NB NB NB NB NB NB # # NOTE: The API binary wrappers in this file are in the process of being # deprecated. DO NOT ADD NEW WRAPPERS HERE. Call the functions using # named arguments directly instead. # import os import time from collections import deque from six import moves, iteritems from vpp_papi import VPPApiClient, mac_pton from hook import Hook from vpp_ip_route import MPLS_IETF_MAX_LABEL, MPLS_LABEL_INVALID # # Dictionary keyed on message name to override default values for # named parameters # defaultmapping = { 'acl_interface_add_del': {'is_add': 1, 'is_input': 1}, 'bd_ip_mac_add_del': {'is_add': 1, }, 'bfd_udp_add': {'is_authenticated': False, 'bfd_key_id': None, 'conf_key_id': None}, 'bfd_udp_auth_activate': {'bfd_key_id': None, 'conf_key_id': None, 'is_delayed': False}, 'bier_disp_entry_add_del': {'next_hop_rpf_id': -1, 'next_hop_is_ip4': 1, 'is_add': 1, }, 'bier_disp_table_add_del': {'is_add': 1, }, 'bier_imp_add': {'is_add': 1, }, 'bier_route_add_del': {'is_add': 1, }, 'bier_table_add_del': {'is_add': 1, }, 'bridge_domain_add_del': {'flood': 1, 'uu_flood': 1, 'forward': 1, 'learn': 1, 'is_add': 1, }, 'bvi_delete': {}, 'gbp_subnet_add_del': {'sw_if_index': 4294967295, 'epg_id': 65535, }, 'geneve_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1, 'decap_next_index': 4294967295, }, 'input_acl_set_interface': {'ip4_table_index': 4294967295, 'ip6_table_index': 4294967295, 'l2_table_index': 4294967295, }, 'ip6_add_del_address_using_prefix': {'is_add': 1, }, 'ip6nd_send_router_solicitation': {'irt': 1, 'mrt': 120, }, 'ip_add_del_route': {'next_hop_sw_if_index': 4294967295, 'next_hop_weight': 1, 'next_hop_via_label': 1048576, 'classify_table_index': 4294967295, 'is_add': 1, }, 'ip_mroute_add_del': {'is_add': 1, }, 'ip_neighbor_add_del': {'is_add': 1, }, 'ip_route_add_del': {'is_add': 1, }, 'ipsec_interface_add_del_spd': {'is_add': 1, }, 'ipsec_spd_add_del': {'is_add': 1, }, 'ipsec_spd_dump': {'sa_id': 4294967295, }, 'ipsec_spd_entry_add_del': {'local_port_stop': 65535, 'remote_port_stop': 65535, 'priority': 100, 'is_outbound': 1, 'is_add': 1, }, 'ipsec_tunnel_if_add_del': {'is_add': 1, 'anti_replay': 1, }, 'l2_emulation': {'enable': 1, }, 'l2fib_add_del': {'is_add': 1, }, 'lisp_add_del_adjacency': {'is_add': 1, }, 'lisp_add_del_local_eid': {'is_add': 1, }, 'lisp_add_del_locator': {'priority': 1, 'weight': 1, 'is_add': 1, }, 'lisp_add_del_locator_set': {'is_add': 1, }, 'lisp_add_del_remote_mapping': {'is_add': 1, }, 'macip_acl_interface_add_del': {'is_add': 1, }, 'mpls_ip_bind_unbind': {'is_ip4': 1, 'is_bind': 1, }, 'mpls_route_add_del': {'mr_next_hop_sw_if_index': 4294967295, 'mr_next_hop_weight': 1, 'mr_next_hop_via_label': 1048576, 'mr_is_add': 1, 'mr_classify_table_index': 4294967295, }, 'mpls_table_add_del': {'is_add': 1, }, 'mpls_tunnel_add_del': {'next_hop_sw_if_index': 4294967295, 'next_hop_weight': 1, 'next_hop_via_label': 1048576, 'is_add': 1, }, 'output_acl_set_interface': {'ip4_table_index': 4294967295, 'ip6_table_index': 4294967295, 'l2_table_index': 4294967295, }, 'pppoe_add_del_session': {'is_add': 1, }, 'policer_add_del': {'is_add': 1, 'conform_action': {'type': 1}, }, 'set_ipfix_exporter': {'collector_port': 4739, }, 'sr_policy_add': {'weight': 1, 'is_encap': 1, }, 'sw_interface_add_del_address': {'is_add': 1, }, 'sw_interface_ip6nd_ra_prefix': {'val_lifetime': 4294967295, 'pref_lifetime': 4294967295, }, 'sw_interface_set_ip_directed_broadcast': {'enable': 1, }, 'sw_interface_set_l2_bridge': {'enable': 1, }, 'sw_interface_set_mpls_enable': {'enable': 1, }, 'sw_interface_set_mtu': {'mtu': [0, 0, 0, 0], }, 'sw_interface_set_unnumbered': {'is_add': 1, }, 'sw_interface_span_enable_disable': {'state': 1, }, 'vxlan_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1, 'decap_next_index': 4294967295, 'instance': 4294967295, }, 'vxlan_gpe_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1, 'protocol': 3, }, 'want_bfd_events': {'enable_disable': 1, }, 'want_igmp_events': {'enable': 1, }, 'want_interface_events': {'enable_disable': 1, }, 'want_l2_macs_events': {'enable_disable': 1, 'pid': os.getpid(), }, 'want_l2_macs_events2': {'enable_disable': 1, 'pid': os.getpid(), }, } def as_fn_signature(d): return ", ".join(f"{k}={v}" for k, v in d.items()) class CliFailedCommandError(Exception): """ cli command failed.""" class CliSyntaxError(Exception): """ cli command had a syntax error.""" class UnexpectedApiReturnValueError(Exception): """ exception raised when the API return value is unexpected """ pass class VppPapiProvider(object): """VPP-api provider using vpp-papi @property hook: hook object providing before and after api/cli hooks """ _zero, _negative = range(2) def __init__(self, name, shm_prefix, test_class, read_timeout): self.hook = Hook(test_class) self.name = name self.shm_prefix = shm_prefix self.test_class = test_class self._expect_api_retval = self._zero self._expect_stack = [] # install_dir is a class attribute. We need to set it before # calling the constructor. VPPApiClient.apidir = os.getenv('VPP_INSTALL_PATH') use_socket = False try: if os.environ['SOCKET'] == '1':
# Copyright (c) 2018 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.
add_vpp_library (vlibmemory
SOURCES
memory_api.c
memory_shared.c
memory_client.c
socket_api.c
vlib_api.c
vlib_api_cli.c
../vlibapi/api_shared.c
../vlibapi/node_serialize.c
INSTALL_HEADERS
vl_memory_msg_enum.h
memory_shared.h
vl_memory_api_h.h
socket_client.h
memory_api.h
api.h
memory_client.h
socket_api.h
API_FILES
memclnt.api
LINK_LIBRARIES vppinfra svm vlib
)
add_dependencies(vlibmemory vlibmemory_api_headers)
add_vpp_library (vlibmemoryclient
SOURCES
memory_shared.c
memory_client.c
socket_client.c
../vlibapi/api_shared.c
../vlibapi/node_serialize.c
LINK_LIBRARIES vppinfra svm
)
add_dependencies(vlibmemoryclient vlibmemory_api_headers)