Asterisk - The Open Source Telephony Project GIT-master-2070bb5
|
Network socket handling. More...
Go to the source code of this file.
Data Structures | |
struct | ast_sockaddr |
Socket address structure. More... | |
Enumerations | |
enum | { AST_AF_UNSPEC = AF_UNSPEC , AST_AF_INET = AF_INET , AST_AF_INET6 = AF_INET6 } |
enum | ast_transport { AST_TRANSPORT_UDP = 1 , AST_TRANSPORT_TCP = 1 << 1 , AST_TRANSPORT_TLS = 1 << 2 , AST_TRANSPORT_WS = 1 << 3 , AST_TRANSPORT_WSS = 1 << 4 } |
Functions | |
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_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_apply_netmask (const struct ast_sockaddr *addr, const struct ast_sockaddr *netmask, struct ast_sockaddr *result) |
Apply a netmask to an address and store the result in a separate structure. More... | |
int | ast_sockaddr_cidr_bits (const struct ast_sockaddr *sa) |
Count the 1 bits in a netmask. 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... | |
static void | ast_sockaddr_copy (struct ast_sockaddr *dst, const struct ast_sockaddr *src) |
Copies the data from one ast_sockaddr to another. More... | |
static void | ast_sockaddr_copy_sockaddr (struct ast_sockaddr *dst, struct sockaddr *src, socklen_t len) |
Copies the data from a sockaddr to an ast_sockaddr. 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_ipv4_multicast (const struct ast_sockaddr *addr) |
Determine if an IPv4 address is a multicast 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... | |
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. 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_resolve_first_af (struct ast_sockaddr *addr, const char *name, int flag, int family) |
Return the first entry from ast_sockaddr_resolve filtered by address family. More... | |
static void | ast_sockaddr_setnull (struct ast_sockaddr *addr) |
Sets address addr to null. More... | |
int | ast_sockaddr_split_hostport (char *str, char **host, char **port, int flags) |
Splits a string into its host and port components. More... | |
static char * | ast_sockaddr_stringify (const struct ast_sockaddr *addr) |
Wrapper around ast_sockaddr_stringify_fmt() with default format. More... | |
static char * | ast_sockaddr_stringify_addr (const struct ast_sockaddr *addr) |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only. More... | |
static char * | ast_sockaddr_stringify_addr_remote (const struct ast_sockaddr *addr) |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only. More... | |
char * | ast_sockaddr_stringify_fmt (const struct ast_sockaddr *addr, int format) |
Convert a socket address to a string. More... | |
static char * | ast_sockaddr_stringify_host (const struct ast_sockaddr *addr) |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brackets for IPv6). More... | |
static char * | ast_sockaddr_stringify_host_remote (const struct ast_sockaddr *addr) |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brackets for IPv6). More... | |
static char * | ast_sockaddr_stringify_port (const struct ast_sockaddr *addr) |
Wrapper around ast_sockaddr_stringify_fmt() to return a port only. More... | |
static char * | ast_sockaddr_stringify_remote (const struct ast_sockaddr *addr) |
Wrapper around ast_sockaddr_stringify_fmt() with default format. More... | |
const char * | ast_transport2str (enum ast_transport transport) |
Returns a string representation of an ast_transport. More... | |
static int | _ast_addressfamily_to_sockaddrsize (int af, const char *file, int line, const char *func) |
void | _ast_sockaddr_from_sin (struct ast_sockaddr *addr, const struct sockaddr_in *sin, 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) |
#define | ast_addressfamily_to_sockaddrsize(family) _ast_addressfamily_to_sockaddrsize(family, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Takes an AF_XXX value as input and returns the size of the underlying sockaddr structure if known, or zero if not. More... | |
#define | ast_sockaddr_from_sin(addr, sin) _ast_sockaddr_from_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Converts a struct sockaddr_in to a struct ast_sockaddr. More... | |
#define | ast_sockaddr_from_sockaddr(addr, sa) ast_sockaddr_copy_sockaddr(addr, sa, ast_addressfamily_to_sockaddrsize(((const struct sockaddr*)(sa))->sa_family)) |
Converts a struct sockaddr to a struct ast_sockaddr. More... | |
#define | ast_sockaddr_to_sin(addr, sin) _ast_sockaddr_to_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Converts a struct ast_sockaddr to a struct sockaddr_in. More... | |
Network socket handling.
Definition in file netsock2.h.
#define ast_addressfamily_to_sockaddrsize | ( | family | ) | _ast_addressfamily_to_sockaddrsize(family, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Takes an AF_XXX value as input and returns the size of the underlying sockaddr structure if known, or zero if not.
family | The AF_XXX value to determine the size of |
Definition at line 791 of file netsock2.h.
#define AST_SOCKADDR_BUFLEN (45 + 2 + 1 + 5 + 1) |
Definition at line 46 of file netsock2.h.
#define ast_sockaddr_from_sin | ( | addr, | |
sin | |||
) | _ast_sockaddr_from_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Converts a struct sockaddr_in to a struct ast_sockaddr.
addr | |
sin | The sockaddr_in to convert |
Definition at line 778 of file netsock2.h.
#define ast_sockaddr_from_sockaddr | ( | addr, | |
sa | |||
) | ast_sockaddr_copy_sockaddr(addr, sa, ast_addressfamily_to_sockaddrsize(((const struct sockaddr*)(sa))->sa_family)) |
Converts a struct sockaddr to a struct ast_sockaddr.
Note that there is an underlying assumption that sockaddr data is valid, more specifically, if sa_family is set to AF_INET that it's actually a sockaddr_in, and in the case of AF_INET6 a valid sockaddr_in6 structure.
You can check for failure with ast_sockaddr_isnull.
[out] | addr | The address of the ast_sockaddr to store into |
sa | The sockaddr structure (sockaddr_in or sockaddr_in6) to convert |
Definition at line 819 of file netsock2.h.
#define ast_sockaddr_port | ( | addr | ) | _ast_sockaddr_port(addr, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Get the port number of a socket address.
0 | Address is null |
non-zero | The port number of the ast_sockaddr |
Definition at line 517 of file netsock2.h.
#define ast_sockaddr_set_port | ( | addr, | |
port | |||
) | _ast_sockaddr_set_port(addr,port,__FILE__,__LINE__,__PRETTY_FUNCTION__) |
Sets the port number of a socket address.
addr | Address on which to set the port |
port | The port you wish to set the address to use |
Definition at line 532 of file netsock2.h.
#define AST_SOCKADDR_STR_ADDR (1 << 0) |
Definition at line 198 of file netsock2.h.
#define AST_SOCKADDR_STR_ADDR_REMOTE (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_REMOTE) |
Definition at line 204 of file netsock2.h.
#define AST_SOCKADDR_STR_BRACKETS (1 << 2) |
Definition at line 200 of file netsock2.h.
#define AST_SOCKADDR_STR_DEFAULT (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT) |
Definition at line 203 of file netsock2.h.
#define AST_SOCKADDR_STR_DEFAULT_REMOTE (AST_SOCKADDR_STR_DEFAULT | AST_SOCKADDR_STR_REMOTE) |
Definition at line 206 of file netsock2.h.
#define AST_SOCKADDR_STR_FORMAT_MASK (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT | AST_SOCKADDR_STR_BRACKETS) |
Definition at line 207 of file netsock2.h.
#define AST_SOCKADDR_STR_HOST (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_BRACKETS) |
Definition at line 202 of file netsock2.h.
#define AST_SOCKADDR_STR_HOST_REMOTE (AST_SOCKADDR_STR_HOST | AST_SOCKADDR_STR_REMOTE) |
Definition at line 205 of file netsock2.h.
#define AST_SOCKADDR_STR_PORT (1 << 1) |
Definition at line 199 of file netsock2.h.
#define AST_SOCKADDR_STR_REMOTE (1 << 3) |
Definition at line 201 of file netsock2.h.
#define ast_sockaddr_to_sin | ( | addr, | |
sin | |||
) | _ast_sockaddr_to_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Converts a struct ast_sockaddr to a struct sockaddr_in.
These are backward compatibility functions that may be used by subsystems that have not yet been converted to IPv6. They will be removed when all subsystems are IPv6-ready.
addr | The ast_sockaddr to convert | |
[out] | sin | The resulting sockaddr_in struct |
nonzero | Success |
zero | Failure |
Definition at line 765 of file netsock2.h.
#define V6_WORD | ( | sin6, | |
index | |||
) | ((uint32_t *)&((sin6)->sin6_addr))[(index)] |
Isolate a 32-bit section of an IPv6 address.
An IPv6 address can be divided into 4 32-bit chunks. This gives easy access to one of these chunks.
sin6 | A pointer to a struct sockaddr_in6 |
index | Which 32-bit chunk to operate on. Must be in the range 0-3. |
Definition at line 77 of file netsock2.h.
anonymous enum |
Values for address families that we support. This is reproduced from socket.h because we do not want users to include that file. Only netsock2.c should ever include socket.h.
Enumerator | |
---|---|
AST_AF_UNSPEC | |
AST_AF_INET | |
AST_AF_INET6 |
Definition at line 53 of file netsock2.h.
enum ast_transport |
Enumerator | |
---|---|
AST_TRANSPORT_UDP | |
AST_TRANSPORT_TCP | |
AST_TRANSPORT_TLS | |
AST_TRANSPORT_WS | |
AST_TRANSPORT_WSS |
Definition at line 59 of file netsock2.h.
|
inlinestatic |
Definition at line 792 of file netsock2.h.
References __LOG_WARNING, ast_log, and make_ari_stubs::file.
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 689 of file netsock2.c.
References __LOG_DEBUG, ast_log, DEBUG_ATLEAST, make_ari_stubs::file, ast_sockaddr::len, and ast_sockaddr::ss.
uint16_t _ast_sockaddr_port | ( | const struct ast_sockaddr * | addr, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 453 of file netsock2.c.
References __LOG_DEBUG, ast_log, DEBUG_ATLEAST, make_ari_stubs::file, ast_sockaddr::len, and ast_sockaddr::ss.
void _ast_sockaddr_set_port | ( | struct ast_sockaddr * | addr, |
uint16_t | port, | ||
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 473 of file netsock2.c.
References __LOG_DEBUG, ast_log, DEBUG_ATLEAST, make_ari_stubs::file, ast_sockaddr::len, and ast_sockaddr::ss.
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 668 of file netsock2.c.
References __LOG_DEBUG, __LOG_ERROR, ast_log, ast_sockaddr_isnull(), DEBUG_ATLEAST, make_ari_stubs::file, ast_sockaddr::len, and ast_sockaddr::ss.
int ast_accept | ( | int | sockfd, |
struct ast_sockaddr * | addr | ||
) |
Wrapper around accept(2) that uses struct ast_sockaddr.
For parameter and return information, see the man page for accept(2).
Definition at line 584 of file netsock2.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_tcptls_server_root().
int ast_bind | ( | int | sockfd, |
const struct ast_sockaddr * | addr | ||
) |
Wrapper around bind(2) that uses struct ast_sockaddr.
For parameter and return information, see the man page for bind(2).
Definition at line 590 of file netsock2.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_netsock_bindaddr(), ast_rtp_prop_set(), ast_tcptls_client_create(), ast_tcptls_server_start(), ast_udptl_new_with_bindaddr(), check_srcaddr(), load_module(), and rtp_allocate_transport().
int ast_connect | ( | int | sockfd, |
const struct ast_sockaddr * | addr | ||
) |
Wrapper around connect(2) that uses struct ast_sockaddr.
For parameter and return information, see the man page for connect(2).
Definition at line 595 of file netsock2.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_audiosocket_connect(), ast_ouraddrfor(), launch_netscript(), socket_connect(), and stun_monitor_request().
int ast_getsockname | ( | int | sockfd, |
struct ast_sockaddr * | addr | ||
) |
Wrapper around getsockname(2) that uses struct ast_sockaddr.
For parameter and return information, see the man page for getsockname(2).
Definition at line 600 of file netsock2.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_ouraddrfor(), ast_set_qos(), and ast_websocket_uri_cb().
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.
For parameter and return information, see the man page for recvfrom(2).
Definition at line 606 of file netsock2.c.
References buf, len(), ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by __rtp_recvfrom(), ast_udptl_read(), and socket_read().
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.
For parameter and return information, see the man page for sendto(2)
Definition at line 614 of file netsock2.c.
References buf, len(), ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by __rtp_sendto(), ast_statsd_log_string(), ast_udptl_write(), dundi_xmit(), hep_queue_cb(), multicast_send_control_packet(), raw_hangup(), rtp_raw_write(), send_apathetic_reply(), send_packet(), and transmit_trunk().
int ast_set_qos | ( | int | sockfd, |
int | tos, | ||
int | cos, | ||
const char * | desc | ||
) |
Set type of service.
Set ToS ("Type of Service for IPv4 and "Traffic Class for IPv6) and CoS (Linux's SO_PRIORITY)
sockfd | File descriptor for socket on which to set the parameters |
tos | The type of service for the socket |
cos | The cost of service for the socket |
desc | A text description of the socket in question. |
0 | Success |
-1 | Error, with errno set to an appropriate value |
Definition at line 621 of file netsock2.c.
References ast_getsockname(), ast_log, ast_sockaddr_is_any(), ast_sockaddr_is_ipv6(), ast_verb, cos, desc, errno, LOG_WARNING, and tos.
Referenced by ast_netsock_bindaddr(), ast_netsock_set_qos(), ast_rtp_qos_set(), ast_udptl_setqos(), load_module(), and reload_config().
int ast_sockaddr_apply_netmask | ( | const struct ast_sockaddr * | addr, |
const struct ast_sockaddr * | netmask, | ||
struct ast_sockaddr * | result | ||
) |
Apply a netmask to an address and store the result in a separate structure.
When dealing with IPv6 addresses, one cannot apply a netmask with a simple logical AND operation. Futhermore, the incoming address may be an IPv4 address and needs to be mapped properly before attempting to apply a rule.
addr | The IP address to apply the mask to. |
netmask | The netmask configured in the host access rule. |
result | The resultant address after applying the netmask to the given address |
0 | Successfully applied netmask |
-1 | Failed to apply netmask |
Definition at line 357 of file netsock2.c.
References ast_sockaddr_from_sin, ast_sockaddr_is_ipv4(), ast_sockaddr_is_ipv6(), result, ast_sockaddr::ss, and V6_WORD.
Referenced by addr_range_match_address_cb(), append_ha_core(), ast_apply_ha(), and authenticate_reply().
int ast_sockaddr_cidr_bits | ( | const struct ast_sockaddr * | sa | ) |
Count the 1 bits in a netmask.
Definition at line 130 of file netsock2.c.
References ast_sockaddr_ipv4_mapped(), ast_sockaddr_isnull(), ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_ha_join_cidr(), and cli_print_body().
int ast_sockaddr_cmp | ( | const struct ast_sockaddr * | a, |
const struct ast_sockaddr * | b | ||
) |
Compares two ast_sockaddr structures.
-1 | a is lexicographically smaller than b |
0 | a is equal to b |
1 | b is lexicographically smaller than a |
Definition at line 388 of file netsock2.c.
References a, ast_sockaddr_ipv4_mapped(), b, ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by __rtp_recvfrom(), ast_netsock_find(), ast_rtcp_interpret(), ast_rtp_instance_get_and_cmp_local_address(), ast_rtp_instance_get_and_cmp_requested_target_address(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_sockaddr_pj_sockaddr_cmp(), ast_tcptls_client_create(), ast_tcptls_server_start(), AST_TEST_DEFINE(), ast_udptl_read(), dnsmgr_refresh(), find_tpeer(), find_transaction(), handle_command_response(), has_state_changed(), iax2_ack_registry(), iax2_getpeername(), iax2_getpeertrunk(), match(), registry_rerequest(), rtcp_debug_test_addr(), rtp_debug_test_addr(), socket_process_helper(), udptl_debug_test_addr(), and update_registry().
int ast_sockaddr_cmp_addr | ( | const struct ast_sockaddr * | a, |
const struct ast_sockaddr * | b | ||
) |
Compares the addresses of two ast_sockaddr structures.
-1 | a is lexicographically smaller than b |
0 | a is equal to b |
1 | b is lexicographically smaller than a |
Definition at line 413 of file netsock2.c.
References a, ast_sockaddr_ipv4_mapped(), b, ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by addr_range_cmp_cb(), addr_range_match_address_cb(), ast_apply_ha(), AST_TEST_DEFINE(), authenticate_reply(), iax_outputframe(), peercnt_cmp_cb(), realtime_peer(), realtime_user(), rtcp_debug_test_addr(), rtp_debug_test_addr(), socket_read(), and udptl_debug_test_addr().
|
inlinestatic |
Copies the data from one ast_sockaddr to another.
dst | The destination ast_sockaddr |
src | The source ast_sockaddr |
Definition at line 167 of file netsock2.h.
References ast_sockaddr::len.
Referenced by __ast_http_load(), __find_callno(), __init_manager(), __rtp_recvfrom(), app_exec(), apply_peer(), ast_copy_ha(), ast_find_ourip(), ast_netsock_bindaddr(), ast_rtcp_interpret(), ast_rtcp_read(), ast_rtcp_write(), ast_rtp_instance_get_and_cmp_local_address(), ast_rtp_instance_get_and_cmp_requested_target_address(), ast_rtp_instance_get_incoming_source_address(), ast_rtp_instance_get_local_address(), ast_rtp_instance_get_requested_target_address(), ast_rtp_instance_new(), ast_rtp_instance_set_local_address(), ast_rtp_instance_set_requested_target_address(), ast_rtp_new(), ast_rtp_prop_set(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_sockaddr_resolve_first_af(), ast_tcptls_client_create(), ast_tcptls_server_root(), ast_tcptls_server_start(), ast_udptl_get_peer(), ast_udptl_get_us(), ast_udptl_new_with_bindaddr(), ast_udptl_read(), ast_udptl_set_peer(), ast_websocket_uri_cb(), auth_manager_http_callback(), auth_mxml_http_callback(), auth_rawman_http_callback(), authenticate_reply(), build_mansession(), build_peer(), configure_local_rtp(), create_addr(), dnsmgr_refresh(), dundi_reject(), find_tpeer(), find_transaction(), handle_cli_iax2_set_debug(), handle_cli_iax2_show_callno_limits(), handle_cli_udptl_set_debug(), handle_command_response(), http_server_create(), iax2_ack_registry(), iax2_provision(), manager_http_callback(), mxml_http_callback(), peercnt_add(), peercnt_modify(), peercnt_remove(), peercnt_remove_by_addr(), populate_addr(), rawman_http_callback(), resolve_first(), rtp_allocate_transport(), rtp_instance_set_incoming_source_address_nolock(), rtp_reload(), rtp_transport_wide_cc_feedback_produce(), sched_delay_remove(), session_do(), set_peercnt_limit(), socket_process_helper(), socket_read(), try_transfer(), unicast_rtp_request(), update_registry(), websocket_client_args_create(), and websocket_client_connect().
|
inlinestatic |
Copies the data from a sockaddr to an ast_sockaddr.
dst | The destination ast_sockaddr |
src | The source sockaddr |
len | Length of the value stored in sockaddr |
Definition at line 151 of file netsock2.h.
References len(), and ast_sockaddr::len.
Referenced by curl_open_socket_cb().
int ast_sockaddr_hash | ( | const struct ast_sockaddr * | addr | ) |
Computes a hash value from the address. The port is ignored.
0 | Unknown address family |
other | A 32-bit hash derived from the address |
Definition at line 548 of file netsock2.c.
References ast_log, LOG_ERROR, and ast_sockaddr::ss.
Referenced by addr_range_hash_cb(), and peercnt_hash_cb().
uint32_t ast_sockaddr_ipv4 | ( | const struct ast_sockaddr * | addr | ) |
Get an IPv4 address of an ast_sockaddr.
Definition at line 491 of file netsock2.c.
References ast_sockaddr::ss.
Referenced by ast_sockaddr_is_ipv4_multicast(), iax_template_parse(), and multicast_send_control_packet().
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.
addr | The IPv4-mapped address to convert |
ast_mapped | The resulting IPv4 address |
0 | Unable to make the conversion |
1 | Successful conversion |
Definition at line 37 of file netsock2.c.
References ast_sockaddr_from_sin, ast_sockaddr_is_ipv4_mapped(), ast_sockaddr_is_ipv6(), and ast_sockaddr::ss.
Referenced by append_ha_core(), ast_apply_ha(), ast_rtcp_read(), ast_rtp_read(), ast_sockaddr_cidr_bits(), ast_sockaddr_cmp(), ast_sockaddr_cmp_addr(), and ast_sockaddr_stringify_fmt().
int ast_sockaddr_is_any | ( | const struct ast_sockaddr * | addr | ) |
Determine if the address type is unspecified, or "any" address.
For IPv4, this would be the address 0.0.0.0, and for IPv6, this would be the address ::. The port number is ignored.
1 | This is an "any" address |
0 | This is not an "any" address |
Definition at line 534 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_tcptls_client_create(), and set_session_media_remotely_held().
int ast_sockaddr_is_ipv4 | ( | const struct ast_sockaddr * | addr | ) |
Determine if the address is an IPv4 address.
1 | This is an IPv4 address |
0 | This is an IPv6 or IPv4-mapped IPv6 address |
Definition at line 497 of file netsock2.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by append_ha_core(), ast_apply_ha(), ast_json_ipaddr(), ast_rtcp_read(), ast_rtp_prop_set(), ast_rtp_read(), ast_sockaddr_apply_netmask(), ast_sockaddr_is_any(), dump_addr(), dundi_xmit(), hep_queue_cb(), jingle_interpret_ice_udp_transport(), load_module(), negotiate_incoming_sdp_stream(), and rtp_allocate_transport().
int ast_sockaddr_is_ipv4_mapped | ( | const struct ast_sockaddr * | addr | ) |
Determine if this is an IPv4-mapped IPv6 address.
1 | This is an IPv4-mapped IPv6 address. |
0 | This is not an IPv4-mapped IPv6 address. |
Definition at line 507 of file netsock2.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_apply_ha(), ast_json_ipaddr(), ast_sockaddr_ipv4_mapped(), build_peer(), and dump_addr().
int ast_sockaddr_is_ipv4_multicast | ( | const struct ast_sockaddr * | addr | ) |
Determine if an IPv4 address is a multicast address.
addr | the address to check |
This function checks if an address is in the 224.0.0.0/4 network block.
Definition at line 513 of file netsock2.c.
References ast_sockaddr_ipv4().
int ast_sockaddr_is_ipv6 | ( | const struct ast_sockaddr * | addr | ) |
Determine if this is an IPv6 address.
1 | This is an IPv6 or IPv4-mapped IPv6 address. |
0 | This is an IPv4 address. |
Definition at line 524 of file netsock2.c.
References ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by ast_apply_ha(), ast_netsock_bindaddr(), ast_ouraddrfor(), ast_rtp_prop_set(), ast_set_qos(), ast_sockaddr_apply_netmask(), 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(), build_peer(), hepv3_data_alloc(), load_module(), multicast_send_control_packet(), negotiate_incoming_sdp_stream(), reload_config(), rtp_allocate_transport(), and set_host_ipaddr().
int ast_sockaddr_is_ipv6_link_local | ( | const struct ast_sockaddr * | addr | ) |
Determine if this is a link-local IPv6 address.
1 | This is a link-local IPv6 address. |
0 | This is link-local IPv6 address. |
Definition at line 518 of file netsock2.c.
References ast_sockaddr_is_ipv6(), and ast_sockaddr::ss.
Referenced by ast_sockaddr_stringify_fmt().
|
inlinestatic |
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
addr | Pointer to the ast_sockaddr we wish to check |
1 | addr is null |
0 | addr is non-null. |
Definition at line 127 of file netsock2.h.
References ast_sockaddr::len.
Referenced by __ast_http_load(), __iax2_do_register_s(), __iax2_show_peers(), __init_manager(), __rtp_recvfrom(), _ast_sockaddr_to_sin(), acf_channel_read(), add_ice_to_stream(), append_transaction(), apply_peer(), ast_rtcp_calculate_sr_rr_statistics(), ast_rtcp_generate_nack(), ast_rtcp_generate_report(), ast_rtcp_generate_sdes(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_interpret(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_rtp_sendcng(), ast_rtp_write(), ast_sip_rewrite_uri_to_local(), ast_sockaddr_cidr_bits(), ast_sockaddr_stringify_fmt(), ast_tcptls_client_create(), ast_tcptls_server_start(), ast_udptl_read(), ast_udptl_write(), authenticate_reply(), bridge_p2p_rtp_write(), build_peer(), check_for_rtp_changes(), create_addr(), create_outgoing_sdp_stream(), create_transaction(), do_monitor(), dundi_show_peer(), dundi_show_peers(), dundi_sockaddr_port(), dundi_sockaddr_stringify_host(), function_iaxpeer(), handle_cli_iax2_show_registry(), iax2_ack_registry(), iax2_devicestate(), iax2_do_register(), iax2_poke_peer(), iax2_prov_app(), iax_outputframe(), jingle_interpret_ice_udp_transport(), load_module(), manager_iax2_show_registry(), multicast_send_control_packet(), ooh323_indicate(), ooh323_set_rtp_peer(), peercnt_hash_cb(), process_nat(), realtime_peer(), realtime_update_peer(), realtime_user(), rtcp_debug_test_addr(), rtp_check_timeout(), rtp_debug_test_addr(), rtp_raw_write(), rtp_write_rtcp_fir(), rtp_write_rtcp_psfb(), send_keepalive(), set_caps(), set_config(), set_session_media_remotely_held(), socket_process_helper(), try_transfer(), udptl_debug_test_addr(), and update_registry().
int ast_sockaddr_parse | ( | struct ast_sockaddr * | addr, |
const char * | str, | ||
int | flags | ||
) |
Parse an IPv4 or IPv6 address string.
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.
[out] | addr | The resulting ast_sockaddr. This MAY be NULL from functions that are performing validity checks only, e.g. ast_parse_arg(). |
str | The string to parse | |
flags | If 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. |
1 | Success |
0 | Failure |
Definition at line 230 of file netsock2.c.
References ast_log, ast_sockaddr_split_hostport(), ast_strdupa, ast_sockaddr::len, LOG_ERROR, LOG_WARNING, NULL, S_OR, ast_sockaddr::ss, and str.
Referenced by __init_manager(), append_ha_core(), apply_acl(), apply_endpoint_acl(), ast_netsock_bind(), ast_parse_arg(), ast_sip_get_transport_name(), ast_sip_rewrite_uri_to_local(), AST_TEST_DEFINE(), build_peer(), change_outgoing_sdp_stream_media_address(), corosync_node_alloc(), create_rtp(), evt_gen_auth_method_not_allowed(), evt_gen_chal_resp_failed(), evt_gen_chal_sent(), evt_gen_failed_acl(), evt_gen_inval_acct_id(), evt_gen_inval_password(), evt_gen_inval_transport(), evt_gen_load_avg(), evt_gen_mem_limit(), evt_gen_req_bad_format(), evt_gen_req_no_support(), evt_gen_req_not_allowed(), evt_gen_session_limit(), evt_gen_successful_auth(), evt_gen_unexpected_addr(), internal_dnsmgr_lookup(), ip_identify(), ip_identify_match_handler(), jingle_alloc(), jingle_enable_video(), jingle_interpret_google_transport(), jingle_interpret_ice_udp_transport(), load_module(), logging_on_rx_msg(), logging_on_tx_msg(), media_address_handler(), multicast_rtp_request(), peer_set_srcaddr(), pjsip_enable_logger_host(), pjsip_log_test_filter(), process_ice_attributes(), process_nat(), realtime_peer(), reg_source_db(), rtcp_do_debug_ip(), rtcp_message_handler(), rtp_do_debug_ip(), security_event_populate(), session_outgoing_nat_hook(), set_config(), set_loc_src(), t38_initialize_session(), test_init_rtp_instances(), unicast_rtp_request(), and validate_location_source().
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.
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]
[out] | addrs | The resulting array of ast_sockaddrs |
str | The string to parse | |
flags | If 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. | |
family | Only addresses of the given family will be returned. Use 0 or AST_AF_UNSPEC to get addresses of all families. |
0 | Failure |
non-zero | The number of elements in addrs array. |
Definition at line 280 of file netsock2.c.
References ast_log, ast_malloc, ast_sockaddr_split_hostport(), ast_strdupa, cleanup(), LOG_ERROR, NULL, S_OR, and str.
Referenced by app_exec(), apply_negotiated_sdp_stream(), ast_audiosocket_connect(), ast_sockaddr_resolve_first_af(), build_peer(), extract_contact_addr(), get_ipaddress(), handle_cli_udptl_set_debug(), http_server_get_by_host(), ip_identify_match_host_lookup(), launch_netscript(), negotiate_incoming_sdp_stream(), populate_addr(), realtime_peer(), realtime_user(), resolve_first(), and websocket_client_args_create().
int ast_sockaddr_resolve_first_af | ( | struct ast_sockaddr * | addr, |
const char * | name, | ||
int | flag, | ||
int | family | ||
) |
Return the first entry from ast_sockaddr_resolve filtered by address family.
Parses a string containing a host name or an IPv4 or IPv6 address followed by an optional port (separated by a colon). This function only returns the first address into the ast_sockaddr. Allowed formats for name 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]
[out] | addr | The resulting ast_sockaddr |
name | The string to parse | |
flag | If 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. | |
family | Only addresses of the given family will be returned. Use 0 or AST_AF_UNSPEC to specify any address family. Behavior is ultimately determined by getaddrinfo in how it orders return results. First result is selected to be returned. |
0 | Success |
non-zero | Failure |
Return the first entry from ast_sockaddr_resolve filtered by address family.
Definition at line 337 of file netsock2.c.
References ast_debug, ast_free, ast_sockaddr_copy(), ast_sockaddr_resolve(), and name.
Referenced by ast_parse_arg(), audiosocket_request(), festival_exec(), hepv3_data_alloc(), iax_template_parse(), pjsip_enable_logger_host(), and reload_config().
|
inlinestatic |
Sets address addr to null.
Definition at line 138 of file netsock2.h.
References ast_sockaddr::len.
Referenced by __ast_http_load(), __expire_registry(), ast_tcptls_client_create(), ast_tcptls_server_start(), ast_udptl_stop(), build_peer(), check_for_rtp_changes(), do_register_expire(), get_local_address(), load_module(), manager_set_defaults(), multicast_rtp_request(), reload(), rtp_reload(), and socket_process_helper().
int ast_sockaddr_split_hostport | ( | char * | str, |
char ** | host, | ||
char ** | port, | ||
int | flags | ||
) |
Splits a string into its host and port components.
[in] | str | The string to parse. May be modified by writing a NUL at the end of the host part. |
[out] | host | Pointer to the host component within str. |
[out] | port | Pointer to the port component within str. |
flags | If 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. |
1 | Success |
0 | Failure |
Definition at line 164 of file netsock2.c.
References ast_debug, ast_log, LOG_WARNING, NULL, PARSE_PORT_FORBID, PARSE_PORT_IGNORE, PARSE_PORT_MASK, PARSE_PORT_REQUIRE, and str.
Referenced by ast_ari_channels_external_media(), ast_sockaddr_parse(), ast_sockaddr_resolve(), peer_set_srcaddr(), rtcp_do_debug_ip(), rtp_do_debug_ip(), rtp_reload(), setup_stunaddr(), and unicast_rtp_request().
|
inlinestatic |
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Definition at line 256 of file netsock2.h.
References AST_SOCKADDR_STR_DEFAULT, and ast_sockaddr_stringify_fmt().
Referenced by __find_callno(), __rtp_recvfrom(), append_ha_core(), apply_acl(), apply_contact_acl(), ast_apply_ha(), ast_ari_callback(), ast_ari_websocket_session_write(), ast_audiosocket_connect(), ast_ha_join(), ast_netsock_bindaddr(), ast_parse_arg(), ast_rtcp_calculate_sr_rr_statistics(), ast_rtcp_interpret(), ast_rtcp_read(), ast_rtcp_write(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_interpret(), ast_rtp_prop_set(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_rtp_sendcng(), ast_sockaddr_pj_sockaddr_cmp(), ast_tcptls_client_create(), ast_tcptls_client_start_timeout(), ast_tcptls_server_root(), ast_tcptls_server_start(), AST_TEST_DEFINE(), ast_udptl_read(), ast_udptl_write(), ast_websocket_close(), ast_websocket_uri_cb(), bridge_p2p_rtp_write(), channel_read_rtp(), cli_print_body(), create_dtmf_frame(), debug_ha_sense_appended(), dnsmgr_refresh(), dump_addr(), dump_ipaddr(), dundi_rexmit(), dundi_showframe(), dundi_xmit(), find_tpeer(), handle_audiosocket_connection(), handle_call_token(), handle_cli_iax2_show_callno_limits(), handle_cli_iax2_show_registry(), handle_cli_udptl_set_debug(), handle_command_response(), handle_connection(), handle_manager_show_settings(), handle_show_http(), handle_tcptls_connection(), http_server_get_by_addr(), httpstatus_callback(), iax2_ack_registry(), iax2_devicestate(), iax2_prov_app(), iax2_trunk_queue(), iax_showframe(), ip_identify_match_check(), ip_identify_match_host_lookup(), launch_netscript(), load_module(), manager_iax2_show_registry(), match_to_var_list_append(), pjsip_enable_logger_host(), process_cn_rfc3389(), process_dtmf_rfc2833(), raw_hangup(), reg_source_db(), registry_rerequest(), rtcp_do_debug_ip(), rtp_allocate_transport(), rtp_do_debug_ip(), rtp_raw_write(), rtp_transport_wide_cc_feedback_produce(), send_packet(), session_destroy_fn(), set_config(), set_peercnt_limit(), sockaddr_handler_fn(), socket_process_helper(), socket_process_meta(), stasis_app_message_handler(), stun_monitor_request(), timing_read(), transport_create(), transport_read(), and update_registry().
|
inlinestatic |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition at line 286 of file netsock2.h.
References AST_SOCKADDR_STR_ADDR, and ast_sockaddr_stringify_fmt().
Referenced by __attempt_transmit(), __init_manager(), _iax2_show_peers_one(), acf_channel_read(), action_login(), ast_apply_acl_internal(), ast_ha_join(), ast_ha_join_cidr(), ast_ha_output(), ast_json_ipaddr(), ast_manager_hangup_helper(), ast_ouraddrfor(), auth_http_callback(), authenticate(), build_user(), calltoken_required(), check_access(), cli_print_body(), configure_local_rtp(), do_message(), function_iaxpeer(), generic_http_callback(), get_input(), handle_cli_iax2_show_channels(), handle_cli_iax2_show_peer(), handle_command_response(), handle_showmanconn(), hep_queue_cb(), localnet_to_vl_append(), match_to_var_list_append(), ooh323_get_rtp_peer(), ooh323_set_rtp_peer(), peercnt_add(), peercnt_modify(), peercnt_remove(), pjsip_enable_logger_host(), publish_cluster_discovery_to_stasis_full(), purge_sessions(), realtime_peer(), realtime_update_peer(), realtime_user(), register_verify(), sched_delay_remove(), session_do(), transport_create(), transport_read(), unicast_rtp_request(), and update_registry().
|
inlinestatic |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition at line 313 of file netsock2.h.
References AST_SOCKADDR_STR_ADDR_REMOTE, and ast_sockaddr_stringify_fmt().
Referenced by add_ice_to_stream(), change_outgoing_sdp_stream_media_address(), media_address_handler(), and session_outgoing_nat_hook().
char * ast_sockaddr_stringify_fmt | ( | const struct ast_sockaddr * | addr, |
int | format | ||
) |
Convert a socket address to a string.
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.
addr | The input to be stringified |
format | one 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 |
(null) | addr is null |
"" | An error occurred during processing |
Definition at line 65 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, NULL, 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(), ast_sockaddr_stringify_remote(), create_outgoing_sdp_stream(), and statsd_init().
|
inlinestatic |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brackets for IPv6).
Definition at line 327 of file netsock2.h.
References AST_SOCKADDR_STR_HOST, and ast_sockaddr_stringify_fmt().
Referenced by ast_sip_rewrite_uri_to_local(), build_peer(), dundi_show_peer(), dundi_show_trans(), dundi_sockaddr_stringify_host(), get_ipaddress(), jingle_add_google_candidates_to_transport(), jingle_add_ice_udp_candidates_to_transport(), process_nat(), rtp_reload(), and setup_udptl_connection().
|
inlinestatic |
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brackets for IPv6).
Definition at line 345 of file netsock2.h.
References AST_SOCKADDR_STR_HOST_REMOTE, and ast_sockaddr_stringify_fmt().
|
inlinestatic |
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
Definition at line 358 of file netsock2.h.
References AST_SOCKADDR_STR_PORT, and ast_sockaddr_stringify_fmt().
Referenced by _iax2_show_peers_one(), add_ice_to_stream(), ast_json_ipaddr(), handle_cli_iax2_set_debug(), handle_cli_iax2_show_peer(), jingle_add_google_candidates_to_transport(), jingle_add_ice_udp_candidates_to_transport(), realtime_peer(), realtime_update_peer(), realtime_user(), and unicast_rtp_request().
|
inlinestatic |
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Definition at line 273 of file netsock2.h.
References AST_SOCKADDR_STR_DEFAULT_REMOTE, and ast_sockaddr_stringify_fmt().
const char * ast_transport2str | ( | enum ast_transport | transport | ) |
Returns a string representation of an ast_transport.
Definition at line 566 of file netsock2.c.
References AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, AST_TRANSPORT_WS, and AST_TRANSPORT_WSS.