def __create_counter(): if _args['table_id'] == None: print( 'Missing mandatory attributes to create counter-Required table-id') sys.exit(1) counter_id = nas_acl.create_counter(table_id=int(_args['table_id']), types=['PACKET']) return counter_id
def acl_ut_counter_create(table_id, types=[]): global total, passed total.append(sys._getframe().f_code.co_name) try: cid = nas_acl.create_counter(table_id=table_id, types=types) except RuntimeError: print (sys._getframe().f_code.co_name + " - Error creating Counter") return None print (sys._getframe().f_code.co_name + " - Created Counter " + str(cid)) passed.append(sys._getframe().f_code.co_name) return cid
import nas_acl # # ACL Table to hold the ACL Entries. # tid = nas_acl.create_table( stage='INGRESS', prio=99, allow_filters=['DST_IP', 'SRC_MAC', 'IN_PORT', 'DSCP']) # # ACL Entry to drop all packets received from MAC 50:10:6e:xx:xx:xx on port 23 # # ACL counter to count number of dropped packets counter_mac = nas_acl.create_counter(table_id=tid, types=['PACKET']) # CPS Create the ACL entry eid_mac = nas_acl.create_entry(table_id=tid, prio=512, filter_map={ 'SRC_MAC': { 'addr': '50:10:6e:00:00:00', 'mask': 'ff:ff:ff:00:00:00' }, 'IN_PORT': 23 }, action_map={ 'PACKET_ACTION': 'DROP', 'SET_COUNTER': counter_mac }) #
if len(sys.argv) <= 1: print "Usage ./nas_acl_example.py <table-priority> <entry-priority>" sys.exit(0) # Create ACL Table with a list of allowed filters tid = nas_acl.create_table(stage='INGRESS', prio=sys.argv[1], allow_filters=[ 'SRC_IP', 'SRC_MAC', 'DST_MAC', 'DST_IP', 'IP_TYPE', 'TCP_FLAGS', 'ECN', 'IPV6_FLOW_LABEL', 'IN_PORT']) if len(sys.argv) < 3: sys.exit(0) # Create ACL counter for this Table counter_id = nas_acl.create_counter(table_id=tid) # Create Mirroring sessions mirr_id_1, mirr_opq_1 = a_utl.mirror_create(15) mirr_id_2, mirr_opq_2 = a_utl.mirror_create(16) # # Example shows how various filters and actions can be specified for ACL entry create # filters = { 'SRC_MAC': '01:80:c2:00:00:05', # Auto apply default mask 'IPV6_FLOW_LABEL': '34456',
sys.exit(0) # Create ACL Table with a list of allowed filters tid = nas_acl.create_table(stage='INGRESS', prio=sys.argv[1], allow_filters=[ 'SRC_IP', 'SRC_MAC', 'DST_MAC', 'DST_IP', 'IP_TYPE', 'TCP_FLAGS', 'ECN', 'IPV6_FLOW_LABEL', 'IN_PORT' ]) if len(sys.argv) < 3: sys.exit(0) # Create ACL counter for this Table counter_id = nas_acl.create_counter(table_id=tid) # Create Mirroring sessions mirr_id_1, mirr_opq_1 = a_utl.mirror_create(15) mirr_id_2, mirr_opq_2 = a_utl.mirror_create(16) # # Example shows how various filters and actions can be specified for ACL entry create # filters = { 'SRC_MAC': '01:80:c2:00:00:05', # Auto apply default mask 'IPV6_FLOW_LABEL': '34456', 'SRC_IP': { 'addr': '23.0.0.1',
import nas_acl # # ACL Table to hold the ACL Entries. # tid = nas_acl.create_table(stage='INGRESS', prio=99, allow_filters=['DST_IP', 'SRC_MAC', 'IN_PORT', 'DSCP']) # # ACL Entry to drop all packets received from MAC 50:10:6e:xx:xx:xx on port 23 # # ACL counter to count number of dropped packets counter_mac = nas_acl.create_counter(table_id=tid, types=['PACKET']) # CPS Create the ACL entry eid_mac = nas_acl.create_entry(table_id=tid, prio=512, filter_map={'SRC_MAC': {'addr':'50:10:6e:00:00:00', 'mask':'ff:ff:ff:00:00:00'}, 'IN_PORT': 23}, action_map={'PACKET_ACTION': 'DROP', 'SET_COUNTER': counter_mac}) # # ACL Entry to set traffic class for packets destined to IP 23.0.0.1 # with a DSCP range 8-15 # # ACL counter to count number of dropped packets counter_ip = nas_acl.create_counter(table_id=tid, types=['PACKET']) # CPS Create the ACL entry