Loading...
Searching...
No Matches
netstats.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Cenk Gündoğan <cenk.guendogan@haw-hamburg.de>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
19#ifndef NETSTATS_H
20#define NETSTATS_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include "irq.h"
28
29#define GNRC_RPL_NETSTATS_MULTICAST (0)
30#define GNRC_RPL_NETSTATS_UNICAST (1)
31
39static inline void gnrc_rpl_netstats_rx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
40{
41 /* other threads (e.g. the shell thread via the rpl shell command) read
42 * out the data, so we have to sync accesses */
43 unsigned irq_state = irq_disable();
44 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
45 netstats->dio.rx_mcast_count++;
46 netstats->dio.rx_mcast_bytes += len;
47 }
48 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
49 netstats->dio.rx_ucast_count++;
50 netstats->dio.rx_ucast_bytes += len;
51 }
52 irq_restore(irq_state);
53}
54
62static inline void gnrc_rpl_netstats_tx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
63{
64 /* other threads (e.g. the shell thread via the rpl shell command) read
65 * out the data, so we have to sync accesses */
66 unsigned irq_state = irq_disable();
67 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
68 netstats->dio.tx_mcast_count++;
69 netstats->dio.tx_mcast_bytes += len;
70 }
71 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
72 netstats->dio.tx_ucast_count++;
73 netstats->dio.tx_ucast_bytes += len;
74 }
75 irq_restore(irq_state);
76}
77
85static inline void gnrc_rpl_netstats_rx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
86{
87 /* other threads (e.g. the shell thread via the rpl shell command) read
88 * out the data, so we have to sync accesses */
89 unsigned irq_state = irq_disable();
90 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
91 netstats->dis.rx_mcast_count++;
92 netstats->dis.rx_mcast_bytes += len;
93 }
94 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
95 netstats->dis.rx_ucast_count++;
96 netstats->dis.rx_ucast_bytes += len;
97 }
98 irq_restore(irq_state);
99}
100
108static inline void gnrc_rpl_netstats_tx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
109{
110 /* other threads (e.g. the shell thread via the rpl shell command) read
111 * out the data, so we have to sync accesses */
112 unsigned irq_state = irq_disable();
113 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
114 netstats->dis.tx_mcast_count++;
115 netstats->dis.tx_mcast_bytes += len;
116 }
117 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
118 netstats->dis.tx_ucast_count++;
119 netstats->dis.tx_ucast_bytes += len;
120 }
121 irq_restore(irq_state);
122}
123
131static inline void gnrc_rpl_netstats_rx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
132{
133 /* other threads (e.g. the shell thread via the rpl shell command) read
134 * out the data, so we have to sync accesses */
135 unsigned irq_state = irq_disable();
136 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
137 netstats->dao.rx_mcast_count++;
138 netstats->dao.rx_mcast_bytes += len;
139 }
140 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
141 netstats->dao.rx_ucast_count++;
142 netstats->dao.rx_ucast_bytes += len;
143 }
144 irq_restore(irq_state);
145}
146
154static inline void gnrc_rpl_netstats_tx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
155{
156 /* other threads (e.g. the shell thread via the rpl shell command) read
157 * out the data, so we have to sync accesses */
158 unsigned irq_state = irq_disable();
159 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
160 netstats->dao.tx_mcast_count++;
161 netstats->dao.tx_mcast_bytes += len;
162 }
163 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
164 netstats->dao.tx_ucast_count++;
165 netstats->dao.tx_ucast_bytes += len;
166 }
167 irq_restore(irq_state);
168}
169
177static inline void gnrc_rpl_netstats_rx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
178{
179 /* other threads (e.g. the shell thread via the rpl shell command) read
180 * out the data, so we have to sync accesses */
181 unsigned irq_state = irq_disable();
182 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
183 netstats->dao_ack.rx_mcast_count++;
184 netstats->dao_ack.rx_mcast_bytes += len;
185 }
186 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
187 netstats->dao_ack.rx_ucast_count++;
188 netstats->dao_ack.rx_ucast_bytes += len;
189 }
190 irq_restore(irq_state);
191}
192
200static inline void gnrc_rpl_netstats_tx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
201{
202 /* other threads (e.g. the shell thread via the rpl shell command) read
203 * out the data, so we have to sync accesses */
204 unsigned irq_state = irq_disable();
205 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
206 netstats->dao_ack.tx_mcast_count++;
207 netstats->dao_ack.tx_mcast_bytes += len;
208 }
209 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
210 netstats->dao_ack.tx_ucast_count++;
211 netstats->dao_ack.tx_ucast_bytes += len;
212 }
213 irq_restore(irq_state);
214}
215
216#ifdef __cplusplus
217}
218#endif
219
220#endif /* NETSTATS_H */
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
IRQ driver interface.
static void gnrc_rpl_netstats_tx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DIO.
Definition netstats.h:62
static void gnrc_rpl_netstats_tx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DAO-ACK.
Definition netstats.h:200
static void gnrc_rpl_netstats_rx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DAO.
Definition netstats.h:131
static void gnrc_rpl_netstats_tx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DIO.
Definition netstats.h:154
static void gnrc_rpl_netstats_rx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DIO.
Definition netstats.h:39
static void gnrc_rpl_netstats_rx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DIS.
Definition netstats.h:85
static void gnrc_rpl_netstats_rx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DAO-ACK.
Definition netstats.h:177
static void gnrc_rpl_netstats_tx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DIS.
Definition netstats.h:108
Definition of RPL related packet statistics.
uint32_t rx_ucast_bytes
unicast bytes received
uint32_t rx_mcast_count
multicast packets received
uint32_t tx_mcast_count
multicast packets sent
uint32_t rx_ucast_count
unicast packets received
uint32_t rx_mcast_bytes
multicast bytes received
uint32_t tx_ucast_bytes
unicast bytes sent
uint32_t tx_mcast_bytes
multicast bytes sent
uint32_t tx_ucast_count
unicast packets sent
RPL statistics struct.
netstats_rpl_block_t dis
DIS statistics.
netstats_rpl_block_t dio
DIO statistics.
netstats_rpl_block_t dao_ack
DAO-ACK statistics.
netstats_rpl_block_t dao
DAO statistics.