source: azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/inc/azure_c_shared_utility/gbnetwork.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 2.0 KB
Line 
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#ifndef GBNETWORK_H
5#define GBNETWORK_H
6
7#ifdef __cplusplus
8#include <cstdlib>
9#include <cstdint>
10#else
11#include <stdlib.h>
12#include <stdint.h>
13#endif
14
15#include "umock_c/umock_c_prod.h"
16
17#ifdef WIN32
18 #include <winsock2.h>
19#else
20 #include <sys/socket.h>
21#endif
22
23#ifdef __cplusplus
24extern "C"
25{
26#endif
27
28/* all translation units that need network measurement need to have GB_MEASURE_NETWORK_FOR_THIS defined */
29/* GB_DEBUG_NETWORK is the switch that turns the measurement on/off, so that it is not on always */
30#if defined(GB_DEBUG_NETWORK)
31
32MOCKABLE_FUNCTION(, int, gbnetwork_init);
33MOCKABLE_FUNCTION(, void, gbnetwork_deinit);
34
35#ifdef WIN32
36MOCKABLE_FUNCTION(, int, gbnetwork_send, SOCKET, sock, const char*, buf, int, len, int, flags);
37#else
38MOCKABLE_FUNCTION(, ssize_t, gbnetwork_send, int, sock, const void*, buf, size_t, len, int, flags);
39#endif
40
41#ifdef WIN32
42MOCKABLE_FUNCTION(, int, gbnetwork_recv, SOCKET, sock, char*, buf, int, len, int, flags);
43#else
44MOCKABLE_FUNCTION(, ssize_t, gbnetwork_recv, int, sock, void*, buf, size_t, len, int, flags);
45#endif
46
47MOCKABLE_FUNCTION(, uint64_t, gbnetwork_getBytesSent);
48MOCKABLE_FUNCTION(, uint64_t, gbnetwork_getNumSends);
49MOCKABLE_FUNCTION(, uint64_t, gbnetwork_getBytesRecv);
50MOCKABLE_FUNCTION(, uint64_t, gbnetwork_getNumRecv);
51MOCKABLE_FUNCTION(, void, gbnetwork_resetMetrics);
52
53/* if GB_MEASURE_NETWORK_FOR_THIS is defined then we want to redirect network send functions to gbnetwork_xxx functions */
54#ifdef GB_MEASURE_NETWORK_FOR_THIS
55#define send gbnetwork_send
56#define recv gbnetwork_recv
57#endif
58
59#else /* GB_DEBUG_NETWORK */
60
61#define gbnetwork_init() 0
62#define gbnetwork_deinit() ((void)0)
63#define gbnetwork_getBytesSent() 0
64#define gbnetwork_getNumSends() 0
65
66#define gbnetwork_getBytesRecv() 0
67#define gbnetwork_getNumRecv() 0
68
69#endif /* GB_DEBUG_NETWORK */
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif /* GBNETWORK_H */
Note: See TracBrowser for help on using the repository browser.