Wireshark 4.7.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
67WS_DLL_PUBLIC char *ws_init_sockets(void);
68
74WS_DLL_PUBLIC void ws_cleanup_sockets(void);
75
87WS_DLL_PUBLIC int ws_socket_ptoa(struct sockaddr_storage *dst, const char *src, uint16_t def_port);
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif /* __SOCKET_H__ */
94
95/*
96 * Editor modelines - https://www.wireshark.org/tools/modelines.html
97 *
98 * Local variables:
99 * c-basic-offset: 8
100 * tab-width: 8
101 * indent-tabs-mode: t
102 * End:
103 *
104 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
105 * :indentSize=8:tabSize=8:noTabs=false:
106 */
WS_DLL_PUBLIC void ws_cleanup_sockets(void)
Cleans up the socket subsystem.
Definition socket.c:46
WS_DLL_PUBLIC int ws_socket_ptoa(struct sockaddr_storage *dst, const char *src, uint16_t def_port)
Converts a string representation of an IP address and port into a sockaddr.
Definition socket.c:55
WS_DLL_PUBLIC char * ws_init_sockets(void)
Initializes the socket subsystem.
Definition socket.c:27