Asterisk - The Open Source Telephony Project  18.5.0
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...

#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <sys/socket.h>
#include <net/if.h>
#include <sys/ioctl.h>
Include dependency graph for network.h:
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.

Referenced by get_input().

◆ MAXHOSTNAMELEN

#define MAXHOSTNAMELEN   256

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 782 of file main/utils.c.

References ast_threadstorage_get(), buf, and inet_ntoa_buf.

Referenced by _skinny_show_device(), _skinny_show_devices(), _stun_show_status(), add_sdp(), ast_dns_get_nameservers(), ast_parse_arg(), config_load(), create_client(), find_command(), find_subchannel_and_lock(), get_defaults(), get_to_address(), handle_error(), handle_mgcp_show_endpoints(), handle_open_receive_channel_ack_message(), handle_request(), handle_skinny_show_settings(), iax_server(), mgcpsock_read(), parsing(), process_request(), process_sdp(), reload_config(), resend_response(), rtp_add_candidates_to_ice(), rtp_reload(), score_address(), send_raw_client(), send_request(), send_response(), send_start_rtp(), send_trunk(), show_main_page(), skinny_session(), skinny_session_cleanup(), skinny_set_rtp_peer(), start_rtp(), stun_monitor_request(), transmit_serverres(), transmit_startmediatransmission(), unistim_show_devices(), unistim_show_info(), and unistimsock_read().

783 {
784  char *buf;
785 
786  if (!(buf = ast_threadstorage_get(&inet_ntoa_buf, INET_ADDRSTRLEN)))
787  return "";
788 
789  return inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN);
790 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static struct ast_threadstorage inet_ntoa_buf
Definition: main/utils.c:83

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