Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow.criteria; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 17 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 18 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 19 | /** |
| 20 | * Representation of a single header field selection. |
| 21 | */ |
| 22 | public interface Criterion { |
| 23 | |
| 24 | /** |
| 25 | * Types of fields to which the selection criterion may apply. |
| 26 | */ |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 27 | // From page 75 of OpenFlow 1.5.0 spec |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 28 | enum Type { |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 29 | /** Switch input port. */ |
| 30 | IN_PORT, |
| 31 | /** Switch physical input port. */ |
| 32 | IN_PHY_PORT, |
| 33 | /** Metadata passed between tables. */ |
| 34 | METADATA, |
| 35 | /** Ethernet destination address. */ |
| 36 | ETH_DST, |
| 37 | /** Ethernet source address. */ |
| 38 | ETH_SRC, |
| 39 | /** Ethernet frame type. */ |
| 40 | ETH_TYPE, |
| 41 | /** VLAN id. */ |
| 42 | VLAN_VID, |
| 43 | /** VLAN priority. */ |
| 44 | VLAN_PCP, |
| 45 | /** IP DSCP (6 bits in ToS field). */ |
| 46 | IP_DSCP, |
| 47 | /** IP ECN (2 bits in ToS field). */ |
| 48 | IP_ECN, |
| 49 | /** IP protocol. */ |
| 50 | IP_PROTO, |
| 51 | /** IPv4 source address. */ |
| 52 | IPV4_SRC, |
| 53 | /** IPv4 destination address. */ |
| 54 | IPV4_DST, |
| 55 | /** TCP source port. */ |
| 56 | TCP_SRC, |
| 57 | /** TCP destination port. */ |
| 58 | TCP_DST, |
| 59 | /** UDP source port. */ |
| 60 | UDP_SRC, |
| 61 | /** UDP destination port. */ |
| 62 | UDP_DST, |
| 63 | /** SCTP source port. */ |
| 64 | SCTP_SRC, |
| 65 | /** SCTP destination port. */ |
| 66 | SCTP_DST, |
| 67 | /** ICMP type. */ |
| 68 | ICMPV4_TYPE, |
| 69 | /** ICMP code. */ |
| 70 | ICMPV4_CODE, |
| 71 | /** ARP opcode. */ |
| 72 | ARP_OP, |
| 73 | /** ARP source IPv4 address. */ |
| 74 | ARP_SPA, |
| 75 | /** ARP target IPv4 address. */ |
| 76 | ARP_TPA, |
| 77 | /** ARP source hardware address. */ |
| 78 | ARP_SHA, |
| 79 | /** ARP target hardware address. */ |
| 80 | ARP_THA, |
| 81 | /** IPv6 source address. */ |
| 82 | IPV6_SRC, |
| 83 | /** IPv6 destination address. */ |
| 84 | IPV6_DST, |
| 85 | /** IPv6 Flow Label. */ |
| 86 | IPV6_FLABEL, |
| 87 | /** ICMPv6 type. */ |
| 88 | ICMPV6_TYPE, |
| 89 | /** ICMPv6 code. */ |
| 90 | ICMPV6_CODE, |
| 91 | /** Target address for ND. */ |
| 92 | IPV6_ND_TARGET, |
| 93 | /** Source link-layer for ND. */ |
| 94 | IPV6_ND_SLL, |
| 95 | /** Target link-layer for ND. */ |
| 96 | IPV6_ND_TLL, |
| 97 | /** MPLS label. */ |
| 98 | MPLS_LABEL, |
| 99 | /** MPLS TC. */ |
| 100 | MPLS_TC, |
| 101 | /** MPLS BoS bit. */ |
| 102 | MPLS_BOS, |
| 103 | /** PBB I-SID. */ |
| 104 | PBB_ISID, |
| 105 | /** Logical Port Metadata. */ |
| 106 | TUNNEL_ID, |
| 107 | /** IPv6 Extension Header pseudo-field. */ |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 108 | IPV6_EXTHDR, |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 109 | /** Unassigned value: 40. */ |
| 110 | UNASSIGNED_40, |
| 111 | /** PBB UCA header field. */ |
| 112 | PBB_UCA, |
| 113 | /** TCP flags. */ |
| 114 | TCP_FLAGS, |
| 115 | /** Output port from action set metadata. */ |
| 116 | ACTSET_OUTPUT, |
| 117 | /** Packet type value. */ |
| 118 | PACKET_TYPE, |
| 119 | |
| 120 | // |
| 121 | // NOTE: Everything below is defined elsewhere: ONOS-specific, |
| 122 | // extensions, etc. |
| 123 | // |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 124 | /** Optical channel signal ID (lambda). */ |
| 125 | OCH_SIGID, |
| 126 | /** Optical channel signal type (fixed or flexible). */ |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 127 | OCH_SIGTYPE, |
Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 128 | /** ODU (Optical channel Data Unit) signal ID. */ |
| 129 | ODU_SIGID, |
| 130 | /** ODU (Optical channel Data Unit) signal type. */ |
| 131 | ODU_SIGTYPE, |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * An empty criterion. |
| 135 | */ |
| 136 | DUMMY |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 137 | } |
| 138 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 139 | /** |
| 140 | * Returns the type of criterion. |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 141 | * |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 142 | * @return type of criterion |
| 143 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 144 | Type type(); |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 145 | |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 146 | /** |
| 147 | * Bit definitions for IPv6 Extension Header pseudo-field. |
| 148 | * From page 79 of OpenFlow 1.5.0 spec. |
| 149 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 150 | enum IPv6ExthdrFlags { |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 151 | /** "No next header" encountered. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 152 | NONEXT((short) (1 << 0)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 153 | /** Encrypted Sec Payload header present. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 154 | ESP((short) (1 << 1)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 155 | /** Authentication header present. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 156 | AUTH((short) (1 << 2)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 157 | /** 1 or 2 dest headers present. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 158 | DEST((short) (1 << 3)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 159 | /** Fragment header present. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 160 | FRAG((short) (1 << 4)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 161 | /** Router header present. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 162 | ROUTER((short) (1 << 5)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 163 | /** Hop-by-hop header present. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 164 | HOP((short) (1 << 6)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 165 | /** Unexpected repeats encountered. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 166 | UNREP((short) (1 << 7)), |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 167 | /** Unexpected sequencing encountered. */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 168 | UNSEQ((short) (1 << 8)); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 169 | |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 170 | private short value; |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 171 | |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 172 | IPv6ExthdrFlags(short value) { |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 173 | this.value = value; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Gets the value as an integer. |
| 178 | * |
| 179 | * @return the value as an integer |
| 180 | */ |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 181 | public short getValue() { |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 182 | return this.value; |
| 183 | } |
| 184 | } |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 185 | } |