Asterisk - The Open Source Telephony Project GIT-master-a358458
Macros | Functions
network.h File Reference

Wrapper for network related headers, masking differences between various operating systems. On passing, we also provide here trivial functions or other simple wrappers to network-related functions. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define getprotobyname   __getprotobyname_is_not_threadsafe__do_not_use__
 
#define IFNAMSIZ   16
 
#define inet_ntoa   __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__
 
#define MAXHOSTNAMELEN   256
 

Functions

const char * ast_inet_ntoa (struct in_addr ia)
 thread-safe replacement for inet_ntoa(). More...
 
static force_inline int inaddrcmp (const struct sockaddr_in *sin1, const struct sockaddr_in *sin2)
 Compares the source address and port of two sockaddr_in. More...
 
int inet_aton (const char *cp, struct in_addr *pin)
 

Detailed Description

Wrapper for network related headers, masking differences between various operating systems. On passing, we also provide here trivial functions or other simple wrappers to network-related functions.

Definition in file network.h.

Macro Definition Documentation

◆ getprotobyname

#define getprotobyname   __getprotobyname_is_not_threadsafe__do_not_use__

Definition at line 92 of file network.h.

◆ IFNAMSIZ

#define IFNAMSIZ   16

Definition at line 65 of file network.h.

◆ inet_ntoa

#define inet_ntoa   __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__

Definition at line 87 of file network.h.

◆ MAXHOSTNAMELEN

#define MAXHOSTNAMELEN   256

Definition at line 69 of file network.h.

Function Documentation

◆ ast_inet_ntoa()

const char * ast_inet_ntoa ( struct in_addr  ia)

thread-safe replacement for inet_ntoa().

Note
It is very important to note that even though this is a thread-safe replacement for inet_ntoa(), it is not reentrant. In a single thread, the result from a previous call to this function is no longer valid once it is called again. If the result from multiple calls to this function need to be kept or used at once, then the result must be copied to a local buffer before calling this function again.

thread-safe replacement for inet_ntoa().

Definition at line 928 of file utils.c.

929{
930 char *buf;
931
932 if (!(buf = ast_threadstorage_get(&inet_ntoa_buf, INET_ADDRSTRLEN)))
933 return "";
934
935 return inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN);
936}
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
static struct ast_threadstorage inet_ntoa_buf
Definition: utils.c:85

References ast_threadstorage_get(), buf, and inet_ntoa_buf.

Referenced by _stun_show_status(), ast_parse_arg(), create_client(), get_defaults(), get_to_address(), handle_cli_rtp_settings(), handle_error(), handle_stun_timeout(), iax_server(), parsing(), phoneprov_callback(), process_request(), reload_config(), rtp_reload(), score_address(), send_raw_client(), send_start_rtp(), send_trunk(), show_main_page(), start_rtp(), stun_monitor_request(), unistim_show_devices(), unistim_show_info(), and unistimsock_read().

◆ inaddrcmp()

static force_inline int inaddrcmp ( const struct sockaddr_in *  sin1,
const struct sockaddr_in *  sin2 
)
static

Compares the source address and port of two sockaddr_in.

Definition at line 95 of file network.h.

96{
97 return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
98 || (sin1->sin_port != sin2->sin_port));
99}

◆ inet_aton()

int inet_aton ( const char *  cp,
struct in_addr *  pin 
)

Referenced by set_if().