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

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

Function Documentation

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.

References ast_threadstorage_get().

Referenced by _stun_show_status(), ast_parse_arg(), rtp_add_candidates_to_ice(), rtp_reload(), score_address(), and stun_monitor_request().

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 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.