1 #ifndef __OF1X_MATCH_PP_H__
2 #define __OF1X_MATCH_PP_H__
9 #include "../../../util/pp_guard.h"
10 #include "../../../common/packet_matches.h"
11 #include "../../../common/protocol_constants.h"
12 #include "../../../common/ternary_fields.h"
13 #include "../../../platform/likely.h"
14 #include "../../../platform/packet.h"
58 case OF1X_MATCH_METADATA:
return __utern_compare64(it->__tern, &pkt->__metadata);
66 case OF1X_MATCH_VLAN_VID:
if( it->vlan_present == OF1X_MATCH_VLAN_SPECIFIC )
73 case OF1X_MATCH_MPLS_LABEL:{
75 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_MPLS_UNICAST || *ptr_ether_type == ETH_TYPE_MPLS_MULTICAST ))
return false;
78 case OF1X_MATCH_MPLS_TC:{
80 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_MPLS_UNICAST || *ptr_ether_type == ETH_TYPE_MPLS_MULTICAST ))
return false;
83 case OF1X_MATCH_MPLS_BOS:{
85 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_MPLS_UNICAST || *ptr_ether_type == ETH_TYPE_MPLS_MULTICAST ))
return false;
87 return __utern_compare8(it->__tern, &bos);
91 case OF1X_MATCH_ARP_OP:{
93 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_ARP))
return false;
96 case OF1X_MATCH_ARP_SHA:{
98 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_ARP))
return false;
101 case OF1X_MATCH_ARP_SPA:{
103 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_ARP))
return false;
106 case OF1X_MATCH_ARP_THA:{
108 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_ARP))
return false;
111 case OF1X_MATCH_ARP_TPA:{
113 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_ARP))
return false;
118 case OF1X_MATCH_NW_PROTO:{
119 #ifdef ROFL_EXPERIMENTAL
121 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
122 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6 || *ptr_ether_type == ETH_TYPE_ARP || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && (*ptr_ppp_proto == PPP_PROTO_IP4 || *ptr_ppp_proto == PPP_PROTO_IP6) )))
return false;
123 if(*ptr_ether_type == ETH_TYPE_ARP){
125 return __utern_compare8(it->__tern, ++low_byte);
131 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6 || *ptr_ether_type == ETH_TYPE_ARP ))
return false;
132 if(*ptr_ether_type == ETH_TYPE_ARP){
134 return __utern_compare8(it->__tern, ++low_byte);
140 case OF1X_MATCH_NW_SRC:{
141 #ifdef ROFL_EXPERIMENTAL
143 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
144 if( ptr_ether_type && (*ptr_ether_type == ETH_TYPE_IPV4 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP4 )))
146 if(ptr_ether_type && *ptr_ether_type == ETH_TYPE_ARP)
151 if( ptr_ether_type && (*ptr_ether_type == ETH_TYPE_IPV4))
153 if(ptr_ether_type && *ptr_ether_type == ETH_TYPE_ARP)
158 case OF1X_MATCH_NW_DST:{
159 #ifdef ROFL_EXPERIMENTAL
161 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
162 if( ptr_ether_type && (*ptr_ether_type == ETH_TYPE_IPV4 ||(*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP4 )))
164 if( ptr_ether_type && *ptr_ether_type == ETH_TYPE_ARP)
169 if( ptr_ether_type && (*ptr_ether_type == ETH_TYPE_IPV4))
171 if( ptr_ether_type && *ptr_ether_type == ETH_TYPE_ARP)
178 case OF1X_MATCH_IP_PROTO:{
179 #ifdef ROFL_EXPERIMENTAL
181 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
182 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && (*ptr_ppp_proto == PPP_PROTO_IP4 || *ptr_ppp_proto == PPP_PROTO_IP6) )))
return false;
186 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6))
return false;
190 case OF1X_MATCH_IP_ECN:{
191 #ifdef ROFL_EXPERIMENTAL
193 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
194 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP4 )))
return false;
197 return __utern_compare8(it->__tern, &ecn);
201 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6))
return false;
204 return __utern_compare8(it->__tern, &ecn);
208 case OF1X_MATCH_IP_DSCP:{
209 #ifdef ROFL_EXPERIMENTAL
211 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
212 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP4 )))
return false;
215 return __utern_compare8(it->__tern, &dscp);
219 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || *ptr_ether_type == ETH_TYPE_IPV6))
return false;
222 return __utern_compare8(it->__tern, &dscp);
228 case OF1X_MATCH_IPV4_SRC:{
229 #ifdef ROFL_EXPERIMENTAL
231 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
232 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP4 )))
return false;
236 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4))
return false;
240 case OF1X_MATCH_IPV4_DST:{
241 #ifdef ROFL_EXPERIMENTAL
243 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
244 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4 ||(*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP4 )))
return false;
248 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV4))
return false;
254 case OF1X_MATCH_TCP_SRC:{
256 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_TCP))
return false;
259 case OF1X_MATCH_TCP_DST:{
261 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_TCP))
return false;
266 case OF1X_MATCH_UDP_SRC:{
268 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_UDP))
return false;
271 case OF1X_MATCH_UDP_DST:{
273 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_UDP))
return false;
277 case OF1X_MATCH_SCTP_SRC:{
279 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_SCTP))
return false;
282 case OF1X_MATCH_SCTP_DST:{
284 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_SCTP))
return false;
289 case OF1X_MATCH_TP_SRC:{
291 if(ptr_ip_proto && (*ptr_ip_proto == IP_PROTO_TCP))
293 if(ptr_ip_proto && (*ptr_ip_proto == IP_PROTO_UDP))
295 if(ptr_ip_proto && (*ptr_ip_proto == IP_PROTO_ICMPV4)){
297 return __utern_compare16(it->__tern, (uint16_t*)&two_byte);
301 case OF1X_MATCH_TP_DST:{
303 if(ptr_ip_proto && (*ptr_ip_proto == IP_PROTO_TCP))
305 if(ptr_ip_proto && (*ptr_ip_proto == IP_PROTO_UDP))
307 if(ptr_ip_proto && (*ptr_ip_proto == IP_PROTO_ICMPV4)){
309 return __utern_compare16(it->__tern, (uint16_t*)&two_byte);
315 case OF1X_MATCH_ICMPV4_TYPE:{
317 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_ICMPV4))
return false;
320 case OF1X_MATCH_ICMPV4_CODE:{
322 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_ICMPV4))
return false;
327 case OF1X_MATCH_IPV6_SRC:{
328 #ifdef ROFL_EXPERIMENTAL
330 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
331 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV6 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP6 )))
return false;
335 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV6))
return false;
339 case OF1X_MATCH_IPV6_DST:{
340 #ifdef ROFL_EXPERIMENTAL
342 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
343 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV6 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP6 )))
return false;
347 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV6))
return false;
351 case OF1X_MATCH_IPV6_FLABEL:{
352 #ifdef ROFL_EXPERIMENTAL
354 uint16_t *ptr_ppp_proto = platform_packet_get_ppp_proto(pkt);
355 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV6 || (*ptr_ether_type == ETH_TYPE_PPPOE_SESSION && ptr_ppp_proto && *ptr_ppp_proto == PPP_PROTO_IP6 )))
return false;
359 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_IPV6))
return false;
363 case OF1X_MATCH_IPV6_ND_TARGET:{
365 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_ICMPV6))
return false;
368 case OF1X_MATCH_IPV6_ND_SLL:{
373 case OF1X_MATCH_IPV6_ND_TLL:{
378 case OF1X_MATCH_IPV6_EXTHDR:
383 case OF1X_MATCH_ICMPV6_TYPE:{
385 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_ICMPV6))
return false;
388 case OF1X_MATCH_ICMPV6_CODE:{
390 if( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_ICMPV6 ))
return false;
395 case OF1X_MATCH_PBB_ISID:{
397 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_PBB))
return false;
403 #ifdef ROFL_EXPERIMENTAL
405 case OF1X_MATCH_PPPOE_CODE:{
407 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_PPPOE_DISCOVERY || *ptr_ether_type == ETH_TYPE_PPPOE_SESSION ))
return false;
408 return __utern_compare8(it->__tern, platform_packet_get_pppoe_code(pkt));
410 case OF1X_MATCH_PPPOE_TYPE:{
412 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_PPPOE_DISCOVERY || *ptr_ether_type == ETH_TYPE_PPPOE_SESSION ))
return false;
413 return __utern_compare8(it->__tern, platform_packet_get_pppoe_type(pkt));
415 case OF1X_MATCH_PPPOE_SID:{
417 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_PPPOE_DISCOVERY || *ptr_ether_type == ETH_TYPE_PPPOE_SESSION ))
return false;
418 return __utern_compare16(it->__tern, platform_packet_get_pppoe_sid(pkt));
422 case OF1X_MATCH_PPP_PROT:{
424 if( !ptr_ether_type || !(*ptr_ether_type == ETH_TYPE_PPPOE_SESSION ))
return false;
425 return __utern_compare16(it->__tern, platform_packet_get_ppp_proto(pkt));
429 case OF1X_MATCH_GTP_MSG_TYPE:{
432 if (!ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_UDP || (ptr_udp_dst && *ptr_udp_dst == UDP_DST_PORT_GTPU)))
return false;
433 return __utern_compare8(it->__tern, platform_packet_get_gtp_msg_type(pkt));
435 case OF1X_MATCH_GTP_TEID:{
438 if ( !ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_UDP || (ptr_udp_dst && *ptr_udp_dst == UDP_DST_PORT_GTPU)))
return false;
439 return __utern_compare32(it->__tern, platform_packet_get_gtp_teid(pkt));
443 case OF1X_MATCH_CAPWAP_WBID:{
447 if (!ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_UDP || (ptr_udp_dst && *ptr_udp_dst == UDP_DST_PORT_CAPWAPC)))
return false;
448 return __utern_compare8(it->__tern, platform_packet_get_capwap_wbid(pkt));
450 case OF1X_MATCH_CAPWAP_RID:{
454 if (!ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_UDP || (ptr_udp_dst && *ptr_udp_dst == UDP_DST_PORT_CAPWAPC)))
return false;
455 return __utern_compare8(it->__tern, platform_packet_get_capwap_rid(pkt));
457 case OF1X_MATCH_CAPWAP_FLAGS:{
461 if (!ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_UDP || (ptr_udp_dst && *ptr_udp_dst == UDP_DST_PORT_CAPWAPC)))
return false;
462 return __utern_compare16(it->__tern, platform_packet_get_capwap_flags(pkt));
465 case OF1X_MATCH_WLAN_FC:{
467 return __utern_compare16(it->__tern, platform_packet_get_wlan_fc(pkt));
469 case OF1X_MATCH_WLAN_TYPE:{
471 return __utern_compare8(it->__tern, platform_packet_get_wlan_type(pkt));
473 case OF1X_MATCH_WLAN_SUBTYPE:{
475 return __utern_compare8(it->__tern, platform_packet_get_wlan_subtype(pkt));
477 case OF1X_MATCH_WLAN_DIRECTION:{
479 return __utern_compare8(it->__tern, platform_packet_get_wlan_direction(pkt));
481 case OF1X_MATCH_WLAN_ADDRESS_1:{
483 return __utern_compare64(it->__tern, platform_packet_get_wlan_address_1(pkt));
485 case OF1X_MATCH_WLAN_ADDRESS_2:{
487 return __utern_compare64(it->__tern, platform_packet_get_wlan_address_2(pkt));
489 case OF1X_MATCH_WLAN_ADDRESS_3:{
491 return __utern_compare64(it->__tern, platform_packet_get_wlan_address_3(pkt));
495 case OF1X_MATCH_GRE_VERSION:{
497 if (!ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_GRE))
return false;
498 return __utern_compare16(it->__tern, platform_packet_get_gre_version(pkt));
500 case OF1X_MATCH_GRE_PROT_TYPE:{
502 if (!ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_GRE))
return false;
503 return __utern_compare16(it->__tern, platform_packet_get_gre_prot_type(pkt));
505 case OF1X_MATCH_GRE_KEY:{
507 if (!ptr_ip_proto || !(*ptr_ip_proto == IP_PROTO_GRE))
return false;
508 return __utern_compare32(it->__tern, platform_packet_get_gre_key(pkt));
511 case OF1X_MATCH_PPPOE_CODE:
512 case OF1X_MATCH_PPPOE_TYPE:
513 case OF1X_MATCH_PPPOE_SID:
514 case OF1X_MATCH_PPP_PROT:
515 case OF1X_MATCH_GTP_MSG_TYPE:
516 case OF1X_MATCH_GTP_TEID:
517 case OF1X_MATCH_CAPWAP_WBID:
518 case OF1X_MATCH_CAPWAP_RID:
519 case OF1X_MATCH_CAPWAP_FLAGS:
520 case OF1X_MATCH_WLAN_FC:
521 case OF1X_MATCH_WLAN_TYPE:
522 case OF1X_MATCH_WLAN_SUBTYPE:
523 case OF1X_MATCH_WLAN_DIRECTION:
524 case OF1X_MATCH_WLAN_ADDRESS_1:
525 case OF1X_MATCH_WLAN_ADDRESS_2:
526 case OF1X_MATCH_WLAN_ADDRESS_3:
527 case OF1X_MATCH_GRE_VERSION:
528 case OF1X_MATCH_GRE_PROT_TYPE:
529 case OF1X_MATCH_GRE_KEY:
546 #endif //OF1X_MATCH_PP
OpenFlow v1.0, 1.2 and 1.3.2 matches.