def __show_stats(): if _args['table_id'] == None or _args['counter_id'] == None: print( 'Missing attributes to show stats - Needed table-id and counter-id' ) sys.exit(1) nas_acl.print_stats(int(_args['table_id']), int(_args['counter_id']))
def acl_ut_stats_get(table_id=None, counter_id=None): global total, passed total.append(sys._getframe().f_code.co_name) try: print '#### Stats Show ####' nas_acl.print_stats(table_id, entry_id) passed.append(sys._getframe().f_code.co_name) except RuntimeError: print (sys._getframe().f_code.co_name + ": Error in Get")
def main(): tid = nas_acl.create_table(stage='EGRESS', prio=99, allow_filters=[ 'SRC_IP', 'DST_IP', 'IN_PORT', 'OUT_PORT', 'L4_SRC_PORT', 'L4_DST_PORT' ]) # # ACL Entry to drop all packets received from DST_IP on L4_DST_PORT # # 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_tcp = nas_acl.create_entry(table_id=tid, prio=512, filter_map={ 'SRC_IP': { 'addr': '23.0.0.1', 'mask': '255.0.0.0' }, 'L4_SRC_PORT': 443, }, action_map={'PACKET_ACTION': 'DROP'}) """ eid_ip = nas_acl.create_entry(table_id=tid, prio=511, filter_map={'DST_IP': '23.0.0.1', 'DSCP': {'data':0x08, 'mask':0x38}}, action_map={'SET_TC': 4, 'SET_COUNTER': counter_ip}) """ # Print both entries in ACL table nas_acl.print_entry(tid) #return tid,eid_mac #raw_input("Press Enter to clean up the ACL entries and table ...") # Print the ACL stats object #nas_acl.print_stats(tid, counter_ip) nas_acl.print_stats(tid)
eid_ip = nas_acl.create_entry(table_id=tid, prio=511, filter_map={ 'DST_IP': '23.0.0.1', 'DSCP': { 'data': 0x08, 'mask': 0x38 } }, action_map={ 'SET_TC': 4, 'SET_COUNTER': counter_ip }) # Print both entries in ACL table nas_acl.print_entry(tid) raw_input("Press Enter to clean up the ACL entries and table ...") # Print the ACL stats object nas_acl.print_stats(tid, counter_ip) nas_acl.print_stats(tid, counter_mac) # Clean up nas_acl.delete_entry(tid, eid_ip) nas_acl.delete_entry(tid, eid_mac) nas_acl.delete_counter(tid, counter_ip) nas_acl.delete_counter(tid, counter_mac) nas_acl.delete_table(tid) print "Clean up Successful"
# # 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 eid_ip = nas_acl.create_entry(table_id=tid, prio=511, filter_map={'DST_IP': '23.0.0.1', 'DSCP': {'data':0x08, 'mask':0x38}}, action_map={'SET_TC': 4, 'SET_COUNTER': counter_ip}) # Print both entries in ACL table nas_acl.print_entry(tid) raw_input("Press Enter to clean up the ACL entries and table ...") # Print the ACL stats object nas_acl.print_stats(tid, counter_ip) nas_acl.print_stats(tid, counter_mac) # Clean up nas_acl.delete_entry(tid, eid_ip) nas_acl.delete_entry(tid, eid_mac) nas_acl.delete_counter(tid, counter_ip) nas_acl.delete_counter(tid, counter_mac) nas_acl.delete_table(tid) print "Clean up Successful"