Amazon Kinesis Webrtc C SDK
Network.h
Go to the documentation of this file.
1 /*******************************************
2 HostInfo internal include file
3 *******************************************/
4 #ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_NETWORK__
5 #define __KINESIS_VIDEO_WEBRTC_CLIENT_NETWORK__
6 
7 #pragma once
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #define MAX_LOCAL_NETWORK_INTERFACE_COUNT 128
14 
15 // string buffer size for ipv4 and ipv6. Null terminator included.
16 // for ipv6: 0000:0000:0000:0000:0000:0000:0000:0000 = 39
17 // for ipv4 mapped ipv6: 0000:0000:0000:0000:0000:ffff:192.168.100.228 = 45
18 #define KVS_IP_ADDRESS_STRING_BUFFER_LEN 46
19 
20 // 000.000.000.000
21 #define KVS_MAX_IPV4_ADDRESS_STRING_LEN 15
22 
23 #define KVS_GET_IP_ADDRESS_PORT(a) ((UINT16) getInt16((a)->port))
24 
25 #define IPV4_TEMPLATE "%d.%d.%d.%d"
26 #define IPV6_TEMPLATE "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
27 
28 #if defined(__MACH__)
29 #define NO_SIGNAL_SOCK_OPT SO_NOSIGPIPE
30 #define NO_SIGNAL_SEND 0
31 #else
32 #define NO_SIGNAL_SEND MSG_NOSIGNAL
33 #endif
34 
35 // Some systems, such as Windows, do not have this value
36 #ifndef EAI_SYSTEM
37 #define EAI_SYSTEM -11
38 #endif
39 
40 // Windows uses EWOULDBLOCK (WSAEWOULDBLOCK) to indicate connection attempt
41 // cannot be completed immediately, whereas POSIX uses EINPROGRESS.
42 #ifdef _WIN32
43 #define KVS_SOCKET_IN_PROGRESS EWOULDBLOCK
44 #else
45 #define KVS_SOCKET_IN_PROGRESS EINPROGRESS
46 #endif
47 
48 typedef enum {
53 
65 
66 // TODO add support for windows socketpair
67 #ifndef _WIN32
73 STATUS createSocketPair(INT32 (*)[2]);
74 #endif
75 
84 STATUS createSocket(KVS_IP_FAMILY_TYPE, KVS_SOCKET_PROTOCOL, UINT32, PINT32);
85 
91 STATUS closeSocket(INT32);
92 
99 STATUS socketBind(PKvsIpAddress, INT32);
100 
107 STATUS socketConnect(PKvsIpAddress, INT32);
108 
116 STATUS socketWrite(INT32, const void*, SIZE_T);
117 
125 STATUS getIpWithHostName(PCHAR, PKvsIpAddress);
126 
136 BOOL isIpAddr(PCHAR, UINT16);
137 
138 STATUS getIpAddrStr(PKvsIpAddress, PCHAR, UINT32);
139 
141 
145 INT32 getErrorCode(VOID);
146 
152 PCHAR getErrorString(INT32);
153 
154 #ifdef _WIN32
155 #define POLL WSAPoll
156 #else
157 #define POLL poll
158 #endif
159 
160 #ifdef __cplusplus
161 }
162 #endif
163 #endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_NETWORK__ */
KVS_IP_FAMILY_TYPE
Definition: Include_i.h:94
STATUS getLocalhostIpAddresses(PKvsIpAddress, PUINT32, IceSetInterfaceFilterFunc, UINT64)
Definition: Network.c:7
STATUS getIpWithHostName(PCHAR, PKvsIpAddress)
Definition: Network.c:396
STATUS socketBind(PKvsIpAddress, INT32)
Definition: Network.c:238
INT32 getErrorCode(VOID)
Definition: Network.c:529
STATUS closeSocket(INT32)
Definition: Network.c:223
STATUS createSocketPair(INT32(*)[2])
Definition: Network.c:155
KVS_SOCKET_PROTOCOL
Definition: Network.h:48
@ KVS_SOCKET_PROTOCOL_TCP
Definition: Network.h:50
@ KVS_SOCKET_PROTOCOL_NONE
Definition: Network.h:49
@ KVS_SOCKET_PROTOCOL_UDP
Definition: Network.h:51
STATUS getIpAddrStr(PKvsIpAddress, PCHAR, UINT32)
Definition: Network.c:461
STATUS createSocket(KVS_IP_FAMILY_TYPE, KVS_SOCKET_PROTOCOL, UINT32, PINT32)
Definition: Network.c:168
STATUS socketConnect(PKvsIpAddress, INT32)
Definition: Network.c:289
STATUS socketWrite(INT32, const void *, SIZE_T)
Definition: Network.c:324
PCHAR getErrorString(INT32)
Definition: Network.c:564
BOOL isIpAddr(PCHAR, UINT16)
Definition: Network.c:338
BOOL isSameIpAddress(PKvsIpAddress, PKvsIpAddress, BOOL)
Definition: Network.c:488
BOOL(* IceSetInterfaceFilterFunc)(UINT64, PCHAR)
IceSetInterfaceFilterFunc is fired when a callback function to filter network interfaces is assigned....
Definition: Include.h:1073
Definition: Include_i.h:99