Ejemplo n.º 1
0
def get_LPM_table_entry(index):
	if index < 0 or index > reg_defines.ROUTER_OP_LUT_ROUTE_TABLE_DEPTH() - 1:
		print 'get_LPM_table_entry_generic: Bad data'
		sys.exit(1)
	nftest_regwrite(reg_defines.ROUTER_OP_LUT_ROUTE_TABLE_RD_ADDR_REG(), index)
	IP = regread('nf2c0', reg_defines.ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_IP_REG())
	mask = regread('nf2c0', reg_defines.ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_MASK_REG())
	next_hop = regread('nf2c0', reg_defines.ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_NEXT_HOP_IP_REG())
	output_port = regread('nf2c0', reg_defines.ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_OUTPUT_PORT_REG())

	ip_str = socket.inet_ntoa(struct.pack('!L', IP))
	mask_str = socket.inet_ntoa(struct.pack('!L', mask))
	next_hop_str = socket.inet_ntoa(struct.pack('!L', next_hop))
	return ip_str + '-' + mask_str + '-' + next_hop_str + "-0x%02x"%output_port
Ejemplo n.º 2
0
def get_router_MAC(port, MAC):
	port = int(port)
	if port < 1 or port > 4:
		print 'bad port number'
	port -= 1
	mac_hi = regread('nf2c0', reg_defines.ROUTER_OP_LUT_MAC_0_HI_REG() + port * 8 )
	mac_lo = regread('nf2c0', reg_defines.ROUTER_OP_LUT_MAC_0_LO_REG() + port * 8 )
	mac_tmp = "%04x%08x"%(mac_hi, mac_lo)
        grp_mac = re.search("^(..)(..)(..)(..)(..)(..)$", mac_tmp).groups()
        str_mac = ''
        for octet in grp_mac:
            str_mac += grp_mac + ":"
        str_mac.rstrip(':')
	return str_mac
Ejemplo n.º 3
0
def get_ARP_table_entry(index):
	if index < 0 or index > reg_defines.ROUTER_OP_LUT_ARP_TABLE_DEPTH()-1:
		print 'check_ARP_table_entry: Bad data'
		sys.exit(1)
	nftest_regwrite(reg_defines.ROUTER_OP_LUT_ARP_TABLE_RD_ADDR_REG(), index)
	IP = regread('nf2c0', reg_defines.ROUTER_OP_LUT_ARP_TABLE_ENTRY_NEXT_HOP_IP_REG())
	mac_hi = regread('nf2c0', reg_defines.ROUTER_OP_LUT_ARP_TABLE_ENTRY_MAC_HI_REG())
	mac_lo = regread('nf2c0', reg_defines.ROUTER_OP_LUT_ARP_TABLE_ENTRY_MAC_LO_REG())

	IP_str = socket.inet_ntoa(struct.pack('!L', IP))
	mac_tmp = "%04x%08x"%(mac_hi, mac_lo)
        grp_mac = re.search("^(..)(..)(..)(..)(..)(..)$", mac_tmp).groups()
        str_mac = ''
        for octet in grp_mac:
            str_mac += octet + ":"
        str_mac = str_mac.rstrip(':')
	return IP_str + '-' + str_mac
Ejemplo n.º 4
0
def get_dst_ip_filter_entry(index):
	if index < 0 or index > reg_defines.ROUTER_OP_LUT_DST_IP_FILTER_TABLE_DEPTH()-1:
		print 'Bad data'
		sys.exit(1)
	nftest_regwrite(reg_defines.ROUTER_OP_LUT_DST_IP_FILTER_TABLE_RD_ADDR_REG(), index)
	return regread('nf2c0', reg_defines.ROUTER_OP_LUT_DST_IP_FILTER_TABLE_ENTRY_IP_REG())