RTS API Documentation
1.10.11
|
Modules | |
IP Protocol Definitions for use when creating sockets | |
Macros | |
#define | SWITCH_SO_LINGER 1 |
#define | SWITCH_SO_KEEPALIVE 2 |
#define | SWITCH_SO_DEBUG 4 |
#define | SWITCH_SO_NONBLOCK 8 |
#define | SWITCH_SO_REUSEADDR 16 |
#define | SWITCH_SO_SNDBUF 64 |
#define | SWITCH_SO_RCVBUF 128 |
#define | SWITCH_SO_DISCONNECTED 256 |
#define | SWITCH_SO_TCP_NODELAY 512 |
#define | SWITCH_SO_TCP_KEEPIDLE 520 |
#define | SWITCH_SO_TCP_KEEPINTVL 530 |
#define | SWITCH_SO_IPV6_V6ONLY 16384 /* Don't accept IPv4 connections on an IPv6 listening socket. */ |
#define | SWITCH_INET AF_INET |
#define | SWITCH_INET6 0 |
#define | SWITCH_UNSPEC 0 |
Typedefs | |
typedef struct fspr_socket_t | switch_socket_t |
typedef struct fspr_sockaddr_t | switch_sockaddr_t |
Enumerations | |
enum | switch_shutdown_how_e { SWITCH_SHUTDOWN_READ, SWITCH_SHUTDOWN_WRITE, SWITCH_SHUTDOWN_READWRITE } |
#define SWITCH_INET AF_INET |
Not all platforms have these defined, so we'll define them here The default values come from FreeBSD 4.1.1
Definition at line 1009 of file switch_apr.h.
#define SWITCH_INET6 0 |
Definition at line 1013 of file switch_apr.h.
#define SWITCH_SO_DEBUG 4 |
Definition at line 993 of file switch_apr.h.
#define SWITCH_SO_DISCONNECTED 256 |
Definition at line 998 of file switch_apr.h.
#define SWITCH_SO_IPV6_V6ONLY 16384 /* Don't accept IPv4 connections on an IPv6 listening socket. */ |
Definition at line 1002 of file switch_apr.h.
Referenced by msock_init().
#define SWITCH_SO_KEEPALIVE 2 |
Definition at line 992 of file switch_apr.h.
Referenced by msrp_worker().
#define SWITCH_SO_LINGER 1 |
Definition at line 991 of file switch_apr.h.
#define SWITCH_SO_NONBLOCK 8 |
Definition at line 994 of file switch_apr.h.
Referenced by do_flush(), init_nat_monitor(), switch_rtp_clear_flag(), switch_rtp_set_flag(), switch_rtp_set_local_address(), switch_rtp_udptl_mode(), and switch_stun_lookup().
#define SWITCH_SO_RCVBUF 128 |
Definition at line 997 of file switch_apr.h.
Referenced by switch_rtp_set_local_address().
#define SWITCH_SO_REUSEADDR 16 |
Definition at line 995 of file switch_apr.h.
Referenced by enable_local_rtcp_socket(), init_nat_monitor(), msock_init(), and switch_rtp_set_local_address().
#define SWITCH_SO_SNDBUF 64 |
Definition at line 996 of file switch_apr.h.
Referenced by switch_rtp_set_local_address().
#define SWITCH_SO_TCP_KEEPIDLE 520 |
Definition at line 1000 of file switch_apr.h.
Referenced by msrp_worker(), and switch_socket_opt_set().
#define SWITCH_SO_TCP_KEEPINTVL 530 |
Definition at line 1001 of file switch_apr.h.
Referenced by msrp_worker(), and switch_socket_opt_set().
#define SWITCH_SO_TCP_NODELAY 512 |
Definition at line 999 of file switch_apr.h.
Referenced by msrp_listener(), and msrp_worker().
#define SWITCH_UNSPEC 0 |
Let the system decide which address family to use
Definition at line 1022 of file switch_apr.h.
Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), handle_ice(), init_nat_monitor(), msock_init(), msrp_worker(), switch_ivr_activate_unicast(), switch_rtp_activate_ice(), switch_rtp_activate_rtcp(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), switch_stun_host_lookup(), and switch_stun_lookup().
typedef struct fspr_sockaddr_t switch_sockaddr_t |
Freeswitch's socket address type, used to ensure protocol independence
Definition at line 1029 of file switch_apr.h.
typedef struct fspr_socket_t switch_socket_t |
A structure to represent sockets
Definition at line 1026 of file switch_apr.h.
Enumerator | |
---|---|
SWITCH_SHUTDOWN_READ | no longer allow read request |
SWITCH_SHUTDOWN_WRITE | no longer allow write requests |
SWITCH_SHUTDOWN_READWRITE | no longer allow read or write requests |
Definition at line 1031 of file switch_apr.h.
const char* switch_get_addr | ( | char * | buf, |
switch_size_t | len, | ||
switch_sockaddr_t * | in | ||
) |
Definition at line 979 of file switch_apr.c.
References buf, get_addr(), get_addr6(), memset(), and SWITCH_BLANK_STRING.
Referenced by check_rtcp_and_ice(), do_dtls(), enable_local_rtcp_socket(), enable_remote_rtcp_socket(), handle_ice(), handle_nack(), msrp_listener(), read_bundle_rtp_packet(), read_rtcp_packet(), read_rtp_packet(), rtp_common_read(), rtp_common_write(), switch_print_host(), switch_rtp_activate_ice(), switch_rtp_write_frame(), and switch_stun_host_lookup().
switch_status_t switch_getnameinfo | ( | char ** | hostname, |
switch_sockaddr_t * | sa, | ||
int32_t | flags | ||
) |
Definition at line 1011 of file switch_apr.c.
switch_status_t switch_mcast_hops | ( | switch_socket_t * | sock, |
uint8_t | ttl | ||
) |
Set the Multicast Time to Live (ttl) for a multicast transmission.
sock | The socket to set the multicast ttl |
ttl | Time to live to Assign. 0-255, default=1 |
Definition at line 961 of file switch_apr.c.
Referenced by switch_rtp_set_local_address().
switch_status_t switch_mcast_interface | ( | switch_socket_t * | sock, |
switch_sockaddr_t * | iface | ||
) |
Definition at line 971 of file switch_apr.c.
Referenced by switch_rtp_set_local_address().
switch_status_t switch_mcast_join | ( | switch_socket_t * | sock, |
switch_sockaddr_t * | join, | ||
switch_sockaddr_t * | iface, | ||
switch_sockaddr_t * | source | ||
) |
Join a Multicast Group
sock | The socket to join a multicast group |
join | The address of the multicast group to join |
iface | Address of the interface to use. If NULL is passed, the default multicast interface will be used. (OS Dependent) |
source | Source Address to accept transmissions from (non-NULL implies Source-Specific Multicast) |
Definition at line 956 of file switch_apr.c.
Referenced by init_nat_monitor(), and switch_rtp_set_local_address().
switch_status_t switch_mcast_loopback | ( | switch_socket_t * | sock, |
uint8_t | opt | ||
) |
Definition at line 966 of file switch_apr.c.
switch_status_t switch_sockaddr_create | ( | switch_sockaddr_t ** | sa, |
switch_memory_pool_t * | pool | ||
) |
Definition at line 818 of file switch_apr.c.
References pool, switch_assert, and SWITCH_STATUS_SUCCESS.
Referenced by switch_rtp_create().
int switch_sockaddr_equal | ( | const switch_sockaddr_t * | sa1, |
const switch_sockaddr_t * | sa2 | ||
) |
Definition at line 951 of file switch_apr.c.
int32_t switch_sockaddr_get_family | ( | switch_sockaddr_t * | sa | ) |
Definition at line 1006 of file switch_apr.c.
Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), msock_init(), msrp_worker(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), and test_port().
uint16_t switch_sockaddr_get_port | ( | switch_sockaddr_t * | sa | ) |
Definition at line 1001 of file switch_apr.c.
Referenced by check_rtcp_and_ice(), enable_local_rtcp_socket(), handle_ice(), handle_nack(), msrp_listener(), read_bundle_rtp_packet(), read_rtcp_packet(), read_rtp_packet(), rtp_common_read(), rtp_common_write(), switch_print_host(), switch_rtp_activate_ice(), and switch_rtp_write_frame().
switch_status_t switch_sockaddr_info_get | ( | switch_sockaddr_t ** | sa, |
const char * | hostname, | ||
int32_t | family, | ||
switch_port_t | port, | ||
int32_t | flags, | ||
switch_memory_pool_t * | pool | ||
) |
Create fspr_sockaddr_t from hostname, address family, and port.
sa | The new fspr_sockaddr_t. |
hostname | The hostname or numeric address string to resolve/parse, or NULL to build an address that corresponds to 0.0.0.0 or :: |
family | The address family to use, or SWITCH_UNSPEC if the system should decide. |
port | The port number. |
flags | Special processing flags: APR_IPV4_ADDR_OK first query for IPv4 addresses; only look for IPv6 addresses if the first query failed; only valid if family is APR_UNSPEC and hostname isn't NULL; mutually exclusive with APR_IPV6_ADDR_OK APR_IPV6_ADDR_OK first query for IPv6 addresses; only look for IPv4 addresses if the first query failed; only valid if family is APR_UNSPEC and hostname isn't NULL and APR_HAVE_IPV6; mutually exclusive with APR_IPV4_ADDR_OK |
pool | The pool for the fspr_sockaddr_t and associated storage. |
Definition at line 839 of file switch_apr.c.
Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), handle_ice(), init_nat_monitor(), msock_init(), msrp_worker(), switch_ivr_activate_unicast(), switch_rtp_activate_ice(), switch_rtp_activate_rtcp(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), switch_stun_host_lookup(), and switch_stun_lookup().
switch_status_t switch_sockaddr_ip_get | ( | char ** | addr, |
switch_sockaddr_t * | sa | ||
) |
Definition at line 946 of file switch_apr.c.
switch_status_t switch_sockaddr_new | ( | switch_sockaddr_t ** | sa, |
const char * | ip, | ||
switch_port_t | port, | ||
switch_memory_pool_t * | pool | ||
) |
Definition at line 845 of file switch_apr.c.
References pool, switch_assert, switch_goto_status, SWITCH_STATUS_GENERR, and SWITCH_STATUS_SUCCESS.
Referenced by test_port().
switch_status_t switch_socket_accept | ( | switch_socket_t ** | new_sock, |
switch_socket_t * | sock, | ||
switch_memory_pool_t * | pool | ||
) |
Accept a new connection request
new_sock | A copy of the socket that is connected to the socket that made the connection request. This is the socket which should be used for all future communication. |
sock | The socket we are listening on. |
pool | The pool for the new socket. |
Definition at line 752 of file switch_apr.c.
Referenced by msrp_listener().
switch_status_t switch_socket_atmark | ( | switch_socket_t * | sock, |
int * | atmark | ||
) |
Definition at line 1016 of file switch_apr.c.
switch_status_t switch_socket_bind | ( | switch_socket_t * | sock, |
switch_sockaddr_t * | sa | ||
) |
Bind the socket to its associated port
sock | The socket to bind |
sa | The socket address to bind to |
Definition at line 742 of file switch_apr.c.
Referenced by enable_local_rtcp_socket(), init_nat_monitor(), msock_init(), switch_ivr_activate_unicast(), switch_rtp_set_local_address(), switch_stun_lookup(), and test_port().
switch_status_t switch_socket_close | ( | switch_socket_t * | sock | ) |
Close a socket.
sock | The socket to close |
Definition at line 737 of file switch_apr.c.
Referenced by close_socket(), enable_local_rtcp_socket(), enable_remote_rtcp_socket(), init_nat_monitor(), switch_ivr_deactivate_unicast(), switch_rtp_destroy(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), switch_rtp_udptl_mode(), switch_stun_lookup(), and test_port().
switch_status_t switch_socket_connect | ( | switch_socket_t * | sock, |
switch_sockaddr_t * | sa | ||
) |
Issue a connection request to a socket either on the same machine or a different one.
sock | The socket we wish to use for our side of the connection |
sa | The address of the machine we wish to connect to. |
Definition at line 757 of file switch_apr.c.
Referenced by msrp_worker().
switch_status_t switch_socket_create | ( | switch_socket_t ** | new_sock, |
int | family, | ||
int | type, | ||
int | protocol, | ||
switch_memory_pool_t * | pool | ||
) |
Create a socket.
new_sock | The new socket that has been set up. |
family | The address family of the socket (e.g., SWITCH_INET). |
type | The type of the socket (e.g., SOCK_STREAM). |
protocol | The protocol of the socket (e.g., SWITCH_PROTO_TCP). |
pool | The pool to use |
Definition at line 727 of file switch_apr.c.
Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), init_nat_monitor(), msock_init(), msrp_worker(), switch_ivr_activate_unicast(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), switch_stun_lookup(), and test_port().
int switch_socket_fd_get | ( | switch_socket_t * | sock | ) |
Get socket fd for the switch socket passed
sock | The socket we wish to have fd |
Definition at line 996 of file switch_apr.c.
switch_status_t switch_socket_listen | ( | switch_socket_t * | sock, |
int32_t | backlog | ||
) |
Listen to a bound socket for connections.
sock | The socket to listen on |
backlog | The number of outstanding connections allowed in the sockets listen queue. If this value is less than zero, the listen queue size is set to zero. |
Definition at line 747 of file switch_apr.c.
Referenced by msock_init().
switch_status_t switch_socket_opt_set | ( | switch_socket_t * | sock, |
int32_t | opt, | ||
int32_t | on | ||
) |
Setup socket options for the specified socket
sock | The socket to set up. |
opt | The option we would like to configure. One of: APR_SO_DEBUG -- turn on debugging information APR_SO_KEEPALIVE -- keep connections active APR_SO_LINGER -- lingers on close if data is present APR_SO_NONBLOCK -- Turns blocking on/off for socket When this option is enabled, use the APR_STATUS_IS_EAGAIN() macro to see if a send or receive function could not transfer data without blocking. APR_SO_REUSEADDR -- The rules used in validating addresses supplied to bind should allow reuse of local addresses. APR_SO_SNDBUF -- Set the SendBufferSize APR_SO_RCVBUF -- Set the ReceiveBufferSize |
on | Value for the option. |
Definition at line 907 of file switch_apr.c.
References SWITCH_SO_TCP_KEEPIDLE, SWITCH_SO_TCP_KEEPINTVL, SWITCH_STATUS_FALSE, SWITCH_STATUS_NOTIMPL, and SWITCH_STATUS_SUCCESS.
Referenced by do_flush(), enable_local_rtcp_socket(), init_nat_monitor(), msock_init(), msrp_listener(), msrp_worker(), switch_rtp_clear_flag(), switch_rtp_set_flag(), switch_rtp_set_local_address(), switch_rtp_udptl_mode(), and switch_stun_lookup().
switch_status_t switch_socket_recv | ( | switch_socket_t * | sock, |
char * | buf, | ||
switch_size_t * | len | ||
) |
Read data from a network.
sock | The socket to read the data from. |
buf | The buffer to store the data in. |
len | On entry, the number of bytes to receive; on exit, the number of bytes received. |
This functions acts like a blocking read by default. To change this behavior, use fspr_socket_timeout_set() or the APR_SO_NONBLOCK socket option. The number of bytes actually received is stored in argument 3.
It is possible for both bytes to be received and an APR_EOF or other error to be returned.
APR_EINTR is never returned.
Definition at line 805 of file switch_apr.c.
References SWITCH_STATUS_BREAK.
Referenced by msrp_socket_recv(), and unicast_thread_run().
switch_status_t switch_socket_recvfrom | ( | switch_sockaddr_t * | from, |
switch_socket_t * | sock, | ||
int32_t | flags, | ||
char * | buf, | ||
size_t * | len | ||
) |
from | The fspr_sockaddr_t to fill in the recipient info |
sock | The socket to use |
flags | The flags to use |
buf | The buffer to use |
len | The length of the available buffer |
Definition at line 1021 of file switch_apr.c.
References SWITCH_STATUS_BREAK, and SWITCH_STATUS_GENERR.
Referenced by do_flush(), read_rtcp_packet(), read_rtp_packet(), switch_nat_multicast_runtime(), switch_rtp_set_local_address(), and switch_stun_lookup().
switch_status_t switch_socket_send | ( | switch_socket_t * | sock, |
const char * | buf, | ||
switch_size_t * | len | ||
) |
Send data over a network.
sock | The socket to send the data over. |
buf | The buffer which contains the data to be sent. |
len | On entry, the number of bytes to send; on exit, the number of bytes sent. |
This functions acts like a blocking write by default. To change this behavior, use fspr_socket_timeout_set() or the APR_SO_NONBLOCK socket option.
It is possible for both bytes to be sent and an error to be returned.
APR_EINTR is never returned.
Definition at line 762 of file switch_apr.c.
References SWITCH_STATUS_BREAK, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_yield.
Referenced by msrp_socket_send().
switch_status_t switch_socket_send_nonblock | ( | switch_socket_t * | sock, |
const char * | buf, | ||
switch_size_t * | len | ||
) |
Definition at line 787 of file switch_apr.c.
References SWITCH_STATUS_GENERR.
switch_status_t switch_socket_sendto | ( | switch_socket_t * | sock, |
switch_sockaddr_t * | where, | ||
int32_t | flags, | ||
const char * | buf, | ||
switch_size_t * | len | ||
) |
sock | The socket to send from |
where | The fspr_sockaddr_t describing where to send the data |
flags | The flags to use |
buf | The data to send |
len | The length of the data to send |
Definition at line 796 of file switch_apr.c.
References SWITCH_STATUS_GENERR.
Referenced by check_rtcp_and_ice(), do_dtls(), handle_ice(), ice_out(), ping_socket(), rtp_common_read(), rtp_common_write(), switch_ivr_park(), switch_rtp_set_local_address(), switch_rtp_write_frame(), switch_rtp_write_raw(), and switch_stun_lookup().
switch_status_t switch_socket_shutdown | ( | switch_socket_t * | sock, |
switch_shutdown_how_e | how | ||
) |
Shutdown either reading, writing, or both sides of a socket.
sock | The socket to close |
how | How to shutdown the socket. One of: SWITCH_SHUTDOWN_READ no longer allow read requests SWITCH_SHUTDOWN_WRITE no longer allow write requests SWITCH_SHUTDOWN_READWRITE no longer allow read or write requests |
Definition at line 732 of file switch_apr.c.
Referenced by close_socket(), switch_ivr_deactivate_unicast(), switch_rtp_kill_socket(), switch_rtp_udptl_mode(), and switch_stun_lookup().
switch_status_t switch_socket_timeout_get | ( | switch_socket_t * | sock, |
switch_interval_time_t * | t | ||
) |
Query socket timeout for the specified socket
sock | The socket to query |
t | Socket timeout returned from the query. t > 0 – read and write calls return APR_TIMEUP if specified time elapsess with no data read or written t == 0 – read and write calls never block t < 0 – read and write calls block |
Definition at line 932 of file switch_apr.c.
switch_status_t switch_socket_timeout_set | ( | switch_socket_t * | sock, |
switch_interval_time_t | t | ||
) |
Setup socket timeout for the specified socket
sock | The socket to set up. |
t | Value for the timeout. t > 0 – read and write calls return APR_TIMEUP if specified time elapsess with no data read or written t == 0 – read and write calls never block t < 0 – read and write calls block |
Definition at line 941 of file switch_apr.c.
Referenced by msrp_worker().