1 #ifndef __OF1X_MATCH_H__
2 #define __OF1X_MATCH_H__
10 #include "../../../common/ternary_fields.h"
11 #include "../../../common/packet_matches.h"
39 union of_packet_matches;
45 OF1X_MATCH_IN_PHY_PORT,
58 OF1X_MATCH_MPLS_LABEL,
84 OF1X_MATCH_IPV6_FLABEL,
85 OF1X_MATCH_ICMPV6_TYPE,
86 OF1X_MATCH_ICMPV6_CODE,
87 OF1X_MATCH_IPV6_ND_TARGET,
88 OF1X_MATCH_IPV6_ND_SLL,
89 OF1X_MATCH_IPV6_ND_TLL,
90 OF1X_MATCH_IPV6_EXTHDR,
101 OF1X_MATCH_ICMPV4_TYPE,
102 OF1X_MATCH_ICMPV4_CODE,
106 OF1X_MATCH_TUNNEL_ID,
113 OF1X_MATCH_PPPOE_CODE,
114 OF1X_MATCH_PPPOE_TYPE,
115 OF1X_MATCH_PPPOE_SID,
119 OF1X_MATCH_GTP_MSG_TYPE,
123 OF1X_MATCH_CAPWAP_WBID,
124 OF1X_MATCH_CAPWAP_RID,
125 OF1X_MATCH_CAPWAP_FLAGS,
129 OF1X_MATCH_WLAN_TYPE,
130 OF1X_MATCH_WLAN_SUBTYPE,
131 OF1X_MATCH_WLAN_DIRECTION,
132 OF1X_MATCH_WLAN_ADDRESS_1,
133 OF1X_MATCH_WLAN_ADDRESS_2,
134 OF1X_MATCH_WLAN_ADDRESS_3,
137 OF1X_MATCH_GRE_VERSION,
138 OF1X_MATCH_GRE_PROT_TYPE,
146 enum of1x_vlan_present{
147 OF1X_MATCH_VLAN_NONE=0,
148 OF1X_MATCH_VLAN_ANY=1,
149 OF1X_MATCH_VLAN_SPECIFIC=2,
155 of1x_match_type_t type;
171 enum of1x_vlan_present vlan_present;
185 unsigned int num_elements;
630 of1x_match_t* of1x_init_pbb_isid_match(uint32_t value, uint32_t mask);
654 uint8_t __of1x_get_match_val8(
const of1x_match_t* match,
bool get_mask,
bool raw_nbo){
659 wrap = &match->__tern->mask;
661 wrap = &match->__tern->value;
667 case OF1X_MATCH_VLAN_PCP:
668 return OF1X_VLAN_PCP_VALUE(wrap->u8);
669 case OF1X_MATCH_MPLS_TC:
670 return OF1X_MPLS_TC_VALUE(wrap->u8);
671 case OF1X_MATCH_MPLS_BOS:
672 case OF1X_MATCH_NW_PROTO:
673 case OF1X_MATCH_IP_PROTO:
674 case OF1X_MATCH_IP_ECN:
675 case OF1X_MATCH_ICMPV4_TYPE:
676 case OF1X_MATCH_ICMPV4_CODE:
677 case OF1X_MATCH_ICMPV6_TYPE:
678 case OF1X_MATCH_ICMPV6_CODE:
679 case OF1X_MATCH_PPPOE_TYPE:
680 case OF1X_MATCH_PPPOE_CODE:
681 case OF1X_MATCH_GTP_MSG_TYPE:
683 case OF1X_MATCH_IP_DSCP:
684 return OF1X_IP_DSCP_VALUE(wrap->u8);
701 return __of1x_get_match_val8(match,
false,
false);
707 uint16_t __of1x_get_match_val16(
const of1x_match_t* match,
bool get_mask,
bool raw_nbo){
712 wrap = &match->__tern->mask;
714 wrap = &match->__tern->value;
721 case OF1X_MATCH_ETH_TYPE:
722 case OF1X_MATCH_VLAN_VID:
723 case OF1X_MATCH_ARP_OP:
724 case OF1X_MATCH_TCP_SRC:
725 case OF1X_MATCH_TCP_DST:
726 case OF1X_MATCH_UDP_SRC:
727 case OF1X_MATCH_UDP_DST:
728 case OF1X_MATCH_SCTP_SRC:
729 case OF1X_MATCH_SCTP_DST:
730 case OF1X_MATCH_TP_SRC:
731 case OF1X_MATCH_TP_DST:
732 case OF1X_MATCH_PPPOE_SID:
733 case OF1X_MATCH_PPP_PROT:
734 case OF1X_MATCH_IPV6_EXTHDR:
735 case OF1X_MATCH_GRE_VERSION:
736 case OF1X_MATCH_GRE_PROT_TYPE:
737 return NTOHB16(wrap->u16);
753 return __of1x_get_match_val16(match,
false,
false);
758 uint32_t __of1x_get_match_val32(
const of1x_match_t* match,
bool get_mask,
bool raw_nbo){
763 wrap = &match->__tern->mask;
765 wrap = &match->__tern->value;
772 case OF1X_MATCH_IN_PORT:
773 case OF1X_MATCH_IN_PHY_PORT:
775 case OF1X_MATCH_MPLS_LABEL:
776 return OF1X_MPLS_LABEL_VALUE(NTOHB32(wrap->u32));
777 case OF1X_MATCH_ARP_TPA:
778 case OF1X_MATCH_ARP_SPA:
779 case OF1X_MATCH_NW_SRC:
780 case OF1X_MATCH_NW_DST:
781 case OF1X_MATCH_IPV4_SRC:
782 case OF1X_MATCH_IPV4_DST:
783 case OF1X_MATCH_GTP_TEID:
784 case OF1X_MATCH_PBB_ISID:
785 case OF1X_MATCH_GRE_KEY:
786 return NTOHB32(wrap->u32);
787 case OF1X_MATCH_IPV6_FLABEL:
788 return OF1X_IP6_FLABEL_VALUE(NTOHB32(wrap->u32));
806 return __of1x_get_match_val32(match,
false,
false);
811 uint64_t __of1x_get_match_val64(
const of1x_match_t* match,
bool get_mask,
bool raw_nbo){
816 wrap = &match->__tern->mask;
818 wrap = &match->__tern->value;
825 case OF1X_MATCH_METADATA:
826 case OF1X_MATCH_TUNNEL_ID:
829 case OF1X_MATCH_ETH_DST:
830 case OF1X_MATCH_ETH_SRC:
831 case OF1X_MATCH_ARP_THA:
832 case OF1X_MATCH_ARP_SHA:
833 case OF1X_MATCH_IPV6_ND_SLL:
834 case OF1X_MATCH_IPV6_ND_TLL:
835 return OF1X_MAC_VALUE(NTOHB64(wrap->u64));
852 return __of1x_get_match_val64(match,
false,
false);
862 wrap = &match->__tern->mask;
864 wrap = &match->__tern->value;
870 case OF1X_MATCH_IPV6_SRC:
871 case OF1X_MATCH_IPV6_DST:
872 case OF1X_MATCH_IPV6_ND_TARGET:
892 return __of1x_get_match_val128(match,
false,
false);
907 return __of1x_get_match_val8(match,
true,
false);
918 return __of1x_get_match_val16(match,
true,
false);
929 return __of1x_get_match_val32(match,
true,
false);
940 return __of1x_get_match_val64(match,
true,
false);
951 return __of1x_get_match_val128(match,
true,
false);
994 void __of1x_dump_matches(
of1x_match_t* matches,
bool raw_nbo);
of1x_match_t * of1x_init_ip6_flabel_match(uint32_t value, uint32_t mask)
Create an IP6_FLABEL match.
of1x_match_t * of1x_init_tunnel_id_match(uint64_t value, uint64_t mask)
Create an TUNNEL_ID match.
static uint16_t of1x_get_match_mask16(const of1x_match_t *match)
Retrieve the match mask value for 16 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_tp_dst_match(uint16_t value)
Create an TP_DST match (TCP/UDP), OF1.0 ONLY!
of1x_match_t * of1x_init_arp_sha_match(uint64_t value, uint64_t mask)
Create an ARP_SHA match.
of1x_match_t * of1x_init_capwap_wbid_match(uint8_t value, uint8_t mask)
Create a CAPWAP_WBID match.
of1x_match_t * of1x_init_vlan_vid_match(uint16_t value, uint16_t mask, enum of1x_vlan_present vlan_present)
Create an VLAN_VID match according to 1.2 semantics (13th bit is a flag)
of1x_match_t * of1x_init_pppoe_code_match(uint8_t value)
Create an PPPOE_CODE match.
static uint64_t of1x_get_match_mask64(const of1x_match_t *match)
Retrieve the match mask value for 64 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_mpls_label_match(uint32_t value)
Create an MPLS_LABEL match.
of1x_match_t * of1x_init_ip4_dst_match(uint32_t value, uint32_t mask)
Create an IP4_DST match.
static uint32_t of1x_get_match_mask32(const of1x_match_t *match)
Retrieve the match mask value for 32 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_gre_version_match(uint16_t value)
Create a GRE_VERSION match.
of1x_match_t * of1x_init_wlan_address_2_match(uint64_t value, uint64_t mask)
Create an WLAN_ADDRESS_2 match.
static uint32_t of1x_get_match_value32(const of1x_match_t *match)
Retrieve the match value for 32 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_capwap_rid_match(uint8_t value, uint8_t mask)
Create a CAPWAP_RID match.
of1x_match_t * of1x_init_port_in_phy_match(uint32_t value)
Create an PHY_PORT_IN match.
of1x_match_t * of1x_init_ip6_src_match(uint128__t value, uint128__t mask)
Create an IP6_SRC match.
of1x_match_t * of1x_init_eth_type_match(uint16_t value)
Create an ETH_TYPE match.
static uint16_t of1x_get_match_value16(const of1x_match_t *match)
Retrieve the match value for 16 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_eth_dst_match(uint64_t value, uint64_t mask)
Create an ETH_DST match.
of1x_match_t * of1x_init_gtp_msg_type_match(uint8_t value)
Create an PPP_PROTO match.
static uint8_t of1x_get_match_mask8(const of1x_match_t *match)
Retrieve the match mask value for 8 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_gtp_teid_match(uint32_t value, uint32_t mask)
Create an PPP_PROTO match.
of1x_match_t * of1x_init_mpls_tc_match(uint8_t value)
Create an MPLS_TC match.
of1x_match_t * of1x_init_wlan_subtype_match(uint8_t value, uint8_t mask)
Create a WLAN_SUBTYPE match.
of1x_match_t * of1x_init_wlan_fc_match(uint16_t value, uint16_t mask)
Create a WLAN_FC match.
of1x_match_t * of1x_init_icmpv4_type_match(uint8_t value)
Create an ICMPv4_TYPE match.
of1x_match_t * of1x_init_vlan_pcp_match(uint8_t value)
Create an VLAN_PCP match.
of1x_match_t * of1x_init_icmpv6_code_match(uint8_t value)
Create an ICMPV6_CODE match.
of1x_match_t * of1x_init_mpls_bos_match(uint8_t value)
Create an MPLS_BOS match.
void of1x_destroy_match(of1x_match_t *match)
Destroys whichever match previously created using of1x_init_match_*()
of1x_match_t * of1x_init_capwap_flags_match(uint16_t value, uint16_t mask)
Create a CAPWAP_FLAGS match.
of1x_match_t * of1x_init_arp_tpa_match(uint32_t value, uint32_t mask)
Create an ARP_TPA match.
of1x_match_t * of1x_init_ip_ecn_match(uint8_t value)
Create an IPC_ECN match.
of1x_match_t * of1x_init_nw_dst_match(uint32_t value, uint32_t mask)
Create an NW_DST match (IP/ARP), OF1.0 ONLY!
ROFL_BEGIN_DECLS of1x_match_t * of1x_init_port_in_match(uint32_t value)
Create an PORT_IN match.
of1x_match_t * of1x_init_arp_spa_match(uint32_t value, uint32_t mask)
Create an ARP_SPA match.
static bool bitmap128_is_empty(bitmap128_t *bitmap)
Is bitmap empty.
of1x_match_t * of1x_init_ip_dscp_match(uint8_t value)
Create an IP_DSCP match.
of1x_match_t * of1x_init_gre_prot_type_match(uint16_t value)
Create a GRE_PROT_TYPE match.
of1x_match_t * of1x_init_arp_tha_match(uint64_t value, uint64_t mask)
Create an ARP_THA match.
of1x_match_t * of1x_init_gre_key_match(uint32_t value)
Create a GRE_KEY match.
of1x_match_t * of1x_init_wlan_direction_match(uint8_t value, uint8_t mask)
Create a WLAN_DIRECTION match.
static uint128__t of1x_get_match_mask128(const of1x_match_t *match)
Retrieve the match mask value for 128 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_nw_proto_match(uint8_t value)
Create an NW_PROTO match, OF1.0 ONLY!
of1x_match_t * of1x_init_wlan_address_3_match(uint64_t value, uint64_t mask)
Create an WLAN_ADDRESS_3 match.
of1x_match_t * of1x_init_wlan_address_1_match(uint64_t value, uint64_t mask)
Create an WLAN_ADDRESS_1 match.
of1x_match_t * of1x_init_arp_opcode_match(uint16_t value)
Create an ARP_OPCODE match.
of1x_match_t * of1x_init_sctp_src_match(uint16_t value)
Create an SCTP_SRC match.
of1x_match_t * of1x_init_ip4_src_match(uint32_t value, uint32_t mask)
Create an IP4_SRC match.
of1x_match_t * of1x_init_ip6_dst_match(uint128__t value, uint128__t mask)
Create an IP6_DST match.
of1x_match_t * of1x_init_ip6_nd_tll_match(uint64_t value)
Create an IP6_ND_TLL match.
of1x_match_t * of1x_init_icmpv4_code_match(uint8_t value)
Create an ICMPv4_CODE match.
of1x_match_t * of1x_init_tp_src_match(uint16_t value)
Create an TP_SRC match (TCP/UDP), OF1.0 ONLY!
of1x_match_t * of1x_init_ip6_exthdr_match(uint16_t value, uint16_t mask)
Create an IP6_EXTHDR match.
of1x_match_t * of1x_init_tcp_dst_match(uint16_t value)
Create an TCP_DST match.
of1x_match_t * of1x_init_pppoe_type_match(uint8_t value)
Create an PPPOE_TYPE match.
of1x_match_t * of1x_init_ip6_nd_target_match(uint128__t value)
Create an IP6_ND_TARGET match.
of1x_match_t * of1x_init_sctp_dst_match(uint16_t value)
Create an SCTP_DST match.
of1x_match_t * of1x_init_metadata_match(uint64_t value, uint64_t mask)
Create an METADATA match.
of1x_match_t * of1x_init_udp_src_match(uint16_t value)
Create an UDP_SRC match.
of1x_match_t * of1x_init_wlan_type_match(uint8_t value, uint8_t mask)
Create a WLAN_TYPE match.
static uint64_t of1x_get_match_value64(const of1x_match_t *match)
Retrieve the match value for 64 bit values (or less) in HOST BYTE ORDER.
static uint8_t of1x_get_match_value8(const of1x_match_t *match)
Retrieve the match value for 8 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_udp_dst_match(uint16_t value)
Create an UDP_DST match.
of1x_match_t * of1x_init_ip6_nd_sll_match(uint64_t value)
Create an IP6_ND_SLL match.
of1x_match_t * of1x_init_pppoe_session_match(uint16_t value)
Create an PPPOE_SESSION match.
of1x_match_t * of1x_init_nw_src_match(uint32_t value, uint32_t mask)
Create an NW_SRC match (IP/ARP), OF1.0 ONLY!
of1x_match_t * of1x_init_ip_proto_match(uint8_t value)
Create an IP_PROTO match.
of1x_match_t * of1x_init_ppp_prot_match(uint16_t value)
Create an PPP_PROTO match.
of1x_match_t * of1x_init_icmpv6_type_match(uint8_t value)
Create an ICMPV6_TYPE match.
of1x_match_t * of1x_init_tcp_src_match(uint16_t value)
Create an TCP_SRC match.
static uint128__t of1x_get_match_value128(const of1x_match_t *match)
Retrieve the match value for 128 bit values (or less) in HOST BYTE ORDER.
of1x_match_t * of1x_init_eth_src_match(uint64_t value, uint64_t mask)
Create an ETH_SRC match.