# 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 = { 'map_add_domain': {'mtu': 1280}, 'syslog_set_sender': {'collector_port': 514, 'max_msg_size': 480}, 'acl_interface_add_del': {'is_add': 1, 'is_input': 1}, 'acl_interface_list_dump': {'sw_if_index': 4294967295, }, 'app_namespace_add_del': {'sw_if_index': 4294967295, }, '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, }, 'bond_create': {'mac_address': '', 'id': 0xFFFFFFFF}, 'bridge_domain_add_del': {'flood': 1, 'uu_flood': 1, 'forward': 1, 'learn': 1, 'is_add': 1, }, 'bvi_create': {'user_instance': 4294967295, }, '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_punt_police': {'is_add': 1, }, 'ip_punt_redirect': {'is_add': 1, }, 'ip_route_add_del': {'is_add': 1, }, 'ip_unnumbered_dump': {'sw_if_index': 4294967295, }, 'ipsec_interface_add_del_spd': {'is_add': 1, }, 'ipsec_sad_entry_add_del': {'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, }, 'lb_conf': {'sticky_buckets_per_core': 4294967295, 'flow_timeout': 4294967295}, '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_add_replace': {'acl_index': 4294967295, }, 'macip_acl_dump': {'acl_index': 4294967295, }, '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_
from trex_stl_lib.api import *
# step is not 1.
class STLS1(object):
def __init__ (self):
self.fsize =64; # the size of the packet
def create_stream (self):
# Create base packet and pad it to size
size = self.fsize - 4; # HW will add 4 bytes ethernet FCS
base_pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
pad = max(0, size - len(base_pkt)) * 'x'
vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=0, max_value=10, size=2, op="inc",step=1),
STLVmWrMaskFlowVar(fv_name="mac_src", pkt_offset= 10,pkt_cast_size=1, mask=0xff,add_value=5,shift=0) # range is 5-15
]
)
return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
mode = STLTXCont( pps=10 ))
def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
# dynamic load - used for trex console or simulator
def register():
return STLS1()