Esempio n. 1
0
//Matches with mask (including matches that do not support)
void __of1x_dump_matches(of1x_match_t* matches, bool raw_nbo){
	of1x_match_t* it;
	for(it=matches;it;it=it->next){
		switch(it->type){
			case OF1X_MATCH_IN_PORT: ROFL_PIPELINE_INFO_NO_PREFIX("[PORT_IN:%u], ", __of1x_get_match_val32(it, false, raw_nbo)); 
				break;
			case OF1X_MATCH_IN_PHY_PORT: ROFL_PIPELINE_INFO_NO_PREFIX("[PHY_PORT_IN:%u], ", __of1x_get_match_val32(it, false, raw_nbo));
				break; 

			case OF1X_MATCH_METADATA: ROFL_PIPELINE_INFO_NO_PREFIX("[METADATA:0x%"PRIx64"|0x%"PRIx64"],  ", __of1x_get_match_val64(it, false, raw_nbo), __of1x_get_match_val64(it, true, raw_nbo)); 
				break;

			case OF1X_MATCH_ETH_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[ETH_DST:0x%"PRIx64"|0x%"PRIx64"],  ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
				break; 
			case OF1X_MATCH_ETH_SRC:  ROFL_PIPELINE_INFO_NO_PREFIX("[ETH_SRC:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
				break; 
			case OF1X_MATCH_ETH_TYPE:  ROFL_PIPELINE_INFO_NO_PREFIX("[ETH_TYPE:0x%x], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 

			case OF1X_MATCH_VLAN_VID:  	if(it->vlan_present == OF1X_MATCH_VLAN_NONE)
								ROFL_PIPELINE_INFO_NO_PREFIX("[NO_VLAN], ");
							else if(it->vlan_present == OF1X_MATCH_VLAN_ANY)
								ROFL_PIPELINE_INFO_NO_PREFIX("[ANY_VLAN], ");
							else
								ROFL_PIPELINE_INFO_NO_PREFIX("[VLAN_ID:%u|0x%x], ",__of1x_get_match_val16(it, false, raw_nbo),__of1x_get_match_val16(it, true, raw_nbo));
				break; 
			case OF1X_MATCH_VLAN_PCP:  ROFL_PIPELINE_INFO_NO_PREFIX("[VLAN_PCP:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 

			case OF1X_MATCH_MPLS_LABEL:  ROFL_PIPELINE_INFO_NO_PREFIX("[MPLS_LABEL:0x%x], ",__of1x_get_match_val32(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_MPLS_TC:  ROFL_PIPELINE_INFO_NO_PREFIX("[MPLS_TC:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_MPLS_BOS:  ROFL_PIPELINE_INFO_NO_PREFIX("[MPLS_BOS:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
				break;

			case OF1X_MATCH_ARP_OP: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_OPCODE:0x%x], ",__of1x_get_match_val16(it, false, raw_nbo));
				break;
			case OF1X_MATCH_ARP_SHA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_SHA:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
				break;
			case OF1X_MATCH_ARP_SPA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_SPA:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break;
			case OF1X_MATCH_ARP_THA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_THA:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
				break;
			case OF1X_MATCH_ARP_TPA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_TPA:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break;

			case OF1X_MATCH_NW_PROTO:  ROFL_PIPELINE_INFO_NO_PREFIX("[NW_PROTO:%u|0x%x], ",__of1x_get_match_val8(it, false, raw_nbo),__of1x_get_match_val8(it, true, raw_nbo));
				break; 
			case OF1X_MATCH_NW_SRC:  ROFL_PIPELINE_INFO_NO_PREFIX("[NW_SRC:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break; 
			case OF1X_MATCH_NW_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("[NW_DST:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break; 

			case OF1X_MATCH_IP_ECN:  ROFL_PIPELINE_INFO_NO_PREFIX("[IP_ECN:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_IP_DSCP:  ROFL_PIPELINE_INFO_NO_PREFIX("[IP_DSCP:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_IP_PROTO:  ROFL_PIPELINE_INFO_NO_PREFIX("[IP_PROTO:%u|0x%x], ",__of1x_get_match_val8(it, false, raw_nbo),__of1x_get_match_val8(it, true, raw_nbo));
				break; 

			case OF1X_MATCH_IPV4_SRC:  ROFL_PIPELINE_INFO_NO_PREFIX("[IP4_SRC:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break; 
			case OF1X_MATCH_IPV4_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("[IP4_DST:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break; 

			case OF1X_MATCH_TCP_SRC:  ROFL_PIPELINE_INFO_NO_PREFIX("[TCP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_TCP_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("[TCP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 

			case OF1X_MATCH_UDP_SRC:  ROFL_PIPELINE_INFO_NO_PREFIX("[UDP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_UDP_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("[UDP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 

			case OF1X_MATCH_SCTP_SRC:  ROFL_PIPELINE_INFO_NO_PREFIX("[SCTP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_SCTP_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("[SCTP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 

			//OF1.0 only
			case OF1X_MATCH_TP_SRC:  ROFL_PIPELINE_INFO_NO_PREFIX("[TP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_TP_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("[TP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 


			case OF1X_MATCH_ICMPV4_TYPE:  ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV4_TYPE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_ICMPV4_CODE:  ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV4_CODE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			
			//IPv6
			case OF1X_MATCH_IPV6_SRC: 
				{
					uint128__t value = __of1x_get_match_val128(it, false, raw_nbo);	
					uint128__t mask = __of1x_get_match_val128(it, true, raw_nbo);
					(void)value;	
					(void)mask;	
					ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_SRC:0x%lx:%lx|0x%lx:%lx], ",UINT128__T_HI(value),UINT128__T_LO(value),UINT128__T_HI(mask),UINT128__T_LO(mask));
				}
				break;
			case OF1X_MATCH_IPV6_DST: 
				{
					uint128__t value = __of1x_get_match_val128(it, false, raw_nbo);	
					uint128__t mask = __of1x_get_match_val128(it, true, raw_nbo);
					(void)value;	
					(void)mask;	

					ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_DST:0x%lx:%lx|0x%lx:%lx], ",UINT128__T_HI(value),UINT128__T_LO(value),UINT128__T_HI(mask),UINT128__T_LO(mask));
				}
				break;
			case OF1X_MATCH_IPV6_FLABEL:  ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_FLABEL:%lu], ",__of1x_get_match_val64(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_IPV6_ND_TARGET: {
					uint128__t value = __of1x_get_match_val128(it, false, raw_nbo);	
					uint128__t mask = __of1x_get_match_val128(it, true, raw_nbo);
					(void)value;	
					(void)mask;	

					ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_ND_TARGET:0x%lx:%lx], ",UINT128__T_HI(value),UINT128__T_LO(mask));
				}
				break;
			case OF1X_MATCH_IPV6_ND_SLL:  ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_ND_SLL:%lu], ",__of1x_get_match_val64(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_IPV6_ND_TLL:  ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_ND_TLL:%lu], ",__of1x_get_match_val64(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_IPV6_EXTHDR:  ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_EXTHDR:%lu|0x%lx], ",__of1x_get_match_val16(it, false, raw_nbo),__of1x_get_match_val16(it, true, raw_nbo));
				break; 
			//ICMPv6
			case OF1X_MATCH_ICMPV6_TYPE:  ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV6_TYPE:%lu], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_ICMPV6_CODE:  ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV6_CODE:%lu], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
					
			//PBB	
			case OF1X_MATCH_PBB_ISID: ROFL_PIPELINE_INFO_NO_PREFIX("[PBB_ISID:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break;
			//TUNNEL ID
			case OF1X_MATCH_TUNNEL_ID: ROFL_PIPELINE_INFO_NO_PREFIX("[TUNNEL_ID:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
				break;

			/* PPP/PPPoE related extensions */
			case OF1X_MATCH_PPPOE_CODE:  ROFL_PIPELINE_INFO_NO_PREFIX("[PPPOE_CODE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_PPPOE_TYPE:  ROFL_PIPELINE_INFO_NO_PREFIX("[PPPOE_TYPE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
				break; 
			case OF1X_MATCH_PPPOE_SID:  ROFL_PIPELINE_INFO_NO_PREFIX("[PPPOE_SID:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 

			case OF1X_MATCH_PPP_PROT:  ROFL_PIPELINE_INFO_NO_PREFIX("[PPP_PROT:%u] ",__of1x_get_match_val16(it, false, raw_nbo));
				break; 

			/* GTP related extensions */
			case OF1X_MATCH_GTP_MSG_TYPE:  ROFL_PIPELINE_INFO_NO_PREFIX("[GTP_MSG_TYPE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
				break;
			case OF1X_MATCH_GTP_TEID:  ROFL_PIPELINE_INFO_NO_PREFIX("[GTP_TEID:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
				break;

			case OF1X_MATCH_MAX: assert(0);
				break;

			//Add more here ...
			//Warning: NEVER add a default clause
		}
	}	
}
Esempio n. 2
0
/* Dumping */
static void __of1x_dump_packet_action(of1x_packet_action_t* action, bool raw_nbo){

	ROFL_PIPELINE_INFO_NO_PREFIX("<");
	switch(action->type){
		case OF1X_AT_NO_ACTION: /*TODO: print some error traces? */
			break;

		case OF1X_AT_COPY_TTL_IN: ROFL_PIPELINE_INFO_NO_PREFIX("TTL_IN");
			break;

		case OF1X_AT_POP_VLAN:ROFL_PIPELINE_INFO_NO_PREFIX("POP_VLAN");
			break;
		case OF1X_AT_POP_MPLS:ROFL_PIPELINE_INFO_NO_PREFIX("POP_MPLS");
			break;
		case OF1X_AT_POP_PPPOE:ROFL_PIPELINE_INFO_NO_PREFIX("POP_PPPOE");
			break;

		case OF1X_AT_PUSH_PPPOE:ROFL_PIPELINE_INFO_NO_PREFIX("PUSH_PPPOE");
			break;
		case OF1X_AT_PUSH_MPLS:ROFL_PIPELINE_INFO_NO_PREFIX("PUSH_MPLS");
			break;
		case OF1X_AT_PUSH_VLAN:ROFL_PIPELINE_INFO_NO_PREFIX("PUSH_VLAN");
			break;

		case OF1X_AT_COPY_TTL_OUT:ROFL_PIPELINE_INFO_NO_PREFIX("COPY_TTL_OUT");
			break;

		case OF1X_AT_DEC_NW_TTL:ROFL_PIPELINE_INFO_NO_PREFIX("DEC_NW_TTL");
			break;
		case OF1X_AT_DEC_MPLS_TTL:ROFL_PIPELINE_INFO_NO_PREFIX("DEC_MPLS_TTL");
			break;

		case OF1X_AT_SET_MPLS_TTL:ROFL_PIPELINE_INFO_NO_PREFIX("SET_MPLS_TTL: %u", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_NW_TTL:ROFL_PIPELINE_INFO_NO_PREFIX("SET_NW_TTL: %u", __of1x_get_packet_action_field8(action, raw_nbo));
			break;

		case OF1X_AT_SET_QUEUE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_QUEUE: %u", __of1x_get_packet_action_field32(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_ETH_DST: ROFL_PIPELINE_INFO_NO_PREFIX("SET_ETH_DST: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo)); 
			break;
		case OF1X_AT_SET_FIELD_ETH_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("SET_ETH_SRC: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_ETH_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_ETH_TYPE: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_VLAN_VID:ROFL_PIPELINE_INFO_NO_PREFIX("SET_VLAN_VID: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_VLAN_PCP:ROFL_PIPELINE_INFO_NO_PREFIX("SET_VLAN_PCP: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_ARP_OPCODE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_ARP_OPCODE: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_ARP_SHA: ROFL_PIPELINE_INFO_NO_PREFIX("SET_ARP_SHA: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_ARP_SPA: ROFL_PIPELINE_INFO_NO_PREFIX("SET_ARP_SPA: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_ARP_THA: ROFL_PIPELINE_INFO_NO_PREFIX("SET_ARP_THA: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_ARP_TPA: ROFL_PIPELINE_INFO_NO_PREFIX("SET_ARP_TPA: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;

		/* OF1.0 only */
		case OF1X_AT_SET_FIELD_NW_PROTO: ROFL_PIPELINE_INFO_NO_PREFIX("SET_NW_PROTO: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_NW_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("SET_NW_SRC: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_NW_DST: ROFL_PIPELINE_INFO_NO_PREFIX("SET_NW_DST: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;
		/* OF1.0 only */

		case OF1X_AT_SET_FIELD_IP_DSCP: ROFL_PIPELINE_INFO_NO_PREFIX("SET_IP_DSCP: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_IP_ECN:  ROFL_PIPELINE_INFO_NO_PREFIX("SET_IP_ECN: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_IP_PROTO:ROFL_PIPELINE_INFO_NO_PREFIX("SET_IP_PROTO: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_IPV4_SRC:ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV4_SRC: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_IPV4_DST:ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV4_DST: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;

		/* OF1.0 only */
		case OF1X_AT_SET_FIELD_TP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("SET_TP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_TP_DST: ROFL_PIPELINE_INFO_NO_PREFIX("SET_TP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		/* OF1.0 only */
		case OF1X_AT_SET_FIELD_TCP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("SET_TCP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_TCP_DST: ROFL_PIPELINE_INFO_NO_PREFIX("SET_TCP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_UDP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("SET_UDP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_UDP_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("SET_UDP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_SCTP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("SET_SCTP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_SCTP_DST:  ROFL_PIPELINE_INFO_NO_PREFIX("SET_SCTP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_ICMPV4_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_ICMPV4_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_ICMPV4_CODE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_ICMPV4_CODE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_MPLS_LABEL:ROFL_PIPELINE_INFO_NO_PREFIX("SET_MPLS_LABEL: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_MPLS_TC:ROFL_PIPELINE_INFO_NO_PREFIX("SET_MPLS_TC: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_MPLS_BOS:ROFL_PIPELINE_INFO_NO_PREFIX("SET_MPLS_BOS: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_PPPOE_CODE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_PPPOE_CODE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_PPPOE_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_PPPOE_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_PPPOE_SID:ROFL_PIPELINE_INFO_NO_PREFIX("SET_PPPOE_SID: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;

		case OF1X_AT_SET_FIELD_PPP_PROT:ROFL_PIPELINE_INFO_NO_PREFIX("SET_PPP_PROT: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
			
		case OF1X_AT_SET_FIELD_IPV6_SRC:
			{
				uint128__t addr = __of1x_get_packet_action_field128(action, raw_nbo);
				(void)addr;
				COND_NTOHB128(raw_nbo,addr);
				ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV6_SRC: 0x%lx %lx",UINT128__T_HI(addr),UINT128__T_LO(addr));
			}
			break;
		case OF1X_AT_SET_FIELD_IPV6_DST:
			{
				uint128__t addr = __of1x_get_packet_action_field128(action, raw_nbo);
				(void)addr;
				COND_NTOHB128(raw_nbo,addr);
				ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV6_DST: 0x%lx %lx",UINT128__T_HI(addr),UINT128__T_LO(addr));
			}
			break;
		case OF1X_AT_SET_FIELD_IPV6_FLABEL:ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV6_FLABEL: 0x%u", __of1x_get_packet_action_field32(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_IPV6_ND_TARGET:
			{
				uint128__t addr = __of1x_get_packet_action_field128(action, raw_nbo);
				(void)addr;
				COND_NTOHB128(raw_nbo,addr);
				ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV6_ND_TARGET: 0x%lx %lx",UINT128__T_HI(addr),UINT128__T_LO(addr));
			}
			break;
		case OF1X_AT_SET_FIELD_IPV6_ND_SLL:ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV6_ND_SLL: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_IPV6_ND_TLL:ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV6_ND_TLL: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_IPV6_EXTHDR:ROFL_PIPELINE_INFO_NO_PREFIX("SET_IPV6_EXTHDR: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
			
		case OF1X_AT_SET_FIELD_ICMPV6_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_ICMPV6_TYPE: 0x%u", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_ICMPV6_CODE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_ICMPV6_CODE: 0x%u", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_POP_PBB:ROFL_PIPELINE_INFO_NO_PREFIX("POP_PBB");
			break;
		case OF1X_AT_PUSH_PBB:ROFL_PIPELINE_INFO_NO_PREFIX("PUSH_PBB");
			break;
		case OF1X_AT_SET_FIELD_PBB_ISID:ROFL_PIPELINE_INFO_NO_PREFIX("SET_PBB_ISID: 0x%u", __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_TUNNEL_ID:ROFL_PIPELINE_INFO_NO_PREFIX("SET_TUNNEL_ID: 0x%u", __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		

		case OF1X_AT_SET_FIELD_GTP_MSG_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_GTP_MSG_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_GTP_TEID:ROFL_PIPELINE_INFO_NO_PREFIX("SET_GTP_TEID: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
			break;
		case OF1X_AT_POP_GTP:ROFL_PIPELINE_INFO_NO_PREFIX("POP_GTP");
			break;
		case OF1X_AT_PUSH_GTP:ROFL_PIPELINE_INFO_NO_PREFIX("PUSH_GTP");
			break;

		case OF1X_AT_SET_FIELD_CAPWAP_WBID:ROFL_PIPELINE_INFO_NO_PREFIX("SET_CAPWAP_WBID: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_CAPWAP_RID:ROFL_PIPELINE_INFO_NO_PREFIX("SET_CAPWAP_RID: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_CAPWAP_FLAGS:ROFL_PIPELINE_INFO_NO_PREFIX("SET_CAPWAP_FLAGS: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_POP_CAPWAP:ROFL_PIPELINE_INFO_NO_PREFIX("POP_CAPWAP");
			break;
		case OF1X_AT_PUSH_CAPWAP:ROFL_PIPELINE_INFO_NO_PREFIX("PUSH_CAPWAP");
			break;

		case OF1X_AT_SET_FIELD_WLAN_FC:ROFL_PIPELINE_INFO_NO_PREFIX("SET_WLAN_FC: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_WLAN_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_WLAN_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_WLAN_SUBTYPE:ROFL_PIPELINE_INFO_NO_PREFIX("SET_WLAN_SUBTYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_WLAN_DIRECTION:ROFL_PIPELINE_INFO_NO_PREFIX("SET_WLAN_DIRECTION: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_WLAN_ADDRESS_1:ROFL_PIPELINE_INFO_NO_PREFIX("SET_WLAN_ADDRESS_1: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_WLAN_ADDRESS_2:ROFL_PIPELINE_INFO_NO_PREFIX("SET_WLAN_ADDRESS_2: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_SET_FIELD_WLAN_ADDRESS_3:ROFL_PIPELINE_INFO_NO_PREFIX("SET_WLAN_ADDRESS_3: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
			break;
		case OF1X_AT_POP_WLAN:ROFL_PIPELINE_INFO_NO_PREFIX("POP_WLAN");
			break;
		case OF1X_AT_PUSH_WLAN:ROFL_PIPELINE_INFO_NO_PREFIX("PUSH_WLAN");
			break;

		case OF1X_AT_GROUP:ROFL_PIPELINE_INFO_NO_PREFIX("GROUP:%u", __of1x_get_packet_action_field32(action, raw_nbo));
			break;

		case OF1X_AT_EXPERIMENTER:ROFL_PIPELINE_INFO_NO_PREFIX("EXPERIMENTER");
			break;

		case OF1X_AT_OUTPUT:
				ROFL_PIPELINE_INFO_NO_PREFIX("OUTPUT port: ");
				switch(__of1x_get_packet_action_field32(action, raw_nbo)){
	
					case OF1X_PORT_FLOOD:
						ROFL_PIPELINE_INFO_NO_PREFIX("FLOOD");
						break;
					case OF1X_PORT_NORMAL:
						ROFL_PIPELINE_INFO_NO_PREFIX("NORMAL");
						break;	
					case OF1X_PORT_CONTROLLER:
						ROFL_PIPELINE_INFO_NO_PREFIX("CONTROLLER");
						break;	
					case OF1X_PORT_ALL:
						ROFL_PIPELINE_INFO_NO_PREFIX("ALL");
						break;	
					case OF1X_PORT_IN_PORT:
						ROFL_PIPELINE_INFO_NO_PREFIX("IN-PORT");
						break;	
					default:
						ROFL_PIPELINE_INFO_NO_PREFIX("%u", __of1x_get_packet_action_field32(action, raw_nbo));
						break;
				}
			break;
	}
	ROFL_PIPELINE_INFO_NO_PREFIX(">,");

}
Esempio n. 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...	
}
Esempio n. 4
0
/* Actions init and destroyed */
of1x_packet_action_t* of1x_init_packet_action(of1x_packet_action_type_t type, wrap_uint_t field, uint16_t output_send_len){

	of1x_packet_action_t* action;

	if( unlikely(type==OF1X_AT_NO_ACTION) )
		return NULL;

	action = platform_malloc_shared(sizeof(of1x_packet_action_t));

	if( unlikely(action==NULL) )
		return NULL;
	
	//Set type
	action->type = type;

	//Set min max 
	action->ver_req.min_ver = OF1X_MIN_VERSION;
	action->ver_req.max_ver = OF1X_MAX_VERSION;

	//Make valgrind happy
	UINT128__T_HI(action->__field.u128) = UINT128__T_LO(action->__field.u128) = 0x0ULL;
	
	/*
	* Setting the field (for set_field actions) and fast validation flags
	*/
	switch(type){
		//16 byte
		case OF1X_AT_SET_FIELD_IPV6_ND_TARGET:
		case OF1X_AT_SET_FIELD_IPV6_SRC:
		case OF1X_AT_SET_FIELD_IPV6_DST:{
			uint128__t tmp = field.u128;
			HTONB128(tmp);
			action->__field.u128 = tmp;
			action->ver_req.min_ver = OF_VERSION_12;
		}break;

		//8 byte
		case OF1X_AT_SET_FIELD_TUNNEL_ID:
			action->__field.u64 = field.u64&OF1X_8_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_13;
			break;

		//6 byte values
		case OF1X_AT_SET_FIELD_IPV6_ND_SLL:
			field.u64 = HTONB64(OF1X_MAC_ALIGN(field.u64));
			action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_IPV6_ND_TLL:
			field.u64 = HTONB64(OF1X_MAC_ALIGN(field.u64));
			action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_ETH_DST:
			field.u64 = HTONB64(OF1X_MAC_ALIGN(field.u64));
			action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
			break;
		case OF1X_AT_SET_FIELD_ETH_SRC:
			field.u64 = HTONB64(OF1X_MAC_ALIGN(field.u64));
			action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
			break;
		case OF1X_AT_SET_FIELD_ARP_SHA:
			field.u64 = HTONB64(OF1X_MAC_ALIGN(field.u64));
			action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_ARP_THA:
			field.u64 = HTONB64(OF1X_MAC_ALIGN(field.u64));
			action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		/* Extensions */
		case OF1X_AT_SET_FIELD_WLAN_ADDRESS_1:
		case OF1X_AT_SET_FIELD_WLAN_ADDRESS_2:
		case OF1X_AT_SET_FIELD_WLAN_ADDRESS_3:
			field.u64 = HTONB64(OF1X_MAC_ALIGN(field.u64));
			action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		/* Extensions end */
	
		//4 byte values
		case OF1X_AT_SET_FIELD_NW_DST:
			action->ver_req.min_ver = OF_VERSION_10;
			action->ver_req.max_ver = OF_VERSION_10;
		case OF1X_AT_SET_FIELD_IPV4_DST:
			field.u32 = HTONB32(field.u32);
			action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
			break;
		case OF1X_AT_SET_FIELD_NW_SRC:
			action->ver_req.min_ver = OF_VERSION_10;
			action->ver_req.max_ver = OF_VERSION_10;
		case OF1X_AT_SET_FIELD_IPV4_SRC:
			field.u32 = HTONB32(field.u32);
			action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
			break;
		case OF1X_AT_SET_FIELD_ARP_SPA:
			field.u32 = HTONB32(field.u32);
			action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_10;
			break;
		case OF1X_AT_SET_FIELD_ARP_TPA:
			field.u32 = HTONB32(field.u32);
			action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_10;
			break;
		case OF1X_AT_OUTPUT:
			action->send_len = output_send_len;
			action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
			break;
		case OF1X_AT_SET_FIELD_GTP_TEID:
			field.u32 = HTONB32(field.u32);
			action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;

		//3 byte
		case OF1X_AT_SET_FIELD_PBB_ISID:
			//TODO Align value
			action->__field.u32 = field.u32&OF1X_3_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_13;
			break;
	
		//20 bit values
		case OF1X_AT_SET_FIELD_IPV6_FLABEL:
			field.u32 = HTONB32(OF1X_IP6_FLABEL_ALIGN(field.u32));
			action->__field.u32 = field.u32&OF1X_20_BITS_IPV6_FLABEL_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_MPLS_LABEL:
			field.u32 = HTONB32(OF1X_MPLS_LABEL_ALIGN(field.u32));
			action->__field.u32 = field.u32&OF1X_20_BITS_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;

		//2 byte values
		case OF1X_AT_SET_FIELD_ETH_TYPE:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			break;
		case OF1X_AT_SET_FIELD_ARP_OPCODE:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK; // TODO: lower 8bits of opcode only?
			action->ver_req.min_ver = OF_VERSION_10;
			break;
		case OF1X_AT_SET_FIELD_TP_SRC:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_10;
			action->ver_req.max_ver = OF_VERSION_10;
			break;
		case OF1X_AT_SET_FIELD_TP_DST:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_10;
			action->ver_req.max_ver = OF_VERSION_10;
			break;
		case OF1X_AT_SET_FIELD_TCP_SRC:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_TCP_DST:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_UDP_SRC:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_UDP_DST:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_SCTP_SRC:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_SCTP_DST:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_PPPOE_SID:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_PPP_PROT:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_CAPWAP_FLAGS:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_FIELD_WLAN_FC:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		/*case OF1X_AT_POP_VLAN: TODO: CHECK THIS*/
		case OF1X_AT_POP_MPLS:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_POP_PPPOE:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_POP_PBB:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_13;
			break;
		/* Extensions */
		case OF1X_AT_POP_WLAN:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_POP_GTP:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_POP_CAPWAP:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_PUSH_GTP:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_PUSH_CAPWAP:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_PUSH_WLAN:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		/* Extensions end */
		case OF1X_AT_PUSH_PPPOE:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_PUSH_MPLS:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_PUSH_VLAN:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_PUSH_PBB:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_13;
			break;


		//12 bit values
		case OF1X_AT_SET_FIELD_VLAN_VID:
			field.u16 = HTONB16(field.u16);
			action->__field.u16 = field.u16&OF1X_12_BITS_MASK;
			break;


		//9 bit value
		case OF1X_AT_SET_FIELD_IPV6_EXTHDR:
			//TODO align to pipeline -- currently not implemented
			action->__field.u16 = field.u16&OF1X_9_BITS_MASK;
			action->ver_req.min_ver = OF_VERSION_13;
			break;

		//1 byte values
		case OF1X_AT_SET_FIELD_NW_PROTO:
			action->ver_req.min_ver = OF_VERSION_10;
			action->ver_req.max_ver = OF_VERSION_10;
			action->__field.u8 = field.u8&OF1X_1_BYTE_MASK;
			break;
		case OF1X_AT_SET_FIELD_ICMPV6_TYPE:
		case OF1X_AT_SET_FIELD_ICMPV6_CODE:
		case OF1X_AT_SET_FIELD_PPPOE_CODE:
		case OF1X_AT_SET_FIELD_PPPOE_TYPE:
		case OF1X_AT_SET_MPLS_TTL:
		case OF1X_AT_SET_NW_TTL:
		case OF1X_AT_SET_FIELD_IP_PROTO:
		case OF1X_AT_SET_FIELD_ICMPV4_TYPE:
		case OF1X_AT_SET_FIELD_ICMPV4_CODE:
			action->__field.u8 = field.u8&OF1X_1_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_10;
			break;
		/* Extensions */
		case OF1X_AT_SET_FIELD_GTP_MSG_TYPE:
		case OF1X_AT_SET_FIELD_CAPWAP_WBID:
		case OF1X_AT_SET_FIELD_CAPWAP_RID:
		case OF1X_AT_SET_FIELD_WLAN_TYPE:
		case OF1X_AT_SET_FIELD_WLAN_SUBTYPE:
		case OF1X_AT_SET_FIELD_WLAN_DIRECTION:
		/* Extensions end */
			action->__field.u8 = field.u8&OF1X_1_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;

		//6 bit values
		case OF1X_AT_SET_FIELD_IP_DSCP:
			field.u8 = OF1X_IP_DSCP_ALIGN(field.u8);
			action->__field.u8 = field.u8&OF1X_6MSBITS_MASK;
			break;

		//3 bit values
		case OF1X_AT_SET_FIELD_VLAN_PCP:
			field.u8 = OF1X_VLAN_PCP_ALIGN(field.u8);
			action->__field.u8 = field.u8&OF1X_3MSBITS_MASK;
			break;

		case OF1X_AT_SET_FIELD_MPLS_TC:
			field.u8 = OF1X_MPLS_TC_ALIGN(field.u8);
			action->__field.u8 = field.u8&OF1X_BITS_12AND3_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;

		//2 bit values
		case OF1X_AT_SET_FIELD_IP_ECN:
			action->__field.u8 = field.u8&OF1X_2LSBITS_MASK;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		case OF1X_AT_SET_QUEUE:
			action->__field.u32 =  field.u32&OF1X_4_BYTE_MASK;
			action->ver_req.min_ver = OF_VERSION_10;
			break;
		case OF1X_AT_GROUP:
			action->__field.u32 =  field.u32&OF1X_4_BYTE_MASK; //id of the group
			action->ver_req.min_ver = OF_VERSION_12;
			//action->group = of1x_group_search(sw->pipeline->groups, action->__field); // pointer to the group //FIXME evaluate if this can be done here or not
			break;

		//1 bit values
		case OF1X_AT_SET_FIELD_MPLS_BOS:
			action->__field.u8 =  field.u8&OF1X_BIT0_MASK; //id of the group
			action->ver_req.min_ver = OF_VERSION_13;
			break;

		//No value
		case OF1X_AT_POP_VLAN:
			action->__field.u64 = 0x0; // action strip vlan
			break;

		case OF1X_AT_COPY_TTL_IN:
		case OF1X_AT_COPY_TTL_OUT:
		case OF1X_AT_DEC_NW_TTL:
		case OF1X_AT_DEC_MPLS_TTL:
		case OF1X_AT_EXPERIMENTER:
			action->__field.u64 = 0x0;
			action->ver_req.min_ver = OF_VERSION_12;
			break;
		
		//Shall never happen
		case OF1X_AT_NO_ACTION: 
			assert(0);
			action->__field.u64 = 0x0;
			break;
	}
	
	return action;
}