230 likes | 445 Views
SER(SIP Express Router). Speaker: Changyu Wu Adviser: Quincy Wu Date:2007/02/07. Overview. Introduction Configuration file architecture Global parameter External module loading Module parameters Routing blocks Example program AVPOPS Exported Parameters Exported Functions Conclusion
E N D
SER(SIP Express Router) Speaker: Changyu Wu Adviser: Quincy Wu Date:2007/02/07
Overview • Introduction • Configuration file architecture • Global parameter • External module loading • Module parameters • Routing blocks • Example program • AVPOPS • Exported Parameters • Exported Functions • Conclusion • Reference
Introduction • SIP Express Router (SER) is a high-performance, configurable, free SIP server • It can act as SIP registrar, proxy or redirect server. • SER’ s configuration file is divided into four main sections. • Global parameter • External module loading • Module parameters • Routing blocks
Configuration file architecture ………………….. listen=163.22.16.33 alias=john.ipv6.club.tw port=5060 ……………….. loadmodule “/usr/local/lib/ser/ser/modules/mysql.so” loadmodule “/usr/local/lib/ser/ser/modules/auth_db.so” ………………. mdoparam(“auth_db”, “db_url”, “mysql://ser:password@localhost/ser”) modparam(“auth_db”, “calculate_ha1”, yes) ………………. route{ if (!uri==163.22.16.33){ …………………. break; } Global parameter External module loading Module parameters Routing blocks /usr/local/etc/ser/ser.cfg (OS:FreeBSD5.4)
Global parameter • alias: All requests with hostname matching an alias will satisfy the condition "uri==myself". • Ex: alias= ms11.voip.edu.tw • listen: list of all IP addresses or hostnames SER should listen on. • Ex: listen=163.22.16.40 • port: Listens on the specified port (default 5060). • Ex: port=5060
External module loading • loadmodule: Specifies a module to be loaded • loadmodule “/path/modules name” • Ex: • loadmodule “/usr/local/lib/ser/ser/modules/mysql.so” • loadmodule “/usr/local/lib/ser/ser/modules/auth_db.so”
Module parameters • modparam: Module parameter configuration. The commands takes three parameters: • module - Module in which the parameter resides. • parameter - Name of the parameter to be configured. • value - New value of the parameter. • modparam (“module”, “parameter”, “value”) • Ex:modparam(“auth_db”, “calculate_ha1”, yes)
Routing blocks • route[number]{...} - This marks a "route block" in configuration files. • route blocks are basic building blocks of ser scripts. • route(n), where n is number of the block. The action break exits currently executed route block. route[0] { # call routing block number 2 route(2); } route[2] { forward(“163.22.16.40", 5060); }
Conditional statements • A very useful feature is the ability to make routing logic depend on a condition. If (uri=~”^sip:[0-9].*@ms11.voip.edu.tw”){ …… } Else { ….. };
Domain matching • The easiest way to decide whether a request belongs a served domain is using the myselfoperand. alias=“ms11.voip.edu.tw" route[0] { if (uri==myself) { log(1,"request for served domain"); } else { log(1,"request for outbound domain"); # outbound forwarding t_relay(); }; }
Request URL Rewriting • SER has the ability to change request URI in many ways. • rewritehost(“hostname”) • Ex:rewritehost(“163.22.16.40”) • rewriteuri(“uri”) • Ex:rewriteuri(“sip:changyu@163.22.16.40”) If (method==INVITE){ if(uri~=“^(0-9).*@”){ rewritehost(“163.22.20.154”); forward(uri:host, uri:port); }; }
Authentication • Load auth modules • loadmodule “/usr/local/lib/ser/modules/auth.so” • loadmodule “/usr/local/lib/ser/modules/auth_db.so” • Module parameters • modparm(“auth_db”, “calculate_ha1”, yes) • modparm(“auth_db”, “password_column”, “password”)
Authentication (cont) If (uri==myself){ if (method==“REGISTER”){ If (!(www_authorize(“ms11.voip.edu.tw”, “subscriber”))){ www_challenge(“ms11.voip.edu.tw”, “0”); break; }; save(“location”); break; }; If (!lookup(“location”)){ sl_send_reply(“404”, “Not found”); };
Reply message • sl module • For the current request, a reply is sent back having the given code and text reason. sl_send_reply(code, reason) Ex: If (!lookup(“location”)){ sl_send_reply(“404”, “Not found”); };
AVPops • AVPops modules • Implementing services and preferences per user or domain. • The AVPops module exports functions for interfacing DB resources. • Exported Parameters. • Exported Functions.
Exported Parameters • avp_url (string) • modparam("avpops","avp_url","mysql://ser:passwd@localhost/ser") • avp_table (string) • modparam("avpops","avp_table","subscriber") • avp_aliases (string) • modparam("avpops","avp_aliases","uuid=i:660;email=s:email_address")
Exported Functions • avp_db_load(source,name) • source • $ruri - use information from RURI • $avp_alias - use the content of the AVP (defined by alias) as UUID • name • which AVPs will be loaded from DB into memory Ex: avp_db_load("$ruri","i:678");
Exported Functions (cont) • avp_write(value,name) • Value • $ruri - write RURI • value - write the value • Name • The name of the new written AVP avp_write(“4762",“s:phone");
Exported Functions (cont) • avp_pushto(destination,name) • destination • $ruri • username • domain • name • The name of the new written AVP avp_pushto(“$ruri/username”, “s:phone”)
Exported Functions (cont) • avp_check(name,op_value) • name • which AVP(s) should be checked • op_value • eq - AVP value equal to value • lt - AVP value less than value • gt - AVP value greater than value • The value can be: • $ruri - check against RURI • $from - check against FROM URI avp_check("s:person","eq/$from/I");
Rewrite uri route{ avp_db_load(“$ruri/username”, “s:tele”); avp_write(“4762”, “s:phone”); if (avp_check(“s:tele”, “eq/s:phone/g”)){ ……. ……. }; }
Conclusion • How can configuring SER • Four main sections • Routing block design • How use AVPops module
Reference • SER • http://www.iptel.org/ser/ • Install SER • http://ms11.voip.edu.tw/~changyu/Technological%20file/20061114_Changyu_SER.ppt • AVPops modules • http://www.voice-sistem.ro/docs/avpops/ • Registrar modules • http://www.openser.org/docs/modules/1.1.x/registrar.html • Auth_db modules • http://www.openser.org/docs/modules/1.1.x/auth_db.html • sl modules • http://www.openser.org/docs/modules/1.1.x/sl.html • RFC2617 • HTTP Authentication: Basic and Digest Access Authentication