blob: 0d085ddde984bb403e642c4e3bb002cc6de96d06 [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 */
tom9c94c5b2014-09-17 13:14:42 -070016package org.onlab.onos.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
29 //TODO: may want to support sending packet out other switches than
30 // the one it came in on.
31 /**
32 * Blocks further responses (ie. send() calls) on this
33 * packet in event.
Yuta HIGUCHI5c947272014-11-03 21:39:21 -080034 * @return true if blocks
tom7ef8ff92014-09-17 13:08:06 -070035 */
36 public boolean block();
37
38 /**
39 * Checks whether the packet has been handled.
40 * @return true if handled, false otherwise.
41 */
42 public boolean isHandled();
43
44 /**
45 * Provided build has been called send the packet
46 * out the switch it came in on.
47 */
48 public void send();
49
50 /**
51 * Build the packet out in response to this packet in event.
52 * @param outPort the out port to send to packet out of.
53 */
54 public void build(OFPort outPort);
55
56 /**
57 * Build the packet out in response to this packet in event.
58 * @param ethFrame the actual packet to send out.
59 * @param outPort the out port to send to packet out of.
60 */
61 public void build(Ethernet ethFrame, OFPort outPort);
62
63 /**
64 * Provided a handle onto the parsed payload.
65 * @return the parsed form of the payload.
66 */
67 public Ethernet parsed();
68
69 /**
70 * Provide an unparsed copy of the data.
71 * @return the unparsed form of the payload.
72 */
73 public byte[] unparsed();
74
75 /**
76 * Provide the dpid of the switch where the packet in arrived.
77 * @return the dpid of the switch.
78 */
79 public Dpid dpid();
80
81 /**
82 * Provide the port on which the packet arrived.
83 * @return the port
84 */
85 public Integer inPort();
alshabibe9d3a322014-09-23 15:18:33 -070086
87 /**
88 * Indicates that this packet is buffered at the switch.
89 * @return buffer indication
90 */
91 boolean isBuffered();
tom7ef8ff92014-09-17 13:08:06 -070092}