Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
socket.h
Go to the documentation of this file.
1
12#ifndef __SOCKET_H__
13#define __SOCKET_H__
14
15#include <wireshark.h>
16
17#if defined(_WIN32) && !defined(__CYGWIN__)
18 #include <windows.h>
19 #include <ws2tcpip.h>
20 #include <winsock2.h>
21 #include <process.h>
22
23 #define socket_handle_t SOCKET
24 #define socklen_t int
25#else
26 /*
27 * UN*X, or Windows pretending to be UN*X with the aid of Cygwin.
28 */
29 #ifdef HAVE_UNISTD_H
30 /*
31 * For close().
32 */
33 #include <unistd.h>
34 #endif
35 #ifdef HAVE_SYS_SOCKET_H
36 #include <sys/socket.h>
37 #endif
38
39 #define closesocket(socket) close(socket)
40 #define socket_handle_t int
41#ifndef INVALID_SOCKET
42 #define INVALID_SOCKET (-1)
43#endif
44 #define SOCKET_ERROR (-1)
45#endif
46
47#ifdef HAVE_ARPA_INET_H
48 #include <arpa/inet.h>
49#endif
50
51#ifdef HAVE_NETINET_IN_H
52 #include <netinet/in.h>
53#endif
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59/*
60 * Initialize sockets.
61 *
62 * Returns NULL on success, a g_malloc()ed error message on failure.
63 */
64WS_DLL_PUBLIC char *ws_init_sockets(void);
65
66/*
67 * Clean up sockets.
68 */
69WS_DLL_PUBLIC void ws_cleanup_sockets(void);
70
71/*
72 * Convert the strings ipv4_address:port or [ipv6_address]:port to a
73 * sockaddr object. Ports are optional. Receives default port
74 * in host byte order.
75 */
76WS_DLL_PUBLIC int
77ws_socket_ptoa(struct sockaddr_storage *dst, const char *src,
78 uint16_t def_port);
79
80#ifdef __cplusplus
81}
82#endif
83
84#endif /* __SOCKET_H__ */
85
86/*
87 * Editor modelines - https://www.wireshark.org/tools/modelines.html
88 *
89 * Local variables:
90 * c-basic-offset: 8
91 * tab-width: 8
92 * indent-tabs-mode: t
93 * End:
94 *
95 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
96 * :indentSize=8:tabSize=8:noTabs=false:
97 */