背景介绍
dialplan 主要用于号码转换,规则匹配替换等. 必须依赖数据库,从数据库读取规则。
kamailio 的版本:
version: kamailio 5.8.5 (x86_64/linux)
参数解析
|
|
重要函数
dp_replace(dpid, inval, outvar)
根据dpid
规则,把inval
替换成dpid
表达式下的数据存储在outvar
中.
dp_match(dpid, inval)
根据dpid
规则匹配inval
dp_translate(id, [src[/dest]])
根据id
规则转换src
成dest
,如果没有dest
,只匹配src
,并存储attrs
到$avp(s:dest)
里。此id
还是dpid
实战
构造数据
- 表结构
name type size default null key extra attributes description id unsigned int 10 no primary auto increment unique ID dpid int 11 no Dialplan ID pr int 11 no Priority of rule match_op int 11 no Matching operator for rule (0-equal, 1-regexp) match_exp string 64 no Matching expression (regexp or string) match_len int 11 no Length of the matching expression (used only for equal operator) subst_exp string 64 no Substitution expression repl_exp string 256 no Replacement expression (sed like) attrs string 64 no General attributes string to be returned in case of rule matching
所有的字段都要填写
- 数据
|
|
配置示例
|
|
目前使用的规则是号码添加前缀200
, 实际效果打印的日志为:
|
|