Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 1 | package org.openflow.protocol.match; |
| 2 | |
| 3 | import org.openflow.types.EthType; |
| 4 | import org.openflow.types.IPv4; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 5 | import org.openflow.types.IPv6; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 6 | import org.openflow.types.IpProtocol; |
| 7 | import org.openflow.types.MacAddress; |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 8 | import org.openflow.types.Masked; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 9 | import org.openflow.types.OFPort; |
| 10 | import org.openflow.types.U16; |
| 11 | import org.openflow.types.U8; |
| 12 | import org.openflow.types.VlanPcp; |
| 13 | import org.openflow.types.VlanVid; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 14 | |
| 15 | public 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 Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 36 | 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 Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 40 | |
| 41 | public final static MatchField<EthType, NoMatch> ETH_TYPE = |
| 42 | new MatchField<EthType, NoMatch>("eth_type"); |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 43 | |
| 44 | public final static MatchField<VlanVid, Masked<VlanVid>> VLAN_VID = |
| 45 | new MatchField<VlanVid, Masked<VlanVid>>("vlan_vid"); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 46 | public final static MatchField<VlanPcp, NoMatch> VLAN_PCP = |
| 47 | new MatchField<VlanPcp, NoMatch>("vlan_pcp"); |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 48 | |
| 49 | |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 50 | 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 Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 57 | 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 Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 61 | |
| 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 Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 84 | 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 Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 92 | |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 93 | 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 Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 97 | |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame^] | 98 | // FIXME: Wrong masked type? |
| 99 | public final static MatchField<U8, Masked<IPv6>> IPV6_FLABEL = |
| 100 | new MatchField<U8, Masked<IPv6>>("ipv6_flabel"); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 101 | |
| 102 | public String getName() { |
| 103 | return name; |
| 104 | } |
| 105 | |
| 106 | } |