Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
socket.h File Reference
#include <wireshark.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

Go to the source code of this file.

Macros

#define closesocket(socket)
#define socket_handle_t   int
#define INVALID_SOCKET   (-1)
#define SOCKET_ERROR   (-1)

Functions

WS_DLL_PUBLIC char * ws_init_sockets (void)
 Initializes the socket subsystem.
WS_DLL_PUBLIC void ws_cleanup_sockets (void)
 Cleans up the socket subsystem.
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.
WS_DLL_PUBLIC bool ws_verify_peercred (int sock)
 Verify the credentials of the peer connected to a Unix domain socket.

Detailed Description

Socket wrappers

Copyright 2016, Dario Lombardo

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Macro Definition Documentation

◆ closesocket

#define closesocket ( socket)
Value:
close(socket)

Function Documentation

◆ ws_cleanup_sockets()

WS_DLL_PUBLIC void ws_cleanup_sockets ( void )

Cleans up the socket subsystem.

Performs any necessary platform-specific cleanup for socket operations.

◆ ws_init_sockets()

WS_DLL_PUBLIC char * ws_init_sockets ( void )

Initializes the socket subsystem.

Performs any necessary platform-specific setup for socket operations.

Returns
NULL on success, or a g_malloc()ed error message string on failure. The caller is responsible for freeing the returned string.

◆ ws_socket_ptoa()

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.

Converts a string of the form ipv4_address:port or [ipv6_address]:port into a sockaddr_storage structure. If the port is omitted, def_port is used.

Parameters
dstPointer to a sockaddr_storage structure to receive the parsed address.
srcThe input string containing the address and optional port.
def_portThe default port to use if none is specified (in host byte order).
Returns
0 on success, or -1 on failure (e.g., invalid format or address).

◆ ws_verify_peercred()

WS_DLL_PUBLIC bool ws_verify_peercred ( int sock)

Verify the credentials of the peer connected to a Unix domain socket.

Verifies that the UID of the peer process that is connected to a Unix domain socket is the same as the effective UID of the current process, if possible.

Parameters
sockA socket handle (on UN*X, file descriptor)
Returns
true on success, or false on failure (including if unsupported).