... | ... |
@@ -12,14 +12,14 @@ struct lump_rpl* build_lump_rpl( char* text, int len ) |
12 | 12 |
lump = (struct lump_rpl*) pkg_malloc(sizeof(struct lump_rpl)); |
13 | 13 |
if (!lump) |
14 | 14 |
{ |
15 |
- LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n"); |
|
15 |
+ LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (struct)!\n"); |
|
16 | 16 |
goto error; |
17 | 17 |
} |
18 | 18 |
|
19 | 19 |
lump->text.s = pkg_malloc( len ); |
20 | 20 |
if (!lump->text.s) |
21 | 21 |
{ |
22 |
- LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n"); |
|
22 |
+ LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (%d)!\n", len ); |
|
23 | 23 |
goto error; |
24 | 24 |
} |
25 | 25 |
|
... | ... |
@@ -48,7 +48,7 @@ modparam("usrloc", "expires_column", "expires") |
48 | 48 |
modparam("usrloc", "q_column", "q") |
49 | 49 |
modparam("usrloc", "callid_column", "callid") |
50 | 50 |
modparam("usrloc", "cseq_column", "cseq") |
51 |
-modparam("usrloc", "flush_interval", 60) |
|
51 |
+modparam("usrloc", "flush_interval", 10) |
|
52 | 52 |
modparam("usrloc", "db_url", "sql://csps:47csps11@dbhost/csps107") |
53 | 53 |
|
54 | 54 |
# -- auth params -- |
... | ... |
@@ -107,6 +107,11 @@ route{ |
107 | 107 |
# filter local stateless ACK generated by authentication of mf replies |
108 | 108 |
sl_filter_ACK(); |
109 | 109 |
|
110 |
+ if (len_gt( max_len )) { |
|
111 |
+ sl_send_reply("513", "Riesengross -- Message too large"); |
|
112 |
+ break; |
|
113 |
+ }; |
|
114 |
+ |
|
110 | 115 |
# filter too old messages |
111 | 116 |
log("LOG: Checking maxfwd\n"); |
112 | 117 |
if (!mf_process_maxfwd_header("10")) { |
... | ... |
@@ -115,6 +120,74 @@ route{ |
115 | 120 |
break; |
116 | 121 |
}; |
117 | 122 |
|
123 |
+ # -------------------- testing accounts ---------------- |
|
124 |
+#XX |
|
125 |
+ if (uri=~"sip:333.*@iptel\.org") { |
|
126 |
+ forward( 195.113.147.6, 5060 ); |
|
127 |
+ break; |
|
128 |
+ } ; |
|
129 |
+ |
|
130 |
+ if (uri=~"sip:everloop@iptel\.org") { |
|
131 |
+ t_relay(); |
|
132 |
+ break; |
|
133 |
+ } ; |
|
134 |
+ |
|
135 |
+ if (uri=~"sip:looptester@iptel\.org") { |
|
136 |
+ seturi("sip:lt0@iptel.org"); |
|
137 |
+ t_relay(); |
|
138 |
+ break; |
|
139 |
+ } else if (uri=~"sip:lt0@iptel\.org") { |
|
140 |
+ seturi("sip:lt1@iptel.org"); |
|
141 |
+ t_relay(); |
|
142 |
+ break; |
|
143 |
+ } else if (uri=~"sip:lt1@iptel\.org") { |
|
144 |
+ seturi("sip:lt2@iptel.org"); |
|
145 |
+ t_relay(); |
|
146 |
+ break; |
|
147 |
+ } else if (uri=~"sip:lt2@iptel\.org") { |
|
148 |
+ seturi("sip:lt3@iptel.org"); |
|
149 |
+ t_relay(); |
|
150 |
+ break; |
|
151 |
+ } else if (uri=~"sip:lt3@iptel\.org") { |
|
152 |
+ seturi("sip:lt4@iptel.org"); |
|
153 |
+ t_relay(); |
|
154 |
+ break; |
|
155 |
+ } else if (uri=~"sip:lt4@iptel\.org") { |
|
156 |
+ seturi("sip:lt5@iptel.org"); |
|
157 |
+ t_relay(); |
|
158 |
+ break; |
|
159 |
+ } else if (uri=~"sip:lt5@iptel\.org") { |
|
160 |
+ seturi("sip:lt6@iptel.org"); |
|
161 |
+ t_relay(); |
|
162 |
+ break; |
|
163 |
+ } else if (uri=~"sip:lt6@iptel\.org") { |
|
164 |
+ seturi("sip:lt7@iptel.org"); |
|
165 |
+ t_relay(); |
|
166 |
+ break; |
|
167 |
+ } else if (uri=~"sip:lt7@iptel\.org") { |
|
168 |
+ seturi("sip:lt8@iptel.org"); |
|
169 |
+ t_relay(); |
|
170 |
+ break; |
|
171 |
+ } ; if (uri=~"sip:lt8@iptel\.org") { |
|
172 |
+# } else if (uri=~"sip:lt8@iptel\.org") { |
|
173 |
+ seturi("sip:lt9@iptel.org"); |
|
174 |
+ t_relay(); |
|
175 |
+ break; |
|
176 |
+ } else if (uri=~"sip:lt9@iptel\.org") { |
|
177 |
+ seturi("sip:lt0@iptel.org"); |
|
178 |
+ t_relay(); |
|
179 |
+ break; |
|
180 |
+ } else if (uri=~"sip:lt0@iptel\.org") { |
|
181 |
+ seturi("sip:lta@iptel.org"); |
|
182 |
+ t_relay(); |
|
183 |
+ break; |
|
184 |
+ } else if (uri=~"sip:lta@iptel\.org") { |
|
185 |
+ seturi("sip:ltb@iptel.org"); |
|
186 |
+ t_relay(); |
|
187 |
+ break; |
|
188 |
+ }; |
|
189 |
+ # -------------------- Eo testing account ---------------- |
|
190 |
+ |
|
118 | 191 |
# Do strict routing if route headers present |
119 | 192 |
rewriteFromRoute(); |
120 | 193 |
|
... | ... |
@@ -124,6 +197,8 @@ route{ |
124 | 197 |
sethost("iptel.org"); |
125 | 198 |
# t_relay_to("fox.iptel.org", "5066"); |
126 | 199 |
t_relay_to("fox.iptel.org", "6060"); |
200 |
+#XX |
|
201 |
+# { sl_reply_error(); break; } |
|
127 | 202 |
break; |
128 | 203 |
}; |
129 | 204 |
|
... | ... |
@@ -135,7 +210,9 @@ route{ |
135 | 210 |
|
136 | 211 |
# sign of our domain: there is @ (username), : |
137 | 212 |
# (nothing) or . (host) in front of our domain name |
138 |
- if (!(uri=~"[@:\.]iptel\.org([;:].*)*" |
|
213 |
+#XX |
|
214 |
+# if (!(uri=~"[@:\.]iptel\.org([;:].*)*" |
|
215 |
+ if (!(uri=~"[@:]iptel\.org([;:].*)*" |
|
139 | 216 |
| uri=~"[@:\.]195\.37\.77\.101([;:].*)*" | |
140 | 217 |
uri=~"@195\.37\.77\.110([;:].*)*" )) { |
141 | 218 |
route(2); |
... | ... |
@@ -145,17 +222,26 @@ route{ |
145 | 222 |
# here we continue with requests for our domain... |
146 | 223 |
|
147 | 224 |
# various aliases (might use a database in future) |
225 |
+# lookup_contact("aliases"); |
|
148 | 226 |
if (uri=~"sip:9040@") { |
149 |
- seturi("jiri@iptel.org"); |
|
227 |
+ seturi("sip:jiri@iptel.org"); |
|
228 |
+ }; |
|
229 |
+ if (uri=~"sip:9042@") { |
|
230 |
+ seturi("sip:sisalem@iptel.org"); |
|
150 | 231 |
}; |
151 | 232 |
if (uri=~"sip:17@") { |
152 | 233 |
seturi("sip:henry@siptest.wcom.com"); |
153 | 234 |
}; |
154 |
- if (uri=~"sip:jirim@") { |
|
235 |
+ if (uri=~"sip:jirim@" ) { |
|
155 | 236 |
seturi("sip:001795061546@iptel.org"); |
156 | 237 |
}; |
238 |
+ if ( uri=~"sip:info@" ) { |
|
239 |
+ seturi("sip:jiri@mail.iptel.org"); |
|
240 |
+ }; |
|
157 | 241 |
# check again, if it is still for our domain after aliases |
158 |
- if ( !(uri=~"[@:\.]iptel\.org([;:].*)*" | |
|
242 |
+#XX |
|
243 |
+# if ( !(uri=~"[@:\.]iptel\.org([;:].*)*" | |
|
244 |
+ if ( !(uri=~"[@:]iptel\.org([;:].*)*" | |
|
159 | 245 |
uri=~"[@:\.]195\.37\.77\.101([;:].*)*" | |
160 | 246 |
uri=~"@195\.37\.77\.110([;:].*)*" )) { |
161 | 247 |
route(2); |
... | ... |
@@ -168,23 +254,26 @@ route{ |
168 | 254 |
# avoid stealing incoming calls |
169 | 255 |
if (method=="REGISTER") { |
170 | 256 |
log("LOG Request is REGISTER\n"); |
257 |
+ # prohibit attempts to grab someone else's To address |
|
258 |
+ # using valid credentials; the only exception is the user |
|
259 |
+ # 'replciator' permitted to generate 3-rd party registrations |
|
260 |
+ |
|
261 |
+ |
|
171 | 262 |
if (!www_authorize( "iptel.org" /* realm */, |
172 |
-# if (!proxy_authorize( "iptel.org" /* realm */, |
|
173 | 263 |
"subscriber" /* table name */ )) { |
174 | 264 |
log("LOG: REGISTER has no credentials, sending challenge\n"); |
175 | 265 |
www_challenge( "iptel.org" /* realm */, |
176 |
-# proxy_challenge( "iptel.org" /* realm */, |
|
177 | 266 |
"0" /* no qop -- M$ can't deal with it */); |
178 | 267 |
break; |
179 | 268 |
}; |
180 |
- # prohibit attempts to grab someone else's To address |
|
181 |
- # using valid credentials |
|
182 |
- if (!check_to()) { |
|
269 |
+ |
|
270 |
+ if (!is_user("replicator") & !check_to()) { |
|
183 | 271 |
log("LOG: To Cheating attempt\n"); |
184 | 272 |
sl_send_reply("403", "That is ugly -- use To=id next time"); |
185 | 273 |
break; |
186 | 274 |
}; |
187 | 275 |
|
276 |
+ |
|
188 | 277 |
# update Contact database |
189 | 278 |
log("LOG: REGISTER is authorized, saving location\n"); |
190 | 279 |
save_contact("location"); |
... | ... |
@@ -201,7 +290,7 @@ route{ |
201 | 290 |
|
202 | 291 |
# ---------- CPL demo - begin -------------- |
203 | 292 |
/* added by Bogdan for cpl demo - Dorgham request*/ |
204 |
- if (uri=~"sip:test@.*" && method=="INVITE") |
|
293 |
+ if (uri=~"sip:test@.*" & method=="INVITE") |
|
205 | 294 |
{ |
206 | 295 |
log("SER : runing CPL!! :)\n"); |
207 | 296 |
if ( !cpl_run_script() ) |
... | ... |
@@ -222,23 +311,25 @@ route{ |
222 | 311 |
}; |
223 | 312 |
# -------------- CPL demo - end ------------- |
224 | 313 |
# ---------- forking demo2 - begin -------------- |
225 |
- if (uri=~"sip:cebit@.*" && method=="INVITE") { |
|
314 |
+ if (uri=~"sip:cebit@.*" & method=="INVITE") { |
|
226 | 315 |
# Cisco phone on Jiri's desktop; Caution: DHCP address, |
227 | 316 |
# subject to change |
228 |
- seturi("sip:qwe@195.37.78.129"); |
|
317 |
+ seturi("sip:cebit@195.37.78.242"); |
|
229 | 318 |
# Jiri's desktop PC; Caution: DHCP address, |
230 | 319 |
# subject to change |
231 |
- t_fork_to_uri("sip:cebit@195.37.78.126"); |
|
320 |
+ # t_fork_to_uri("sip:cebit@195.37.78.126"); |
|
232 | 321 |
# gateway address; Caution: is PSTN number changes, it must |
233 | 322 |
# on the list of free destination bellow; otherwise the |
234 | 323 |
# caller will be challenged! |
235 |
- #t_fork_to_uri("sip:001795061546@195.37.77.110"); |
|
236 |
- t_fork_to_uri( "sip:0016097265544@195.37.77.110"); |
|
324 |
+ t_fork_to_uri("sip:001795061546@195.37.77.110"); |
|
325 |
+ #t_fork_to_uri( "sip:0016097265544@195.37.77.110"); |
|
237 | 326 |
|
238 | 327 |
|
239 | 328 |
t_fork_on_no_response("sip:cebit@mail.iptel.org"); |
240 | 329 |
|
241 | 330 |
t_relay(); |
331 |
+#XX |
|
332 |
+#{ sl_reply_error(); break; } |
|
242 | 333 |
break; |
243 | 334 |
}; |
244 | 335 |
# ---------- forking demo2 - end -------------- |
... | ... |
@@ -263,12 +354,14 @@ route{ |
263 | 354 |
}; |
264 | 355 |
|
265 | 356 |
# requests from gateway should be RR-ed too |
266 |
- if (src_ip==195.37.77.110 && method=="INVITE") { |
|
357 |
+ if (src_ip==195.37.77.110 & method=="INVITE") { |
|
267 | 358 |
addRecordRoute(); |
268 | 359 |
}; |
269 | 360 |
|
270 | 361 |
# we now know we may, we know where, let it go out now! |
271 | 362 |
t_relay(); |
363 |
+#XX |
|
364 |
+#{ sl_reply_error(); break; } |
|
272 | 365 |
} |
273 | 366 |
|
274 | 367 |
# routing logic for outbound requests targeted out of our domain |
... | ... |
@@ -301,13 +394,16 @@ route[2] { |
301 | 394 |
}; |
302 | 395 |
|
303 | 396 |
t_relay(); |
397 |
+#XX |
|
398 |
+#{ sl_reply_error(); break; } |
|
304 | 399 |
} |
305 | 400 |
|
306 | 401 |
# logic for calls through our PSTN gateway |
307 | 402 |
route[3] { |
308 | 403 |
# free call destinations ... no authentication needed |
309 | 404 |
if (uri=~"sip:001795061546@.*" | uri=~"sip:0016097265544.*" |
310 |
- | uri=~"sip:[79][0-9][0-9][0-9]@.*") { |
|
405 |
+ | uri=~"sip:[79][0-9][0-9][0-9]@.*" |
|
406 |
+ | uri=~"sip:98[0-9][0-9][0-9][0-9]") { |
|
311 | 407 |
log("LOG: Free PSTN\n"); |
312 | 408 |
# let's log free calls for now too ... |
313 | 409 |
setflag(1); |
... | ... |
@@ -387,4 +483,33 @@ route[3] { |
387 | 483 |
|
388 | 484 |
|
389 | 485 |
t_relay(); |
486 |
+#XX |
|
487 |
+#{ sl_reply_error(); break; } |
|
390 | 488 |
} |
489 |
+ |
|
490 |
+/* |
|
491 |
+ |
|
492 |
+if (! t_newtran()) { |
|
493 |
+ # # retransmit whatever we have |
|
494 |
+ t_retransmit_reply(); |
|
495 |
+} else { |
|
496 |
+ # do what you want to do |
|
497 |
+ if (send_sms()) { |
|
498 |
+ # things went well, send ok upstream |
|
499 |
+ if (!t_send_reply("200", "yes sir, SMS sent over")) { |
|
500 |
+ # if replying failed, retry statelessly |
|
501 |
+ sl_reply_error(); |
|
502 |
+ }; |
|
503 |
+ } else { |
|
504 |
+ if (!t_send_reply("500", "SMS error :-(")) { |
|
505 |
+ # if replying failed, retry statelessly |
|
506 |
+ sl_reply_error(); |
|
507 |
+ }; |
|
508 |
+ }; |
|
509 |
+ # transaction concluded -- junk it now |
|
510 |
+ t_release(); |
|
511 |
+} |
|
512 |
+t_unref(); |
|
513 |
+ |
|
514 |
+*/ |
|
515 |
+ |
... | ... |
@@ -320,13 +320,13 @@ int t_forward_ack( struct sip_msg* p_msg ) |
320 | 320 |
} |
321 | 321 |
#endif |
322 | 322 |
|
323 |
- /* check for bizzar race condition if two processes receive |
|
324 |
- two ACKs concurrently; use shmem semaphore for protection |
|
325 |
- -- we have to enter it here anyway (the trick with inACKed |
|
326 |
- inside the protection region) */ |
|
323 |
+ /* we relay an ACK for second time, hmmm -- noticable; anyway, |
|
324 |
+ keep relaying; it may be for example spiraled ACK mistakenly |
|
325 |
+ matching the first transaction in second cycle (there is |
|
326 |
+ no way to distinguish) */ |
|
327 | 327 |
if (T->uas.isACKed ) { |
328 | 328 |
LOG(L_WARN,"Warning: ACK received when there's one; check upstream\n"); |
329 |
- return 1; |
|
329 |
+ /* return 1; */ |
|
330 | 330 |
} |
331 | 331 |
ack = shm_malloc( len ); |
332 | 332 |
memcpy(ack , buf , len); |
... | ... |
@@ -372,7 +372,7 @@ int forward_serial_branch(struct cell* Trans,int branch) |
372 | 372 |
shm_free_lump(b); |
373 | 373 |
} |
374 | 374 |
|
375 |
- DBG("DEBUG: t_forward_serial_branch: building req for branch" |
|
375 |
+ LOG(L_ERR,"DEBUG: t_forward_serial_branch: building req for branch" |
|
376 | 376 |
"%d; uri=|%.*s|.\n", branch, Trans->uac[branch].uri.len, |
377 | 377 |
Trans->uac[branch].uri.s); |
378 | 378 |
/* updates the new uri*/ |