blob: 740d89d091d61dea69a4c20dcb16bc6c622c7cfd [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.openflow.controller;
tom7ef8ff92014-09-17 13:08:06 -070017
18import org.onlab.packet.Ethernet;
19import org.projectfloodlight.openflow.types.OFPort;
20
21/**
22 * A representation of a packet context which allows any provider
Ayaka Koshibeab3374b2014-09-19 11:41:25 -070023 * to view a packet in event, but may block the response to the
24 * event if blocked has been called. This packet context can be used
25 * to react to the packet in event with a packet out.
tom7ef8ff92014-09-17 13:08:06 -070026 */
27public interface OpenFlowPacketContext {
28
tom7ef8ff92014-09-17 13:08:06 -070029 /**
30 * Blocks further responses (ie. send() calls) on this
31 * packet in event.
Yuta HIGUCHI5c947272014-11-03 21:39:21 -080032 * @return true if blocks
tom7ef8ff92014-09-17 13:08:06 -070033 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070034 boolean block();
tom7ef8ff92014-09-17 13:08:06 -070035
36 /**
37 * Checks whether the packet has been handled.
38 * @return true if handled, false otherwise.
39 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070040 boolean isHandled();
tom7ef8ff92014-09-17 13:08:06 -070041
42 /**
43 * Provided build has been called send the packet
44 * out the switch it came in on.
45 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070046 void send();
tom7ef8ff92014-09-17 13:08:06 -070047
48 /**
49 * Build the packet out in response to this packet in event.
50 * @param outPort the out port to send to packet out of.
51 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070052 void build(OFPort outPort);
tom7ef8ff92014-09-17 13:08:06 -070053
54 /**
55 * Build the packet out in response to this packet in event.
56 * @param ethFrame the actual packet to send out.
57 * @param outPort the out port to send to packet out of.
58 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070059 void build(Ethernet ethFrame, OFPort outPort);
tom7ef8ff92014-09-17 13:08:06 -070060
61 /**
62 * Provided a handle onto the parsed payload.
63 * @return the parsed form of the payload.
64 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070065 Ethernet parsed();
tom7ef8ff92014-09-17 13:08:06 -070066
67 /**
68 * Provide an unparsed copy of the data.
69 * @return the unparsed form of the payload.
70 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070071 byte[] unparsed();
tom7ef8ff92014-09-17 13:08:06 -070072
73 /**
74 * Provide the dpid of the switch where the packet in arrived.
75 * @return the dpid of the switch.
76 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070077 Dpid dpid();
tom7ef8ff92014-09-17 13:08:06 -070078
79 /**
80 * Provide the port on which the packet arrived.
81 * @return the port
82 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070083 Integer inPort();
alshabibe9d3a322014-09-23 15:18:33 -070084
85 /**
86 * Indicates that this packet is buffered at the switch.
87 * @return buffer indication
88 */
89 boolean isBuffered();
tom7ef8ff92014-09-17 13:08:06 -070090}