2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.bgp.controller.impl;
18 import org.onosproject.bgp.controller.BgpPacketStats;
21 * A representation of a packet context which allows any provider
22 * to view a packet in event, but may block the response to the
23 * event if blocked has been called. This packet context can be used
24 * to react to the packet in event with a packet out.
26 public class BgpPacketStatsImpl implements BgpPacketStats {
28 private int inPacketCount;
29 private int outPacketCount;
30 private int wrongPacketCount;
36 public BgpPacketStatsImpl() {
37 this.inPacketCount = 0;
38 this.outPacketCount = 0;
39 this.wrongPacketCount = 0;
44 * Get the outgoing packet count number.
46 * @return packet count
48 public int outPacketCount() {
49 return outPacketCount;
53 * Get the incoming packet count number.
55 * @return packet count
57 public int inPacketCount() {
62 * Get the wrong packet count number.
64 * @return packet count
66 public int wrongPacketCount() {
67 return wrongPacketCount;
71 * Increments the received packet counter.
73 public void addInPacket() {
78 * Increments the sent packet counter.
80 public void addOutPacket() {
81 this.outPacketCount++;
85 * Increments the sent packet counter by specified value.
87 * @param value of no of packets sent
89 public void addOutPacket(int value) {
90 this.outPacketCount = this.outPacketCount + value;
94 * Increments the wrong packet counter.
96 public void addWrongPacket() {
97 this.wrongPacketCount++;
101 * Resets wrong packet count.
103 public void resetWrongPacket() {
104 this.wrongPacketCount = 0;
112 public long getTime() {
119 * @param time value to set
121 public void setTime(long time) {