blob: 1acc1a26e91838e0f5bf21aa7bbbc0acb3739554 [file] [log] [blame]
Yotam Harcholf3f11152013-09-05 16:47:16 -07001package org.projectfloodlight.openflow.protocol.match;
2
3import org.projectfloodlight.openflow.types.ArpOpcode;
Rich Laneeb21c4f2013-10-28 17:34:41 -07004import org.projectfloodlight.openflow.types.ClassId;
Yotam Harcholf3f11152013-09-05 16:47:16 -07005import org.projectfloodlight.openflow.types.EthType;
6import org.projectfloodlight.openflow.types.ICMPv4Code;
7import org.projectfloodlight.openflow.types.ICMPv4Type;
Yotam Harchola289d552013-09-16 10:10:40 -07008import org.projectfloodlight.openflow.types.IPv4Address;
9import org.projectfloodlight.openflow.types.IPv6Address;
Yotam Harcholf3f11152013-09-05 16:47:16 -070010import org.projectfloodlight.openflow.types.IPv6FlowLabel;
11import org.projectfloodlight.openflow.types.IpDscp;
12import org.projectfloodlight.openflow.types.IpEcn;
13import org.projectfloodlight.openflow.types.IpProtocol;
Rich Lane376cafe2013-10-27 21:49:14 -070014import org.projectfloodlight.openflow.types.LagId;
Yotam Harcholf3f11152013-09-05 16:47:16 -070015import org.projectfloodlight.openflow.types.MacAddress;
Andreas Wundsam520c8802013-10-08 22:05:23 -070016import org.projectfloodlight.openflow.types.OFBitMask128;
Rich Lane9c27b5d2013-10-30 17:14:32 -070017import org.projectfloodlight.openflow.types.OFBooleanValue;
Yotam Harcholf3f11152013-09-05 16:47:16 -070018import org.projectfloodlight.openflow.types.OFMetadata;
19import org.projectfloodlight.openflow.types.OFPort;
20import org.projectfloodlight.openflow.types.OFValueType;
Andreas Wundsam98a18632013-11-05 11:34:24 -080021import org.projectfloodlight.openflow.types.OFVlanVidMatch;
Yotam Harcholf3f11152013-09-05 16:47:16 -070022import org.projectfloodlight.openflow.types.TransportPort;
Rich Lane9b178072014-05-19 15:31:55 -070023import org.projectfloodlight.openflow.types.U16;
Byungjoon Leeb4c38b82014-04-23 14:24:59 +090024import org.projectfloodlight.openflow.types.U64;
Yotam Harchola86e4252013-09-06 15:36:28 -070025import org.projectfloodlight.openflow.types.U32;
26import org.projectfloodlight.openflow.types.U8;
Rich Lane53ddf5c2014-03-20 15:24:08 -070027import org.projectfloodlight.openflow.types.UDF;
Rich Laneeb21c4f2013-10-28 17:34:41 -070028import org.projectfloodlight.openflow.types.VRF;
Andreas Wundsam98a18632013-11-05 11:34:24 -080029import org.projectfloodlight.openflow.types.VlanPcp;
Yotam Harcholf3f11152013-09-05 16:47:16 -070030
31@SuppressWarnings("unchecked")
32public class MatchField<F extends OFValueType<F>> {
33 private final String name;
34 public final MatchFields id;
35 private final Prerequisite<?>[] prerequisites;
36
37 private MatchField(final String name, final MatchFields id, Prerequisite<?>... prerequisites) {
38 this.name = name;
39 this.id = id;
40 this.prerequisites = prerequisites;
41 }
42
43 public final static MatchField<OFPort> IN_PORT =
44 new MatchField<OFPort>("in_port", MatchFields.IN_PORT);
45
46 public final static MatchField<OFPort> IN_PHY_PORT =
47 new MatchField<OFPort>("in_phy_port", MatchFields.IN_PHY_PORT,
48 new Prerequisite<OFPort>(MatchField.IN_PORT));
49
50 public final static MatchField<OFMetadata> METADATA =
51 new MatchField<OFMetadata>("metadata", MatchFields.METADATA);
52
53 public final static MatchField<MacAddress> ETH_DST =
54 new MatchField<MacAddress>("eth_dst", MatchFields.ETH_DST);
55
56 public final static MatchField<MacAddress> ETH_SRC =
57 new MatchField<MacAddress>("eth_src", MatchFields.ETH_SRC);
58
59 public final static MatchField<EthType> ETH_TYPE =
60 new MatchField<EthType>("eth_type", MatchFields.ETH_TYPE);
61
Andreas Wundsam98a18632013-11-05 11:34:24 -080062 public final static MatchField<OFVlanVidMatch> VLAN_VID =
63 new MatchField<OFVlanVidMatch>("vlan_vid", MatchFields.VLAN_VID);
Yotam Harcholf3f11152013-09-05 16:47:16 -070064
65 public final static MatchField<VlanPcp> VLAN_PCP =
66 new MatchField<VlanPcp>("vlan_pcp", MatchFields.VLAN_PCP,
Andreas Wundsam98a18632013-11-05 11:34:24 -080067 new Prerequisite<OFVlanVidMatch>(MatchField.VLAN_VID));
Yotam Harcholf3f11152013-09-05 16:47:16 -070068
69 public final static MatchField<IpDscp> IP_DSCP =
70 new MatchField<IpDscp>("ip_dscp", MatchFields.IP_DSCP,
Andreas Wundsamb70b0442013-09-23 14:44:43 -070071 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
Yotam Harcholf3f11152013-09-05 16:47:16 -070072
73 public final static MatchField<IpEcn> IP_ECN =
Ronald Li8083dfa2013-11-20 15:00:05 -080074 new MatchField<IpEcn>("ip_ecn", MatchFields.IP_ECN,
Andreas Wundsamb70b0442013-09-23 14:44:43 -070075 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
Yotam Harcholf3f11152013-09-05 16:47:16 -070076
77 public final static MatchField<IpProtocol> IP_PROTO =
78 new MatchField<IpProtocol>("ip_proto", MatchFields.IP_PROTO,
Andreas Wundsamb70b0442013-09-23 14:44:43 -070079 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
Yotam Harcholf3f11152013-09-05 16:47:16 -070080
Yotam Harchola289d552013-09-16 10:10:40 -070081 public final static MatchField<IPv4Address> IPV4_SRC =
82 new MatchField<IPv4Address>("ipv4_src", MatchFields.IPV4_SRC,
Andreas Wundsamb70b0442013-09-23 14:44:43 -070083 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
Yotam Harcholf3f11152013-09-05 16:47:16 -070084
Yotam Harchola289d552013-09-16 10:10:40 -070085 public final static MatchField<IPv4Address> IPV4_DST =
86 new MatchField<IPv4Address>("ipv4_dst", MatchFields.IPV4_DST,
Andreas Wundsamb70b0442013-09-23 14:44:43 -070087 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
Yotam Harcholf3f11152013-09-05 16:47:16 -070088
89 public final static MatchField<TransportPort> TCP_SRC = new MatchField<TransportPort>(
90 "tcp_src", MatchFields.TCP_SRC,
Andreas Wundsam520c8802013-10-08 22:05:23 -070091 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.TCP));
Yotam Harcholf3f11152013-09-05 16:47:16 -070092
93 public final static MatchField<TransportPort> TCP_DST = new MatchField<TransportPort>(
94 "tcp_dst", MatchFields.TCP_DST,
Andreas Wundsam520c8802013-10-08 22:05:23 -070095 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.TCP));
Yotam Harcholf3f11152013-09-05 16:47:16 -070096
97 public final static MatchField<TransportPort> UDP_SRC = new MatchField<TransportPort>(
98 "udp_src", MatchFields.UDP_SRC,
Andreas Wundsam520c8802013-10-08 22:05:23 -070099 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.UDP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700100
101 public final static MatchField<TransportPort> UDP_DST = new MatchField<TransportPort>(
102 "udp_dst", MatchFields.UDP_DST,
Andreas Wundsam520c8802013-10-08 22:05:23 -0700103 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.UDP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700104
105 public final static MatchField<TransportPort> SCTP_SRC = new MatchField<TransportPort>(
106 "sctp_src", MatchFields.SCTP_SRC,
Andreas Wundsam520c8802013-10-08 22:05:23 -0700107 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.SCTP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700108
109 public final static MatchField<TransportPort> SCTP_DST = new MatchField<TransportPort>(
110 "sctp_dst", MatchFields.SCTP_DST,
Andreas Wundsam520c8802013-10-08 22:05:23 -0700111 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.SCTP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700112
113 public final static MatchField<ICMPv4Type> ICMPV4_TYPE = new MatchField<ICMPv4Type>(
Ronald Lid7a63f02013-11-20 15:49:33 -0800114 "icmpv4_type", MatchFields.ICMPV4_TYPE,
Andreas Wundsam520c8802013-10-08 22:05:23 -0700115 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.ICMP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700116
117 public final static MatchField<ICMPv4Code> ICMPV4_CODE = new MatchField<ICMPv4Code>(
Ronald Lid7a63f02013-11-20 15:49:33 -0800118 "icmpv4_code", MatchFields.ICMPV4_CODE,
Andreas Wundsam520c8802013-10-08 22:05:23 -0700119 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.ICMP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700120
121 public final static MatchField<ArpOpcode> ARP_OP = new MatchField<ArpOpcode>(
122 "arp_op", MatchFields.ARP_OP,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700123 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700124
Yotam Harchola289d552013-09-16 10:10:40 -0700125 public final static MatchField<IPv4Address> ARP_SPA =
126 new MatchField<IPv4Address>("arp_spa", MatchFields.ARP_SPA,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700127 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700128
Yotam Harchola289d552013-09-16 10:10:40 -0700129 public final static MatchField<IPv4Address> ARP_TPA =
130 new MatchField<IPv4Address>("arp_tpa", MatchFields.ARP_TPA,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700131 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700132
133 public final static MatchField<MacAddress> ARP_SHA =
134 new MatchField<MacAddress>("arp_sha", MatchFields.ARP_SHA,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700135 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700136
137 public final static MatchField<MacAddress> ARP_THA =
138 new MatchField<MacAddress>("arp_tha", MatchFields.ARP_THA,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700139 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700140
Yotam Harchola289d552013-09-16 10:10:40 -0700141 public final static MatchField<IPv6Address> IPV6_SRC =
142 new MatchField<IPv6Address>("ipv6_src", MatchFields.IPV6_SRC,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700143 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700144
Yotam Harchola289d552013-09-16 10:10:40 -0700145 public final static MatchField<IPv6Address> IPV6_DST =
146 new MatchField<IPv6Address>("ipv6_dst", MatchFields.IPV6_DST,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700147 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700148
149 public final static MatchField<IPv6FlowLabel> IPV6_FLABEL =
150 new MatchField<IPv6FlowLabel>("ipv6_flabel", MatchFields.IPV6_FLABEL,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700151 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
Yotam Harcholf3f11152013-09-05 16:47:16 -0700152
Yotam Harchola86e4252013-09-06 15:36:28 -0700153 public final static MatchField<U8> ICMPV6_TYPE =
154 new MatchField<U8>("icmpv6_type", MatchFields.ICMPV6_TYPE,
Andreas Wundsam520c8802013-10-08 22:05:23 -0700155 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IPv6_ICMP));
Yotam Harchola86e4252013-09-06 15:36:28 -0700156
157 public final static MatchField<U8> ICMPV6_CODE =
158 new MatchField<U8>("icmpv6_code", MatchFields.ICMPV6_CODE,
Andreas Wundsam520c8802013-10-08 22:05:23 -0700159 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IPv6_ICMP));
Yotam Harchola86e4252013-09-06 15:36:28 -0700160
Yotam Harchola289d552013-09-16 10:10:40 -0700161 public final static MatchField<IPv6Address> IPV6_ND_TARGET =
162 new MatchField<IPv6Address>("ipv6_nd_target", MatchFields.IPV6_ND_TARGET,
Yotam Harchola86e4252013-09-06 15:36:28 -0700163 new Prerequisite<U8>(MatchField.ICMPV6_TYPE, U8.of((short)135), U8.of((short)136)));
164
165 public final static MatchField<MacAddress> IPV6_ND_SLL =
166 new MatchField<MacAddress>("ipv6_nd_sll", MatchFields.IPV6_ND_SLL,
167 new Prerequisite<U8>(MatchField.ICMPV6_TYPE, U8.of((short)135)));
168
169 public final static MatchField<MacAddress> IPV6_ND_TLL =
170 new MatchField<MacAddress>("ipv6_nd_tll", MatchFields.IPV6_ND_TLL,
171 new Prerequisite<U8>(MatchField.ICMPV6_TYPE, U8.of((short)136)));
172
173 public final static MatchField<U32> MPLS_LABEL =
174 new MatchField<U32>("mpls_label", MatchFields.MPLS_LABEL,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700175 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
Yotam Harchola86e4252013-09-06 15:36:28 -0700176
177 public final static MatchField<U8> MPLS_TC =
178 new MatchField<U8>("mpls_tc", MatchFields.MPLS_TC,
Andreas Wundsamb70b0442013-09-23 14:44:43 -0700179 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
Yotam Harchola86e4252013-09-06 15:36:28 -0700180
Byungjoon Leeb4c38b82014-04-23 14:24:59 +0900181 public final static MatchField<U64> TUNNEL_ID =
182 new MatchField<U64>("tunnel_id", MatchFields.TUNNEL_ID);
183
Yotam Harchol2c535582013-10-01 15:50:20 -0700184 public final static MatchField<OFBitMask128> BSN_IN_PORTS_128 =
Ronald Lia07b2572013-11-18 13:54:08 -0800185 new MatchField<OFBitMask128>("bsn_in_ports_128", MatchFields.BSN_IN_PORTS_128);
Yotam Harchola11f38b2013-09-26 15:38:17 -0700186
Rich Lane376cafe2013-10-27 21:49:14 -0700187 public final static MatchField<LagId> BSN_LAG_ID =
188 new MatchField<LagId>("bsn_lag_id", MatchFields.BSN_LAG_ID);
Rich Lane1424d0b2013-10-24 17:16:24 -0700189
Rich Laneeb21c4f2013-10-28 17:34:41 -0700190 public final static MatchField<VRF> BSN_VRF =
191 new MatchField<VRF>("bsn_vrf", MatchFields.BSN_VRF);
192
Rich Lane9c27b5d2013-10-30 17:14:32 -0700193 public final static MatchField<OFBooleanValue> BSN_GLOBAL_VRF_ALLOWED =
194 new MatchField<OFBooleanValue>("bsn_global_vrf_allowed", MatchFields.BSN_GLOBAL_VRF_ALLOWED);
Rich Laneeb21c4f2013-10-28 17:34:41 -0700195
196 public final static MatchField<ClassId> BSN_L3_INTERFACE_CLASS_ID =
197 new MatchField<ClassId>("bsn_l3_interface_class_id", MatchFields.BSN_L3_INTERFACE_CLASS_ID);
198
199 public final static MatchField<ClassId> BSN_L3_SRC_CLASS_ID =
200 new MatchField<ClassId>("bsn_l3_src_class_id", MatchFields.BSN_L3_SRC_CLASS_ID);
201
202 public final static MatchField<ClassId> BSN_L3_DST_CLASS_ID =
203 new MatchField<ClassId>("bsn_l3_dst_class_id", MatchFields.BSN_L3_DST_CLASS_ID);
204
Rich Lane917bb9a2014-03-11 17:49:56 -0700205 public final static MatchField<ClassId> BSN_EGR_PORT_GROUP_ID =
206 new MatchField<ClassId>("bsn_egr_port_group_id", MatchFields.BSN_EGR_PORT_GROUP_ID);
207
Rich Lane53ddf5c2014-03-20 15:24:08 -0700208 public final static MatchField<UDF> BSN_UDF0 =
209 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF0);
210
211 public final static MatchField<UDF> BSN_UDF1 =
212 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF1);
213
214 public final static MatchField<UDF> BSN_UDF2 =
215 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF2);
216
217 public final static MatchField<UDF> BSN_UDF3 =
218 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF3);
219
220 public final static MatchField<UDF> BSN_UDF4 =
221 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF4);
222
223 public final static MatchField<UDF> BSN_UDF5 =
224 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF5);
225
226 public final static MatchField<UDF> BSN_UDF6 =
227 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF6);
228
229 public final static MatchField<UDF> BSN_UDF7 =
230 new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF7);
231
Rich Lane9b178072014-05-19 15:31:55 -0700232 public final static MatchField<U16> BSN_TCP_FLAGS =
233 new MatchField<U16>("bsn_tcp_flags", MatchFields.BSN_TCP_FLAGS);
234
Rich Lanea5eeae32014-06-26 19:59:04 -0700235 public final static MatchField<ClassId> BSN_VLAN_XLATE_PORT_GROUP_ID =
236 new MatchField<ClassId>("bsn_vlan_xlate_port_group_id", MatchFields.BSN_VLAN_XLATE_PORT_GROUP_ID);
237
Praseed Balakrishnanf78068b2014-09-04 10:30:40 -0700238
239 public final static MatchField<U64> OCH_SIGID =
240 new MatchField<U64>("och_sigid",
241 MatchFields.OCH_SIGID);
242
243 public final static MatchField<U64> OCH_SIGTYPE =
244 new MatchField<U64>("och_sigid",
245 MatchFields.OCH_SIGTYPE);
246
Yotam Harcholf3f11152013-09-05 16:47:16 -0700247 public String getName() {
248 return name;
249 }
250
251 public boolean arePrerequisitesOK(Match match) {
252 for (Prerequisite<?> p : this.prerequisites) {
253 if (!p.isSatisfied(match)) {
254 return false;
255 }
256 }
257 return true;
258 }
259
260}