blob: d3675a0420b8f822f075d186cb2316c63ec82f30 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present 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
Charles Chancb13d122016-02-10 13:03:40 -080021import java.util.Optional;
22
tom7ef8ff92014-09-17 13:08:06 -070023/**
24 * A representation of a packet context which allows any provider
Ayaka Koshibeab3374b2014-09-19 11:41:25 -070025 * 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.
tom7ef8ff92014-09-17 13:08:06 -070028 */
29public interface OpenFlowPacketContext {
30
tom7ef8ff92014-09-17 13:08:06 -070031 /**
32 * Blocks further responses (ie. send() calls) on this
33 * packet in event.
Charles Chancb13d122016-02-10 13:03:40 -080034 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -080035 * @return true if blocks
tom7ef8ff92014-09-17 13:08:06 -070036 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070037 boolean block();
tom7ef8ff92014-09-17 13:08:06 -070038
39 /**
40 * Checks whether the packet has been handled.
Charles Chancb13d122016-02-10 13:03:40 -080041 *
tom7ef8ff92014-09-17 13:08:06 -070042 * @return true if handled, false otherwise.
43 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070044 boolean isHandled();
tom7ef8ff92014-09-17 13:08:06 -070045
46 /**
47 * Provided build has been called send the packet
48 * out the switch it came in on.
49 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070050 void send();
tom7ef8ff92014-09-17 13:08:06 -070051
52 /**
53 * Build the packet out in response to this packet in event.
Charles Chancb13d122016-02-10 13:03:40 -080054 *
tom7ef8ff92014-09-17 13:08:06 -070055 * @param outPort the out port to send to packet out of.
56 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070057 void build(OFPort outPort);
tom7ef8ff92014-09-17 13:08:06 -070058
59 /**
60 * Build the packet out in response to this packet in event.
Charles Chancb13d122016-02-10 13:03:40 -080061 *
tom7ef8ff92014-09-17 13:08:06 -070062 * @param ethFrame the actual packet to send out.
63 * @param outPort the out port to send to packet out of.
64 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070065 void build(Ethernet ethFrame, OFPort outPort);
tom7ef8ff92014-09-17 13:08:06 -070066
67 /**
68 * Provided a handle onto the parsed payload.
Charles Chancb13d122016-02-10 13:03:40 -080069 *
tom7ef8ff92014-09-17 13:08:06 -070070 * @return the parsed form of the payload.
71 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070072 Ethernet parsed();
tom7ef8ff92014-09-17 13:08:06 -070073
74 /**
75 * Provide an unparsed copy of the data.
Charles Chancb13d122016-02-10 13:03:40 -080076 *
tom7ef8ff92014-09-17 13:08:06 -070077 * @return the unparsed form of the payload.
78 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070079 byte[] unparsed();
tom7ef8ff92014-09-17 13:08:06 -070080
81 /**
82 * Provide the dpid of the switch where the packet in arrived.
Charles Chancb13d122016-02-10 13:03:40 -080083 *
tom7ef8ff92014-09-17 13:08:06 -070084 * @return the dpid of the switch.
85 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070086 Dpid dpid();
tom7ef8ff92014-09-17 13:08:06 -070087
88 /**
89 * Provide the port on which the packet arrived.
Charles Chancb13d122016-02-10 13:03:40 -080090 *
tom7ef8ff92014-09-17 13:08:06 -070091 * @return the port
92 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070093 Integer inPort();
alshabibe9d3a322014-09-23 15:18:33 -070094
95 /**
96 * Indicates that this packet is buffered at the switch.
Charles Chancb13d122016-02-10 13:03:40 -080097 *
alshabibe9d3a322014-09-23 15:18:33 -070098 * @return buffer indication
99 */
100 boolean isBuffered();
Charles Chancb13d122016-02-10 13:03:40 -0800101
102 /**
103 * Provide the cookie in the packet in message.
104 *
105 * @return optional flow cookie
106 */
107 Optional<Long> cookie();
tom7ef8ff92014-09-17 13:08:06 -0700108}