-
Notifications
You must be signed in to change notification settings - Fork 908
/
43.sh
executable file
·101 lines (82 loc) · 2.68 KB
/
43.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
# check forward functionality in utils module
# Copyright (C) 2009 1&1 Internet AG
#
# This file is part of Kamailio, a free SIP server.
#
# Kamailio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version
#
# Kamailio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
. include/common
. include/require.sh
. include/database.sh
if ! (check_kamailio && check_module "utils" && check_module "db_mysql" && check_mysql); then
exit 0
fi ;
CFG=43.cfg
TMPFILE=`mktemp -t kamailio-test.XXXXXXXXX`
# setup config
echo "loadmodule \"tm/tm.so\"" > $CFG
echo "loadmodule \"sl/sl.so\"" >> $CFG
echo "loadmodule \"mi_fifo/mi_fifo.so\"" >> $CFG
echo "loadmodule \"utils/utils.so\"" >> $CFG
echo "modparam(\"mi_fifo\", \"fifo_name\", \"/tmp/kamailio_fifo\")" >> $CFG
echo "modparam(\"utils\", \"forward_active\", 1)" >> $CFG
echo "route {sl_send_reply(\"404\", \"forbidden\");}" >> $CFG
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG > /dev/null
ret=$?
sleep 1
$CTL fifo forward_list &> /dev/null
$CTL fifo forward_filter 0=REGISTER:INVITE &> /dev/null
$CTL fifo forward_list &> /dev/null
$CTL fifo forward_proxy 0=127.0.0.1:7000 &> /dev/null
$CTL fifo forward_list > $TMPFILE
tmp=`grep -v "Printing forwarding information:
id switch filter proxy
0 off REGISTER:INVITE 127.0.0.1:7000" $TMPFILE`
if [ "$tmp" = "" ] ; then
ret=0
else
ret=1
fi ;
if [ "$ret" -eq 0 ] ; then
sipp -sn uac -s 123456787 127.0.0.1:5060 -i 127.0.0.1 -m 1 -nr &> /dev/null
ret=$?
killall sipp &> /dev/null
fi;
if ! [ "$ret" -eq 0 ] ; then
$CTL fifo forward_switch 0=on
$CTL fifo forward_list > $TMPFILE
tmp=`grep -v "Printing forwarding information:
id switch filter proxy
0 on REGISTER:INVITE 127.0.0.1:7000" $TMPFILE`
if [ "$tmp" = "" ] ; then
ret=0
else
ret=1
fi ;
nc -l -u -p 7000 1> $TMPFILE 2> /dev/null &
sipp -sn uac -s 123456787 127.0.0.1:5060 -i 127.0.0.1 -m 1 -nr &> /dev/null
killall sipp &> /dev/null
killall nc &> /dev/null
fi;
NR=`cat $TMPFILE | grep "INVITE sip:" | wc -l`
if [ "$NR" -eq 1 ] ; then
ret=0
else
ret=1
fi;
rm $CFG
rm $TMPFILE
$KILL
exit $ret