Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -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 | 781d18b | 2014-10-27 10:31:25 -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 | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.openflow.controller; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.Ethernet; |
| 19 | import org.projectfloodlight.openflow.types.OFPort; |
| 20 | |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 21 | import java.util.Optional; |
| 22 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 23 | /** |
| 24 | * A representation of a packet context which allows any provider |
Ayaka Koshibe | ab3374b | 2014-09-19 11:41:25 -0700 | [diff] [blame] | 25 | * to view a packet in event, but may block the response to the |
| 26 | * event if blocked has been called. This packet context can be used |
| 27 | * to react to the packet in event with a packet out. |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 28 | */ |
| 29 | public interface OpenFlowPacketContext { |
| 30 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Blocks further responses (ie. send() calls) on this |
| 33 | * packet in event. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 34 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 35 | * @return true if blocks |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 36 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 37 | boolean block(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Checks whether the packet has been handled. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 41 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 42 | * @return true if handled, false otherwise. |
| 43 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 44 | boolean isHandled(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Provided build has been called send the packet |
| 48 | * out the switch it came in on. |
| 49 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 50 | void send(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Build the packet out in response to this packet in event. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 54 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 55 | * @param outPort the out port to send to packet out of. |
| 56 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 57 | void build(OFPort outPort); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * Build the packet out in response to this packet in event. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 61 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 62 | * @param ethFrame the actual packet to send out. |
| 63 | * @param outPort the out port to send to packet out of. |
| 64 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 65 | void build(Ethernet ethFrame, OFPort outPort); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Provided a handle onto the parsed payload. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 69 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 70 | * @return the parsed form of the payload. |
| 71 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 72 | Ethernet parsed(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Provide an unparsed copy of the data. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 76 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 77 | * @return the unparsed form of the payload. |
| 78 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 79 | byte[] unparsed(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Provide the dpid of the switch where the packet in arrived. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 83 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 84 | * @return the dpid of the switch. |
| 85 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 86 | Dpid dpid(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Provide the port on which the packet arrived. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 90 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 91 | * @return the port |
| 92 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 93 | Integer inPort(); |
alshabib | e9d3a32 | 2014-09-23 15:18:33 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * Indicates that this packet is buffered at the switch. |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 97 | * |
alshabib | e9d3a32 | 2014-09-23 15:18:33 -0700 | [diff] [blame] | 98 | * @return buffer indication |
| 99 | */ |
| 100 | boolean isBuffered(); |
Charles Chan | cb13d12 | 2016-02-10 13:03:40 -0800 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Provide the cookie in the packet in message. |
| 104 | * |
| 105 | * @return optional flow cookie |
| 106 | */ |
| 107 | Optional<Long> cookie(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 108 | } |