41407dc485b20ca28311f1003e99283ce3e43bee
[onosfw.git] /
1 /*
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  */
16 package org.onosproject.bgp.controller.impl;
17
18 import org.onosproject.bgp.controller.BGPPacketStats;
19
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  */
26 public class BGPPacketStatsImpl implements BGPPacketStats {
27
28     private int inPacketCount;
29     private int outPacketCount;
30     private int wrongPacketCount;
31     private long time;
32
33     /**
34      * Resets parameter.
35      */
36     public BGPPacketStatsImpl() {
37         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      *
46      * @return
47      *          packet count
48      */
49     public int outPacketCount() {
50         return outPacketCount;
51     }
52
53     /**
54      * Get the incoming packet count number.
55      *
56      * @return
57      *          packet count
58      */
59     public int inPacketCount() {
60         return inPacketCount;
61     }
62
63     /**
64      * Get the wrong packet count number.
65      *
66      * @return
67      *          packet count
68      */
69     public int wrongPacketCount() {
70         return wrongPacketCount;
71     }
72
73     /**
74      * Increments the received packet counter.
75      */
76     public void addInPacket() {
77         this.inPacketCount++;
78     }
79
80     /**
81      * Increments the sent packet counter.
82      */
83     public void addOutPacket() {
84         this.outPacketCount++;
85     }
86
87     /**
88      * Increments the sent packet counter by specified value.
89      *
90      * @param value of no of packets sent
91      */
92     public void addOutPacket(int value) {
93         this.outPacketCount = this.outPacketCount + value;
94     }
95
96     /**
97      * Increments the wrong packet counter.
98      */
99     public void addWrongPacket() {
100         this.wrongPacketCount++;
101     }
102
103     /**
104      * Resets wrong packet count.
105      */
106     public void resetWrongPacket() {
107         this.wrongPacketCount = 0;
108     }
109
110     /**
111      * Get the time.
112      *
113      * @return
114      *          time
115      */
116     public long getTime() {
117         return this.time;
118     }
119
120     /**
121      * Sets the time.
122      *
123      * @param time value to set
124      */
125     public void setTime(long time) {
126         this.time = time;
127     }
128 }