blob: cc191ab24103975ea173dbbebbc73bfa971341b9 [file] [log] [blame]
Andreas Wundsam40e14f72013-05-06 14:49:08 -07001package org.openflow.protocol.match;
2
3import org.openflow.types.EthType;
4import org.openflow.types.IPv4;
Andreas Wundsam40e14f72013-05-06 14:49:08 -07005import org.openflow.types.IPv6;
Andreas Wundsam40e14f72013-05-06 14:49:08 -07006import org.openflow.types.IpProtocol;
7import org.openflow.types.MacAddress;
Yotam Harchol161a5d52013-07-25 17:17:48 -07008import org.openflow.types.Masked;
Andreas Wundsam40e14f72013-05-06 14:49:08 -07009import org.openflow.types.OFPort;
10import org.openflow.types.U16;
11import org.openflow.types.U8;
12import org.openflow.types.VlanPcp;
13import org.openflow.types.VlanVid;
Andreas Wundsam40e14f72013-05-06 14:49:08 -070014
15public class MatchField<F, M> {
16 private final String name;
17 public final int id;
18
19 public MatchField(final String name) {
20 this.name = name;
21 this.id = -1;
22 }
23
24 public MatchField(final String name, final int id) {
25 this.name = name;
26 this.id = id;
27 }
28
29 public final static MatchField<OFPort, NoMatch> IN_PORT =
30 new MatchField<OFPort, NoMatch>("in_port", 0);
31 public final static MatchField<OFPort, NoMatch> IN_PHY_PORT =
32 new MatchField<OFPort, NoMatch>("in_phy_port");
33 public final static MatchField<OFPort, NoMatch> METADATA =
34 new MatchField<OFPort, NoMatch>("metadata");
35
Yotam Harchol161a5d52013-07-25 17:17:48 -070036 public final static MatchField<MacAddress, Masked<MacAddress>> ETH_DST =
37 new MatchField<MacAddress, Masked<MacAddress>>("eth_dst");
38 public final static MatchField<MacAddress, Masked<MacAddress>> ETH_SRC =
39 new MatchField<MacAddress, Masked<MacAddress>>("eth_src", 1);
Andreas Wundsam40e14f72013-05-06 14:49:08 -070040
41 public final static MatchField<EthType, NoMatch> ETH_TYPE =
42 new MatchField<EthType, NoMatch>("eth_type");
Yotam Harchol161a5d52013-07-25 17:17:48 -070043
44 public final static MatchField<VlanVid, Masked<VlanVid>> VLAN_VID =
45 new MatchField<VlanVid, Masked<VlanVid>>("vlan_vid");
Andreas Wundsam40e14f72013-05-06 14:49:08 -070046 public final static MatchField<VlanPcp, NoMatch> VLAN_PCP =
47 new MatchField<VlanPcp, NoMatch>("vlan_pcp");
Yotam Harchol161a5d52013-07-25 17:17:48 -070048
49
Andreas Wundsam40e14f72013-05-06 14:49:08 -070050 public final static MatchField<NoMatch, NoMatch> IP_DSCP =
51 new MatchField<NoMatch, NoMatch>("ip_dscp");
52 public final static MatchField<NoMatch, NoMatch> IP_ECN =
53 new MatchField<NoMatch, NoMatch>("ip_dscp");
54 public final static MatchField<IpProtocol, NoMatch> IP_PROTO =
55 new MatchField<IpProtocol, NoMatch>("ip_proto");
56
Yotam Harchol161a5d52013-07-25 17:17:48 -070057 public final static MatchField<IPv4, Masked<IPv4>> IPV4_SRC =
58 new MatchField<IPv4, Masked<IPv4>>("ipv4_src");
59 public final static MatchField<IPv4, Masked<IPv4>> IPV4_DST =
60 new MatchField<IPv4, Masked<IPv4>>("ipv4_dst");
Andreas Wundsam40e14f72013-05-06 14:49:08 -070061
62 public final static MatchField<U16, NoMatch> TCP_SRC = new MatchField<U16, NoMatch>(
63 "tcp_src");
64 public final static MatchField<U16, NoMatch> TCP_DST = new MatchField<U16, NoMatch>(
65 "tcp_dst");
66
67 public final static MatchField<U16, NoMatch> UDP_SRC = new MatchField<U16, NoMatch>(
68 "udp_src");
69 public final static MatchField<U16, NoMatch> UDP_DST = new MatchField<U16, NoMatch>(
70 "udp_dst");
71
72 public final static MatchField<U16, NoMatch> SCTP_SRC = new MatchField<U16, NoMatch>(
73 "sctp_src");
74 public final static MatchField<U16, NoMatch> SCTP_DST = new MatchField<U16, NoMatch>(
75 "sctp_dst");
76
77 public final static MatchField<U8, NoMatch> ICMPV4_TYPE = new MatchField<U8, NoMatch>(
78 "icmpv4_src");
79 public final static MatchField<U8, NoMatch> ICMPV4_CODE = new MatchField<U8, NoMatch>(
80 "icmpv4_dst");
81
82 public final static MatchField<U16, NoMatch> ARP_OP = new MatchField<U16, NoMatch>(
83 "arp_op");
Yotam Harchol161a5d52013-07-25 17:17:48 -070084 public final static MatchField<IPv4, Masked<IPv4>> ARP_SPA =
85 new MatchField<IPv4, Masked<IPv4>>("arp_spa");
86 public final static MatchField<IPv4, Masked<IPv4>> ARP_TPA =
87 new MatchField<IPv4, Masked<IPv4>>("arp_tpa");
88 public final static MatchField<MacAddress, Masked<MacAddress>> ARP_SHA =
89 new MatchField<MacAddress, Masked<MacAddress>>("arp_sha");
90 public final static MatchField<MacAddress, Masked<MacAddress>> ARP_THA =
91 new MatchField<MacAddress, Masked<MacAddress>>("arp_tha");
Andreas Wundsam40e14f72013-05-06 14:49:08 -070092
Yotam Harchol161a5d52013-07-25 17:17:48 -070093 public final static MatchField<IPv6, Masked<IPv6>> IPV6_SRC =
94 new MatchField<IPv6, Masked<IPv6>>("ipv6_src");
95 public final static MatchField<IPv6, Masked<IPv6>> IPV6_DST =
96 new MatchField<IPv6, Masked<IPv6>>("ipv6_dst");
Andreas Wundsam40e14f72013-05-06 14:49:08 -070097
Yotam Harchol161a5d52013-07-25 17:17:48 -070098 // FIXME: Wrong masked type?
99 public final static MatchField<U8, Masked<IPv6>> IPV6_FLABEL =
100 new MatchField<U8, Masked<IPv6>>("ipv6_flabel");
Andreas Wundsam40e14f72013-05-06 14:49:08 -0700101
102 public String getName() {
103 return name;
104 }
105
106}