netstats.h
5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* Copyright (C) 2016 Cenk Gündoğan <mail@cgundogan.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc_rpl
* @{
*
* @file
* @brief RPL control message statistics functions
*
* @author Cenk Gündoğan <mail@cgundogan.de>
*/
#ifndef RPL_NETSTATS_H_
#define RPL_NETSTATS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "net/rpl/rpl_netstats.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
#define GNRC_RPL_NETSTATS_MULTICAST (0)
#define GNRC_RPL_NETSTATS_UNICAST (1)
/**
* @brief Increase statistics for received DIO
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_rx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dio_rx_mcast_count++;
netstats->dio_rx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dio_rx_ucast_count++;
netstats->dio_rx_ucast_bytes += len;
}
}
/**
* @brief Increase statistics for sent DIO
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_tx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dio_tx_mcast_count++;
netstats->dio_tx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dio_tx_ucast_count++;
netstats->dio_tx_ucast_bytes += len;
}
}
/**
* @brief Increase statistics for received DIS
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_rx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dis_rx_mcast_count++;
netstats->dis_rx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dis_rx_ucast_count++;
netstats->dis_rx_ucast_bytes += len;
}
}
/**
* @brief Increase statistics for sent DIS
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_tx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dis_tx_mcast_count++;
netstats->dis_tx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dis_tx_ucast_count++;
netstats->dis_tx_ucast_bytes += len;
}
}
/**
* @brief Increase statistics for received DAO
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_rx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dao_rx_mcast_count++;
netstats->dao_rx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dao_rx_ucast_count++;
netstats->dao_rx_ucast_bytes += len;
}
}
/**
* @brief Increase statistics for sent DIO
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_tx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dao_tx_mcast_count++;
netstats->dao_tx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dao_tx_ucast_count++;
netstats->dao_tx_ucast_bytes += len;
}
}
/**
* @brief Increase statistics for received DAO-ACK
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_rx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dao_ack_rx_mcast_count++;
netstats->dao_ack_rx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dao_ack_rx_ucast_count++;
netstats->dao_ack_rx_ucast_bytes += len;
}
}
/**
* @brief Increase statistics for sent DAO-ACK
*
* @param[in] netstats Pointer to netstats_rpl_t
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
*/
static inline void gnrc_rpl_netstats_tx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
{
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
netstats->dao_ack_tx_mcast_count++;
netstats->dao_ack_tx_mcast_bytes += len;
}
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
netstats->dao_ack_tx_ucast_count++;
netstats->dao_ack_tx_ucast_bytes += len;
}
}
#ifdef __cplusplus
}
#endif
#endif /* RPL_NETSTATS_H_ */
/** @} */