yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.incubator.net.virtual.impl.provider; |
| 18 | |
| 19 | import org.onosproject.incubator.net.virtual.NetworkId; |
Harold Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 20 | import org.onosproject.incubator.net.virtual.VirtualPacketContext; |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 21 | import org.onosproject.net.packet.DefaultPacketContext; |
| 22 | import org.onosproject.net.packet.InboundPacket; |
| 23 | import org.onosproject.net.packet.OutboundPacket; |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
Harold Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 26 | *Default implementation of a virtual packet context. |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 27 | */ |
Harold Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 28 | public class DefaultVirtualPacketContext extends DefaultPacketContext |
| 29 | implements VirtualPacketContext { |
| 30 | |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 31 | private NetworkId networkId; |
Harold Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 32 | private DefaultVirtualPacketProvider dvpp; |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 33 | |
| 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 Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 42 | * @param dvpp pointer to default virtual packet provider |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 43 | */ |
| 44 | |
Harold Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 45 | protected DefaultVirtualPacketContext(long time, InboundPacket inPkt, |
| 46 | OutboundPacket outPkt, boolean block, |
| 47 | NetworkId networkId, |
| 48 | DefaultVirtualPacketProvider dvpp) { |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 49 | 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 Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 58 | dvpp.send(this); |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
Harold Huang | bee92f6 | 2017-06-07 22:39:37 +0800 | [diff] [blame] | 62 | @Override |
| 63 | public NetworkId networkId() { |
yoonseon | 5a51ef7 | 2016-10-26 14:50:09 -0700 | [diff] [blame] | 64 | return networkId; |
| 65 | } |
| 66 | } |