Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Macros | Functions
socket.h File Reference
#include <wireshark.h>

Go to the source code of this file.

Macros

#define closesocket(socket)   close(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.
 

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

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).