No subject
Wed Jun 9 03:17:30 CEST 2010
<BR>
All call with $rU=="0216666" is forwarded to the video AS as the route[CONF].<BR>
<BR>
Thanks in advance!<BR>
<BR>
Thanks,<BR>
Kevin<BR>
<BR>
Below is the current config of the kamailio server:<BR>
<BR>
==============CFG=============<BR>
AppSer01:root@/usr/local/kamailio-3.0/etc/kamailio$ cat kamailio.cfg<BR>#!KAMAILIO<BR>#!define WITH_DEBUG<BR>#!define WITH_MYSQL<BR>#!define WITH_AUTH<BR>#!define WITH_USRLOCDB<BR># $Id$<BR>#<BR># Kamailio (OpenSER) SIP Server v3.0 - basic configuration script<BR># - web: <A href="http://www.kamailio.org">http://www.kamailio.org</A><BR># - git: <A href="http://sip-router.org">http://sip-router.org</A><BR>#<BR># Direct your questions about this file to: <<A href="mailto:users at lists.kamailio.org">users at lists.kamailio.org</A>><BR>#<BR># Refer to the Core CookBook at <A href="http://www.kamailio.org/dokuwiki/doku.php">http://www.kamailio.org/dokuwiki/doku.php</A><BR># for an explanation of possible statements, functions and parameters.<BR>#<BR># Several features can be enabled using '#!define WITH_FEATURE' directives:<BR>#<BR># *** To run in debug mode: <BR># - define WITH_DEBUG<BR>#<BR># *** To enable mysql: <BR># - define WITH_MYSQL<BR>#<BR># *** To enable authentication execute:<BR># - enable mysql<BR># - define WITH_AUTH<BR># - add users using 'kamctl'<BR>#<BR># *** To enable persistent user location execute:<BR># - enable mysql<BR># - define WITH_USRLOCDB<BR>#<BR># *** To enable presence server execute:<BR># - enable mysql<BR># - define WITH_PRESENCE<BR>#<BR># *** To enable nat traversal execute:<BR># - define WITH_NAT<BR># - install RTPProxy: <A href="http://www.rtpproxy.org">http://www.rtpproxy.org</A><BR># - start RTPProxy:<BR># rtpproxy -l _your_public_ip_ -s udp:localhost:7722<BR>#<BR># *** To enable PSTN gateway routing execute:<BR># - define WITH_PSTN<BR># - set the value of pstn.gw_ip<BR># - check route[PSTN] for regexp routing condition<BR>#<BR># *** To enhance accounting execute:<BR># - enable mysql<BR># - define WITH_ACCDB<BR># - add following columns to database<BR>#!ifdef ACCDB_COMMENT<BR> ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';<BR> ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';<BR> ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';<BR> ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';<BR> ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';<BR> ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';<BR> ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';<BR> ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';<BR> ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';<BR> ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';<BR>#!endif<BR>
<BR>####### Global Parameters #########<BR>
#!ifdef WITH_DEBUG<BR>debug=4<BR>log_stderror=no<BR>#!else<BR>debug=2<BR>log_stderror=no<BR>#!endif<BR>
memdbg=5<BR>memlog=5<BR>
log_facility=LOG_LOCAL0<BR>
fork=yes<BR>children=4<BR>
/* uncomment the next line to disable TCP (default on) */<BR>#disable_tcp=yes<BR>
/* uncomment the next line to disable the auto discovery of local aliases<BR> based on revers DNS on IPs (default on) */<BR>#auto_aliases=no<BR>
port=5060<BR>
/* uncomment and configure the following line if you want Kamailio to <BR> bind on a specific interface/port/proto (default bind on all available) */<BR>listen=udp:210.13.124.15:5060<BR>
<BR>####### Custom Parameters #########<BR>
# These parameters can be modified runtime via RPC interface<BR># - see the documentation of 'cfg_rpc' module.<BR>#<BR># Format: group.id = value 'desc' description<BR># Access: $sel(cfg_get.group.id) or @cfg_get.group.id<BR>#<BR>
#!ifdef WITH_PSTN<BR># PSTN GW Routing<BR>#<BR># - pstn.gw_ip: valid IP or hostname as string value, example:<BR># pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"<BR>#<BR># - by default is empty to avoid misrouting<BR>pstn.gw_ip = "" desc "PSTN GW Address"<BR>#!endif<BR>
<BR>####### Modules Section ########<BR>
#set module path<BR>mpath="/usr/local/kamailio-3.0/lib/kamailio/modules_k/:/usr/local/kamailio-3.0/lib/kamailio/modules/"<BR>
/* uncomment next line for MySQL DB support */<BR>#!ifdef WITH_MYSQL<BR>loadmodule "db_mysql.so"<BR>#!endif<BR>loadmodule "mi_fifo.so"<BR>loadmodule "kex.so"<BR>loadmodule "tm.so"<BR>loadmodule "tmx.so"<BR>loadmodule "sl.so"<BR>loadmodule "rr.so"<BR>loadmodule "pv.so"<BR>loadmodule "maxfwd.so"<BR>loadmodule "usrloc.so"<BR>loadmodule "registrar.so"<BR>loadmodule "textops.so"<BR>loadmodule "uri_db.so"<BR>loadmodule "siputils.so"<BR>loadmodule "xlog.so"<BR>loadmodule "sanity.so"<BR>loadmodule "ctl.so"<BR>loadmodule "mi_rpc.so"<BR>loadmodule "acc.so"<BR>#!ifdef WITH_AUTH<BR>loadmodule "auth.so"<BR>loadmodule "auth_db.so"<BR>#!endif<BR>/* uncomment next line for aliases support<BR> NOTE: a DB (like db_mysql) module must be also loaded */<BR>#loadmodule "alias_db.so"<BR>/* uncomment next line for multi-domain support<BR> NOTE: a DB (like db_mysql) module must be also loaded<BR> NOTE: be sure and enable multi-domain support in all used modules<BR> (see "multi-module params" section ) */<BR>#loadmodule "domain.so"<BR>#!ifdef WITH_PRESENCE<BR>loadmodule "presence.so"<BR>loadmodule "presence_xml.so"<BR>#!endif<BR>
#!ifdef WITH_NAT<BR>loadmodule "nathelper.so"<BR>#!endif<BR>
# ----------------- setting module-specific parameters ---------------<BR>
<BR># ----- mi_fifo params -----<BR>modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")<BR>
<BR># ----- rr params -----<BR># add value to ;lr param to cope with most of the UAs<BR>modparam("rr", "enable_full_lr", 1)<BR># do not append from tag to the RR (no need for this script)<BR>modparam("rr", "append_fromtag", 0)<BR>
<BR># ----- rr params -----<BR>modparam("registrar", "method_filtering", 1)<BR>/* uncomment the next line to disable parallel forking via location */<BR># modparam("registrar", "append_branches", 0)<BR>/* uncomment the next line not to allow more than 10 contacts per AOR */<BR>#modparam("registrar", "max_contacts", 10)<BR>
<BR># ----- uri_db params -----<BR>/* by default we disable the DB support in the module as we do not need it<BR> in this configuration */<BR>modparam("uri_db", "use_uri_table", 0)<BR>modparam("uri_db", "db_url", "")<BR>
<BR># ----- acc params -----<BR>/* what sepcial events should be accounted ? */<BR>modparam("acc", "early_media", 1)<BR>modparam("acc", "report_ack", 1)<BR>modparam("acc", "report_cancels", 1)<BR>/* by default ww do not adjust the direct of the sequential requests.<BR> if you enable this parameter, be sure the enable "append_fromtag"<BR> in "rr" module */<BR>modparam("acc", "detect_direction", 0)<BR>/* account triggers (flags) */<BR>modparam("acc", "failed_transaction_flag", 3)<BR>modparam("acc", "log_flag", 1)<BR>modparam("acc", "log_missed_flag", 2)<BR>modparam("acc", "log_extra", <BR> "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")<BR>/* enhanced DB accounting */<BR>#!ifdef WITH_ACCDB<BR>modparam("acc", "db_flag", 1)<BR>modparam("acc", "db_missed_flag", 2)<BR>modparam("acc", "db_url",<BR> "mysql://openser:openK2mrw23@localhost/openser")<BR>modparam("acc", "db_extra",<BR> "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")<BR>#!endif<BR>
# ----- usrloc params -----<BR>/* enable DB persistency for location entries */<BR>#!ifdef WITH_USRLOCDB<BR>modparam("usrloc", "db_mode", 2)<BR>modparam("usrloc", "db_url",<BR> "mysql://openser:openK2mrw23@localhost/openser")<BR>#!endif<BR>
# ----- auth_db params -----<BR>/* enable the DB based authentication */<BR>#!ifdef WITH_AUTH<BR>modparam("auth_db", "calculate_ha1", yes)<BR>modparam("auth_db", "password_column", "password")<BR>modparam("auth_db", "db_url",<BR> "mysql://openser:openK2mrw23@localhost/openser")<BR>modparam("auth_db", "load_credentials", "")<BR>#!endif<BR>
# ----- alias_db params -----<BR>/* uncomment the following lines if you want to enable the DB based<BR> aliases */<BR>#modparam("alias_db", "db_url",<BR># "mysql://openser:openK2mrw23@localhost/openser")<BR>
<BR># ----- domain params -----<BR>/* uncomment the following lines to enable multi-domain detection<BR> support */<BR>#modparam("domain", "db_url",<BR># "mysql://openser:openK2mrw23@localhost/openser")<BR>#modparam("domain", "db_mode", 1) # Use caching<BR>
<BR># ----- multi-module params -----<BR>/* uncomment the following line if you want to enable multi-domain support<BR> in the modules (dafault off) */<BR>#modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)<BR>
<BR># ----- presence params -----<BR>/* enable presence server support */<BR>#!ifdef WITH_PRESENCE<BR>modparam("presence|presence_xml", "db_url",<BR> "mysql://openser:openK2mrw23@localhost/openser")<BR>modparam("presence_xml", "force_active", 1)<BR>modparam("presence", "server_address", "sip:10.0.0.10:5060")<BR>#!endif<BR>
# ----- nathelper -----<BR>#!ifdef WITH_NAT<BR>modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:7722")<BR>modparam("nathelper", "natping_interval", 30)<BR>modparam("nathelper", "ping_nated_only", 1)<BR>modparam("nathelper", "sipping_bflag", 7)<BR>modparam("nathelper", "sipping_from", "sip:pinger at kamailio.org")<BR>modparam("registrar|nathelper", "received_avp", "$avp(i:80)")<BR>modparam("usrloc", "nat_bflag", 6)<BR>#!endif<BR>
####### Routing Logic ########<BR>
<BR># main request routing logic<BR>
route{<BR>
if (!mf_process_maxfwd_header("10")) {<BR> sl_send_reply("483","Too Many Hops");<BR> exit;<BR> }<BR>
if(!sanity_check("1511", "7"))<BR> {<BR> xlog("Malformed SIP message from $si:$sp\n");<BR> exit;<BR> }<BR>
# NAT detection<BR> route(NAT);<BR>
if (has_totag()) {<BR> # sequential request withing a dialog should<BR> # take the path determined by record-routing<BR> if (loose_route()) {<BR> if (is_method("BYE")) {<BR> setflag(1); # do accounting ...<BR> setflag(3); # ... even if the transaction fails<BR> }<BR> route(RELAY);<BR> } else {<BR> if (is_method("SUBSCRIBE") && uri == myself) {<BR> # in-dialog subscribe requests<BR> route(PRESENCE);<BR> exit;<BR> }<BR> if ( is_method("ACK") ) {<BR> if ( t_check_trans() ) {<BR> # non loose-route, but stateful ACK; must be an ACK after a 487 or e.g. 404 from upstream server<BR> t_relay();<BR> exit;<BR> } else {<BR> # ACK without matching transaction ... ignore and discard.\n");<BR> exit;<BR> }<BR> }<BR> sl_send_reply("404","Not here");<BR> }<BR> exit;<BR> }<BR>
#initial requests<BR>
# CANCEL processing<BR> if (is_method("CANCEL"))<BR> {<BR> if (t_check_trans())<BR> t_relay();<BR> exit;<BR> }<BR>
t_check_trans();<BR>
# authentication<BR> route(AUTH);<BR>
# record routing for dialog forming requests (in case they are routed)<BR> # - remove preloaded route headers<BR> remove_hf("Route");<BR> if (is_method("INVITE|SUBSCRIBE"))<BR> record_route();<BR>
# account only INVITEs<BR> if (is_method("INVITE")) {<BR> setflag(1); # do accounting<BR> }<BR> if (!uri==myself)<BR> /* replace with following line if multi-domain support is used */<BR> ##if (!is_uri_host_local())<BR> {<BR> append_hf("P-hint: outbound\r\n"); <BR> route(RELAY);<BR> }<BR>
# requests for my domain<BR>
if( is_method("PUBLISH|SUBSCRIBE"))<BR> route(PRESENCE);<BR>
if (is_method("REGISTER"))<BR> {<BR> if(isflagset(5))<BR> {<BR> setbflag("6");<BR> # uncomment next line to do SIP NAT pinging <BR> ## setbflag("7");<BR> }<BR> if (!save("location"))<BR> sl_reply_error();<BR>
exit;<BR> }<BR>
if ($rU==$null) {<BR> # request with no Username in RURI<BR> sl_send_reply("484","Address Incomplete");<BR> exit;<BR> }<BR>
route(PSTN);<BR> <BR> route(CONF);<BR>
# apply DB based aliases (uncomment to enable)<BR> ##alias_db_lookup("dbaliases");<BR>
if (!lookup("location")) {<BR> switch ($rc) {<BR> case -1:<BR> case -3:<BR> t_newtran();<BR> t_reply("404", "Not Found");<BR> exit;<BR> case -2:<BR> sl_send_reply("405", "Method Not Allowed");<BR> exit;<BR> }<BR> }<BR>
# when routing via usrloc, log the missed calls also<BR> setflag(2);<BR>
route(RELAY);<BR>}<BR>
<BR>route[RELAY] {<BR>#!ifdef WITH_NAT<BR> if (check_route_param("nat=yes")) {<BR> setbflag("6");<BR> }<BR> if (isflagset(5) || isbflagset("6")) {<BR> route(RTPPROXY);<BR> }<BR>#!endif<BR>
/* example how to enable some additional event routes */<BR> if (is_method("INVITE")) {<BR> #t_on_branch("BRANCH_ONE");<BR> t_on_reply("REPLY_ONE");<BR> t_on_failure("FAIL_ONE");<BR> }<BR>
if (!t_relay()) {<BR> sl_reply_error();<BR> }<BR> exit;<BR>}<BR>
<BR># Presence server route<BR>route[PRESENCE]<BR>{<BR>#!ifdef WITH_PRESENCE<BR> if (!t_newtran())<BR> {<BR> sl_reply_error();<BR> exit;<BR> };<BR>
if(is_method("PUBLISH"))<BR> {<BR> handle_publish();<BR> t_release();<BR> }<BR> else<BR> if( is_method("SUBSCRIBE"))<BR> {<BR> handle_subscribe();<BR> t_release();<BR> }<BR> exit;<BR>#!endif<BR> <BR> # if presence enabled, this part will not be executed<BR> if (is_method("PUBLISH") || $rU==$null)<BR> {<BR> sl_send_reply("404", "Not here");<BR> exit;<BR> }<BR> return;<BR>}<BR>
# Authentication route<BR>route[AUTH] {<BR>#!ifdef WITH_AUTH<BR> if (is_method("REGISTER"))<BR> {<BR> # authenticate the REGISTER requests (uncomment to enable auth)<BR> if (!www_authorize("", "subscriber"))<BR> {<BR> www_challenge("", "0");<BR> exit;<BR> }<BR>
if ($au!=$tU)<BR> {<BR> sl_send_reply("403","Forbidden auth ID");<BR> exit;<BR> }<BR> } else {<BR> # authenticate if from local subscriber (uncomment to enable auth)<BR> if (from_uri==myself)<BR> {<BR> if (!proxy_authorize("", "subscriber")) {<BR> proxy_challenge("", "0");<BR> exit;<BR> }<BR> if (is_method("PUBLISH"))<BR> {<BR> if ($au!=$tU) {<BR> sl_send_reply("403","Forbidden auth ID");<BR> exit;<BR> }<BR> } else {<BR> if ($au!=$fU) {<BR> sl_send_reply("403","Forbidden auth ID");<BR> exit;<BR> }<BR> }<BR>
consume_credentials();<BR> # caller authenticated<BR> }<BR> }<BR>#!endif<BR> return;<BR>}<BR>
# Caller NAT detection route<BR>route[NAT]{<BR>#!ifdef WITH_NAT<BR> force_rport();<BR> if (nat_uac_test("19")) {<BR> if (method=="REGISTER") {<BR> fix_nated_register();<BR> } else {<BR> fix_nated_contact();<BR> }<BR> setflag(5);<BR> }<BR>#!endif<BR> return;<BR>}<BR>
# RTPProxy control<BR>route[RTPPROXY] {<BR>#!ifdef WITH_NAT<BR> if (is_method("BYE")) {<BR> unforce_rtp_proxy();<BR> } else if (is_method("INVITE")){<BR> force_rtp_proxy();<BR> }<BR> if (!has_totag()) add_rr_param(";nat=yes");<BR>#!endif<BR> return;<BR>}<BR>
# PSTN GW routing<BR>route[PSTN] {<BR>#!ifdef WITH_PSTN<BR> # check if PSTN GW IP is defined<BR> if (strempty($sel(cfg_get.pstn.gw_ip))) {<BR> xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");<BR> return;<BR> }<BR>
# route to PSTN dialed numbers starting with '+' or '00'<BR> # (international format)<BR> # - update the condition to match your dialing rules for PSTN routing<BR> if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))<BR> return;<BR>
# only local users allowed to call<BR> if(from_uri!=myself) {<BR> sl_send_reply("403", "Not Allowed");<BR> exit;<BR> }<BR>
$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);<BR>
route(RELAY);<BR> exit;<BR>#!endif<BR>
return;<BR>}<BR>
# add by KJ --start<BR>route[CONF] {<BR> if(is_method("INVITE") && $rU=="0216666") {<BR> rewritehostport("210.x.y.z:5060"); <BR> }<BR> route(RELAY);<BR> exit;<BR>}<BR>
# add by KJ --end<BR>
# Sample branch router<BR>branch_route[BRANCH_ONE] {<BR> xdbg("new branch at $ru\n");<BR>}<BR>
# Sample onreply route<BR>onreply_route[REPLY_ONE] {<BR> xdbg("incoming reply\n");<BR>#!ifdef WITH_NAT<BR> if ((isflagset(5) || isbflagset("6")) && status=~"(183)|(2[0-9][0-9])") {<BR> force_rtp_proxy();<BR> }<BR> if (isbflagset("6")) {<BR> fix_nated_contact();<BR> }<BR>#!endif<BR>}<BR>
# Sample failure route<BR>failure_route[FAIL_ONE] {<BR>#!ifdef WITH_NAT<BR> if (is_method("INVITE")<BR> && (isbflagset("6") || isflagset(5))) {<BR> unforce_rtp_proxy();<BR> }<BR>#!endif<BR>
if (t_is_canceled()) {<BR> exit;<BR> }<BR>
# uncomment the following lines if you want to block client <BR> # redirect based on 3xx replies.<BR> ##if (t_check_status("3[0-9][0-9]")) {<BR> ##t_reply("404","Not found");<BR> ## exit;<BR> ##}<BR>
# uncomment the following lines if you want to redirect the failed <BR> # calls to a different new destination<BR> ##if (t_check_status("486|408")) {<BR> ## sethostport("192.168.2.100:5060");<BR> ## append_branch();<BR> ## # do not set the missed call flag again<BR> ## t_relay();<BR> ##}<BR>}<BR>AppSer01:root@/usr/local/kamailio-3.0/etc/kamailio$ <BR>
<BR>
<BR>
<BR> <br /><hr />ʹÓÃÐÂÒ»´ú Windows Live Messenger ÇáËɽ»Á÷ºÍ¹²Ïí£¡ <a href='http://www.windowslive.cn/messenger/' target='_new'>Á¢¿ÌÏÂÔØ£¡</a></body>
</html>
--_945d707f-4f6b-47f2-9e46-ae3c4df0a0d8_--
More information about the sr-users
mailing list