blob: 646efa1dcc2dae5a1d87f0a58666a1cbcb316e15 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.packet;
tom613d8142014-09-11 15:09:37 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.flow.TrafficTreatment;
tom8bb16062014-09-12 14:47:46 -070019
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}