White, Phil
2014-10-05 15:51:03 UTC
Hi All,
I've had an 'interesting' weekend reading RFCs and playing with kamailio.
I'm making progress - however, I would be grateful for a little
clarification.
I have sorted out a very basic stateless redirect proxy (config file
below). I have cut it down to the absolute basic minimum - and it mostly
appears to do what I would expect it to do. It does allow me to call any
registered extension from my SIP softphone.
Problem 1: I have a Grandstream Budgetone 200, which will happily receive
calls, but will not initiate any. Looking at a ngrep, it is ignoring the
redirect, and sends out a flood of UDP INVITEs (also see below for details)
Question: Is this the fault of my configuration, or the Grandstream
behaving incorrectly?
Problem 2: I am having difficulty in working out which module and command I
require to perform a function. Could someone please indicate the INVITE
route in this file for a stateful proxy?
Many thanks,
Phil
---
## WARNING - DO NOT USE THIS IN A PRODUCTION SERVER. FOR TESTING & EDUCTION ONLY
debug=2
fork=no
log_stderror=yes
listen=192.168.1.254:5060
####### Modules Section ########
mpath="/usr/lib/kamailio/modules/"
loadmodule "pv.so"
loadmodule "sl.so"
loadmodule "usrloc"
modparam("usrloc", "db_mode", 0)
loadmodule "xlog.so"
loadmodule "registrar.so"
####### Routing Logic ########
route{
if(method=="REGISTER") {
if (!save("location")) {
xlog("L_ERR", "**REGISTER: save failed \n");
sl_reply_error();
} else {
xlog("L_NOTICE", " REGISTER rcvd $si:$sp \n");
};
};
if(method=="INVITE") {
lookup("location");
switch ($retcode) {
case -1:
case -3:
sl_send_reply("404", "Not Found");
exit;
case -2:
sl_send_reply("405", "Not Found");
exit;
};
sl_send_reply("302","Redirect");
};
if(method=="PUBLISH" || method=="SUBSCRIBE"){
xlog("L_INFO","REJECTION. We do not process $rm requests. \n");
route(No);
};
}
route[No] {
sl_send_reply(503, "Service Unavailable");
}
---
U 2014/10/05 16:38:04.925388 192.168.123.16:5060 -> 192.168.123.254:5060
INVITE sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP
SIP/2.0.
Via: SIP/2.0/UDP 192.168.123.16:5060;branch=z9hG4bKaf202530a743a053.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=905632682e68e9b5.
To: <sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP>.
Contact: <sip:111-***@public.gmane.org:5060;transport=udp;user=phone>.
Supported: replaces, timer, 100rel, path.
Session-Expires: 180.
Min-SE: 90.
Call-ID: 358a9652404b14ad-***@public.gmane.org
CSeq: 63317 INVITE.
User-Agent: Grandstream BT200 1.1.6.32.
Max-Forwards: 70.
Allow:
INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK.
Content-Type: application/sdp.
Content-Length: 407.
<...SNIP...>
U 2014/10/05 16:38:04.925895 192.168.123.254:5060 -> 192.168.123.16:5060
SIP/2.0 302 Redirect.
Via: SIP/2.0/UDP 192.168.123.16:5060
;branch=z9hG4bKaf202530a743a053;rport=5060.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=905632682e68e9b5.
To: <sip:105-***@public.gmane.org:58833
;rinstance=0d82c786ca88f460;transport=UDP>;tag=71d9875c03b727cbe0217d2db6ac2a49.422e.
Call-ID: 358a9652404b14ad-***@public.gmane.org
CSeq: 63317 INVITE.
Contact: <sip:105-***@public.gmane.org:58833
;rinstance=0d82c786ca88f460;transport=UDP>.
Server: My SIP Server.
Content-Length: 0.U 2014/10/05 16:38:04.954405 192.168.123.16:5060 ->
192.168.123.254:5060
ACK sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP
SIP/2.0.
Via: SIP/2.0/UDP 192.168.123.16:5060;branch=z9hG4bKaf202530a743a053.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=905632682e68e9b5.
To: <sip:105-***@public.gmane.org:58833
;rinstance=0d82c786ca88f460;transport=UDP>;tag=71d9875c03b727cbe0217d2db6ac2a49.422e.
Contact: <sip:111-***@public.gmane.org:5060;transport=udp;user=phone>.
Supported: path.
Call-ID: 358a9652404b14ad-***@public.gmane.org
CSeq: 63317 ACK.
User-Agent: Grandstream BT200 1.1.6.32.
Max-Forwards: 70.
Allow:
INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK.
Content-Length: 0.
.
U 2014/10/05 16:38:04.975398 192.168.123.16:5060 -> 192.168.123.254:5060
INVITE sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP
SIP/2.0.
Via: SIP/2.0/UDP 192.168.123.16:5060;branch=z9hG4bKa55f284fa742ad32.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=9a25392722276c54.
To: <sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP>.
Contact: <sip:111-***@public.gmane.org:5060;transport=udp;user=phone>.
Supported: replaces, timer, 100rel, path.
Session-Expires: 180.
Min-SE: 90.
Call-ID: f2989990cfa8525c-***@public.gmane.org
CSeq: 1445 INVITE.
User-Agent: Grandstream BT200 1.1.6.32.
Max-Forwards: 70.
Allow:
INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK.
Content-Type: application/sdp.
Content-Length: 407.
.
.
. etc...
I've had an 'interesting' weekend reading RFCs and playing with kamailio.
I'm making progress - however, I would be grateful for a little
clarification.
I have sorted out a very basic stateless redirect proxy (config file
below). I have cut it down to the absolute basic minimum - and it mostly
appears to do what I would expect it to do. It does allow me to call any
registered extension from my SIP softphone.
Problem 1: I have a Grandstream Budgetone 200, which will happily receive
calls, but will not initiate any. Looking at a ngrep, it is ignoring the
redirect, and sends out a flood of UDP INVITEs (also see below for details)
Question: Is this the fault of my configuration, or the Grandstream
behaving incorrectly?
Problem 2: I am having difficulty in working out which module and command I
require to perform a function. Could someone please indicate the INVITE
route in this file for a stateful proxy?
Many thanks,
Phil
---
## WARNING - DO NOT USE THIS IN A PRODUCTION SERVER. FOR TESTING & EDUCTION ONLY
debug=2
fork=no
log_stderror=yes
listen=192.168.1.254:5060
####### Modules Section ########
mpath="/usr/lib/kamailio/modules/"
loadmodule "pv.so"
loadmodule "sl.so"
loadmodule "usrloc"
modparam("usrloc", "db_mode", 0)
loadmodule "xlog.so"
loadmodule "registrar.so"
####### Routing Logic ########
route{
if(method=="REGISTER") {
if (!save("location")) {
xlog("L_ERR", "**REGISTER: save failed \n");
sl_reply_error();
} else {
xlog("L_NOTICE", " REGISTER rcvd $si:$sp \n");
};
};
if(method=="INVITE") {
lookup("location");
switch ($retcode) {
case -1:
case -3:
sl_send_reply("404", "Not Found");
exit;
case -2:
sl_send_reply("405", "Not Found");
exit;
};
sl_send_reply("302","Redirect");
};
if(method=="PUBLISH" || method=="SUBSCRIBE"){
xlog("L_INFO","REJECTION. We do not process $rm requests. \n");
route(No);
};
}
route[No] {
sl_send_reply(503, "Service Unavailable");
}
---
U 2014/10/05 16:38:04.925388 192.168.123.16:5060 -> 192.168.123.254:5060
INVITE sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP
SIP/2.0.
Via: SIP/2.0/UDP 192.168.123.16:5060;branch=z9hG4bKaf202530a743a053.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=905632682e68e9b5.
To: <sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP>.
Contact: <sip:111-***@public.gmane.org:5060;transport=udp;user=phone>.
Supported: replaces, timer, 100rel, path.
Session-Expires: 180.
Min-SE: 90.
Call-ID: 358a9652404b14ad-***@public.gmane.org
CSeq: 63317 INVITE.
User-Agent: Grandstream BT200 1.1.6.32.
Max-Forwards: 70.
Allow:
INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK.
Content-Type: application/sdp.
Content-Length: 407.
<...SNIP...>
U 2014/10/05 16:38:04.925895 192.168.123.254:5060 -> 192.168.123.16:5060
SIP/2.0 302 Redirect.
Via: SIP/2.0/UDP 192.168.123.16:5060
;branch=z9hG4bKaf202530a743a053;rport=5060.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=905632682e68e9b5.
To: <sip:105-***@public.gmane.org:58833
;rinstance=0d82c786ca88f460;transport=UDP>;tag=71d9875c03b727cbe0217d2db6ac2a49.422e.
Call-ID: 358a9652404b14ad-***@public.gmane.org
CSeq: 63317 INVITE.
Contact: <sip:105-***@public.gmane.org:58833
;rinstance=0d82c786ca88f460;transport=UDP>.
Server: My SIP Server.
Content-Length: 0.U 2014/10/05 16:38:04.954405 192.168.123.16:5060 ->
192.168.123.254:5060
ACK sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP
SIP/2.0.
Via: SIP/2.0/UDP 192.168.123.16:5060;branch=z9hG4bKaf202530a743a053.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=905632682e68e9b5.
To: <sip:105-***@public.gmane.org:58833
;rinstance=0d82c786ca88f460;transport=UDP>;tag=71d9875c03b727cbe0217d2db6ac2a49.422e.
Contact: <sip:111-***@public.gmane.org:5060;transport=udp;user=phone>.
Supported: path.
Call-ID: 358a9652404b14ad-***@public.gmane.org
CSeq: 63317 ACK.
User-Agent: Grandstream BT200 1.1.6.32.
Max-Forwards: 70.
Allow:
INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK.
Content-Length: 0.
.
U 2014/10/05 16:38:04.975398 192.168.123.16:5060 -> 192.168.123.254:5060
INVITE sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP
SIP/2.0.
Via: SIP/2.0/UDP 192.168.123.16:5060;branch=z9hG4bKa55f284fa742ad32.
From: "01782478349" <sip:111-Q0ErXNX1RubIU/***@public.gmane.org
;user=phone>;tag=9a25392722276c54.
To: <sip:105-***@public.gmane.org:58833;rinstance=0d82c786ca88f460;transport=UDP>.
Contact: <sip:111-***@public.gmane.org:5060;transport=udp;user=phone>.
Supported: replaces, timer, 100rel, path.
Session-Expires: 180.
Min-SE: 90.
Call-ID: f2989990cfa8525c-***@public.gmane.org
CSeq: 1445 INVITE.
User-Agent: Grandstream BT200 1.1.6.32.
Max-Forwards: 70.
Allow:
INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK.
Content-Type: application/sdp.
Content-Length: 407.
.
.
. etc...