Asterisk - The Open Source Telephony Project
18.5.0
|
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_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... | |
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... | |
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) |
Pulls first resolved address and returns it. 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... | |
const char * | ast_transport2str (enum ast_transport transport) |
Returns a string representation of an ast_transport. More... | |
Variables | |
static struct ast_threadstorage | ast_sockaddr_stringify_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_ast_sockaddr_stringify_buf , .custom_init = NULL , } |
Network socket handling.
Definition in file netsock2.c.
|
static |
Definition at line 63 of file netsock2.c.
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, 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, 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, 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, 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(), reload_config(), 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(), ast_tcptls_client_start(), launch_netscript(), 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 ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by __rtp_recvfrom(), ast_udptl_read(), sipsock_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 ast_sockaddr::len, and ast_sockaddr::ss.
Referenced by __rtp_sendto(), __sip_xmit(), ast_rtp_on_turn_rx_rtcp_data(), ast_rtp_on_turn_rx_rtp_data(), 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(), sip_send_keepalive(), 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, errno, and LOG_WARNING.
Referenced by ast_netsock_bindaddr(), ast_netsock_set_qos(), ast_rtp_qos_set(), ast_udptl_setqos(), config_load(), load_module(), reload_config(), and sip_prepare_socket().
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(), ast_sockaddr::len, ast_sockaddr::ss, and V6_WORD.
Referenced by addr_range_match_address_cb(), append_ha_core(), ast_apply_ha(), ast_sockaddr_stringify_port(), 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(), ast_sockaddr_stringify_addr(), 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_sd_notify(), ast_sockaddr_copy(), 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(), ice_candidate_cmp(), match(), parse_register_contact(), realtime_peer_by_name(), registry_rerequest(), reload_config(), rtcp_debug_test_addr(), rtp_add_candidates_to_ice(), rtp_debug_test_addr(), should_drop_packets(), sip_debug_test_addr(), sip_uri_domain_cmp(), socket_process_helper(), threadinfo_locate_cb(), transmit_register(), 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 add_sdp(), addr_range_cmp_cb(), addr_range_match_address_cb(), ast_apply_ha(), ast_sockaddr_copy(), AST_TEST_DEFINE(), authenticate_reply(), check_for_nat(), get_our_media_address(), iax_outputframe(), peer_ipcmp_cb_full(), peercnt_cmp_cb(), realtime_peer(), realtime_user(), reload_config(), rtcp_debug_test_addr(), rtp_add_candidates_to_ice(), rtp_debug_test_addr(), should_drop_packets(), sip_debug_test_addr(), socket_read(), and udptl_debug_test_addr().
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(), peer_iphash_cb(), peercnt_hash_cb(), and threadt_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(), 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_sip_ouraddrfor(), ast_tcptls_client_create(), get_address_family_filter(), get_our_media_address(), negotiate_incoming_sdp_stream(), reload_config(), rtp_add_candidates_to_ice(), sip_show_settings(), and sockaddr_is_null_or_any().
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_ice_turn_request(), 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(), rtp_add_candidates_to_ice(), 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 add_sdp(), ast_apply_ha(), ast_json_ipaddr(), ast_sip_ouraddrfor(), 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().
Referenced by process_via().
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 add_sdp(), ast_apply_ha(), ast_netsock_bindaddr(), ast_ouraddrfor(), ast_rtp_prop_set(), ast_set_qos(), ast_sip_ouraddrfor(), 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(), get_address_family_filter(), hepv3_data_alloc(), load_module(), multicast_send_control_packet(), negotiate_incoming_sdp_stream(), reload_config(), rtp_allocate_transport(), set_host_ipaddr(), and sip_show_settings().
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().
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, host, ast_sockaddr::len, LOG_ERROR, LOG_WARNING, NULL, S_OR, and ast_sockaddr::ss.
Referenced by __init_manager(), append_ha_core(), apply_acl(), apply_endpoint_acl(), ast_netsock_bind(), ast_parse_arg(), ast_rtp_ice_add_cand(), ast_rtp_ice_turn_request(), ast_sip_get_transport_name(), ast_sockaddr_stringify_port(), 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(), handle_cli_rtp_drop_incoming_packets(), 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(), multicast_rtp_request(), peer_set_srcaddr(), pjsip_enable_logger_host(), pjsip_log_test_addr(), process_ice_attributes(), process_nat(), process_sdp_a_ice(), proxy_update(), realtime_peer(), reg_source_db(), reload_config(), rtcp_do_debug_ip(), rtcp_message_handler(), rtp_do_debug_ip(), security_event_populate(), session_outgoing_nat_hook(), set_config(), sip_sanitized_host(), sip_uri_domain_cmp(), test_init_rtp_instances(), unicast_rtp_request(), and update_address_with_ice_candidate().
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(), host, LOG_ERROR, NULL, and S_OR.
Referenced by __ast_http_load(), app_exec(), apply_negotiated_sdp_stream(), ast_audiosocket_connect(), ast_sockaddr_resolve_first_af(), ast_sockaddr_stringify_port(), build_peer(), extract_contact_addr(), get_ipaddress(), handle_cli_udptl_set_debug(), ip_identify_match_host_lookup(), launch_netscript(), negotiate_incoming_sdp_stream(), populate_addr(), realtime_peer(), realtime_peer_by_name(), 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 | ||
) |
Pulls first resolved address and returns it.
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(), and ast_sockaddr_resolve().
Referenced by ast_sip_ouraddrfor(), ast_sockaddr_resolve_first(), ast_sockaddr_resolve_first_transport(), ast_sockaddr_stringify_port(), audiosocket_request(), hepv3_data_alloc(), pjsip_enable_logger_host(), process_sdp_c(), reload_config(), and sip_do_debug_ip().
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(), ast_sockaddr_stringify_port(), extract_host_from_hostport(), peer_set_srcaddr(), rtcp_do_debug_ip(), rtp_do_debug_ip(), setup_stunaddr(), sip_parse_host(), and unicast_rtp_request().
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 |
string | The stringified form of the address |
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(), host, 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().
const char* ast_transport2str | ( | enum ast_transport | transport | ) |
Returns a string representation of an ast_transport.
Name | of the tranpsort if it is defined |
Undefined | if the transport is undefined |
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.
Referenced by sip_show_channel().
|
static |
Definition at line 63 of file netsock2.c.
Referenced by ast_sockaddr_stringify_fmt().