blob: 014f4364392f43d64487b526557fda8d28168b60 [file] [log] [blame]
yoonseon5a51ef72016-10-26 14:50:09 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
yoonseon5a51ef72016-10-26 14:50:09 -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 */
16
17package org.onosproject.incubator.net.virtual.impl.provider;
18
19import org.onosproject.incubator.net.virtual.NetworkId;
Harold Huangbee92f62017-06-07 22:39:37 +080020import org.onosproject.incubator.net.virtual.VirtualPacketContext;
yoonseon5a51ef72016-10-26 14:50:09 -070021import org.onosproject.net.packet.DefaultPacketContext;
22import org.onosproject.net.packet.InboundPacket;
23import org.onosproject.net.packet.OutboundPacket;
yoonseon5a51ef72016-10-26 14:50:09 -070024
25/**
Harold Huangbee92f62017-06-07 22:39:37 +080026 *Default implementation of a virtual packet context.
yoonseon5a51ef72016-10-26 14:50:09 -070027 */
Harold Huangbee92f62017-06-07 22:39:37 +080028public class DefaultVirtualPacketContext extends DefaultPacketContext
29 implements VirtualPacketContext {
30
yoonseon5a51ef72016-10-26 14:50:09 -070031 private NetworkId networkId;
Harold Huangbee92f62017-06-07 22:39:37 +080032 private DefaultVirtualPacketProvider dvpp;
yoonseon5a51ef72016-10-26 14:50:09 -070033
34 /**
35 * Creates a new packet context.
36 *
37 * @param time creation time
38 * @param inPkt inbound packet
39 * @param outPkt outbound packet
40 * @param block whether the context is blocked or not
41 * @param networkId virtual network ID where this context is handled
Harold Huangbee92f62017-06-07 22:39:37 +080042 * @param dvpp pointer to default virtual packet provider
yoonseon5a51ef72016-10-26 14:50:09 -070043 */
44
Harold Huangbee92f62017-06-07 22:39:37 +080045 protected DefaultVirtualPacketContext(long time, InboundPacket inPkt,
46 OutboundPacket outPkt, boolean block,
47 NetworkId networkId,
48 DefaultVirtualPacketProvider dvpp) {
yoonseon5a51ef72016-10-26 14:50:09 -070049 super(time, inPkt, outPkt, block);
50
51 this.networkId = networkId;
52 this.dvpp = dvpp;
53 }
54
55 @Override
56 public void send() {
57 if (!this.block()) {
Harold Huangbee92f62017-06-07 22:39:37 +080058 dvpp.send(this);
yoonseon5a51ef72016-10-26 14:50:09 -070059 }
60 }
61
Harold Huangbee92f62017-06-07 22:39:37 +080062 @Override
63 public NetworkId networkId() {
yoonseon5a51ef72016-10-26 14:50:09 -070064 return networkId;
65 }
66}