asterisk模块编写

合集下载

asteriskagi编程函数解析收藏

asteriskagi编程函数解析收藏

asterisk agi 编程函数解析收藏一下内容转自网络。

IntroductionThe AGI facility allows you to launch scripts, written in just about any language, from an Asterisk dial plan. Communication between your script and Asterisk is via standard input and standard output.拨号方案中,可以采用各种语言很方便的通过AGI接口编写实施脚本。

脚本和Asterisk之间通过标准的输入输出进行交互。

Starting your scriptEach item in an extension is of the form:exten => extension-number,priority,application,argumentsTo launch an AGI script the application is 'agi' and the argument is the filename of your script. The script:执行AGI脚本时,Application应用就是'agi',参数是脚本的文件名,同时脚本需要满足以下条件∙must be executable 必须可执行,chomd 755∙must be located in /var/lib/asterisk/agi-bin 必须放置在指定目录∙must be specified complete with an extension 必须指定完整分机信息For example to run a Python script named 'test.py' then a suitable extension item would be:exten => 1,2,agi,test.pyWhen your script runs, you get a message saying so on the asterisk console provided you have your 'verbosity' level set to 3 or higher. If your script isn't found (you mis-typed the name) you will get a message saying failed to execute ... no such file or directory.If your script isn't executable (you forgot to give it execute permission) you will get a message saying failed to execute ... permission denied.脚本执行时,可以从控制台上得到不同基本的详细信息,例如,文件不能被执行,或者找不到文件等等。

标准ERP配置Asterisk服务器使用指南说明书

标准ERP配置Asterisk服务器使用指南说明书

CONFIGURING AN ASTERISK SERVERFrom Standard ERP's T elephony module, it is possible to fully configure an Asterisk server, whether it is installed locally on the same server as Standard ERP (only applicable on a Linux-based server) or on a separate remote server.It is also possible to integrate Standard ERP with an existing Asterisk server without managing its configuration directly from Standard ERP. Below are the steps required for a full integration, and will not explain what steps are required for local, remote, and existing servers.PBX ConnectionThe basic setting for integrating your Standard ERP system with an Asterisk server is a PBX Connection. A PBX Connection represents a connection to a unique actual VoIP Server.T o start with, you should create a new PBX Connection from the T elephony module in the PBX Connection register.A PBX Connection is defined primarily by:Code: The PBX unique identifier.Comment: A descriptive text.Type: The type of VoIP server to connect to; this can be chosen from a variety of Asterisk versions, TrixBox, Digium Switchvox, VPBX and 3CX Phone System 12 etc.Hostname: The hostname for the server being used.Host IP address: The IP address for the server being used.Port: The port through which the Asterisk's Management Interface (AMI) can be reached (5038 by default for Asterisk)Username: Username to connect to the AMI.Password:Password to connect to the AMI.Closed: A PBX Connection can be closed when it is no longer in use or valid.In the case of a locally or remotely installed Asterisk server, the T ype should be Asterisk 1.8 (AMI). The username and password can be freely set as they will be configured in the server for you.In case you are connecting to an existing server, the port, username, and password should match the content of your server's manager.conf file. Here is an example of manager configuration usable with Standard ERP:[general]enabled=yesport=5038bindaddr=0.0.0.0allowmultiplelogin=yesdisplayconnects=yestimestampevents=yes[myadmin]secret=passwordxyzdeny=0.0.0.0/0.0.0.0permit=1.2.3.4read=system,call,originatewrite=system,call,originateIn this case Port would be 5038, username myadmin and password passwordxyz. You should replace 1.2.3.4 by the IP address of your Standard ERP server.A PBX Connection has other fields organised in four tabs, and which are used when managing a local or remote server entirely from Standard ERP. Administrators using an existing server fully managed by some external means should skip over to the Contact records section.Dialling SettingsUnder this tab, you can configure the various telephony prefixes in use in your system.International Dial Prefix: T o dial out of your country.Country Code: T o dial in your country.Default Area Code: T o dial in your local area.External Line Prefix: T o dial out of your organisation.Skip Digit for International Calls:As its name indicates, you may also define digits to skip when dialling internationally.These parameters are used to place and receive calls, and to identify contacts based on their caller ID, including when using IAX (see below).RulesThis T ab allows to define a number of rules from various types:Ignore SIP Channel:In case of an existing server, this will ignore possible intermediary SIP channels to handle calls and instead only care about the end points. The Identifier is the name of the intermediary SIP channel to ignore.No Act For Calls Between Extensions Shorter Than: Disables the automatic Activity creation for internal calls (detected by the short length of internal extensions). This is only applicable for PBX Connections of the T ype Digium SwitchVox. The Identifier is the maximum length.Track number: Not used.Unique callers only: With this option, only one call will be displayed in Communicator even if there is more than one call from or to the number configured in Identifier.Remote AdministrationFrom this tab, you can define the following:Remote User: Linux user that will be used to copy the Asterisk configuration files to a remote serverRemote Configuration Directory: The path where to copy said configuration files. As such, it is important that the directory is writable by the Linux user and that your Standard ERP server has been set up to be able to connect directly to the remote Asterisk server without needing to enter a password (namely set up a Public Key Authentication between both servers).AsteriskFrom this final tab, you can enable the connection of your Asterisk server to other Asterisk server using IAX (Inter-Asterisk eXchange).Enable Inter-Asterisk eXchange(IAX):By ticking this option, you will allow all other PBX Connections configured in Standard ERP and set to use IAX to connect to this particular server as well as allow this server to connect to all other servers enabled for IAX and configured in Standard ERP.IAX Password: The password used by this server to connect to other IAX servers.Sending configuration to the serverThis section only applies to the local and remote servers situations.After completing the above configuration of a PBX Connection, you can already send the configuration to an Asterisk server.If you are running a local server, you can dump the configuration files by using the Local Asterisk Server settings from the T elephony module.First, you will need to install the Asterisk server by selecting Setup Asterisk Server in the Operation Menu. This will give you a warning pop-up reading “Starting download and installation of Asterisk server”. Click OK. This will download the binaries for the Asterisk Server from the HansaWorld servers and install them on your local server. The server will then be started. You should never have to use Setup Asterisk Server again after this.If you close the Local Asterisk Inspect window and reopen it, you will see the path where your server is installed.From the Operation Menu, you can also select “Update Asterisk Server Configuration” (which will dump the current configuration on the Asterisk server configuration directory and restart the Asterisk server so that the configuration is applied), Start Asterisk Server, and Stop Asterisk Server (which should both only rarely be used, for instance for external maintenance purposes).If you are running a remote server which is fully configured using Standard ERP, you should instead head to the Asterisk SIP Configuration Files maintenance in the Routines of the T elephony module.Use Paste Special in the PBX Connection to select the server you want to update, and tick Send Files to Server before running. If you do not tick this option, then the files will only be generated locally on your Standard ERP server.Note that this will only work if you have properly setup your PBX Connection and the Linux environment of your Asterisk server (see above).You can also select from the following other Maintenance Routines:!Asterisk SIP trunks.!Asterisk Users.These routines will generate respectively only the configuration files for the SIP trunks of a PBX Connection, or for its users, instead of regenerating all the files.Note that the files are only sent to the server but not applied. An administrator needs to connect manually to the Asterisk server and reload them. For instance by issuing a 'core reload' command from Asterisk's command line interface.Asterisk usersThe next step in setting up your Asterisk server is to create a number of users.This section is applicable for local and remote servers.From the T elephony module, you can create new Asterisk Users for your employees or partners.For each user, you can define:PBX Connections: One or more servers on which the user will be created and allowed to connect to. Leave blank to create the user on all PBX Connections configured.Name: A descriptive name.Username: Will be used to configure their SIP client.Password:Will be used to configure their SIP client.Group: No longer used.Caller ID number: The display number that might be shown to the party this user is calling. Note that this can easily be overridden by the configuration of a SIP client or SIP trunk. Especially when dialling out to international telephone numbers, Caller ID numbers are likely to get lost.Caller ID name: The display name that might be shown to the party this user is calling. Note that this can easilybe overridden by the configuration of a SIP client or SIP trunk.Especially when dialling out to a mobile or landline telephone number, plain text display names will be lost.Closed: A closed user will simply not be configured on the server and as such, it will not be possible to connect to the server using that user.No Queue Fallback: If an Asterisk User is marked as not being part of Queue Fallback, then that user will not be called when a queue is not staffed but is receiving a phone call.Note that after creating one (or more) Asterisk users, it is necessary to send the configuration to the server, as described above.Contact recordsThis section is applicable for all types of servers: local, remote, and existing.As of now, Asterisk users and Standard ERP users (Persons), and their contact cards are not connected and as such, Contact cards for your users will need to be filled in manually with their SIP contact details.In the SIP field of the contact record pertaining to your Asterisk user should be filled in as username@host name. Where username comes from the Asterisk User record, and hostname from the PBX Connection record.SIP TrunksThis section is applicable for local and remote servers.At this point of the configuration, you can place calls between users of your Asterisk server. T o reach out to the outside world, you will need a SIP trunk or VoIP trunk. Each country usually has several providers that can help you get started. As Asterisk is a commonly used VoIP server platform, it is easy to get help from your provider in general.A simple Internet search should allow you to find a number of SIP providers for your country.Using the information provided by your subscriber, you will be able to fill in the SIP Trunk record necessary for you to place calls to the rest of the world. A SIP provider will usually be able to sell you the usage of one, or more phone numbers that your contacts will be able to call to reach you. In some cases, your SIP provider might also allow you to place outgoing calls. Make sure to carefully select the SIP provider that is able to provide you with the capabilities you need to run your business smoothly.Setting up a SIP trunk comes with a wide array of technical possibilities, a number of which are supported inStandard ERP. We will detail some of those here but it is not possible to list all the possible technical configurations one can encounter.Code: Select a unique code for your SIP trunk.PBX Connection: Paste Special the PBX connection on which you want this SIP trunk to be terminated.Host: Fill in the host name or IP address provided by your SIP provider here. It might be that host and domain have the same value.Domain: Fill in the domain name provided by your SIP provider here. It might be that host and domain have the same value.Username: Fill in the username provided by your SIP provider here.Password: Fill in the information provided by your SIP provider here.Skip Digit for International Calls: This parameters operates similarly to that set in the PBX Connection but will apply to calls using the SIP trunk.Country Code:This parameters operates similarly to that set in PBX Connection but will apply to calls using the SIP trunk.Caller ID: The caller ID of your SIP trunk provider (optional).Allow anonymous calls: Lets the system accept anonymous calls coming from your providers.Allowed IPs: Only incoming calls coming from these IP addresses will be allowed. Please check with your SIP provider to only open the minimum number of addresses. (optional but important security point).Inbound phone numbers: A SIP provider may very well provide you several telephone numbers using the same SIP trunks. In certain cases, you will be given unique identifiers for each one of them. They should be filled in here. It might be that the usernames and passwords are the same as above.Trunk type:Set to Outbound calls only if you intend to input a separate configuration for Inbound Phone Numbers in the matrix as described just above. Set to In- and outbound calls if you do not have a separate configuration for Inbound Phone Numbers.IAX: Select this if your SIP trunk provider is providing you services using an Asterisk IAX trunk.Queues and MenusThis section is applicable for local and remote servers.Most of us are familiar with the telephony lines operated by large companies. A welcome Menu plays when you call into the support line of a company, after pushing a few digits on your phone and listening to a few more voice Menu messages, you are placed in a Queue. Thanks to Standard ERP's integration with Asterisk, your company can easily benefit from such technology.In Standard ERP's terminology, a Menu is used to select between different queues or menus; and a Queue is used to put in relation agents answering calls and external callers. Queues and Menus share a number of settings (Phone Numbers, Opening Times) and capabilities (Playing a sound upon arrival, when closed, etc.).Instructions for users to use queues can be found earlier in the document.A Queue contains the following information:Code: A unique identifier in Standard ERPQueue ID: A unique identifier in Asterisk which will be used by your employees to connect to the queue and start answering calls.SIP Trunk: The SIP trunk from where the calls will be arriving.Description: A free-text comment.Phone Number: (Optional) in the case where you want a direct number for callers to reach the queue without going through a Menu. Note: you can play a greetings message even in the case where callers go straight toa queue. You do not need a Menu to play a welcome message.Fallback number: An optional number to call in the case i) no agent is available in the queue AND ii) no one is logged in to the Asterisk server or everyone who is logged in is marked with “No Queue Fallback”.Open from/until: it is possible to define two sets of opening hours (to include the possibility of a lunch break for instance). In case only one set of opening hours is needed, use the first pair of “Open from”/”Open until”fields and leave the second pair blank.A Menu contains the following information:Code: A unique identifier.SIP Trunk: T he SIP trunk from where the calls will be arriving.Description: A free-text comment.Phone Number: The phone number for your contacts to dial in order to access the Menu. Optional in case the Menu is accessed via another Menu.Open from/until:It is possible to define two sets of opening hours (to include the possibility of a lunch break for instance). In case only one set of opening hours is needed, use the first pair of “Open from”/”Open until”fields and leave the second pair blank.Repeat every (s): The number of seconds between repeats of the message explaining to the caller his or her possible choices.A matrix finally allows you to configure the different Menus and Queues reachable from this Menu:Number: The digit to press for the user to enter the selected Queue or Menu. Note that in the case pressing the digit leads to entering a Queue, the digit need not be the same as the Queue ID defined in the Queue.Queue: Paste Special to an existing Queue (note, if you select this, you should not select a Menu as well).Menu: Paste Special to an existing Menu (note, if you select this, you should not select a Queue as well).Comment: A free-text comment as a reminder of what the selected Queue or Menu might be.Using Menus, you can cascade multiple levels of Menus. However, once a caller has joined a Queue, he or she will not be able to go back to another Queue or Menu.The last remaining part of the configuration is now to assign sound files to be played to guide your callers through your Menus and Queues.Whereas all the previous configuration was done in Registers of the T elephony module, sounds will be configured from the Settings of the T elephony module. More precisely, from the PBX Sounds setting.First, create a new PBX Sound. Then in Event, use Paste Special to select the type of Event that will trigger the sound file to play. The Event you select will affect whether you are selecting a Queue or a Menu in the following field. Available Events are:Initial Queue Message: Played as an initial greeting when a caller reaches a Queue.Line Busy: Played after 30 seconds of a caller waiting in a Queue.Menu Closed: Played whenever a caller arrives to a Menu outside of the defined opening hoursMenu Message: Played as an initial greeting when a caller enters a Menu (should also describes the options available from the Menu and the digits associated with each function).Music on Hold:Music to play while the caller is waiting in a Queue.Queue Closed: Played whenever a caller arrives to a Queue outside of the defined opening hours.Once an Event is selected, use Paste Special to select the Queue/Menu where the sound file should be used. Only one Queue or Menu can be selected. After Saving the Record, you can now attach a file to the Record following the usual way of dragging and dropping the file over the paperclip icon or into the Document Manager window which you can open by double-clicking the paperclip icon.Note: the attached sound file must be a mono.wav file, sampled at 8kHz.Remember to send the configuration to the server once done. The sound files will be copied during that stage a s well.。

Asterisk安装和测试

Asterisk安装和测试

Asterisk安装(红色字体部分为需要键入或修改的部分)下载准备系统环境:Linux CentOS 5.0,安装开发工具以及开发库。

Asterisk 源代码包asterisk-1.6.1.20.tar.gz,版本:1.6.1.20。

SIP软电话使用eyebeam 版本:1.5.8。

1.切换用户(需要输入管理员密码),执行su root2.进入源码包存放文件夹[root@asterisk-test1 ~]#cd /usr/local/src3.下载[root@asterisk-test1 ~]#wget/pub/telephony/asterisk/releases/asterisk1.6.1.20.tar.gz编译安装Asterisk1.解压源代码包[root@asterisk-test1 ~]# tar -zxvf asterisk-1.6.1.20.tar.gz2.进入包目录[root@asterisk-test1 ~]# cd asterisk-1.6.1.203.环境检测和预配置[root@asterisk-test1 asterisk-1.4.5]# ./configure(其实这样直接进行configure并非十分规范。

应当先使用“./configure –help”命令来查看一些可用的选项和参数,然后根据实际情况才进行定制操作。

)当环境预检测和预配置工作做完时,最后会显示以上反馈信息。

并且建立好Makefile。

注意:系统如果缺少安装必须的包,此步骤可能会出现configure: error错误,解决方案见后文可能遇到的问题configure: creating ./config.statusconfig.status: creating build_tools/menuselect-depsconfig.status: creating makeoptsconfig.status: creating channels/h323/Makefileconfig.status: creating include/asterisk/autoconfig.h.$$$$$$$$$$$$$$$=...$7$7.. .7$$7:..$$:. ,$7.7.$7. 7$$$$ .$$77..$$. $$$$$ .$$$7..7$ .?. $$$$$ .?. 7$$$.$.$. .$$$7. $$$$7 .7$$$. .$$$..777. .$$$$$$77$$$77$$$$$7. $$$,$$$~ .7$$$$$$$$$$$$$7. .$$$..$$7 .7$$$$$$$7: ?$$$.$$$ ?7$$$$$$$$$$I .$$$7$$$ .7$$$$$$$$$$$$$$$$ $$$.$$$ $$$$$$7$$$$$$$$$$$$ .$$$.$$$ $$$ 7$$$7 .$$$ .$$$.$$$$ $$$$7 .$$$.7$$$7 7$$$$ 7$$$$$$$$ $$$$$$$7. $$ (TM)$$$$$$$. .7$$$$$$ $$$$$$$$$$$$$$7$$$$$$$$$.$$$$$$$$$$$$$$$$$$$$$$.configure: Package configured for:configure: OS type : linux-gnuconfigure: Host CPU : i6864.清除陈旧的已编译文件[root@asterisk-test1 asterisk-1.4.5]# make clean5.重新编译Asterisk程序[root@asterisk-test1 asterisk-1.4.5]# make编译完成后会显示以下反馈提示信息,提示用户进行下一步可选的操作。

asterisk_phpagi简单开发第四版

asterisk_phpagi简单开发第四版

asterisk_phpagi简单开发第四版Asterisk phpagi开发入门不知不觉过了一个多月了哈,由于呼叫中心的项目进度比较缓慢,俺也就不急了,所以边做边玩,这一版俺讲讲AGI处理等待中的来电,当然这一个多月俺也把那个test.php 文件也做了一个比较大的改动。

具体请看下文。

本人水平有限,难免会有写的不周到或错误的地方,欢迎指正。

首先拨号规则基本没有动,前面几版都有说明,我就不再重复了先看看这个test.php脚本吧 #!/usr/bin/php�Cq//说明上面这个是php脚步的写法,/usr/bin/php是你的php安装目录(这段话是我写的说明,请勿放在test.php里)set_time_limit(60);ob_implicit_flush(false);include(\引用phpagi接口$num = $argv[1]; //这个就是带过来的通道变量${EXTEN}的值,获取来电者按了哪一个键或者拨了哪个分机$flag = $argv[2];//表示是分组还是直接拨分机号 $caller = $argv[3]; //来电号码$number = $num;//默认认为来电者直接拨分机号 $group = 0;//默认分组是0,表示直接拨分机号的 //表示是按了一个键,表示分组 if($flag){$group = $num; //分组号 $number =0;}$url=\.\r;$string = file_get_contents($url);//这个字符串是MV中间件返回的 $res = explode('|',$string);/*说明,我改动了这一部分$res[0]:规则状位(0:挂机或返回上一级、1:等待、2:可以接通)$res[1]:振铃状态(0:普通方式、1:同时振铃)$res[2]:可以dial的分机(如果$res[0]为2并且$res[1]为0,这里就是一个分机号;如果$res[0]为2并且$res[1]为1,这里就是多个分机号(SIP/8260&SIP/8263....),表示同时振铃 ) *//*调用远程接口去访问数据库,然后在接口里进行了复杂(嘻嘻)的运算,因为要考虑每个分机可能设置了呼叫转移啊,并且必须要满足一定的条件才可以触发呼叫转移,还有轮询查询每一个分机是否开启了呼叫保持,反正就是好几个递归,源码比较复杂,搞的我快精神崩溃了,呵呵,最终还是写出来了。

asterisk_phpagi简单开发第七版.

asterisk_phpagi简单开发第七版.

Asterisk phpagi开发入门第六版已经是一个初步完整的版本了,这一版,基本上算是第一阶段的收官之版了。

对于之前的录音问题,本人再次表示歉意。

本人水平有限,难免会有写的不周到或错误的地方, 欢迎指正。

首先拨号规则[ext-state]exten=> _XXXX,hint,SIP/${EXTEN}------------------------------------------------------没有变化重申一下 asterisk1.8的话,需要在 sip.conf 文件里需要改一个地方找到 ;callcounter=yes把前面的注释去掉好像有两处,随便某一处好像都可以context 我也做了一些优化和更新,请童鞋们注意[from-ivr-agi-transfer]exten => _XXXX,1,Dial(SIP/${EXTEN}exten => _XXXX,n,NoOp( Dial Status: ${DIALSTATUS}exten => _XXXX,n,Goto(s-${DIALSTATUS},1exten => s-NOANSWER,1,Goto(from-ivr-wait-hangup,w,1exten => s-CONGESTION,1,Goto(from-ivr-wait-hangup,w,1exten => s-CANCEL,1,Goto(from-ivr-wait-hangup,w,1exten => s-BUSY,1,Goto(from-ivr-wait-hangup,w,1exten => s-CHANUNAVAIL,1,Goto(from-ivr-wait-hangup,w,1-----------------------------------------------有变化了,这里主要解决了一个问题就是说在处理等待的 AGI 守护进程中再重定向之前,我会去判断一下被转移的目的分机是否状态正常正常则转移,不正常就继续等待,之前的 context 虽然实现了正常重定向转移但是对于 asterisk 的分机状态的获取很不稳定,也许判断的时候是正常的但是执行 AMI 指令开始重定向的时候分机是不正常的,导致来电会被挂掉这段新的 context 就是处理那种情况,让其继续等待,直到被转移成功或者时间到了挂掉,或者来电自己挂断[from-ivr-wait-hangup]exten => w,1,Playback(waitexten =>w,n,Playback(wait_mexten =>w,n,Hangup(exten => r,1,Playback(hungupexten =>r,n,Hangup([from-ivr-agi]exten => _66687XXX,1,Answer(exten => _66687XXX,n,Set(CHANNEL(language=cnexten => _66687XXX,n,Goto(from-ivr-agi,s,1exten => s,1,Background(companyexten =>s,n,Background(wait_mexten =>s,n,Hangup(exten =>_Z,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},0 exten => _Z,n,Hangup(include => from-ivr-wait-hangup-------------------------------------------------------注意exten =>_Z,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},0 最后一个参数表示多级分组的 ID 的字符串[two-from-ivr-agi]exten => s,1,Background(${IVR}exten =>s,n,Background(upexten =>s,n,Background(wait_mexten =>s,n,Hangup(exten =>_Z,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},${TEAM PATH} exten => _Z,n,Hangup(exten => *,1,Goto(from-ivr-agi,s,1exten => *,n,Hangup(include => from-ivr-wait-hangup----------------------------------------------------------exten =>_Z,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},${TEAM PATH} 最后一个参数表示多级分组的 ID 的字符串,这个是在 AGI 脚本里传过来的,下面我会说明 *号键返回上一级[three-from-ivr-agi]exten => s,1,Background(${IVR}exten =>s,n,Background(upexten =>s,n,Background(wait_mexten =>s,n,Hangup(exten =>_Z,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},${TEAM PATH} exten => _Z,n,Hangup(exten =>*,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},${TEAMP ATH} exten => *,n,Hangup(include => from-ivr-wait-hangup-------------------------------------------------------------------------这个是第三级目前是最后一级,当然是直接呼叫了*号键返回上一级 , 已经实现, AGI 脚本里会说明这个地方理论上可以支持无限分组了关键的exten =>_Z,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},${TEAM PATH} 和exten =>*,1,AGI(script_mv_agi.php,${EXTEN},${CALLERID(num},${CHANNEL},${TEAMP ATH} 这两段是不需要变的,这个也是核心,所以我说理论上原来的 test.php 我已经改名了 :script_mv_agi.php内容又变了#!/usr/bin/php -qanswer(;if($string{$res = explode('|',$string;$context = $res[4]; //当前所在的 contextif($res[0]==3{$agi->set_variable('IVR',$res[3];//这个就是对应分组播放的 IVR$team_path = $res[5];$agi->set_variable('TEAMPATH',$team_path;//这个就是当前分组的各级父分组的 ID 字符串$agi->exec_goto("$context,s,1";//注意 asterisk 1.8 这个地方是逗号。

Asterisk核心框架

Asterisk核心框架

Asterisk内核框架Asterisk是一个开源的pbx系统,在公开的资料中,很难找到asterisk内核系统的详细描述。

因此,很有必要写一篇内核框架的描述文档,作为内部培训文档,相互学习提高。

本文主要从三个层面来描述asterisk内核,即asterisk内核模块、内核启动过程、基本呼叫流程。

一、asterisk内核模块Asterisk由内部核心和外围动态可加载模块组成。

内部核心由以下六个部分组成:PBX交换核心模块(PBX Switching Core)、调度和I/O管理模块(Scheduler and I/O Manager)、应用调用模块(Application Launcher)、编解码转换模块(Codec Translator)、动态模块加载器模块(Dynamic Module Loader)和CDR生成模块(CDR Core)。

外围动态可加载模块包括以App_开始的Applications、以Func_开始的Functions、以Res_开始的Resources、以Chan_开始的channels、以Codec_开始的codec编解码模块等。

1.内核模块1) PBX交换核心模块(PBX Switching Core):l pbx.cpbx.c是asterisk的核心模块,每路呼叫都需要经过它调度。

pbx实现了builtin applications,也就是内置的应用,比如最常见的Answer,Hangup, Background,Wait等等。

struct ast_app是一个关键数据结构,它定义了注册builtin applications的结构。

load_pbx函数用来注册builtin applications和一些命令行CLI命令(每个模块都有些CLI 命令)。

该函数在系统启动时被调用。

pbx_exec是Answer/BackGround/Busy/Goto/GotoIf/Hangup/Set等builtin applications的执行入口函数,它被pbx_extension_helper调用。

Asterisk权威指南中文版-第02章Asterisk体系结构

Asterisk权威指南中文版-第02章Asterisk体系结构

第二章 Asterisk体系结构目录2.1 Modules (2)2.1.1 Dialplan Applications (3)2.1.2 Bridging Modules (6)2.1.3 Call Detail Recording Modules (6)2.1.4 Channel event logging modules (7)2.1.5 Channel Drivers (7)2.1.6 Codec Translators (8)2.1.7 Format Interpreters (9)2.1.8 Dialplan Functions (10)2.1.9 PBX Modules (12)2.1.10 Resource Modules (12)2.1.11 Addon Modules (14)2.1.12 Test Modules (15)2.2 文件结构 (15)2.2.1 Configuration files (15)2.2.2 Modules (15)2.2.3 The Resource Library (15)2.2.4 The Spool (16)2.2.5 Logging (16)2.3 The Dialplan (16)2.4 硬件 (16)2.5 Asterisk版本 (17)2.5.1 以前的版本号机制 (17)2.5.2 新的版本机制 (18)2.6 结论 (18)Asterisk完全不同于其他的,更加传统的PXB系统。

在Asterisk中,dialplan基本上采用完全一样的方法处理所有呼入channel。

在传统PBX中,“内线”和“外线”在逻辑上是分开的。

举例来说,你不能把一个外部网关联接到PBX的内线分机端口上,用户也无法在不按下外线数字的情况下拨打外线(例如,很多的IP PBX拨打外线要加拨“0”)。

与此相反,在Asterisk中并没有严格的“内线”和“外线”的概念。

AsteriskConfig(Asterisk配置)

AsteriskConfig(Asterisk配置)

配置AsteriskSiSky企业版为Asterisk提供多达16路的Skype通道!方法1:配置Asterisk(例如:Asterisk不带有freePBX) --> 请点击这儿。

方法2:配置 Asterisk(例如: Asterisk+freePBX 或 Trixbox )。

下列以16个通道为例,您可以创建从501到516这16个SIP帐号作为SiSky的SIP 端口。

1. 将下面的内容添加到extensions_custom.conf的[from-internal-custom]中: exten => _500.,1,Dial(SIP/${EXTEN:0}@501)exten => _501.,1,Dial(SIP/${EXTEN:0}@501)exten => _502.,1,Dial(SIP/${EXTEN:0}@502)exten => _503.,1,Dial(SIP/${EXTEN:0}@503)exten => _504.,1,Dial(SIP/${EXTEN:0}@504)exten => _505.,1,Dial(SIP/${EXTEN:0}@505)exten => _506.,1,Dial(SIP/${EXTEN:0}@506)exten => _507.,1,Dial(SIP/${EXTEN:0}@507)exten => _508.,1,Dial(SIP/${EXTEN:0}@508)exten => _509.,1,Dial(SIP/${EXTEN:0}@509)exten => _510.,1,Dial(SIP/${EXTEN:0}@510)exten => _511.,1,Dial(SIP/${EXTEN:0}@511)exten => _512.,1,Dial(SIP/${EXTEN:0}@512)exten => _513.,1,Dial(SIP/${EXTEN:0}@513)exten => _514.,1,Dial(SIP/${EXTEN:0}@514)exten => _515.,1,Dial(SIP/${EXTEN:0}@515)exten => _516.,1,Dial(SIP/${EXTEN:0}@516)注意:exten => _500.,1,Dial (SIP/${EXTEN:0}@501)---表示自动从第1个到第16个Skype通道中,寻找空闲的通道进行呼出。

asterisk 编译

asterisk 编译

asterisk 编译Asterisk 是一个开源的电话交换机,它允许你连接各种电话设备,包括传统的电话线路、VoIP 网关、SIP 设备等。

要编译 Asterisk,你需要遵循以下步骤:1. 安装依赖:在编译 Asterisk 之前,你需要确保你的系统上安装了所有必需的依赖项。

这些依赖项可能因操作系统而异。

以下是在 Ubuntu 系统上的一些常见依赖项:arduinosudo apt-get updatesudo apt-get install build-essential libncurses5-dev libncursesw5-dev libcurl4-openssl-dev libsigc++-2.0-dev unixodbc-dev gcc-sodbc2. 下载源代码:从 Asterisk 的官方网站下载最新的源代码。

你可以从它们的网站上找到最新的版本和下载链接。

将下载的源代码解压到一个目录中。

3. 配置:进入解压后的源代码目录,运行以下命令进行配置:bashcd asterisk-*./configure这将检查你的系统上是否已安装所有必需的依赖项,并生成一些配置文件。

在配置过程中,你可以使用 --prefix 选项指定 Asterisk 的安装目录。

例如:bash./configure --prefix=/usr/local/asterisk4. 编译:运行以下命令开始编译 Asterisk:gomake这将编译 Asterisk 的源代码并生成可执行文件。

5. 安装:运行以下命令将 Asterisk 安装到你的系统中:gosudo make install这将把 Asterisk 可执行文件复制到指定的安装目录。

6. 配置环境变量:为了让系统能够找到 Asterisk 可执行文件,你需要将 Asterisk 的路径添加到 PATH 环境变量中。

例如,如果你将 Asterisk 安装在/usr/local/asterisk 目录下,你可以通过编辑 /etc/profile 文件来添加 PATH 环境变量:bashecho 'export PATH=/usr/local/asterisk/bin:$PATH' >>/etc/profilesource /etc/profile7. 设置权限:运行以下命令为 Asterisk 可执行文件设置适当的权限:bashsudo chmod +x /usr/local/asterisk/bin/asterisk。

asterisk源码解读

asterisk源码解读

Asterisk是一个开源的电话系统软件,其源码包含了大量的代码和模块,解读Asterisk源码需要一定的编程和电话系统知识。

以下是一些解读Asterisk源码的建议:了解Asterisk的基本架构和模块:Asterisk是一个模块化的软件,由多个模块组成,包括应用程序、设备驱动、协议模块等。

在解读源码之前,需要了解Asterisk的基本架构和各个模块的功能和作用。

学习C语言和编程知识:Asterisk 的源码是使用C语言编写的,因此需要具备一定的C语言和编程知识,以便更好地理解源码的结构和逻辑。

阅读代码注释和文档:Asterisk的源码中包含了大量的注释和文档,这些注释和文档可以帮助理解代码的作用和实现方式。

逐个模块阅读代码:从Asterisk的入口函数开始,逐个模块阅读代码,了解每个模块的功能和实现方式。

调试和测试:在解读源码的过程中,可以通过调试和测试来验证代码的功能和正确性。

需要注意的是,Asterisk的源码非常庞大和复杂,需要花费大量的时间和精力来解读和理解。

因此,建议在解读源码之前先了解一些基本的电话系统和编程知识,以便更好地理解和掌握Asterisk的源码。

asterisk配置实例

asterisk配置实例

Erik写了一个关于dailplan的配置实例,主要是改写asterisk中的配置文件extensions.conf,修改后的文件我放到了附件当中。

简单说明一下如何使用该配置文件
1)下载附件后,存放到/etc/asterisk/extensions.conf中,extensions的作用表征手机号码和手机地址映射关系
2) 在同目录下的sip.conf增加几行,一个SIM 卡对应一个入口配置,所以有几张SIM卡就要复制几段
[IMSI204123170034543] ;这个204123170034543就是注册到bts中的sim卡的IMSI号,可以通过log文件,或者tmsis命令查看到
callerid=IMSI204123170034543 <IMSI204123170034543>
canreinvite=no
type=friend
allow=gsm
context=sip-internal
host=dynamic
3)运行:首先运行asterisk -r进入到控制台,然后运行openbts,你可以在asterisk的控制台中看到手机注册的信息
4)电话号码申请手机成功注册后,可以通过拨号的方式申请电话,由于里面的配置限制,可以申请1001-1012 共12个电话号码
申请过程:号码前加拨0 如拨打01002, 你会听到提示音,提示输入pin码,此时你只需要输入1234# 就可以成功申请了,1234是配置文件里设置的默认pin码,可以很容易通过修改配置文件改变
5)其他功能,里面还设置了一些特殊号码的使用,仔细阅读,如01234退订所有申请的号码,只需要简单的阅读,就能明白。

asterisk1.2代码学习笔记

asterisk1.2代码学习笔记

Ippbx平台相关的Cvs 目前IX在CVS目录ippbx/ipbxsource/ix_src_polylink下,版本可查看目录下的.version文件命令lsb_release –a和uname –a可以查看OS的信息查看程序的版本:在代码的根目录下cat .version编译方法:在根目录下make;make install发布版本:/PolyLink/usr下的sbin/ippbx、lib/modules/PolyLink/etc是配置文件使用ippbx –g(ippbx –gvvvc)开启,然后使用ippbx –r/ippbx -ddddddddvvvvvvvvcr连接上去重启ippbx用命令(在ippbx –r中)restart now,stop now可以停止在命令行添加命令后要重启ippbx,每次编译完后也要重启使用reload重新加载某个函数时,会调用模块的reload()函数ast_log函数的使用debug level 1 app_queue.cAsterisk 的编解码的配置要配置在每个帐号里面。

加在genenal里面是不行的/PolyLink/etc/modules.conf可以控制是否加载某些模块,参考文件asterisk.c中的main()函数关键配置文件:sip.conf,queues.conf(排队相关的),manager.conf(座席,带member 的),extension.conf(规则),modules.conf(控制模块加载)登录座席的时候,先登录座席的软电话才可以登录成功。

int init_manager(void)中注册的模块用于座席软件通过manager interface,向PBX发送redirect 消息,与命令行无关,ast_cli_register()是注册命令行的。

有一个叫sysmoni的进程,先把这个进程杀了,ippbx就不会自己重启了/////////////////////////////////////////////////////http://192.168.10.121/ipbx/login.dosystem 123在web上保存信息时,ippbx会重启。

Asterisk 代码架构概述(译)

Asterisk 代码架构概述(译)

Asterisk 代码架构概述(译)注意:这篇文档所描述的内容,可能已经过时。

为了保证您所获取的信息是最新的,请您确保您使用的文档是从Asterisk的trunk上生成的。

运行时,Asterisk加载了许多模块。

Asterisk的模块都有具体的名称,以标识模块所提供的功能,但是,这些名称没有任何技术意义上的特殊。

Asterisk 加载一个模块时,模块向内核注册它所提供的功能。

整个流程看起来是这样的:1.启动Asterisk2.Asterisk加载模块3.模块跟内核说:嗨,Asterisk,我是一个模块,我能提供X、Y、Z三种功能,用得着的时候要记得我哦。

3抽象接口类型Asterisk提供了许多不同类型的接口,具体的模块可以实现这些接口并注册给内核调用。

任何模块,都可以注册任意多种的接口。

通常,一个模块内整合了某些相关的功能。

本节讨论接口的类型,后续将讨论各种场景下不同组件间的协作关系。

3.1 编码解释器CodecInterpreter编码解释器接口的实现,提供了两种编码间的转换能力。

Asterisk当前只有音频编码转换的能力。

这些模块不了解话务相关的任何信息,也不知为什么要调用它们进行音频转换。

它们仅需要知道音频采样率、音频的输入格式、期待的输出格式这些信息。

如果注册了多个编码解释器,那么编码A转换为编码B的过程,就可能有多种不同的转换路径。

在(编码)模块加载之后,Asterisk建立一张转换表,表中包含不同translator的转换开销评估值,因此,Asterisk能够找出A转换B的最佳路径。

在源码树中,编码模块通常在codecs/目录下。

已有编码解释器的实现列表,请参考:Module:Codecs更多编码解释器API的信息,请参考接口定义文件:include/asterisk/translate.h.内核关于编码解释器的相关实现,参考源码:main/translate.c3.2文件格式处理器File Format Handler文件格式处理器接口的实现,为Asterisk提供了读写文件的能力。

Asterisk实战

Asterisk实战

Asterisk目录
AGI脚本目录: /var/lib/asterisk/agi-bin/ Asterisk语音:/var/lib/asterisk/sounds/ Asterisk配置文件: /etc/asterisk/ 录音目录: /var/spool/asterisk/monitor/ Asterisk日志: /var/log/asterisk/
Asterisk实战
--samuel.li<weiyesoft@>
安装配置
1、Asterisk 官方站点: 2、Asterisk yum 安装 配置yum源: /downloads/yum 安装asterisk: yum -y install asterisk18 安装FreePBX yum -y install freepbx 3、FreePBX初始管理员账号密码: freepbx/fpbx
实践
1. 2. 3. 4. 5. 用FreePBX配置Asterisk 跟踪Dialplan流程 编写Dialplan:掌握context、Macro编写方法 编写AGI脚本 使用manager 编写客户端控制程序,如点击页面链接拨打顾客电 话。
其它
参考网址 免费的soft phone sjphone x-lite
令)、Orginate、SetVar、GetVar 4、Manager API的配置文件: /etc/asterisk/manager.conf 5、Manager 端 口: 5038 tcp
学习AGI
1、AGI: Asterisk Gateway Interface 用于扩展Asterisk功能,可以用Perl、PHP、SHELL或C来编 写、通过Application Comand中的AGI、DeadAGI调用。 2、通过EAGI、AGI、DeadAGI、FastAGI调用AGI程序。 3、AGI脚本中的几个重要变量: agi_channel、agi_uniqueid、agi_callerid、agi_dnidnds的库来进行AGI脚本编写。

基于Asterisk的VoIP开发指南—Asterisk模块编写指南

基于Asterisk的VoIP开发指南—Asterisk模块编写指南

基于Asterisk的VoIP开发指南—Asterisk模块编写指南1.开源项目概述Asterisk是一个开源的软件包,通常运行在Linux操作系统平台上。

Asterisk可以用三种协议来实现VoIP,同时可以与目前电话使用的标准硬件进行交互通信,Asterisk在实现VoIP时,不需要任何附加硬件,本文所采用的也是这种使用方式。

但是,如果企业没有与VoIP 语音网关运营商建立合作关系,想要自己构建这样的一个平台,那么要和数字电话设备与模拟电话设备进行交互通信,Asterisk需要一个PCI硬件的支持,这个硬件生产商中最著名的是Digium平台提供的。

Asterisk 的结构基本上是十分简单,但是它不同于大多数的电话产品。

基本上,Asterisk担任的是一个中间件的功能,它连接了底层的电话技术和上层的电话应用。

所以,Asterisk 具有很大的柔韧性,特殊的API接口都围绕着PBX核心系统。

这个核心处理着PBX内部之间的相互联系。

每一部分都是清晰来自于协议、编码或内部电话使用的硬件接口的抽象。

这些抽象的接口使Asterisk可以与任何的硬件和技术以及将来的硬件和软件技术完美的结合。

从图2.5可以看出,Asterisk由内部核心和外围动态可加载模块组成。

内部核心由以下六个部分组成:PBX交换核心模块(PBX Switching Core)、调度和I/O管理模块(Scheduler and I/O Manager)、应用调用模块(Application Launcher)、编解码转换模块(Codec Translator)、动态模块加载器模块(Dynamic Module Loader)和CDR生成模块(CDR Core) 。

图1 Asterisk结构图2.Asterisk二次开发概述Asterisk是一个开源的PBX架构;但它并不是一个成品。

通常情况下,由于企业应用的多样性,很难有一个成型的PBX产品可以满足企业的各种需求。

Asterisk 中 队列的简单实现

Asterisk 中 队列的简单实现

Asterisk 中队列的简单实现所谓队列,个人理解是一个什么什么电话组,可以实现呼入电话在座席分机上轮询呼叫及其它控制,一般用于呼叫中心。

你可以在freepbx 中图形界面去控制队列,下面是简单的纯代码实现队列,简要把我的理解写到上面。

............................................................................................................ .................................................................................一:编辑queues.conf ,添加静态座席及其它控制参数(简要介绍几个常用的参数)view plaincopy to clipboardprint?1.[general] ;这些是系统默认的2.persistentmembers = yes3.autofill = yes4.monitor-type = MixMonitor5.[jh]6.musicclass=default//默认播放的音乐7.strategy= ringall //振铃策略8.timeout=15 //每个座席分机的振铃时间9.retry=0 // 表示队列呼叫失败后,给多少秒再重新呼叫分机的振铃时间,一般我设置为010.weight=0 //权重,一般设置默认为0,好像没看到所有什么特别之处11.wrapuptime=012.member => SIP/8111,113.member => SIP/8112,n14.。

//这里还可以写很多队列分机二:添加一个Dialplan 呼叫规则到队列中应用view plaincopy to clipboardprint?1.exten => 9999,1,Answer()2.exten => 9999,n,Queue(jh,t,,,30) ;jh 为上面的队列名称,30秒为呼叫整个该队列的超时时间3.exten => 9999,n,Hangup()添加后。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
让我们继续进行同时包含使用 Asteisk 日志模块接口,用于显示 Asterisk 日志信息,显
示日志信息也是本模块所要做的事情。 #include "asterisk/logger.h"
现在包含每个 Asterisk 模块必须的使用的两个函数,load_module()和 unload_module().
通过 CLI 命令可以自己卸载、加载你的模块,可以观测到日志信息。 *CLI> module unload res_helloworld.so
[Jun 19 10:50:57] NOTICE[26612]: res_helloworld.c:35 unload_module: Goodbye World! *CLI> module load res_helloworld.so
Asterisk1.6 的,为 Asterisk1.4 编写模块几乎一样。创建的文件名为 res_helloworld.c,存放在
Asterisk 的源代码树/res 目录下。
首先每个 Asterisk 模块都包含主要的 Asterisk 头文件,asterisk.h #include "asterisk.h“
ast_cdr_register("HelloWorld", "Hello World CDR Handler", cdr_helloworld); 在 unload_module() 中,需要对刚刚添加的应用注销。
ast_cdr_unregister("HelloWorld");
编译安装后,运行 Asterisk ,可以去确认你的新 CDR 应用是否被注册到了 Asterisk
这个功能。 复制代码 static char *handle_cli_echo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) {
switch (cmd) { case CLI_INIT:
e->command = "echo"; e->usage =
最后,每个模块必须包含 AST_MODULE_INFO 宏实例。该宏包含模块必要代码是用
于该模块被加载时向 Asterisk core 注册自己。 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Hello World");
最终的结果构成 res_helloworld.c 文件。
Core 。
*CLI> cdr show status ... CDR registered backend: HelloWorld

当你挂电话,将会看到 CDR 处理被执行。
[Jun 20 18:08:29] NOTICE[4922]: res_helloworld.c:36 cdr_helloworld: We got a CDR for channel ‘SIP/5001-007e9da8′. Source: ‘5001′, Dest: ‘586′, Duration: 1
当 Asterisk 加载和卸载模块时会调用他们。 static int load_module(void) { ast_log(LOG_NOTICE, "Hello World!\n"); return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { ast_log(LOG_NOTICE, "Goodbye World!\n"); return 0; } static int unload_module(void) { ast_log(LOG_NOTICE, "Goodbye World!\n"); return 0; }
相反的,unload_module 的工作是“ Hello Asterisk, again. I’m about to disappear, so please don’t use any of these features that I was providing to you anymore. If you do, you’ll explode. kthx! ”
接下来,将刚刚实现的应用通过 load_module() 和 unload_module() 函数经新功能添加到 该模块中去。
在 load_module() 函数中,将增加一个函数调用用于向 Asterisk Core 注册该 CDR 处理。 参数是该应用的名称,简短的描述,以及当 CDR post 时 Asterisk Core 调用函数。
现在是更新模块提供功能给 Asterisk 的时候了。我们将从 CDR 处理开始,CDR 接口不 算是一个非常简单的应用。首先是添加合适的头文件。
#include "asterisk/cdr.h" 然后,我们增加一个新的函数,该函数在每次 CDR post 时将会调用,参数是 CDR 本 身。
static int cdr_helloworld(struct ast_cdr *cdr) {
在本文里,你将看到如何实现一个 Asterisk CLI 命令。CLI 命令对于显示配置信息、统
计信息和其它调试目的来说都是非常有用的。我们继续编辑上一篇文章中的那个
res_helloworld2.c。
第一步是加载定义 CLI 命令接口的头文件: #include "asterisk/cli.h"
下面是实现 CLI 命令“echo”的代码,简单地打印了 CLI 命令的第一个参数,后面会解释
[Jun 19 10:51:05] NOTICE[26612]: res_helloworld.c:42 load_module: Hello World! Loaded res_helloworld.so => (Hello World) 祝贺你,你已经成功的完成了 Asteisk 模块编写! 下一步,我们将开始实现在 Asteirsk 模块中更有用的应用。请看下一篇《Asterisk 模块 编写 2—进阶》。 上一篇文章《Asterisk 模块编写入门》里已经解释了 Hello World Asterisk 模块。该模块只实 现了能够给 Asterisk 编译,能够加载到 Asteisk 中去,当被加载或卸载时打印简单的日志信 息。现在让该模块做些更有意义的事情。
下面这小段代码表示至少给函数提供了一个参数。值得注意的是,这里的 ast_cli_entry 参数用于检索多少命令本身定义的参数和 ast_cli_args 参数用于检索多少参数,实际上是在 CLI 命令行下执行此命令时指定的。如果它们相等,那么就能提供简单的“echo”。
if (a->argc == e->args) { ast_cli(a->fd, "You did not provide an argument to echo\n\n"); return CLI_SHOWUSAGE;
你已经可以在 Arisk 模块编写 3--高级
下面是通过基本接口来为 Asterisk 提供更多功能系列文章的第三篇--Asterisk 模块编写 3--高
级。
第一篇《Asterisk 模块编写 1--入门》
第二篇《Asterisk 模块编写 2--进阶》
"Usage: echo <stuff>\n" " Print back the first argument.\n" "Examples:\n" " echo foo\n" " echo \"multiple words\"\n" ""; return NULL; case CLI_GENERATE: return NULL; }
接下来,包含 ASTERISK_FILE_VERSION 宏,该宏用于注册该文件的版本,通过 CLI
命令“core show file version like filename”命令查看文件 SVN 版本。
包含 Asterisk 模块头文件,包含该头文件是定义实现 Asterisk 模块所必须的。 #include "asterisk/module.h"
if (a->argc == e->args) { ast_cli(a->fd, "You did not provide an argument to echo\n\n"); return CLI_SHOWUSAGE;
}
ast_cli(a->fd, "%s\n", a->argv[1]);
return CLI_SUCCESS; }
这个 CLI 处理程序相匹配的 CLI 命令处理程序定义的函数原型。ast_cli_entry 参数包括 有关 CLI 命令正在执行的静态信息。当 CLI 命令非正常执行其他调用的时候,会设置 cmd 参 数。该 ast_cli_args 参数包含这一命令一次执行的特定信息,如同命令参数。
static char *handle_cli_echo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
重新编译 Asterisk,编译系统将自动发现该模块,该模块像其他模块一样,也会被编译,
最后安装。通过编译,安装,运行 Asterisk,这时可以确认你的模块是否被正确的加载: *CLI> module show like helloworld Module Description Use Count res_helloworld.so Hello World 0 1 modules loaded
相关文档
最新文档