blob: 78e6075afdc373a3ddadc759b1677671d7f6fc5e [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001package org.projectfloodlight.openflow.protocol.match;
2
3import org.projectfloodlight.openflow.types.ArpOpcode;
4import org.projectfloodlight.openflow.types.ClassId;
5import org.projectfloodlight.openflow.types.EthType;
6import org.projectfloodlight.openflow.types.ICMPv4Code;
7import org.projectfloodlight.openflow.types.ICMPv4Type;
8import org.projectfloodlight.openflow.types.IPv4Address;
9import org.projectfloodlight.openflow.types.IPv6Address;
10import org.projectfloodlight.openflow.types.IPv6FlowLabel;
11import org.projectfloodlight.openflow.types.IpDscp;
12import org.projectfloodlight.openflow.types.IpEcn;
13import org.projectfloodlight.openflow.types.IpProtocol;
14import org.projectfloodlight.openflow.types.LagId;
15import org.projectfloodlight.openflow.types.MacAddress;
16import org.projectfloodlight.openflow.types.OFBitMask128;
17import org.projectfloodlight.openflow.types.OFBooleanValue;
18import org.projectfloodlight.openflow.types.OFMetadata;
19import org.projectfloodlight.openflow.types.OFPort;
20import org.projectfloodlight.openflow.types.OFValueType;
21import org.projectfloodlight.openflow.types.OFVlanVidMatch;
22import org.projectfloodlight.openflow.types.TransportPort;
23import org.projectfloodlight.openflow.types.U16;
24import org.projectfloodlight.openflow.types.U64;
25import org.projectfloodlight.openflow.types.U32;
26import org.projectfloodlight.openflow.types.U8;
27import org.projectfloodlight.openflow.types.UDF;
28import org.projectfloodlight.openflow.types.VRF;
29import org.projectfloodlight.openflow.types.VlanPcp;
30
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
62 public final static MatchField<OFVlanVidMatch> VLAN_VID =
63 new MatchField<OFVlanVidMatch>("vlan_vid", MatchFields.VLAN_VID);
64
65 public final static MatchField<VlanPcp> VLAN_PCP =
66 new MatchField<VlanPcp>("vlan_pcp", MatchFields.VLAN_PCP,
67 new Prerequisite<OFVlanVidMatch>(MatchField.VLAN_VID));
68
69 public final static MatchField<IpDscp> IP_DSCP =
70 new MatchField<IpDscp>("ip_dscp", MatchFields.IP_DSCP,
71 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
72
73 public final static MatchField<IpEcn> IP_ECN =
74 new MatchField<IpEcn>("ip_ecn", MatchFields.IP_ECN,
75 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
76
77 public final static MatchField<IpProtocol> IP_PROTO =
78 new MatchField<IpProtocol>("ip_proto", MatchFields.IP_PROTO,
79 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
80
81 public final static MatchField<IPv4Address> IPV4_SRC =
82 new MatchField<IPv4Address>("ipv4_src", MatchFields.IPV4_SRC,
83 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
84
85 public final static MatchField<IPv4Address> IPV4_DST =
86 new MatchField<IPv4Address>("ipv4_dst", MatchFields.IPV4_DST,
87 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
88
89 public final static MatchField<TransportPort> TCP_SRC = new MatchField<TransportPort>(
90 "tcp_src", MatchFields.TCP_SRC,
91 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.TCP));
92
93 public final static MatchField<TransportPort> TCP_DST = new MatchField<TransportPort>(
94 "tcp_dst", MatchFields.TCP_DST,
95 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.TCP));
96
97 public final static MatchField<TransportPort> UDP_SRC = new MatchField<TransportPort>(
98 "udp_src", MatchFields.UDP_SRC,
99 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.UDP));
100
101 public final static MatchField<TransportPort> UDP_DST = new MatchField<TransportPort>(
102 "udp_dst", MatchFields.UDP_DST,
103 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.UDP));
104
105 public final static MatchField<TransportPort> SCTP_SRC = new MatchField<TransportPort>(
106 "sctp_src", MatchFields.SCTP_SRC,
107 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.SCTP));
108
109 public final static MatchField<TransportPort> SCTP_DST = new MatchField<TransportPort>(
110 "sctp_dst", MatchFields.SCTP_DST,
111 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.SCTP));
112
113 public final static MatchField<ICMPv4Type> ICMPV4_TYPE = new MatchField<ICMPv4Type>(
114 "icmpv4_type", MatchFields.ICMPV4_TYPE,
115 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.ICMP));
116
117 public final static MatchField<ICMPv4Code> ICMPV4_CODE = new MatchField<ICMPv4Code>(
118 "icmpv4_code", MatchFields.ICMPV4_CODE,
119 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.ICMP));
120
121 public final static MatchField<ArpOpcode> ARP_OP = new MatchField<ArpOpcode>(
122 "arp_op", MatchFields.ARP_OP,
123 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
124
125 public final static MatchField<IPv4Address> ARP_SPA =
126 new MatchField<IPv4Address>("arp_spa", MatchFields.ARP_SPA,
127 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
128
129 public final static MatchField<IPv4Address> ARP_TPA =
130 new MatchField<IPv4Address>("arp_tpa", MatchFields.ARP_TPA,
131 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
132
133 public final static MatchField<MacAddress> ARP_SHA =
134 new MatchField<MacAddress>("arp_sha", MatchFields.ARP_SHA,
135 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
136
137 public final static MatchField<MacAddress> ARP_THA =
138 new MatchField<MacAddress>("arp_tha", MatchFields.ARP_THA,
139 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
140
141 public final static MatchField<IPv6Address> IPV6_SRC =
142 new MatchField<IPv6Address>("ipv6_src", MatchFields.IPV6_SRC,
143 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
144
145 public final static MatchField<IPv6Address> IPV6_DST =
146 new MatchField<IPv6Address>("ipv6_dst", MatchFields.IPV6_DST,
147 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
148
149 public final static MatchField<IPv6FlowLabel> IPV6_FLABEL =
150 new MatchField<IPv6FlowLabel>("ipv6_flabel", MatchFields.IPV6_FLABEL,
151 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
152
153 public final static MatchField<U8> ICMPV6_TYPE =
154 new MatchField<U8>("icmpv6_type", MatchFields.ICMPV6_TYPE,
155 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IPv6_ICMP));
156
157 public final static MatchField<U8> ICMPV6_CODE =
158 new MatchField<U8>("icmpv6_code", MatchFields.ICMPV6_CODE,
159 new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IPv6_ICMP));
160
161 public final static MatchField<IPv6Address> IPV6_ND_TARGET =
162 new MatchField<IPv6Address>("ipv6_nd_target", MatchFields.IPV6_ND_TARGET,
163 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,
175 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
176
177 public final static MatchField<U8> MPLS_TC =
178 new MatchField<U8>("mpls_tc", MatchFields.MPLS_TC,
179 new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
180
181 public final static MatchField<U64> TUNNEL_ID =
182 new MatchField<U64>("tunnel_id", MatchFields.TUNNEL_ID);
183
184 public final static MatchField<OFBitMask128> BSN_IN_PORTS_128 =
185 new MatchField<OFBitMask128>("bsn_in_ports_128", MatchFields.BSN_IN_PORTS_128);
186
187 public final static MatchField<LagId> BSN_LAG_ID =
188 new MatchField<LagId>("bsn_lag_id", MatchFields.BSN_LAG_ID);
189
190 public final static MatchField<VRF> BSN_VRF =
191 new MatchField<VRF>("bsn_vrf", MatchFields.BSN_VRF);
192
193 public final static MatchField<OFBooleanValue> BSN_GLOBAL_VRF_ALLOWED =
194 new MatchField<OFBooleanValue>("bsn_global_vrf_allowed", MatchFields.BSN_GLOBAL_VRF_ALLOWED);
195
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
205 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
208 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
232 public final static MatchField<U16> BSN_TCP_FLAGS =
233 new MatchField<U16>("bsn_tcp_flags", MatchFields.BSN_TCP_FLAGS);
234
235 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
238 public String getName() {
239 return name;
240 }
241
242 public boolean arePrerequisitesOK(Match match) {
243 for (Prerequisite<?> p : this.prerequisites) {
244 if (!p.isSatisfied(match)) {
245 return false;
246 }
247 }
248 return true;
249 }
250
251}