Wed Jan 8 2020 09:50:15

Asterisk developer's documentation


netsock2.c File Reference

Network socket handling. More...

#include "asterisk.h"
#include "asterisk/config.h"
#include "asterisk/netsock2.h"
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"

Go to the source code of this file.

Functions

static void __init_ast_sockaddr_stringify_buf (void)
 
void _ast_sockaddr_from_sin (struct ast_sockaddr *addr, const struct sockaddr_in *sin, const char *file, int line, const char *func)
 
uint16_t _ast_sockaddr_port (const struct ast_sockaddr *addr, const char *file, int line, const char *func)
 
void _ast_sockaddr_set_port (struct ast_sockaddr *addr, uint16_t port, const char *file, int line, const char *func)
 
int _ast_sockaddr_to_sin (const struct ast_sockaddr *addr, struct sockaddr_in *sin, const char *file, int line, const char *func)
 
int ast_accept (int sockfd, struct ast_sockaddr *addr)
 Wrapper around accept(2) that uses struct ast_sockaddr. More...
 
int ast_bind (int sockfd, const struct ast_sockaddr *addr)
 Wrapper around bind(2) that uses struct ast_sockaddr. More...
 
int ast_connect (int sockfd, const struct ast_sockaddr *addr)
 Wrapper around connect(2) that uses struct ast_sockaddr. More...
 
int ast_getsockname (int sockfd, struct ast_sockaddr *addr)
 Wrapper around getsockname(2) that uses struct ast_sockaddr. More...
 
ssize_t ast_recvfrom (int sockfd, void *buf, size_t len, int flags, struct ast_sockaddr *src_addr)
 Wrapper around recvfrom(2) that uses struct ast_sockaddr. More...
 
ssize_t ast_sendto (int sockfd, const void *buf, size_t len, int flags, const struct ast_sockaddr *dest_addr)
 Wrapper around sendto(2) that uses ast_sockaddr. More...
 
int ast_set_qos (int sockfd, int tos, int cos, const char *desc)
 Set type of service. More...
 
int ast_sockaddr_cmp (const struct ast_sockaddr *a, const struct ast_sockaddr *b)
 Compares two ast_sockaddr structures. More...
 
int ast_sockaddr_cmp_addr (const struct ast_sockaddr *a, const struct ast_sockaddr *b)
 Compares the addresses of two ast_sockaddr structures. More...
 
int ast_sockaddr_hash (const struct ast_sockaddr *addr)
 Computes a hash value from the address. The port is ignored. More...
 
uint32_t ast_sockaddr_ipv4 (const struct ast_sockaddr *addr)
 Get an IPv4 address of an ast_sockaddr. More...
 
int ast_sockaddr_ipv4_mapped (const struct ast_sockaddr *addr, struct ast_sockaddr *ast_mapped)
 Convert an IPv4-mapped IPv6 address into an IPv4 address. More...
 
int ast_sockaddr_is_any (const struct ast_sockaddr *addr)
 Determine if the address type is unspecified, or "any" address. More...
 
int ast_sockaddr_is_ipv4 (const struct ast_sockaddr *addr)
 Determine if the address is an IPv4 address. More...
 
int ast_sockaddr_is_ipv4_mapped (const struct ast_sockaddr *addr)
 Determine if this is an IPv4-mapped IPv6 address. More...
 
int ast_sockaddr_is_ipv6 (const struct ast_sockaddr *addr)
 Determine if this is an IPv6 address. More...
 
int ast_sockaddr_is_ipv6_link_local (const struct ast_sockaddr *addr)
 Determine if this is a link-local IPv6 address. More...
 
int ast_sockaddr_parse (struct ast_sockaddr *addr, const char *str, int flags)
 Parse an IPv4 or IPv6 address string. More...
 
int ast_sockaddr_resolve (struct ast_sockaddr **addrs, const char *str, int flags, int family)
 Parses a string with an IPv4 or IPv6 address and place results into an array. More...
 
int ast_sockaddr_split_hostport (char *str, char **host, char **port, int flags)
 Splits a string into its host and port components. More...
 
char * ast_sockaddr_stringify_fmt (const struct ast_sockaddr *sa, int format)
 Convert a socket address to a string. More...
 

Variables

static struct ast_threadstorage ast_sockaddr_stringify_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_ast_sockaddr_stringify_buf , .custom_init = NULL , }
 

Detailed Description

Network socket handling.

Author
Viagénie aster.nosp@m.iskv.nosp@m.6@via.nosp@m.geni.nosp@m.e.ca

Definition in file netsock2.c.

Function Documentation

static void __init_ast_sockaddr_stringify_buf ( void  )
static

Definition at line 65 of file netsock2.c.

68 {
void _ast_sockaddr_from_sin ( struct ast_sockaddr addr,
const struct sockaddr_in *  sin,
const char *  file,
int  line,
const char *  func 
)

Definition at line 561 of file netsock2.c.

References __LOG_DEBUG, ast_log(), ast_sockaddr::len, option_debug, and ast_sockaddr::ss.

563 {
564  memcpy(&addr->ss, sin, sizeof(*sin));
565 
566  if (addr->ss.ss_family != AF_INET && option_debug >= 1) {
567  ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");
568  }
569 
570  addr->len = sizeof(*sin);
571 }
struct sockaddr_storage ss
Definition: netsock2.h:64
#define __LOG_DEBUG
Definition: logger.h:121
int option_debug
Definition: asterisk.c:182
socklen_t len
Definition: netsock2.h:65
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
uint16_t _ast_sockaddr_port ( const struct ast_sockaddr addr,
const char *  file,
int  line,
const char *  func 
)

Definition at line 365 of file netsock2.c.

References __LOG_DEBUG, ast_log(), ast_sockaddr::len, option_debug, and ast_sockaddr::ss.

366 {
367  if (addr->ss.ss_family == AF_INET &&
368  addr->len == sizeof(struct sockaddr_in)) {
369  return ntohs(((struct sockaddr_in *)&addr->ss)->sin_port);
370  } else if (addr->ss.ss_family == AF_INET6 &&
371  addr->len == sizeof(struct sockaddr_in6)) {
372  return ntohs(((struct sockaddr_in6 *)&addr->ss)->sin6_port);
373  }
374  if (option_debug >= 1) {
375  ast_log(__LOG_DEBUG, file, line, func, "Not an IPv4 nor IPv6 address, cannot get port.\n");
376  }
377  return 0;
378 }
struct sockaddr_storage ss
Definition: netsock2.h:64
#define __LOG_DEBUG
Definition: logger.h:121
int option_debug
Definition: asterisk.c:182
socklen_t len
Definition: netsock2.h:65
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void _ast_sockaddr_set_port ( struct ast_sockaddr addr,
uint16_t  port,
const char *  file,
int  line,
const char *  func 
)

Definition at line 380 of file netsock2.c.

References __LOG_DEBUG, ast_log(), ast_sockaddr::len, option_debug, and ast_sockaddr::ss.

381 {
382  if (addr->ss.ss_family == AF_INET &&
383  addr->len == sizeof(struct sockaddr_in)) {
384  ((struct sockaddr_in *)&addr->ss)->sin_port = htons(port);
385  } else if (addr->ss.ss_family == AF_INET6 &&
386  addr->len == sizeof(struct sockaddr_in6)) {
387  ((struct sockaddr_in6 *)&addr->ss)->sin6_port = htons(port);
388  } else if (option_debug >= 1) {
389  ast_log(__LOG_DEBUG, file, line, func,
390  "Not an IPv4 nor IPv6 address, cannot set port.\n");
391  }
392 }
struct sockaddr_storage ss
Definition: netsock2.h:64
#define __LOG_DEBUG
Definition: logger.h:121
int option_debug
Definition: asterisk.c:182
socklen_t len
Definition: netsock2.h:65
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int _ast_sockaddr_to_sin ( const struct ast_sockaddr addr,
struct sockaddr_in *  sin,
const char *  file,
int  line,
const char *  func 
)

Definition at line 540 of file netsock2.c.

References __LOG_DEBUG, __LOG_ERROR, ast_log(), ast_sockaddr_isnull(), ast_sockaddr::len, option_debug, and ast_sockaddr::ss.

542 {
543  if (ast_sockaddr_isnull(addr)) {
544  memset(sin, 0, sizeof(*sin));
545  return 1;
546  }
547 
548  if (addr->len != sizeof(*sin)) {
549  ast_log(__LOG_ERROR, file, line, func, "Bad address cast to IPv4\n");
550  return 0;
551  }
552 
553  if (addr->ss.ss_family != AF_INET && option_debug >= 1) {
554  ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");
555  }
556 
557  *sin = *(struct sockaddr_in *)&addr->ss;
558  return 1;
559 }
struct sockaddr_storage ss
Definition: netsock2.h:64
#define __LOG_DEBUG
Definition: logger.h:121
int option_debug
Definition: asterisk.c:182
socklen_t len
Definition: netsock2.h:65
#define __LOG_ERROR
Definition: logger.h:154
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
Definition: netsock2.h:93
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_accept ( int  sockfd,
struct ast_sockaddr addr 
)

Wrapper around accept(2) that uses struct ast_sockaddr.

Since
1.8

For parameter and return information, see the man page for accept(2).

Definition at line 456 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by ast_tcptls_server_root().

457 {
458  addr->len = sizeof(addr->ss);
459  return accept(sockfd, (struct sockaddr *)&addr->ss, &addr->len);
460 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
int ast_bind ( int  sockfd,
const struct ast_sockaddr addr 
)

Wrapper around bind(2) that uses struct ast_sockaddr.

Since
1.8

For parameter and return information, see the man page for bind(2).

Definition at line 462 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by ast_rtp_new(), ast_rtp_prop_set(), ast_tcptls_client_create(), ast_tcptls_server_start(), ast_udptl_new_with_bindaddr(), and reload_config().

463 {
464  return bind(sockfd, (const struct sockaddr *)&addr->ss, addr->len);
465 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
int ast_connect ( int  sockfd,
const struct ast_sockaddr addr 
)

Wrapper around connect(2) that uses struct ast_sockaddr.

Since
1.8

For parameter and return information, see the man page for connect(2).

Definition at line 467 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by ast_ouraddrfor(), ast_tcptls_client_start(), gtalk_update_externip(), and stun_monitor_request().

468 {
469  return connect(sockfd, (const struct sockaddr *)&addr->ss, addr->len);
470 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
int ast_getsockname ( int  sockfd,
struct ast_sockaddr addr 
)

Wrapper around getsockname(2) that uses struct ast_sockaddr.

Since
1.8

For parameter and return information, see the man page for getsockname(2).

Definition at line 472 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by ast_ouraddrfor(), and ast_set_qos().

473 {
474  addr->len = sizeof(addr->ss);
475  return getsockname(sockfd, (struct sockaddr *)&addr->ss, &addr->len);
476 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
ssize_t ast_recvfrom ( int  sockfd,
void *  buf,
size_t  len,
int  flags,
struct ast_sockaddr src_addr 
)

Wrapper around recvfrom(2) that uses struct ast_sockaddr.

Since
1.8

For parameter and return information, see the man page for recvfrom(2).

Definition at line 478 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by __rtp_recvfrom(), ast_udptl_read(), and sipsock_read().

480 {
481  src_addr->len = sizeof(src_addr->ss);
482  return recvfrom(sockfd, buf, len, flags,
483  (struct sockaddr *)&src_addr->ss, &src_addr->len);
484 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
ssize_t ast_sendto ( int  sockfd,
const void *  buf,
size_t  len,
int  flags,
const struct ast_sockaddr dest_addr 
)

Wrapper around sendto(2) that uses ast_sockaddr.

Since
1.8

For parameter and return information, see the man page for sendto(2)

Definition at line 486 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by __rtp_sendto(), __sip_xmit(), ast_udptl_write(), multicast_rtp_write(), and multicast_send_control_packet().

488 {
489  return sendto(sockfd, buf, len, flags,
490  (const struct sockaddr *)&dest_addr->ss, dest_addr->len);
491 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_set_qos ( int  sockfd,
int  tos,
int  cos,
const char *  desc 
)

Set type of service.

Since
1.8

Set ToS ("Type of Service for IPv4 and "Traffic Class for IPv6) and CoS (Linux's SO_PRIORITY)

Parameters
sockfdFile descriptor for socket on which to set the parameters
tosThe type of service for the socket
cosThe cost of service for the socket
descA text description of the socket in question.
Return values
0Success
-1Error, with errno set to an appropriate value

Definition at line 493 of file netsock2.c.

References ast_getsockname(), ast_log(), ast_sockaddr_is_any(), ast_sockaddr_is_ipv6(), ast_verb, errno, and LOG_WARNING.

Referenced by ast_rtp_qos_set(), and reload_config().

494 {
495  int res = 0;
496  int set_tos;
497  int set_tclass;
498  struct ast_sockaddr addr;
499 
500  /* If the sock address is IPv6, the TCLASS field must be set. */
501  set_tclass = !ast_getsockname(sockfd, &addr) && ast_sockaddr_is_ipv6(&addr) ? 1 : 0;
502 
503  /* If the the sock address is IPv4 or (IPv6 set to any address [::]) set TOS bits */
504  set_tos = (!set_tclass || (set_tclass && ast_sockaddr_is_any(&addr))) ? 1 : 0;
505 
506  if (set_tos) {
507  if ((res = setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))) {
508  ast_log(LOG_WARNING, "Unable to set %s DSCP TOS value to %d (may be you have no "
509  "root privileges): %s\n", desc, tos, strerror(errno));
510  } else if (tos) {
511  ast_verb(2, "Using %s TOS bits %d\n", desc, tos);
512  }
513  }
514 
515 #if defined(IPV6_TCLASS) && defined(IPPROTO_IPV6)
516  if (set_tclass) {
517  if (!ast_getsockname(sockfd, &addr) && ast_sockaddr_is_ipv6(&addr)) {
518  if ((res = setsockopt(sockfd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)))) {
519  ast_log(LOG_WARNING, "Unable to set %s DSCP TCLASS field to %d (may be you have no "
520  "root privileges): %s\n", desc, tos, strerror(errno));
521  } else if (tos) {
522  ast_verb(2, "Using %s TOS bits %d in TCLASS field.\n", desc, tos);
523  }
524  }
525  }
526 #endif
527 
528 #ifdef linux
529  if (setsockopt(sockfd, SOL_SOCKET, SO_PRIORITY, &cos, sizeof(cos))) {
530  ast_log(LOG_WARNING, "Unable to set %s CoS to %d: %s\n", desc, cos,
531  strerror(errno));
532  } else if (cos) {
533  ast_verb(2, "Using %s CoS mark %d\n", desc, cos);
534  }
535 #endif
536 
537  return res;
538 }
static unsigned int tos
Definition: chan_h323.c:146
#define LOG_WARNING
Definition: logger.h:144
Socket address structure.
Definition: netsock2.h:63
#define ast_verb(level,...)
Definition: logger.h:243
int ast_sockaddr_is_any(const struct ast_sockaddr *addr)
Determine if the address type is unspecified, or "any" address.
Definition: netsock2.c:424
static const char desc[]
Definition: cdr_radius.c:85
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
int ast_getsockname(int sockfd, struct ast_sockaddr *addr)
Wrapper around getsockname(2) that uses struct ast_sockaddr.
Definition: netsock2.c:472
static unsigned int cos
Definition: chan_h323.c:147
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
Definition: netsock2.c:418
int ast_sockaddr_cmp ( const struct ast_sockaddr a,
const struct ast_sockaddr b 
)

Compares two ast_sockaddr structures.

Since
1.8
Return values
-1a is lexicographically smaller than b
0a is equal to b
1b is lexicographically smaller than a

Definition at line 300 of file netsock2.c.

References ast_sockaddr_ipv4_mapped(), ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by add_sdp(), ast_rtcp_read(), ast_rtp_instance_get_and_cmp_local_address(), ast_rtp_instance_get_and_cmp_remote_address(), ast_rtp_read(), ast_tcptls_client_create(), ast_tcptls_server_start(), ast_udptl_bridge(), ast_udptl_read(), dnsmgr_refresh(), parse_register_contact(), realtime_peer_by_name(), reload_config(), remote_bridge_loop(), rtcp_debug_test_addr(), rtp_debug_test_addr(), sip_debug_test_addr(), sip_uri_domain_cmp(), threadinfo_locate_cb(), transmit_register(), udptl_debug_test_addr(), and update_registry().

301 {
302  const struct ast_sockaddr *a_tmp, *b_tmp;
303  struct ast_sockaddr ipv4_mapped;
304 
305  a_tmp = a;
306  b_tmp = b;
307 
308  if (a_tmp->len != b_tmp->len) {
309  if (ast_sockaddr_ipv4_mapped(a, &ipv4_mapped)) {
310  a_tmp = &ipv4_mapped;
311  } else if (ast_sockaddr_ipv4_mapped(b, &ipv4_mapped)) {
312  b_tmp = &ipv4_mapped;
313  }
314  }
315 
316  if (a_tmp->len < b_tmp->len) {
317  return -1;
318  } else if (a_tmp->len > b_tmp->len) {
319  return 1;
320  }
321 
322  return memcmp(&a_tmp->ss, &b_tmp->ss, a_tmp->len);
323 }
struct sockaddr_storage ss
Definition: netsock2.h:64
int ast_sockaddr_ipv4_mapped(const struct ast_sockaddr *addr, struct ast_sockaddr *ast_mapped)
Convert an IPv4-mapped IPv6 address into an IPv4 address.
Definition: netsock2.c:39
socklen_t len
Definition: netsock2.h:65
Socket address structure.
Definition: netsock2.h:63
int ast_sockaddr_cmp_addr ( const struct ast_sockaddr a,
const struct ast_sockaddr b 
)

Compares the addresses of two ast_sockaddr structures.

Since
1.8
Return values
-1a is lexicographically smaller than b
0a is equal to b
1b is lexicographically smaller than a

Definition at line 325 of file netsock2.c.

References ast_sockaddr_ipv4_mapped(), ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by addr_range_cmp_cb(), ast_apply_ha(), get_our_media_address(), peer_ipcmp_cb(), rtcp_debug_test_addr(), rtp_debug_test_addr(), sip_debug_test_addr(), and udptl_debug_test_addr().

326 {
327  const struct ast_sockaddr *a_tmp, *b_tmp;
328  struct ast_sockaddr ipv4_mapped;
329  const struct in_addr *ip4a, *ip4b;
330  const struct in6_addr *ip6a, *ip6b;
331  int ret = -1;
332 
333  a_tmp = a;
334  b_tmp = b;
335 
336  if (a_tmp->len != b_tmp->len) {
337  if (ast_sockaddr_ipv4_mapped(a, &ipv4_mapped)) {
338  a_tmp = &ipv4_mapped;
339  } else if (ast_sockaddr_ipv4_mapped(b, &ipv4_mapped)) {
340  b_tmp = &ipv4_mapped;
341  }
342  }
343 
344  if (a->len < b->len) {
345  ret = -1;
346  } else if (a->len > b->len) {
347  ret = 1;
348  }
349 
350  switch (a_tmp->ss.ss_family) {
351  case AF_INET:
352  ip4a = &((const struct sockaddr_in*)&a_tmp->ss)->sin_addr;
353  ip4b = &((const struct sockaddr_in*)&b_tmp->ss)->sin_addr;
354  ret = memcmp(ip4a, ip4b, sizeof(*ip4a));
355  break;
356  case AF_INET6:
357  ip6a = &((const struct sockaddr_in6*)&a_tmp->ss)->sin6_addr;
358  ip6b = &((const struct sockaddr_in6*)&b_tmp->ss)->sin6_addr;
359  ret = memcmp(ip6a, ip6b, sizeof(*ip6a));
360  break;
361  }
362  return ret;
363 }
struct sockaddr_storage ss
Definition: netsock2.h:64
int ast_sockaddr_ipv4_mapped(const struct ast_sockaddr *addr, struct ast_sockaddr *ast_mapped)
Convert an IPv4-mapped IPv6 address into an IPv4 address.
Definition: netsock2.c:39
socklen_t len
Definition: netsock2.h:65
Socket address structure.
Definition: netsock2.h:63
int ast_sockaddr_hash ( const struct ast_sockaddr addr)

Computes a hash value from the address. The port is ignored.

Since
1.8
Return values
0Unknown address family
otherA 32-bit hash derived from the address

Definition at line 438 of file netsock2.c.

References ast_log(), LOG_ERROR, and ast_sockaddr::ss.

Referenced by peer_iphash_cb(), and threadt_hash_cb().

439 {
440  /*
441  * For IPv4, return the IP address as-is. For IPv6, return the last 32
442  * bits.
443  */
444  switch (addr->ss.ss_family) {
445  case AF_INET:
446  return ((const struct sockaddr_in *)&addr->ss)->sin_addr.s_addr;
447  case AF_INET6:
448  return ((uint32_t *)&((const struct sockaddr_in6 *)&addr->ss)->sin6_addr)[3];
449  default:
450  ast_log(LOG_ERROR, "Unknown address family '%d'.\n",
451  addr->ss.ss_family);
452  return 0;
453  }
454 }
struct sockaddr_storage ss
Definition: netsock2.h:64
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
uint32_t ast_sockaddr_ipv4 ( const struct ast_sockaddr addr)

Get an IPv4 address of an ast_sockaddr.

Since
1.8
Warning
You should rarely need this function. Only use if you know what you're doing.
Returns
IPv4 address in network byte order

Definition at line 394 of file netsock2.c.

References ast_sockaddr::ss.

Referenced by addr_is_multicast(), iax2_devicestate(), iax2_do_register(), iax2_poke_peer(), jingle_create_candidates(), load_module(), and multicast_send_control_packet().

395 {
396  const struct sockaddr_in *sin = (struct sockaddr_in *)&addr->ss;
397  return ntohl(sin->sin_addr.s_addr);
398 }
struct sockaddr_storage ss
Definition: netsock2.h:64
int ast_sockaddr_ipv4_mapped ( const struct ast_sockaddr addr,
struct ast_sockaddr ast_mapped 
)

Convert an IPv4-mapped IPv6 address into an IPv4 address.

Warning
You should rarely need this function. Only call this if you know what you're doing.
Parameters
addrThe IPv4-mapped address to convert
mapped_addrThe resulting IPv4 address
Return values
0Unable to make the conversion
1Successful conversion

Definition at line 39 of file netsock2.c.

References ast_sockaddr_from_sin, ast_sockaddr_is_ipv4_mapped(), ast_sockaddr_is_ipv6(), and ast_sockaddr::ss.

Referenced by ast_append_ha(), ast_apply_ha(), ast_rtp_read(), ast_sockaddr_cmp(), ast_sockaddr_cmp_addr(), and ast_sockaddr_stringify_fmt().

40 {
41  const struct sockaddr_in6 *sin6;
42  struct sockaddr_in sin4;
43 
44  if (!ast_sockaddr_is_ipv6(addr)) {
45  return 0;
46  }
47 
48  if (!ast_sockaddr_is_ipv4_mapped(addr)) {
49  return 0;
50  }
51 
52  sin6 = (const struct sockaddr_in6*)&addr->ss;
53 
54  memset(&sin4, 0, sizeof(sin4));
55  sin4.sin_family = AF_INET;
56  sin4.sin_port = sin6->sin6_port;
57  sin4.sin_addr.s_addr = ((uint32_t *)&sin6->sin6_addr)[3];
58 
59  ast_sockaddr_from_sin(ast_mapped, &sin4);
60 
61  return 1;
62 }
struct sockaddr_storage ss
Definition: netsock2.h:64
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
Definition: netsock2.h:642
int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr)
Determine if this is an IPv4-mapped IPv6 address.
Definition: netsock2.c:406
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
Definition: netsock2.c:418
int ast_sockaddr_is_any ( const struct ast_sockaddr addr)

Determine if the address type is unspecified, or "any" address.

Since
1.8

For IPv4, this would be the address 0.0.0.0, and for IPv6, this would be the address ::. The port number is ignored.

Return values
1This is an "any" address
0This is not an "any" address

Definition at line 424 of file netsock2.c.

References ast_sockaddr_is_ipv4(), ast_sockaddr_is_ipv6(), and ast_sockaddr::ss.

Referenced by ast_find_ourip(), ast_set_qos(), ast_sip_ouraddrfor(), get_address_family_filter(), get_our_media_address(), gtalk_get_local_ip(), reload_config(), sip_show_settings(), and sockaddr_is_null_or_any().

425 {
426  union {
427  struct sockaddr_storage ss;
428  struct sockaddr_in sin;
429  struct sockaddr_in6 sin6;
430  } tmp_addr = {
431  .ss = addr->ss,
432  };
433 
434  return (ast_sockaddr_is_ipv4(addr) && (tmp_addr.sin.sin_addr.s_addr == INADDR_ANY)) ||
435  (ast_sockaddr_is_ipv6(addr) && IN6_IS_ADDR_UNSPECIFIED(&tmp_addr.sin6.sin6_addr));
436 }
struct sockaddr_storage ss
Definition: netsock2.h:64
int ast_sockaddr_is_ipv4(const struct ast_sockaddr *addr)
Determine if the address is an IPv4 address.
Definition: netsock2.c:400
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
Definition: netsock2.c:418
int ast_sockaddr_is_ipv4 ( const struct ast_sockaddr addr)

Determine if the address is an IPv4 address.

Since
1.8
Warning
You should rarely need this function. Only use if you know what you're doing.
Return values
1This is an IPv4 address
0This is an IPv6 or IPv4-mapped IPv6 address

Definition at line 400 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by apply_netmask(), ast_append_ha(), ast_apply_ha(), ast_rtp_new(), ast_rtp_prop_set(), ast_rtp_read(), and ast_sockaddr_is_any().

401 {
402  return addr->ss.ss_family == AF_INET &&
403  addr->len == sizeof(struct sockaddr_in);
404 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
int ast_sockaddr_is_ipv4_mapped ( const struct ast_sockaddr addr)

Determine if this is an IPv4-mapped IPv6 address.

Since
1.8
Warning
You should rarely need this function. Only use if you know what you're doing.
Return values
1This is an IPv4-mapped IPv6 address.
0This is not an IPv4-mapped IPv6 address.

Definition at line 406 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by add_sdp(), ast_apply_ha(), ast_rtp_instance_bridge(), and ast_sockaddr_ipv4_mapped().

407 {
408  const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&addr->ss;
409  return addr->len && IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr);
410 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
int ast_sockaddr_is_ipv6 ( const struct ast_sockaddr addr)

Determine if this is an IPv6 address.

Since
1.8
Warning
You should rarely need this function. Only use if you know what you're doing.
Return values
1This is an IPv6 or IPv4-mapped IPv6 address.
0This is an IPv4 address.

Definition at line 418 of file netsock2.c.

References ast_sockaddr::len, and ast_sockaddr::ss.

Referenced by add_sdp(), apply_netmask(), ast_apply_ha(), ast_ouraddrfor(), ast_rtp_new(), ast_rtp_prop_set(), ast_set_qos(), ast_sip_ouraddrfor(), ast_sockaddr_ipv4_mapped(), ast_sockaddr_is_any(), ast_sockaddr_is_ipv6_link_local(), ast_tcptls_client_create(), ast_tcptls_server_start(), ast_udptl_new_with_bindaddr(), get_address_family_filter(), multicast_send_control_packet(), reload_config(), and sip_show_settings().

419 {
420  return addr->ss.ss_family == AF_INET6 &&
421  addr->len == sizeof(struct sockaddr_in6);
422 }
struct sockaddr_storage ss
Definition: netsock2.h:64
socklen_t len
Definition: netsock2.h:65
int ast_sockaddr_is_ipv6_link_local ( const struct ast_sockaddr addr)

Determine if this is a link-local IPv6 address.

Since
1.8
Warning
You should rarely need this function. Only use if you know what you're doing.
Return values
1This is a link-local IPv6 address.
0This is link-local IPv6 address.

Definition at line 412 of file netsock2.c.

References ast_sockaddr_is_ipv6(), and ast_sockaddr::ss.

Referenced by ast_sockaddr_stringify_fmt().

413 {
414  const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&addr->ss;
415  return ast_sockaddr_is_ipv6(addr) && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr);
416 }
struct sockaddr_storage ss
Definition: netsock2.h:64
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
Definition: netsock2.c:418
int ast_sockaddr_parse ( struct ast_sockaddr addr,
const char *  str,
int  flags 
)

Parse an IPv4 or IPv6 address string.

Since
1.8

Parses a string containing an IPv4 or IPv6 address followed by an optional port (separated by a colon) into a struct ast_sockaddr. The allowed formats are the following:

a.b.c.d a.b.c.d:port a:b:c:...:d [a:b:c:...:d] Host names are NOT allowed.

Parameters
[out]addrThe resulting ast_sockaddr. This MAY be NULL from functions that are performing validity checks only, e.g. ast_parse_arg().
strThe string to parse
flagsIf set to zero, a port MAY be present. If set to PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a port MUST NOT be present.
Return values
1Success
0Failure

Definition at line 198 of file netsock2.c.

References ast_log(), ast_sockaddr_split_hostport(), ast_strdupa, ast_sockaddr::len, LOG_ERROR, LOG_WARNING, S_OR, and ast_sockaddr::ss.

Referenced by ast_append_ha(), ast_parse_arg(), build_peer(), internal_dnsmgr_lookup(), multicast_rtp_request(), proxy_update(), realtime_peer(), reg_source_db(), reload_config(), rtcp_do_debug_ip(), rtp_do_debug_ip(), sip_sanitized_host(), and sip_uri_domain_cmp().

199 {
200  struct addrinfo hints;
201  struct addrinfo *res;
202  char *s;
203  char *host;
204  char *port;
205  int e;
206 
207  s = ast_strdupa(str);
208  if (!ast_sockaddr_split_hostport(s, &host, &port, flags)) {
209  return 0;
210  }
211 
212  memset(&hints, 0, sizeof(hints));
213  /* Hint to get only one entry from getaddrinfo */
214  hints.ai_socktype = SOCK_DGRAM;
215 
216 #ifdef AI_NUMERICSERV
217  hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
218 #else
219  hints.ai_flags = AI_NUMERICHOST;
220 #endif
221  if ((e = getaddrinfo(host, port, &hints, &res))) {
222  if (e != EAI_NONAME) { /* if this was just a host name rather than a ip address, don't print error */
223  ast_log(LOG_ERROR, "getaddrinfo(\"%s\", \"%s\", ...): %s\n",
224  host, S_OR(port, "(null)"), gai_strerror(e));
225  }
226  return 0;
227  }
228 
229  /*
230  * I don't see how this could be possible since we're not resolving host
231  * names. But let's be careful...
232  */
233  if (res->ai_next != NULL) {
234  ast_log(LOG_WARNING, "getaddrinfo() returned multiple "
235  "addresses. Ignoring all but the first.\n");
236  }
237 
238  if (addr) {
239  addr->len = res->ai_addrlen;
240  memcpy(&addr->ss, res->ai_addr, addr->len);
241  }
242 
243  freeaddrinfo(res);
244 
245  return 1;
246 }
struct sockaddr_storage ss
Definition: netsock2.h:64
#define LOG_WARNING
Definition: logger.h:144
socklen_t len
Definition: netsock2.h:65
const char * str
Definition: app_jack.c:144
static struct ao2_container * hints
Definition: pbx.c:1314
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
Definition: netsock2.c:132
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
int ast_sockaddr_resolve ( struct ast_sockaddr **  addrs,
const char *  str,
int  flags,
int  family 
)

Parses a string with an IPv4 or IPv6 address and place results into an array.

Since
1.8

Parses a string containing a host name or an IPv4 or IPv6 address followed by an optional port (separated by a colon). The result is returned into a array of struct ast_sockaddr. Allowed formats for str are the following:

hostname:port host.example.com:port a.b.c.d a.b.c.d:port a:b:c:...:d [a:b:c:...:d]

Parameters
[out]addrsThe resulting array of ast_sockaddrs
strThe string to parse
flagsIf set to zero, a port MAY be present. If set to PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a port MUST NOT be present.
familyOnly addresses of the given family will be returned. Use 0 or AST_SOCKADDR_UNSPEC to get addresses of all families.
Return values
0Failure
non-zeroThe number of elements in addrs array.

Definition at line 248 of file netsock2.c.

References ast_log(), ast_malloc, ast_sockaddr_split_hostport(), ast_strdupa, cleanup(), LOG_ERROR, and S_OR.

Referenced by ast_sockaddr_resolve_first_af(), gtalk_get_local_ip(), handle_cli_udptl_set_debug(), realtime_peer_by_name(), and resolve_first().

250 {
251  struct addrinfo hints, *res, *ai;
252  char *s, *host, *port;
253  int e, i, res_cnt;
254 
255  if (!str) {
256  return 0;
257  }
258 
259  s = ast_strdupa(str);
260  if (!ast_sockaddr_split_hostport(s, &host, &port, flags)) {
261  return 0;
262  }
263 
264  memset(&hints, 0, sizeof(hints));
265  hints.ai_family = family;
266  hints.ai_socktype = SOCK_DGRAM;
267 
268  if ((e = getaddrinfo(host, port, &hints, &res))) {
269  ast_log(LOG_ERROR, "getaddrinfo(\"%s\", \"%s\", ...): %s\n",
270  host, S_OR(port, "(null)"), gai_strerror(e));
271  return 0;
272  }
273 
274  res_cnt = 0;
275  for (ai = res; ai; ai = ai->ai_next) {
276  res_cnt++;
277  }
278 
279  if (res_cnt == 0) {
280  goto cleanup;
281  }
282 
283  if ((*addrs = ast_malloc(res_cnt * sizeof(struct ast_sockaddr))) == NULL) {
284  res_cnt = 0;
285  goto cleanup;
286  }
287 
288  i = 0;
289  for (ai = res; ai; ai = ai->ai_next) {
290  (*addrs)[i].len = ai->ai_addrlen;
291  memcpy(&(*addrs)[i].ss, ai->ai_addr, ai->ai_addrlen);
292  ++i;
293  }
294 
295 cleanup:
296  freeaddrinfo(res);
297  return res_cnt;
298 }
const char * str
Definition: app_jack.c:144
static struct ao2_container * hints
Definition: pbx.c:1314
Socket address structure.
Definition: netsock2.h:63
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
Definition: netsock2.c:132
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void * cleanup(void *unused)
Definition: pbx_realtime.c:125
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
#define ast_malloc(a)
Definition: astmm.h:91
int ast_sockaddr_split_hostport ( char *  str,
char **  host,
char **  port,
int  flags 
)

Splits a string into its host and port components.

Since
1.8
Parameters
str[in]The string to parse. May be modified by writing a NUL at the end of the host part.
host[out]Pointer to the host component within str.
port[out]Pointer to the port component within str.
flagsIf set to zero, a port MAY be present. If set to PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a port MUST NOT be present.
Return values
1Success
0Failure

Definition at line 132 of file netsock2.c.

References ast_debug, ast_log(), LOG_WARNING, PARSE_PORT_FORBID, PARSE_PORT_IGNORE, PARSE_PORT_MASK, PARSE_PORT_REQUIRE, and str.

Referenced by ast_sockaddr_parse(), ast_sockaddr_resolve(), extract_host_from_hostport(), rtcp_do_debug_ip(), rtp_do_debug_ip(), setup_stunaddr(), and sip_parse_host().

133 {
134  char *s = str;
135  char *orig_str = str;/* Original string in case the port presence is incorrect. */
136  char *host_end = NULL;/* Delay terminating the host in case the port presence is incorrect. */
137 
138  ast_debug(5, "Splitting '%s' into...\n", str);
139  *host = NULL;
140  *port = NULL;
141  if (*s == '[') {
142  *host = ++s;
143  for (; *s && *s != ']'; ++s) {
144  }
145  if (*s == ']') {
146  host_end = s;
147  ++s;
148  }
149  if (*s == ':') {
150  *port = s + 1;
151  }
152  } else {
153  *host = s;
154  for (; *s; ++s) {
155  if (*s == ':') {
156  if (*port) {
157  *port = NULL;
158  break;
159  } else {
160  *port = s;
161  }
162  }
163  }
164  if (*port) {
165  host_end = *port;
166  ++*port;
167  }
168  }
169 
170  switch (flags & PARSE_PORT_MASK) {
171  case PARSE_PORT_IGNORE:
172  *port = NULL;
173  break;
174  case PARSE_PORT_REQUIRE:
175  if (*port == NULL) {
176  ast_log(LOG_WARNING, "Port missing in %s\n", orig_str);
177  return 0;
178  }
179  break;
180  case PARSE_PORT_FORBID:
181  if (*port != NULL) {
182  ast_log(LOG_WARNING, "Port disallowed in %s\n", orig_str);
183  return 0;
184  }
185  break;
186  }
187 
188  /* Can terminate the host string now if needed. */
189  if (host_end) {
190  *host_end = '\0';
191  }
192  ast_debug(5, "...host '%s' and port '%s'.\n", *host, *port ? *port : "");
193  return 1;
194 }
#define LOG_WARNING
Definition: logger.h:144
const char * str
Definition: app_jack.c:144
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char* ast_sockaddr_stringify_fmt ( const struct ast_sockaddr addr,
int  format 
)

Convert a socket address to a string.

Since
1.8

This will be of the form a.b.c.d:xyz for IPv4 and [a:b:c:...:d]:xyz for IPv6.

This function is thread-safe. The returned string is on static thread-specific storage.

Parameters
addrThe input to be stringified
formatone of the following: AST_SOCKADDR_STR_DEFAULT: a.b.c.d:xyz for IPv4 [a:b:c:...:d]:xyz for IPv6. AST_SOCKADDR_STR_ADDR: address only a.b.c.d for IPv4 a:b:c:...:d for IPv6. AST_SOCKADDR_STR_HOST: address only, suitable for a URL a.b.c.d for IPv4 [a:b:c:...:d] for IPv6. AST_SOCKADDR_STR_PORT: port only
Note
The string pointer returned by this function will point to a string that will be changed whenever any form of ast_sockaddr_stringify_fmt is called on that thread. Because of this, it is important that if you use this function, you use the string before another use of this function is made elsewhere in the same thread. The easiest way to accomplish this is by immediately copying the string to a buffer with something like ast_strdupa.
Return values
(null)addr is null
""An error occurred during processing
stringThe stringified form of the address

Definition at line 67 of file netsock2.c.

References ast_log(), ast_sockaddr_ipv4_mapped(), ast_sockaddr_is_ipv6_link_local(), ast_sockaddr_isnull(), AST_SOCKADDR_STR_ADDR, AST_SOCKADDR_STR_DEFAULT, AST_SOCKADDR_STR_FORMAT_MASK, AST_SOCKADDR_STR_HOST, AST_SOCKADDR_STR_PORT, AST_SOCKADDR_STR_REMOTE, ast_sockaddr_stringify_buf, ast_str_buffer(), ast_str_set(), ast_str_thread_get(), ast_sockaddr::len, LOG_ERROR, ast_sockaddr::ss, and str.

Referenced by ast_sockaddr_stringify(), ast_sockaddr_stringify_addr(), ast_sockaddr_stringify_addr_remote(), ast_sockaddr_stringify_host(), ast_sockaddr_stringify_host_remote(), ast_sockaddr_stringify_port(), and ast_sockaddr_stringify_remote().

68 {
69  struct ast_sockaddr sa_ipv4;
70  const struct ast_sockaddr *sa_tmp;
71  char host[NI_MAXHOST];
72  char port[NI_MAXSERV];
73  struct ast_str *str;
74  int e;
75  static const size_t size = sizeof(host) - 1 + sizeof(port) - 1 + 4;
76 
77 
78  if (ast_sockaddr_isnull(sa)) {
79  return "(null)";
80  }
81 
82  if (!(str = ast_str_thread_get(&ast_sockaddr_stringify_buf, size))) {
83  return "";
84  }
85 
86  if (ast_sockaddr_ipv4_mapped(sa, &sa_ipv4)) {
87  sa_tmp = &sa_ipv4;
88  } else {
89  sa_tmp = sa;
90  }
91 
92  if ((e = getnameinfo((struct sockaddr *)&sa_tmp->ss, sa_tmp->len,
93  format & AST_SOCKADDR_STR_ADDR ? host : NULL,
94  format & AST_SOCKADDR_STR_ADDR ? sizeof(host) : 0,
95  format & AST_SOCKADDR_STR_PORT ? port : 0,
96  format & AST_SOCKADDR_STR_PORT ? sizeof(port): 0,
97  NI_NUMERICHOST | NI_NUMERICSERV))) {
98  ast_log(LOG_ERROR, "getnameinfo(): %s\n", gai_strerror(e));
99  return "";
100  }
101 
102  if ((format & AST_SOCKADDR_STR_REMOTE) == AST_SOCKADDR_STR_REMOTE) {
103  char *p;
104  if (ast_sockaddr_is_ipv6_link_local(sa) && (p = strchr(host, '%'))) {
105  *p = '\0';
106  }
107  }
108 
109  switch ((format & AST_SOCKADDR_STR_FORMAT_MASK)) {
111  ast_str_set(&str, 0, sa_tmp->ss.ss_family == AF_INET6 ?
112  "[%s]:%s" : "%s:%s", host, port);
113  break;
115  ast_str_set(&str, 0, "%s", host);
116  break;
118  ast_str_set(&str, 0,
119  sa_tmp->ss.ss_family == AF_INET6 ? "[%s]" : "%s", host);
120  break;
122  ast_str_set(&str, 0, "%s", port);
123  break;
124  default:
125  ast_log(LOG_ERROR, "Invalid format\n");
126  return "";
127  }
128 
129  return ast_str_buffer(str);
130 }
struct sockaddr_storage ss
Definition: netsock2.h:64
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
int ast_sockaddr_ipv4_mapped(const struct ast_sockaddr *addr, struct ast_sockaddr *ast_mapped)
Convert an IPv4-mapped IPv6 address into an IPv4 address.
Definition: netsock2.c:39
socklen_t len
Definition: netsock2.h:65
const char * str
Definition: app_jack.c:144
Socket address structure.
Definition: netsock2.h:63
#define AST_SOCKADDR_STR_DEFAULT
Definition: netsock2.h:157
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. &quot;null&quot; in this sense essentially means uninitialized, or having a 0 length.
Definition: netsock2.h:93
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:874
#define LOG_ERROR
Definition: logger.h:155
#define AST_SOCKADDR_STR_PORT
Definition: netsock2.h:153
int ast_sockaddr_is_ipv6_link_local(const struct ast_sockaddr *addr)
Determine if this is a link-local IPv6 address.
Definition: netsock2.c:412
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
#define AST_SOCKADDR_STR_HOST
Definition: netsock2.h:156
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_SOCKADDR_STR_ADDR
Definition: netsock2.h:152
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Definition: strings.h:669
#define AST_SOCKADDR_STR_FORMAT_MASK
Definition: netsock2.h:161
static snd_pcm_format_t format
Definition: chan_alsa.c:93
static struct ast_threadstorage ast_sockaddr_stringify_buf
Definition: netsock2.c:65
#define AST_SOCKADDR_STR_REMOTE
Definition: netsock2.h:155

Variable Documentation

struct ast_threadstorage ast_sockaddr_stringify_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_ast_sockaddr_stringify_buf , .custom_init = NULL , }
static

Definition at line 65 of file netsock2.c.

Referenced by ast_sockaddr_stringify_fmt().