Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
chan_iax2.c File Reference

Implementation of Inter-Asterisk eXchange Version 2 as specified in RFC 5456. More...

#include "asterisk.h"
#include <sys/mman.h>
#include <dirent.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/time.h>
#include <signal.h>
#include <netdb.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <regex.h>
#include "asterisk/paths.h"
#include "asterisk/lock.h"
#include "asterisk/frame.h"
#include "asterisk/channel.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/translate.h"
#include "asterisk/md5.h"
#include "asterisk/crypto.h"
#include "asterisk/acl.h"
#include "asterisk/manager.h"
#include "asterisk/callerid.h"
#include "asterisk/app.h"
#include "asterisk/mwi.h"
#include "asterisk/astdb.h"
#include "asterisk/musiconhold.h"
#include "asterisk/features.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/localtime.h"
#include "asterisk/dnsmgr.h"
#include "asterisk/devicestate.h"
#include "asterisk/stringfields.h"
#include "asterisk/linkedlists.h"
#include "asterisk/astobj2.h"
#include "asterisk/timing.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/test.h"
#include "asterisk/security_events.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/bridge.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_system.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/format_cache.h"
#include "asterisk/format_compatibility.h"
#include "asterisk/format_cap.h"
#include "iax2/include/iax2.h"
#include "iax2/include/firmware.h"
#include "iax2/include/parser.h"
#include "iax2/include/provision.h"
#include "iax2/include/codec_pref.h"
#include "iax2/include/format_compatibility.h"
#include "iax2/include/netsock.h"
#include "jitterbuf.h"

Go to the source code of this file.

Data Structures

struct  active_list
 
struct  addr_range
 
struct  call_number_pool
 
struct  chan_iax2_pvt
 
struct  create_addr_info
 
struct  dpcache
 
struct  dpreq_data
 
struct  dynamic_list
 
struct  iax2_context
 
struct  iax2_dpcache
 
struct  iax2_peer
 
struct  iax2_pkt_buf
 
struct  iax2_registry
 
struct  iax2_thread
 
struct  iax2_trunk_peer
 
struct  iax2_user
 
struct  iax_rr
 
struct  idle_list
 
struct  parsed_dial_string
 
struct  peercnt
 
struct  registrations
 
struct  show_peers_context
 
struct  chan_iax2_pvt::signaling_queue
 
struct  signaling_queue_entry
 
struct  tpeers
 

Macros

#define ACN_FORMAT1   "%-24.25s %4u %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d %s%s %4s%s\n"
 
#define ACN_FORMAT2   "%s %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %s%s %s%s\n"
 
#define AUTH_METHOD_NAMES_BUFSIZE   19
 
#define CALLNO_ENTRY_GET_CALLNO(a)   ((a) & 0x7FFF)
 
#define CALLNO_ENTRY_IS_VALIDATED(a)   ((a) & 0x8000)
 
#define CALLNO_ENTRY_SET_VALIDATED(a)   ((a) |= 0x8000)
 
#define CALLNO_ENTRY_TO_PTR(a)   ((void *)(unsigned long)(a))
 
#define CALLNO_TO_PTR(a)   ((void *)(unsigned long)(a))
 
#define CALLTOKEN_HASH_FORMAT   "%s%u%d" /* address + port + ts + randomcalldata */
 
#define CALLTOKEN_IE_FORMAT   "%u?%s" /* time + ? + (40 char hash) */
 
#define DEBUG_SCHED_MULTITHREAD
 
#define DEBUG_SUPPORT
 
#define DEFAULT_CONTEXT   "default"
 
#define DEFAULT_DROP   3
 
#define DEFAULT_FREQ_NOTOK   10 * 1000 /* How often to check, if the host is down... */
 
#define DEFAULT_FREQ_OK   60 * 1000 /* How often to check for the host to be up */
 
#define DEFAULT_MAX_THREAD_COUNT   100
 
#define DEFAULT_MAXMS   2000 /* Must be faster than 2 seconds by default */
 
#define DEFAULT_RETRY_TIME   1000
 
#define DEFAULT_THREAD_COUNT   10
 
#define DEFAULT_TRUNKDATA   640 * 10
 
#define FORMAT   "%-15.15s %-20.20s %-15.15s %-15.15s %-5.5s %-5.10s\n"
 
#define FORMAT   "%-45.45s %-6.6s %-10.10s %-45.45s %8d %s\n"
 
#define FORMAT   "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d %-5.5dms %-4.4dms %-4.4dms %-6.6s %s%s %3s%s\n"
 
#define FORMAT2   "%-15.15s %-20.20s %-15.15d %-15.15s %-5.5s %-5.10s\n"
 
#define FORMAT2   "%-45.45s %-6.6s %-10.10s %-45.45s %8.8s %s\n"
 
#define FORMAT2   "%-20.20s %-40.40s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %-6.6s %s %s %9s\n"
 
#define FORMATB   "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d [Native Bridged to ID=%5.5d]\n"
 
#define GAMMA   (0.01)
 
#define IAX2_TRUNK_PREFACE   (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr))
 
#define IAX_ALLOWFWDOWNLOAD   (uint64_t)(1LLU << 26)
 
#define IAX_ALREADYGONE   (uint64_t)(1LLU << 9)
 
#define IAX_CALLENCRYPTED(pvt)    (ast_test_flag64(pvt, IAX_ENCRYPTED) && ast_test_flag64(pvt, IAX_KEYPOPULATED))
 
#define IAX_CAPABILITY_FULLBANDWIDTH   0xFFFF
 
#define IAX_CAPABILITY_LOWBANDWIDTH
 
#define IAX_CAPABILITY_LOWFREE
 
#define IAX_CAPABILITY_MEDBANDWIDTH
 
#define IAX_CODEC_NOCAP   (uint64_t)(1LLU << 16)
 
#define IAX_CODEC_NOPREFS   (uint64_t)(1LLU << 15)
 
#define IAX_CODEC_USER_FIRST   (uint64_t)(1LLU << 14)
 
#define IAX_DEBUGDIGEST(msg, key)
 
#define IAX_DELAYPBXSTART   (uint64_t)(1LLU << 25)
 
#define IAX_DELME   (uint64_t)(1LLU << 1)
 
#define IAX_DYNAMIC   (uint64_t)(1LLU << 6)
 
#define IAX_ENCRYPTED   (uint64_t)(1LLU << 12)
 
#define IAX_FORCE_ENCRYPT   (uint64_t)(1LLU << 30)
 
#define IAX_HASCALLERID   (uint64_t)(1LLU << 0)
 
#define IAX_IMMEDIATE   (uint64_t)(1LLU << 27)
 
#define IAX_KEYPOPULATED   (uint64_t)(1LLU << 13)
 
#define IAX_MAXAUTHREQ   (uint64_t)(1LLU << 24)
 
#define IAX_NOTRANSFER   (uint64_t)(1LLU << 4)
 
#define IAX_PROVISION   (uint64_t)(1LLU << 10)
 
#define IAX_QUELCH   (uint64_t)(1LLU << 11)
 
#define IAX_RECVCONNECTEDLINE   (uint64_t)(1LLU << 29)
 
#define IAX_RTAUTOCLEAR   (uint64_t)(1LLU << 19)
 
#define IAX_RTCACHEFRIENDS   (uint64_t)(1LLU << 17)
 
#define IAX_RTIGNOREREGEXPIRE   (uint64_t)(1LLU << 21)
 
#define IAX_RTSAVE_SYSNAME   (uint64_t)(1LLU << 8)
 
#define IAX_RTUPDATE   (uint64_t)(1LLU << 18)
 
#define IAX_SENDANI   (uint64_t)(1LLU << 7)
 
#define IAX_SENDCONNECTEDLINE   (uint64_t)(1LLU << 28)
 
#define IAX_SHRINKCALLERID   (uint64_t)(1LLU << 31)
 
#define IAX_TEMPONLY   (uint64_t)(1LLU << 2)
 
#define IAX_TRANSFERMEDIA   (uint64_t)(1LLU << 23)
 
#define IAX_TRUNK   (uint64_t)(1LLU << 3)
 
#define IAX_TRUNKTIMESTAMPS   (uint64_t)(1LLU << 22)
 
#define IAX_USEJITTERBUF   (uint64_t)(1LLU << 5)
 
#define MARK_IAX_SUBCLASS_TX   0x8000
 
#define MAX_JITTER_BUFFER   50
 
#define MAX_PEER_BUCKETS   563
 
#define MAX_RETRY_TIME   10000
 
#define MAX_TIMESTAMP_SKEW   160
 
#define MAX_TRUNK_MTU   1240
 Maximum transmission unit for the UDP packet in the trunk not to be fragmented. This is based on 1516 - ethernet - ip - udp - iax minus one g711 frame = 1240. More...
 
#define MAX_TRUNKDATA   640 * 200
 
#define MAX_USER_BUCKETS   MAX_PEER_BUCKETS
 
#define MEMORY_SIZE   100
 
#define MIN_JITTER_BUFFER   10
 
#define MIN_RETRY_TIME   100
 
#define MIN_REUSE_TIME   60 /* Don't reuse a call number within 60 seconds */
 
#define PEERS_FORMAT   "%-15.15s %-40.40s %s %-40.40s %-6s%s %s %-11s %-32.32s\n"
 
#define PEERS_FORMAT2   "%-15.15s %-40.40s %s %-40.40s %-9s %s %-11s %-32.32s\n"
 
#define PTR_TO_CALLNO(a)   ((unsigned short)(unsigned long)(a))
 
#define PTR_TO_CALLNO_ENTRY(a)   ((uint16_t)(unsigned long)(a))
 
#define SCHED_MULTITHREADED
 
#define schedule_action(func, data)   __schedule_action(func, data, __PRETTY_FUNCTION__)
 
#define TRUNK_CALL_START   (IAX_MAX_CALLS / 2)
 
#define TS_GAP_FOR_JB_RESYNC   5000
 

Typedefs

typedef uint16_t callno_entry
 

Enumerations

enum  {
  CACHE_FLAG_EXISTS = (1 << 0) , CACHE_FLAG_NONEXISTENT = (1 << 1) , CACHE_FLAG_CANEXIST = (1 << 2) , CACHE_FLAG_PENDING = (1 << 3) ,
  CACHE_FLAG_TIMEOUT = (1 << 4) , CACHE_FLAG_TRANSMITTED = (1 << 5) , CACHE_FLAG_UNKNOWN = (1 << 6) , CACHE_FLAG_MATCHMORE = (1 << 7)
}
 
enum  { NEW_PREVENT = 0 , NEW_ALLOW = 1 , NEW_FORCE = 2 , NEW_ALLOW_CALLTOKEN_VALIDATED = 3 }
 
enum  callno_type { CALLNO_TYPE_NORMAL , CALLNO_TYPE_TRUNK }
 
enum  calltoken_peer_enum { CALLTOKEN_DEFAULT = 0 , CALLTOKEN_YES = 1 , CALLTOKEN_AUTO = 2 , CALLTOKEN_NO = 3 }
 Call token validation settings. More...
 
enum  iax2_state { IAX_STATE_STARTED = (1 << 0) , IAX_STATE_AUTHENTICATED = (1 << 1) , IAX_STATE_TBD = (1 << 2) }
 
enum  iax2_thread_iostate { IAX_IOSTATE_IDLE , IAX_IOSTATE_READY , IAX_IOSTATE_PROCESSING , IAX_IOSTATE_SCHEDREADY }
 
enum  iax2_thread_type { IAX_THREAD_TYPE_POOL , IAX_THREAD_TYPE_DYNAMIC }
 
enum  iax_reg_state {
  REG_STATE_UNREGISTERED = 0 , REG_STATE_REGSENT , REG_STATE_AUTHSENT , REG_STATE_REGISTERED ,
  REG_STATE_REJECTED , REG_STATE_TIMEOUT , REG_STATE_NOAUTH
}
 
enum  iax_transfer_state {
  TRANSFER_NONE = 0 , TRANSFER_BEGIN , TRANSFER_READY , TRANSFER_RELEASED ,
  TRANSFER_PASSTHROUGH , TRANSFER_MBEGIN , TRANSFER_MREADY , TRANSFER_MRELEASED ,
  TRANSFER_MPASSTHROUGH , TRANSFER_MEDIA , TRANSFER_MEDIAPASS
}
 

Functions

static void __attempt_transmit (const void *data)
 
static void __auth_reject (const void *nothing)
 
static void __auto_congest (const void *nothing)
 
static void __auto_hangup (const void *nothing)
 
static int __do_deliver (void *data)
 
static void __expire_registry (const void *data)
 
static int __find_callno (unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int return_locked, int check_dcallno)
 
static void __get_from_jb (const void *p)
 
static void __iax2_do_register_s (const void *data)
 
static void __iax2_poke_noanswer (const void *data)
 
static void __iax2_poke_peer_s (const void *data)
 
static int __iax2_show_peers (int fd, int *total, struct mansession *s, const int argc, const char *const argv[])
 
static void __reg_module (void)
 
static int __schedule_action (void(*func)(const void *data), const void *data, const char *funcname)
 
static int __send_command (struct chan_iax2_pvt *i, char type, int command, unsigned int ts, const unsigned char *data, int datalen, int seqno, int now, int transfer, int final)
 
static void __send_lagrq (const void *data)
 
static void __send_ping (const void *data)
 
static int __unload_module (void)
 
static void __unreg_module (void)
 
static void _iax2_show_peers_one (int fd, struct mansession *s, struct show_peers_context *cont, struct iax2_peer *peer)
 
static int acf_channel_read (struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
 
static int acf_iaxvar_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int acf_iaxvar_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static void acl_change_stasis_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
 
static void acl_change_stasis_subscribe (void)
 
static void acl_change_stasis_unsubscribe (void)
 
static int add_calltoken_ignore (const char *addr)
 
static void add_empty_calltoken_ie (struct chan_iax2_pvt *pvt, struct iax_ie_data *ied)
 
static int addr_range_cmp_cb (void *obj, void *arg, int flags)
 
static int addr_range_delme_cb (void *obj, void *arg, int flags)
 
static int addr_range_hash_cb (const void *obj, const int flags)
 
static int addr_range_match_address_cb (void *obj, void *arg, int flags)
 
static int apply_context (struct iax2_context *con, const char *context)
 
static int ast_cli_netstats (struct mansession *s, int fd, int limit_fmt)
 
static struct ast_channelast_iax2_new (int callno, int state, iax2_format capability, struct iax2_codec_pref *prefs, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, unsigned int cachable)
 Create new call, interface with the PBX core. More...
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int attempt_transmit (const void *data)
 
static int auth_fail (int callno, int failcode)
 
static char * auth_method_names (int authmethods, char *restrict buf)
 Get names of all auth methods. More...
 
static int auth_reject (const void *data)
 
static int authenticate (const char *challenge, const char *secret, const char *keyn, int authmethods, struct iax_ie_data *ied, struct ast_sockaddr *addr, struct chan_iax2_pvt *pvt)
 
static int authenticate_reply (struct chan_iax2_pvt *p, struct ast_sockaddr *addr, struct iax_ies *ies, const char *override, const char *okey)
 
static int authenticate_request (int call_num)
 
static int authenticate_verify (struct chan_iax2_pvt *p, struct iax_ies *ies)
 
static int auto_congest (const void *data)
 
static int auto_hangup (const void *data)
 
static void build_callno_limits (struct ast_variable *v)
 
static struct iax2_contextbuild_context (const char *context)
 
static void build_ecx_key (const unsigned char *digest, struct chan_iax2_pvt *pvt)
 
static void build_encryption_keys (const unsigned char *digest, struct chan_iax2_pvt *pvt)
 
static struct iax2_peerbuild_peer (const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
 Create peer structure based on configuration. More...
 
static void build_rand_pad (unsigned char *buf, ssize_t len)
 
static struct iax2_userbuild_user (const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
 Create in-memory user structure from configuration. More...
 
static int cache_get_callno_locked (const char *data)
 
static unsigned int calc_rxstamp (struct chan_iax2_pvt *p, unsigned int offset)
 
static unsigned int calc_timestamp (struct chan_iax2_pvt *p, unsigned int ts, struct ast_frame *f)
 
static unsigned int calc_txpeerstamp (struct iax2_trunk_peer *tpeer, int sampms, struct timeval *now)
 
static int calltoken_required (struct ast_sockaddr *addr, const char *name, int subclass)
 
static int check_access (int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
 
static int check_provisioning (struct ast_sockaddr *addr, int sockfd, char *si, unsigned int ver)
 
static int check_srcaddr (struct ast_sockaddr *addr)
 Check if address can be used as packet source. More...
 
static void cleanup_thread_list (void *head)
 
static struct ast_formatcodec_choose_from_prefs (struct iax2_codec_pref *pref, struct ast_format_cap *cap)
 
static int complete_dpreply (struct chan_iax2_pvt *pvt, struct iax_ies *ies)
 
static char * complete_iax2_peers (const char *line, const char *word, int pos, int state, uint64_t flags)
 
static char * complete_iax2_unregister (const char *line, const char *word, int pos, int state)
 
static int complete_transfer (int callno, struct iax_ies *ies)
 
static unsigned char compress_subclass (iax2_format subclass)
 
static void construct_rr (struct chan_iax2_pvt *pvt, struct iax_ie_data *iep)
 
static int create_addr (const char *peername, struct ast_channel *c, struct ast_sockaddr *addr, struct create_addr_info *cai)
 
static int create_callno_pools (void)
 
static int decode_frame (ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
 
static int decrypt_frame (int callno, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen)
 
static void defer_full_frame (struct iax2_thread *from_here, struct iax2_thread *to_here)
 Queue the last read full frame for processing by a certain thread. More...
 
static void delete_users (void)
 
static void dp_lookup (int callno, const char *context, const char *callednum, const char *callerid, int skiplock)
 
static void * dp_lookup_thread (void *data)
 
static void encmethods_to_str (int e, struct ast_str **buf)
 
static int encrypt_frame (ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh, unsigned char *poo, int *datalen)
 
static int expire_registry (const void *data)
 
static struct iax2_dpcachefind_cache (struct ast_channel *chan, const char *data, const char *context, const char *exten, int priority)
 
static int find_callno (unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
 
static int find_callno_locked (unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int new, int sockfd, int full_frame)
 
static struct iax2_threadfind_idle_thread (void)
 
static struct iax2_peerfind_peer (const char *name, int realtime)
 
static struct iax2_trunk_peerfind_tpeer (struct ast_sockaddr *addr, int fd)
 
static struct iax2_userfind_user (const char *name)
 
static int firmware_show_callback (struct ast_iax2_firmware_header *header, void *user_data)
 
static unsigned int fix_peerts (struct timeval *rxtrunktime, int callno, unsigned int ts)
 
static void free_context (struct iax2_context *con)
 
static void free_signaling_queue_entry (struct signaling_queue_entry *s)
 
static int function_iaxpeer (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int get_auth_methods (const char *value)
 
static int get_encrypt_methods (const char *s)
 
static int get_from_jb (const void *p)
 
static int get_unused_callno (enum callno_type type, int validated, callno_entry *entry)
 
static int handle_call_token (struct ast_iax2_full_hdr *fh, struct iax_ies *ies, struct ast_sockaddr *addr, int fd)
 
static char * handle_cli_iax2_provision (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_prune_realtime (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_set_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_set_debug_jb (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_set_debug_trunk (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_set_mtu (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Set trunk MTU from CLI. More...
 
static char * handle_cli_iax2_show_cache (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_callno_limits (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_firmware (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_netstats (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_peer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show one peer in detail. More...
 
static char * handle_cli_iax2_show_peers (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_registry (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_stats (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_threads (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_show_users (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_test_losspct (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_iax2_unregister (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static void handle_deferred_full_frames (struct iax2_thread *thread)
 Handle any deferred full frames for this thread. More...
 
static int handle_error (void)
 
static int iax2_ack_registry (struct iax_ies *ies, struct ast_sockaddr *addr, int callno)
 Acknowledgment received for OUR registration. More...
 
static int attribute_pure iax2_allow_new (int frametype, int subclass, int inbound)
 
static int iax2_answer (struct ast_channel *c)
 
static int iax2_append_register (const char *hostname, const char *username, const char *secret, const char *porta)
 
static int iax2_call (struct ast_channel *c, const char *dest, int timeout)
 
static int iax2_canmatch (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 part of the IAX2 dial plan switch interface More...
 
static iax2_format iax2_codec_choose (struct iax2_codec_pref *pref, iax2_format formats)
 
static unsigned int iax2_datetime (const char *tz)
 
static int iax2_delete_from_sched (const void *data)
 
static void iax2_destroy (int callno)
 
static void iax2_destroy_helper (struct chan_iax2_pvt *pvt)
 
static int iax2_devicestate (const char *data)
 Part of the device state notification system —. More...
 
static int iax2_digit_begin (struct ast_channel *c, char digit)
 
static int iax2_digit_end (struct ast_channel *c, char digit, unsigned int duration)
 
static int iax2_do_register (struct iax2_registry *reg)
 
static int iax2_do_register_s (const void *data)
 
static void iax2_dprequest (struct iax2_dpcache *dp, int callno)
 
static void * iax2_dup_variable_datastore (void *)
 
static int iax2_exec (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 Execute IAX2 dialplan switch. More...
 
static int iax2_exists (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 Part of the IAX2 switch interface. More...
 
static int iax2_fixup (struct ast_channel *oldchannel, struct ast_channel *newchan)
 
static void iax2_frame_free (struct iax_frame *fr)
 
static void iax2_free_variable_datastore (void *)
 
const char * iax2_getformatname (iax2_format format)
 iax2 wrapper function for ast_getformatname More...
 
static const char * iax2_getformatname_multiple (iax2_format format, struct ast_str **codec_buf)
 
static int iax2_getpeername (struct ast_sockaddr addr, char *host, int len)
 
static int iax2_getpeertrunk (struct ast_sockaddr addr)
 
static int iax2_hangup (struct ast_channel *c)
 
static int iax2_indicate (struct ast_channel *c, int condition, const void *data, size_t datalen)
 
static int iax2_is_control_frame_allowed (int subtype)
 
static int iax2_key_rotate (const void *vpvt)
 
static int iax2_lock_callno_unless_destroyed (int callno)
 Acquire the iaxsl[callno] if call exists and not having ongoing hangup. More...
 
static void iax2_lock_owner (int callno)
 
static int iax2_matchmore (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 Part of the IAX2 Switch interface. More...
 
static int iax2_parse_allow_disallow (struct iax2_codec_pref *pref, iax2_format *formats, const char *list, int allowing)
 
static int iax2_poke_noanswer (const void *data)
 
static int iax2_poke_peer (struct iax2_peer *peer, int heldcall)
 
static int iax2_poke_peer_cb (void *obj, void *arg, int flags)
 
static int iax2_poke_peer_s (const void *data)
 
static int iax2_predestroy (int callno)
 
static void * iax2_process_thread (void *data)
 
static void iax2_process_thread_cleanup (void *data)
 
static int iax2_prov_app (struct ast_channel *chan, const char *data)
 
static int iax2_provision (struct ast_sockaddr *end, int sockfd, const char *dest, const char *template, int force)
 
static void iax2_publish_registry (const char *username, const char *domain, const char *status, const char *cause)
 
static int iax2_queryoption (struct ast_channel *c, int option, void *data, int *datalen)
 
static int iax2_queue_frame (int callno, struct ast_frame *f)
 Queue a frame to a call's owning asterisk channel. More...
 
static int iax2_queue_hangup (int callno)
 Queue a hangup frame on the ast_channel owner. More...
 
static int iax2_queue_hold (int callno, const char *musicclass)
 Queue a hold frame on the ast_channel owner. More...
 
static int iax2_queue_unhold (int callno)
 Queue an unhold frame on the ast_channel owner. More...
 
static struct ast_frameiax2_read (struct ast_channel *c)
 
static int iax2_register (const char *value, int lineno)
 
static struct ast_channeliax2_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
 
static int iax2_sched_add (struct ast_sched_context *sched, int when, ast_sched_cb callback, const void *data)
 
static int iax2_sched_replace (int id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data)
 
static int iax2_send (struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned int ts, int seqno, int now, int transfer, int final)
 
static int iax2_sendhtml (struct ast_channel *c, int subclass, const char *data, int datalen)
 
static int iax2_sendimage (struct ast_channel *c, struct ast_frame *img)
 
static int iax2_sendtext (struct ast_channel *c, const char *text)
 
static int iax2_setoption (struct ast_channel *c, int option, void *data, int datalen)
 
static int iax2_transfer (struct ast_channel *c, const char *dest)
 
static int iax2_transmit (struct iax_frame *fr)
 
static int iax2_trunk_expired (struct iax2_trunk_peer *tpeer, struct timeval *now)
 
static int iax2_trunk_queue (struct chan_iax2_pvt *pvt, struct iax_frame *fr)
 
static int iax2_vnak (int callno)
 
static int iax2_write (struct ast_channel *c, struct ast_frame *f)
 
static void iax_debug_output (const char *data)
 
static void iax_error_output (const char *data)
 
static void iax_outputframe (struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen)
 
static ast_callid iax_pvt_callid_get (int callno)
 
static void iax_pvt_callid_new (int callno)
 
static void iax_pvt_callid_set (int callno, ast_callid callid)
 
static struct iax_frameiaxfrdup2 (struct iax_frame *fr)
 
static void insert_idle_thread (struct iax2_thread *thread)
 
static int invalid_key (ast_aes_decrypt_key *ecx)
 
static void jb_debug_output (const char *fmt,...)
 
static void jb_error_output (const char *fmt,...)
 
static void jb_warning_output (const char *fmt,...)
 
static int load_module (void)
 Load the module. More...
 
static int load_objects (void)
 
static void log_jitterstats (unsigned short callno)
 
static int make_trunk (unsigned short callno, int locked)
 
static int manager_iax2_show_netstats (struct mansession *s, const struct message *m)
 
static int manager_iax2_show_peer_list (struct mansession *s, const struct message *m)
 callback to display iax peers in manager format More...
 
static int manager_iax2_show_peers (struct mansession *s, const struct message *m)
 callback to display iax peers in manager More...
 
static int manager_iax2_show_registry (struct mansession *s, const struct message *m)
 
static int match (struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
 
static void memcpy_decrypt (unsigned char *dst, const unsigned char *src, int len, ast_aes_decrypt_key *dcx)
 
static void memcpy_encrypt (unsigned char *dst, const unsigned char *src, int len, ast_aes_encrypt_key *ecx)
 
static void merge_encryption (struct chan_iax2_pvt *p, unsigned int enc)
 
static int network_change_sched_cb (const void *data)
 
static void network_change_stasis_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
 
static void network_change_stasis_subscribe (void)
 
static void network_change_stasis_unsubscribe (void)
 
static void * network_thread (void *ignore)
 
static struct chan_iax2_pvtnew_iax (struct ast_sockaddr *addr, const char *host)
 
static void parse_dial_string (char *data, struct parsed_dial_string *pds)
 Parses an IAX dial string into its component parts. More...
 
static int peer_cmp_cb (void *obj, void *arg, int flags)
 
static int peer_delme_cb (void *obj, void *arg, int flags)
 
static void peer_destructor (void *obj)
 
static int peer_hash_cb (const void *obj, const int flags)
 
static struct iax2_peerpeer_ref (struct iax2_peer *peer)
 
static int peer_set_sock_cb (void *obj, void *arg, int flags)
 
static int peer_set_srcaddr (struct iax2_peer *peer, const char *srcaddr)
 Parse the "sourceaddress" value, lookup in netsock list and set peer's sockfd. Defaults to defaultsockfd if not found. More...
 
static int peer_status (struct iax2_peer *peer, char *status, int statuslen)
 peer_status: Report Peer status in character string More...
 
static struct iax2_peerpeer_unref (struct iax2_peer *peer)
 
static int peercnt_add (struct ast_sockaddr *addr)
 
static int peercnt_cmp_cb (void *obj, void *arg, int flags)
 
static int peercnt_hash_cb (const void *obj, const int flags)
 
static void peercnt_modify (unsigned char reg, uint16_t limit, struct ast_sockaddr *sockaddr)
 
static void peercnt_remove (struct peercnt *peercnt)
 
static int peercnt_remove_by_addr (struct ast_sockaddr *addr)
 
static int peercnt_remove_cb (const void *obj)
 
static void poke_all_peers (void)
 
static int prune_addr_range_cb (void *obj, void *arg, int flags)
 
static void prune_peers (void)
 
static void prune_users (void)
 
static int pvt_cmp_cb (void *obj, void *arg, int flags)
 
static void pvt_destructor (void *obj)
 
static int pvt_hash_cb (const void *obj, const int flags)
 
static int queue_signalling (struct chan_iax2_pvt *pvt, struct ast_frame *f)
 All frames other than that of type AST_FRAME_IAX must be held until we have received a destination call number. More...
 
static int raw_hangup (struct ast_sockaddr *addr, unsigned short src, unsigned short dst, int sockfd)
 
static struct iax2_peerrealtime_peer (const char *peername, struct ast_sockaddr *addr)
 
static void realtime_update_peer (const char *peername, struct ast_sockaddr *sockaddr, time_t regtime)
 
static struct iax2_userrealtime_user (const char *username, struct ast_sockaddr *addr)
 
static void reg_source_db (struct iax2_peer *p)
 
static void register_peer_exten (struct iax2_peer *peer, int onoff)
 
static int register_verify (int callno, struct ast_sockaddr *addr, struct iax_ies *ies)
 Verify inbound registration. More...
 
static int registry_authrequest (int callno)
 
static int registry_rerequest (struct iax_ies *ies, int callno, struct ast_sockaddr *addr)
 
static char * regstate2str (int regstate)
 
static int reload (void)
 
static int reload_config (int forced_reload)
 
static void remove_by_peercallno (struct chan_iax2_pvt *pvt)
 
static void remove_by_transfercallno (struct chan_iax2_pvt *pvt)
 
static int replace_callno (const void *obj)
 
static void requirecalltoken_mark_auto (const char *name, int subclass)
 
static void resend_with_token (int callno, struct iax_frame *f, const char *newtoken)
 
static void save_osptoken (struct iax_frame *fr, struct iax_ies *ies)
 
static void save_rr (struct iax_frame *fr, struct iax_ies *ies)
 
static void sched_delay_remove (struct ast_sockaddr *addr, callno_entry entry)
 
static int schedule_delivery (struct iax_frame *fr, int updatehistory, int fromtrunk, unsigned int *tsout)
 
static int scheduled_destroy (const void *vid)
 
static int send_apathetic_reply (unsigned short callno, unsigned short dcallno, struct ast_sockaddr *addr, int command, int ts, unsigned char seqno, int sockfd, struct iax_ie_data *ied)
 
static int send_command (struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
 
static int send_command_final (struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
 
static int send_command_immediate (struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
 
static int send_command_locked (unsigned short callno, char, int, unsigned int, const unsigned char *, int, int)
 
static int send_command_transfer (struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int)
 
static int send_lagrq (const void *data)
 
static int send_packet (struct iax_frame *f)
 
static int send_ping (const void *data)
 
static void send_signaling (struct chan_iax2_pvt *pvt)
 This function must be called once we are sure the other side has given us a call number. All signaling is held here until that point. More...
 
static int send_trunk (struct iax2_trunk_peer *tpeer, struct timeval *now)
 
static int set_config (const char *config_file, int reload, int forced)
 Load configuration. More...
 
static void set_config_destroy (void)
 
static void set_hangup_source_and_cause (int callno, unsigned char causecode)
 
static void set_peercnt_limit (struct peercnt *peercnt)
 
static int set_peercnt_limit_all_cb (void *obj, void *arg, int flags)
 
static void signal_condition (ast_mutex_t *lock, ast_cond_t *cond)
 
static int socket_process (struct iax2_thread *thread)
 
static int socket_process_helper (struct iax2_thread *thread)
 
static int socket_process_meta (int packet_len, struct ast_iax2_meta_hdr *meta, struct ast_sockaddr *addr, int sockfd, struct iax_frame *fr)
 
static int socket_read (int *id, int fd, short events, void *cbdata)
 
static void spawn_dp_lookup (int callno, const char *context, const char *callednum, const char *callerid)
 
static int start_network_thread (void)
 
static void stop_stuff (int callno)
 
static void store_by_peercallno (struct chan_iax2_pvt *pvt)
 
static void store_by_transfercallno (struct chan_iax2_pvt *pvt)
 
static int timing_read (int *id, int fd, short events, void *cbdata)
 
static int transfercallno_pvt_cmp_cb (void *obj, void *arg, int flags)
 
static int transfercallno_pvt_hash_cb (const void *obj, const int flags)
 
static int transmit_frame (void *data)
 
static int transmit_trunk (struct iax_frame *f, struct ast_sockaddr *addr, int sockfd)
 
static int try_transfer (struct chan_iax2_pvt *pvt, struct iax_ies *ies)
 
static iax2_format uncompress_subclass (unsigned char csub)
 
static void unlink_peer (struct iax2_peer *peer)
 
static int unload_module (void)
 
static void unwrap_timestamp (struct iax_frame *fr)
 
static void update_jbsched (struct chan_iax2_pvt *pvt)
 
static int update_packet (struct iax_frame *f)
 
static int update_registry (struct ast_sockaddr *addr, int callno, char *devtype, int fd, unsigned short refresh)
 
static int user_cmp_cb (void *obj, void *arg, int flags)
 
static int user_delme_cb (void *obj, void *arg, int flags)
 
static void user_destructor (void *obj)
 
static int user_hash_cb (const void *obj, const int flags)
 
static struct iax2_useruser_unref (struct iax2_user *user)
 
static void vnak_retransmit (int callno, int last)
 
static int wait_for_peercallno (struct chan_iax2_pvt *pvt)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Inter Asterisk eXchange (Ver 2)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, .requires = "dnsmgr", .optional_modules = "res_crypto", }
 
static char accountcode [AST_MAX_ACCOUNT_CODE]
 
static struct stasis_subscriptionacl_change_sub
 
static struct active_list active_list = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static int adsi = 0
 
static int amaflags = 0
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const char * auth_method_labels []
 Name of effective auth method. More...
 
static int authdebug = 0
 
static int autokill = 0
 
static struct ao2_containercallno_limits
 
static struct call_number_pool callno_pool
 
static ast_mutex_t callno_pool_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct call_number_pool callno_pool_trunk
 
static struct ao2_containercalltoken_ignores
 
static struct ast_cli_entry cli_iax2 []
 
static struct ast_sockaddr debugaddr
 
static uint16_t DEFAULT_MAXCALLNO_LIMIT = 2048
 
static uint16_t DEFAULT_MAXCALLNO_LIMIT_NONVAL = 8192
 
static char default_parkinglot [AST_MAX_CONTEXT]
 
static int defaultsockfd = -1
 
static int delayreject = 0
 
static struct dpcache dpcache = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static struct dynamic_list dynamic_list = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
struct {
   struct iax_frame *   first
 
   struct iax_frame *   last
 
frame_queue [IAX_MAX_CALLS]
 a list of frames that may need to be retransmitted More...
 
static int global_max_trunk_mtu
 
static uint16_t global_maxcallno
 
static uint16_t global_maxcallno_nonval
 
static int global_rtautoclear = 120
 
static struct ast_flags64 globalflags = { 0 }
 
static int iax2_authmethods = 0
 
static iax2_format iax2_capability = IAX_CAPABILITY_FULLBANDWIDTH
 
static int iax2_encryption = 0
 
static int(* iax2_regfunk )(const char *username, int onoff) = NULL
 
static struct ast_switch iax2_switch
 
static struct ast_channel_tech iax2_tech
 
static const struct ast_datastore_info iax2_variable_datastore_info
 
static struct ao2_containeriax_peercallno_pvts
 Another container of iax2_pvt structures. More...
 
static struct ao2_containeriax_transfercallno_pvts
 Another container of iax2_pvt structures. More...
 
static int iaxactivethreadcount = 0
 
static int iaxcompat = 0
 
static int iaxdebug = 0
 
static int iaxdefaultdpcache =10 * 60
 
static int iaxdefaulttimeout = 5
 
static int iaxdynamicthreadcount = 0
 
static int iaxdynamicthreadnum = 0
 
static int iaxmaxthreadcount = DEFAULT_MAX_THREAD_COUNT
 
static struct ast_custom_function iaxpeer_function
 
static struct chan_iax2_pvtiaxs [IAX_MAX_CALLS]
 an array of iax2 pvt structures More...
 
static ast_mutex_t iaxsl [ARRAY_LEN(iaxs)]
 chan_iax2_pvt structure locks More...
 
static int iaxthreadcount = DEFAULT_THREAD_COUNT
 
static int iaxtrunkdebug = 0
 
static struct ast_custom_function iaxvar_function
 
static struct idle_list idle_list = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static struct io_contextio
 
static int jittertargetextra = 40
 
static int lagrq_time = 10
 
static char language [MAX_LANGUAGE] = ""
 
static int last_authmethod = 0
 
static time_t max_calltoken_delay = 10
 
static int max_reg_expire
 
static int max_retries = 4
 
static int maxauthreq = 3
 
static int maxjitterbuffer =1000
 
static int maxjitterinterps =10
 
static int min_reg_expire
 
static char mohinterpret [MAX_MUSICCLASS]
 
static char mohsuggest [MAX_MUSICCLASS]
 
static struct ast_netsock_listnetsock
 
static pthread_t netthreadid = AST_PTHREADT_NULL
 
static int network_change_sched_id = -1
 
static struct stasis_subscriptionnetwork_change_sub
 
static struct ast_netsock_listoutsock
 
static char * papp = "IAX2Provision"
 
static struct ao2_containerpeercnts
 
static struct ao2_containerpeers
 
static int ping_time = 21
 
static struct iax2_codec_pref prefs_global
 
struct {
   unsigned int   cos
 
   unsigned int   tos
 
qos = { 0, 0 }
 
static int randomcalltokendata
 
static char regcontext [AST_MAX_CONTEXT] = ""
 
static struct registrations registrations = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static int resyncthreshold =1000
 
static struct ast_sched_contextsched
 
static int srvlookup = 0
 
static const char tdesc [] = "Inter Asterisk eXchange Driver (Ver 2)"
 
static int test_losspct = 0
 
static struct ast_timertimer
 
static uint16_t total_nonval_callno_used = 0
 
static struct tpeers tpeers = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static struct ast_taskprocessortransmit_processor
 
static int trunk_maxmtu
 
static int trunk_nmaxmtu
 
static int trunk_timed
 
static int trunk_untimed
 
static int trunkfreq = 20
 
static int trunkmaxsize = MAX_TRUNKDATA
 
static struct ao2_containerusers
 

Detailed Description

Implementation of Inter-Asterisk eXchange Version 2 as specified in RFC 5456.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Todo:
Implement musicclass settings for IAX2 devices

Definition in file chan_iax2.c.

Macro Definition Documentation

◆ ACN_FORMAT1

#define ACN_FORMAT1   "%-24.25s %4u %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d %s%s %4s%s\n"

◆ ACN_FORMAT2

#define ACN_FORMAT2   "%s %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %s%s %s%s\n"

◆ AUTH_METHOD_NAMES_BUFSIZE

#define AUTH_METHOD_NAMES_BUFSIZE   19

Definition at line 407 of file chan_iax2.c.

◆ CALLNO_ENTRY_GET_CALLNO

#define CALLNO_ENTRY_GET_CALLNO (   a)    ((a) & 0x7FFF)

Definition at line 955 of file chan_iax2.c.

◆ CALLNO_ENTRY_IS_VALIDATED

#define CALLNO_ENTRY_IS_VALIDATED (   a)    ((a) & 0x8000)

Definition at line 954 of file chan_iax2.c.

◆ CALLNO_ENTRY_SET_VALIDATED

#define CALLNO_ENTRY_SET_VALIDATED (   a)    ((a) |= 0x8000)

Definition at line 953 of file chan_iax2.c.

◆ CALLNO_ENTRY_TO_PTR

#define CALLNO_ENTRY_TO_PTR (   a)    ((void *)(unsigned long)(a))

Definition at line 951 of file chan_iax2.c.

◆ CALLNO_TO_PTR

#define CALLNO_TO_PTR (   a)    ((void *)(unsigned long)(a))

Definition at line 293 of file chan_iax2.c.

◆ CALLTOKEN_HASH_FORMAT

#define CALLTOKEN_HASH_FORMAT   "%s%u%d" /* address + port + ts + randomcalldata */

◆ CALLTOKEN_IE_FORMAT

#define CALLTOKEN_IE_FORMAT   "%u?%s" /* time + ? + (40 char hash) */

◆ DEBUG_SCHED_MULTITHREAD

#define DEBUG_SCHED_MULTITHREAD

Definition at line 285 of file chan_iax2.c.

◆ DEBUG_SUPPORT

#define DEBUG_SUPPORT

Definition at line 301 of file chan_iax2.c.

◆ DEFAULT_CONTEXT

#define DEFAULT_CONTEXT   "default"

Definition at line 320 of file chan_iax2.c.

◆ DEFAULT_DROP

#define DEFAULT_DROP   3

Definition at line 299 of file chan_iax2.c.

◆ DEFAULT_FREQ_NOTOK

#define DEFAULT_FREQ_NOTOK   10 * 1000 /* How often to check, if the host is down... */

Definition at line 396 of file chan_iax2.c.

◆ DEFAULT_FREQ_OK

#define DEFAULT_FREQ_OK   60 * 1000 /* How often to check for the host to be up */

Definition at line 395 of file chan_iax2.c.

◆ DEFAULT_MAX_THREAD_COUNT

#define DEFAULT_MAX_THREAD_COUNT   100

Definition at line 296 of file chan_iax2.c.

◆ DEFAULT_MAXMS

#define DEFAULT_MAXMS   2000 /* Must be faster than 2 seconds by default */

Definition at line 394 of file chan_iax2.c.

◆ DEFAULT_RETRY_TIME

#define DEFAULT_RETRY_TIME   1000

Definition at line 297 of file chan_iax2.c.

◆ DEFAULT_THREAD_COUNT

#define DEFAULT_THREAD_COUNT   10

Definition at line 295 of file chan_iax2.c.

◆ DEFAULT_TRUNKDATA

#define DEFAULT_TRUNKDATA   640 * 10

40ms, uncompressed linear * 10 channels

Definition at line 710 of file chan_iax2.c.

◆ FORMAT [1/3]

#define FORMAT   "%-15.15s %-20.20s %-15.15s %-15.15s %-5.5s %-5.10s\n"

◆ FORMAT [2/3]

#define FORMAT   "%-45.45s %-6.6s %-10.10s %-45.45s %8d %s\n"

◆ FORMAT [3/3]

#define FORMAT   "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d %-5.5dms %-4.4dms %-4.4dms %-6.6s %s%s %3s%s\n"

◆ FORMAT2 [1/3]

#define FORMAT2   "%-15.15s %-20.20s %-15.15d %-15.15s %-5.5s %-5.10s\n"

◆ FORMAT2 [2/3]

#define FORMAT2   "%-45.45s %-6.6s %-10.10s %-45.45s %8.8s %s\n"

◆ FORMAT2 [3/3]

#define FORMAT2   "%-20.20s %-40.40s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %-6.6s %s %s %9s\n"

◆ FORMATB

#define FORMATB   "%-20.20s %-40.40s %-10.10s %5.5d/%5.5d %5.5d/%5.5d [Native Bridged to ID=%5.5d]\n"

◆ GAMMA

#define GAMMA   (0.01)

Definition at line 306 of file chan_iax2.c.

◆ IAX2_TRUNK_PREFACE

#define IAX2_TRUNK_PREFACE   (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr))

Definition at line 638 of file chan_iax2.c.

◆ IAX_ALLOWFWDOWNLOAD

#define IAX_ALLOWFWDOWNLOAD   (uint64_t)(1LLU << 26)

Allow the FWDOWNL command?

Definition at line 523 of file chan_iax2.c.

◆ IAX_ALREADYGONE

#define IAX_ALREADYGONE   (uint64_t)(1LLU << 9)

Already disconnected

Definition at line 507 of file chan_iax2.c.

◆ IAX_CALLENCRYPTED

#define IAX_CALLENCRYPTED (   pvt)     (ast_test_flag64(pvt, IAX_ENCRYPTED) && ast_test_flag64(pvt, IAX_KEYPOPULATED))

Definition at line 440 of file chan_iax2.c.

◆ IAX_CAPABILITY_FULLBANDWIDTH

#define IAX_CAPABILITY_FULLBANDWIDTH   0xFFFF

Definition at line 373 of file chan_iax2.c.

◆ IAX_CAPABILITY_LOWBANDWIDTH

#define IAX_CAPABILITY_LOWBANDWIDTH
Value:
~AST_FORMAT_G726 & \
~AST_FORMAT_G726_AAL2 & \
~AST_FORMAT_ADPCM)
#define IAX_CAPABILITY_MEDBANDWIDTH
Definition: chan_iax2.c:375

Definition at line 385 of file chan_iax2.c.

◆ IAX_CAPABILITY_LOWFREE

#define IAX_CAPABILITY_LOWFREE
Value:
~AST_FORMAT_G723)
#define IAX_CAPABILITY_LOWBANDWIDTH
Definition: chan_iax2.c:385

Definition at line 390 of file chan_iax2.c.

◆ IAX_CAPABILITY_MEDBANDWIDTH

#define IAX_CAPABILITY_MEDBANDWIDTH

Definition at line 375 of file chan_iax2.c.

◆ IAX_CODEC_NOCAP

#define IAX_CODEC_NOCAP   (uint64_t)(1LLU << 16)

only consider requested format and ignore capabilities

Definition at line 514 of file chan_iax2.c.

◆ IAX_CODEC_NOPREFS

#define IAX_CODEC_NOPREFS   (uint64_t)(1LLU << 15)

Force old behaviour by turning off prefs

Definition at line 513 of file chan_iax2.c.

◆ IAX_CODEC_USER_FIRST

#define IAX_CODEC_USER_FIRST   (uint64_t)(1LLU << 14)

are we willing to let the other guy choose the codec?

Definition at line 512 of file chan_iax2.c.

◆ IAX_DEBUGDIGEST

#define IAX_DEBUGDIGEST (   msg,
  key 
)

Definition at line 443 of file chan_iax2.c.

◆ IAX_DELAYPBXSTART

#define IAX_DELAYPBXSTART   (uint64_t)(1LLU << 25)

Don't start a PBX on the channel until the peer sends us a response, so that we've achieved a three-way handshake with them before sending voice or anything else

Definition at line 522 of file chan_iax2.c.

◆ IAX_DELME

#define IAX_DELME   (uint64_t)(1LLU << 1)

Needs to be deleted

Definition at line 499 of file chan_iax2.c.

◆ IAX_DYNAMIC

#define IAX_DYNAMIC   (uint64_t)(1LLU << 6)

dynamic peer

Definition at line 504 of file chan_iax2.c.

◆ IAX_ENCRYPTED

#define IAX_ENCRYPTED   (uint64_t)(1LLU << 12)

Whether we should assume encrypted tx/rx

Definition at line 510 of file chan_iax2.c.

◆ IAX_FORCE_ENCRYPT

#define IAX_FORCE_ENCRYPT   (uint64_t)(1LLU << 30)

Forces call encryption, if encryption not possible hangup

Definition at line 527 of file chan_iax2.c.

◆ IAX_HASCALLERID

#define IAX_HASCALLERID   (uint64_t)(1LLU << 0)

CallerID has been specified

Definition at line 498 of file chan_iax2.c.

◆ IAX_IMMEDIATE

#define IAX_IMMEDIATE   (uint64_t)(1LLU << 27)

Allow immediate off-hook to extension s

Definition at line 524 of file chan_iax2.c.

◆ IAX_KEYPOPULATED

#define IAX_KEYPOPULATED   (uint64_t)(1LLU << 13)

Whether we have a key populated

Definition at line 511 of file chan_iax2.c.

◆ IAX_MAXAUTHREQ

#define IAX_MAXAUTHREQ   (uint64_t)(1LLU << 24)

Maximum outstanding AUTHREQ restriction is in place

Definition at line 521 of file chan_iax2.c.

◆ IAX_NOTRANSFER

#define IAX_NOTRANSFER   (uint64_t)(1LLU << 4)

Don't native bridge

Definition at line 502 of file chan_iax2.c.

◆ IAX_PROVISION

#define IAX_PROVISION   (uint64_t)(1LLU << 10)

This is a provisioning request

Definition at line 508 of file chan_iax2.c.

◆ IAX_QUELCH

#define IAX_QUELCH   (uint64_t)(1LLU << 11)

Whether or not we quelch audio

Definition at line 509 of file chan_iax2.c.

◆ IAX_RECVCONNECTEDLINE

#define IAX_RECVCONNECTEDLINE   (uint64_t)(1LLU << 29)

Allow receiving of connected line updates

Definition at line 526 of file chan_iax2.c.

◆ IAX_RTAUTOCLEAR

#define IAX_RTAUTOCLEAR   (uint64_t)(1LLU << 19)

erase me on expire

Definition at line 517 of file chan_iax2.c.

◆ IAX_RTCACHEFRIENDS

#define IAX_RTCACHEFRIENDS   (uint64_t)(1LLU << 17)

let realtime stay till your reload

Definition at line 515 of file chan_iax2.c.

◆ IAX_RTIGNOREREGEXPIRE

#define IAX_RTIGNOREREGEXPIRE   (uint64_t)(1LLU << 21)

When using realtime, ignore registration expiration

Definition at line 518 of file chan_iax2.c.

◆ IAX_RTSAVE_SYSNAME

#define IAX_RTSAVE_SYSNAME   (uint64_t)(1LLU << 8)

Save Systname on Realtime Updates

Definition at line 506 of file chan_iax2.c.

◆ IAX_RTUPDATE

#define IAX_RTUPDATE   (uint64_t)(1LLU << 18)

Send a realtime update

Definition at line 516 of file chan_iax2.c.

◆ IAX_SENDANI

#define IAX_SENDANI   (uint64_t)(1LLU << 7)

Send ANI along with CallerID

Definition at line 505 of file chan_iax2.c.

◆ IAX_SENDCONNECTEDLINE

#define IAX_SENDCONNECTEDLINE   (uint64_t)(1LLU << 28)

Allow sending of connected line updates

Definition at line 525 of file chan_iax2.c.

◆ IAX_SHRINKCALLERID

#define IAX_SHRINKCALLERID   (uint64_t)(1LLU << 31)

Turn on and off caller id shrinking

Definition at line 528 of file chan_iax2.c.

◆ IAX_TEMPONLY

#define IAX_TEMPONLY   (uint64_t)(1LLU << 2)

Temporary (realtime)

Definition at line 500 of file chan_iax2.c.

◆ IAX_TRANSFERMEDIA

#define IAX_TRANSFERMEDIA   (uint64_t)(1LLU << 23)

When doing IAX2 transfers, transfer media only

Definition at line 520 of file chan_iax2.c.

◆ IAX_TRUNK

#define IAX_TRUNK   (uint64_t)(1LLU << 3)

Treat as a trunk

Definition at line 501 of file chan_iax2.c.

◆ IAX_TRUNKTIMESTAMPS

#define IAX_TRUNKTIMESTAMPS   (uint64_t)(1LLU << 22)

Send trunk timestamps

Definition at line 519 of file chan_iax2.c.

◆ IAX_USEJITTERBUF

#define IAX_USEJITTERBUF   (uint64_t)(1LLU << 5)

Use jitter buffer

Definition at line 503 of file chan_iax2.c.

◆ MARK_IAX_SUBCLASS_TX

#define MARK_IAX_SUBCLASS_TX   0x8000

Definition at line 718 of file chan_iax2.c.

◆ MAX_JITTER_BUFFER

#define MAX_JITTER_BUFFER   50

Definition at line 707 of file chan_iax2.c.

◆ MAX_PEER_BUCKETS

#define MAX_PEER_BUCKETS   563

This module will get much higher performance when doing a lot of user and peer lookups if the number of buckets is increased from 1. However, to maintain old behavior for Asterisk 1.4, these are set to 1 by default. When using multiple buckets, search order through these containers is considered random, so you will not be able to depend on the order the entires are specified in iax.conf for matching order.

Definition at line 998 of file chan_iax2.c.

◆ MAX_RETRY_TIME

#define MAX_RETRY_TIME   10000

Definition at line 705 of file chan_iax2.c.

◆ MAX_TIMESTAMP_SKEW

#define MAX_TIMESTAMP_SKEW   160

maximum difference between actual and predicted ts for sending

Definition at line 712 of file chan_iax2.c.

◆ MAX_TRUNK_MTU

#define MAX_TRUNK_MTU   1240

Maximum transmission unit for the UDP packet in the trunk not to be fragmented. This is based on 1516 - ethernet - ip - udp - iax minus one g711 frame = 1240.

Definition at line 315 of file chan_iax2.c.

◆ MAX_TRUNKDATA

#define MAX_TRUNKDATA   640 * 200

40ms, uncompressed linear * 200 channels

Definition at line 340 of file chan_iax2.c.

◆ MAX_USER_BUCKETS

#define MAX_USER_BUCKETS   MAX_PEER_BUCKETS

Definition at line 1002 of file chan_iax2.c.

◆ MEMORY_SIZE

#define MEMORY_SIZE   100

Definition at line 298 of file chan_iax2.c.

◆ MIN_JITTER_BUFFER

#define MIN_JITTER_BUFFER   10

Definition at line 708 of file chan_iax2.c.

◆ MIN_RETRY_TIME

#define MIN_RETRY_TIME   100

Definition at line 704 of file chan_iax2.c.

◆ MIN_REUSE_TIME

#define MIN_REUSE_TIME   60 /* Don't reuse a call number within 60 seconds */

Definition at line 303 of file chan_iax2.c.

◆ PEERS_FORMAT

#define PEERS_FORMAT   "%-15.15s %-40.40s %s %-40.40s %-6s%s %s %-11s %-32.32s\n"

Definition at line 6943 of file chan_iax2.c.

◆ PEERS_FORMAT2

#define PEERS_FORMAT2   "%-15.15s %-40.40s %s %-40.40s %-9s %s %-11s %-32.32s\n"

Definition at line 6942 of file chan_iax2.c.

◆ PTR_TO_CALLNO

#define PTR_TO_CALLNO (   a)    ((unsigned short)(unsigned long)(a))

Definition at line 292 of file chan_iax2.c.

◆ PTR_TO_CALLNO_ENTRY

#define PTR_TO_CALLNO_ENTRY (   a)    ((uint16_t)(unsigned long)(a))

Definition at line 950 of file chan_iax2.c.

◆ SCHED_MULTITHREADED

#define SCHED_MULTITHREADED
Todo:
XXX The IAX2 channel driver needs its native bridge code converted to the new bridge technology scheme.
Note
The chan_dahdi native bridge code can be used as an example. It also appears that chan_iax2 also has a native transfer check like chan_dahdi to eliminate tromboned calls.
The existing native bridge code is marked with the IAX2_NATIVE_BRIDGING conditional.

Definition at line 281 of file chan_iax2.c.

◆ schedule_action

#define schedule_action (   func,
  data 
)    __schedule_action(func, data, __PRETTY_FUNCTION__)

Definition at line 1724 of file chan_iax2.c.

◆ TRUNK_CALL_START

#define TRUNK_CALL_START   (IAX_MAX_CALLS / 2)

Definition at line 1222 of file chan_iax2.c.

◆ TS_GAP_FOR_JB_RESYNC

#define TS_GAP_FOR_JB_RESYNC   5000

Definition at line 715 of file chan_iax2.c.

Typedef Documentation

◆ callno_entry

typedef uint16_t callno_entry

Definition at line 740 of file chan_iax2.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CACHE_FLAG_EXISTS 

Extension exists

CACHE_FLAG_NONEXISTENT 

Extension is nonexistent

CACHE_FLAG_CANEXIST 

Extension can exist

CACHE_FLAG_PENDING 

Waiting to hear back response

CACHE_FLAG_TIMEOUT 

Timed out

CACHE_FLAG_TRANSMITTED 

Request transmitted

CACHE_FLAG_UNKNOWN 

Timeout

CACHE_FLAG_MATCHMORE 

Matchmore

Definition at line 1049 of file chan_iax2.c.

1049 {
1050 /*! Extension exists */
1051 CACHE_FLAG_EXISTS = (1 << 0),
1052 /*! Extension is nonexistent */
1053 CACHE_FLAG_NONEXISTENT = (1 << 1),
1054 /*! Extension can exist */
1055 CACHE_FLAG_CANEXIST = (1 << 2),
1056 /*! Waiting to hear back response */
1057 CACHE_FLAG_PENDING = (1 << 3),
1058 /*! Timed out */
1059 CACHE_FLAG_TIMEOUT = (1 << 4),
1060 /*! Request transmitted */
1061 CACHE_FLAG_TRANSMITTED = (1 << 5),
1062 /*! Timeout */
1063 CACHE_FLAG_UNKNOWN = (1 << 6),
1064 /*! Matchmore */
1065 CACHE_FLAG_MATCHMORE = (1 << 7),
1066};
@ CACHE_FLAG_TIMEOUT
Definition: chan_iax2.c:1059
@ CACHE_FLAG_EXISTS
Definition: chan_iax2.c:1051
@ CACHE_FLAG_UNKNOWN
Definition: chan_iax2.c:1063
@ CACHE_FLAG_MATCHMORE
Definition: chan_iax2.c:1065
@ CACHE_FLAG_CANEXIST
Definition: chan_iax2.c:1055
@ CACHE_FLAG_PENDING
Definition: chan_iax2.c:1057
@ CACHE_FLAG_NONEXISTENT
Definition: chan_iax2.c:1053
@ CACHE_FLAG_TRANSMITTED
Definition: chan_iax2.c:1061

◆ anonymous enum

anonymous enum
Enumerator
NEW_PREVENT 
NEW_ALLOW 
NEW_FORCE 
NEW_ALLOW_CALLTOKEN_VALIDATED 

Definition at line 2350 of file chan_iax2.c.

2350 {
2351 /* do not allow a new call number, only search ones in use for match */
2352 NEW_PREVENT = 0,
2353 /* search for match first, then allow a new one to be allocated */
2354 NEW_ALLOW = 1,
2355 /* do not search for match, force a new call number */
2356 NEW_FORCE = 2,
2357 /* do not search for match, force a new call number. Signifies call number
2358 * has been calltoken validated */
2360};
@ NEW_PREVENT
Definition: chan_iax2.c:2352
@ NEW_ALLOW
Definition: chan_iax2.c:2354
@ NEW_FORCE
Definition: chan_iax2.c:2356
@ NEW_ALLOW_CALLTOKEN_VALIDATED
Definition: chan_iax2.c:2359

◆ callno_type

Enumerator
CALLNO_TYPE_NORMAL 
CALLNO_TYPE_TRUNK 

Definition at line 945 of file chan_iax2.c.

945 {
948};
@ CALLNO_TYPE_TRUNK
Definition: chan_iax2.c:947
@ CALLNO_TYPE_NORMAL
Definition: chan_iax2.c:946

◆ calltoken_peer_enum

Call token validation settings.

Enumerator
CALLTOKEN_DEFAULT 

Default calltoken required unless the ip is in the ignorelist.

CALLTOKEN_YES 

Require call token validation.

CALLTOKEN_AUTO 

Require call token validation after a successful registration using call token validation occurs.

CALLTOKEN_NO 

Do not require call token validation.

Definition at line 536 of file chan_iax2.c.

536 {
537 /*! \brief Default calltoken required unless the ip is in the ignorelist */
539 /*! \brief Require call token validation. */
540 CALLTOKEN_YES = 1,
541 /*! \brief Require call token validation after a successful registration
542 * using call token validation occurs. */
543 CALLTOKEN_AUTO = 2,
544 /*! \brief Do not require call token validation. */
545 CALLTOKEN_NO = 3,
546};
@ CALLTOKEN_DEFAULT
Default calltoken required unless the ip is in the ignorelist.
Definition: chan_iax2.c:538
@ CALLTOKEN_AUTO
Require call token validation after a successful registration using call token validation occurs.
Definition: chan_iax2.c:543
@ CALLTOKEN_NO
Do not require call token validation.
Definition: chan_iax2.c:545
@ CALLTOKEN_YES
Require call token validation.
Definition: chan_iax2.c:540

◆ iax2_state

enum iax2_state
Enumerator
IAX_STATE_STARTED 
IAX_STATE_AUTHENTICATED 
IAX_STATE_TBD 

Definition at line 486 of file chan_iax2.c.

486 {
487 IAX_STATE_STARTED = (1 << 0),
488 IAX_STATE_AUTHENTICATED = (1 << 1),
489 IAX_STATE_TBD = (1 << 2),
490};
@ IAX_STATE_TBD
Definition: chan_iax2.c:489
@ IAX_STATE_AUTHENTICATED
Definition: chan_iax2.c:488
@ IAX_STATE_STARTED
Definition: chan_iax2.c:487

◆ iax2_thread_iostate

Enumerator
IAX_IOSTATE_IDLE 
IAX_IOSTATE_READY 
IAX_IOSTATE_PROCESSING 
IAX_IOSTATE_SCHEDREADY 

Definition at line 1090 of file chan_iax2.c.

1090 {
1095};
@ IAX_IOSTATE_PROCESSING
Definition: chan_iax2.c:1093
@ IAX_IOSTATE_SCHEDREADY
Definition: chan_iax2.c:1094
@ IAX_IOSTATE_IDLE
Definition: chan_iax2.c:1091
@ IAX_IOSTATE_READY
Definition: chan_iax2.c:1092

◆ iax2_thread_type

Enumerator
IAX_THREAD_TYPE_POOL 
IAX_THREAD_TYPE_DYNAMIC 

Definition at line 1097 of file chan_iax2.c.

1097 {
1100};
@ IAX_THREAD_TYPE_DYNAMIC
Definition: chan_iax2.c:1099
@ IAX_THREAD_TYPE_POOL
Definition: chan_iax2.c:1098

◆ iax_reg_state

Enumerator
REG_STATE_UNREGISTERED 
REG_STATE_REGSENT 
REG_STATE_AUTHSENT 
REG_STATE_REGISTERED 
REG_STATE_REJECTED 
REG_STATE_TIMEOUT 
REG_STATE_NOAUTH 

Definition at line 661 of file chan_iax2.c.

661 {
669};
@ REG_STATE_REGSENT
Definition: chan_iax2.c:663
@ REG_STATE_TIMEOUT
Definition: chan_iax2.c:667
@ REG_STATE_AUTHSENT
Definition: chan_iax2.c:664
@ REG_STATE_NOAUTH
Definition: chan_iax2.c:668
@ REG_STATE_REGISTERED
Definition: chan_iax2.c:665
@ REG_STATE_REJECTED
Definition: chan_iax2.c:666
@ REG_STATE_UNREGISTERED
Definition: chan_iax2.c:662

◆ iax_transfer_state

Enumerator
TRANSFER_NONE 
TRANSFER_BEGIN 
TRANSFER_READY 
TRANSFER_RELEASED 
TRANSFER_PASSTHROUGH 
TRANSFER_MBEGIN 
TRANSFER_MREADY 
TRANSFER_MRELEASED 
TRANSFER_MPASSTHROUGH 
TRANSFER_MEDIA 
TRANSFER_MEDIAPASS 

Definition at line 671 of file chan_iax2.c.

671 {
672 TRANSFER_NONE = 0,
683};
@ TRANSFER_MEDIA
Definition: chan_iax2.c:681
@ TRANSFER_NONE
Definition: chan_iax2.c:672
@ TRANSFER_MPASSTHROUGH
Definition: chan_iax2.c:680
@ TRANSFER_MEDIAPASS
Definition: chan_iax2.c:682
@ TRANSFER_PASSTHROUGH
Definition: chan_iax2.c:676
@ TRANSFER_MRELEASED
Definition: chan_iax2.c:679
@ TRANSFER_BEGIN
Definition: chan_iax2.c:673
@ TRANSFER_MREADY
Definition: chan_iax2.c:678
@ TRANSFER_READY
Definition: chan_iax2.c:674
@ TRANSFER_MBEGIN
Definition: chan_iax2.c:677
@ TRANSFER_RELEASED
Definition: chan_iax2.c:675

Function Documentation

◆ __attempt_transmit()

static void __attempt_transmit ( const void *  data)
static

Definition at line 3595 of file chan_iax2.c.

3596{
3597 /* Attempt to transmit the frame to the remote peer...
3598 Called without iaxsl held. */
3599 struct iax_frame *f = (struct iax_frame *)data;
3600 int freeme = 0;
3601 int callno = f->callno;
3602
3603 /* Make sure this call is still active */
3604 if (callno)
3606 if (callno && iaxs[callno]) {
3607 if (f->retries < 0) {
3608 /* Already ACK'd */
3609 freeme = 1;
3610 } else if (f->retries >= max_retries) {
3611 /* Too many attempts. Record an error. */
3612 if (f->transfer) {
3613 /* Transfer timeout */
3615 } else if (f->final) {
3617 } else {
3618 if (iaxs[callno]->owner) {
3619 ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %u, subclass = %d, ts=%u, seqno=%d)\n",
3622 f->af.frametype,
3623 f->af.subclass.integer,
3624 f->ts,
3625 f->oseqno);
3626 }
3627 iaxs[callno]->error = ETIMEDOUT;
3628 if (iaxs[callno]->owner) {
3630 /* Hangup the fd */
3631 iax2_queue_frame(callno, &fr); /* XXX */
3632 /* Remember, owner could disappear */
3633 if (iaxs[callno] && iaxs[callno]->owner)
3635 } else {
3636 if (iaxs[callno]->reg) {
3637 memset(&iaxs[callno]->reg->us, 0, sizeof(iaxs[callno]->reg->us));
3638 iaxs[callno]->reg->regstate = REG_STATE_TIMEOUT;
3640 }
3641 iax2_destroy(callno);
3642 }
3643 }
3644 freeme = 1;
3645 } else {
3646 /* Update it if it needs it */
3647 update_packet(f);
3648 /* Attempt transmission */
3649 send_packet(f);
3650 f->retries++;
3651 /* Try again later after 10 times as long */
3652 f->retrytime *= 10;
3653 if (f->retrytime > MAX_RETRY_TIME)
3655 /* Transfer messages max out at one second */
3656 if (f->transfer && (f->retrytime > 1000))
3657 f->retrytime = 1000;
3659 }
3660 } else {
3661 /* Make sure it gets freed */
3662 f->retries = -1;
3663 freeme = 1;
3664 }
3665
3666 if (freeme) {
3667 /* Don't attempt delivery, just remove it from the queue */
3668 AST_LIST_REMOVE(&frame_queue[callno], f, list);
3669 ast_mutex_unlock(&iaxsl[callno]);
3670 f->retrans = -1; /* this is safe because this is the scheduled function */
3671 /* Free the IAX frame */
3672 iax2_frame_free(f);
3673 } else if (callno) {
3674 ast_mutex_unlock(&iaxsl[callno]);
3675 }
3676}
#define ast_log
Definition: astobj2.c:42
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
Definition: causes.h:115
static int update_packet(struct iax_frame *f)
Definition: chan_iax2.c:3568
static ast_mutex_t iaxsl[ARRAY_LEN(iaxs)]
chan_iax2_pvt structure locks
Definition: chan_iax2.c:1211
static int send_command(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
Definition: chan_iax2.c:7831
static int attempt_transmit(const void *data)
Definition: chan_iax2.c:3678
#define MAX_RETRY_TIME
Definition: chan_iax2.c:705
static void iax2_destroy(int callno)
Definition: chan_iax2.c:3506
static struct @117 frame_queue[IAX_MAX_CALLS]
a list of frames that may need to be retransmitted
static int iax2_sched_add(struct ast_sched_context *sched, int when, ast_sched_cb callback, const void *data)
Definition: chan_iax2.c:1733
static int max_retries
Definition: chan_iax2.c:332
static struct chan_iax2_pvt * iaxs[IAX_MAX_CALLS]
an array of iax2 pvt structures
Definition: chan_iax2.c:1173
static int iax2_queue_frame(int callno, struct ast_frame *f)
Queue a frame to a call's owning asterisk channel.
Definition: chan_iax2.c:3300
static int send_packet(struct iax_frame *f)
Definition: chan_iax2.c:3449
static void iax2_frame_free(struct iax_frame *fr)
Definition: chan_iax2.c:2177
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
@ IAX_COMMAND_TXREJ
Definition: iax2.h:93
#define IAX_DEFAULT_REG_EXPIRE
Definition: iax2.h:123
@ AST_FRAME_CONTROL
@ AST_CONTROL_HANGUP
#define LOG_WARNING
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
#define ast_mutex_unlock(a)
Definition: lock.h:190
#define ast_mutex_lock(a)
Definition: lock.h:189
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition: netsock2.h:286
#define NULL
Definition: resample.c:96
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
struct ast_sockaddr addr
Definition: chan_iax2.c:776
struct ast_channel * owner
Definition: chan_iax2.c:808
struct iax2_registry * reg
Definition: chan_iax2.c:882
enum iax_reg_state regstate
Definition: chan_iax2.c:691
struct ast_sockaddr us
Definition: chan_iax2.c:694
unsigned int final
Definition: parser.h:120
int retrans
Definition: parser.h:130
unsigned int ts
Definition: parser.h:110
void * data
Definition: parser.h:104
unsigned short callno
Definition: parser.h:100
int retries
Definition: parser.h:108
int retrytime
Definition: parser.h:112
unsigned int transfer
Definition: parser.h:118
struct ast_frame af
Definition: parser.h:142
int oseqno
Definition: parser.h:126
Definition: sched.c:76

References chan_iax2_pvt::addr, iax_frame::af, AST_CAUSE_DESTINATION_OUT_OF_ORDER, ast_channel_hangupcause_set(), ast_channel_name(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, AST_FRAME_IAX, AST_LIST_REMOVE, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_sockaddr_stringify_addr(), attempt_transmit(), iax_frame::callno, iax_frame::data, chan_iax2_pvt::error, iax_frame::final, frame_queue, ast_frame::frametype, iax2_destroy(), iax2_frame_free(), iax2_queue_frame(), iax2_sched_add(), IAX_COMMAND_TXREJ, IAX_DEFAULT_REG_EXPIRE, iaxs, iaxsl, ast_frame_subclass::integer, LOG_WARNING, max_retries, MAX_RETRY_TIME, NULL, iax_frame::oseqno, chan_iax2_pvt::owner, iax2_registry::refresh, chan_iax2_pvt::reg, REG_STATE_TIMEOUT, iax2_registry::regstate, iax_frame::retrans, iax_frame::retries, iax_frame::retrytime, send_command(), send_packet(), ast_frame::subclass, iax_frame::transfer, iax_frame::ts, update_packet(), and iax2_registry::us.

Referenced by attempt_transmit().

◆ __auth_reject()

static void __auth_reject ( const void *  nothing)
static

Definition at line 9424 of file chan_iax2.c.

9425{
9426 /* Called from IAX thread only, without iaxs lock */
9427 int callno = (int)(long)(nothing);
9428 struct iax_ie_data ied;
9429 ast_mutex_lock(&iaxsl[callno]);
9430 if (iaxs[callno]) {
9431 memset(&ied, 0, sizeof(ied));
9432 if (iaxs[callno]->authfail == IAX_COMMAND_REGREJ) {
9433 iax_ie_append_str(&ied, IAX_IE_CAUSE, "Registration Refused");
9435 } else if (iaxs[callno]->authfail == IAX_COMMAND_REJECT) {
9436 iax_ie_append_str(&ied, IAX_IE_CAUSE, "No authority found");
9438 }
9439 send_command_final(iaxs[callno], AST_FRAME_IAX, iaxs[callno]->authfail, 0, ied.buf, ied.pos, -1);
9440 }
9441 ast_mutex_unlock(&iaxsl[callno]);
9442}
#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED
Definition: causes.h:126
#define AST_CAUSE_FACILITY_REJECTED
Definition: causes.h:117
static int send_command_final(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int)
Definition: chan_iax2.c:7856
@ IAX_COMMAND_REJECT
Definition: iax2.h:57
@ IAX_COMMAND_REGREJ
Definition: iax2.h:71
#define IAX_IE_CAUSE
Definition: iax2.h:152
#define IAX_IE_CAUSECODE
Definition: iax2.h:172
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
Definition: parser.c:775
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
Definition: parser.c:770

References AST_CAUSE_FACILITY_NOT_SUBSCRIBED, AST_CAUSE_FACILITY_REJECTED, AST_FRAME_IAX, ast_mutex_lock, ast_mutex_unlock, iax_ie_data::buf, IAX_COMMAND_REGREJ, IAX_COMMAND_REJECT, iax_ie_append_byte(), iax_ie_append_str(), IAX_IE_CAUSE, IAX_IE_CAUSECODE, iaxs, iaxsl, iax_ie_data::pos, and send_command_final().

Referenced by auth_reject().

◆ __auto_congest()

static void __auto_congest ( const void *  nothing)
static

Definition at line 4782 of file chan_iax2.c.

4783{
4784 int callno = PTR_TO_CALLNO(nothing);
4786 ast_mutex_lock(&iaxsl[callno]);
4787 if (iaxs[callno]) {
4788 iaxs[callno]->initid = -1;
4789 iax2_queue_frame(callno, &f);
4790 ast_log(LOG_NOTICE, "Auto-congesting call due to slow response\n");
4791 }
4792 ast_mutex_unlock(&iaxsl[callno]);
4793}
#define PTR_TO_CALLNO(a)
Definition: chan_iax2.c:292
@ AST_CONTROL_CONGESTION
#define LOG_NOTICE

References AST_CONTROL_CONGESTION, AST_FRAME_CONTROL, ast_log, ast_mutex_lock, ast_mutex_unlock, iax2_queue_frame(), iaxs, iaxsl, chan_iax2_pvt::initid, LOG_NOTICE, and PTR_TO_CALLNO.

Referenced by auto_congest().

◆ __auto_hangup()

static void __auto_hangup ( const void *  nothing)
static

Definition at line 9473 of file chan_iax2.c.

9474{
9475 /* Called from IAX thread only, without iaxs lock */
9476 int callno = (int)(long)(nothing);
9477 struct iax_ie_data ied;
9478 ast_mutex_lock(&iaxsl[callno]);
9479 if (iaxs[callno]) {
9480 memset(&ied, 0, sizeof(ied));
9481 iax_ie_append_str(&ied, IAX_IE_CAUSE, "Timeout");
9483 send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1);
9484 }
9485 ast_mutex_unlock(&iaxsl[callno]);
9486}
#define AST_CAUSE_NO_USER_RESPONSE
Definition: causes.h:108
@ IAX_COMMAND_HANGUP
Definition: iax2.h:56

References AST_CAUSE_NO_USER_RESPONSE, AST_FRAME_IAX, ast_mutex_lock, ast_mutex_unlock, iax_ie_data::buf, IAX_COMMAND_HANGUP, iax_ie_append_byte(), iax_ie_append_str(), IAX_IE_CAUSE, IAX_IE_CAUSECODE, iaxs, iaxsl, iax_ie_data::pos, and send_command_final().

Referenced by auto_hangup().

◆ __do_deliver()

static int __do_deliver ( void *  data)
static
Note
This function assumes that iaxsl[callno] is locked when called.
IMPORTANT NOTE!!! Any time this function is used, even if iaxs[callno] was valid before calling it, it may no longer be valid after calling it. This function calls iax2_queue_frame(), which may unlock and lock the mutex associated with this callno, meaning that another thread may grab it and destroy the call.

Definition at line 3387 of file chan_iax2.c.

3388{
3389 /* Just deliver the packet by using queueing. This is called by
3390 the IAX thread with the iaxsl lock held. */
3391 struct iax_frame *fr = data;
3392 fr->retrans = -1;
3395 iax2_queue_frame(fr->callno, &fr->af);
3396 /* Free our iax frame */
3397 iax2_frame_free(fr);
3398 /* And don't run again */
3399 return 0;
3400}
#define IAX_ALREADYGONE
Definition: chan_iax2.c:507
@ AST_FRFLAG_HAS_TIMING_INFO
#define ast_test_flag64(p, flag)
Definition: utils.h:120
#define ast_clear_flag(p, flag)
Definition: utils.h:77

References iax_frame::af, ast_clear_flag, AST_FRFLAG_HAS_TIMING_INFO, ast_test_flag64, iax_frame::callno, iax_frame::data, iax2_frame_free(), iax2_queue_frame(), IAX_ALREADYGONE, iaxs, and iax_frame::retrans.

Referenced by __get_from_jb(), and schedule_delivery().

◆ __expire_registry()

static void __expire_registry ( const void *  data)
static

Definition at line 9040 of file chan_iax2.c.

9041{
9042 struct iax2_peer *peer = (struct iax2_peer *) data;
9043 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
9044
9045 if (!peer)
9046 return;
9047 if (peer->expire == -1) {
9048 /* Removed already (possibly through CLI), ignore */
9049 return;
9050 }
9051
9052 peer->expire = -1;
9053
9054 ast_debug(1, "Expiring registration for peer '%s'\n", peer->name);
9056 realtime_update_peer(peer->name, &peer->addr, 0);
9058 blob = ast_json_pack("{s: s, s: s}",
9059 "peer_status", "Unregistered",
9060 "cause", "Expired");
9062 /* modify entry in peercnts table as _not_ registered */
9063 peercnt_modify((unsigned char) 0, 0, &peer->addr);
9064 /* Reset the address */
9065 ast_sockaddr_setnull(&peer->addr);
9066 /* Reset expiry value */
9067 peer->expiry = min_reg_expire;
9068 if (!ast_test_flag64(peer, IAX_TEMPONLY))
9069 ast_db_del("IAX/Registry", peer->name);
9070 register_peer_exten(peer, 0);
9071 ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
9072 if (iax2_regfunk)
9073 iax2_regfunk(peer->name, 0);
9074
9076 unlink_peer(peer);
9077
9078 peer_unref(peer);
9079}
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
Definition: main/db.c:478
static void peercnt_modify(unsigned char reg, uint16_t limit, struct ast_sockaddr *sockaddr)
Definition: chan_iax2.c:2650
static int min_reg_expire
Definition: chan_iax2.c:359
static void register_peer_exten(struct iax2_peer *peer, int onoff)
Definition: chan_iax2.c:9002
#define IAX_RTUPDATE
Definition: chan_iax2.c:516
static int(* iax2_regfunk)(const char *username, int onoff)
Definition: chan_iax2.c:370
#define IAX_RTCACHEFRIENDS
Definition: chan_iax2.c:515
static void unlink_peer(struct iax2_peer *peer)
Definition: chan_iax2.c:9021
static struct iax2_peer * peer_unref(struct iax2_peer *peer)
Definition: chan_iax2.c:2075
static struct ast_flags64 globalflags
Definition: chan_iax2.c:482
static void realtime_update_peer(const char *peername, struct ast_sockaddr *sockaddr, time_t regtime)
Definition: chan_iax2.c:4624
#define IAX_RTAUTOCLEAR
Definition: chan_iax2.c:517
#define IAX_TEMPONLY
Definition: chan_iax2.c:500
@ AST_DEVSTATE_CACHABLE
Definition: devicestate.h:70
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
Definition: devicestate.c:510
@ AST_DEVICE_UNAVAILABLE
Definition: devicestate.h:58
@ AST_ENDPOINT_OFFLINE
Definition: endpoints.h:55
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
void ast_endpoint_blob_publish(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates and publishes a ast_endpoint_blob message.
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
#define ast_debug(level,...)
Log a DEBUG message.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
Definition: netsock2.h:138
Abstract JSON element (object, array, string, int, ...).
struct ast_sockaddr addr
Definition: chan_iax2.c:602
int expire
Definition: chan_iax2.c:614
struct ast_endpoint * endpoint
Definition: chan_iax2.c:635
int expiry
Definition: chan_iax2.c:615
const ast_string_field name
Definition: chan_iax2.c:599
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References iax2_peer::addr, ast_db_del(), ast_debug, AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_endpoint_blob_publish(), AST_ENDPOINT_OFFLINE, ast_endpoint_set_state(), ast_endpoint_state_type(), ast_json_pack(), ast_json_unref(), ast_sockaddr_setnull(), ast_test_flag64, iax2_peer::endpoint, iax2_peer::expire, iax2_peer::expiry, globalflags, iax2_regfunk, IAX_RTAUTOCLEAR, IAX_RTCACHEFRIENDS, IAX_RTUPDATE, IAX_TEMPONLY, min_reg_expire, iax2_peer::name, NULL, peer_unref(), peercnt_modify(), RAII_VAR, realtime_update_peer(), register_peer_exten(), and unlink_peer().

Referenced by expire_registry().

◆ __find_callno()

static int __find_callno ( unsigned short  callno,
unsigned short  dcallno,
struct ast_sockaddr addr,
int  new,
int  sockfd,
int  return_locked,
int  check_dcallno 
)
static
Note
Calling this function while holding another pvt lock can cause a deadlock.

Definition at line 3155 of file chan_iax2.c.

3156{
3157 int res = 0;
3158 int x;
3159 /* this call is calltoken validated as long as it is either NEW_FORCE
3160 * or NEW_ALLOW_CALLTOKEN_VALIDATED */
3161 int validated = (new > NEW_ALLOW) ? 1 : 0;
3162 char host[80];
3163
3164 if (new <= NEW_ALLOW) {
3165 if (callno) {
3166 struct chan_iax2_pvt *pvt;
3167 struct chan_iax2_pvt tmp_pvt = {
3168 .callno = dcallno,
3169 .peercallno = callno,
3170 .transfercallno = callno,
3171 /* hack!! */
3172 .frames_received = check_dcallno,
3173 };
3174
3175 ast_sockaddr_copy(&tmp_pvt.addr, addr);
3176 /* this works for finding normal call numbers not involving transfering */
3177 if ((pvt = ao2_find(iax_peercallno_pvts, &tmp_pvt, OBJ_POINTER))) {
3178 if (return_locked) {
3179 ast_mutex_lock(&iaxsl[pvt->callno]);
3180 }
3181 res = pvt->callno;
3182 ao2_ref(pvt, -1);
3183 pvt = NULL;
3184 return res;
3185 }
3186 /* this searches for transfer call numbers that might not get caught otherwise */
3187 memset(&tmp_pvt.addr, 0, sizeof(tmp_pvt.addr));
3188 ast_sockaddr_copy(&tmp_pvt.transfer, addr);
3189 if ((pvt = ao2_find(iax_transfercallno_pvts, &tmp_pvt, OBJ_POINTER))) {
3190 if (return_locked) {
3191 ast_mutex_lock(&iaxsl[pvt->callno]);
3192 }
3193 res = pvt->callno;
3194 ao2_ref(pvt, -1);
3195 pvt = NULL;
3196 return res;
3197 }
3198 }
3199 /* This will occur on the first response to a message that we initiated,
3200 * such as a PING. */
3201 if (dcallno) {
3202 ast_mutex_lock(&iaxsl[dcallno]);
3203 }
3204 if (callno && dcallno && iaxs[dcallno] && !iaxs[dcallno]->peercallno && match(addr, callno, dcallno, iaxs[dcallno], check_dcallno)) {
3205 iaxs[dcallno]->peercallno = callno;
3206 res = dcallno;
3207 store_by_peercallno(iaxs[dcallno]);
3208 if (!res || !return_locked) {
3209 ast_mutex_unlock(&iaxsl[dcallno]);
3210 }
3211 return res;
3212 }
3213 if (dcallno) {
3214 ast_mutex_unlock(&iaxsl[dcallno]);
3215 }
3216 }
3217 if (!res && (new >= NEW_ALLOW)) {
3219
3220 /* It may seem odd that we look through the peer list for a name for
3221 * this *incoming* call. Well, it is weird. However, users don't
3222 * have an IP address/port number that we can match against. So,
3223 * this is just checking for a peer that has that IP/port and
3224 * assuming that we have a user of the same name. This isn't always
3225 * correct, but it will be changed if needed after authentication. */
3226 if (!iax2_getpeername(*addr, host, sizeof(host)))
3227 snprintf(host, sizeof(host), "%s", ast_sockaddr_stringify(addr));
3228
3229 if (peercnt_add(addr)) {
3230 /* This address has hit its callnumber limit. When the limit
3231 * is reached, the connection is not added to the peercnts table.*/
3232 return 0;
3233 }
3234
3235 if (get_unused_callno(CALLNO_TYPE_NORMAL, validated, &entry)) {
3236 /* since we ran out of space, remove the peercnt
3237 * entry we added earlier */
3239 ast_log(LOG_WARNING, "No more space\n");
3240 return 0;
3241 }
3243 ast_mutex_lock(&iaxsl[x]);
3244
3245 iaxs[x] = new_iax(addr, host);
3246 if (iaxs[x]) {
3247 if (iaxdebug)
3248 ast_debug(1, "Creating new call structure %d\n", x);
3249 iaxs[x]->callno_entry = entry;
3250 iaxs[x]->sockfd = sockfd;
3252 iaxs[x]->peercallno = callno;
3253 iaxs[x]->callno = x;
3256 iaxs[x]->pingid = iax2_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
3257 iaxs[x]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
3258 iaxs[x]->amaflags = amaflags;
3264
3265 if (iaxs[x]->peercallno) {
3267 }
3268 } else {
3269 ast_log(LOG_WARNING, "Out of resources\n");
3272 return 0;
3273 }
3274 if (!return_locked)
3276 res = x;
3277 }
3278 return res;
3279}
#define OBJ_POINTER
Definition: astobj2.h:1150
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static int send_ping(const void *data)
Definition: chan_iax2.c:1787
static int replace_callno(const void *obj)
Definition: chan_iax2.c:3029
static struct chan_iax2_pvt * new_iax(struct ast_sockaddr *addr, const char *host)
Definition: chan_iax2.c:2290
static char default_parkinglot[AST_MAX_CONTEXT]
Definition: chan_iax2.c:322
static int ping_time
Definition: chan_iax2.c:333
#define IAX_NOTRANSFER
Definition: chan_iax2.c:502
static int iax2_getpeername(struct ast_sockaddr addr, char *host, int len)
Definition: chan_iax2.c:2092
#define CALLNO_ENTRY_GET_CALLNO(a)
Definition: chan_iax2.c:955
static struct ao2_container * iax_transfercallno_pvts
Another container of iax2_pvt structures.
Definition: chan_iax2.c:1218
#define IAX_RECVCONNECTEDLINE
Definition: chan_iax2.c:526
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Definition: chan_iax2.c:2362
#define IAX_FORCE_ENCRYPT
Definition: chan_iax2.c:527
#define IAX_SENDCONNECTEDLINE
Definition: chan_iax2.c:525
static int get_unused_callno(enum callno_type type, int validated, callno_entry *entry)
Definition: chan_iax2.c:2952
static int send_lagrq(const void *data)
Definition: chan_iax2.c:1851
static int peercnt_add(struct ast_sockaddr *addr)
Definition: chan_iax2.c:2678
#define DEFAULT_RETRY_TIME
Definition: chan_iax2.c:297
static int lagrq_time
Definition: chan_iax2.c:334
static void store_by_peercallno(struct chan_iax2_pvt *pvt)
Definition: chan_iax2.c:2465
static int peercnt_remove_by_addr(struct ast_sockaddr *addr)
Definition: chan_iax2.c:2769
#define CALLNO_ENTRY_TO_PTR(a)
Definition: chan_iax2.c:951
#define IAX_USEJITTERBUF
Definition: chan_iax2.c:503
#define IAX_TRANSFERMEDIA
Definition: chan_iax2.c:520
static int iaxdebug
Definition: chan_iax2.c:461
uint16_t callno_entry
Definition: chan_iax2.c:740
static int amaflags
Definition: chan_iax2.c:476
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:473
static char mohsuggest[MAX_MUSICCLASS]
Definition: chan_iax2.c:475
static char mohinterpret[MAX_MUSICCLASS]
Definition: chan_iax2.c:474
static struct ao2_container * iax_peercallno_pvts
Another container of iax2_pvt structures.
Definition: chan_iax2.c:1202
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Definition: netsock2.h:256
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
Definition: netsock2.h:167
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
unsigned int pingtime
Definition: chan_iax2.c:772
struct ast_sockaddr transfer
Definition: chan_iax2.c:894
unsigned short peercallno
Definition: chan_iax2.c:786
unsigned short callno
Definition: chan_iax2.c:782
const ast_string_field parkinglot
Definition: chan_iax2.c:861
const ast_string_field host
Definition: chan_iax2.c:861
callno_entry callno_entry
Definition: chan_iax2.c:784
Definition: search.h:40
#define ast_copy_flags64(dest, src, flagz)
Definition: utils.h:141

References accountcode, chan_iax2_pvt::addr, amaflags, chan_iax2_pvt::amaflags, ao2_find, ao2_ref, ast_copy_flags64, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_sockaddr_copy(), ast_sockaddr_stringify(), ast_string_field_set, chan_iax2_pvt::callno, chan_iax2_pvt::callno_entry, CALLNO_ENTRY_GET_CALLNO, CALLNO_ENTRY_TO_PTR, CALLNO_TYPE_NORMAL, default_parkinglot, DEFAULT_RETRY_TIME, chan_iax2_pvt::expiry, get_unused_callno(), globalflags, chan_iax2_pvt::host, iax2_getpeername(), iax2_sched_add(), IAX_FORCE_ENCRYPT, IAX_NOTRANSFER, iax_peercallno_pvts, IAX_RECVCONNECTEDLINE, IAX_SENDCONNECTEDLINE, iax_transfercallno_pvts, IAX_TRANSFERMEDIA, IAX_USEJITTERBUF, iaxdebug, iaxs, iaxsl, chan_iax2_pvt::lagid, lagrq_time, LOG_WARNING, match(), min_reg_expire, mohinterpret, mohsuggest, NEW_ALLOW, new_iax(), NULL, OBJ_POINTER, chan_iax2_pvt::parkinglot, chan_iax2_pvt::peercallno, peercnt_add(), peercnt_remove_by_addr(), ping_time, chan_iax2_pvt::pingid, chan_iax2_pvt::pingtime, replace_callno(), send_lagrq(), send_ping(), chan_iax2_pvt::sockfd, store_by_peercallno(), and chan_iax2_pvt::transfer.

Referenced by find_callno(), and find_callno_locked().

◆ __get_from_jb()

static void __get_from_jb ( const void *  p)
static

Definition at line 4172 of file chan_iax2.c.

4173{
4174 int callno = PTR_TO_CALLNO(p);
4175 struct chan_iax2_pvt *pvt = NULL;
4176 struct iax_frame *fr;
4177 jb_frame frame;
4178 int ret;
4179 long ms;
4180 long next;
4181 struct timeval now = ast_tvnow();
4182 struct ast_format *voicefmt;
4183
4184 /* Make sure we have a valid private structure before going on */
4185 ast_mutex_lock(&iaxsl[callno]);
4186 pvt = iaxs[callno];
4187 if (!pvt) {
4188 /* No go! */
4189 ast_mutex_unlock(&iaxsl[callno]);
4190 return;
4191 }
4192
4193 pvt->jbid = -1;
4194
4195 /* round up a millisecond since ast_sched_runq does; */
4196 /* prevents us from spinning while waiting for our now */
4197 /* to catch up with runq's now */
4198 now.tv_usec += 1000;
4199
4200 ms = ast_tvdiff_ms(now, pvt->rxcore);
4201 if (ms >= (next = jb_next(pvt->jb))) {
4203 if (!voicefmt) {
4204 /* pvt->voiceformat won't be set if we haven't received any voice frames yet.
4205 * In this case, fall back to using the format negotiated during call setup,
4206 * so we don't stall the jitterbuffer completely. */
4208 }
4209 if (!voicefmt) {
4210 /* Really shouldn't happen, but if it does, should be looked into */
4211 ast_log(LOG_WARNING, "No voice format and no peer format available on %s, backlogging frame\n", ast_channel_name(pvt->owner));
4212 goto cleanup; /* Don't crash if there's no voice format */
4213 }
4214 ret = jb_get(pvt->jb, &frame, ms, ast_format_get_default_ms(voicefmt));
4215 switch(ret) {
4216 case JB_OK:
4217 fr = frame.data;
4218 __do_deliver(fr);
4219 /* __do_deliver() can cause the call to disappear */
4220 pvt = iaxs[callno];
4221 break;
4222 case JB_INTERP:
4223 {
4224 struct ast_frame af = { 0, };
4225
4226 /* create an interpolation frame */
4228 af.subclass.format = voicefmt;
4229 af.samples = frame.ms * (ast_format_get_sample_rate(voicefmt) / 1000);
4230 af.src = "IAX2 JB interpolation";
4231 af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000));
4233
4234 /* queue the frame: For consistency, we would call __do_deliver here, but __do_deliver wants an iax_frame,
4235 * which we'd need to malloc, and then it would free it. That seems like a drag */
4236 if (!ast_test_flag64(iaxs[callno], IAX_ALREADYGONE)) {
4237 iax2_queue_frame(callno, &af);
4238 /* iax2_queue_frame() could cause the call to disappear */
4239 pvt = iaxs[callno];
4240 }
4241 }
4242 break;
4243 case JB_DROP:
4244 iax2_frame_free(frame.data);
4245 break;
4246 case JB_NOFRAME:
4247 case JB_EMPTY:
4248 /* do nothing */
4249 break;
4250 default:
4251 /* shouldn't happen */
4252 break;
4253 }
4254 }
4255cleanup:
4256 if (pvt)
4257 update_jbsched(pvt);
4258 ast_mutex_unlock(&iaxsl[callno]);
4259}
static int __do_deliver(void *data)
Definition: chan_iax2.c:3387
static void update_jbsched(struct chan_iax2_pvt *pvt)
Definition: chan_iax2.c:4155
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379
unsigned int ast_format_get_default_ms(const struct ast_format *format)
Get the default framing size (in milliseconds) for a format.
Definition: format.c:359
struct ast_format * ast_format_compatibility_bitfield2format(uint64_t bitfield)
Convert a bitfield to its respective format structure.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
@ AST_FRAME_VOICE
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl)
get a frame for time now (receiver's time) return value is one of JB_OK: You've got frame!...
Definition: jitterbuf.c:785
long jb_next(jitterbuf *jb)
when is the next frame due out, in receiver's time (0=EMPTY) This value may change as frames are adde...
Definition: jitterbuf.c:767
@ JB_EMPTY
Definition: jitterbuf.h:52
@ JB_DROP
Definition: jitterbuf.h:55
@ JB_NOFRAME
Definition: jitterbuf.h:53
@ JB_INTERP
Definition: jitterbuf.h:54
@ JB_OK
Definition: jitterbuf.h:51
static void * cleanup(void *unused)
Definition: pbx_realtime.c:124
Definition of a media format.
Definition: format.c:43
struct ast_format * format
struct timeval delivery
struct ast_frame * next
const char * src
struct timeval rxcore
Definition: chan_iax2.c:798
iax2_format voiceformat
Definition: chan_iax2.c:748
iax2_format peerformat
Definition: chan_iax2.c:792
jitterbuf * jb
Definition: chan_iax2.c:800
struct iax_frame * next
Definition: parser.h:140
long ms
Definition: jitterbuf.h:104
void * data
Definition: jitterbuf.h:102
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Definition: time.h:282
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2282
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159

References __do_deliver(), ast_channel_name(), ast_format_compatibility_bitfield2format(), ast_format_get_default_ms(), ast_format_get_sample_rate(), AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_samp2tv(), ast_test_flag64, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), cleanup(), jb_frame::data, ast_frame::delivery, ast_frame_subclass::format, ast_frame::frametype, iax2_frame_free(), iax2_queue_frame(), IAX_ALREADYGONE, iaxs, iaxsl, chan_iax2_pvt::jb, JB_DROP, JB_EMPTY, jb_get(), JB_INTERP, jb_next(), JB_NOFRAME, JB_OK, chan_iax2_pvt::jbid, LOG_WARNING, jb_frame::ms, iax_frame::next, ast_frame::next, NULL, ast_frame::offset, chan_iax2_pvt::owner, chan_iax2_pvt::peerformat, PTR_TO_CALLNO, chan_iax2_pvt::rxcore, ast_frame::samples, ast_frame::src, ast_frame::subclass, update_jbsched(), and chan_iax2_pvt::voiceformat.

Referenced by get_from_jb().

◆ __iax2_do_register_s()

static void __iax2_do_register_s ( const void *  data)
static

Definition at line 8683 of file chan_iax2.c.

8684{
8685 struct iax2_registry *reg = (struct iax2_registry *)data;
8686
8687 if (ast_sockaddr_isnull(&reg->addr)) {
8688 reg->addr.ss.ss_family = AST_AF_UNSPEC;
8689 ast_dnsmgr_lookup(reg->hostname, &reg->addr, &reg->dnsmgr, srvlookup ? "_iax._udp" : NULL);
8690 if (!ast_sockaddr_port(&reg->addr)) {
8691 ast_sockaddr_set_port(&reg->addr, reg->port);
8692 } else {
8693 reg->port = ast_sockaddr_port(&reg->addr);
8694 }
8695 }
8696
8697 reg->expire = -1;
8698 iax2_do_register(reg);
8699}
static int iax2_do_register(struct iax2_registry *reg)
Definition: chan_iax2.c:12304
static int srvlookup
Definition: chan_iax2.c:362
int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
Allocate and initialize a DNS manager entry.
Definition: dnsmgr.c:191
@ AST_AF_UNSPEC
Definition: netsock2.h:54
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
Definition: netsock2.h:517
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
Definition: netsock2.h:127
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
Definition: netsock2.h:532
struct sockaddr_storage ss
Definition: netsock2.h:98
struct ast_sockaddr addr
Definition: chan_iax2.c:686
struct ast_dnsmgr_entry * dnsmgr
Definition: chan_iax2.c:695
char hostname[]
Definition: chan_iax2.c:698

References iax2_registry::addr, AST_AF_UNSPEC, ast_dnsmgr_lookup(), ast_sockaddr_isnull(), ast_sockaddr_port, ast_sockaddr_set_port, iax2_registry::dnsmgr, iax2_registry::expire, iax2_registry::hostname, iax2_do_register(), NULL, iax2_registry::port, srvlookup, and ast_sockaddr::ss.

Referenced by iax2_do_register_s().

◆ __iax2_poke_noanswer()

static void __iax2_poke_noanswer ( const void *  data)
static

Definition at line 12485 of file chan_iax2.c.

12486{
12487 struct iax2_peer *peer = (struct iax2_peer *)data;
12488 int callno;
12489
12490 if (peer->lastms > -1) {
12491 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
12492
12493 ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE! Time: %d\n", peer->name, peer->lastms);
12495 blob = ast_json_pack("{s: s, s: i}",
12496 "peer_status", "Unreachable",
12497 "time", peer->lastms);
12499 ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
12500 }
12501 if ((callno = peer->callno) > 0) {
12505 }
12506 peer->callno = 0;
12507 peer->lastms = -1;
12508 /* Try again quickly */
12510 if (peer->pokeexpire == -1)
12511 peer_unref(peer);
12512}
static int iax2_poke_peer_s(const void *data)
Definition: chan_iax2.c:9540
static struct iax2_peer * peer_ref(struct iax2_peer *peer)
Definition: chan_iax2.c:2069
int callno
Definition: chan_iax2.c:619
int pokefreqnotok
Definition: chan_iax2.c:625
int lastms
Definition: chan_iax2.c:621
int pokeexpire
Definition: chan_iax2.c:620

References AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_endpoint_blob_publish(), AST_ENDPOINT_OFFLINE, ast_endpoint_set_state(), ast_endpoint_state_type(), ast_json_pack(), ast_json_unref(), ast_log, ast_mutex_lock, ast_mutex_unlock, iax2_peer::callno, iax2_peer::endpoint, iax2_destroy(), iax2_poke_peer_s(), iax2_sched_add(), iaxsl, iax2_peer::lastms, LOG_NOTICE, iax2_peer::name, NULL, peer_ref(), peer_unref(), iax2_peer::pokeexpire, iax2_peer::pokefreqnotok, and RAII_VAR.

Referenced by iax2_poke_noanswer().

◆ __iax2_poke_peer_s()

static void __iax2_poke_peer_s ( const void *  data)
static

Definition at line 9533 of file chan_iax2.c.

9534{
9535 struct iax2_peer *peer = (struct iax2_peer *)data;
9536 iax2_poke_peer(peer, 0);
9537 peer_unref(peer);
9538}
static int iax2_poke_peer(struct iax2_peer *peer, int heldcall)
Definition: chan_iax2.c:12535

References iax2_poke_peer(), and peer_unref().

Referenced by iax2_poke_peer_s().

◆ __iax2_show_peers()

static int __iax2_show_peers ( int  fd,
int *  total,
struct mansession s,
const int  argc,
const char *const  argv[] 
)
static

Definition at line 7046 of file chan_iax2.c.

7047{
7048 struct show_peers_context cont = {
7049 .havepattern = 0,
7050 .idtext = "",
7051 .registeredonly = 0,
7052
7053 .peerlist = 0,
7054
7055 .total_peers = 0,
7056 .online_peers = 0,
7057 .offline_peers = 0,
7058 .unmonitored_peers = 0,
7059 };
7060
7061 struct ao2_iterator i;
7062
7063 struct iax2_peer *peer = NULL;
7064
7065 switch (argc) {
7066 case 6:
7067 if (!strcasecmp(argv[3], "registered"))
7068 cont.registeredonly = 1;
7069 else
7070 return RESULT_SHOWUSAGE;
7071 if (!strcasecmp(argv[4], "like")) {
7072 if (regcomp(&cont.regexbuf, argv[5], REG_EXTENDED | REG_NOSUB))
7073 return RESULT_SHOWUSAGE;
7074 cont.havepattern = 1;
7075 } else
7076 return RESULT_SHOWUSAGE;
7077 break;
7078 case 5:
7079 if (!strcasecmp(argv[3], "like")) {
7080 if (regcomp(&cont.regexbuf, argv[4], REG_EXTENDED | REG_NOSUB))
7081 return RESULT_SHOWUSAGE;
7082 cont.havepattern = 1;
7083 } else
7084 return RESULT_SHOWUSAGE;
7085 break;
7086 case 4:
7087 if (!strcasecmp(argv[3], "registered")) {
7088 cont.registeredonly = 1;
7089 } else {
7090 return RESULT_SHOWUSAGE;
7091 }
7092 break;
7093 case 3:
7094 break;
7095 default:
7096 return RESULT_SHOWUSAGE;
7097 }
7098
7099
7100 if (!s) {
7101 ast_cli(fd, PEERS_FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", "Description");
7102 }
7103
7104 i = ao2_iterator_init(peers, 0);
7105 for (; (peer = ao2_iterator_next(&i)); peer_unref(peer)) {
7106
7107 if (cont.registeredonly && ast_sockaddr_isnull(&peer->addr)) {
7108 continue;
7109 }
7110 if (cont.havepattern && regexec(&cont.regexbuf, peer->name, 0, NULL, 0)) {
7111 continue;
7112 }
7113
7114 _iax2_show_peers_one(fd, s, &cont, peer);
7115
7116 }
7118
7119 if (!s) {
7120 ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]\n",
7122 }
7123
7124 if (cont.havepattern) {
7125 regfree(&cont.regexbuf);
7126 }
7127
7128 if (total) {
7129 *total = cont.total_peers;
7130 }
7131
7132 return RESULT_SUCCESS;
7133
7134}
#define ao2_iterator_next(iter)
Definition: astobj2.h:1911
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define PEERS_FORMAT2
Definition: chan_iax2.c:6942
static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers_context *cont, struct iax2_peer *peer)
Definition: chan_iax2.c:6945
#define RESULT_SHOWUSAGE
Definition: cli.h:41
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
#define RESULT_SUCCESS
Definition: cli.h:40
static int total
Definition: res_adsi.c:970
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821

References _iax2_show_peers_one(), iax2_peer::addr, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_cli(), ast_sockaddr_isnull(), show_peers_context::havepattern, iax2_peer::name, NULL, show_peers_context::offline_peers, show_peers_context::online_peers, peer_unref(), PEERS_FORMAT2, show_peers_context::regexbuf, show_peers_context::registeredonly, RESULT_SHOWUSAGE, RESULT_SUCCESS, total, show_peers_context::total_peers, and show_peers_context::unmonitored_peers.

Referenced by handle_cli_iax2_show_peers(), and manager_iax2_show_peers().

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 15136 of file chan_iax2.c.

◆ __schedule_action()

static int __schedule_action ( void(*)(const void *data)  func,
const void *  data,
const char *  funcname 
)
static

Definition at line 1699 of file chan_iax2.c.

1700{
1701 struct iax2_thread *thread;
1702 static time_t lasterror;
1703 time_t t;
1704
1706 if (thread != NULL) {
1707 thread->schedfunc = func;
1708 thread->scheddata = data;
1709 thread->iostate = IAX_IOSTATE_SCHEDREADY;
1710#ifdef DEBUG_SCHED_MULTITHREAD
1711 ast_copy_string(thread->curfunc, funcname, sizeof(thread->curfunc));
1712#endif
1713 signal_condition(&thread->lock, &thread->cond);
1714 return 0;
1715 }
1716 time(&t);
1717 if (t != lasterror) {
1718 lasterror = t;
1719 ast_debug(1, "Out of idle IAX2 threads for scheduling! (%s)\n", funcname);
1720 }
1721
1722 return -1;
1723}
pthread_t thread
Definition: app_sla.c:329
static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
Definition: chan_iax2.c:1158
static struct iax2_thread * find_idle_thread(void)
Definition: chan_iax2.c:1632
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ast_copy_string(), ast_debug, find_idle_thread(), IAX_IOSTATE_SCHEDREADY, NULL, signal_condition(), and thread.

◆ __send_command()

static int __send_command ( struct chan_iax2_pvt i,
char  type,
int  command,
unsigned int  ts,
const unsigned char *  data,
int  datalen,
int  seqno,
int  now,
int  transfer,
int  final 
)
static

Definition at line 7812 of file chan_iax2.c.

7814{
7815 struct ast_frame f = { 0, };
7816 int res = 0;
7817
7818 f.frametype = type;
7819 f.subclass.integer = command;
7820 f.datalen = datalen;
7821 f.src = __FUNCTION__;
7822 f.data.ptr = (void *) data;
7823
7824 if ((res = queue_signalling(i, &f)) <= 0) {
7825 return res;
7826 }
7827
7828 return iax2_send(i, &f, ts, seqno, now, transfer, final);
7829}
static int queue_signalling(struct chan_iax2_pvt *pvt, struct ast_frame *f)
All frames other than that of type AST_FRAME_IAX must be held until we have received a destination ca...
Definition: chan_iax2.c:2218
static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned int ts, int seqno, int now, int transfer, int final)
Definition: chan_iax2.c:6643
static const char type[]
Definition: chan_ooh323.c:109
static int transfer(void *data)
Definition: chan_pjsip.c:2133
union ast_frame::@226 data

References ast_frame::data, ast_frame::datalen, ast_frame::frametype, iax2_send(), ast_frame_subclass::integer, ast_frame::ptr, queue_signalling(), ast_frame::seqno, ast_frame::src, ast_frame::subclass, transfer(), ast_frame::ts, and type.

Referenced by send_command(), send_command_final(), send_command_immediate(), and send_command_transfer().

◆ __send_lagrq()

static void __send_lagrq ( const void *  data)
static

Definition at line 1827 of file chan_iax2.c.

1828{
1829 int callno = PTR_TO_CALLNO(data);
1830
1831 if (iax2_lock_callno_unless_destroyed(callno) == 0) {
1832 ast_debug(3, "Hangup initiated on call %d, aborting __send_lagrq\n", callno);
1833 return;
1834 }
1835
1836 /* Mark lagid as invalid scheduler id. */
1837 iaxs[callno]->lagid = -1;
1838
1839 /* callno is now locked. */
1840 if (iaxs[callno]->peercallno) {
1841 /* Send LAGRQ packet. */
1843
1844 /* Schedule sending next lagrq. */
1845 iaxs[callno]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, data);
1846 }
1847
1848 ast_mutex_unlock(&iaxsl[callno]);
1849}
static int iax2_lock_callno_unless_destroyed(int callno)
Acquire the iaxsl[callno] if call exists and not having ongoing hangup.
Definition: chan_iax2.c:1745
@ IAX_COMMAND_LAGRQ
Definition: iax2.h:62

References ast_debug, AST_FRAME_IAX, ast_mutex_unlock, iax2_thread::callno, iax2_lock_callno_unless_destroyed(), iax2_sched_add(), IAX_COMMAND_LAGRQ, iaxs, iaxsl, chan_iax2_pvt::lagid, lagrq_time, NULL, PTR_TO_CALLNO, send_command(), and send_lagrq().

Referenced by send_lagrq().

◆ __send_ping()

static void __send_ping ( const void *  data)
static

Definition at line 1763 of file chan_iax2.c.

1764{
1765 int callno = PTR_TO_CALLNO(data);
1766
1767 if (iax2_lock_callno_unless_destroyed(callno) == 0) {
1768 ast_debug(3, "Hangup initiated on call %d, aborting __send_ping\n", callno);
1769 return;
1770 }
1771
1772 /* Mark pingid as invalid scheduler id. */
1773 iaxs[callno]->pingid = -1;
1774
1775 /* callno is now locked. */
1776 if (iaxs[callno]->peercallno) {
1777 /* Send PING packet. */
1778 send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_PING, 0, NULL, 0, -1);
1779
1780 /* Schedule sending next ping. */
1781 iaxs[callno]->pingid = iax2_sched_add(sched, ping_time * 1000, send_ping, data);
1782 }
1783
1784 ast_mutex_unlock(&iaxsl[callno]);
1785}
@ IAX_COMMAND_PING
Definition: iax2.h:53

References ast_debug, AST_FRAME_IAX, ast_mutex_unlock, iax2_thread::callno, iax2_lock_callno_unless_destroyed(), iax2_sched_add(), IAX_COMMAND_PING, iaxs, iaxsl, NULL, ping_time, chan_iax2_pvt::pingid, PTR_TO_CALLNO, send_command(), and send_ping().

Referenced by send_ping().

◆ __unload_module()

static int __unload_module ( void  )
static

Definition at line 14763 of file chan_iax2.c.

14764{
14765 int x;
14766
14769
14770 ast_manager_unregister("IAXpeers");
14771 ast_manager_unregister("IAXpeerlist");
14772 ast_manager_unregister("IAXnetstats");
14773 ast_manager_unregister("IAXregistry");
14778
14780 pthread_cancel(netthreadid);
14781 pthread_kill(netthreadid, SIGURG);
14782 pthread_join(netthreadid, NULL);
14783 }
14784
14785 for (x = 0; x < ARRAY_LEN(iaxs); x++) {
14786 if (iaxs[x]) {
14787 iax2_destroy(x);
14788 }
14789 }
14790
14791 /* Call for all threads to halt */
14795
14798 for (x = 0; x < ARRAY_LEN(iaxs); x++) {
14799 if (iaxs[x]) {
14800 iax2_destroy(x);
14801 }
14802 }
14803 ast_manager_unregister( "IAXpeers" );
14804 ast_manager_unregister( "IAXpeerlist" );
14805 ast_manager_unregister( "IAXnetstats" );
14806 ast_manager_unregister( "IAXregistry" );
14811 delete_users();
14814
14815 for (x = 0; x < ARRAY_LEN(iaxsl); x++) {
14817 }
14818
14819 ao2_ref(peers, -1);
14820 ao2_ref(users, -1);
14825 if (timer) {
14827 timer = NULL;
14828 }
14830
14833 sched = NULL;
14834 ao2_ref(peercnts, -1);
14835
14837 ast_unload_realtime("iaxpeers");
14838
14841 return 0;
14842}
static struct ao2_container * peercnts
Definition: chan_iax2.c:1006
static struct ast_channel_tech iax2_tech
Definition: chan_iax2.c:1341
static int peercnt_remove_cb(const void *obj)
Definition: chan_iax2.c:2755
static char regcontext[AST_MAX_CONTEXT]
Definition: chan_iax2.c:325
static struct ao2_container * callno_limits
Definition: chan_iax2.c:1009
static struct ast_netsock_list * netsock
Definition: chan_iax2.c:366
static struct ast_netsock_list * outsock
Definition: chan_iax2.c:367
static void acl_change_stasis_unsubscribe(void)
Definition: chan_iax2.c:1526
static struct ast_switch iax2_switch
Definition: chan_iax2.c:14705
static char * papp
Definition: chan_iax2.c:12412
static struct ast_taskprocessor * transmit_processor
Definition: chan_iax2.c:982
static struct ast_timer * timer
Definition: chan_iax2.c:364
static pthread_t netthreadid
Definition: chan_iax2.c:484
static void network_change_stasis_unsubscribe(void)
Definition: chan_iax2.c:1511
static struct ao2_container * calltoken_ignores
Definition: chan_iax2.c:1012
static void delete_users(void)
Definition: chan_iax2.c:13569
static void cleanup_thread_list(void *head)
Definition: chan_iax2.c:14743
static struct ast_cli_entry cli_iax2[]
Definition: chan_iax2.c:14715
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:570
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
void iax_firmware_unload(void)
Definition: firmware.c:250
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7606
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
Definition: main/config.c:3583
#define AST_PTHREADT_NULL
Definition: lock.h:66
#define ast_mutex_destroy(a)
Definition: lock.h:188
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
int ast_netsock_release(struct ast_netsock_list *list)
Definition: netsock.c:85
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
Definition: pbx.c:8205
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
Definition: pbx_switch.c:76
int iax_provision_unload(void)
Definition: provision.c:517
void ast_sched_clean_by_callback(struct ast_sched_context *con, ast_sched_cb match, ast_sched_cb cleanup_cb)
Clean all scheduled events with matching callback.
Definition: sched.c:409
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:271
struct ast_format_cap * capabilities
Definition: channel.h:652
list of users found in the config file
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
Definition: timing.c:154
#define ARRAY_LEN(a)
Definition: utils.h:666

References acl_change_stasis_unsubscribe(), ao2_ref, ARRAY_LEN, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_context_destroy_by_name(), ast_manager_unregister(), ast_mutex_destroy, ast_netsock_release(), AST_PTHREADT_NULL, ast_sched_clean_by_callback(), ast_sched_context_destroy(), ast_taskprocessor_unreference(), ast_timer_close(), ast_unload_realtime(), ast_unregister_application(), ast_unregister_switch(), callno_limits, calltoken_ignores, ast_channel_tech::capabilities, cleanup_thread_list(), cli_iax2, delete_users(), iax2_destroy(), iax2_switch, iax2_tech, iax_firmware_unload(), iax_peercallno_pvts, iax_provision_unload(), iax_transfercallno_pvts, iaxs, iaxsl, netsock, netthreadid, network_change_stasis_unsubscribe(), NULL, outsock, papp, peercnt_remove_cb(), peercnts, regcontext, timer, and transmit_processor.

Referenced by load_module(), and unload_module().

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 15136 of file chan_iax2.c.

◆ _iax2_show_peers_one()

static void _iax2_show_peers_one ( int  fd,
struct mansession s,
struct show_peers_context cont,
struct iax2_peer peer 
)
static

Definition at line 6945 of file chan_iax2.c.

6946{
6947 char name[256] = "";
6948 char status[64];
6949 int retstatus;
6950 struct ast_str *encmethods = ast_str_alloca(256);
6951
6952 char *tmp_host, *tmp_mask, *tmp_port;
6953
6954 tmp_host = ast_strdupa(ast_sockaddr_stringify_addr(&peer->addr));
6955 tmp_mask = ast_strdupa(ast_sockaddr_stringify_addr(&peer->mask));
6956 tmp_port = ast_strdupa(ast_sockaddr_stringify_port(&peer->addr));
6957
6958 if (!ast_strlen_zero(peer->username)) {
6959 snprintf(name, sizeof(name), "%s/%s", peer->name, peer->username);
6960 } else {
6961 ast_copy_string(name, peer->name, sizeof(name));
6962 }
6963
6964 encmethods_to_str(peer->encmethods, &encmethods);
6965 retstatus = peer_status(peer, status, sizeof(status));
6966 if (retstatus > 0) {
6967 cont->online_peers++;
6968 } else if (!retstatus) {
6969 cont->offline_peers++;
6970 } else {
6971 cont->unmonitored_peers++;
6972 }
6973
6974 if (s) {
6975 if (cont->peerlist) { /* IAXpeerlist */
6976 astman_append(s,
6977 "Event: PeerEntry\r\n%s"
6978 "Channeltype: IAX\r\n",
6979 cont->idtext);
6980 if (!ast_strlen_zero(peer->username)) {
6981 astman_append(s,
6982 "ObjectName: %s\r\n"
6983 "ObjectUsername: %s\r\n",
6984 peer->name,
6985 peer->username);
6986 } else {
6987 astman_append(s,
6988 "ObjectName: %s\r\n",
6989 name);
6990 }
6991 } else { /* IAXpeers */
6992 astman_append(s,
6993 "Event: PeerEntry\r\n%s"
6994 "Channeltype: IAX2\r\n"
6995 "ObjectName: %s\r\n",
6996 cont->idtext,
6997 name);
6998 }
6999 astman_append(s,
7000 "ChanObjectType: peer\r\n"
7001 "IPaddress: %s\r\n",
7002 tmp_host);
7003 if (cont->peerlist) { /* IAXpeerlist */
7004 astman_append(s,
7005 "Mask: %s\r\n"
7006 "Port: %s\r\n",
7007 tmp_mask,
7008 tmp_port);
7009 } else { /* IAXpeers */
7010 astman_append(s,
7011 "IPport: %s\r\n",
7012 tmp_port);
7013 }
7014 astman_append(s,
7015 "Dynamic: %s\r\n"
7016 "Trunk: %s\r\n"
7017 "Encryption: %s\r\n"
7018 "Status: %s\r\n",
7019 ast_test_flag64(peer, IAX_DYNAMIC) ? "yes" : "no",
7020 ast_test_flag64(peer, IAX_TRUNK) ? "yes" : "no",
7021 peer->encmethods ? ast_str_buffer(encmethods) : "no",
7022 status);
7023 if (cont->peerlist) { /* IAXpeerlist */
7024 astman_append(s, "\r\n");
7025 } else { /* IAXpeers */
7026 astman_append(s,
7027 "Description: %s\r\n\r\n",
7028 peer->description);
7029 }
7030 } else {
7032 name,
7033 tmp_host,
7034 ast_test_flag64(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
7035 tmp_mask,
7036 tmp_port,
7037 ast_test_flag64(peer, IAX_TRUNK) ? "(T)" : " ",
7038 peer->encmethods ? "(E)" : " ",
7039 status,
7040 peer->description);
7041 }
7042
7043 cont->total_peers++;
7044}
jack_status_t status
Definition: app_jack.c:146
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define IAX_TRUNK
Definition: chan_iax2.c:501
static void encmethods_to_str(int e, struct ast_str **buf)
Definition: chan_iax2.c:1797
static int peer_status(struct iax2_peer *peer, char *status, int statuslen)
peer_status: Report Peer status in character string
Definition: chan_iax2.c:3839
#define IAX_DYNAMIC
Definition: chan_iax2.c:504
#define PEERS_FORMAT
Definition: chan_iax2.c:6943
static const char name[]
Definition: format_mp3.c:68
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:1890
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
Definition: netsock2.h:358
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_str_alloca(init_len)
Definition: strings.h:848
Support for dynamic strings.
Definition: strings.h:623
const ast_string_field username
Definition: chan_iax2.c:599
const ast_string_field description
Definition: chan_iax2.c:599
struct ast_sockaddr mask
Definition: chan_iax2.c:605
int encmethods
Definition: chan_iax2.c:612
char idtext[256]
Definition: chan_iax2.c:6933

References iax2_peer::addr, ast_cli(), ast_copy_string(), ast_sockaddr_stringify_addr(), ast_sockaddr_stringify_port(), ast_str_alloca, ast_str_buffer(), ast_strdupa, ast_strlen_zero(), ast_test_flag64, astman_append(), iax2_peer::description, iax2_peer::encmethods, encmethods_to_str(), IAX_DYNAMIC, IAX_TRUNK, show_peers_context::idtext, iax2_peer::mask, name, iax2_peer::name, show_peers_context::offline_peers, show_peers_context::online_peers, peer_status(), show_peers_context::peerlist, PEERS_FORMAT, status, show_peers_context::total_peers, show_peers_context::unmonitored_peers, and iax2_peer::username.

Referenced by __iax2_show_peers(), and manager_iax2_show_peer_list().

◆ acf_channel_read()

static int acf_channel_read ( struct ast_channel chan,
const char *  funcname,
char *  preparse,
char *  buf,
size_t  buflen 
)
static

Definition at line 14629 of file chan_iax2.c.

14630{
14631 struct chan_iax2_pvt *pvt;
14632 unsigned int callno;
14633 int res = 0;
14634
14635 if (!chan || ast_channel_tech(chan) != &iax2_tech) {
14636 ast_log(LOG_ERROR, "This function requires a valid IAX2 channel\n");
14637 return -1;
14638 }
14639
14642 if (!(pvt = iaxs[callno])) {
14644 return -1;
14645 }
14646
14647 if (!strcasecmp(args, "osptoken")) {
14648 ast_copy_string(buf, pvt->osptoken, buflen);
14649 } else if (!strcasecmp(args, "peerip")) {
14651 } else if (!strcasecmp(args, "peername")) {
14652 ast_copy_string(buf, pvt->username, buflen);
14653 } else if (!strcasecmp(args, "secure_signaling") || !strcasecmp(args, "secure_media")) {
14654 snprintf(buf, buflen, "%s", IAX_CALLENCRYPTED(pvt) ? "1" : "");
14655 } else {
14656 res = -1;
14657 }
14658
14660
14661 return res;
14662}
#define IAX_CALLENCRYPTED(pvt)
Definition: chan_iax2.c:440
void * ast_channel_tech_pvt(const struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_ERROR
const ast_string_field username
Definition: chan_iax2.c:861
const ast_string_field osptoken
Definition: chan_iax2.c:861
const char * args

References chan_iax2_pvt::addr, args, ast_channel_tech(), ast_channel_tech_pvt(), ast_copy_string(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_sockaddr_isnull(), ast_sockaddr_stringify_addr(), buf, chan_iax2_pvt::callno, iax2_tech, IAX_CALLENCRYPTED, iaxs, iaxsl, LOG_ERROR, chan_iax2_pvt::osptoken, PTR_TO_CALLNO, and chan_iax2_pvt::username.

◆ acf_iaxvar_read()

static int acf_iaxvar_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 10119 of file chan_iax2.c.

10120{
10121 struct ast_datastore *variablestore;
10122 AST_LIST_HEAD(, ast_var_t) *varlist;
10123 struct ast_var_t *var;
10124
10125 if (!chan) {
10126 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
10127 return -1;
10128 }
10129
10131 if (!variablestore) {
10132 *buf = '\0';
10133 return 0;
10134 }
10135 varlist = variablestore->data;
10136
10137 AST_LIST_LOCK(varlist);
10138 AST_LIST_TRAVERSE(varlist, var, entries) {
10139 if (strcmp(var->name, data) == 0) {
10140 ast_copy_string(buf, var->value, len);
10141 break;
10142 }
10143 }
10144 AST_LIST_UNLOCK(varlist);
10145 return 0;
10146}
#define var
Definition: ast_expr2f.c:605
static const struct ast_datastore_info iax2_variable_datastore_info
Definition: chan_iax2.c:1569
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2418
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
Definition: linkedlists.h:173
Structure for a data store object.
Definition: datastore.h:64
void * data
Definition: datastore.h:66
struct ast_var_t::@211 entries

References ast_channel_datastore_find(), ast_copy_string(), AST_LIST_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log, buf, ast_datastore::data, ast_var_t::entries, iax2_variable_datastore_info, len(), LOG_WARNING, NULL, and var.

◆ acf_iaxvar_write()

static int acf_iaxvar_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 10148 of file chan_iax2.c.

10149{
10150 struct ast_datastore *variablestore;
10151 AST_LIST_HEAD(, ast_var_t) *varlist;
10152 struct ast_var_t *var;
10153
10154 if (!chan) {
10155 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
10156 return -1;
10157 }
10158
10160 if (!variablestore) {
10162 if (!variablestore) {
10163 ast_log(LOG_ERROR, "Memory allocation error\n");
10164 return -1;
10165 }
10166 varlist = ast_calloc(1, sizeof(*varlist));
10167 if (!varlist) {
10168 ast_datastore_free(variablestore);
10169 ast_log(LOG_ERROR, "Unable to assign new variable '%s'\n", data);
10170 return -1;
10171 }
10172
10173 AST_LIST_HEAD_INIT(varlist);
10174 variablestore->data = varlist;
10175 variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
10176 ast_channel_datastore_add(chan, variablestore);
10177 } else
10178 varlist = variablestore->data;
10179
10180 AST_LIST_LOCK(varlist);
10182 if (strcmp(var->name, data) == 0) {
10185 break;
10186 }
10187 }
10189 var = ast_var_assign(data, value);
10190 if (var)
10191 AST_LIST_INSERT_TAIL(varlist, var, entries);
10192 else
10193 ast_log(LOG_ERROR, "Unable to assign new variable '%s'\n", data);
10194 AST_LIST_UNLOCK(varlist);
10195 return 0;
10196}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2404
#define DATASTORE_INHERIT_FOREVER
Definition: channel.h:194
#define ast_var_assign(name, value)
Definition: chanvars.h:40
void ast_var_delete(struct ast_var_t *var)
Definition: extconf.c:2471
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:85
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
Definition: linkedlists.h:626
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
unsigned int inheritance
Definition: datastore.h:69
int value
Definition: syslog.c:37

References ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc, ast_datastore_free(), AST_LIST_HEAD, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log, ast_var_assign, ast_var_delete(), ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_var_t::entries, iax2_variable_datastore_info, ast_datastore::inheritance, LOG_ERROR, LOG_WARNING, NULL, value, and var.

◆ acl_change_stasis_cb()

static void acl_change_stasis_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
)
static

Definition at line 1558 of file chan_iax2.c.

1560{
1562 return;
1563 }
1564
1565 ast_log(LOG_NOTICE, "Reloading chan_iax2 in response to ACL change event.\n");
1566 reload_config(1);
1567}
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs
static int reload_config(int forced_reload)
Definition: chan_iax2.c:14180
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.

References ast_log, ast_named_acl_change_type(), LOG_NOTICE, reload_config(), and stasis_message_type().

Referenced by acl_change_stasis_subscribe(), and rtp_reload().

◆ acl_change_stasis_subscribe()

static void acl_change_stasis_subscribe ( void  )
static

Definition at line 1516 of file chan_iax2.c.

1517{
1518 if (!acl_change_sub) {
1523 }
1524}
static struct stasis_subscription * acl_change_sub
Definition: chan_iax2.c:328
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Definition: chan_iax2.c:1558
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
Definition: stasis.h:297
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
Definition: stasis.c:1024
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
Definition: stasis.c:1078
#define stasis_subscribe(topic, callback, data)
Definition: stasis.h:649

References acl_change_stasis_cb(), acl_change_sub, ast_named_acl_change_type(), ast_security_topic(), NULL, stasis_subscribe, stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, and stasis_subscription_set_filter().

Referenced by build_peer(), and build_user().

◆ acl_change_stasis_unsubscribe()

static void acl_change_stasis_unsubscribe ( void  )
static

Definition at line 1526 of file chan_iax2.c.

1527{
1529}
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Definition: stasis.c:1135

References acl_change_sub, and stasis_unsubscribe_and_join().

Referenced by __unload_module().

◆ add_calltoken_ignore()

static int add_calltoken_ignore ( const char *  addr)
static

Definition at line 2842 of file chan_iax2.c.

2843{
2844 struct addr_range tmp;
2845 struct addr_range *addr_range = NULL;
2846 struct ast_ha *ha = NULL;
2847 int error = 0;
2848
2849 if (ast_strlen_zero(addr)) {
2850 ast_log(LOG_WARNING, "invalid calltokenoptional (null)\n");
2851 return -1;
2852 }
2853
2854 ha = ast_append_ha("permit", addr, NULL, &error);
2855
2856 /* check for valid config information */
2857 if (error) {
2858 ast_log(LOG_WARNING, "Error %d creating calltokenoptional entry %s\n", error, addr);
2859 return -1;
2860 }
2861
2862 ast_copy_ha(ha, &tmp.ha);
2863 /* find or create the addr_range */
2866 addr_range->delme = 0;
2868 } else if ((addr_range = ao2_alloc(sizeof(*addr_range), NULL))) {
2869 /* copy over config data into addr_range object */
2870 ast_copy_ha(ha, &addr_range->ha); /* this is safe because only one ha is possible */
2872 } else {
2873 ast_free_ha(ha);
2874 return -1;
2875 }
2876
2877 ast_free_ha(ha);
2878 ao2_ref(addr_range, -1); /* decrement ref from ao2_find and ao2_alloc, only container ref remains */
2879
2880 return 0;
2881}
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
Definition: acl.c:222
void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to)
Copy the contents of one HA to another.
Definition: acl.c:255
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
Definition: acl.c:712
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
static int tmp()
Definition: bt_open.c:389
struct ast_ha ha
Definition: chan_iax2.c:1042
unsigned char delme
Definition: chan_iax2.c:1046
internal representation of ACL entries In principle user applications would have no need for this,...
Definition: acl.h:51
struct ast_sockaddr addr
Definition: acl.h:53
int error(const char *format,...)
Definition: utils/frame.c:999

References ast_ha::addr, ao2_alloc, ao2_find, ao2_link, ao2_lock, ao2_ref, ao2_unlock, ast_append_ha(), ast_copy_ha(), ast_free_ha(), ast_log, ast_strlen_zero(), calltoken_ignores, addr_range::delme, error(), addr_range::ha, LOG_WARNING, NULL, OBJ_POINTER, and tmp().

Referenced by set_config().

◆ add_empty_calltoken_ie()

static void add_empty_calltoken_ie ( struct chan_iax2_pvt pvt,
struct iax_ie_data ied 
)
static

Definition at line 4858 of file chan_iax2.c.

4859{
4860 /* first make sure their are two empty bytes left in ied->buf */
4861 if (pvt && ied && (2 < ((int) sizeof(ied->buf) - ied->pos))) {
4862 ied->buf[ied->pos++] = IAX_IE_CALLTOKEN; /* type */
4863 ied->buf[ied->pos++] = 0; /* data size, ZERO in this case */
4864 pvt->calltoken_ie_len = 2;
4865 }
4866}
#define IAX_IE_CALLTOKEN
Definition: iax2.h:185
unsigned char calltoken_ie_len
Definition: chan_iax2.c:933
int pos
Definition: parser.h:151
unsigned char buf[1024]
Definition: parser.h:150

References iax_ie_data::buf, chan_iax2_pvt::calltoken_ie_len, IAX_IE_CALLTOKEN, and iax_ie_data::pos.

Referenced by cache_get_callno_locked(), iax2_call(), iax2_do_register(), iax2_poke_peer(), and registry_rerequest().

◆ addr_range_cmp_cb()

static int addr_range_cmp_cb ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 2498 of file chan_iax2.c.

2499{
2500 struct addr_range *lim1 = obj, *lim2 = arg;
2501 return (!(ast_sockaddr_cmp_addr(&lim1->ha.addr, &lim2->ha.addr)) &&
2502 !(ast_sockaddr_cmp_addr(&lim1->ha.netmask, &lim2->ha.netmask))) ?
2503 CMP_MATCH | CMP_STOP : 0;
2504}
@ CMP_MATCH
Definition: astobj2.h:1027
@ CMP_STOP
Definition: astobj2.h:1028
int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares the addresses of two ast_sockaddr structures.
Definition: netsock2.c:413
struct ast_sockaddr netmask
Definition: acl.h:54

References ast_ha::addr, ast_sockaddr_cmp_addr(), CMP_MATCH, CMP_STOP, addr_range::ha, and ast_ha::netmask.

Referenced by load_objects().

◆ addr_range_delme_cb()

static int addr_range_delme_cb ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 2485 of file chan_iax2.c.

2486{
2487 struct addr_range *lim = obj;
2488 lim->delme = 1;
2489 return 0;
2490}

References addr_range::delme.

Referenced by set_config_destroy().

◆ addr_range_hash_cb()

static int addr_range_hash_cb ( const void *  obj,
const int  flags 
)
static

Definition at line 2492 of file chan_iax2.c.

2493{
2494 const struct addr_range *lim = obj;
2495 return abs(ast_sockaddr_hash(&lim->ha.addr));
2496}
#define abs(x)
Definition: f2c.h:195
int ast_sockaddr_hash(const struct ast_sockaddr *addr)
Computes a hash value from the address. The port is ignored.
Definition: netsock2.c:548

References abs, ast_ha::addr, ast_sockaddr_hash(), and addr_range::ha.

Referenced by load_objects().

◆ addr_range_match_address_cb()

static int addr_range_match_address_cb ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 2522 of file chan_iax2.c.

2523{
2524 struct addr_range *addr_range = obj;
2525 struct ast_sockaddr *addr = arg;
2526 struct ast_sockaddr tmp_addr;
2527
2528 ast_sockaddr_apply_netmask(addr, &addr_range->ha.netmask, &tmp_addr);
2529
2530 if (!ast_sockaddr_cmp_addr(&tmp_addr, &addr_range->ha.addr)) {
2531 return CMP_MATCH | CMP_STOP;
2532 }
2533 return 0;
2534}
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.
Definition: netsock2.c:357
Socket address structure.
Definition: netsock2.h:97

References ast_ha::addr, ast_sockaddr_apply_netmask(), ast_sockaddr_cmp_addr(), CMP_MATCH, CMP_STOP, addr_range::ha, and ast_ha::netmask.

Referenced by calltoken_required(), and set_peercnt_limit().

◆ apply_context()

static int apply_context ( struct iax2_context con,
const char *  context 
)
static

Definition at line 7876 of file chan_iax2.c.

7877{
7878 while(con) {
7879 if (!strcmp(con->context, context) || !strcmp(con->context, "*"))
7880 return -1;
7881 con = con->next;
7882 }
7883 return 0;
7884}
char context[AST_MAX_CONTEXT]
Definition: chan_iax2.c:493
struct iax2_context * next
Definition: chan_iax2.c:494

References iax2_context::context, voicemailpwcheck::context, and iax2_context::next.

Referenced by check_access().

◆ ast_cli_netstats()

static int ast_cli_netstats ( struct mansession s,
int  fd,
int  limit_fmt 
)
static

Definition at line 7577 of file chan_iax2.c.

7578{
7579 int x;
7580 int numchans = 0;
7581 char first_message[10] = { 0, };
7582 char last_message[10] = { 0, };
7583#define ACN_FORMAT1 "%-24.25s %4u %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d %s%s %4s%s\n"
7584#define ACN_FORMAT2 "%s %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %s%s %s%s\n"
7585 for (x = 0; x < ARRAY_LEN(iaxs); x++) {
7586 ast_mutex_lock(&iaxsl[x]);
7587 if (iaxs[x]) {
7588 int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
7589 jb_info jbinfo;
7590 iax_frame_subclass2str(iaxs[x]->first_iax_message & ~MARK_IAX_SUBCLASS_TX, first_message, sizeof(first_message));
7591 iax_frame_subclass2str(iaxs[x]->last_iax_message & ~MARK_IAX_SUBCLASS_TX, last_message, sizeof(last_message));
7592
7594 jb_getinfo(iaxs[x]->jb, &jbinfo);
7595 localjitter = jbinfo.jitter;
7596 localdelay = jbinfo.current - jbinfo.min;
7597 locallost = jbinfo.frames_lost;
7598 locallosspct = jbinfo.losspct/1000;
7599 localdropped = jbinfo.frames_dropped;
7600 localooo = jbinfo.frames_ooo;
7601 } else {
7602 localjitter = -1;
7603 localdelay = 0;
7604 locallost = -1;
7605 locallosspct = -1;
7606 localdropped = 0;
7607 localooo = -1;
7608 }
7609 if (s)
7610 astman_append(s, limit_fmt ? ACN_FORMAT1 : ACN_FORMAT2,
7611 iaxs[x]->owner ? ast_channel_name(iaxs[x]->owner) : "(None)",
7612 iaxs[x]->pingtime,
7613 localjitter,
7614 localdelay,
7615 locallost,
7616 locallosspct,
7617 localdropped,
7618 localooo,
7619 iaxs[x]->frames_received/1000,
7620 iaxs[x]->remote_rr.jitter,
7621 iaxs[x]->remote_rr.delay,
7625 iaxs[x]->remote_rr.ooo,
7626 iaxs[x]->remote_rr.packets/1000,
7627 (iaxs[x]->first_iax_message & MARK_IAX_SUBCLASS_TX) ? "Tx:" : "Rx:",
7628 first_message,
7629 (iaxs[x]->last_iax_message & MARK_IAX_SUBCLASS_TX) ? "Tx:" : "Rx:",
7630 last_message);
7631 else
7632 ast_cli(fd, limit_fmt ? ACN_FORMAT1 : ACN_FORMAT2,
7633 iaxs[x]->owner ? ast_channel_name(iaxs[x]->owner) : "(None)",
7634 iaxs[x]->pingtime,
7635 localjitter,
7636 localdelay,
7637 locallost,
7638 locallosspct,
7639 localdropped,
7640 localooo,
7641 iaxs[x]->frames_received/1000,
7642 iaxs[x]->remote_rr.jitter,
7643 iaxs[x]->remote_rr.delay,
7647 iaxs[x]->remote_rr.ooo,
7648 iaxs[x]->remote_rr.packets/1000,
7649 (iaxs[x]->first_iax_message & MARK_IAX_SUBCLASS_TX) ? "Tx:" : "Rx:",
7650 first_message,
7651 (iaxs[x]->last_iax_message & MARK_IAX_SUBCLASS_TX) ? "Tx:" : "Rx:",
7652 last_message);
7653 numchans++;
7654 }
7656 }
7657
7658 return numchans;
7659}
#define MARK_IAX_SUBCLASS_TX
Definition: chan_iax2.c:718
#define ACN_FORMAT2
#define ACN_FORMAT1
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
get jitterbuf info: only "statistics" may be valid
Definition: jitterbuf.c:815
void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t len)
Definition: parser.c:463
int first_iax_message
Definition: chan_iax2.c:766
struct iax_rr remote_rr
Definition: chan_iax2.c:923
int last_iax_message
Definition: chan_iax2.c:768
int ooo
Definition: chan_iax2.c:733
int losscnt
Definition: chan_iax2.c:729
int delay
Definition: chan_iax2.c:731
int losspct
Definition: chan_iax2.c:728
int dropped
Definition: chan_iax2.c:732
int packets
Definition: chan_iax2.c:730
long min
Definition: jitterbuf.h:87
long current
Definition: jitterbuf.h:88
long losspct
Definition: jitterbuf.h:90
long frames_lost
Definition: jitterbuf.h:82
long frames_ooo
Definition: jitterbuf.h:84
long frames_dropped
Definition: jitterbuf.h:83
long jitter
Definition: jitterbuf.h:86

References ACN_FORMAT1, ACN_FORMAT2, ARRAY_LEN, ast_channel_name(), ast_cli(), ast_mutex_lock, ast_mutex_unlock, ast_test_flag64, astman_append(), jb_info::current, iax_rr::delay, iax_rr::dropped, chan_iax2_pvt::first_iax_message, jb_info::frames_dropped, jb_info::frames_lost, jb_info::frames_ooo, iax_frame_subclass2str(), IAX_USEJITTERBUF, iaxs, iaxsl, jb_getinfo(), jb_info::jitter, chan_iax2_pvt::last_iax_message, iax_rr::losscnt, iax_rr::losspct, jb_info::losspct, MARK_IAX_SUBCLASS_TX, jb_info::min, iax_rr::ooo, iax_rr::packets, and chan_iax2_pvt::remote_rr.

Referenced by handle_cli_iax2_show_netstats(), and manager_iax2_show_netstats().

◆ ast_iax2_new()

static struct ast_channel * ast_iax2_new ( int  callno,
int  state,
iax2_format  capability,
struct iax2_codec_pref prefs,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
unsigned int  cachable 
)
static

Create new call, interface with the PBX core.

Definition at line 5906 of file chan_iax2.c.

5909{
5910 struct ast_channel *tmp = NULL;
5911 struct chan_iax2_pvt *i;
5912 struct iax2_peer *peer;
5913 struct ast_variable *v = NULL;
5914 struct ast_format_cap *native;
5915 struct ast_format *tmpfmt;
5916 ast_callid callid;
5917 char *peer_name = NULL;
5918
5919 if (!(i = iaxs[callno])) {
5920 ast_log(LOG_WARNING, "No IAX2 pvt found for callno '%d' !\n", callno);
5921 return NULL;
5922 }
5923
5924 if (!capability) {
5925 ast_log(LOG_WARNING, "No formats specified for call to: IAX2/%s-%d\n",
5926 i->host, i->callno);
5927 return NULL;
5928 }
5930 if (!native) {
5931 return NULL;
5932 }
5933 if (iax2_codec_pref_best_bitfield2cap(capability, prefs, native)
5934 || !ast_format_cap_count(native)) {
5935 ast_log(LOG_WARNING, "No requested formats available for call to: IAX2/%s-%d\n",
5936 i->host, i->callno);
5937 ao2_ref(native, -1);
5938 return NULL;
5939 }
5940
5941 if (!ast_strlen_zero(i->peer)) {
5942 peer_name = ast_strdupa(i->peer);
5943 } else if (!ast_strlen_zero(i->host)) {
5944 peer_name = ast_strdupa(i->host);
5945 }
5946
5947 /* Don't hold call lock while making a channel or looking up a peer */
5948 ast_mutex_unlock(&iaxsl[callno]);
5949
5950 if (!ast_strlen_zero(peer_name)) {
5951 peer = find_peer(peer_name, 1);
5952 if (peer && peer->endpoint) {
5954 i->accountcode, i->exten, i->context, assignedids, requestor,
5955 i->amaflags, peer->endpoint, "IAX2/%s-%d", i->host, i->callno);
5956 }
5957 ao2_cleanup(peer);
5958 }
5959
5960 if (!tmp) {
5962 i->exten, i->context, assignedids, requestor, i->amaflags, "IAX2/%s-%d",
5963 i->host, i->callno);
5964 }
5965
5966 ast_mutex_lock(&iaxsl[callno]);
5967 if (i != iaxs[callno]) {
5968 if (tmp) {
5969 /* unlock and relock iaxsl[callno] to preserve locking order */
5970 ast_mutex_unlock(&iaxsl[callno]);
5973 ast_mutex_lock(&iaxsl[callno]);
5974 }
5975 ao2_ref(native, -1);
5976 return NULL;
5977 }
5978 if (!tmp) {
5979 ao2_ref(native, -1);
5980 return NULL;
5981 }
5982
5984
5985 if ((callid = iaxs[callno]->callid)) {
5986 ast_channel_callid_set(tmp, callid);
5987 }
5988
5990
5991 /* We can support any format by default, until we get restricted */
5993 tmpfmt = ast_format_cap_get_format(native, 0);
5994
5999
6000 ao2_ref(tmpfmt, -1);
6001 ao2_ref(native, -1);
6002
6004
6005 if (!ast_strlen_zero(i->parkinglot))
6006 ast_channel_parkinglot_set(tmp, i->parkinglot);
6007 /* Don't use ast_set_callerid() here because it will
6008 * generate a NewCallerID event before the NewChannel event */
6009 if (!ast_strlen_zero(i->ani)) {
6012 } else if (!ast_strlen_zero(i->cid_num)) {
6015 }
6017 if (!ast_strlen_zero(i->rdnis)) {
6020 }
6026 if (!ast_strlen_zero(i->language))
6027 ast_channel_language_set(tmp, i->language);
6029 ast_channel_accountcode_set(tmp, i->accountcode);
6030 if (i->amaflags)
6034 if (i->adsi)
6036 else
6038 i->owner = tmp;
6039 i->capability = capability;
6040
6041 if (!cachable) {
6043 }
6044
6045 /* Set inherited variables */
6046 if (i->vars) {
6047 for (v = i->vars ; v ; v = v->next)
6049 }
6050 if (i->iaxvars) {
6051 struct ast_datastore *variablestore;
6052 struct ast_variable *var, *prev = NULL;
6053 AST_LIST_HEAD(, ast_var_t) *varlist;
6054 ast_debug(1, "Loading up the channel with IAXVARs\n");
6055 varlist = ast_calloc(1, sizeof(*varlist));
6057 if (variablestore && varlist) {
6058 variablestore->data = varlist;
6059 variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
6060 AST_LIST_HEAD_INIT(varlist);
6061 for (var = i->iaxvars; var; var = var->next) {
6062 struct ast_var_t *newvar = ast_var_assign(var->name, var->value);
6063 if (prev)
6064 ast_free(prev);
6065 prev = var;
6066 if (!newvar) {
6067 /* Don't abort list traversal, as this would leave i->iaxvars in an inconsistent state. */
6068 ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
6069 } else {
6070 AST_LIST_INSERT_TAIL(varlist, newvar, entries);
6071 }
6072 }
6073 if (prev)
6074 ast_free(prev);
6075 i->iaxvars = NULL;
6076 ast_channel_datastore_add(i->owner, variablestore);
6077 } else {
6078 if (variablestore) {
6079 ast_datastore_free(variablestore);
6080 }
6081 if (varlist) {
6082 ast_free(varlist);
6083 }
6084 }
6085 }
6086
6089
6090 if (state != AST_STATE_DOWN) {
6091 if (ast_pbx_start(tmp)) {
6092 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
6093 /* unlock and relock iaxsl[callno] to preserve locking order */
6094 ast_mutex_unlock(&iaxsl[callno]);
6095 ast_hangup(tmp);
6096 ast_mutex_lock(&iaxsl[callno]);
6097 return NULL;
6098 }
6099 }
6100
6102 return tmp;
6103}
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define CALLNO_TO_PTR(a)
Definition: chan_iax2.c:293
static struct iax2_peer * find_peer(const char *name, int realtime)
Definition: chan_iax2.c:2056
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint,...)
Definition: channel.h:1303
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2560
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1299
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
@ AST_ADSI_UNAVAILABLE
Definition: channel.h:891
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1603
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
Definition: channel.h:1049
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_channel_unlock(chan)
Definition: channel.h:2969
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
@ AST_STATE_DOWN
Definition: channelstate.h:36
int iax2_codec_pref_best_bitfield2cap(uint64_t bitfield, struct iax2_codec_pref *prefs, struct ast_format_cap *cap)
Convert a bitfield to a format capabilities structure in the "best" order.
Definition: codec_pref.c:112
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
unsigned int ast_callid
#define ast_module_ref(mod)
Hold a reference to the module.
Definition: module.h:457
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Definition: pbx.c:4708
Main Channel structure associated with a channel.
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
struct ast_module * self
Definition: module.h:356
struct ast_party_id id
Caller party ID.
Definition: channel.h:422
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:435
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:429
struct ast_party_dialed::@208 number
Dialed/Called number.
char * str
Subscriber phone number (Malloced)
Definition: channel.h:388
int transit_network_select
Transit Network Select.
Definition: channel.h:399
struct ast_party_name name
Subscriber name.
Definition: channel.h:342
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:279
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:297
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299
char * str
Subscriber phone number (Malloced)
Definition: channel.h:293
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:295
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:529
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
struct ast_variable * vars
Definition: chan_iax2.c:919
const ast_string_field language
Definition: chan_iax2.c:861
int calling_ani2
Definition: chan_iax2.c:915
const ast_string_field cid_num
Definition: chan_iax2.c:861
iax2_format capability
Definition: chan_iax2.c:756
const ast_string_field accountcode
Definition: chan_iax2.c:861
struct ast_variable * iaxvars
Definition: chan_iax2.c:921
const ast_string_field context
Definition: chan_iax2.c:861
const ast_string_field rdnis
Definition: chan_iax2.c:861
int calling_pres
Definition: chan_iax2.c:914
const ast_string_field exten
Definition: chan_iax2.c:861
const ast_string_field ani
Definition: chan_iax2.c:861
const ast_string_field cid_name
Definition: chan_iax2.c:861
const ast_string_field dnid
Definition: chan_iax2.c:861
const ast_string_field peer
Definition: chan_iax2.c:861
#define ast_set_flag(p, flag)
Definition: utils.h:70

References chan_iax2_pvt::accountcode, chan_iax2_pvt::adsi, chan_iax2_pvt::amaflags, chan_iax2_pvt::ani, ast_party_caller::ani, ast_party_caller::ani2, ao2_cleanup, ao2_ref, AST_ADSI_UNAVAILABLE, ast_calloc, ast_channel_adsicpe_set(), ast_channel_alloc, ast_channel_alloc_with_endpoint, ast_channel_amaflags_set(), ast_channel_caller(), ast_channel_callid_set(), ast_channel_context_set(), ast_channel_datastore_add(), ast_channel_dialed(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_name(), ast_channel_nativeformats_set(), ast_channel_redirecting(), ast_channel_release(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_tech_pvt_set(), ast_channel_tech_set(), ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), ast_debug, AST_FLAG_DISABLE_DEVSTATE_CACHE, ast_format_cap_alloc, ast_format_cap_count(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_format(), ast_free, ast_hangup(), AST_LIST_HEAD, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, ast_log, ast_module_ref, ast_mutex_lock, ast_mutex_unlock, ast_pbx_start(), ast_set_flag, AST_STATE_DOWN, ast_strdup, ast_strdupa, ast_strlen_zero(), ast_var_assign, chan_iax2_pvt::calling_ani2, chan_iax2_pvt::calling_pres, chan_iax2_pvt::calling_tns, chan_iax2_pvt::calling_ton, chan_iax2_pvt::callno, CALLNO_TO_PTR, chan_iax2_pvt::capability, chan_iax2_pvt::cid_name, chan_iax2_pvt::cid_num, chan_iax2_pvt::context, ast_datastore::data, DATASTORE_INHERIT_FOREVER, chan_iax2_pvt::dnid, iax2_peer::endpoint, ast_var_t::entries, chan_iax2_pvt::exten, find_peer(), ast_party_redirecting::from, chan_iax2_pvt::host, iax2_codec_pref_best_bitfield2cap(), iax2_tech, iax2_variable_datastore_info, iaxs, iaxsl, chan_iax2_pvt::iaxvars, ast_party_caller::id, ast_datastore::inheritance, chan_iax2_pvt::language, LOG_ERROR, LOG_WARNING, ast_party_id::name, ast_variable::name, ast_variable::next, NULL, ast_party_id::number, ast_party_dialed::number, chan_iax2_pvt::owner, chan_iax2_pvt::parkinglot, pbx_builtin_setvar_helper(), chan_iax2_pvt::peer, chan_iax2_pvt::peeradsicpe, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, chan_iax2_pvt::rdnis, ast_module_info::self, ast_party_number::str, ast_party_dialed::str, tmp(), ast_party_dialed::transit_network_select, ast_party_number::valid, ast_variable::value, var, and chan_iax2_pvt::vars.

Referenced by iax2_request(), and socket_process_helper().

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 15136 of file chan_iax2.c.

◆ attempt_transmit()

static int attempt_transmit ( const void *  data)
static

Definition at line 3678 of file chan_iax2.c.

3679{
3680#ifdef SCHED_MULTITHREADED
3682#endif
3683 __attempt_transmit(data);
3684 return 0;
3685}
#define schedule_action(func, data)
Definition: chan_iax2.c:1724
static void __attempt_transmit(const void *data)
Definition: chan_iax2.c:3595

References __attempt_transmit(), ast_frame::data, and schedule_action.

Referenced by __attempt_transmit(), and transmit_frame().

◆ auth_fail()

static int auth_fail ( int  callno,
int  failcode 
)
static

Definition at line 9458 of file chan_iax2.c.

9459{
9460 /* Schedule sending the authentication failure in one second, to prevent
9461 guessing */
9462 if (iaxs[callno]) {
9463 iaxs[callno]->authfail = failcode;
9464 if (delayreject) {
9465 iaxs[callno]->authid = iax2_sched_replace(iaxs[callno]->authid,
9466 sched, 1000, auth_reject, (void *)(long)callno);
9467 } else
9468 auth_reject((void *)(long)callno);
9469 }
9470 return 0;
9471}
static int delayreject
Definition: chan_iax2.c:478
static int auth_reject(const void *data)
Definition: chan_iax2.c:9444
static int iax2_sched_replace(int id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data)
Definition: chan_iax2.c:1727

References auth_reject(), chan_iax2_pvt::authfail, chan_iax2_pvt::authid, delayreject, iax2_sched_replace(), and iaxs.

Referenced by socket_process_helper().

◆ auth_method_names()

static char * auth_method_names ( int  authmethods,
char *restrict  buf 
)
static

Get names of all auth methods.

Parameters
Bitfield of auth methods
[out]bufBuffer into which to write the names. Must be of size AUTH_METHOD_NAMES_BUFSIZE.
Returns
Auth methods name

Definition at line 415 of file chan_iax2.c.

416{
417 char *pos = buf;
418
419 *pos = '\0';
420
421 if (authmethods & IAX_AUTH_RSA) {
422 pos += sprintf(pos, "|RSA");
423 }
424 if (authmethods & IAX_AUTH_MD5) {
425 pos += sprintf(pos, "|MD5");
426 }
427 if (authmethods & IAX_AUTH_PLAINTEXT) {
428 pos += sprintf(pos, "|plaintext");
429 }
430
431 if (pos == buf) { /* No auth methods */
432 strcpy(buf, "none");
433 return buf;
434 }
435
436 return buf + 1; /* Skip leading | */
437}
#define IAX_AUTH_RSA
Definition: iax2.h:199
#define IAX_AUTH_MD5
Definition: iax2.h:198
#define IAX_AUTH_PLAINTEXT
Definition: iax2.h:197

References buf, IAX_AUTH_MD5, IAX_AUTH_PLAINTEXT, and IAX_AUTH_RSA.

Referenced by socket_process_helper().

◆ auth_reject()

static int auth_reject ( const void *  data)
static

Definition at line 9444 of file chan_iax2.c.

9445{
9446 int callno = (int)(long)(data);
9447 ast_mutex_lock(&iaxsl[callno]);
9448 if (iaxs[callno])
9449 iaxs[callno]->authid = -1;
9450 ast_mutex_unlock(&iaxsl[callno]);
9451#ifdef SCHED_MULTITHREADED