source: azure_iot_hub/trunk/azure_iohub/c-utility/inc/azure_c_shared_utility/gbnetwork.h@ 388

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

Azure IoT Hub Device C SDK を使ったサンプルの追加

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