blob: 7494c8140d55f4567e15a627f49d838885bc82d5 [file] [log] [blame]
Satish Ke107e662015-09-21 19:00:17 +05301/*
2 * Copyright 2015 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 */
16package org.onosproject.bgp.controller.impl;
17
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053018import org.onosproject.bgp.controller.BgpPacketStats;
Satish Ke107e662015-09-21 19:00:17 +053019
20/**
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.
25 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053026public class BgpPacketStatsImpl implements BgpPacketStats {
Satish Ke107e662015-09-21 19:00:17 +053027
28 private int inPacketCount;
29 private int outPacketCount;
30 private int wrongPacketCount;
31 private long time;
32
33 /**
34 * Resets parameter.
35 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053036 public BgpPacketStatsImpl() {
Satish Ke107e662015-09-21 19:00:17 +053037 this.inPacketCount = 0;
38 this.outPacketCount = 0;
39 this.wrongPacketCount = 0;
40 this.time = 0;
41 }
42
43 /**
44 * Get the outgoing packet count number.
45 *
Shashikanth VH6de20d32015-10-09 12:04:13 +053046 * @return packet count
Satish Ke107e662015-09-21 19:00:17 +053047 */
48 public int outPacketCount() {
49 return outPacketCount;
50 }
51
52 /**
53 * Get the incoming packet count number.
54 *
Shashikanth VH6de20d32015-10-09 12:04:13 +053055 * @return packet count
Satish Ke107e662015-09-21 19:00:17 +053056 */
57 public int inPacketCount() {
58 return inPacketCount;
59 }
60
61 /**
62 * Get the wrong packet count number.
63 *
Shashikanth VH6de20d32015-10-09 12:04:13 +053064 * @return packet count
Satish Ke107e662015-09-21 19:00:17 +053065 */
66 public int wrongPacketCount() {
67 return wrongPacketCount;
68 }
69
70 /**
71 * Increments the received packet counter.
72 */
73 public void addInPacket() {
74 this.inPacketCount++;
75 }
76
77 /**
78 * Increments the sent packet counter.
79 */
80 public void addOutPacket() {
81 this.outPacketCount++;
82 }
83
84 /**
85 * Increments the sent packet counter by specified value.
86 *
87 * @param value of no of packets sent
88 */
89 public void addOutPacket(int value) {
90 this.outPacketCount = this.outPacketCount + value;
91 }
92
93 /**
94 * Increments the wrong packet counter.
95 */
96 public void addWrongPacket() {
97 this.wrongPacketCount++;
98 }
99
100 /**
101 * Resets wrong packet count.
102 */
103 public void resetWrongPacket() {
104 this.wrongPacketCount = 0;
105 }
106
107 /**
108 * Get the time.
109 *
Shashikanth VH6de20d32015-10-09 12:04:13 +0530110 * @return time
Satish Ke107e662015-09-21 19:00:17 +0530111 */
112 public long getTime() {
113 return this.time;
114 }
115
116 /**
117 * Sets the time.
118 *
119 * @param time value to set
120 */
121 public void setTime(long time) {
122 this.time = time;
123 }
124}