tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.packet; |
| 2 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 3 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 4 | |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 5 | /** |
| 6 | * Represents context for processing an inbound packet, and (optionally) |
| 7 | * emitting a corresponding outbound packet. |
| 8 | */ |
| 9 | public interface PacketContext { |
| 10 | |
| 11 | /** |
| 12 | * Returns the time when the packet was received. |
| 13 | * |
| 14 | * @return the time in millis since start of epoch |
| 15 | */ |
| 16 | long time(); |
| 17 | |
| 18 | /** |
| 19 | * Returns the inbound packet being processed. |
| 20 | * |
| 21 | * @return inbound packet |
| 22 | */ |
| 23 | InboundPacket inPacket(); |
| 24 | |
| 25 | /** |
| 26 | * Returns the view of the outbound packet. |
| 27 | * |
| 28 | * @return outbound packet |
| 29 | */ |
| 30 | OutboundPacket outPacket(); |
| 31 | |
| 32 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 33 | * Returns a builder for constructing traffic treatment. |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 34 | * |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 35 | * @return traffic treatment builder |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 36 | */ |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 37 | TrafficTreatment.Builder treatmentBuilder(); |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Triggers the outbound packet to be sent. |
| 41 | */ |
| 42 | void send(); |
| 43 | |
| 44 | /** |
| 45 | * Blocks the outbound packet from being sent from this point onward. |
tom | 89b63c5 | 2014-09-16 09:19:51 -0700 | [diff] [blame] | 46 | * |
alshabib | 63d5afe | 2014-09-15 09:40:24 -0700 | [diff] [blame] | 47 | * @return whether the outbound packet is blocked. |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 48 | */ |
alshabib | 030111e | 2014-09-15 15:56:42 -0700 | [diff] [blame] | 49 | boolean block(); |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
tom | 89b63c5 | 2014-09-16 09:19:51 -0700 | [diff] [blame] | 52 | * Indicates whether the outbound packet is handled, i.e. sent or blocked. |
| 53 | * |
| 54 | * @return true uf the packed is handled |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 55 | */ |
| 56 | boolean isHandled(); |
| 57 | |
| 58 | } |