-
Notifications
You must be signed in to change notification settings - Fork 909
/
alg.cfg
99 lines (86 loc) · 2.61 KB
/
alg.cfg
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
#
# Simple application level gateway config script.
#
# Assumes that Kamailio and rtpproxy run on a machine, which connected to
# two non-routable letworks: 192.168.0.0/24 and 192.168.1.1/24.
#
# Correspondingly, this machine has two IP addresses: 192.168.0.1
# and 192.168.1.1.
#
# 192.168.0.0/24 - "internal" network
# 192.168.1.0/24 - "external" network
#
# rtpproxy started with `-l 192.168.0.1/192.168.1.1' option.
#
# ------------------ module loading ----------------------------------
loadmodule "/usr/local/lib/kamailio/modules/sl.so"
loadmodule "/usr/local/lib/kamailio/modules/tm.so"
loadmodule "/usr/local/lib/kamailio/modules/rr.so"
loadmodule "/usr/local/lib/kamailio/modules/maxfwd.so"
loadmodule "/usr/local/lib/kamailio/modules/usrloc.so"
loadmodule "/usr/local/lib/kamailio/modules/registrar.so"
loadmodule "/usr/local/lib/kamailio/modules/nathelper.so"
loadmodule "/usr/local/lib/kamailio/modules/rtpproxy.so"
# ----------------- setting module-specific parameters ---------------
# -- nathelper params --
modparam("nathelper", "natping_interval", 15)
# ------------------ main fun below ----------------------------------
request_route {
# initial sanity checks -- messages with
# max_forwards == 0, or excessively long requests,
# or those that don't addressed to us
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483", "Too Many Hops");
break;
};
if (!(uri == myself) && method == "INVITE") {
sl_send_reply("403", "Call cannot be served here");
break;
};
if (method == "REGISTER") {
if (dst_ip == 192.168.0.1) {
save("location-internal");
} else if (dst_ip == 192.168.1.1) {
save("location-external");
} else {
sl_send_reply("403", "Call cannot be served here");
};
break;
};
if (method == "INVITE") {
if (lookup("location-internal")) {
if (dst_ip == 192.168.0.1)
if (rtpproxy_offer("FAII"))
t_on_reply("MNGRPL");
if (dst_ip == 192.168.1.1)
if (rtpproxy_offer("FAEI"))
t_on_reply("MNGRPL");
} else if (lookup("location-external")) {
if (dst_ip == 192.168.0.1)
if (rtpproxy_offer("FAIE"))
t_on_reply("MNGRPL");
if (dst_ip == 192.168.1.1)
if (rtpproxy_offer("FAEE"))
t_on_reply("MNGRPL");
} else {
sl_send_reply("403", "Call cannot be served here");
break;
};
}
if (method == "BYE" || method == "CANCEL")
unforce_rtp_proxy();
# Do strict routing if pre-loaded route headers present
if (loose_route()) {
t_relay();
break;
};
if (method == "INVITE")
record_route();
if (!t_relay())
sl_reply_error();
}
onreply_route[MNGRPL] {
if (!(status=~"183" || status=~"200"))
break;
rtpproxy_answer("FA");
}