Beispiel #1
0
void __of1x_dump_instructions(of1x_instruction_group_t group, bool raw_nbo){

	unsigned int i,has_write_actions=0, has_apply_actions=0;

	ROFL_PIPELINE_INFO("\t\tInst->> ");

	for(i=0;i<OF1X_IT_MAX;i++){

		//Check all instructions in order 
		switch(group.instructions[i].type){
			case OF1X_IT_APPLY_ACTIONS:  
					ROFL_PIPELINE_INFO_NO_PREFIX(" APPLY, ");
					has_apply_actions++;
					break;
    			case OF1X_IT_CLEAR_ACTIONS: 
					ROFL_PIPELINE_INFO_NO_PREFIX(" CLEAR, ");
					break;
			case OF1X_IT_WRITE_ACTIONS: 
					ROFL_PIPELINE_INFO_NO_PREFIX(" WRITE, ");
					has_write_actions++;
					break;
    			case OF1X_IT_WRITE_METADATA:
					ROFL_PIPELINE_INFO_NO_PREFIX(" WRITE-META(0x%"PRIx64":0x%"PRIx64"), ", group.instructions[i].write_metadata.metadata, group.instructions[i].write_metadata.metadata_mask);
					break;
			case OF1X_IT_EXPERIMENTER: //TODO:
					ROFL_PIPELINE_INFO_NO_PREFIX(" EXP, ");
					break;
    			case OF1X_IT_GOTO_TABLE:  
					ROFL_PIPELINE_INFO_NO_PREFIX(" GOTO(%u), ",group.instructions[i].go_to_table);
					break;
    			
			case OF1X_IT_METER:  //TODO implement
				assert(0);
				break;
				
			case OF1X_IT_NO_INSTRUCTION: //Empty instruction
				break;
		}
	}
	ROFL_PIPELINE_INFO_NO_PREFIX("\n");
	if( has_apply_actions ){
		ROFL_PIPELINE_INFO("\t\t\tAPP.ACTIONs:");
		__of1x_dump_action_group(group.instructions[OF1X_IT_APPLY_ACTIONS].apply_actions, raw_nbo);
		ROFL_PIPELINE_INFO_NO_PREFIX("\n");
	}
	if( has_write_actions ){
		ROFL_PIPELINE_INFO("\t\t\tWR.ACTIONs:");
		__of1x_dump_write_actions(group.instructions[OF1X_IT_WRITE_ACTIONS].write_actions, raw_nbo);
		ROFL_PIPELINE_INFO_NO_PREFIX("\n");
	}	
}
Beispiel #2
0
/* Dump methods */
void of1x_dump_table(of1x_flow_table_t* table, bool raw_nbo){
	of1x_flow_entry_t* entry;
	int i;	

	ROFL_PIPELINE_INFO("\n"); //This is done in purpose 
	ROFL_PIPELINE_INFO("Dumping table # %u (%p). Default action: %u. # of entries: %d\n", table->number, table, table->default_action,table->num_of_entries);
	
	if(!table->entries){
		ROFL_PIPELINE_INFO("\t[*] No entries\n");
		return;	
	}
	for(entry=table->entries, i=0;entry!=NULL;entry=entry->next,i++){
		ROFL_PIPELINE_INFO("\t[%d] ",i);
		of1x_dump_flow_entry(entry, raw_nbo);
	}
	
	ROFL_PIPELINE_INFO("\t[*] No more entries...\n");
	
	if(of1x_matching_algorithms[table->matching_algorithm].dump_hook){
		ROFL_PIPELINE_INFO("\tMatching algorithm %u specific state\n", table->matching_algorithm);
		of1x_matching_algorithms[table->matching_algorithm].dump_hook(table, raw_nbo);
	}
}
Beispiel #3
0
//Dump packet matches
void dump_packet_matches(datapacket_t *const pkt, bool raw_nbo){

	packet_matches_t matches;
	packet_matches_t* m = &matches;

	//Prefill packet matches	
	fill_packet_matches(pkt, m);
	
	ROFL_PIPELINE_INFO("Packet[%p] {", pkt);	
	
	//Ports
	if(m->__port_in)
		ROFL_PIPELINE_INFO_NO_PREFIX("PORT_IN:%u, ",m->__port_in);
	if(m->__phy_port_in)
		ROFL_PIPELINE_INFO_NO_PREFIX("PHY_PORT_IN:%u, ",m->__phy_port_in);
	
	//Metadata
	if(m->__metadata)
		ROFL_PIPELINE_INFO_NO_PREFIX("METADATA: 0x%" PRIx64 ", ",m->__metadata);
	
	//802	
	if(m->__eth_src){
		uint64_t tmp = m->__eth_src;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("ETH_SRC:0x%"PRIx64", ", tmp);
	}
	if(m->__eth_dst){
		uint64_t tmp = m->__eth_dst;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("ETH_DST:0x%"PRIx64", ", tmp);
	}
	if(m->__eth_type)
		ROFL_PIPELINE_INFO_NO_PREFIX("ETH_TYPE:0x%x, ", COND_NTOHB16(raw_nbo,m->__eth_type));

	//802.1q
	if(m->__has_vlan)
		ROFL_PIPELINE_INFO_NO_PREFIX("VLAN_VID:%u, ", COND_NTOHB16(raw_nbo,m->__vlan_vid));
	if(m->__has_vlan){
		uint8_t tmp = m->__vlan_pcp;
		if(!raw_nbo)
			tmp = OF1X_VLAN_PCP_VALUE(tmp);
		ROFL_PIPELINE_INFO_NO_PREFIX("VLAN_PCP:%u, ", tmp);
	}
	//ARP
	if(m->__eth_type == ETH_TYPE_ARP)
		ROFL_PIPELINE_INFO_NO_PREFIX("ARP_OPCODE:0x%x, ", COND_NTOHB16(raw_nbo,m->__arp_opcode));
	if(m->__eth_type == ETH_TYPE_ARP){
		uint64_t tmp = m->__arp_sha;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("ARP_SHA:0x%"PRIx64", ", tmp);
	}
	if(m->__eth_type == ETH_TYPE_ARP)
		ROFL_PIPELINE_INFO_NO_PREFIX("ARP_SPA:0x%x, ", COND_NTOHB32(raw_nbo,m->__arp_spa));
	if(m->__eth_type == ETH_TYPE_ARP){
		uint64_t tmp = m->__arp_tha;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("ARP_THA:0x%"PRIx64", ", tmp); 
	}
	if(m->__eth_type == ETH_TYPE_ARP)
		ROFL_PIPELINE_INFO_NO_PREFIX("ARP_TPA:0x%x, ", COND_NTOHB32(raw_nbo,m->__arp_tpa));
	//IP/IPv4
	if((m->__eth_type == ETH_TYPE_IPV4 || m->__eth_type == ETH_TYPE_IPV6) && m->__ip_proto)
		ROFL_PIPELINE_INFO_NO_PREFIX("IP_PROTO:%u, ",m->__ip_proto);

	if((m->__eth_type == ETH_TYPE_IPV4 || m->__eth_type == ETH_TYPE_IPV6) && m->__ip_ecn)
		ROFL_PIPELINE_INFO_NO_PREFIX("IP_ECN:0x%x, ",m->__ip_ecn);
	
	if((m->__eth_type == ETH_TYPE_IPV4 || m->__eth_type == ETH_TYPE_IPV6) && m->__ip_dscp){
		uint8_t tmp = m->__ip_dscp;
		if(!raw_nbo)
			tmp = OF1X_IP_DSCP_VALUE(tmp); 
		
		ROFL_PIPELINE_INFO_NO_PREFIX("IP_DSCP:0x%x, ", tmp);
	}
	
	if(m->__ipv4_src)
		ROFL_PIPELINE_INFO_NO_PREFIX("IPV4_SRC:0x%x, ", COND_NTOHB32(raw_nbo,m->__ipv4_src));
	if(m->__ipv4_dst)
		ROFL_PIPELINE_INFO_NO_PREFIX("IPV4_DST:0x%x, ", COND_NTOHB32(raw_nbo,m->__ipv4_dst));
	//TCP
	if(m->__tcp_src)
		ROFL_PIPELINE_INFO_NO_PREFIX("TCP_SRC:%u, ", COND_NTOHB16(raw_nbo,m->__tcp_src));
	if(m->__tcp_dst)
		ROFL_PIPELINE_INFO_NO_PREFIX("TCP_DST:%u, ", COND_NTOHB16(raw_nbo,m->__tcp_dst));
	//UDP
	if(m->__udp_src)
		ROFL_PIPELINE_INFO_NO_PREFIX("UDP_SRC:%u, ", COND_NTOHB16(raw_nbo,m->__udp_src));
	if(m->__udp_dst)
		ROFL_PIPELINE_INFO_NO_PREFIX("UDP_DST:%u, ", COND_NTOHB16(raw_nbo,m->__udp_dst));

	//SCTP
	if(m->__sctp_src)
		ROFL_PIPELINE_INFO_NO_PREFIX("SCTP_SRC:%u, ", COND_NTOHB16(raw_nbo,m->__sctp_src));
	if(m->__sctp_dst)
		ROFL_PIPELINE_INFO_NO_PREFIX("SCTP_DST:%u, ", COND_NTOHB16(raw_nbo,m->__sctp_dst));

	//ICMPV4
	if(m->__ip_proto == IP_PROTO_ICMPV4)
		ROFL_PIPELINE_INFO_NO_PREFIX("ICMPV4_TYPE:%u, ICMPV4_CODE:%u, ",m->__icmpv4_type,m->__icmpv4_code);
	
	//IPv6
	if( UINT128__T_LO(m->__ipv6_src) || UINT128__T_HI(m->__ipv6_src) ){
		uint128__t tmp = m->__ipv6_src;
		(void)tmp;
		if(!raw_nbo)
			NTOHB128(tmp); 	
		ROFL_PIPELINE_INFO_NO_PREFIX("IPV6_SRC:0x%lx:%lx, ",UINT128__T_HI(tmp),UINT128__T_LO(tmp));
	}
	if( UINT128__T_LO(m->__ipv6_dst) || UINT128__T_HI(m->__ipv6_dst) ){
		uint128__t tmp = m->__ipv6_dst;
		(void)tmp;
		if(!raw_nbo)
			NTOHB128(tmp); 
		ROFL_PIPELINE_INFO_NO_PREFIX("IPV6_DST:0x%lx:%lx, ",UINT128__T_HI(tmp),UINT128__T_LO(tmp));
	}
	if(m->__eth_type == ETH_TYPE_IPV6){
		uint32_t tmp = m->__ipv6_flabel;
		if(!raw_nbo)
			tmp = OF1X_IP6_FLABEL_VALUE(NTOHB32(tmp));		
		ROFL_PIPELINE_INFO_NO_PREFIX("IPV6_FLABEL:0x%lu, ", tmp);
	}
	if(m->__ip_proto == IP_PROTO_ICMPV6){
		uint128__t tmp = m->__ipv6_nd_target; 
		(void)tmp;
		if(!raw_nbo)
			NTOHB128(tmp); 	
		ROFL_PIPELINE_INFO_NO_PREFIX("IPV6_ND_TARGET:0x%lx:%lx, ",UINT128__T_HI(tmp),UINT128__T_LO(tmp));
	}
	if(m->__ip_proto == IP_PROTO_ICMPV6){
		//NOTE && m->__icmpv6_type ==?
		uint64_t tmp = m->__ipv6_nd_sll;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));

		ROFL_PIPELINE_INFO_NO_PREFIX("IPV6_ND_SLL:0x%"PRIx64", ", tmp);
	}
	if(m->__ip_proto == IP_PROTO_ICMPV6){
		//NOTE && m->__icmpv6_type ==?
		uint64_t tmp = m->__ipv6_nd_tll; 
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("IPV6_ND_TLL:0x%"PRIx64", ", tmp);
	} 
	/*TODO IPV6 exthdr*/
	/*nd_target nd_sll nd_tll exthdr*/
	
	//ICMPv6
	if(m->__ip_proto == IP_PROTO_ICMPV6)
		ROFL_PIPELINE_INFO_NO_PREFIX("ICMPV6_TYPE:%lu, ICMPV6_CODE:%lu, ",m->__icmpv6_type,m->__icmpv6_code);
	
	//MPLS	
   	if(m->__eth_type == ETH_TYPE_MPLS_UNICAST || m->__eth_type == ETH_TYPE_MPLS_MULTICAST ){
		uint8_t tmp_tc = m->__mpls_tc;
		uint32_t tmp_label = m->__mpls_label; 
		if(!raw_nbo){
			tmp_tc = OF1X_MPLS_TC_VALUE(tmp_tc);
			tmp_label = OF1X_MPLS_LABEL_VALUE(NTOHB32(tmp_label));
		}
		ROFL_PIPELINE_INFO_NO_PREFIX("MPLS_LABEL:0x%x, MPLS_TC:0x%x, MPLS_BOS:%u", tmp_label, tmp_tc, m->__mpls_bos);
	}

	//PBB
	if(m->__pbb_isid)
		ROFL_PIPELINE_INFO_NO_PREFIX("PBB_ISID:%u,", COND_NTOHB32(raw_nbo,m->__pbb_isid));
	//Tunnel id
	if(m->__tunnel_id)
		ROFL_PIPELINE_INFO_NO_PREFIX("TUNNEL ID:0x%"PRIx64", ", COND_NTOHB64(raw_nbo,m->__tunnel_id));

#ifdef ROFL_EXPERIMENTAL
	//PPPoE
	if(m->__eth_type == ETH_TYPE_PPPOE_DISCOVERY || m->__eth_type == ETH_TYPE_PPPOE_SESSION ){
		ROFL_PIPELINE_INFO_NO_PREFIX("PPPOE_CODE:0x%x, PPPOE_TYPE:0x%x, PPPOE_SID:0x%x, ",m->__pppoe_code, m->__pppoe_type,COND_NTOHB16(raw_nbo, m->__pppoe_sid));
		//PPP
		if(m->__eth_type == ETH_TYPE_PPPOE_SESSION)
			ROFL_PIPELINE_INFO_NO_PREFIX("PPP_PROTO:0x%x, ",m->__ppp_proto);
				
	}

	//GTP
	if(m->__ip_proto == IP_PROTO_UDP && m->__udp_dst == UDP_DST_PORT_GTPU){
		ROFL_PIPELINE_INFO_NO_PREFIX("GTP_MSG_TYPE:%u, GTP_TEID:0x%x, ",m->__gtp_msg_type,  COND_NTOHB32(raw_nbo, m->__gtp_teid));
	}

	//CAPWAP
	if((m->__ip_proto == IP_PROTO_UDP) && ((m->__udp_dst == UDP_DST_PORT_CAPWAPC) || (m->__udp_dst == UDP_DST_PORT_CAPWAPU))) {
		ROFL_PIPELINE_INFO_NO_PREFIX("CAPWAP_WBID:%u, CAPWAP_RID:%u, CAPWAP_FLAGS:0x%x, ", m->__capwap_wbid, m->__capwap_rid, COND_NTOHB16(raw_nbo, m->__capwap_flags));
	}

	//WLAN
	if(m->__wlan_fc)
		ROFL_PIPELINE_INFO_NO_PREFIX("WLAN_FC:0x%x,", COND_NTOHB16(raw_nbo, m->__wlan_fc));
	if(m->__wlan_type)
		ROFL_PIPELINE_INFO_NO_PREFIX("WLAN_TYPE:%u,", m->__wlan_type);
	if(m->__wlan_subtype)
		ROFL_PIPELINE_INFO_NO_PREFIX("WLAN_SUBTYPE:%u,", m->__wlan_type);
	if(m->__wlan_direction)
		ROFL_PIPELINE_INFO_NO_PREFIX("WLAN_DIRECTION:%u,", m->__wlan_direction);
	if(m->__wlan_address_1){
		uint64_t tmp = m->__wlan_address_1;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("WLAN_ADDRESS_1:0x%"PRIx64", ", tmp);
	}
	if(m->__wlan_address_2){
		uint64_t tmp = m->__wlan_address_2;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("WLAN_ADDRESS_2:0x%"PRIx64", ", tmp);
	}
	if(m->__wlan_address_3){
		uint64_t tmp = m->__wlan_address_3;
		if(!raw_nbo)
			tmp = OF1X_MAC_VALUE(NTOHB64(tmp));
		ROFL_PIPELINE_INFO_NO_PREFIX("WLAN_ADDRESS_3:0x%"PRIx64", ", tmp);
	}
#endif
	
	ROFL_PIPELINE_INFO_NO_PREFIX("}\n");	

	//Add more here...	
}