1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,116 @@ |
1 |
+# |
|
2 |
+# $Id$ |
|
3 |
+# |
|
4 |
+# welcome message for new subscribers; based on exec |
|
5 |
+# |
|
6 |
+ |
|
7 |
+# ----------- global configuration parameters ------------------------ |
|
8 |
+ |
|
9 |
+debug=3 # debug level (cmd line: -dddddddddd) |
|
10 |
+# must be yes since REGISTER processing causes an INVITE to be sent, |
|
11 |
+# which needs to be processed by another process |
|
12 |
+fork=yes |
|
13 |
+children=4 |
|
14 |
+ |
|
15 |
+# debugging |
|
16 |
+log_stderror=yes # (cmd line: -E) |
|
17 |
+ |
|
18 |
+mhomed=yes |
|
19 |
+listen=192.168.2.16 |
|
20 |
+ |
|
21 |
+fifo="/tmp/ser_fifo" |
|
22 |
+ |
|
23 |
+# ------------------ module loading ---------------------------------- |
|
24 |
+ |
|
25 |
+# Uncomment this if you want to use SQL database |
|
26 |
+loadmodule "modules/mysql/mysql.so" |
|
27 |
+ |
|
28 |
+loadmodule "modules/sl/sl.so" |
|
29 |
+loadmodule "modules/tm/tm.so" |
|
30 |
+loadmodule "modules/rr/rr.so" |
|
31 |
+loadmodule "modules/maxfwd/maxfwd.so" |
|
32 |
+loadmodule "modules/usrloc/usrloc.so" |
|
33 |
+loadmodule "modules/registrar/registrar.so" |
|
34 |
+ |
|
35 |
+loadmodule "modules/exec/exec.so" |
|
36 |
+ |
|
37 |
+# ----------------- setting module-specific parameters --------------- |
|
38 |
+ |
|
39 |
+# -- usrloc params -- |
|
40 |
+ |
|
41 |
+modparam("usrloc", "db_mode", 2) |
|
42 |
+modparam("usrloc", "db_url", "sql://ser:heslo@192.168.2.16/ser" ) |
|
43 |
+# ------------------------- request routing logic ------------------- |
|
44 |
+ |
|
45 |
+# main routing logic |
|
46 |
+ |
|
47 |
+route{ |
|
48 |
+ |
|
49 |
+ # initial sanity checks -- messages with |
|
50 |
+ # max_forwards==0, or excessively long requests |
|
51 |
+ if (!mf_process_maxfwd_header("10")) { |
|
52 |
+ sl_send_reply("483","Too Many Hops"); |
|
53 |
+ break; |
|
54 |
+ }; |
|
55 |
+ if (len_gt( max_len )) { |
|
56 |
+ sl_send_reply("513", "Message too big"); |
|
57 |
+ break; |
|
58 |
+ }; |
|
59 |
+ |
|
60 |
+ # we record-route all messages -- to make sure that |
|
61 |
+ # subsequent messages will go through our proxy; that's |
|
62 |
+ # particularly good if upstream and downstream entities |
|
63 |
+ # use different transport protocol |
|
64 |
+ if (method=="INVITE") record_route(); # 1=loose routing |
|
65 |
+ |
|
66 |
+ # loose-route processing |
|
67 |
+ if (loose_route()) { |
|
68 |
+ t_relay(); |
|
69 |
+ break; |
|
70 |
+ }; |
|
71 |
+ |
|
72 |
+ log(1, "RR processing completed\n"); |
|
73 |
+ |
|
74 |
+ # if the request is for other domain use UsrLoc |
|
75 |
+ # (in case, it does not work, use the following command |
|
76 |
+ # with proper names and addresses in it) |
|
77 |
+ if (uri==myself) { |
|
78 |
+ |
|
79 |
+ if (method=="REGISTER") { |
|
80 |
+ save("location"); |
|
81 |
+ if (!exec_msg(' |
|
82 |
+ # config: |
|
83 |
+ # --announcement server |
|
84 |
+ ANS="sip:7170@iptel.org" |
|
85 |
+ # --SIP domain |
|
86 |
+ DOMAIN="192.168.2.16" |
|
87 |
+ # ---- |
|
88 |
+ # check if first time ... |
|
89 |
+ SIP_UID=`echo $SIP_HF_TO | sed -e "s/^.*sip:\([a-zA-Z0-9_\.]*\)@.*$/\1/g"` |
|
90 |
+ QUERY="select flag from subscriber |
|
91 |
+ where username=\"$SIP_UID\"; |
|
92 |
+ update subscriber set flag=\"x\" |
|
93 |
+ where username=\"$SIP_UID\" "; |
|
94 |
+ mysql -Bsuser -pheslo -e "$QUERY" ser| grep "^x$" > /dev/null |
|
95 |
+ # ... if so, c-t-d to announcement server |
|
96 |
+ if [ "$?" -ne 0 ] ; then |
|
97 |
+ # flag was not set to x yet -- first-time registration; |
|
98 |
+ # initiate a call from telephone of the user to an announcement server |
|
99 |
+ ${HOME}/sip_router/examples/ctd.sh "sip:$SIP_UID@$DOMAIN" "$ANS" > /dev/null 2>&1 |
|
100 |
+ fi |
|
101 |
+ ')) { |
|
102 |
+ sl_send_reply("500", "register/exec failed"); |
|
103 |
+ break; |
|
104 |
+ }; |
|
105 |
+ |
|
106 |
+ break; |
|
107 |
+ }; |
|
108 |
+ |
|
109 |
+ # native SIP destinations are handled using our USRLOC DB |
|
110 |
+ if (!lookup("location")) { |
|
111 |
+ sl_send_reply("404", "Not Found"); |
|
112 |
+ break; |
|
113 |
+ }; |
|
114 |
+ }; |
|
115 |
+ t_relay(); |
|
116 |
+} |