PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/include/net/net_stats.h

https://gitlab.com/david.furminieux/zephyr-os
C Header | 264 lines | 140 code | 61 blank | 63 comment | 0 complexity | 7faaec18d446df850c9012ae869d6ce6 MD5 | raw file
  1. /** @file
  2. * @brief Network statistics
  3. *
  4. * Network statistics data. This should only be enabled when
  5. * debugging as it consumes memory.
  6. */
  7. /*
  8. * Copyright (c) 2016 Intel Corporation
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. */
  22. #ifndef __NET_STATS_H
  23. #define __NET_STATS_H
  24. #include <stdint.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #if defined(CONFIG_NET_STATISTICS)
  29. #define NET_STATS(s) s
  30. extern struct net_stats net_stats;
  31. #else
  32. #define NET_STATS(s)
  33. #endif
  34. typedef uint32_t net_stats_t;
  35. struct net_stats_ip {
  36. /** Number of received packets at the IP layer. */
  37. net_stats_t recv;
  38. /** Number of sent packets at the IP layer. */
  39. net_stats_t sent;
  40. /** Number of forwarded packets at the IP layer. */
  41. net_stats_t forwarded;
  42. /** Number of dropped packets at the IP layer. */
  43. net_stats_t drop;
  44. };
  45. struct net_stats_ip_errors {
  46. /** Number of packets dropped due to wrong IP version or header length. */
  47. net_stats_t vhlerr;
  48. /** Number of packets dropped due to wrong IP length, high byte. */
  49. net_stats_t hblenerr;
  50. /** Number of packets dropped due to wrong IP length, low byte. */
  51. net_stats_t lblenerr;
  52. /** Number of packets dropped because they were IP fragments. */
  53. net_stats_t fragerr;
  54. /** Number of packets dropped due to IP checksum errors. */
  55. net_stats_t chkerr;
  56. /** Number of packets dropped because they were neither ICMP, UDP nor TCP. */
  57. net_stats_t protoerr;
  58. };
  59. struct net_stats_icmp {
  60. /** Number of received ICMP packets. */
  61. net_stats_t recv;
  62. /** Number of sent ICMP packets. */
  63. net_stats_t sent;
  64. /** Number of dropped ICMP packets. */
  65. net_stats_t drop;
  66. /** Number of ICMP packets with a wrong type. */
  67. net_stats_t typeerr;
  68. /** Number of ICMP packets with a bad checksum. */
  69. net_stats_t chkerr;
  70. };
  71. struct net_stats_tcp {
  72. /** Number of recived TCP segments. */
  73. net_stats_t recv;
  74. /** Number of sent TCP segments. */
  75. net_stats_t sent;
  76. /** Number of dropped TCP segments. */
  77. net_stats_t drop;
  78. /** Number of TCP segments with a bad checksum. */
  79. net_stats_t chkerr;
  80. /** Number of TCP segments with a bad ACK number. */
  81. net_stats_t ackerr;
  82. /** Number of received TCP RST (reset) segments. */
  83. net_stats_t rst;
  84. /** Number of retransmitted TCP segments. */
  85. net_stats_t rexmit;
  86. /** Number of dropped SYNs because too few connections were available. */
  87. net_stats_t syndrop;
  88. /** Number of SYNs for closed ports, triggering a RST. */
  89. net_stats_t synrst;
  90. };
  91. struct net_stats_udp {
  92. /** Number of dropped UDP segments. */
  93. net_stats_t drop;
  94. /** Number of recived UDP segments. */
  95. net_stats_t recv;
  96. /** Number of sent UDP segments. */
  97. net_stats_t sent;
  98. /** Number of UDP segments with a bad checksum. */
  99. net_stats_t chkerr;
  100. };
  101. struct net_stats_ipv6_nd {
  102. net_stats_t drop;
  103. net_stats_t recv;
  104. net_stats_t sent;
  105. };
  106. struct net_stats_rpl_dis {
  107. /** Number of received DIS packets. */
  108. net_stats_t recv;
  109. /** Number of sent DIS packets. */
  110. net_stats_t sent;
  111. /** Number of dropped DIS packets. */
  112. net_stats_t drop;
  113. };
  114. struct net_stats_rpl_dio {
  115. /** Number of received DIO packets. */
  116. net_stats_t recv;
  117. /** Number of sent DIO packets. */
  118. net_stats_t sent;
  119. /** Number of dropped DIO packets. */
  120. net_stats_t drop;
  121. /** Number of DIO intervals. */
  122. net_stats_t interval;
  123. };
  124. struct net_stats_rpl_dao {
  125. /** Number of received DAO packets. */
  126. net_stats_t recv;
  127. /** Number of sent DAO packets. */
  128. net_stats_t sent;
  129. /** Number of dropped DAO packets. */
  130. net_stats_t drop;
  131. /** Number of forwarded DAO packets. */
  132. net_stats_t forwarded;
  133. };
  134. struct net_stats_rpl_dao_ack {
  135. /** Number of received DAO-ACK packets. */
  136. net_stats_t recv;
  137. /** Number of sent DAO-ACK packets. */
  138. net_stats_t sent;
  139. /** Number of dropped DAO-ACK packets. */
  140. net_stats_t drop;
  141. };
  142. struct net_stats {
  143. net_stats_t processing_error;
  144. struct net_stats_ip_errors ip_errors;
  145. #if defined(CONFIG_NET_IPV6)
  146. struct net_stats_ip ipv6;
  147. #define NET_STATS_IPV6(s) NET_STATS(s)
  148. #else
  149. #define NET_STATS_IPV6(s)
  150. #endif
  151. #if defined(CONFIG_NET_IPV4)
  152. struct net_stats_ip ipv4;
  153. #define NET_STATS_IPV4(s) NET_STATS(s)
  154. #else
  155. #define NET_STATS_IPV4(s)
  156. #endif
  157. struct net_stats_icmp icmp;
  158. #if defined(CONFIG_NET_TCP)
  159. struct net_stats_tcp tcp;
  160. #define NET_STATS_TCP(s) NET_STATS(s)
  161. #else
  162. #define NET_STATS_TCP(s)
  163. #endif
  164. #if defined (CONFIG_NET_UDP)
  165. struct net_stats_udp udp;
  166. #define NET_STATS_UDP(s) NET_STATS(s)
  167. #else
  168. #define NET_STATS_UDP(s)
  169. #endif
  170. #if defined(CONFIG_NET_IPV6_ND)
  171. struct net_stats_ipv6_nd ipv6_nd;
  172. #define NET_STATS_IPV6_ND(s) NET_STATS(s)
  173. #else
  174. #define NET_STATS_IPV6_ND(s)
  175. #endif
  176. #if defined(CONFIG_NET_RPL_STATS)
  177. struct {
  178. uint16_t mem_overflows;
  179. uint16_t local_repairs;
  180. uint16_t global_repairs;
  181. uint16_t malformed_msgs;
  182. uint16_t resets;
  183. uint16_t parent_switch;
  184. uint16_t forward_errors;
  185. uint16_t loop_errors;
  186. uint16_t loop_warnings;
  187. uint16_t root_repairs;
  188. struct net_stats_rpl_dis dis;
  189. struct net_stats_rpl_dio dio;
  190. struct net_stats_rpl_dao dao;
  191. struct net_stats_rpl_dao_ack dao_ack;
  192. } rpl;
  193. #define NET_STATS_RPL(s) NET_STATS(s)
  194. #define NET_STATS_RPL_DIS(s) NET_STATS(s)
  195. #else
  196. #define NET_STATS_RPL(s)
  197. #define NET_STATS_RPL_DIS(s)
  198. #endif /* CONFIG_NET_RPL_STATS */
  199. };
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203. #endif /* __NET_STATS_H */