blob: 9d03b0dc46f24a7c1ebae2d16883ed951ab8321b [file] [log] [blame]
yoonseon5a51ef72016-10-26 14:50:09 -07001/*
2 * Copyright 2016-present 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 */
16
17package org.onosproject.incubator.net.virtual.impl.provider;
18
19import org.onosproject.incubator.net.virtual.NetworkId;
20import org.onosproject.net.packet.DefaultPacketContext;
21import org.onosproject.net.packet.InboundPacket;
22import org.onosproject.net.packet.OutboundPacket;
yoonseon5a51ef72016-10-26 14:50:09 -070023
24/**
25 * Represents context for processing an inbound packet for a virtual network
26 * and (optionally) emitting a corresponding outbound packet.
27 * The translation of context is handled by VirtualPacketProvider.
28 */
29public class VirtualPacketContext extends DefaultPacketContext {
30 private DefaultVirtualPacketProvider dvpp;
31 private NetworkId networkId;
32
33 /**
34 * Creates a new packet context.
35 *
36 * @param time creation time
37 * @param inPkt inbound packet
38 * @param outPkt outbound packet
39 * @param block whether the context is blocked or not
40 * @param networkId virtual network ID where this context is handled
41 * @param dvpp The pointer for DefaultVirtualPacketProvider
42 */
43
44 protected VirtualPacketContext(long time, InboundPacket inPkt,
45 OutboundPacket outPkt, boolean block,
46 NetworkId networkId,
47 DefaultVirtualPacketProvider dvpp) {
48 super(time, inPkt, outPkt, block);
49
50 this.networkId = networkId;
51 this.dvpp = dvpp;
52 }
53
54 @Override
55 public void send() {
56 if (!this.block()) {
Yoonseon Hanc8089db2017-03-22 20:22:12 +090057 dvpp.devirtualizeContext(this);
yoonseon5a51ef72016-10-26 14:50:09 -070058 }
59 }
60
61 public NetworkId getNetworkId() {
62 return networkId;
63 }
64}