blob: 3e1b3c7cf8ee3ff3b75935937a44b76d0cdb3db8 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
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
7 *
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.
15 */
tom613d8142014-09-11 15:09:37 -070016package org.onlab.onos.net.packet;
17
tom8bb16062014-09-12 14:47:46 -070018import org.onlab.onos.net.flow.TrafficTreatment;
19
tom613d8142014-09-11 15:09:37 -070020/**
21 * Represents context for processing an inbound packet, and (optionally)
22 * emitting a corresponding outbound packet.
23 */
24public interface PacketContext {
25
26 /**
27 * Returns the time when the packet was received.
28 *
29 * @return the time in millis since start of epoch
30 */
31 long time();
32
33 /**
34 * Returns the inbound packet being processed.
35 *
36 * @return inbound packet
37 */
38 InboundPacket inPacket();
39
40 /**
41 * Returns the view of the outbound packet.
42 *
43 * @return outbound packet
44 */
45 OutboundPacket outPacket();
46
47 /**
tom8bb16062014-09-12 14:47:46 -070048 * Returns a builder for constructing traffic treatment.
tom613d8142014-09-11 15:09:37 -070049 *
tom8bb16062014-09-12 14:47:46 -070050 * @return traffic treatment builder
tom613d8142014-09-11 15:09:37 -070051 */
tom8bb16062014-09-12 14:47:46 -070052 TrafficTreatment.Builder treatmentBuilder();
tom613d8142014-09-11 15:09:37 -070053
54 /**
55 * Triggers the outbound packet to be sent.
56 */
57 void send();
58
59 /**
60 * Blocks the outbound packet from being sent from this point onward.
tom89b63c52014-09-16 09:19:51 -070061 *
alshabib63d5afe2014-09-15 09:40:24 -070062 * @return whether the outbound packet is blocked.
tom613d8142014-09-11 15:09:37 -070063 */
alshabib030111e2014-09-15 15:56:42 -070064 boolean block();
tom613d8142014-09-11 15:09:37 -070065
66 /**
tom89b63c52014-09-16 09:19:51 -070067 * Indicates whether the outbound packet is handled, i.e. sent or blocked.
68 *
69 * @return true uf the packed is handled
tom613d8142014-09-11 15:09:37 -070070 */
71 boolean isHandled();
72
73}