Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / wsutil / socket.h
blob7393db1394f2661eaccb8abd17b155efbaf59cc2
1 /** @file
2 * Socket wrappers
4 * Copyright 2016, Dario Lombardo
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __SOCKET_H__
13 #define __SOCKET_H__
15 #include <wireshark.h>
17 #if defined(_WIN32) && !defined(__CYGWIN__)
18 #include <windows.h>
19 #include <ws2tcpip.h>
20 #include <winsock2.h>
21 #include <process.h>
23 #define socket_handle_t SOCKET
24 #define socklen_t int
25 #else
27 * UN*X, or Windows pretending to be UN*X with the aid of Cygwin.
29 #ifdef HAVE_UNISTD_H
31 * For close().
33 #include <unistd.h>
34 #endif
35 #ifdef HAVE_SYS_SOCKET_H
36 #include <sys/socket.h>
37 #endif
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
47 #ifdef HAVE_ARPA_INET_H
48 #include <arpa/inet.h>
49 #endif
51 #ifdef HAVE_NETINET_IN_H
52 #include <netinet/in.h>
53 #endif
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
60 * Initialize sockets.
62 * Returns NULL on success, a g_malloc()ed error message on failure.
64 WS_DLL_PUBLIC char *ws_init_sockets(void);
67 * Clean up sockets.
69 WS_DLL_PUBLIC void ws_cleanup_sockets(void);
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.
76 WS_DLL_PUBLIC int
77 ws_socket_ptoa(struct sockaddr_storage *dst, const char *src,
78 uint16_t def_port);
80 #ifdef __cplusplus
82 #endif
84 #endif /* __SOCKET_H__ */
87 * Editor modelines - https://www.wireshark.org/tools/modelines.html
89 * Local variables:
90 * c-basic-offset: 8
91 * tab-width: 8
92 * indent-tabs-mode: t
93 * End:
95 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
96 * :indentSize=8:tabSize=8:noTabs=false: