Skip to main content

Asterisk Modules

# 模块类型ls /usr/lib/asterisk/modules | egrep -o '^[a-z]+' | sort | uniq -c | sort -nrls /usr/lib/asterisk/modules | xargs -n 1 basename | sed 's/.so$//' | sort | grep func_
# 模块支持状态grep -rP '^\t<support_level>' $(find . -name '*.c') | sed -re 's#</?support_level>##g' | sort
asterisk -x 'module show'

内置模块#

不可以动态 load、unload - 部分可以配置不启用

moduleconfdesc
aclacl.conf统一 ACL 控制
ccssccss.confCall Completion Supplementary Services
cdrcdr.confCall Detail Record
celcel.confCall Event Log
dnsmgrdnsmgr.conf内置 DNS 管理器
dspdsp.conf
enumenum.conf通过 DNS 解析电话号码
extconfigextconfig.conf静态和实时外部配置引擎
featuresfeatures.conf
httphttp.conf内置 HTTP 服务
indicationsindications.conf
loggerlogger.conf
managermanager.confAMI
plcPacket Loss Concealment - 音频丢包补偿
sounds声音文件索引
udptludptl.confUDP Transport Layer - 端口配置
  • dsp - 信号处理
  • CCSS - Call Completion Supplementary Services - 通话完成补偿服务
    • 由 CCBS 和 CCNR 组成
      • CCBS - Call Completion on Busy Subscriber
      • CCNR - Call Completion on No Response
    • 例如 A 呼叫 B,但 B 在和 C 通话,开启 CCSS/CCBS 后,可以在 B 和 C 通话完成后通知 A

动态模块#

  1. 可动态加载
  2. 可能不同模块提供相同功能 - 模块互斥
typedesc
appDialplan 应用
bridge三方通话、会议
cdrCDR+后端配置
celCEL+后端配置
chan通道技术
codec语音编码
format语音文件格式
funcDialplan 函数
pbx路由
res资源

chan#

chanconfdesc
chan_audiosocket简单的 Audio over TCP 协议 - 用于实现外部音频处理
chan_alsaalsa.confLinux 接口
chan_bridge_media
chan_consoleconsole.confLinux 接口
chan_dahdichan_dahdi.confDAHDi 板卡接口
chan_dongledongle.confGSM 接口
chan_iax2iax.confInter Asterisk eXchange (Ver 2)
chan_mgcpmgcp.confMedia Gateway Control Protocol
chan_ossoss.confLinux 接口
chan_pjsippjsip.conf基于 pjproject 的 sip 实现,推荐使用
chan_rtprtp.confRTP Media Channel
chan_sipsip.conf最早的 sip 实现,⚠️ 不再维护
chan_skinnyskinny.confSkinny Client Control Protocol
chan_unistimunistim.confUnified Networks IP Stimulus
chan_mobilechan_mobile.conf蓝牙
modulesdependencies
chan_rtpres_rtp_multicast

# PJSIP# ==========# lookup AOR, dial first Contactexten => _6XXX,1,Dial(PJSIP/${EXTEN})# dial all conacts - 会拼接所有 contactsexten => _6XXX,1,Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})})# dial SIP - trunk 线路# 不使用 AOR 和 Contactexten => _9NXXNXXXXXX,1,Dial(PJSIP/mytrunk/sip:${EXTEN:1}@203.0.113.1:5060)# dial 预先配置 trunk 上的 AOR 信息exten => _9NXXNXXXXXX,1,Dial(PJSIP/${EXTEN:1}@mytrunk)
# Local# ==========exten => 201,1,Verbose(2,Call desk phone and cellphone but with delay)exten => 201,n,Dial(Local/[email protected]&Local/[email protected],30)
# AudioSocket# ==========# Dialplanexten = 100,1,Verbose("Call to AudioSocket via Dialplan Application") same = n,Answer() same = n,AudioSocket(40325ec2-5efd-4bd3-805f-53576e581d13,server.example.com:9092) same = n,Hangup()# Chanexten = 101,1,Verbose("Call to AudioSocket via Channel interface") same = n,Answer() same = n,Dial(AudioSocket/server.example.com:9092/40325ec2-5efd-4bd3-805f-53576e581d13) same = n,Hangup()

pbx#

moduleconfdesc
pbx_aelextensions.ael
pbx_configextensions.conf最常用
pbx_dundi
pbx_loopback
pbx_luaextensions.lua
pbx_realtimedb/extension
pbx_spool将 callfile 放到目录下自动发起拨号
  • pbx_realtime
    • 相当于把 extensions.conf 一行一行存到了数据库, 实际上不太好管理
  • pbx_lua
    • 使用 Lua 来写 dialplain

codec#

codecdesc
codec_a_mu
codec_adpcm
codec_alaw
codec_dahdi/dev/dahdi/transcode - DAHDi 硬件转码
codec_g722
codec_g726
codec_gsm
codec_ilbc
codec_lpc10
codec_resample从新采样
codec_ulaw

format#

formatdesc
format_g719
format_g723
format_g726
format_g729
format_gsm
format_h263
format_h264
format_ilbc
format_pcm
format_siren14
format_siren7
format_sln
format_vox
format_wav
format_wav_gsm

cdr#

moduleconfdesc
cdr_csv
cdr_custom
cdr_managerAMI 接收 CDR
cdr_mysql
cdr_pgsql
cdr_sqlite3_custom
cdr_syslog
cdr_tdsMS SQL Server

cel#

moduleconfdesc
cel_custom
cel_managerAMI 接收 CEL
cel_pgsql
cel_sqlite3_custom
cel_tdsMS SQL Server

bridge#

moduledesc
bridge_builtin_features
bridge_builtin_interval_features
bridge_holdingstore channels in bridge for holding, parking, queues
bridge_native_rtpNative RTP bridging
bridge_simple
bridge_softmix多方,软 mix

func#

funcdesc
func_aes
func_base64
func_blacklist
func_callcompletion
func_callerid
func_cdr
func_channel
func_config
func_curl
func_cut
func_db
func_devstate
func_dialgroup
func_dialplan
func_enum
func_env
func_extstate
func_frame_trace
func_global
func_groupcount
func_hangupcause
func_holdintercept
func_iconv
func_jitterbuffer
func_lock
func_logic
func_math
func_md5
func_module
func_periodic_hook
func_pitchshift
func_pjsip_aor
func_pjsip_contact
func_pjsip_endpoint
func_presencestate
func_rand
func_realtime
func_sha1
func_shell
func_sorcery
func_sprintf
func_srv
func_strings
func_sysinfo
func_talkdetect
func_timeout
func_uri
func_version
func_vmcount
func_volume

app#

appdesc
app_adsiprog
app_agent_pool
app_alarmreceiver
app_amd
app_attended_transfer
app_audiosocket
app_authenticate
app_blind_transfer
app_bridgeaddchan
app_bridgewait
app_cdr
app_celgenuserevent
app_chanisavail
app_channelredirect
app_chanspy
app_confbridgeconfbridge.conf
app_controlplayback
app_dahdiras
app_db
app_dial
app_dictate
app_directed_pickup
app_directory
app_disaDirect Inward System Access
app_dumpchan
app_echo测试应用, 感受延时, 确认是否有声音
app_exec
app_externalivr
app_festival
app_flash
app_followme
app_forkcdr
app_getcpeid
app_ices
app_image
app_meetmeMeetMe conference bridge
app_milliwatt
app_minivm
app_mixmonitorMixed Audio Monitoring
app_morsecode
app_mp3
app_nbscat
app_originate
app_page
app_playback
app_playtones
app_privacy
app_queue
app_read
app_readexten
app_record
app_sayunixtime
app_senddtmf
app_sendtext
app_smsSMS/PSTN
app_softhangup
app_speech_utils
app_stackDialplan subroutines - Gosub, Return
app_stasis
app_stream_echo
app_system
app_talkdetect
app_testInterface Test Application
app_transfer
app_url
app_userevent
app_verboseVERBOSE
app_voicemail
app_waitforring
app_waitforsilence
app_waituntil
app_while
app_zapateller

res#

res moduledesc
res_adsi
res_ael_share
res_agi
res_audiosocket
res_calendar
res_clialiases
res_clioriginate
res_config_curl
res_config_pgsql
res_config_sqlite3
res_convert
res_crypto
res_curl
res_format_attr_celt
res_format_attr_g729
res_format_attr_h263
res_format_attr_h264
res_format_attr_ilbc
res_format_attr_opus
res_format_attr_silk
res_format_attr_siren14
res_format_attr_siren7
res_format_attr_vp8
res_hep
res_hep_pjsip
res_hep_rtcp
res_http_media_cache
res_http_websocket
res_limit
res_manager_devicestate
res_manager_presencestate
res_monitorMonitor 功能, 现在更多推荐使用 app_mixmonitor
res_musiconhold
res_mutestream
res_mwi_devstate
res_parking
res_phoneprov
res_prometheusprometheus 监控
res_realtime
res_resolver_unbound
res_rtp_asteriskRTP,RTCP with Symmetric RTP support for NAT
res_rtp_multicast
res_security_log
res_smdi
res_snmpSNMP 集成
res_speech
res_srtp
res_statsdstattsd 监控
res_stir_shakenSTIR/SHAKEN
res_stun_monitor
res_timing_dahdi
res_timing_pthread
res_timing_timerfd
moduledependencies
res_agires_speech
res_rtp_asteriskres_pjproject
res_snmpnet-snmp-dev
  • STIR/SHAKEN
    • STIR - Secure Telephone Identity Revisited
    • SHAKEN - Signature-based Handling of Asserted Information Using toKENs
    • 避免 PTNS CallID 欺骗

res_stasis#

  • stasis 应用模块
  • 基于 WebSocket 实时控制
res_stasisdesc
res_stasis
res_stasis_answer
res_stasis_device_state
res_stasis_playback
res_stasis_recording
res_stasis_snoop

res_sorcery#

  • asterisk 统一的配置访问接口 - CRUD
res_sorcerydesc
res_sorcery_astdb从 astdb 获取配置
res_sorcery_config操作配置文件
res_sorcery_memory内存配置
res_sorcery_memory_cache缓存远程配置
res_sorcery_realtime从实时后端获取配置

res_ari#

  • Asterisk RESTful Interface
  • REST 管理 Asterisk 资源
  • 不同模块提供不同资源接口
ari moduledesc
res_ari
res_ari_applications
res_ari_asterisk
res_ari_bridges
res_ari_channels
res_ari_device_states
res_ari_endpoints
res_ari_events
res_ari_model
res_ari_playbacks
res_ari_recordings
res_ari_sounds

res_pjsip#

pjsip moduledesc
res_pjprojectPJPROJECT Log & Utility
res_pjsip基础 SIP 资源
res_pjsip_aclPJSIP ACL
res_pjsip_authenticator_digestDigest 认证
res_pjsip_caller_id支持 CallerID
res_pjsip_config_wizardpjsip_wizard.conf
res_pjsip_dialog_info_body_generatorExtension State Dialog Info+XML
res_pjsip_diversionDiversion Header
res_pjsip_dlg_optionsSIP OPTIONS in dialog
res_pjsip_dtmf_info支持 DTMF INFO
res_pjsip_empty_info支持 Empty INFO
res_pjsip_endpoint_identifier_anonymous匿名终端标识
res_pjsip_endpoint_identifier_ipIP 终端标识
res_pjsip_endpoint_identifier_user用户名终端标识
res_pjsip_exten_stateExtension State Notifications
res_pjsip_header_funcsHeader Functions
res_pjsip_history历史
res_pjsip_logger包日志
res_pjsip_messaging支持消息
res_pjsip_mwiMWI 资源
res_pjsip_mwi_body_generator
res_pjsip_natNAT 支持
res_pjsip_notify支持 CLI/AMI PJSIP NOTIFY
res_pjsip_one_touch_record_infoINFO One Touch Recording
res_pjsip_outbound_authenticator_digestoutbound digest 认证
res_pjsip_outbound_publish
res_pjsip_outbound_registrationoutbound 注册
res_pjsip_pathPath 头
res_pjsip_phoneprov_provider
res_pjsip_pidf_body_generatorExtension State PIDF Provider
res_pjsip_pidf_digium_body_supplementPIDF Sangoma presence supplement
res_pjsip_pidf_eyebeam_body_supplementPJSIP PIDF Eyebeam supplement
res_pjsip_publish_asteriskAsterisk Event PUBLISH
res_pjsip_pubsubevent
res_pjsip_referBlind and Attended Transfer
res_pjsip_registrarRegistrar
res_pjsip_rfc3326Reason 头
res_pjsip_sdp_rtpSDP RTP/AVP stream handler
res_pjsip_send_to_voicemailREFER Send to Voicemail
res_pjsip_session
res_pjsip_sips_contactUAC SIPS Contact
res_pjsip_stir_shaken
res_pjsip_t38PJSIP T.38 UDPTL
res_pjsip_transport_websocketWebSocket
res_pjsip_xpidf_body_generatorExtension State PIDF Provider
  • PIDF - Presence Information Data Format
  • T.38 - FoIP Fax over IP - UDP 协议
  • rfc3326 - SIP Reason 头
  • Presence Subscriptions
    • res_pjsip_pubsub
    • res_pjsip_exten_state
    • res_pjsip_pidf_body_generator
    • res_pjsip_xpidf_body_generator
    • res_pjsip_dialog_info_body_generator
    • 特殊驱动支持
      • res_pjsip_pidf_digium_body_supplement
      • res_pjsip_pidf_eyebeam_body_supplement

sip common#

load => res_adsi.soload => res_timing_pthread.so;load => res_timing_dahdi.soload => res_agi.soload => res_crypto.soload => res_pktccops.soload => res_smdi.soload => res_stun_monitor.soload => res_rtp_asterisk.soload => res_rtp_msp.soload => res_curl.soload => res_clioriginate.soload => pbx_config.soload => bridge_multiplexed.soload => app_dial.soload => app_exec.soload => app_system.soload => app_macro.soload => app_cdr.soload => app_chanisavail.soload => app_grppolicy.soload => app_mixmonitor.soload => app_sayunixtime.soload => app_originate.soload => app_playback.soload => app_disa.soload => app_authenticate.soload => format_wav.soload => format_gsm.soload => func_math.soload => func_cdr.soload => func_strings.soload => func_channel.soload => func_callerid.soload => func_timeout.soload => func_shell.soload => func_rand.soload => func_realtime.soload => func_dialplan.soload => func_curl.soload => func_uri.soload => func_blacklist.soload => func_db.soload => func_cut.soload => cdr_manager.soload => cdr_syslog.soload => codec_alaw.soload => codec_ulaw.soload => codec_adpcm.soload => codec_a_mu.soload => codec_g722.soload => codec_g723.soload => codec_g726.soload => codec_g729.soload => codec_gsm.soload => codec_lpc10.so;load => codec_c1k.soload => chan_extra.soload => res_srtp.soload => chan_sip.soload => chan_iax2.soload => res_musiconhold.soload => func_env.so

res_statsd#

statsd.conf

[general]# 是否启用 statsd 指标enabled = yes# statsd 服务端地址# server[:port] - 默认端口 8125server = 127.0.0.1# 指标前缀 - 如果有多个实例则建议添加prefix = ast-1# 添加换行# 方便使用 nc -lu 8125 测试时;add_newline = no
ast-1.PJSIP.contacts.1876;@47519c5004a0a52468bd2e1570095db4.rtt:19|msast-1.PJSIP.contacts.states.Created:+1|gast-1.PJSIP.contacts.states.Created:-1|gast-1.PJSIP.contacts.states.Reachable:+1|g

statsd_exporter 映射规则

mappings:  - match: '([^.]+)[.]PJSIP[.]contacts[.]([^;]+)(;[^.]*)?[.]rtt'    match_type: regex    name: 'pjsip_contacts_rtt'    labels:      asterisk: '$1'      conact: '$2'

res_prometheus#

res_snmp#

# 编译需要额外依赖# ================apk install net-snmp-dev
net-snmp-config --agent-libs
# ./configure --with-netsnmp

配置#

/etc/asterisk/res_snmp.conf

[general]; 运行为子系统 - 需要 snmpd 启动 agentx; 非子系统需要 root - 绑定 161 端口subagent = no; 启动enabled = yes
asterisk -x 'module show like snmp'

/etc/snmp/snmpd.conf

# Asterisk usercreateUser asteriskUser MD5 "<your password>" DESrwuser asteriskUser priv
master agentxagentXSocket    /var/agentx/masteragentXPerms 0660 0550 nobody asterisk
# snmp v2snmpwalk -v2c -c public 127.0.0.1 1.3.6.1.4.1.22736.1# snmp v3snmpwalk -v 3 -u asteriskUser -l authPriv -a MD5 -A <your password> -x DES -X <your password> 127.0.0.1 ASTERISK-MIB::astVersionString

常用配置#

; debggingload => app_verboseload => app_dumpchan
load => res_rtp_multicastload => chan_rtp; rtp engineload => res_rtp_asteriskload => res_pjproject
load => pbx_config
; channel originateload => res_clioriginate
load => res_curlload => res_agi
; bridgeload => chan_bridge_mediaload => app_bridgeaddchanload => app_bridgewaitload => app_confbridgeload => bridge_builtin_featuresload => bridge_builtin_interval_featuresload => bridge_holdingload => bridge_native_rtpload => bridge_simpleload => bridge_softmix
; load all codecload => codec_a_muload => codec_adpcmload => codec_alaw; load => codec_dahdi ; need dahdi hardwareload => codec_g722load => codec_g726load => codec_gsmload => codec_ilbcload => codec_lpc10load => codec_resampleload => codec_ulaw; load all formatload => format_g719load => format_g723load => format_g726load => format_g729load => format_gsmload => format_h263load => format_h264load => format_ilbcload => format_pcmload => format_siren14load => format_siren7load => format_slnload => format_voxload => format_wavload => format_wav_gsm