Hi everyone.
I have two machines running OpenSER, one machines runs OpenSER A and the other runs OpenSER B. Phone A registers in OpenSER A while Phone B registers in OpenSER B. I would like to allow Phone A call Phone B, but not the other way around. I am a newbie so sorry for my lack of knowledge. Would should be my configurations files for OpenSER A and B?
Thanks in advanced
I am trying to incorporate a cpl script for testing purposes with kamailio 3
but have been met with failure with each try.
Test scenario
I have two sip phones registered to kamailio successfully (I can make phone
calls between the two phones).
The CPL XML is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<cpl>
<incoming >
<location clear="yes"
url="sip:1000@192.168.254.144<sip%3A1000(a)192.168.254.144>"
>
<log comment="cpl-log - just location" />
</location>
</incoming>
</cpl>
This compiled successfully and is populating the cpl table in the openser
database.
When I call this from kamailio.cfg I get the 483 (Too many hops) error. If
someone could spot an obvious error, I would appreciate it.
The current kamailio.cfg file is as follows:
------------------
debug=8
log_stderror=yes
memdbg=5
memlog=5
log_facility=LOG_LOCAL0
fork=yes
children=4
/* uncomment the next line to disable TCP (default on) */
disable_tcp=yes
/* uncomment the next line to disable the auto discovery of local aliases
based on revers DNS on IPs (default on) */
auto_aliases=no
port=5060
/* uncomment and configure the following line if you want Kamailio to
bind on a specific interface/port/proto (default bind on all available)
*/
listen=udp:192.168.254.144:5060
####### Custom Parameters #########
# These parameters can be modified runtime via RPC interface
# - see the documentation of 'cfg_rpc' module.
#
# Format: group.id = value 'desc' description
# Access: $sel(cfg_get.group.id) or @cfg_get.group.id
#
pstn.gw_ip = "" desc "PSTN GW Address"
####### Modules Section ########
#set module path
mpath="/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/"
/* uncomment next line for MySQL DB support */
loadmodule "db_mysql.so"
loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "uri_db.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "mi_rpc.so"
loadmodule "acc.so"
#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
#!endif
/* uncomment next line for aliases support
NOTE: a DB (like db_mysql) module must be also loaded */
#loadmodule "alias_db.so"
/* uncomment next line for multi-domain support
NOTE: a DB (like db_mysql) module must be also loaded
NOTE: be sure and enable multi-domain support in all used modules
(see "multi-module params" section ) */
#loadmodule "domain.so"
#!ifdef WITH_PRESENCE
loadmodule "presence.so"
loadmodule "presence_xml.so"
#!endif
#!ifdef WITH_NAT
loadmodule "nathelper.so"
#!endif
# ----kh add------#
loadmodule "cpl-c.so"
# ----kh end -----#
# ----------------- setting module-specific parameters ---------------
# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)
# ----- rr params -----
modparam("registrar", "method_filtering", 1)
/* uncomment the next line to disable parallel forking via location */
# modparam("registrar", "append_branches", 0)
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)
# ----- uri_db params -----
/* by default we disable the DB support in the module as we do not need it
in this configuration */
modparam("uri_db", "use_uri_table", 0)
modparam("uri_db", "db_url", "")
# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
/* by default ww do not adjust the direct of the sequential requests.
if you enable this parameter, be sure the enable "append_fromtag"
in "rr" module */
modparam("acc", "detect_direction", 0)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
modparam("acc", "log_extra",
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
/* enhanced DB accounting */
#!ifdef WITH_ACCDB
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)
modparam("acc", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("acc", "db_extra",
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
#!endif
# ----- usrloc params -----
/* enable DB persistency for location entries */
#!ifdef WITH_USRLOCDB
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://openser:openserrw@localhost/openser")
#!endif
# ----- auth_db params -----
/* enable the DB based authentication */
#!ifdef WITH_AUTH
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("auth_db", "load_credentials", "")
#!endif
# ----- alias_db params -----
/* uncomment the following lines if you want to enable the DB based
aliases */
#modparam("alias_db", "db_url",
# "mysql://openser:openserrw@localhost/openser")
# ----- domain params -----
/* uncomment the following lines to enable multi-domain detection
support */
#modparam("domain", "db_url",
# "mysql://openser:openserrw@localhost/openser")
#modparam("domain", "db_mode", 1) # Use caching
# ----- multi-module params -----
/* uncomment the following line if you want to enable multi-domain support
in the modules (dafault off) */
#modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)
# ----- presence params -----
/* enable presence server support */
#!ifdef WITH_PRESENCE
modparam("presence|presence_xml", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("presence_xml", "force_active", 1)
modparam("presence", "server_address", "sip:10.0.0.10:5060")
#!endif
# ----- nathelper -----
#!ifdef WITH_NAT
modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:7722")
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", 7)
modparam("nathelper", "sipping_from",
"sip:pinger@kamailio.org<sip%3Apinger(a)kamailio.org>
")
modparam("registrar|nathelper", "received_avp", "$avp(i:80)")
modparam("usrloc", "nat_bflag", 6)
#!endif
# ----- cpl --------
modparam("cpl-c","db_url","mysql://openser:openserrw@localhost/openser")
modparam("cpl-c","cpl_dtd_file","/etc/kamailio/cpl-06.dtd")
modparam("cpl-c","log_dir","/var/log/kamailio/cpl")
# ----- cpl --------
####### Routing Logic ########
route{
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}
if(!sanity_check("1511", "7"))
{
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
# NAT detection
route(NAT);
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
}
route(RELAY);
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# non loose-route, but stateful ACK; must be an ACK
after a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ... ignore and
discard.\n");
exit;
}
}
sl_send_reply("404","Not here");
}
exit;
}
#initial requests
# CANCEL processing
if (is_method("CANCEL"))
{
if (t_check_trans())
t_relay();
exit;
}
t_check_trans();
# authentication
route(AUTH);
# record routing for dialog forming requests (in case they are routed)
# - remove preloaded route headers
remove_hf("Route");
if (is_method("INVITE|SUBSCRIBE"))
record_route();
# account only INVITEs
if (is_method("INVITE")) {
setflag(1); # do accounting
}
if (!uri==myself)
/* replace with following line if multi-domain support is used */
##if (!is_uri_host_local())
{
append_hf("P-hint: outbound\r\n");
route(RELAY);
}
# requests for my domain
if( is_method("PUBLISH|SUBSCRIBE"))
route(PRESENCE);
if (is_method("REGISTER"))
{
if(isflagset(5))
{
setbflag("6");
# uncomment next line to do SIP NAT pinging
## setbflag("7");
}
if (!save("location"))
sl_reply_error();
exit;
}
if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
}
route(PSTN);
# apply DB based aliases (uncomment to enable)
##alias_db_lookup("dbaliases");
if (!lookup("location")) {
switch ($rc) {
case -1:
case -3:
t_newtran();
t_reply("404", "Not Found");
exit;
case -2:
sl_send_reply("405", "Method Not Allowed");
exit;
}
}
# when routing via usrloc, log the missed calls also
setflag(2);
route(RELAY);
}
route[RELAY] {
#!ifdef WITH_NAT
if (check_route_param("nat=yes")) {
setbflag("6");
}
if (isflagset(5) || isbflagset("6")) {
route(RTPPROXY);
}
#!endif
/* example how to enable some additional event routes */
if (is_method("INVITE")) {
#t_on_branch("BRANCH_ONE");
xlog("--kh-- before cpl call");
cpl_run_script("incoming", "force_stateful");
xlog("--kh-- after cpl call");
t_on_reply("REPLY_ONE");
t_on_failure("FAIL_ONE");
}
if (!t_relay()) {
sl_reply_error();
}
exit;
}
# Presence server route
route[PRESENCE]
{
#!ifdef WITH_PRESENCE
if (!t_newtran())
{
sl_reply_error();
exit;
};
if(is_method("PUBLISH"))
{
handle_publish();
t_release();
}
else
if( is_method("SUBSCRIBE"))
{
handle_subscribe();
t_release();
}
exit;
#!endif
# if presence enabled, this part will not be executed
if (is_method("PUBLISH") || $rU==$null)
{
sl_send_reply("404", "Not here");
exit;
}
return;
}
# Authentication route
route[AUTH] {
#!ifdef WITH_AUTH
if (is_method("REGISTER"))
{
# authenticate the REGISTER requests (uncomment to enable auth)
if (!www_authorize("", "subscriber"))
{
www_challenge("", "0");
exit;
}
if ($au!=$tU)
{
sl_send_reply("403","Forbidden auth ID");
exit;
}
} else {
# authenticate if from local subscriber (uncomment to enable auth)
if (from_uri==myself)
{
if (!proxy_authorize("", "subscriber")) {
proxy_challenge("", "0");
exit;
}
if (is_method("PUBLISH"))
{
if ($au!=$tU) {
sl_send_reply("403","Forbidden auth ID");
exit;
}
} else {
if ($au!=$fU) {
sl_send_reply("403","Forbidden auth ID");
exit;
}
}
consume_credentials();
# caller authenticated
}
}
#!endif
return;
}
# Caller NAT detection route
route[NAT]{
#!ifdef WITH_NAT
force_rport();
if (nat_uac_test("19")) {
if (method=="REGISTER") {
fix_nated_register();
} else {
fix_nated_contact();
}
setflag(5);
}
#!endif
return;
}
# RTPProxy control
route[RTPPROXY] {
#!ifdef WITH_NAT
if (is_method("BYE")) {
unforce_rtp_proxy();
} else if (is_method("INVITE")){
force_rtp_proxy();
}
if (!has_totag()) add_rr_param(";nat=yes");
#!endif
return;
}
# PSTN GW routing
route[PSTN] {
#!ifdef WITH_PSTN
# check if PSTN GW IP is defined
if (strempty($sel(cfg_get.pstn.gw_ip))) {
xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");
return;
}
# route to PSTN dialed numbers starting with '+' or '00'
# (international format)
# - update the condition to match your dialing rules for PSTN routing
if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))
return;
# only local users allowed to call
if(from_uri!=myself) {
sl_send_reply("403", "Not Allowed");
exit;
}
$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);
route(RELAY);
exit;
#!endif
return;
}
# Sample branch router
branch_route[BRANCH_ONE] {
xdbg("new branch at $ru\n");
}
# Sample onreply route
onreply_route[REPLY_ONE] {
xdbg("incoming reply\n");
#!ifdef WITH_NAT
if ((isflagset(5) || isbflagset("6")) && status=~"(183)|(2[0-9][0-9])")
{
force_rtp_proxy();
}
if (isbflagset("6")) {
fix_nated_contact();
}
#!endif
}
# Sample failure route
failure_route[FAIL_ONE] {
#!ifdef WITH_NAT
if (is_method("INVITE")
&& (isbflagset("6") || isflagset(5))) {
unforce_rtp_proxy();
}
#!endif
if (t_is_canceled()) {
exit;
}
}
--
Karl Harris
Sorry, pls ingore my previous email. I just forgot to remove some echo command added by me before the if statement.
From: kevin.jzh(a)hotmail.com
To: klaus.mailinglists(a)pernau.at; sr-users(a)lists.sip-router.org
Subject: RE: [SR-Users] Fail to add user account
Date: Fri, 11 Jun 2010 07:57:47 +0800
Have changed the kamctl from
if [ $? -eq 0 ] ; then
minfo "user '$1' already exists"
exit 1
fi
to
if [ $? -ne 0 ] ; then
minfo "user '$1' already exists"
exit 1
fi
Now I can add user successfully.
Seems it's a bug in the script in kamailio 3.0.2
Thanks,
Kevin
> Date: Thu, 10 Jun 2010 16:48:13 +0200
> From: klaus.mailinglists(a)pernau.at
> To: kevin.jzh(a)hotmail.com
> Subject: Re: [SR-Users] Fail to add user account
>
> I have no idea.
>
> Try supplying a domain too:
>
> kamctl add user(a)yourdomain.com passwd
>
> regards
> klaus
>
> Am 10.06.2010 16:32, schrieb JinKevin:
> > Thanks Klaus,
> >
> > After change the LAST_LINE in the kamctlrc, the tail error is going, but
> > it still says user "xxxx" already exists.
> >
> > # tail tool
> > LAST_LINE="tail -1"
> >
> > I find the script below returns "false" which makes the kamctl exit.
> >
> > # params: user
> > # output: false if exists, true otherwise
> > is_user() {
> > set_user $1
> > QUERY="select count(*) from $SUB_TABLE where \
> > $SUBSCRIBER_COLUMN='$OSERUSER' and $REALM_COLUMN='$OSERDOMAIN';"
> > CNT=`$DBROCMD "$QUERY" "$DBRAWPARAMS" | $EGREP -v ERROR | $LAST_LINE`
> > mdbg "is_user: user counter=$CNT"
> > if [ "$CNT" = "0" ] ; then
> > false
> > else
> > true
> > fi
> > }
> >
> >
> > What could be the cause?
> >
> > Thanks,
> > Kevin
> >
> >
> > > Date: Thu, 10 Jun 2010 10:11:18 +0200
> > > From: klaus.mailinglists(a)pernau.at
> > > To: kevin.jzh(a)hotmail.com
> > > CC: sr-users(a)lists.sip-router.org
> > > Subject: Re: [SR-Users] Fail to add user account
> > >
> > >
> > >
> > > Am 10.06.2010 03:12, schrieb JinKevin:
> > > > AppSer01:root@/usr/local/kamailio-3.0/sbin$ kamctl add 2000 2000
> > > > usage: tail [+/-[n][lbc][f]] [file]
> > > > tail [+/-[n][l][r|f]] [file]
> > > > INFO: user '2000' already exists
> > >
> > >
> > > between your kamctl command and the error message (user '2000' already
> > > exists) is an error produced by the tail command.
> > >
> > > Looks like kamctl uses tail in a way which is not supported on your OS.
> > >
> > > regards
> > > klaus
> >
> > ------------------------------------------------------------------------
> > 更多热辣资讯尽在新版MSN首页! 立刻访问! <http://cn.msn.com/>
聊天+搜索+邮箱 想要轻松出游,手机MSN帮你搞定! 立刻下载!
_________________________________________________________________
约会说不清地方?来试试微软地图最新msn互动功能!
http://ditu.live.com/?form=TL&swm=1
Hi all,
I try to do something like this on my failure_route[1] :
if (t_check_status("503")) {
if (ip_src==A.B.C.D) {
...
}
}
The goal, is to prevent a 503 from a PSTN gateway and try another one
for terminating the call.
But, I realize that "src_ip" is the IP source of SIP Request.
What could be a possible way to match IP source of the 503 responses ?
Regards,
Adrien L.
Hi All,
Finally, the kamalio was installed on the Solaris 10 sparc and I can start it with the 'kamctl start', and it is running as showed below. However I cann't add user by using the kamctl, it always says the user already exists. And actually the susbciber table is still empty in mysql.
Mysql is accessable with command "mysql -u openser -p ".
What could be the issue?
What are the log files I can check except the syslog? Didn't find an error in the syslog.
=======
AppSer01:root@/usr/local/kamailio-3.0/sbin$ kamctl add 2000 2000
usage: tail [+/-[n][lbc][f]] [file]
tail [+/-[n][l][r|f]] [file]
INFO: user '2000' already exists
AppSer01:root@/usr/local/kamailio-3.0/sbin$ kamctl ps
Process:: ID=0 PID=8888 Type=attendant
Process:: ID=1 PID=8890 Type=udp receiver child=0 sock=210.x.x.x:5060
Process:: ID=2 PID=8891 Type=udp receiver child=1 sock=210.x.x.x:5060
Process:: ID=3 PID=8892 Type=udp receiver child=2 sock=210.x.x.x:5060
Process:: ID=4 PID=8893 Type=udp receiver child=3 sock=210.x.x.x:5060
Process:: ID=5 PID=8894 Type=slow timer
Process:: ID=6 PID=8895 Type=timer
Process:: ID=7 PID=8896 Type=MI FIFO
Process:: ID=8 PID=8897 Type=ctl handler
Process:: ID=9 PID=8898 Type=tcp receiver child=0
Process:: ID=10 PID=8899 Type=tcp receiver child=1
Process:: ID=11 PID=8905 Type=tcp receiver child=2
Process:: ID=12 PID=8906 Type=tcp receiver child=3
Process:: ID=13 PID=8907 Type=tcp main process
AppSer01:root@/usr/local/kamailio-3.0/sbin$
=======
Thanks,
Kevin
_________________________________________________________________
SkyDrive电子画册,带你领略精彩照片,分享“美”时“美”刻!
http://www.windowslive.cn/campaigns/e-magazine/ngmchina/?a=c
Hi,
I have a carrier who insists and have configured their system so they
can receive INVITEs to their domain name only, and not the IP. I
cannot configure the gw for anything but IPs, but thought that I might
be able to replace the IP address in the cfg. So I tried with setting
$dd = "domain.com"; but that's not working, - I guess $dd is read-only
or something. Any ideas?
Thanks!!
//Anders
> If that's really your complete Kamailio config, it's missing a number
> of critical checks and handlers, such as loose_route(), which handles
> sequential (in-dialog) requests differently from initial requests due
> to the presence of a Route: header and a To header tag.
>
> You can't just stick cr_route() in the main route { ... } block
> without those canonical checks and expect everything to work as desired.
>
> The reason that the proxy is not seeing the sequential requests
> (reinvites, BYE, etc.) is because you don't have a Record-Route
> header, which tells the endpoints to relay sequential requests through
> the proxy on the network and transport level. Add this to your
> initial request route prior to (cr_route())[1]:
>
> if(!is_method("REGISTER|OPTIONS|MESSAGE"))
> record_route();
>
> That should take care of it.
>
> -- Alex
>
> [1] And ideally, add quite a few other things as well. See the
> stock configuration file for more insight.
Thanks Alex. I am testing this in the lab so I don't have a
production config loaded, I am really focused on the carrierroute
module and trying to figure that out so I'm running bare bones using
the module example. I looked into the RR functions and read in the CR
module that it invokes the TM when necessary so I was thinking it
would take care of keeping track of dialogs. The thing that threw me
off was the handling of the scenario 1 session with sipp was ok but
with asterisk scenario 2 it was not.
So I loaded in the record_route function in the main routing block and
it did take care of the complete session with the asterisk server, so
that problem is solved.
What I am running into now is the failure route. If the initial
session can not compete to the fist carrierroute, the call switches
over to the failure-route[1] which invokes carrierroute again with
another domain. Then the receiving asterisk server retransmits the
initial OK 6 times, so the transaction is lost or not held in kamailio
state, then the whole session drops after a few more seconds. I think
there is something going on with the append_branch function that is
throwing me off. It is needed so the failure route completes but it's
not handling the complete dialog or I could be totally off.
Thanks.
JR
--
JR Richardson
Engineering for the Masses
hi,
I have configured kamailio 3.0.1 on fedora 12 and its working fine for
ips on the network. But I am unable to get a working configuration for a
natted client. If one client is natted and other is not, both can call
each other through the kamailio server but only the natted client sends
voice to the un-natted client while on tcpdump i found that the
un-natted client is actually seeing the private ip of the natted client
and trying to deliver packets there. So no sound reaches the natted
client from the un-natted client.
I have been searching for some days for some help in this regard but
have not found anything i can use.
help,
regards.
***********************Confidentiality Notice***************************
The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain confidential or privileged information. If you are not
the intended recipient, please notify the sender at Divinet or
info(a)divinetaccess.com immediately and destroy all copies of this
message and any attachments.
Please print this message only if extremely necessary. Plant a tree today.
Save the EARTH.
************************************************************************